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-10-07 13:42:53
|
Revision: 484 http://svn.sourceforge.net/gridarta/?rev=484&view=rev Author: christianhujer Date: 2006-10-07 06:41:41 -0700 (Sat, 07 Oct 2006) Log Message: ----------- Moved unified classes (GameObjectContainer, MapSquare) from crossfire / daimonin to gridarta. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/crossfire/src/cfeditor/map/MapModel.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMapFileEncode.java trunk/daimonin/src/daieditor/CMapTileList.java trunk/daimonin/src/daieditor/CMapViewBasic.java trunk/daimonin/src/daieditor/CopyBuffer.java trunk/daimonin/src/daieditor/ReplaceDialog.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gui/ConnectionView.java trunk/daimonin/src/daieditor/gui/ErrorListView.java trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java trunk/daimonin/src/daieditor/gui/map/tools/DeletionTool.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/MapModelEvent.java trunk/daimonin/src/daieditor/map/validation/DelegatingMapValidator.java trunk/daimonin/src/daieditor/map/validation/GameObjectsValidationError.java trunk/daimonin/src/daieditor/map/validation/MapValidationError.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/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/ExitChecker.java trunk/daimonin/src/daieditor/map/validation/checks/SquareWithoutFloorChecker.java trunk/daimonin/src/daieditor/map/validation/checks/SquareWithoutFloorError.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/map/MapModel.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gameobject/GameObjectContainer.java trunk/src/app/net/sf/gridarta/gameobject/RecursiveGameObjectIterator.java trunk/src/app/net/sf/gridarta/map/MapSquare.java Removed Paths: ------------- trunk/crossfire/src/cfeditor/gameobject/GameObjectContainer.java trunk/crossfire/src/cfeditor/gameobject/RecursiveGameObjectIterator.java trunk/crossfire/src/cfeditor/map/MapSquare.java trunk/daimonin/src/daieditor/gameobject/GameObjectContainer.java trunk/daimonin/src/daieditor/gameobject/RecursiveGameObjectIterator.java trunk/daimonin/src/daieditor/map/MapSquare.java Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2006-10-07 11:38:41 UTC (rev 483) +++ trunk/crossfire/src/cfeditor/CMainView.java 2006-10-07 13:41:41 UTC (rev 484) @@ -307,7 +307,7 @@ // now try to get the topmost object GameObject arch = null; if (pmap.isPointValid(pmap.getMapView().getHighlightStart())) { - arch = pmap.getMapModel().getMapSquare(pmap.getMapView().getHighlightStart()).getFirst(); + arch = (GameObject) pmap.getMapModel().getMapSquare(pmap.getMapView().getHighlightStart()).getFirst(); } if (arch != null) { // so here we return the arch from the pickmap Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-10-07 11:38:41 UTC (rev 483) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-10-07 13:41:41 UTC (rev 484) @@ -31,16 +31,15 @@ import cfeditor.IGUIConstants; import cfeditor.MultiArchData; import cfeditor.ScriptArchData; -import cfeditor.map.MapSquare; import java.io.BufferedReader; import java.io.IOException; import java.io.StringReader; import java.util.Collections; import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import javax.swing.JList; +import net.sf.gridarta.gameobject.GameObjectContainer; +import net.sf.gridarta.map.MapSquare; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -50,7 +49,7 @@ * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -public class GameObject extends GameObjectContainer implements Cloneable, net.sf.gridarta.gameobject.GameObject, Iterable<GameObject> { +public class GameObject extends net.sf.gridarta.gameobject.GameObject<GameObject> implements Cloneable, Iterable<GameObject> { private static final Logger log = Logger.getLogger(GameObject.class); @@ -154,7 +153,7 @@ * <li>A MapSquare, which means that this GameObject is top level on that MapSquare.</li> * </ul> */ - private GameObjectContainer container; + private GameObjectContainer<GameObject> container; /** * All inventory objects. Set to {@link Collections#EMPTY_LIST} @@ -224,13 +223,6 @@ this.archetype = archetype; } - /** {@inheritDoc} - * @note DO NOT INVOKE DIRECTLY YET! - */ - public void setArchetype(final net.sf.gridarta.gameobject.GameObject archetype) { - this.archetype = (GameObject) archetype; - } - /** {@inheritDoc} */ public boolean isArchetype() { return archetype == this; @@ -454,32 +446,18 @@ return isInContainer() ? ((GameObject) container).getTopContainer() : this; } - /** - * Sets container of this GameObject. - * There are two possibilities for the container: - * <ul> - * <li>Another GameObject, which means this object is in the inventory of that GameObject.</li> - * <li>A MapSquare, which means that this GameObject is top level on that MapSquare.</li> - * </ul> - * @param container container of this GameObject. - */ - public void setContainer(final GameObjectContainer container) { + /** {@inheritDoc} */ + public void setContainer(final GameObjectContainer<GameObject> container) { this.container = container; } - /** - * Check whether this GameObject is in a Container (in Daimonin sense, - * which means being in a MapSquare isn't, but being in an GameObject is). - * @return <code>true</code> if this GameObject has a Container and the - * Container is an GameObject, otherwise (no Container or Container is not - * an GameObject) false - */ + /** {@inheritDoc} */ public boolean isInContainer() { return container != null && container instanceof GameObject; } /** {@inheritDoc} */ - @Override public MapSquare getMapSquare() { + @Override public MapSquare<GameObject> getMapSquare() { return container != null ? container.getMapSquare() : null; } Deleted: trunk/crossfire/src/cfeditor/gameobject/GameObjectContainer.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObjectContainer.java 2006-10-07 11:38:41 UTC (rev 483) +++ trunk/crossfire/src/cfeditor/gameobject/GameObjectContainer.java 2006-10-07 13:41:41 UTC (rev 484) @@ -1,427 +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 cfeditor.gameobject; - -import cfeditor.map.MapSquare; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Base class for classes that contain GameObjects as children in the sense of containment. - * The interface serves 2 main purposes: - * <ul> - * <li>{@link GameObject} extends this class for containing other GameObjects, like inventory contents e.g. of a bag or attached events.</li> - * <li>{@link MapSquare} extends this class to list the tiles on a MapSquare.</li> - * </ul> - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @todo: In case of MapSquares, this class is most likely bogus regarding multipart objects. This needs to be fixed. - */ -@SuppressWarnings({"ClassReferencesSubclass"}) -public abstract class GameObjectContainer implements Iterable<GameObject>, Serializable { - - /** Serial Version. */ - private static final long serialVersionUID = 1L; - - /** - * The contents of this container. - * @note the order of this container is bottom to top. - */ - @NotNull private List<GameObject> contents; - - /** Iterable implementation for recursice traversal. */ - @NotNull private transient Iterable<GameObject> recursive; - - /** Iterable implementation for reverse traversal. */ - @NotNull private transient Iterable<GameObject> reverse; - - /** Create a new GameObjectContainer. */ - protected GameObjectContainer() { - initData(); - } - - /** - * Initialize the fields. - * This is needed because there are two ways of object construction, - * <ul> - * <li>regular object construction via constructor invocation and</li> - * <li>cloning of objects via {@link #clone()}.</li> - * </ul> - */ - private void initData() { - contents = new ArrayList<GameObject>(); - recursive = new Iterable<GameObject>() { - /** {@inheritDoc} */ - public Iterator<GameObject> iterator() { - return new RecursiveGameObjectIterator(GameObjectContainer.this); - } - }; - reverse = new Iterable<GameObject>() { - /** {@inheritDoc} */ - public Iterator<GameObject> iterator() { - return new ReverseIterator<GameObject>(contents); - } - }; // Iterable<GameObject> reverse - } - - /** - * {@inheritDoc} - * The Iterator returned does not recurse, it only contains objects on the first level. - * The Iterator returned is transparent, that means modifying the iterator's collection actually modifies the underlying GameObjectContainer. - */ - @NotNull public final Iterator<GameObject> iterator() { - // Do not return contents.iterator() directly because otherwise the remove() operation will not properly unlink the removed GameObject from its container. - return new Iterator<GameObject>() { - - /** The basic iterator. */ - private Iterator<GameObject> delegate = contents.iterator(); - private GameObject current; - - /** {@inheritDoc} */ - public boolean hasNext() { - return delegate.hasNext(); - } - - /** {@inheritDoc} */ - public GameObject next() { - return current = delegate.next(); - } - - /** {@inheritDoc} */ - public void remove() { - // keep this in sync with GameObjectContainer#remove(GameObject) - // we can't simply invoke GameObjectContainer#remove(current) because that would result in a ConcurrentModificationException. - delegate.remove(); - current.setContainer(null); - squareChanged(); - } - }; - } - - /** - * Return an object that is the reverse representation. - * Invoke this method if you want to iterate over the contained GameObjects in reverse order. - * @return reverse representation - */ - @NotNull public final Iterable<GameObject> reverse() { - return reverse; - } - - /** - * Return an object that is a recursive representation. - * Invoke this method if you want to iterate over the contained GameObjects recursively. - * @return recursive representation - */ - @NotNull public final Iterable<GameObject> recursive() { - return recursive; - } - - /** - * Check whether this square is empty. - * @return <code>true</code> if this square is empty, otherwise <code>false</code> - */ - public boolean isEmpty() { - return contents.isEmpty(); - } - - /** - * Return the first GameObject contained in this container. - * @return first GameObject contained or <code>null</code> if {@link #isEmpty()} returns <code>true</code> - */ - @Nullable public final GameObject getFirst() { - return contents.isEmpty() ? null : contents.get(0); - } - - /** - * Return the last GameObject contained in this container. - * You should not invoke this method to iterate over GameObjects, such invocation is regarded deprecated. - * @return last GameObject contained or <code>null</code> if {@link #isEmpty()} returns <code>true</code> - */ - @Nullable public final GameObject getLast() { - return contents.isEmpty() ? null : contents.get(contents.size() - 1); - } - - /** - * Remove a GameObject from this container. - * @param gameObject GameObject to remove - * @throws IllegalArgumentException if <var>gameObject</var> isn't in this container - */ - final void remove(@NotNull final GameObject gameObject) { - // keep this in sync with iterator() - if (!contents.remove(gameObject)) { - throw new IllegalArgumentException(gameObject + " wasn't inside container " + this); - } - gameObject.setContainer(null); - squareChanged(); - } - - /** Remove all GameObjects from this container. */ - public final void removeAll() { - if (contents.size() <= 0) { - return; - } - - for (final GameObject gameObject : contents) { - gameObject.setContainer(null); - } - contents.clear(); - squareChanged(); - } - - /** - * Move an item to top. - * @param gameObject item to move to top - * @throws IllegalArgumentException if <var>gameObject</var> isn't in this container - */ - public final void moveTop(@NotNull final GameObject gameObject) { - final int oldIndex = contents.indexOf(gameObject); - if (oldIndex != contents.size() - 1) { - if (!contents.remove(gameObject)) { - throw new IllegalArgumentException(gameObject + " wasn't inside container " + this); - } - contents.add(gameObject); - squareChanged(); - } - } - - /** - * Move an item up. - * @param gameObject item to move up - * @throws IllegalArgumentException if <var>gameObject</var> isn't in this container - */ - public final void moveUp(@NotNull final GameObject gameObject) { - final int oldIndex = contents.indexOf(gameObject); - if (oldIndex < contents.size() - 1) { - if (!contents.remove(gameObject)) { - throw new IllegalArgumentException(gameObject + " wasn't inside container " + this); - } - contents.add(oldIndex + 1, gameObject); - squareChanged(); - } - } - - /** - * Move an item down. - * @param gameObject item to move down - * @throws IllegalArgumentException if <var>gameObject</var> isn't in this container - */ - public final void moveDown(@NotNull final GameObject gameObject) { - final int oldIndex = contents.indexOf(gameObject); - if (oldIndex > 0) { - if (!contents.remove(gameObject)) { - throw new IllegalArgumentException(gameObject + " wasn't inside container " + this); - } - contents.add(oldIndex - 1, gameObject); - squareChanged(); - } - } - - /** - * Move an item to bottom. - * @param gameObject item to move to bottom - * @throws IllegalArgumentException if <var>gameObject</var> isn't in this container - */ - public final void moveBottom(@NotNull final GameObject gameObject) { - final int oldIndex = contents.indexOf(gameObject); - if (oldIndex != 0) { - if (!contents.remove(gameObject)) { - throw new IllegalArgumentException(gameObject + " wasn't inside container " + this); - } - contents.add(0, gameObject); - squareChanged(); - } - } - - /** - * Get the X coordinate on the map. - * @return X coordinate on map - */ - public abstract int getMapX(); - - /** - * Get the Y coordinate on the map. - * @return Y coordinate on map - */ - public abstract int getMapY(); - - /** - * Add the given GameObject at the end of this Container. - * @param gameObject the free yet unlinked <code>GameObject</code> to be placed in the inventory - * @throws IllegalArgumentException if <var>gameObject</var> already is inside another container - */ - public void addLast(@NotNull final GameObject gameObject) { - if (gameObject.isInContainer()) { - throw new IllegalArgumentException("Can't add " + gameObject + " to " + this + " because it's already inside " + gameObject.getContainer()); - } - contents.add(gameObject); - gameObject.setContainer(this); - squareChanged(); - } - - /** - * Add the given GameObject at the end of this Container. - * @param gameObject the free yet unlinked <code>GameObject</code> to be placed in the inventory - * @throws IllegalArgumentException if <var>gameObject</var> already is inside another container - */ - public void addFirst(@NotNull final GameObject gameObject) { - if (gameObject.isInContainer()) { - throw new IllegalArgumentException("Can't add " + gameObject + " to " + this + " because it's already inside " + gameObject.getContainer()); - } - contents.add(0, gameObject); - gameObject.setContainer(this); - squareChanged(); - } - - /** - * Add a GameObject after another. - * @param previousGameObject previous anchor - * @param newGameObject GameObject to insert - * @throws IllegalArgumentException if <var>newGameObject</var> already is inside another container or <var>previousGameObject</var> isn't inside this container - */ - public void insertAfter(@NotNull final GameObject previousGameObject, @NotNull final GameObject newGameObject) { - if (newGameObject.isInContainer()) { - throw new IllegalArgumentException("Can't add " + newGameObject + " to " + this + " because it's already inside " + newGameObject.getContainer()); - } - final int insertIndex = contents.indexOf(previousGameObject); - if (insertIndex == -1) { - throw new IllegalArgumentException("Can't insert " + newGameObject + " after " + previousGameObject + " because that isn't inside " + this); - } - contents.add(insertIndex, newGameObject); - newGameObject.setContainer(this); - squareChanged(); - } - - /** - * Add a GameObject before another. - * @param newGameObject GameObject to insert - * @param nextGameObject nextGameObject anchor - * @throws IllegalArgumentException if <var>newGameObject</var> already is inside another container or <var>prev</var> isn't inside this container - */ - public void insertBefore(@NotNull final GameObject newGameObject, @NotNull final GameObject nextGameObject) { - if (newGameObject.isInContainer()) { - throw new IllegalArgumentException("Can't add " + newGameObject + " to " + this + " because it's already inside " + newGameObject.getContainer()); - } - final int insertIndex = contents.indexOf(nextGameObject); - if (insertIndex == -1) { - throw new IllegalArgumentException("Can't insert " + newGameObject + " before " + nextGameObject + " because that isn't inside " + this); - } - contents.add(insertIndex + 1, newGameObject); - newGameObject.setContainer(this); - squareChanged(); - } - - /** - * Replace an GameObject with another one. - * @param oldGameObject old GameObject to be replaced - * @param newGameObject new GameObject that replaces oldGameObject - * @throws IllegalArgumentException if <var>oldGameObject</var> isn't in this container - */ - public void replace(@NotNull final GameObject oldGameObject, @NotNull final GameObject newGameObject) { - final int insertIndex = contents.indexOf(oldGameObject); - if (insertIndex == -1) { - throw new IllegalArgumentException(oldGameObject + " wasn't inside container " + this); - } - contents.remove(oldGameObject); - oldGameObject.setContainer(null); - contents.add(insertIndex, newGameObject); - newGameObject.setContainer(this); - squareChanged(); - } - - /** - * Get the MapSquare of this GameObjectContainer. - * @return MapSquare of this GameObjectContainer or <code>null</code> if this GameObjectContainer is not (yet?) connected to a map (a {@link MapSquare} would return itself) - */ - @Nullable public abstract MapSquare getMapSquare(); - - /** - * Tell the model that this MapSquare has changed. - * This method must be invoked by all other methods that change something. - */ - protected final void squareChanged() { - final MapSquare square = getMapSquare(); - if (square != null) { - square.getModel().squareChanged(square); - } - } - - /** {@inheritDoc} */ - @NotNull @Override protected GameObjectContainer clone() throws CloneNotSupportedException { - try { - final GameObjectContainer clone = (GameObjectContainer) super.clone(); - clone.initData(); - return clone; - } catch (final CloneNotSupportedException e) { - assert false; - throw new AssertionError(); - } - } - - /** {@inheritDoc} */ - // writeObject() is not required because this class doesn't require special handling during serialization. - private void readObject(final ObjectInputStream stream) throws IOException, ClassNotFoundException { - stream.defaultReadObject(); - // initialize transients - initData(); - } - - /** - * An iterator for iterating over a list in reverse order. - * @todo move this class to JAPI - */ - private static class ReverseIterator<T> implements Iterator<T> { - - /** The iterator used for delegation. */ - @NotNull private final ListIterator<T> delegate; - - /** - * Create a reverse iterator. - * @param list to iterate over in reverse order - */ - public ReverseIterator(final List<T> list) { - delegate = list.listIterator(list.size()); - } - - /** {@inheritDoc} */ - public boolean hasNext() { - return delegate.hasPrevious(); - } - - /** {@inheritDoc} */ - @NotNull public T next() { - return delegate.previous(); - } - - /** {@inheritDoc} */ - public void remove() { - delegate.remove(); - } - - } // class ReverseIterator - -} // interface GameObjectContainer Deleted: trunk/crossfire/src/cfeditor/gameobject/RecursiveGameObjectIterator.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/RecursiveGameObjectIterator.java 2006-10-07 11:38:41 UTC (rev 483) +++ trunk/crossfire/src/cfeditor/gameobject/RecursiveGameObjectIterator.java 2006-10-07 13:41:41 UTC (rev 484) @@ -1,58 +0,0 @@ -package cfeditor.gameobject; - -import java.util.EmptyStackException; -import java.util.Iterator; -import java.util.Stack; - -/** - * Iterator for recursively iterating over ArchObjectContainers. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -class RecursiveGameObjectIterator implements Iterator<GameObject> { - - /** The Iterator stack. */ - private Stack<Iterator<GameObject>> iteratorStack = new Stack<Iterator<GameObject>>(); - - /** The current iterator. */ - private Iterator<GameObject> current; - - /** - * Create a recursive GameObject Iterator. - * @param container GameObjectContainer to start with - */ - RecursiveGameObjectIterator(final GameObjectContainer container) { - current = container.iterator(); - } - - /** {@inheritDoc} */ - public boolean hasNext() { - return current.hasNext(); - } - - /** {@inheritDoc} */ - public GameObject next() { - final GameObject arch = current.next(); - try { - return arch; - } finally { - if (!arch.isEmpty()) { - iteratorStack.push(current); - current = arch.iterator(); - } else { - try { - while (!current.hasNext() ) { - current = iteratorStack.pop(); - } - } catch (final EmptyStackException e) { - /* ignore. */ - } - } - } - } - - /** {@inheritDoc} */ - public void remove() { - current.remove(); - } - -} // class RecursiveGameObjectIterator Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-10-07 11:38:41 UTC (rev 483) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-10-07 13:41:41 UTC (rev 484) @@ -38,6 +38,7 @@ import java.util.List; import java.util.NoSuchElementException; import net.sf.gridarta.Size2D; +import net.sf.gridarta.map.MapSquare; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -58,7 +59,7 @@ * The map, containing all arches grid-wise. * Index: [width][height] */ - private MapSquare[][] mapGrid; + private MapSquare<GameObject>[][] mapGrid; /** Size of this map. */ private Size2D mapSize; @@ -92,7 +93,7 @@ } /** Iterator for iterating over all squares of a model. */ - private class MapSquareIterator implements Iterator<MapSquare> { + private class MapSquareIterator implements Iterator<MapSquare<GameObject>> { /** * Index of current map square. @@ -116,9 +117,9 @@ } /** {@inheritDoc} */ - public MapSquare next() { + public MapSquare<GameObject> next() { try { - final MapSquare square = mapGrid[point / mapSize.getHeight()][point % mapSize.getHeight()]; + final MapSquare<GameObject> square = mapGrid[point / mapSize.getHeight()][point % mapSize.getHeight()]; point++; return square; } catch (final ArrayIndexOutOfBoundsException e) { @@ -207,12 +208,12 @@ } /** {@inheritDoc} */ - public Iterator<MapSquare> iterator() { + public Iterator<MapSquare<GameObject>> iterator() { return new MapSquareIterator(); } /** {@inheritDoc} */ - public MapSquare getMapSquare(final Point p) throws ArrayIndexOutOfBoundsException { + public MapSquare<GameObject> getMapSquare(final Point p) throws ArrayIndexOutOfBoundsException { return mapGrid[p.x][p.y]; } @@ -870,7 +871,7 @@ // Now the critical step: create an GameObject array of new dimension, // copy all objects and set it to replace the current one. - final MapSquare[][] newGrid = new MapSquare[newSize.getWidth()][newSize.getHeight()]; + 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++) { @@ -878,7 +879,7 @@ if (x < mapSize.getWidth() && y < mapSize.getHeight()) { newGrid[x][y] = mapGrid[x][y]; } else { - newGrid[x][y] = new MapSquare(this, x, y); + newGrid[x][y] = new MapSquare<GameObject>(this, x, y); } } } @@ -1014,7 +1015,7 @@ */ /** {@inheritDoc} */ - public void squareChanged(final MapSquare square) { + public void squareChanged(@NotNull final MapSquare<GameObject> square) { } /** Modified: trunk/crossfire/src/cfeditor/map/MapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapModel.java 2006-10-07 11:38:41 UTC (rev 483) +++ trunk/crossfire/src/cfeditor/map/MapModel.java 2006-10-07 13:41:41 UTC (rev 484) @@ -5,12 +5,13 @@ import java.util.Iterator; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import net.sf.gridarta.map.MapSquare; /** * Interface for MapModels. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public interface MapModel extends net.sf.gridarta.map.MapModel { +public interface MapModel extends net.sf.gridarta.map.MapModel<GameObject> { /** Enable autojoin when inserting objects. */ boolean JOIN_ENABLE = true; @@ -19,7 +20,7 @@ boolean JOIN_DISABLE = false; /** {@inheritDoc} */ - Iterator<MapSquare> iterator(); + Iterator<MapSquare<GameObject>> iterator(); /** * Get the square at a specified location. @@ -27,7 +28,7 @@ * @return square at <var>p</var> * @throws ArrayIndexOutOfBoundsException in case p specifies a location that's not valid within this map model */ - MapSquare getMapSquare(Point p) throws ArrayIndexOutOfBoundsException; + MapSquare<GameObject> getMapSquare(Point p) throws ArrayIndexOutOfBoundsException; @Nullable Point getMouseRightPos(); @@ -71,13 +72,8 @@ void setFileName(String strFileName); - /** - * Method to notify the model that a map square was changed. - * 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. - * @param square MapSquare that has changed - */ - void squareChanged(@NotNull MapSquare square); + /** {@inheritDoc} */ + void squareChanged(@NotNull MapSquare<GameObject> square); MapArchObject getMapArchObject(); Deleted: trunk/crossfire/src/cfeditor/map/MapSquare.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapSquare.java 2006-10-07 11:38:41 UTC (rev 483) +++ trunk/crossfire/src/cfeditor/map/MapSquare.java 2006-10-07 13:41:41 UTC (rev 484) @@ -1,90 +0,0 @@ -/* - * Daimonin 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.map; - -import cfeditor.gameobject.GameObject; -import cfeditor.gameobject.GameObjectContainer; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * A single Map Square. - * This class is implemented in a way that changes via some modifier methods in a map square will automatically fire events in the associated MapModel. - * A MapSquare always knows its model. - * It's not possible to create a MapSquare that is not associated to a model. - * - * <p>The objects are stored bottom to top: {@link #getFirst()} returns the - * object at the bottom, {@link #getLast()} returns the object at the top of - * the tile. - * - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public class MapSquare extends GameObjectContainer { - - /** The MaoModel this square is associated with. */ - @NotNull private final MapModel model; - - /** The X Coordinate of this map square within the model's grid. */ - private final int x; - - /** The Y Coordinate of this map square within the model's grid. */ - private final int y; - - /** - * Creates a new instance of MapSquare. - * @param model MapModel for this MapSquare - * @param x X Coordinate of this map square within the model's grid - * @param y Y Coordinate of this map square within the model's grid - */ - MapSquare(@NotNull final MapModel model, final int x, final int y) { - this.model = model; - this.x = x; - this.y = y; - } - - /** - * Get the MapModel. - * @return MapModel - */ - @NotNull public MapModel getModel() { - return model; - } - - /** {@inheritDoc} */ - @Override public final int getMapX() { - return x; - } - - /** {@inheritDoc} */ - @Override public final int getMapY() { - return y; - } - - /** {@inheritDoc} */ - @Override @NotNull public final MapSquare getMapSquare() { - return this; - } - -} // class MapSquare Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-10-07 11:38:41 UTC (rev 483) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-10-07 13:41:41 UTC (rev 484) @@ -53,7 +53,6 @@ import daieditor.map.MapModel; import daieditor.map.MapModelEvent; import daieditor.map.MapModelListener; -import daieditor.map.MapSquare; import daieditor.map.validation.DefaultErrorCollector; import daieditor.map.validation.DelegatingMapValidator; import daieditor.map.validation.ErrorCollector; @@ -115,6 +114,7 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.gui.HideFileFilterProxy; 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; @@ -2052,7 +2052,7 @@ /** {@inheritDoc} */ public void mapSquaresChanged(final MapModelEvent e) { if (prefs.getBoolean(PREFS_VALIDATOR_AUTO, PREFS_VALIDATOR_AUTO_DEFAULT)) { - final MapSquare[] squares = e.getSquares(); + final MapSquare<GameObject>[] squares = e.getSquares(); if (squares != null) { final ErrorCollector errorCollector = new DefaultErrorCollector(); validators.validate(squares, errorCollector); Modified: trunk/daimonin/src/daieditor/CMapFileEncode.java =================================================================== --- trunk/daimonin/src/daieditor/CMapFileEncode.java 2006-10-07 11:38:41 UTC (rev 483) +++ trunk/daimonin/src/daieditor/CMapFileEncode.java 2006-10-07 13:41:41 UTC (rev 484) @@ -27,13 +27,13 @@ import daieditor.gameobject.GameObject; import daieditor.map.MapArchObject; import daieditor.map.MapModel; -import daieditor.map.MapSquare; import java.awt.Point; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Formatter; import net.sf.gridarta.Size2D; +import net.sf.gridarta.map.MapSquare; import net.sf.gridarta.io.IOUtils; /** @@ -83,7 +83,7 @@ } // y } // x - for (final MapSquare square : mapModel) { + for (final MapSquare<GameObject> square : mapModel) { final int x = square.getMapX(); final int y = square.getMapY(); for (final GameObject node : square) { Modified: trunk/daimonin/src/daieditor/CMapTileList.java =================================================================== --- trunk/daimonin/src/daieditor/CMapTileList.java 2006-10-07 11:38:41 UTC (rev 483) +++ trunk/daimonin/src/daieditor/CMapTileList.java 2006-10-07 13:41:41 UTC (rev 484) @@ -27,7 +27,6 @@ import daieditor.gameobject.GameObject; import daieditor.map.MapControl; -import daieditor.map.MapSquare; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; @@ -54,6 +53,7 @@ import javax.swing.event.ListSelectionListener; import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapCursorListener; +import net.sf.gridarta.map.MapSquare; import net.sf.japi.swing.ActionFactory; import static net.sf.japi.swing.ActionFactory.getFactory; import net.sf.japi.swing.ActionMethod; @@ -86,7 +86,7 @@ private int listCounter; /** The currently selected MapSquare. */ - private transient MapSquare currentSquare; + private transient MapSquare<GameObject> currentSquare; /** Build Panel */ public CMapTileList(final CMainControl mainControl, final CMainView mainView) { Modified: trunk/daimonin/src/daieditor/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-10-07 11:38:41 UTC (rev 483) +++ trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-10-07 13:41:41 UTC (rev 484) @@ -31,7 +31,6 @@ import daieditor.map.MapModel; import daieditor.map.MapModelEvent; import daieditor.map.MapModelListener; -import daieditor.map.MapSquare; import daieditor.map.validation.ErrorCollector; import daieditor.map.validation.ErrorHandler; import daieditor.map.validation.ValidationError; @@ -50,6 +49,7 @@ 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; @@ -105,7 +105,7 @@ private final MapView frame; /** The MapSquares that are known to contain errors. */ - private Map<MapSquare, ValidationError> erraneousMapSquares = new HashMap<MapSquare, ValidationError>(); + private Map<MapSquare<GameObject>, ValidationError> erraneousMapSquares = new HashMap<MapSquare<GameObject>, ValidationError>(); /** The ArchObjects that are known to contain errors. */ private Map<GameObject,ValidationError> erraneousArchObjects = new HashMap<GameObject,ValidationError>(); @@ -250,7 +250,7 @@ * @return cursor square or <code>null</code> if no current cursor * @see #getCursorPosition() */ - @Nullable public MapSquare getCursorSquare() { + @Nullable public MapSquare<GameObject> getCursorSquare() { try { return mapModel.getMapSquare(getCursorPosition()); } catch (final ArrayIndexOutOfBoundsException e) { @@ -288,8 +288,8 @@ * Get the selected squares. * @return selected squares */ - public List<MapSquare> getSelectedSquares() { - final List<MapSquare> selection = new ArrayList<MapSquare>(); + public List<MapSquare<GameObject>> getSelectedSquares() { + final List<MapSquare<GameObject>> selection = new ArrayList<MapSquare<GameObject>>(); final Size2D mapSize = mapModel.getMapSize(); final Point pos = new Point(); for (pos.x = 0; pos.x < mapSize.getWidth(); pos.x++) { @@ -389,7 +389,7 @@ erraneousArchObjects.clear(); mapGrid.clearErrors(); for (ValidationError validationError : errors.getErrors()) { - final MapSquare mapSquare = validationError.getMapSquare(); + final MapSquare<GameObject> mapSquare = validationError.getMapSquare(); final GameObject archObject = validationError.getGameObject(); if (mapSquare != null) { erraneousMapSquares.put(mapSquare, validationError); Modified: trunk/daimonin/src/daieditor/CopyBuffer.java =================================================================== --- trunk/daimonin/src/daieditor/CopyBuffer.java 2006-10-07 11:38:41 UTC (rev 483) +++ trunk/daimonin/src/daieditor/CopyBuffer.java 2006-10-07 13:41:41 UTC (rev 484) @@ -29,12 +29,12 @@ import daieditor.map.MapArchObject; import daieditor.map.MapControl; import daieditor.map.MapModel; -import daieditor.map.MapSquare; import java.awt.Point; import java.awt.Rectangle; import java.util.ArrayList; import java.util.List; import net.sf.gridarta.Size2D; +import net.sf.gridarta.map.MapSquare; import org.jetbrains.annotations.Nullable; /** @@ -150,7 +150,7 @@ final Point offset = selRec.getLocation(); mapControl.getMapModel().beginTransaction(); final List<GameObject> archesToDelete = new ArrayList<GameObject>(); - for (final MapSquare square : mapControl.getMapViewFrame().getView().getSelectedSquares()) { + for (final MapSquare<GameObject> square : mapControl.getMapViewFrame().getView().getSelectedSquares()) { final int posx = square.getMapX(); final int posy = square.getMapY(); for (final GameObject arch : square) { @@ -200,7 +200,7 @@ mapControl.getMapModel().beginTransaction(); final Point pos = new Point(); assert copyMap != null; - for (final MapSquare square : copyMap) { + for (final MapSquare<GameObject> square : copyMap) { pos.setLocation(startp.x + square.getMapX(), startp.y + square.getMapY()); // paste the archs if on the map: if (mapControl.isPointValid(pos)) { @@ -214,7 +214,7 @@ } assert copyMapCtrl != null; - for (final MapSquare square : copyMapCtrl.getMapModel()) { + for (final MapSquare<GameObject> square : copyMapCtrl.getMapModel()) { pos.setLocation(startp); pos.translate(square.getMapX(), square.getMapY()); if (mapControl.isPointValid(pos)) { // paste the archs if on the map: @@ -295,7 +295,7 @@ 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 (GameObject node : map.getMapSquare(pos)) { + for (final GameObject node : map.getMapSquare(pos)) { // only non multi suckers if (!node.isTail()) { @@ -341,11 +341,11 @@ return null; } final MapViewIFrame mapViewIFrame = mapControl.getMapViewFrame(); - final Iterable<MapSquare> mapSquares; + final Iterable<MapSquare<GameObject>> mapSquares; if (mapViewIFrame == null) { mapSquares = mapControl.getAllSquares(); } else { - final List<MapSquare> selectedMapSquares = mapViewIFrame.getView().getSelectedSquares(); + final List<MapSquare<GameObject>> selectedMapSquares = mapViewIFrame.getView().getSelectedSquares(); if (selectedMapSquares.size() == 0) { mapSquares = mapControl.getAllSquares(); } else { @@ -353,7 +353,7 @@ } } final List<GameObject> objects = new ArrayList<GameObject>(max); - for (final MapSquare mapSquare : mapSquares) { + for (final MapSquare<GameObject> mapSquare : mapSquares) { for (final GameObject node : mapSquare) { if (!node.isTail()) { objects.add(node); Modified: trunk/daimonin/src/daieditor/ReplaceDialog.java =================================================================== --- trunk/daimonin/src/daieditor/ReplaceDialog.java 2006-10-07 11:38:41 UTC (rev 483) +++ trunk/daimonin/src/daieditor/ReplaceDialog.java 2006-10-07 13:41:41 UTC (rev 484) @@ -27,7 +27,6 @@ import daieditor.gameobject.GameObject; import daieditor.map.MapControl; -import daieditor.map.MapSquare; import java.awt.FlowLayout; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; @@ -47,6 +46,7 @@ import static javax.swing.WindowConstants.HIDE_ON_CLOSE; 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. @@ -313,8 +313,8 @@ assert mapViewIFrame != null; int replaceCount = 0; final int replaceListSize = replaceList == null ? 0 : replaceList.size(); - for (MapSquare square : entireMap ? mapControl.getMapModel() : mapViewIFrame.getView().getSelectedSquares()) { - for (GameObject node : square) { + for (final MapSquare<GameObject> square : entireMap ? mapControl.getMapModel() : mapViewIFrame.getView().getSelectedSquares()) { + for (final GameObject node : square) { if (!node.isMulti() && (matchCriteria == MATCH_ARCH_NAME && node.getArchetypeName() != null && node.getArchetypeName().equalsIgnoreCase(matchString) || matchCriteria == MATCH_OBJ_NAME && node.getBestName().equalsIgnoreCase(matchString))) { Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2006-10-07 11:38:41 UTC (rev 483) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2006-10-07 13:41:41 UTC (rev 484) @@ -34,12 +34,13 @@ import daieditor.ScriptArchData; import daieditor.gameobject.anim.AnimationObject; import daieditor.gameobject.anim.AnimationObjects; -import daieditor.map.MapSquare; import java.io.Serializable; import javax.swing.ImageIcon; import javax.swing.JList; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import net.sf.gridarta.gameobject.GameObjectContainer; +import net.sf.gridarta.map.MapSquare; /** * The <code>GameObject</code> class handles the Daimonin GameObjects. @@ -54,7 +55,7 @@ * normal arches. * @todo this class is not always the best place for multipart object handling, see also {@link GameObjectContainer} for issues about this */ -public final class GameObject /*extends NamedObject*/ extends GameObjectContainer implements Cloneable, net.sf.gridarta.gameobject.GameObject, Serializable { +public final class GameObject /*extends NamedObject*/ extends net.sf.gridarta.gameobject.GameObject<GameObject> implements Cloneable, Serializable { /** Serial Version. */ private static final long serialVersionUID = 1L; @@ -164,7 +165,7 @@ * <li>A MapSquare, which means that this GameObject is top level on that MapSquare.</li> * </ul> */ - private GameObjectContainer container; + private GameObjectContainer<GameObject> container; private int archType; // CF object type of the arch @@ -202,11 +203,6 @@ this.archetype = archetype; } - /** {@inheritDoc} */ - public void setArchetype(final net.sf.gridarta.gameobject.GameObject archetype) { - this.archetype = (GameObject) archetype; - } - /** Set this to default arch. */ public void setIsArchetype() { this.archetype = this; @@ -431,32 +427,18 @@ return isInContainer() ? ((GameObject) container).getTopContainer() : this; } - /** - * Sets container of this GameObject. - * There are two possibilities for the container: - * <ul> - * <li>Another GameObject, which means this object is in the inventory of that GameObject.</li> - * <li>A MapSquare, which means that this GameObject is top level on that MapSquare.</li> - * </ul> - * @param container container of this GameObject. - */ - public void setContainer(final GameObjectContainer container) { + /** {@inheritDoc} */ + public void setContainer(final GameObjectContainer<GameObject> container) { this.container = container; } - /** - * Check whether this GameObject is in a Container (in Daimonin sense, - * which means being in a MapSquare isn't, but being in an GameObject is). - * @return <code>true</code> if this GameObject has a Container and the - * Container is an GameObject, otherwise (no Container or Container is not - * an GameObject) false - */ + /** {@inheritDoc} */ public boolean isInContainer() { return container != null && container instanceof GameObject; } /** {@inheritDoc} */ - @Override public MapSquare getMapSquare() { + @Override public MapSquare<GameObject> getMapSquare() { return container != null ? container.getMapSquare() : null; } Deleted: trunk/daimonin/src/daieditor/gameobject/GameObjectContainer.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObjectContainer.java 2006-10-07 11:38:41 UTC (rev 483) +++ trunk/daimonin/src/daieditor/gameobject/GameObjectContainer.java 2006-10-07 13:41:41 UTC (rev 484) @@ -1,427 +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.gameobject; - -import daieditor.map.MapSquare; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Base class for classes that contain GameObjects as children in the sense of containment. - * The interface serves 2 main purposes: - * <ul> - * <li>{@link GameObject} extends this class for containing other GameObjects, like inventory contents e.g. of a bag or attached events.</li> - * <li>{@link MapSquare} extends this class to list the tiles on a MapSquare.</li> - * </ul> - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @todo: In case of MapSquares, this class is most likely bogus regarding multipart objects. This needs to be fixed. - */ -@SuppressWarnings({"ClassReferencesSubclass"}) -public abstract class GameObjectContainer implements Iterable<GameObject>, Serializable { - - /** Serial Version. */ - private static final long serialVersionUID = 1L; - - /** - * The contents of this container. - * @note the order of this container is bottom to top. - */ - @NotNull private List<GameObject> contents; - - /** Iterable implementation for recursice traversal. */ - @NotNull private transient Iterable<GameObject> recursive; - - /** Iterable implementation for reverse traversal. */ - @NotNull private transient Iterable<GameObject> reverse; - - /** Create a new GameObjectContainer. */ - protected GameObjectContainer() { - initData(); - } - - /** - * Initialize the fields. - * This is needed because there are two ways of object construction, - * <ul> - * <li>regular object construction via constructor invocation and</li> - * <li>cloning of objects via {@link #clone()}.</li> - * </ul> - */ - private void initData() { - contents = new ArrayList<GameObject>(); - recursive = new Iterable<GameObject>() { - /** {@inheritDoc} */ - public Iterator<GameObject> iterator() { - return new RecursiveGameObjectIterator(GameObjectContainer.this); - } - }; - reverse = new Iterable<GameObject>() { - /** {@inheritDoc} */ - public Iterator<GameObject> iterator() { - return new ReverseIterator<GameObject>(contents); - } - }; // Iterable<GameObject> reverse - } - - /** - * {@inheritDoc} - * The Iterator returned does not recurse, it only contains objects on the first level. - * The Iterator returned is transparent, that means modifying the iterator's collection actually modifies the underlying GameObjectContainer. - */ - @NotNull public final Iterator<GameObject> iterator() { - // Do not return contents.iterator() directly because otherwise the remove() operation will not properly unlink the removed GameObject from its container. - return new Iterator<GameObject>() { - - /** The basic iterator. */ - private Iterator<GameObject> delegate = contents.iterator(); - private GameObject current; - - /** {@inheritDoc} */ - public boolean hasNext() { - return delegate.hasNext(); - } - - /** {@inheritDoc} */ - public GameObject next() { - return current = delegate.next(); - } - - /** {@inheritDoc} */ - public void remove() { - // keep this in sync with GameObjectContainer#remove(GameObject) - // we can't simply invoke GameObjectContainer#remove(current) because that would result in a ConcurrentModificationException. - delegate.remove(); - current.setContainer(null); - squareChanged(); - } - }; - } - - /** - * Return an object that is the reverse representation. - * Invoke this method if you want to iterate over the contained GameObjects in reverse order. - * @return reverse representation - */ - @NotNull public final Iterable<GameObject> reverse() { - return reverse; - } - - /** - * Return an object that is a recursive representation. - * Invoke this method if you want to iterate over the contained GameObjects recursively. - * @return recursive representation - */ - @NotNull public final Iterable<GameObject> recursive() { - return recursive; - } - - /** - * Check whether this square is empty. - * @return <code>true</code> if this square is empty, otherwise <code>false</code> - */ - public boolean isEmpty() { - return contents.isEmpty(); - } - - /** - * Return the first GameObject contained in this container. - * @return first GameObject contained or <code>null</code> if {@link #isEmpty()} returns <code>true</code> - */ - @Nullable public final GameObject getFirst() { - return contents.isEmpty() ? null : contents.get(0); - } - - /** - * Return the last GameObject contained in this container. - * You should not invoke this method to iterate over GameObjects, such invocation is regarded deprecated. - * @return last GameObject contained or <code>null</code> if {@link #isEmpty()} returns <code>true</code> - */ - @Nullable public final GameObject getLast() { - return contents.isEmpty() ? null : contents.get(contents.size() - 1); - } - - /** - * Remove a GameObject from this container. - * @param gameObject GameObject to remove - * @throws IllegalArgumentException if <var>gameObject</var> isn't in this container - */ - final void remove(@NotNull final GameObject gameObject) { - // keep this in sync with iterator() - if (!contents.remove(gameObject)) { - throw new IllegalArgumentException(gameObject + " wasn't inside container " + this); - } - gameObject.setContainer(null); - squareChanged(); - } - - /** Remove all GameObjects from this container. */ - public final void removeAll() { - if (contents.size() <= 0) { - return; - } - - for (final GameObject gameObject : contents) { - gameObject.setContainer(null); - } - contents.clear(); - squareChanged(); - } - - /** - * Move an item to top. - * @param gameObject item to move to top - * @throws IllegalArgumentException if <var>gameObject</var> isn't in this container - */ - public final void moveTop(@NotNull final GameObject gameObject) { - final int oldIndex = contents.indexOf(gameObject); - if (oldIndex != contents.size() - 1) { - if (!contents.remove(gameObject)) { - throw new IllegalArgumentException(gameObject + " wasn't inside container " + this); - } - contents.add(gameObject); - squareChanged(); - } - } - - /** - * Move an item up. - * @param gameObject item to move up - * @throws IllegalArgumentException if <var>gameObject</var> isn't in this container - */ - public final void moveUp(@NotNull final GameObject gameObject) { - final int oldIndex = contents.indexOf(gameObject); - if (oldIndex < contents.size() - 1) { - if (!contents.remove(gameObject)) { - throw new IllegalArgumentException(gameObject + " wasn't inside container " + this); - } - contents.add(oldIndex + 1, gameObject); - squareChanged(); - } - } - - /** - * Move an item down. - * @param gameObject item to move down - * @throws IllegalArgumentException if <var>gameObject</var> isn't in this container - */ - public final void moveDown(@NotNull final GameObject gameObject) { - final int oldIndex = contents.indexOf(gameObject); - if (oldIndex > 0) { - if (!contents.remove(gameObject)) { - throw new IllegalArgumentException(gameObject + " wasn't inside container " + this); - } - contents.add(oldIndex - 1, gameObject); - squareChanged(); - } - } - - /** - * Move an item to bottom. - * @param gameObject item to move to bottom - * @throws IllegalArgumentException if <var>gameObject</var> isn't in this container - */ - public final void moveBottom(@NotNull final GameObject gameObject) { - final int oldIndex = contents.indexOf(gameObject); - if (oldIndex != 0) { - if (!contents.remove(gameObject)) { - throw new IllegalArgumentException(ga... [truncated message content] |
From: <chr...@us...> - 2006-10-07 11:38:47
|
Revision: 483 http://svn.sourceforge.net/gridarta/?rev=483&view=rev Author: christianhujer Date: 2006-10-07 04:38:41 -0700 (Sat, 07 Oct 2006) Log Message: ----------- Minor improvement / unification: no square change event if removing contents of an empty container. Modified Paths: -------------- trunk/daimonin/src/daieditor/gameobject/GameObjectContainer.java Modified: trunk/daimonin/src/daieditor/gameobject/GameObjectContainer.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObjectContainer.java 2006-10-07 11:25:23 UTC (rev 482) +++ trunk/daimonin/src/daieditor/gameobject/GameObjectContainer.java 2006-10-07 11:38:41 UTC (rev 483) @@ -182,6 +182,10 @@ /** Remove all GameObjects from this container. */ public final void removeAll() { + if (contents.size() <= 0) { + return; + } + for (final GameObject gameObject : contents) { gameObject.setContainer(null); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-07 11:25:27
|
Revision: 482 http://svn.sourceforge.net/gridarta/?rev=482&view=rev Author: christianhujer Date: 2006-10-07 04:25:23 -0700 (Sat, 07 Oct 2006) Log Message: ----------- Clarified documentation of getMapX() and getMapY(). 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-10-07 11:17:50 UTC (rev 481) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-10-07 11:25:23 UTC (rev 482) @@ -213,7 +213,7 @@ /** * 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. + * This method only guarantees a reasonable value for GameObjects that are directly bound to a map (i.e. {@link #getTopContainer()} returns <code>null</code>). * Implementations may also return reasonable values for GameObjects inside containers, but they are not required to do so. * @return X coordinate on map * @see #getMapY() @@ -222,7 +222,7 @@ /** * Get the Y coordinate of this GameObject on its map. - * This method only guarantees a reasonable value for GameObjects that are directly bound to a 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>). * Implementations may also return reasonable values for GameObjects inside containers, but they are not required to do so. * @return Y coordinate on map * @see #getMapX() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-07 11:17:55
|
Revision: 481 http://svn.sourceforge.net/gridarta/?rev=481&view=rev Author: christianhujer Date: 2006-10-07 04:17:50 -0700 (Sat, 07 Oct 2006) Log Message: ----------- Clarified documentation of createArch(). 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-10-06 19:54:47 UTC (rev 480) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-10-07 11:17:50 UTC (rev 481) @@ -232,6 +232,8 @@ /** * Create a new GameObject from this Archetype. * If this GameObject is not an Archetype, this method recursively forwards to its Archetype. + * This means that the newly created GameObject will not reflect any differences / attributes specific to this GameObject. + * The newly created GameObject will be based on the Archetype only. * @return new GameObject */ GameObject createArch(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-06 19:54:53
|
Revision: 480 http://svn.sourceforge.net/gridarta/?rev=480&view=rev Author: christianhujer Date: 2006-10-06 12:54:47 -0700 (Fri, 06 Oct 2006) Log Message: ----------- Final fix for Mantis #0000475: Regression: Grid Visibility doesn't work Modified Paths: -------------- trunk/daimonin/src/daieditor/CMainControl.java Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-10-06 19:47:14 UTC (rev 479) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-10-06 19:54:47 UTC (rev 480) @@ -850,6 +850,7 @@ */ public void setGridVisible(final boolean gridVisible) { this.gridVisible = gridVisible; + refreshCurrentMap(); } /** Invoked when user wants to begin editing a new (empty) map. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-06 19:47:21
|
Revision: 479 http://svn.sourceforge.net/gridarta/?rev=479&view=rev Author: christianhujer Date: 2006-10-06 12:47:14 -0700 (Fri, 06 Oct 2006) Log Message: ----------- Partly fix for Mantis #0000475: Regression: Grid Visibility doesn't work Modified Paths: -------------- trunk/daimonin/src/daieditor/CMapViewBasic.java trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java Modified: trunk/daimonin/src/daieditor/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-10-06 19:36:45 UTC (rev 478) +++ trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-10-06 19:47:14 UTC (rev 479) @@ -183,14 +183,6 @@ } /** - * is the map grid visible? - * @return true if map grid is visible - */ - public boolean isGridVisible() { - return renderer.isGridVisible(); - } - - /** * is there a highlighted area in this mapview? * @return true if there is a highlighted area */ @@ -216,14 +208,6 @@ } /** - * Sets whether the map grid should be shown. - * @param gridVisibility set to <code>true</code> if the map should be painted with grid, otherwise <code>false</code> - */ - public void setGridVisibility(final boolean gridVisibility) { - renderer.setGridVisibility(gridVisibility); - } - - /** * Returns the controller of this view. * @return The controller of this view. */ Modified: trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2006-10-06 19:36:45 UTC (rev 478) +++ trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2006-10-06 19:47:14 UTC (rev 479) @@ -95,8 +95,6 @@ /** The ArchObjects that are known to contain errors. */ private Map<GameObject,ValidationError> erraneousArchObjects; - private boolean gridVisibility; - /** Used to avoid creation millions of points */ private final Point tmpPoint = new Point(); @@ -411,7 +409,7 @@ * @param grfx Graphics for painting */ private void paintGrid(final Graphics grfx) { - if (gridVisibility) { + if (mainControl.isGridVisible()) { // draw iso grid grfx.setColor(Color.black); @@ -469,17 +467,6 @@ repaint(); } - public boolean isGridVisible() { - return gridVisibility; - } - - public void setGridVisibility(final boolean gridVisibility) { - if (this.gridVisibility != gridVisibility) { - this.gridVisibility = gridVisibility; - repaint(); - } - } - /** * Set draw mode * @param paintOnlyMap <code>true</code>: grid and selections will not be painted This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-06 19:36:51
|
Revision: 478 http://svn.sourceforge.net/gridarta/?rev=478&view=rev Author: christianhujer Date: 2006-10-06 12:36:45 -0700 (Fri, 06 Oct 2006) Log Message: ----------- Added the term Gridarta to the website to fix bogus google ranking (the gridarta homepage should be listed before the CIA project page). Modified Paths: -------------- trunk/src/doc/start.xhtml Modified: trunk/src/doc/start.xhtml =================================================================== --- trunk/src/doc/start.xhtml 2006-10-06 19:34:12 UTC (rev 477) +++ trunk/src/doc/start.xhtml 2006-10-06 19:36:45 UTC (rev 478) @@ -35,14 +35,14 @@ You can also access the <a href="subversion">latest source code through subversion</a>. <!--To <em>download Gridarta</em>, go to the <a href="http://sourceforge.net/project/showfiles.php?group_id=166996">Files section of the Gridarta Project Page</a>, choose the desired package, release and file type and download it from a mirror of your choice.--> </p> - <h2>Documentation</h2> + <h2>Gridarta Documentation</h2> <ul> - <li><a href="news/">Project News</a></li> - <li><a href="dev/">Developer Documentation</a> Information for Gridarta Developers</li> + <li><a href="news/">Gridarta Project News</a></li> + <li><a href="dev/">Gridarta Developer Documentation</a> Information for Gridarta Developers</li> <li><a href="subversion">Accessing Gridarta's Subversion Repository</a></li> <li><a href="history">History of Gridarta</a></li> </ul> - <h2>Contact the developers</h2> + <h2>Contact the Gridarta developers</h2> <ul> <li> You may visit the <a href="http://sourceforge.net/projects/gridarta">Gridarta Project Page at SourceForge</a> or send mail to <a href="mailto:ch...@ri...">ch...@ri...</a>. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-06 19:34:31
|
Revision: 477 http://svn.sourceforge.net/gridarta/?rev=477&view=rev Author: christianhujer Date: 2006-10-06 12:34:12 -0700 (Fri, 06 Oct 2006) Log Message: ----------- Improved documentation of and naming in the map change event system. Modified Paths: -------------- trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMapViewBasic.java trunk/daimonin/src/daieditor/gui/ConnectionView.java trunk/daimonin/src/daieditor/map/MapControl.java trunk/daimonin/src/daieditor/map/MapModelEvent.java trunk/daimonin/src/daieditor/map/MapModelListener.java Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-10-03 19:06:40 UTC (rev 476) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-10-06 19:34:12 UTC (rev 477) @@ -2062,9 +2062,9 @@ } /** {@inheritDoc} */ - public void mapArchesChanged(final MapModelEvent e) { + public void mapObjectsChanged(final MapModelEvent e) { if (prefs.getBoolean(PREFS_VALIDATOR_AUTO, PREFS_VALIDATOR_AUTO_DEFAULT)) { - final GameObject[] arches = e.getArches(); + final GameObject[] arches = e.getGameObjects(); if (arches != null) { final ErrorCollector errorCollector = new DefaultErrorCollector(); validators.validate(arches, errorCollector); Modified: trunk/daimonin/src/daieditor/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-10-03 19:06:40 UTC (rev 476) +++ trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-10-06 19:34:12 UTC (rev 477) @@ -386,7 +386,7 @@ } /** {@inheritDoc} */ - public void mapArchesChanged(final MapModelEvent e) { + public void mapObjectsChanged(final MapModelEvent e) { repaint(); // TODO: only repaint a specific region } Modified: trunk/daimonin/src/daieditor/gui/ConnectionView.java =================================================================== --- trunk/daimonin/src/daieditor/gui/ConnectionView.java 2006-10-03 19:06:40 UTC (rev 476) +++ trunk/daimonin/src/daieditor/gui/ConnectionView.java 2006-10-06 19:34:12 UTC (rev 477) @@ -70,7 +70,7 @@ } /** {@inheritDoc} */ - public void mapArchesChanged(final MapModelEvent e) { + public void mapObjectsChanged(final MapModelEvent e) { scanMapForConnections(e.getMap()); } Modified: trunk/daimonin/src/daieditor/map/MapControl.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapControl.java 2006-10-03 19:06:40 UTC (rev 476) +++ trunk/daimonin/src/daieditor/map/MapControl.java 2006-10-06 19:34:12 UTC (rev 477) @@ -45,7 +45,6 @@ import java.util.List; import javax.imageio.ImageIO; import javax.swing.ImageIcon; -import net.sf.gridarta.UndoAndRedo; import net.sf.gridarta.Size2D; import net.sf.gridarta.gui.map.MapCursor; import net.sf.gridarta.gui.map.MapGrid; @@ -672,7 +671,7 @@ } /** {@inheritDoc} */ - public void mapArchesChanged(final MapModelEvent e) { + public void mapObjectsChanged(final MapModelEvent e) { changed = true; } Modified: trunk/daimonin/src/daieditor/map/MapModelEvent.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapModelEvent.java 2006-10-03 19:06:40 UTC (rev 476) +++ trunk/daimonin/src/daieditor/map/MapModelEvent.java 2006-10-06 19:34:12 UTC (rev 477) @@ -3,6 +3,7 @@ * 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) * @@ -27,101 +28,104 @@ import daieditor.gameobject.GameObject; import java.util.EventObject; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; /** * Class for Map events. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @todo to improve speed, the event should also be capable of reporting the changed arches + * @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. */ - private final MapModel map; + @NotNull private final MapModel map; /** The squares that have changed. */ - private final MapSquare[] squares; + @Nullable private final MapSquare[] squares; - /** The arches that have been changed. */ - private final GameObject[] arches; + /** The GameObjects that have been changed. */ + @Nullable private final GameObject[] gameObjects; /** The type of this event. */ - private Type type; + @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(final MapModel map, final Type type) { + 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 + * @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(final MapModel map, final Type type, final MapSquare... squares) { + public MapModelEvent(@NotNull final MapModel map, @NotNull final Type type, @NotNull final MapSquare... 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 arches ArchObjects that have changed + * @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(final MapModel map, final Type type, final GameObject... arches) { - this(map, type, null, arches); + 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 - * @param arches ArchObjects that have changed + * @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(final MapModel map, final Type type, final MapSquare[] squares, final GameObject[] arches) { + public MapModelEvent(@NotNull final MapModel map, @NotNull final Type type, @Nullable final MapSquare[] squares, @Nullable final GameObject[] gameObjects) { super(map); this.map = map; this.type = type; this.squares = squares; - this.arches = arches; + this.gameObjects = gameObjects; } /** - * Get the map that's changed by this event. - * @return map that's changed by this event + * Returns the map that's changed by this event. + * @return The map that's changed by this event. */ public MapModel getMap() { return map; } /** - * Get the Squares that have been changed by this event. - * @return squares that have been changed or <code>null</code> if the change did not affect specific squares + * 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. */ - public MapSquare[] getSquares() { + @Nullable public MapSquare[] getSquares() { return squares; } /** - * Get the Arches that have been changed by this event. - * @return arches that have been changed or <code>null</code> if the change did not affect specific arches + * 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. */ - public GameObject[] getArches() { - return arches; + @Nullable public GameObject[] getGameObjects() { + return gameObjects; } /** - * Get the type of this event. - * @return type of this event + * Returns the type of this event. + * @return The type of this event. */ - public Type getType() { + @NotNull public Type getType() { return type; } @@ -133,13 +137,13 @@ /** * A Square has changed. - * This is used when new arches were added, arches were removed or the order of arches inside 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, /** - * Arch inside a Square have changed. - * This is used when the attributes of one or more arches were changed. + * GameObjects inside a Square have changed. + * This is used when the attributes of one or more GameObjects were changed. */ ARCHES_CHANGED Modified: trunk/daimonin/src/daieditor/map/MapModelListener.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapModelListener.java 2006-10-03 19:06:40 UTC (rev 476) +++ trunk/daimonin/src/daieditor/map/MapModelListener.java 2006-10-06 19:34:12 UTC (rev 477) @@ -3,6 +3,7 @@ * 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) * @@ -28,27 +29,41 @@ import java.util.EventListener; /** - * Interface for listeners listening on MapEvents. + * Interface for listeners listening on {@link MapModelEvent}s. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ public interface MapModelListener extends EventListener { /** - * Map size has changed. + * The size of a map has changed. * @param e EventObject with event information */ void mapSizeChanged(MapModelEvent e); /** - * Map Squares have changed. + * 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); /** - * Map Arches have changed. + * 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 mapArchesChanged(MapModelEvent e); + void mapObjectsChanged(MapModelEvent e); } // interface MapModelListener This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-03 19:07:29
|
Revision: 476 http://svn.sourceforge.net/gridarta/?rev=476&view=rev Author: christianhujer Date: 2006-10-03 12:06:40 -0700 (Tue, 03 Oct 2006) Log Message: ----------- Clarified naming (archetype vs. gameObject) for map validation. Modified Paths: -------------- trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMapViewBasic.java trunk/daimonin/src/daieditor/map/validation/DelegatingMapValidator.java trunk/daimonin/src/daieditor/map/validation/MapValidationError.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/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/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/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 Added Paths: ----------- 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/checks/DoubleTypeChecker.java trunk/daimonin/src/daieditor/map/validation/checks/DoubleTypeError.java Removed Paths: ------------- trunk/daimonin/src/daieditor/map/validation/ArchValidationError.java trunk/daimonin/src/daieditor/map/validation/ArchValidator.java trunk/daimonin/src/daieditor/map/validation/ArchesValidationError.java trunk/daimonin/src/daieditor/map/validation/checks/DoubleArchChecker.java trunk/daimonin/src/daieditor/map/validation/checks/DoubleArchError.java Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-10-03 18:42:15 UTC (rev 475) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-10-03 19:06:40 UTC (rev 476) @@ -60,7 +60,7 @@ import daieditor.map.validation.checks.BlockedMobOrSpawnPointChecker; import daieditor.map.validation.checks.ConnectedInsideContainerChecker; import daieditor.map.validation.checks.ConnectedPickableChecker; -import daieditor.map.validation.checks.DoubleArchChecker; +import daieditor.map.validation.checks.DoubleTypeChecker; import daieditor.map.validation.checks.DoubleLayerChecker; import daieditor.map.validation.checks.EmptySpawnPointChecker; import daieditor.map.validation.checks.ExitChecker; @@ -326,7 +326,7 @@ new BlockedMobOrSpawnPointChecker(), new ConnectedInsideContainerChecker(), new ConnectedPickableChecker(), - new DoubleArchChecker(), + new DoubleTypeChecker(), new DoubleLayerChecker(), new EmptySpawnPointChecker(), new ExitChecker(), Modified: trunk/daimonin/src/daieditor/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-10-03 18:42:15 UTC (rev 475) +++ trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-10-03 19:06:40 UTC (rev 476) @@ -406,7 +406,7 @@ mapGrid.clearErrors(); for (ValidationError validationError : errors.getErrors()) { final MapSquare mapSquare = validationError.getMapSquare(); - final GameObject archObject = validationError.getArchObject(); + final GameObject archObject = validationError.getGameObject(); if (mapSquare != null) { erraneousMapSquares.put(mapSquare, validationError); mapGrid.setError(mapSquare.getMapX(), mapSquare.getMapY()); Deleted: trunk/daimonin/src/daieditor/map/validation/ArchValidationError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/ArchValidationError.java 2006-10-03 18:42:15 UTC (rev 475) +++ trunk/daimonin/src/daieditor/map/validation/ArchValidationError.java 2006-10-03 19:06:40 UTC (rev 476) @@ -1,49 +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.validation; - -import daieditor.gameobject.GameObject; - -/** - * Class for validation errors related to an GameObject. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public class ArchValidationError extends SquareValidationError { - - /** The GameObject which caused the error. */ - private final GameObject arch; - - /** - * Create an ArchValidationError. - * @param archObject the arch on which the error occurred - */ - public ArchValidationError(final GameObject archObject) { - super(archObject.getMapSquare()); - this.arch = archObject; - } - - /** {@inheritDoc} */ - @Override public GameObject getArchObject() { - return arch; - } - -} // class ArchValidationError Deleted: trunk/daimonin/src/daieditor/map/validation/ArchValidator.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/ArchValidator.java 2006-10-03 18:42:15 UTC (rev 475) +++ trunk/daimonin/src/daieditor/map/validation/ArchValidator.java 2006-10-03 19:06:40 UTC (rev 476) @@ -1,40 +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.validation; - -import daieditor.gameobject.GameObject; - -/** - * Interface for GameObject Validators. - * To create a ArchValidator, implement this interface. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public interface ArchValidator extends Validator { - - /** - * Validate an arch object. - * @param archObject GameObject to validate - * @param errorCollector Error collector to report errors to - */ - void validate(GameObject archObject, ErrorCollector errorCollector); - -} // interface ArchValidator Deleted: trunk/daimonin/src/daieditor/map/validation/ArchesValidationError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/ArchesValidationError.java 2006-10-03 18:42:15 UTC (rev 475) +++ trunk/daimonin/src/daieditor/map/validation/ArchesValidationError.java 2006-10-03 19:06:40 UTC (rev 476) @@ -1,64 +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.validation; - -import daieditor.gameobject.GameObject; -import daieditor.map.MapSquare; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * Class for validation errors related to more than a single GameObject. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public class ArchesValidationError extends SquareValidationError implements Iterable<GameObject> { - - /** The GameObject which caused the error. */ - private final List<GameObject> archObjects = new ArrayList<GameObject>(); - - /** - * Create an ArchValidationError. - * @param mapSquare the square on which the error occurred - * @param archObjects the arch on which the error occurred - */ - public ArchesValidationError(final MapSquare mapSquare, final GameObject... archObjects) { - super(mapSquare); - for (GameObject archObject : archObjects) { - this.archObjects.add(archObject); - } - } - - /** - * Add another arch that is erraneous. - * @param archObject erraneous arch - */ - public void addArchObject(final GameObject archObject) { - archObjects.add(archObject); - } - - /** {@inheritDoc} */ - public Iterator<GameObject> iterator() { - return archObjects.iterator(); - } - -} // class ArchValidationError Modified: trunk/daimonin/src/daieditor/map/validation/DelegatingMapValidator.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/DelegatingMapValidator.java 2006-10-03 18:42:15 UTC (rev 475) +++ trunk/daimonin/src/daieditor/map/validation/DelegatingMapValidator.java 2006-10-03 19:06:40 UTC (rev 476) @@ -32,7 +32,7 @@ * A Map Validator that delegates to other MapValidators. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public class DelegatingMapValidator extends AbstractValidator implements ArchValidator, SquareValidator, MapValidator, Iterable<Validator> { +public class DelegatingMapValidator extends AbstractValidator implements GameObjectValidator, SquareValidator, MapValidator, Iterable<Validator> { /** Map Validators to validate against. */ private final List<Validator> validators = new ArrayList<Validator>(); @@ -108,12 +108,12 @@ } /** {@inheritDoc} */ - public void validate(final GameObject archObject, final ErrorCollector errorCollector) { + public void validate(final GameObject gameObject, final ErrorCollector errorCollector) { //final long start = currentTimeMillis(); //long next = start; for (final Validator validator : validators) { - if (validator.isEnabled() && validator instanceof ArchValidator) { - ((ArchValidator) validator).validate(archObject, errorCollector); + if (validator.isEnabled() && validator instanceof GameObjectValidator) { + ((GameObjectValidator) validator).validate(gameObject, errorCollector); //System.err.println("Single check " + validator.getClass().getName() + " took " + (-next + (next = currentTimeMillis())) + " milliseconds"); } } @@ -122,12 +122,12 @@ /** * Validate a set of arch objects. - * @param archObjects ArchObjects to validate + * @param gameObjects ArchObjects to validate * @param errorCollector Error collector to report errors to */ - public void validate(final GameObject[] archObjects, final ErrorCollector errorCollector) { - for (final GameObject archObject : archObjects) { - validate(archObject, errorCollector); + public void validate(final GameObject[] gameObjects, final ErrorCollector errorCollector) { + for (final GameObject gameObject : gameObjects) { + validate(gameObject, errorCollector); } } Copied: trunk/daimonin/src/daieditor/map/validation/GameObjectValidationError.java (from rev 475, trunk/daimonin/src/daieditor/map/validation/ArchValidationError.java) =================================================================== --- trunk/daimonin/src/daieditor/map/validation/GameObjectValidationError.java (rev 0) +++ trunk/daimonin/src/daieditor/map/validation/GameObjectValidationError.java 2006-10-03 19:06:40 UTC (rev 476) @@ -0,0 +1,49 @@ +/* + * 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.validation; + +import daieditor.gameobject.GameObject; + +/** + * Class for validation errors related to an GameObject. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class GameObjectValidationError extends SquareValidationError { + + /** The GameObject which caused the error. */ + private final GameObject gameObject; + + /** + * Create an GameObjectValidationError. + * @param gameObject the GameObject on which the error occurred + */ + public GameObjectValidationError(final GameObject gameObject) { + super(gameObject.getMapSquare()); + this.gameObject = gameObject; + } + + /** {@inheritDoc} */ + @Override public GameObject getGameObject() { + return gameObject; + } + +} // class GameObjectValidationError Property changes on: trunk/daimonin/src/daieditor/map/validation/GameObjectValidationError.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Copied: trunk/daimonin/src/daieditor/map/validation/GameObjectValidator.java (from rev 475, trunk/daimonin/src/daieditor/map/validation/ArchValidator.java) =================================================================== --- trunk/daimonin/src/daieditor/map/validation/GameObjectValidator.java (rev 0) +++ trunk/daimonin/src/daieditor/map/validation/GameObjectValidator.java 2006-10-03 19:06:40 UTC (rev 476) @@ -0,0 +1,40 @@ +/* + * 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.validation; + +import daieditor.gameobject.GameObject; + +/** + * Interface for GameObject Validators. + * To create a GameObjectValidator, implement this interface. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public interface GameObjectValidator extends Validator { + + /** + * Validate an arch object. + * @param gameObject GameObject to validate + * @param errorCollector Error collector to report errors to + */ + void validate(GameObject gameObject, ErrorCollector errorCollector); + +} // interface GameObjectValidator Property changes on: trunk/daimonin/src/daieditor/map/validation/GameObjectValidator.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Copied: trunk/daimonin/src/daieditor/map/validation/GameObjectsValidationError.java (from rev 475, trunk/daimonin/src/daieditor/map/validation/ArchesValidationError.java) =================================================================== --- trunk/daimonin/src/daieditor/map/validation/GameObjectsValidationError.java (rev 0) +++ trunk/daimonin/src/daieditor/map/validation/GameObjectsValidationError.java 2006-10-03 19:06:40 UTC (rev 476) @@ -0,0 +1,64 @@ +/* + * 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.validation; + +import daieditor.gameobject.GameObject; +import daieditor.map.MapSquare; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * Class for validation errors related to more than a single GameObject. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class GameObjectsValidationError extends SquareValidationError implements Iterable<GameObject> { + + /** The GameObjects which caused the error. */ + private final List<GameObject> gameObjects = new ArrayList<GameObject>(); + + /** + * Create an GameObjectValidationError. + * @param mapSquare the square on which the error occurred + * @param gameObjects the arch on which the error occurred + */ + public GameObjectsValidationError(final MapSquare mapSquare, final GameObject... gameObjects) { + super(mapSquare); + for (final GameObject gameObject : gameObjects) { + this.gameObjects.add(gameObject); + } + } + + /** + * Add another arch that is erraneous. + * @param gameObject erraneous arch + */ + public void addGameObject(final GameObject gameObject) { + gameObjects.add(gameObject); + } + + /** {@inheritDoc} */ + public Iterator<GameObject> iterator() { + return gameObjects.iterator(); + } + +} // class GameObjectValidationError Property changes on: trunk/daimonin/src/daieditor/map/validation/GameObjectsValidationError.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/daimonin/src/daieditor/map/validation/MapValidationError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/MapValidationError.java 2006-10-03 18:42:15 UTC (rev 475) +++ trunk/daimonin/src/daieditor/map/validation/MapValidationError.java 2006-10-03 19:06:40 UTC (rev 476) @@ -25,7 +25,7 @@ /** * Base Class for validation errors on maps. - * Though you could use this class directly, you'd probably want to extend the class or one of its subclasses like {@link SquareValidationError} or {@link ArchValidationError}. + * Though you could use this class directly, you'd probably want to extend the class or one of its subclasses like {@link SquareValidationError} or {@link GameObjectValidationError}. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ public class MapValidationError extends ValidationError { Modified: trunk/daimonin/src/daieditor/map/validation/ValidationError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/ValidationError.java 2006-10-03 18:42:15 UTC (rev 475) +++ trunk/daimonin/src/daieditor/map/validation/ValidationError.java 2006-10-03 19:06:40 UTC (rev 476) @@ -85,7 +85,7 @@ * The GameObject which caused the error. * @return GameObject that caused the error */ - @Nullable public GameObject getArchObject() { + @Nullable public GameObject getGameObject() { return null; } @@ -98,7 +98,7 @@ final MapSquare mapSquare = getMapSquare(); final int x = mapSquare != null ? mapSquare.getMapX() : -1; final int y = mapSquare != null ? mapSquare.getMapY() : -1; - final GameObject archObject = getArchObject(); + final GameObject archObject = getGameObject(); final String archName = archObject != null ? archObject.getBestName() : null; return ACTION_FACTORY.format(key + ".msg", ACTION_FACTORY.getString(key + ".title"), x, y, archName); } Modified: trunk/daimonin/src/daieditor/map/validation/checks/BlockedMobOrSpawnPointChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/BlockedMobOrSpawnPointChecker.java 2006-10-03 18:42:15 UTC (rev 475) +++ trunk/daimonin/src/daieditor/map/validation/checks/BlockedMobOrSpawnPointChecker.java 2006-10-03 19:06:40 UTC (rev 476) @@ -43,12 +43,12 @@ /** {@inheritDoc} */ public void validate(final MapSquare mapSquare, final ErrorCollector errorCollector) { - for (final GameObject archObject : mapSquare) { - final int archTypNr = archObject.getArchTypNr(); + for (final GameObject gameObject : mapSquare) { + final int archTypNr = gameObject.getArchTypNr(); if (archTypNr == 80 || archTypNr == 81) { - mobsOrSpawnPoints.add(archObject); - } else if (archObject.getAttributeInt("no_pass", true) == 1) { - blockers.add(archObject); + mobsOrSpawnPoints.add(gameObject); + } else if (gameObject.getAttributeInt("no_pass", true) == 1) { + blockers.add(gameObject); } } if (blockers.size() > 0 && mobsOrSpawnPoints.size() > 0) { Modified: trunk/daimonin/src/daieditor/map/validation/checks/BlockedMobOrSpawnPointError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/BlockedMobOrSpawnPointError.java 2006-10-03 18:42:15 UTC (rev 475) +++ trunk/daimonin/src/daieditor/map/validation/checks/BlockedMobOrSpawnPointError.java 2006-10-03 19:06:40 UTC (rev 476) @@ -33,17 +33,17 @@ */ public class BlockedMobOrSpawnPointError extends SquareValidationError implements CorrectableError { - /** Blocking arches. */ + /** Blocking GameObjects. */ private final Iterable<GameObject> blockers; - /** Mob or spawn arches. */ + /** Mob or spawn GameObjects. */ private final Iterable<GameObject> mobsOrSpawnPoints; /** * Create a BlockedMobOrSpawnPointError. * @param mapSquare the square on which the error occurred - * @param blockers blocking arches - * @param mobsOrSpawnPoints mob or spawn arches + * @param blockers blocking GameObjects + * @param mobsOrSpawnPoints mob or spawn GameObjects */ public BlockedMobOrSpawnPointError(final MapSquare mapSquare, final Iterable<GameObject> blockers, final Iterable<GameObject> mobsOrSpawnPoints) { super(mapSquare); @@ -52,16 +52,16 @@ } /** - * Get the blocking arches. - * @return blocking arches + * Get the blocking GameObjects. + * @return Blocking GameObjects. */ public Iterable<GameObject> getBlockers() { return blockers; } /** - * Get the mob or spawn point arches. - * @return mob or spawn point arches + * Get the mob or spawn point GameObjects. + * @return Mob or spawn point GameObjects. */ public Iterable<GameObject> getMobsOrSpawnPoints() { return mobsOrSpawnPoints; Modified: trunk/daimonin/src/daieditor/map/validation/checks/ConnectedInsideContainerChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/ConnectedInsideContainerChecker.java 2006-10-03 18:42:15 UTC (rev 475) +++ trunk/daimonin/src/daieditor/map/validation/checks/ConnectedInsideContainerChecker.java 2006-10-03 19:06:40 UTC (rev 476) @@ -23,21 +23,21 @@ import daieditor.gameobject.GameObject; import daieditor.map.validation.AbstractValidator; -import daieditor.map.validation.ArchValidator; +import daieditor.map.validation.GameObjectValidator; import daieditor.map.validation.ErrorCollector; /** - * An ArchValidator to assert that containers do not contain connected objects. + * An GameObjectValidator to assert that containers do not contain connected objects. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public class ConnectedInsideContainerChecker extends AbstractValidator implements ArchValidator { +public class ConnectedInsideContainerChecker extends AbstractValidator implements GameObjectValidator { /** {@inheritDoc} */ - public void validate(final GameObject archObject, final ErrorCollector errorCollector) { - final String connection = archObject.getAttributeString("connected", true); + public void validate(final GameObject gameObject, final ErrorCollector errorCollector) { + final String connection = gameObject.getAttributeString("connected", true); final boolean connected = connection != null && connection.length() > 0; - if (connected && archObject.isInContainer()) { - errorCollector.collect(new ConnectedInsideContainerError(archObject)); + if (connected && gameObject.isInContainer()) { + errorCollector.collect(new ConnectedInsideContainerError(gameObject)); } } Modified: trunk/daimonin/src/daieditor/map/validation/checks/ConnectedInsideContainerError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/ConnectedInsideContainerError.java 2006-10-03 18:42:15 UTC (rev 475) +++ trunk/daimonin/src/daieditor/map/validation/checks/ConnectedInsideContainerError.java 2006-10-03 19:06:40 UTC (rev 476) @@ -22,7 +22,7 @@ package daieditor.map.validation.checks; import daieditor.gameobject.GameObject; -import daieditor.map.validation.ArchValidationError; +import daieditor.map.validation.GameObjectValidationError; import daieditor.map.validation.CorrectableError; import java.awt.Component; @@ -30,20 +30,20 @@ * A MapValidator that checks for mobs outside spawn points. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public class ConnectedInsideContainerError extends ArchValidationError implements CorrectableError { +public class ConnectedInsideContainerError extends GameObjectValidationError implements CorrectableError { /** * Create a MobOutsideSpawnPointError. - * @param archObject the arch on which the error occurred + * @param gameObject the GameObject on which the error occurred */ - public ConnectedInsideContainerError(final GameObject archObject) { - super(archObject); + public ConnectedInsideContainerError(final GameObject gameObject) { + super(gameObject); } /** {@inheritDoc} */ public void correct(final Component parentComponent) { // TODO: Ask user - getArchObject().remove(); + getGameObject().remove(); } } // class ConnectedInsideContainerError Modified: trunk/daimonin/src/daieditor/map/validation/checks/ConnectedPickableChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/ConnectedPickableChecker.java 2006-10-03 18:42:15 UTC (rev 475) +++ trunk/daimonin/src/daieditor/map/validation/checks/ConnectedPickableChecker.java 2006-10-03 19:06:40 UTC (rev 476) @@ -23,22 +23,22 @@ import daieditor.gameobject.GameObject; import daieditor.map.validation.AbstractValidator; -import daieditor.map.validation.ArchValidator; +import daieditor.map.validation.GameObjectValidator; import daieditor.map.validation.ErrorCollector; /** * A Validator to assert that connected objects cannot be picked up. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public class ConnectedPickableChecker extends AbstractValidator implements ArchValidator { +public class ConnectedPickableChecker extends AbstractValidator implements GameObjectValidator { /** {@inheritDoc} */ - public void validate(final GameObject archObject, final ErrorCollector errorCollector) { - final boolean pickable = archObject.getAttributeInt("no_pick", true) == 0; - final String connection = archObject.getAttributeString("connected", true); + public void validate(final GameObject gameObject, final ErrorCollector errorCollector) { + final boolean pickable = gameObject.getAttributeInt("no_pick", true) == 0; + final String connection = gameObject.getAttributeString("connected", true); final boolean connected = connection != null && connection.length() > 0; if (connected && pickable) { - errorCollector.collect(new ConnectedPickableError(archObject)); + errorCollector.collect(new ConnectedPickableError(gameObject)); } } Modified: trunk/daimonin/src/daieditor/map/validation/checks/ConnectedPickableError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/ConnectedPickableError.java 2006-10-03 18:42:15 UTC (rev 475) +++ trunk/daimonin/src/daieditor/map/validation/checks/ConnectedPickableError.java 2006-10-03 19:06:40 UTC (rev 476) @@ -22,7 +22,7 @@ package daieditor.map.validation.checks; import daieditor.gameobject.GameObject; -import daieditor.map.validation.ArchValidationError; +import daieditor.map.validation.GameObjectValidationError; import daieditor.map.validation.CorrectableError; import java.awt.Component; @@ -30,20 +30,20 @@ * A MapValidator that checks for mobs outside spawn points. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public class ConnectedPickableError extends ArchValidationError implements CorrectableError { +public class ConnectedPickableError extends GameObjectValidationError implements CorrectableError { /** * Create a MobOutsideSpawnPointError. - * @param archObject the arch on which the error occurred + * @param gameObject the GameObject on which the error occurred */ - public ConnectedPickableError(final GameObject archObject) { - super(archObject); + public ConnectedPickableError(final GameObject gameObject) { + super(gameObject); } /** {@inheritDoc} */ public void correct(final Component parentComponent) { // TODO: Ask whether to clear connected attribute, remove or ignore - getArchObject().remove(); + getGameObject().remove(); } } // class ConnectedPickableError Deleted: trunk/daimonin/src/daieditor/map/validation/checks/DoubleArchChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/DoubleArchChecker.java 2006-10-03 18:42:15 UTC (rev 475) +++ trunk/daimonin/src/daieditor/map/validation/checks/DoubleArchChecker.java 2006-10-03 19:06:40 UTC (rev 476) @@ -1,60 +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.validation.checks; - -import daieditor.gameobject.GameObject; -import daieditor.map.MapSquare; -import daieditor.map.validation.AbstractValidator; -import daieditor.map.validation.ArchesValidationError; -import daieditor.map.validation.ErrorCollector; -import daieditor.map.validation.SquareValidator; -import java.util.HashMap; -import java.util.Map; - -/** - * A SquareValidator to assert that there are no two arches of the same type on the same square. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public class DoubleArchChecker extends AbstractValidator implements SquareValidator { - - /** {@inheritDoc} */ - public void validate(final MapSquare mapSquare, final ErrorCollector errorCollector) { - final Map<Integer, Object> typeNums = new HashMap<Integer, Object>(); - for (final GameObject archObject : mapSquare) { - final Integer typeNum = archObject.getArchTypNr(); - if (typeNums.containsKey(typeNum)) { - final Object o = typeNums.get(typeNum); - if (o instanceof GameObject) { - final DoubleArchError error = new DoubleArchError(mapSquare, (GameObject) o); - typeNums.put(typeNum, error); - errorCollector.collect(error); - } else { - assert o instanceof DoubleArchError; - ((ArchesValidationError) o).addArchObject(archObject); - } - } else { - typeNums.put(typeNum, archObject); - } - } - } - -} // class DoubleArchChecker Deleted: trunk/daimonin/src/daieditor/map/validation/checks/DoubleArchError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/DoubleArchError.java 2006-10-03 18:42:15 UTC (rev 475) +++ trunk/daimonin/src/daieditor/map/validation/checks/DoubleArchError.java 2006-10-03 19:06:40 UTC (rev 476) @@ -1,51 +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.validation.checks; - -import daieditor.gameobject.GameObject; -import daieditor.map.MapSquare; -import daieditor.map.validation.ArchesValidationError; -import daieditor.map.validation.CorrectableError; -import java.awt.Component; - -/** - * Validation error that's used when the DoubleArchChecker detected a possible error on the map. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public class DoubleArchError extends ArchesValidationError implements CorrectableError { - - /** - * Create an DoubleArchError. - * @param mapSquare the square on which the error occurred - * @param archObjects the arch on which the error occurred - */ - public DoubleArchError(final MapSquare mapSquare, final GameObject... archObjects) { - super(mapSquare, archObjects); - } - - /** {@inheritDoc} */ - public void correct(final Component parentComponent) { - // TODO: Display the list of all archObjects and ask the user which archObject to keep. - // Then delete all arches except the selected one. - } - -} // class DoubleArchError Modified: trunk/daimonin/src/daieditor/map/validation/checks/DoubleLayerChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/DoubleLayerChecker.java 2006-10-03 18:42:15 UTC (rev 475) +++ trunk/daimonin/src/daieditor/map/validation/checks/DoubleLayerChecker.java 2006-10-03 19:06:40 UTC (rev 476) @@ -24,7 +24,7 @@ import daieditor.gameobject.GameObject; import daieditor.map.MapSquare; import daieditor.map.validation.AbstractValidator; -import daieditor.map.validation.ArchesValidationError; +import daieditor.map.validation.GameObjectsValidationError; import daieditor.map.validation.ErrorCollector; import daieditor.map.validation.SquareValidator; import java.util.HashMap; @@ -51,7 +51,7 @@ errorCollector.collect(error); } else { assert o instanceof DoubleLayerError; - ((ArchesValidationError) o).addArchObject(archObject); + ((GameObjectsValidationError) o).addGameObject(archObject); } } else { layers.put(layer, archObject); Modified: trunk/daimonin/src/daieditor/map/validation/checks/DoubleLayerError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/DoubleLayerError.java 2006-10-03 18:42:15 UTC (rev 475) +++ trunk/daimonin/src/daieditor/map/validation/checks/DoubleLayerError.java 2006-10-03 19:06:40 UTC (rev 476) @@ -23,7 +23,7 @@ import daieditor.gameobject.GameObject; import daieditor.map.MapSquare; -import daieditor.map.validation.ArchesValidationError; +import daieditor.map.validation.GameObjectsValidationError; import daieditor.map.validation.CorrectableError; import java.awt.Component; @@ -31,12 +31,12 @@ * Validation error that's used when the DoubleLayerChecker detected a possible error on the map. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public class DoubleLayerError extends ArchesValidationError implements CorrectableError { +public class DoubleLayerError extends GameObjectsValidationError implements CorrectableError { /** - * Create an DoubleArchError. + * Create an DoubleTypeError. * @param mapSquare the square on which the error occurred - * @param archObject the arch on which the error occurred + * @param archObject the GameObject on which the error occurred */ public DoubleLayerError(final MapSquare mapSquare, final GameObject archObject) { super(mapSquare, archObject); Copied: trunk/daimonin/src/daieditor/map/validation/checks/DoubleTypeChecker.java (from rev 475, trunk/daimonin/src/daieditor/map/validation/checks/DoubleArchChecker.java) =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/DoubleTypeChecker.java (rev 0) +++ trunk/daimonin/src/daieditor/map/validation/checks/DoubleTypeChecker.java 2006-10-03 19:06:40 UTC (rev 476) @@ -0,0 +1,60 @@ +/* + * 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.validation.checks; + +import daieditor.gameobject.GameObject; +import daieditor.map.MapSquare; +import daieditor.map.validation.AbstractValidator; +import daieditor.map.validation.GameObjectsValidationError; +import daieditor.map.validation.ErrorCollector; +import daieditor.map.validation.SquareValidator; +import java.util.HashMap; +import java.util.Map; + +/** + * A SquareValidator to assert that there are no two arches of the same type on the same square. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class DoubleTypeChecker extends AbstractValidator implements SquareValidator { + + /** {@inheritDoc} */ + public void validate(final MapSquare mapSquare, final ErrorCollector errorCollector) { + final Map<Integer, Object> typeNums = new HashMap<Integer, Object>(); + for (final GameObject gameObject : mapSquare) { + final Integer typeNum = gameObject.getArchTypNr(); + if (typeNums.containsKey(typeNum)) { + final Object o = typeNums.get(typeNum); + if (o instanceof GameObject) { + final DoubleTypeError error = new DoubleTypeError(mapSquare, (GameObject) o); + typeNums.put(typeNum, error); + errorCollector.collect(error); + } else { + assert o instanceof DoubleTypeError; + ((GameObjectsValidationError) o).addGameObject(gameObject); + } + } else { + typeNums.put(typeNum, gameObject); + } + } + } + +} // class DoubleTypeChecker Property changes on: trunk/daimonin/src/daieditor/map/validation/checks/DoubleTypeChecker.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Copied: trunk/daimonin/src/daieditor/map/validation/checks/DoubleTypeError.java (from rev 475, trunk/daimonin/src/daieditor/map/validation/checks/DoubleArchError.java) =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/DoubleTypeError.java (rev 0) +++ trunk/daimonin/src/daieditor/map/validation/checks/DoubleTypeError.java 2006-10-03 19:06:40 UTC (rev 476) @@ -0,0 +1,51 @@ +/* + * 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.validation.checks; + +import daieditor.gameobject.GameObject; +import daieditor.map.MapSquare; +import daieditor.map.validation.GameObjectsValidationError; +import daieditor.map.validation.CorrectableError; +import java.awt.Component; + +/** + * Validation error that's used when the DoubleTypeChecker detected a possible error on the map. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class DoubleTypeError extends GameObjectsValidationError implements CorrectableError { + + /** + * Create an DoubleTypeError. + * @param mapSquare the square on which the error occurred + * @param gameObjects the GameObject on which the error occurred + */ + public DoubleTypeError(final MapSquare mapSquare, final GameObject... gameObjects) { + super(mapSquare, gameObjects); + } + + /** {@inheritDoc} */ + public void correct(final Component parentComponent) { + // TODO: Display the list of all archObjects and ask the user which archObject to keep. + // Then delete all arches except the selected one. + } + +} // class DoubleTypeError Property changes on: trunk/daimonin/src/daieditor/map/validation/checks/DoubleTypeError.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/daimonin/src/daieditor/map/validation/checks/EmptySpawnPointChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/EmptySpawnPointChecker.java 2006-10-03 18:42:15 UTC (rev 475) +++ trunk/daimonin/src/daieditor/map/validation/checks/EmptySpawnPointChecker.java 2006-10-03 19:06:40 UTC (rev 476) @@ -23,20 +23,20 @@ import daieditor.gameobject.GameObject; import daieditor.map.validation.AbstractValidator; -import daieditor.map.validation.ArchValidator; +import daieditor.map.validation.GameObjectValidator; import daieditor.map.validation.ErrorCollector; /** - * An ArchValidator to assert that spawn points are not empty. + * An GameObjectValidator to assert that spawn points are not empty. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public class EmptySpawnPointChecker extends AbstractValidator implements ArchValidator { +public class EmptySpawnPointChecker extends AbstractValidator implements GameObjectValidator { /** {@inheritDoc} */ - public void validate(final GameObject archObject, final ErrorCollector errorCollector) { - if (archObject.getArchTypNr() == 81) { - if (archObject.isEmpty()) { - errorCollector.collect(new EmptySpawnPointError(archObject)); + public void validate(final GameObject gameObject, final ErrorCollector errorCollector) { + if (gameObject.getArchTypNr() == 81) { + if (gameObject.isEmpty()) { + errorCollector.collect(new EmptySpawnPointError(gameObject)); } } } Modified: trunk/daimonin/src/daieditor/map/validation/checks/EmptySpawnPointError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/EmptySpawnPointError.java 2006-10-03 18:42:15 UTC (rev 475) +++ trunk/daimonin/src/daieditor/map/validation/checks/EmptySpawnPointError.java 2006-10-03 19:06:40 UTC (rev 476) @@ -22,7 +22,7 @@ package daieditor.map.validation.checks; import daieditor.gameobject.GameObject; -import daieditor.map.validation.ArchValidationError; +import daieditor.map.validation.GameObjectValidationError; import daieditor.map.validation.CorrectableError; import java.awt.Component; @@ -30,14 +30,14 @@ * Validation error that's used when the EmptySpawnPointCheker detected a possible error on the map. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public class EmptySpawnPointError extends ArchValidationError implements CorrectableError { +public class EmptySpawnPointError extends GameObjectValidationError implements CorrectableError { /** * Create an EmptySpawnPointError. - * @param archObject the arch on which the error occurred + * @param gameObject the GameObject on which the error occurred */ - public EmptySpawnPointError(final GameObject archObject) { - super(archObject); + public EmptySpawnPointError(final GameObject gameObject) { + super(gameObject); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/map/validation/checks/ExitChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/ExitChecker.java 2006-10-03 18:42:15 UTC (rev 475) +++ trunk/daimonin/src/daieditor/map/validation/checks/ExitChecker.java 2006-10-03 19:06:40 UTC (rev 476) @@ -3,7 +3,7 @@ import daieditor.CMainControl; import daieditor.gameobject.GameObject; import daieditor.map.validation.AbstractValidator; -import daieditor.map.validation.ArchValidator; +import daieditor.map.validation.GameObjectValidator; import daieditor.map.validation.ErrorCollector; import java.io.File; import org.jetbrains.annotations.NotNull; @@ -12,7 +12,7 @@ * A Validator to assert that exits are connected to maps properly. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public class ExitChecker extends AbstractValidator implements ArchValidator { +public class ExitChecker extends AbstractValidator implements GameObjectValidator { /** The map directory to check. */ @NotNull private File mapDirectory; @@ -34,9 +34,9 @@ } /** {@inheritDoc} */ - public void validate(final GameObject archObject, final ErrorCollector errorCollector) { - if (archObject.getArchTypNr() == 66) { - final String path = archObject.getAttributeString("slaying", false); + public void validate(final GameObject gameObject, final ErrorCollector errorCollector) { + if (gameObject.getArchTypNr() == 66) { + final String path = gameObject.getAttributeString("slaying", false); if (path != null && path.length() > 0) { final File newfile; if (path.startsWith(File.pathSeparator) || path.startsWith("/")) { @@ -44,10 +44,10 @@ newfile = new File(mapDirectory.getAbsolutePath(), path.substring(1)); } else { // we have a relative path: - newfile = new File(archObject.getMapSquare().getModel().getMapControl().getMapFile().getParent(), path); + newfile = new File(gameObject.getMapSquare().getModel().getMapControl().getMapFile().getParent(), path); } if (!newfile.exists() || newfile.isDirectory()) { - errorCollector.collect(new ExitError(archObject, path)); + errorCollector.collect(new ExitError(gameObject, path)); } } } Modified: trunk/daimonin/src/daieditor/map/validation/checks/ExitError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/ExitError.java 2006-10-03 18:42:15 UTC (rev 475) +++ trunk/daimonin/src/daieditor/map/validation/checks/ExitError.java 2006-10-03 19:06:40 UTC (rev 476) @@ -1,24 +1,24 @@ package daieditor.map.validation.checks; import daieditor.gameobject.GameObject; -import daieditor.map.validation.ArchValidationError; +import daieditor.map.validation.GameObjectValidationError; /** * Validation error that's used when a map has wrong exit paths. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public class ExitError extends ArchValidationError { +public class ExitError extends GameObjectValidationError { /** The exit path that was wrong. */ private final String exitPath; /** * Create a MapValidationError. - * @param arch the arch on which the error occurred - * @param exitPath exit path which was wrong + * @param gameObject the GameObject on which the error occurred + * @param exitPath exit path which was wrong */ - public ExitError(final GameObject arch, final String exitPath) { - super(arch); + public ExitError(final GameObject gameObject, final String exitPath) { + super(gameObject); this.exitPath = exitPath; } Modified: trunk/daimonin/src/daieditor/map/validation/checks/MobOutsideSpawnPointChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/MobOutsideSpawnPointChecker.java 2006-10-03 18:42:15 UTC (rev 475) +++ trunk/daimonin/src/daieditor/map/validation/checks/MobOutsideSpawnPointChecker.java 2006-10-03 19:06:40 UTC (rev 476) @@ -23,19 +23,19 @@ import daieditor.gameobject.GameObject; import daieditor.map.validation.AbstractValidator; -import daieditor.map.validation.ArchValidator; +import daieditor.map.validation.GameObjectValidator; import daieditor.map.validation.ErrorCollector; /** - * ArchValidator to assert that mobs are not outside spawn points. + * GameObjectValidator to assert that mobs are not outside spawn points. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public class MobOutsideSpawnPointChecker extends AbstractValidator implements ArchValidator { +public class MobOutsideSpawnPointChecker extends AbstractValidator implements GameObjectValidator { /** {@inheritDoc} */ - public void validate(final GameObject archObject, final ErrorCollector errorCollector) { - if (archObject.getArchTypNr() == 80) { - errorCollector.collect(new MobOutsideSpawnPointError(archObject)); + public void validate(final GameObject gameObject, final ErrorCollector errorCollector) { + if (gameObject.getArchTypNr() == 80) { + errorCollector.collect(new MobOutsideSpawnPointError(gameObject)); } } Modified: trunk/daimonin/src/daieditor/map/validation/checks/MobOutsideSpawnPointError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/MobOutsideSpawnPointError.java 2006-10-03 18:42:15 UTC (rev 475) +++ trunk/daimonin/src/daieditor/map/validation/checks/MobOutsideSpawnPointError.java 2006-10-03 19:06:40 UTC (rev 476) @@ -22,7 +22,7 @@ package daieditor.map.validation.checks; import daieditor.gameobject.GameObject; -import daieditor.map.validation.ArchValidationError; +import daieditor.map.validation.GameObjectValidationError; import daieditor.map.validation.CorrectableError; import java.awt.Component; @@ -30,19 +30,19 @@ * A MapValidator that checks for mobs outside spawn points. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public class MobOutsideSpawnPointError extends ArchValidationError implements CorrectableError { +public class MobOutsideSpawnPointError extends GameObjectValidationError implements CorrectableError { /** * Create a MobOutsideSpawnPointError. - * @param archObject the arch on which the error occurred + * @param gameObject the GameObject on which the error occurred */ - public MobOutsideSpawnPointError(final GameObject archObject) { - super(archObject); + public MobOutsideSpawnPointError(final GameObject gameObject) { + super(gameObject); } /** {@inheritDoc} */ public void correct(final Component parentComponent) { - getArchObject().remove(); + getGameObject().remove(); } } // class MobOutsideSpawnPointError Modified: trunk/daimonin/src/daieditor/map/validation/checks/SlayingChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/SlayingChecker.java 2006-10-03 18:42:15 UTC (rev 475) +++ trunk/daimonin/src/daieditor/map/validation/checks/SlayingChecker.java 2006-10-03 19:06:40 UTC (rev 476) @@ -23,20 +23,20 @@ import daieditor.gameobject.GameObject; import daieditor.map.validation.AbstractValidator; -import daieditor.map.validation.ArchValidator; +import daieditor.map.validation.GameObjectValidator; import daieditor.map.validation.ErrorCollector; /** - * An ArchValidator to assert that arch objects do not have critical slaying strings. + * An GameObjectValidator to assert that arch objects do not have critical slaying strings. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public class SlayingChecker extends AbstractValidator implements ArchValidator { +public class SlayingChecker extends AbstractValidator implements GameObjectValidator { /** {@inheritDoc} */ - public void validate(final GameObject archObject, final ErrorCollector errorCollector) { - final String slaying = archObject.getAttributeString("slaying", true); + public void validate(final GameObject gameObject, final ErrorCollector errorCollector) { + final String slaying = gameObject.getAttributeString("slaying", true); if (slaying != null && !slaying.matches("^[a-zA-Z_0-9/.]*$")) { - errorCollector.collect(new SlayingError(archObject)); + errorCollector.collect(new SlayingError(gameObject)); } } Modified: trunk/daimonin/src/daieditor/map/validation/checks/SlayingError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/SlayingError.java 2006-10-03 18:42:15 UTC (rev 475) +++ trunk/daimonin/src/daieditor/map/validation/checks/SlayingError.java 2006-10-03 19:06:40 UTC (rev 476) @@ -22,7 +22,7 @@ package daieditor.map.validation.checks; import daieditor.gameobject.GameObject; -import daieditor.map.validation.ArchValidationError; +import daieditor.map.validation.GameObjectValidationError; import daieditor.map.validation.CorrectableError; import java.awt.Component; @@ -30,20 +30,20 @@ * Validation error that's used when the SlayingChecker detected a possible error on the map. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public class SlayingError extends ArchValidationError implements CorrectableError { +public class SlayingError extends GameObjectValidationError implements CorrectableError { /** * Create a MobOutsideSpawnPointError. - * @param archObject the arch on which the error occurred + * @param gameObject the GameObject on which the error occurred */ - public SlayingError(final GameObject archObject) { - super(archObject); + public SlayingError(final GameObject gameObject) { + super(gameObject); } /** {@inher... [truncated message content] |
From: <chr...@us...> - 2006-10-03 18:42:51
|
Revision: 475 http://svn.sourceforge.net/gridarta/?rev=475&view=rev Author: christianhujer Date: 2006-10-03 11:42:15 -0700 (Tue, 03 Oct 2006) Log Message: ----------- Clarified variable names to denote either gameObject or archetype. Modified Paths: -------------- trunk/crossfire/src/cfeditor/AutojoinList.java trunk/crossfire/src/cfeditor/CArchPanelPan.java trunk/crossfire/src/cfeditor/CFTreasureListTree.java trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMapArchPanel.java trunk/crossfire/src/cfeditor/CMapTileList.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/crossfire/src/cfeditor/parameter/ArchParameter.java trunk/daimonin/src/daieditor/CArchPanelPan.java trunk/daimonin/src/daieditor/CFTreasureListTree.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gameobject/ArchObjectParser.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java Modified: trunk/crossfire/src/cfeditor/AutojoinList.java =================================================================== --- trunk/crossfire/src/cfeditor/AutojoinList.java 2006-10-03 17:47:02 UTC (rev 474) +++ trunk/crossfire/src/cfeditor/AutojoinList.java 2006-10-03 18:42:15 UTC (rev 475) @@ -327,18 +327,18 @@ * Add/remove a certain connection of the given arch * by changing archtype and face. */ - private void connectArch(final GameObject arch, final String archname) { - final GameObject defarch = stack.getArchetype(archname); // new default arch + private void connectArch(final GameObject gameObject, final String archname) { + final GameObject archetype = stack.getArchetype(archname); // new default arch - if (!arch.getArchetypeName().equals(archname)) { + if (!gameObject.getArchetypeName().equals(archname)) { // set new archtype - arch.setArchetypeName(archname); + gameObject.setArchetypeName(archname); // set face of new default arch - arch.setFaceNr(defarch.getFaceNr()); - arch.setFaceFlag(defarch.getFaceFlag()); - if (arch.getFaceName() != null && arch.getFaceName().length() > 0) { - arch.setFaceName(null); // take default face + gameObject.setFaceNr(archetype.getFaceNr()); + gameObject.setFaceFlag(archetype.getFaceFlag()); + if (gameObject.getFaceName() != null && gameObject.getFaceName().length() > 0) { + gameObject.setFaceName(null); // take default face } } } Modified: trunk/crossfire/src/cfeditor/CArchPanelPan.java =================================================================== --- trunk/crossfire/src/cfeditor/CArchPanelPan.java 2006-10-03 17:47:02 UTC (rev 474) +++ trunk/crossfire/src/cfeditor/CArchPanelPan.java 2006-10-03 18:42:15 UTC (rev 475) @@ -120,23 +120,22 @@ } public GameObject getArchListObject() { - GameObject arch = null; + GameObject archetype = null; int index = theList.getSelectedIndex(); - if (index != -1) { final String archname = theList.getSelectedValue().toString(); - arch = mainControl.getArchetypeSet().getArchetype(archname); + archetype = mainControl.getArchetypeSet().getArchetype(archname); } - return arch; + return archetype; } public void showArchListObject(int index) { - GameObject arch = null; + GameObject archetype = null; if (index != -1) { try { final String archname = theList.getSelectedValue().toString(); - arch = mainControl.getArchetypeSet().getArchetype(archname); + archetype = mainControl.getArchetypeSet().getArchetype(archname); } catch (final NullPointerException e) { /* log.info("NullPointerException in showArchListObject()!", e); @@ -146,7 +145,7 @@ } catch (final NumberFormatException e) { } } - mainControl.showArchPanelQuickObject(arch); // send it to quick view + mainControl.showArchPanelQuickObject(archetype); // send it to quick view } /** @@ -270,19 +269,19 @@ /* We additionally set the JLabels icon property here. */ - final GameObject arch = mainControl.getArchetypeSet().getArchetype(value.toString()); + final GameObject archetype = mainControl.getArchetypeSet().getArchetype(value.toString()); if (isSelected) { archPanel.setPanelArch(value.toString()); mainControl.setStatusText(" " + value + " "); } - setText(arch.getArchetypeName()); + setText(archetype.getArchetypeName()); - if (arch.getFaceFlag()) { + if (archetype.getFaceFlag()) { setIcon(mainControl.getNofaceTileIcon()); - } else if (arch.getFaceNr() == -1) { + } else if (archetype.getFaceNr() == -1) { setIcon(mainControl.getUnknownTileIcon()); } else { - setIcon(mainControl.getFace(arch.getFaceNr())); + setIcon(mainControl.getFace(archetype.getFaceNr())); } return this; Modified: trunk/crossfire/src/cfeditor/CFTreasureListTree.java =================================================================== --- trunk/crossfire/src/cfeditor/CFTreasureListTree.java 2006-10-03 17:47:02 UTC (rev 474) +++ trunk/crossfire/src/cfeditor/CFTreasureListTree.java 2006-10-03 18:42:15 UTC (rev 475) @@ -954,11 +954,11 @@ } else if (content.getType() != TreasureObj.FOLDER) { // normal arch: display the face icon if (CMainControl.getInstance().getArchetypeSet().getLoadStatus() == ArchetypeSet.LoadStatus.COMPLETE) { - final String archname = content.getName(); - final GameObject arch = CMainControl.getInstance().getArch(archname); - if (arch != null) { - if (!arch.getFaceFlag()) { - setIcon(CMainControl.getInstance().getFace(arch.getFaceNr())); + final String archetypeName = content.getName(); + final GameObject archetype = CMainControl.getInstance().getArchetype(archetypeName); + if (archetype != null) { + if (!archetype.getFaceFlag()) { + setIcon(CMainControl.getInstance().getFace(archetype.getFaceNr())); } else { setIcon(noface); } Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-10-03 17:47:02 UTC (rev 474) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-10-03 18:42:15 UTC (rev 475) @@ -361,20 +361,10 @@ mainView.openHelpWindow(); } - // access to ArchNodeList - // remark: i use before some weird access to it, use this instead when you find it - public void addArchToList(final GameObject data) { - archetypeSet.addArchetype(data); + public GameObject getArchetype(final String archetypeName) { + return archetypeSet.getArchetype(archetypeName); } - public int getArchCount() { - return archetypeSet.getArchetypeCount(); - } - - public GameObject getArch(final String archname) { - return archetypeSet.getArchetype(archname); - } - public CopyBuffer getCopyBuffer() { return copybuffer; } @@ -959,33 +949,33 @@ final List<GameObject> tailList = new ArrayList<GameObject>(); // first: attach our map sucker to a default arch we have loaded for (final Iterator<GameObject> it = objects.iterator(); it.hasNext();) { - final GameObject arch = it.next(); - final GameObject defarch = archetypeSet.getArchetype(arch.getArchetypeName()); - if (defarch == null) { + final GameObject gameObject = it.next(); + final GameObject archetype = archetypeSet.getArchetype(gameObject.getArchetypeName()); + if (archetype == null) { // we had an unknown arch here!! // showMessage("Error Loading Map File "+file.getName(), "\n Found Unknown Arch < "+arch.getArchetypeName()+" >"); // return false; } else { - arch.setArchetype(defarch); + gameObject.setArchetype(archetype); } // 2nd: attach the right face... // if there was no special face added in map, get it from def object - if (arch.getFaceName() != null) { - final int index2 = ArchetypeSet.getFaceIndex(arch.getFaceName()); + if (gameObject.getFaceName() != null) { + final int index2 = ArchetypeSet.getFaceIndex(gameObject.getFaceName()); if (index2 == -1) { // just warn here we have not the gfx //showMessage("LOAD FILE", "Arch: "+arch.getFaceName()+" Face: " +arch.getFaceName()+" Face Name Unknown"); } else { - arch.setFaceNr(index2); + gameObject.setFaceNr(index2); } } // 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) - archObjectParser.postParseMapArch(arch, tileEdit); + archObjectParser.postParseMapArch(gameObject, tileEdit); - archObjectParser.expandMulti(arch, tailList); + archObjectParser.expandMulti(gameObject, tailList); } for (final GameObject tail : tailList) { Modified: trunk/crossfire/src/cfeditor/CMapArchPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapArchPanel.java 2006-10-03 17:47:02 UTC (rev 474) +++ trunk/crossfire/src/cfeditor/CMapArchPanel.java 2006-10-03 18:42:15 UTC (rev 475) @@ -306,33 +306,34 @@ // If the active arch is part of a multi, the mutli-head's stats // are taken instead: - final GameObject arch = activeArch.getHead(); + final GameObject gameObject = activeArch.getHead(); - final GameObject defarch = mainControl.getArch(arch.getArchetypeName()); - if (defarch == null) { // hm, this should NOT happen + // FIXME cher: shouldn't this be replaced by archetype = gameObject.getArchetype() ? + final GameObject archetype = mainControl.getArchetype(gameObject.getArchetypeName()); + if (archetype == null) { // hm, this should NOT happen return; } - final String oldArchText = arch.getObjectText(); - final String oldMsg = arch.getMsgText(); + final String oldArchText = gameObject.getObjectText(); + final String oldMsg = gameObject.getMsgText(); // We update all panels: name, face, msg and archText (more to come...) // the obj name: if (testForText(archNameField.getText())) { // there is something in // if this equal the default name... - if (defarch.getObjName() != null) { - if (archNameField.getText().compareTo(defarch.getObjName()) == 0) { - arch.setObjName(null); // yes, we don't need it in map + if (archetype.getObjName() != null) { + if (archNameField.getText().compareTo(archetype.getObjName()) == 0) { + gameObject.setObjName(null); // yes, we don't need it in map } else { - arch.setObjName(archNameField.getText()); // overrule in map arch + gameObject.setObjName(archNameField.getText()); // overrule in map arch } - } else if (archNameField.getText().compareTo(arch.getArchetypeName()) == 0) { - arch.setObjName(null); + } else if (archNameField.getText().compareTo(gameObject.getArchetypeName()) == 0) { + gameObject.setObjName(null); } else { // def is null, something is in panel, so we set it - arch.setObjName(archNameField.getText()); // overrule in map arch + gameObject.setObjName(archNameField.getText()); // overrule in map arch } } else { - arch.setObjName(null); // nothing in, nothing in map arch + gameObject.setObjName(null); // nothing in, nothing in map arch // hm, there is no way yet to overrule a default arch name with "nothing" // like <name > ore <name "">..?? } @@ -340,12 +341,12 @@ // set face if (testForText(archFaceField.getText())) { // there is something in // check if we need a map redraw - if (defarch.getFaceName() != null) { + if (archetype.getFaceName() != null) { final String facename; - if (arch.getFaceName() != null) { - facename = arch.getFaceName(); + if (gameObject.getFaceName() != null) { + facename = gameObject.getFaceName(); } else { - facename = defarch.getFaceName(); + facename = archetype.getFaceName(); } if (archFaceField.getText() != null && @@ -354,81 +355,81 @@ } } - if (defarch.getFaceName() != null) { - if (archFaceField.getText().compareTo(defarch.getFaceName()) == 0) { - arch.setFaceName(null); // yes, we don't need it in map + if (archetype.getFaceName() != null) { + if (archFaceField.getText().compareTo(archetype.getFaceName()) == 0) { + gameObject.setFaceName(null); // yes, we don't need it in map } else { - arch.setFaceName(archFaceField.getText()); // overrule in map arch + gameObject.setFaceName(archFaceField.getText()); // overrule in map arch } } else { - arch.setFaceName(archFaceField.getText()); // overrule in map arch + gameObject.setFaceName(archFaceField.getText()); // overrule in map arch } } else { - if (arch.getFaceName() != null) { + if (gameObject.getFaceName() != null) { needRedraw = true; // reset to default arch - needs redraw } - arch.setFaceName(null); // nothing in, nothing in map arch + gameObject.setFaceName(null); // nothing in, nothing in map arch // also, no overrule... } - if (arch.getFaceName() != null) { + if (gameObject.getFaceName() != null) { // we have a non-default face - final int index = ArchetypeSet.getFaceIndex(arch.getFaceName()); - arch.setFaceNr(index); + final int index = ArchetypeSet.getFaceIndex(gameObject.getFaceName()); + gameObject.setFaceNr(index); } else { // we have the default face - final int index = ArchetypeSet.getFaceIndex(defarch.getFaceName()); - arch.setFaceNr(index); + final int index = ArchetypeSet.getFaceIndex(archetype.getFaceName()); + gameObject.setFaceNr(index); } // the msg TEXT!! ("msg ... endmsg") // if there is an entry in the archTextArea (msg window), this // overrules the default text (if any) if (testForText(archTextArea.getText())) { // there is something in the msg win - if (defarch.getMsgText() != null) { + if (archetype.getMsgText() != null) { // trim text from message window String newMsgtext = archTextArea.getText(); if (newMsgtext != null) { newMsgtext = newMsgtext.trim(); } - if (newMsgtext.equals(defarch.getMsgText().trim())) { - arch.deleteMsgText(); // yes, we don't need it in map + if (newMsgtext.equals(archetype.getMsgText().trim())) { + gameObject.deleteMsgText(); // yes, we don't need it in map } else { - arch.resetMsgText(); - arch.addMsgText(newMsgtext); + gameObject.resetMsgText(); + gameObject.addMsgText(newMsgtext); } } else { - arch.resetMsgText(); - arch.addMsgText(archTextArea.getText()); + gameObject.resetMsgText(); + gameObject.addMsgText(archTextArea.getText()); } } else { // there is nothing in the msg win - arch.deleteMsgText(); // always delete this... - if (defarch.getMsgText() != null) { - arch.addMsgText(""); // but here we must overrule default with msg/endmsg (empty msg) + gameObject.deleteMsgText(); // always delete this... + if (archetype.getMsgText() != null) { + gameObject.addMsgText(""); // but here we must overrule default with msg/endmsg (empty msg) } } // read from archEdit (bottom right textwin) only the attributes // that differ from the default arch. These get stored into // the arche's archText (and finally in the map). - arch.setObjectText(defarch.diffArchText(archEdit.getText(), false)); + gameObject.setObjectText(archetype.diffArchText(archEdit.getText(), false)); // we look for 'type' in the ArchText. In future maybe type should get // a seperate textfield - if (arch.getAttributeString("type", false).length() > 0) { - arch.setArchTypNr(arch.getAttributeInt("type", false)); // specified type + if (gameObject.getAttributeString("type", false).length() > 0) { + gameObject.setArchTypNr(gameObject.getAttributeInt("type", false)); // specified type } // Recalculate the editType value. It shall stay 100% accurate ;) - arch.calculateEditType(mainControl.getCurrentMap().getActiveEditType()); + gameObject.calculateEditType(mainControl.getCurrentMap().getActiveEditType()); // if the archtext changed, set the map changed flag - if ((oldArchText != null && !oldArchText.equals(arch.getObjectText())) || - (oldArchText == null && arch.getObjectText() != null) || - (oldMsg != null && !oldMsg.equals(arch.getMsgText())) || - (oldMsg == null && arch.getMsgText() != null)) { + if ((oldArchText != null && !oldArchText.equals(gameObject.getObjectText())) || + (oldArchText == null && gameObject.getObjectText() != null) || + (oldMsg != null && !oldMsg.equals(gameObject.getMsgText())) || + (oldMsg == null && gameObject.getMsgText() != null)) { mainControl.getCurrentMap().setLevelChangedFlag(); } @@ -659,65 +660,65 @@ // If the active arch is part of a multi, the mutli-head's stats // are displayed (Only the head can store information!). - final GameObject arch = activeArch.getHead(); + final GameObject gameObject = activeArch.getHead(); // no text, we try to set the default text final boolean hasMessage; - if (arch.getMsgText() == null && arch.getArchetypeName() != null) { + if (gameObject.getMsgText() == null && gameObject.getArchetypeName() != null) { archTextArea.setForeground(Color.black); - if (mainControl.getArch(arch.getArchetypeName()).getMsgText() == null) { + if (mainControl.getArchetype(gameObject.getArchetypeName()).getMsgText() == null) { archTextArea.setText(""); hasMessage = false; } else { - archTextArea.setText(mainControl.getArch(arch.getArchetypeName()).getMsgText()); + archTextArea.setText(mainControl.getArchetype(gameObject.getArchetypeName()).getMsgText()); hasMessage = true; } } else { archTextArea.setForeground(Color.blue); - archTextArea.setText(arch.getMsgText()); + archTextArea.setText(gameObject.getMsgText()); hasMessage = true; } archTextArea.setCaretPosition(0); // end msg text // SET FACE - if (arch.getFaceFlag()) { + if (gameObject.getFaceFlag()) { archFaceField.setText(""); - } else if (arch.getFaceName() != null) { // custom face + } else if (gameObject.getFaceName() != null) { // custom face archFaceField.setForeground(Color.blue); - archFaceField.setText(arch.getFaceName()); - } else if (arch.getArchetypeName() != null) { + archFaceField.setText(gameObject.getFaceName()); + } else if (gameObject.getArchetypeName() != null) { archFaceField.setForeground(Color.black); - archFaceField.setText(mainControl.getArch(arch.getArchetypeName()).getFaceName()); + archFaceField.setText(mainControl.getArchetype(gameObject.getArchetypeName()).getFaceName()); } // end face // *** OBJECT NAME *** - if (arch.getObjName() == null && arch.getArchetypeName() != null) { + if (gameObject.getObjName() == null && gameObject.getArchetypeName() != null) { archNameField.setForeground(Color.black); - if (mainControl.getArch(arch.getArchetypeName()).getObjName() == null) { + if (mainControl.getArchetype(gameObject.getArchetypeName()).getObjName() == null) { // arch name - if (arch.getArchetypeName() != null) { - archNameField.setText(arch.getArchetypeName()); + if (gameObject.getArchetypeName() != null) { + archNameField.setText(gameObject.getArchetypeName()); } else { archNameField.setText(""); } } else { // default name - archNameField.setText(mainControl.getArch(arch.getArchetypeName()).getObjName()); + archNameField.setText(mainControl.getArchetype(gameObject.getArchetypeName()).getObjName()); } } else { // object name ("special") archNameField.setForeground(Color.blue); - archNameField.setText(arch.getObjName()); + archNameField.setText(gameObject.getObjName()); } // end ObjName // set hint for "specials": scripts/inventory/message String specialText = ""; final int i; - if ((i = arch.countInvObjects()) > 0) { + if ((i = gameObject.countInvObjects()) > 0) { specialText += "Inv: " + i; } - if (arch.isScripted()) { + if (gameObject.isScripted()) { specialText += specialText.length() > 0 ? ", Script" : "Script"; } if (hasMessage) { @@ -725,19 +726,19 @@ } archInvCount.setText(specialText); // set text to label - archMapPos.setText("Map: " + arch.getMapX() + ", " + arch.getMapY()); + archMapPos.setText("Map: " + gameObject.getMapX() + ", " + gameObject.getMapY()); - if (arch.getArchetypeName() != null) { - archTypeText.setText("Type: " + mainControl.getArchObjectParser().getArchTypeName(arch.getArchTypNr()) - + " (" + arch.getArchTypNr() + ") [" + arch.getArchetypeName() + "]"); + if (gameObject.getArchetypeName() != null) { + archTypeText.setText("Type: " + mainControl.getArchObjectParser().getArchTypeName(gameObject.getArchTypNr()) + + " (" + gameObject.getArchTypNr() + ") [" + gameObject.getArchetypeName() + "]"); } else { archTypeText.setText("Type: <unknown>"); } // check for multi tile - if (arch.isMulti()) { + if (gameObject.isMulti()) { // multi: print size - archTileText.setText("Tile: " + arch.getSizeX() + "x" + arch.getSizeY()); + archTileText.setText("Tile: " + gameObject.getSizeX() + "x" + gameObject.getSizeY()); } else { // single archTileText.setText("Tile: single"); @@ -749,8 +750,8 @@ try { // blue: the "special" attributes, differ from the default archetype StyleConstants.setForeground(currentAttributes, Color.blue); - if (arch.getObjectText() != null) { - doc.insertString(doc.getLength(), arch.getObjectText(), currentAttributes); + if (gameObject.getObjectText() != null) { + doc.insertString(doc.getLength(), gameObject.getObjectText(), currentAttributes); } // doc.insertString(doc.getLength(), "ID#"+arch.getMyID()+ " inv#: "+arch.countInvObjects()+"\n", currentAttributes); @@ -758,8 +759,8 @@ // black: the attributes from the default archetype // that don't exist among the "special" ones StyleConstants.setForeground(currentAttributes, Color.black); - if (arch.getObjectText() != null && mainControl.getArchetypeSet().getArchetype(arch.getArchetypeName()) != null) { - doc.insertString(doc.getLength(), arch.diffArchText(mainControl.getArchetypeSet().getArchetype(arch.getArchetypeName()).getObjectText(), true), currentAttributes); + if (gameObject.getObjectText() != null && mainControl.getArchetypeSet().getArchetype(gameObject.getArchetypeName()) != null) { + doc.insertString(doc.getLength(), gameObject.diffArchText(mainControl.getArchetypeSet().getArchetype(gameObject.getArchetypeName()).getObjectText(), true), currentAttributes); } } catch (final BadLocationException e) { // TODO @@ -767,9 +768,9 @@ archEdit.setCaretPosition(0); // ------ script panel ------ - if (arch.isScripted()) { + if (gameObject.isScripted()) { eventList.removeAll(); // clear event list - arch.addEventsToJList(eventList); // update JList to display all events + gameObject.addEventsToJList(eventList); // update JList to display all events s_modify.setEnabled(true); s_path.setEnabled(true); Modified: trunk/crossfire/src/cfeditor/CMapTileList.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapTileList.java 2006-10-03 17:47:02 UTC (rev 474) +++ trunk/crossfire/src/cfeditor/CMapTileList.java 2006-10-03 18:42:15 UTC (rev 475) @@ -404,7 +404,7 @@ final int num = Integer.parseInt(entry.substring(0, 10)); final int indent = Integer.parseInt(entry.substring(10, 20)); - GameObject arch = mainControl.getMapArch(num, currentSquare); + GameObject gameObject = mainControl.getMapArch(num, currentSquare); //String label; // We must set a disabled Icon (even though we don't want it) @@ -414,31 +414,31 @@ // arch == null should not happen, but it *can* happen when the active // window gets changed by user and java is still blitting here - if (arch != null) { - arch = arch.getHead(); + if (gameObject != null) { + gameObject = gameObject.getHead(); if (!isSelected && indent == 0) { this.setBackground(IGUIConstants.BG_COLOR); } - if (arch.getArchetypeName() == null) { + if (gameObject.getArchetypeName() == null) { setIcon(mainControl.getNoarchTileIcon()); - } else if (arch.getFaceFlag()) { + } else if (gameObject.getFaceFlag()) { setIcon(mainControl.getNofaceTileIcon()); - } else if (arch.getFaceNr() == -1) { + } else if (gameObject.getFaceNr() == -1) { setIcon(mainControl.getUnknownTileIcon()); } else { - setIcon(mainControl.getFace(arch.getFaceNr())); + setIcon(mainControl.getFace(gameObject.getFaceNr())); } // In the map-tile-window the object names are displayed // next to the icons - if (arch.getObjName() != null && arch.getObjName().length() > 0) { - setText(arch.getObjName()); // special name + if (gameObject.getObjName() != null && gameObject.getObjName().length() > 0) { + setText(gameObject.getObjName()); // special name } else { final String defname; - if (arch.getArchetypeName() != null) { - defname = mainControl.getArch(arch.getArchetypeName()).getObjName(); + if (gameObject.getArchetypeName() != null) { + defname = mainControl.getArchetype(gameObject.getArchetypeName()).getObjName(); } else { defname = null; } @@ -446,7 +446,7 @@ if (defname != null && defname.length() > 0) { setText(defname); // default name } else { - setText(arch.getArchetypeName()); // arch name + setText(gameObject.getArchetypeName()); // arch name } } } else { Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-10-03 17:47:02 UTC (rev 474) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-10-03 18:42:15 UTC (rev 475) @@ -414,7 +414,7 @@ final Point[] redraw; // return value (coords needing redraw) - if (mainControl.getAutojoin() && mainControl.getArch(arch.getArchetypeName()).getJoinList() != null) { + if (mainControl.getAutojoin() && mainControl.getArchetype(arch.getArchetypeName()).getJoinList() != null) { // this arch does autojoining: // first look how many we need Modified: trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java 2006-10-03 17:47:02 UTC (rev 474) +++ trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java 2006-10-03 18:42:15 UTC (rev 475) @@ -331,7 +331,7 @@ } } postParseDefArch(arch); - mainControl.addArchToList(arch); + mainControl.getArchetypeSet().addArchetype(arch); archmore = false; // we assume this is last... but perhaps.. @@ -486,28 +486,28 @@ * if null, copy the default text in arch, so the user can see and edit it * if at save time msg-maparch == msg-default, we ignore it * in every other case (even "" text) we save - * @param arch map arch to be parsed + * @param gameObject map arch to be parsed * @param editType edit type(s) to be calculated for the arch */ - public void postParseMapArch(final GameObject arch, final int editType) { - if (arch.getArchetypeName() == null) { + public void postParseMapArch(final GameObject gameObject, final int editType) { + if (gameObject.getArchetypeName() == null) { return; } - final String text = arch.getObjectText(); + final String text = gameObject.getObjectText(); final int len = text.length(); - final GameObject defarch = mainControl.getArch(arch.getArchetypeName()); + final GameObject archetype = mainControl.getArchetype(gameObject.getArchetypeName()); - arch.resetArchText(); + gameObject.resetArchText(); for (int i = 0, s = 0; i < len; i++) { if (text.charAt(i) == '\n') { if (i - s > 0) { if (text.regionMatches(s, "name ", 0, 5)) { - arch.setObjName(text.substring(s + 5, i)); + gameObject.setObjName(text.substring(s + 5, i)); } else { // this is an unparsed arch attribute, it has to stay in the archtext - arch.addArchText(text.substring(s, i) + "\n"); + gameObject.addArchText(text.substring(s, i) + "\n"); } } s = i + 1; @@ -515,36 +515,36 @@ } // so, lets check the stuff a last time - if (arch.getFaceName() == null) { - arch.setFaceNr(defarch.getFaceNr()); - arch.setFaceFlag(defarch.getFaceFlag()); + if (gameObject.getFaceName() == null) { + gameObject.setFaceNr(archetype.getFaceNr()); + gameObject.setFaceFlag(archetype.getFaceFlag()); } // if the type is still unset, then we take the default one - if (arch.getArchTypNr() == GameObject.TYPE_UNSET) { - arch.setArchTypNr(defarch.getArchTypNr()); + if (gameObject.getArchTypNr() == GameObject.TYPE_UNSET) { + gameObject.setArchTypNr(archetype.getArchTypNr()); } - arch.setMultiX(defarch.getMultiX()); - arch.setMultiY(defarch.getMultiY()); + gameObject.setMultiX(archetype.getMultiX()); + gameObject.setMultiY(archetype.getMultiY()); // arch.setEditType(defarch.getEditType()); // validate the ScriptedEvents - arch.validateAllEvents(); + gameObject.validateAllEvents(); // we don't handle anim yet, so attach then back to archtext - if (arch.getAnimText() != null) { - arch.addArchText("anim\n"); - arch.addArchText(arch.getAnimText()); - arch.addArchText("mina\n"); + if (gameObject.getAnimText() != null) { + gameObject.addArchText("anim\n"); + gameObject.addArchText(gameObject.getAnimText()); + gameObject.addArchText("mina\n"); } // Finally, we calculate the desired editType of the arch - if (arch.isTail()) { - arch.setEditType(arch.getHead().getEditType()); // copy from head + if (gameObject.isTail()) { + gameObject.setEditType(gameObject.getHead().getEditType()); // copy from head } else if (editType != 0) { - arch.setEditType(arch.calculateEditType(editType)); // calculate new + gameObject.setEditType(gameObject.calculateEditType(editType)); // calculate new } } @@ -554,25 +554,25 @@ * to the temp list, not a map. This method should only be called * after map-loading. * The ArchetypeSet should be fully initialized at this point. - * @param arch multipart head that needs tail attached + * @param gameObject multipart head that needs tail attached */ - public void expandMulti(final GameObject arch, final List<GameObject> objects) { - final GameObject defarch = mainControl.getArch(arch.getArchetypeName()); // default arch + public void expandMulti(final GameObject gameObject, final List<GameObject> objects) { + final GameObject archetype = mainControl.getArchetype(gameObject.getArchetypeName()); // default arch // is it a multi head? - if (defarch != null && defarch.isMulti() && arch.getMultiRefCount() <= 1) { + if (archetype != null && archetype.isMulti() && gameObject.getMultiRefCount() <= 1) { // we have a multi head and need to insert his tail now // do insertion for all non-head parts of the multi - for (GameObject oldPart = defarch.getMultiNext(); oldPart != null; oldPart = oldPart.getMultiNext()) { + for (GameObject oldPart = archetype.getMultiNext(); oldPart != null; oldPart = oldPart.getMultiNext()) { final GameObject newarch = oldPart.createArch(); - arch.addTailPart(newarch); + gameObject.addTailPart(newarch); objects.add(newarch); // set map position (x, y) - newarch.setMapX(arch.getMapX() + newarch.getMultiX()); - newarch.setMapY(arch.getMapY() + newarch.getMultiY()); + newarch.setMapX(gameObject.getMapX() + newarch.getMultiX()); + newarch.setMapY(gameObject.getMapY() + newarch.getMultiY()); // now attach the default arch and stuff // (don't need edit type as we copy from head) Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-10-03 17:47:02 UTC (rev 474) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-10-03 18:42:15 UTC (rev 475) @@ -561,7 +561,7 @@ // loop through all existing ArchPanels and find all arches // along with their display-category - GameObject arch; + GameObject archetype; for (CArchPanel.PanelNode node = CArchPanel.getStartPanelNode(); node != null; node = node.next) { @@ -571,34 +571,34 @@ // process every arch in this panel for (int i = 0; i < numList.length; i++) { - arch = mainControl.getArch(numList[i]); + archetype = mainControl.getArchetype(numList[i]); - if (arch.isTail()) { + if (archetype.isTail()) { log.error("Collect Error: Multipart Tail in Panel found!"); } - out.writeBytes("Object " + arch.getArchetypeName() + "\n"); + out.writeBytes("Object " + archetype.getArchetypeName() + "\n"); - if (arch.getObjName() != null) { - out.writeBytes("name " + arch.getObjName() + "\n"); + if (archetype.getObjName() != null) { + out.writeBytes("name " + archetype.getObjName() + "\n"); } - if (arch.getFaceName() != null) { - out.writeBytes("face " + arch.getFaceName() + "\n"); + if (archetype.getFaceName() != null) { + out.writeBytes("face " + archetype.getFaceName() + "\n"); } - if (arch.getArchTypNr() > 0) { - out.writeBytes("type " + arch.getArchTypNr() + "\n"); + if (archetype.getArchTypNr() > 0) { + out.writeBytes("type " + archetype.getArchTypNr() + "\n"); } // special: add a string-attribute with the display-category out.writeBytes("editor_folder " + node.getTitle() + "/" + catList[i] + "\n"); // add message text - if (arch.getMsgText() != null && arch.getMsgText().trim().length() > 0) { - out.writeBytes("msg\n" + arch.getMsgText().trim() + "\nendmsg\n"); + if (archetype.getMsgText() != null && archetype.getMsgText().trim().length() > 0) { + out.writeBytes("msg\n" + archetype.getMsgText().trim() + "\nendmsg\n"); } - out.writeBytes(arch.getObjectText()); - if (arch.getObjectText().lastIndexOf(0x0a) != arch.getObjectText().length() - 1) { + out.writeBytes(archetype.getObjectText()); + if (archetype.getObjectText().lastIndexOf(0x0a) != archetype.getObjectText().length() - 1) { out.writeBytes("\n"); } @@ -609,7 +609,7 @@ } // if multi-head, we must attach the tails - for (GameObject tail = arch.getMultiNext(); tail != null; tail = tail.getMultiNext()) { + for (GameObject tail = archetype.getMultiNext(); tail != null; tail = tail.getMultiNext()) { out.writeBytes("More\n"); out.writeBytes("Object " + tail.getArchetypeName() + "\n"); @@ -649,7 +649,7 @@ } // finally we need to get the "map"-arch, which is not in the panels - final GameObject maparch = mainControl.getArch(ArchObjectParser.STARTARCH_NAME); + final GameObject maparch = mainControl.getArchetype(ArchObjectParser.STARTARCH_NAME); if (maparch != null) { count++; @@ -682,8 +682,8 @@ } // check if we still missed any arches - if (count - mainControl.getArchCount() != 0) { - log.warn((mainControl.getArchCount() - count) + " archetypes have been missed during collect!"); + if (count - getArchetypeCount() != 0) { + log.warn((getArchetypeCount() - count) + " archetypes have been missed during collect!"); } pbar.setValue(count); @@ -820,7 +820,7 @@ } } pbar.setValue(faceListCount); // finished - pbar.finished(mainControl.getArchCount(), faceListCount); + pbar.finished(getArchetypeCount(), faceListCount); // close png file out.close(); Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-10-03 17:47:02 UTC (rev 474) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-10-03 18:42:15 UTC (rev 475) @@ -332,13 +332,13 @@ /** * Check if a given archetype fits within map bounds. Multi tiles can't be * set if going out of borders. - * @param archnanme the archetype to check + * @param archName the archetype to check * @param xx the x-coordinate to place archName * @param yy the y-coordinate to place archName * @param intern ??? */ private boolean testArchToMap(final String archName, final int xx, final int yy, final int intern) { - for (GameObject part = getDefaultArch(archName); part != null; part = part.getMultiNext()) { + for (GameObject part = getArchetype(archName); part != null; part = part.getMultiNext()) { final int mapx = xx + part.getMultiX(); final int mapy = yy + part.getMultiY(); if (!isPointValid(mapx, mapy)) { @@ -391,7 +391,7 @@ return false; } - newarch = getDefaultArch(archName); // temp. store this arch + newarch = getArchetype(archName); // temp. store this arch if (newarch == null) { return false; } @@ -403,7 +403,7 @@ if (archName == null) { return false; // only one autojoin type per square allowed } - newarch = getDefaultArch(archName); + newarch = getArchetype(archName); } GameObject newHead = null; @@ -507,7 +507,7 @@ archName = newarch.getArchetypeName(); } // create a new copy of a default arch - invnew = getDefaultArch(archName).createArch(); + invnew = getArchetype(archName).createArch(); } else { // create clone from a pickmap if (!newarch.isMulti()) { @@ -649,7 +649,7 @@ node.remove(); // do autojoining - final GameObject temp = getDefaultArch(node.getArchetypeName()); // get defarch + final GameObject temp = getArchetype(node.getArchetypeName()); // get defarch if (mainControl.getAutojoin() && join == JOIN_ENABLE && mainControl.getJoinlist() != null && temp.getJoinList() != null && !temp.isMulti()) { // remove connections to the deleted arch @@ -1025,7 +1025,7 @@ * @return the default arch object instance corresponding to * <code>archName</code>, or <code>null</code> if it does not exist */ - private GameObject getDefaultArch(final String archName) { + private GameObject getArchetype(final String archName) { return mainControl.getArchetypeSet().getArchetype(archName); } Modified: trunk/crossfire/src/cfeditor/parameter/ArchParameter.java =================================================================== --- trunk/crossfire/src/cfeditor/parameter/ArchParameter.java 2006-10-03 17:47:02 UTC (rev 474) +++ trunk/crossfire/src/cfeditor/parameter/ArchParameter.java 2006-10-03 18:42:15 UTC (rev 475) @@ -30,19 +30,19 @@ parameterType = getParameterType(); } - @Nullable private GameObject locateArch(final String name) { - final ArchetypeSet stack = CMainControl.getInstance().getArchetypeSet(); + @Nullable private GameObject locateArchetype(final String archetypeName) { + final ArchetypeSet archetypeSet = CMainControl.getInstance().getArchetypeSet(); if (CMainControl.getInstance().getArchetypeSet().getLoadStatus() != ArchetypeSet.LoadStatus.COMPLETE) { return null; } - return stack.getArchetype(name); + return archetypeSet.getArchetype(archetypeName); } @Override public void fromXML(final Element e) { super.fromXML(e); valueString = e.getChildTextTrim("value"); if (CMainControl.getInstance().getArchetypeSet().getLoadStatus() == ArchetypeSet.LoadStatus.COMPLETE) { - setValue(locateArch(valueString)); + setValue(locateArchetype(valueString)); } } @@ -64,7 +64,7 @@ @Override public Object getValue() { if (super.getValue() == null) { - final GameObject o = locateArch(valueString); + final GameObject o = locateArchetype(valueString); if (o != null) { setValue(o); } Modified: trunk/daimonin/src/daieditor/CArchPanelPan.java =================================================================== --- trunk/daimonin/src/daieditor/CArchPanelPan.java 2006-10-03 17:47:02 UTC (rev 474) +++ trunk/daimonin/src/daieditor/CArchPanelPan.java 2006-10-03 18:42:15 UTC (rev 475) @@ -270,18 +270,18 @@ super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); final ArchetypeSet archetypeSet = mainControl.getArchetypeSet(); - final String archname = (String) value; - final GameObject arch = archetypeSet.getArchetype(archname); + final String archetypeName = (String) value; + final GameObject archetype = archetypeSet.getArchetype(archetypeName); if (isSelected) { // XXX it is not a good idea to query the selection information at this place. - archPanel.setSelectedArch(archname); + archPanel.setSelectedArch(archetypeName); mainControl.setStatusText(' ' + value.toString() + ' '); } - setText(archname); + setText(archetypeName); - if (arch.hasFaceObject()) { + if (archetype.hasFaceObject()) { setIcon(CMainControl.nofaceTileIcon); } else { - final ImageIcon icon = archetypeSet.getFace(arch.getFaceRealName()); + final ImageIcon icon = archetypeSet.getFace(archetype.getFaceRealName()); if (icon == null) { //setIcon(mainControl.nofaceTileIcon); } else { Modified: trunk/daimonin/src/daieditor/CFTreasureListTree.java =================================================================== --- trunk/daimonin/src/daieditor/CFTreasureListTree.java 2006-10-03 17:47:02 UTC (rev 474) +++ trunk/daimonin/src/daieditor/CFTreasureListTree.java 2006-10-03 18:42:15 UTC (rev 475) @@ -942,10 +942,10 @@ } } else if (content.getType() != TreasureObj.FOLDER) { // normal arch: display the face icon - final GameObject arch = CMainControl.getInstance().getArchetypeSet().getArchetype(content.getName()); - if (arch != null) { - if (!arch.hasFaceObject()) { - setIcon(CMainControl.getInstance().getArchetypeSet().getFace(arch.getFaceObjName())); + final GameObject archetype = CMainControl.getInstance().getArchetypeSet().getArchetype(content.getName()); + if (archetype != null) { + if (!archetype.hasFaceObject()) { + setIcon(CMainControl.getInstance().getArchetypeSet().getFace(archetype.getFaceObjName())); } else { setIcon(noface); } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-10-03 17:47:02 UTC (rev 474) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-10-03 18:42:15 UTC (rev 475) @@ -672,16 +672,6 @@ mainView.openHelpWindow(); } - // access to ArchNodeList - // remark: i use before some weird access to it, use this instead when you find it - public void addArchToList(final GameObject data) { - archetypeSet.addArchetype(data); - } - - public int getArchCount() { - return archetypeSet.getArchetypeCount(); - } - /** Set all global settings from the preferences. */ void readGlobalSettings() { initDirs(); @@ -1274,22 +1264,22 @@ // first: attach our map sucker to a default arch we have loaded //noinspection ForLoopWithMissingComponent for (final Iterator<GameObject> it = objects.iterator(); it.hasNext();) { - final GameObject arch = it.next(); - final GameObject defarch = archetypeSet.getArchetype(arch.getArchetypeName()); - if (defarch == null) { - noarch.append(arch.getArchetypeName()).append('\n'); + final GameObject gameObject = it.next(); + final GameObject archetype = archetypeSet.getArchetype(gameObject.getArchetypeName()); + if (archetype == null) { + noarch.append(gameObject.getArchetypeName()).append('\n'); noarchcount++; it.remove(); } - arch.setArchetype(defarch); + gameObject.setArchetype(archetype); // 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) - ArchObjectParser.postParseMapArch(arch, tileEdit); + ArchObjectParser.postParseMapArch(gameObject, tileEdit); // now lets assign the visible face - perhaps we have still a anim - arch.setObjectFace(); + gameObject.setObjectFace(); - archObjectParser.expandMulti(arch, tailList); + archObjectParser.expandMulti(gameObject, tailList); } for (final GameObject tail : tailList) { Modified: trunk/daimonin/src/daieditor/gameobject/ArchObjectParser.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchObjectParser.java 2006-10-03 17:47:02 UTC (rev 474) +++ trunk/daimonin/src/daieditor/gameobject/ArchObjectParser.java 2006-10-03 18:42:15 UTC (rev 475) @@ -293,7 +293,7 @@ // TODO cher: check whether the arch always is an Archetype and if so remove the method below. arch.setIsArchetype(); arch.setEditorFolder(newCat); - mainControl.addArchToList(arch); + mainControl.getArchetypeSet().addArchetype(arch); if (archmore) { calcLowestMulti(arch); Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-10-03 17:47:02 UTC (rev 474) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-10-03 18:42:15 UTC (rev 475) @@ -256,14 +256,14 @@ // TODO: Allow not having a def arch // at this point we MUST have a legal name and def arch // TODO:Then why not check this and throw an exception if not? - final GameObject defArch = getArchetype(defArchName); - if (name == null || defArchName == null || name.length() == 0 || defArchName.length() == 0 || defArch == null) { + final GameObject archetype = getArchetype(defArchName); + if (name == null || defArchName == null || name.length() == 0 || defArchName.length() == 0 || archetype == null) { System.err.println("Artifacts file: Line " + lineCount + " Object >" + defArchName + "< / >" + name + "< / >" + objTitle + "< has missing name or defArch"); } else if (editorCode != 0 && editorCode != 2) { // the next line of our file is part of a arch parse until a "end" comes // now the editor will do the same as the real server: // get the default arch as base and parse the new values over it // the extended functions of the artifacts file can be ignored here. - mainControl.getArchObjectParser().parseDefArchFromStream(myInput, editorCode == 2 ? null : defArch, thisLine, name, 0, fname); + mainControl.getArchObjectParser().parseDefArchFromStream(myInput, editorCode == 2 ? null : archetype, thisLine, name, 0, fname); // note: in the parser is a small part where we handle the title setting // and the reverse type setting for type == -1 (unique items marker in artifacts file) } else { @@ -644,8 +644,8 @@ } // check if we still missed any arches - if ((count + artifactCount) - mainControl.getArchCount() != 0) { - ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), "archCollectWarningMissed", mainControl.getArchCount() - count); + if ((count + artifactCount) - getArchetypeCount() != 0) { + ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), "archCollectWarningMissed", getArchetypeCount() - count); } pbar.setValue(count); } finally { Modified: trunk/daimonin/src/daieditor/map/DefaultMapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-10-03 17:47:02 UTC (rev 474) +++ trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-10-03 18:42:15 UTC (rev 475) @@ -95,7 +95,7 @@ /** * The MapControl that controls this MapModel. - * @deprecated it's not a good idea to require the MapModel implementation to know such a heavy-weight strongly UI-related glue class like {@link CMapControl}. + * @deprecated it's not a good idea to require the MapModel implementation to know such a heavy-weight strongly UI-related glue class like {@link MapControl}. * @todo care about Serialization if this field remains */ @Deprecated private final MapControl mapControl; @@ -219,7 +219,7 @@ /** {@inheritDoc} */ public boolean isMultiArchFittingToMap(final String archName, final Point pos, final boolean allowDouble) { - final GameObject head = getDefaultArch(archName); + final GameObject head = getArchetype(archName); final Point mapH = new Point(head.getMultiX(), head.getMultiY()); mapH.translate(pos.x, pos.y); if (!isPointValid(mapH)) { @@ -253,7 +253,7 @@ return false; } - final GameObject defaultArch = getDefaultArch(archName); + final GameObject defaultArch = getArchetype(archName); // FIXME: Check maximum RefX and RefY to check whether the multitile arch fits on the map. if (pos.x + defaultArch.getMinX() < 0 || pos.y + defaultArch.getMinY() < 0 || pos.x + defaultArch.getMaxX() > mapSize.getWidth() || pos.y + defaultArch.getMaxY() > mapSize.getHeight()) { @@ -344,7 +344,7 @@ archName = newarch.getArchetypeName(); } // create a new copy of a default arch - invnew = getDefaultArch(archName).createArch(); + invnew = getArchetype(archName).createArch(); } else { // create clone from a pickmap if (!newarch.isMulti()) { @@ -624,14 +624,14 @@ } /** - * Get a default {@link GameObject} instance. + * Get an Archetype. * * @param archName the archetype name * * @return the default arch object instance corresponding to * <code>archName</code>, or <code>null</code> if it does not exist */ - private GameObject getDefaultArch(final String archName) { + private GameObject getArchetype(final String archName) { return mainControl.getArchetypeSet().getArchetype(archName); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-03 17:47:12
|
Revision: 474 http://svn.sourceforge.net/gridarta/?rev=474&view=rev Author: christianhujer Date: 2006-10-03 10:47:02 -0700 (Tue, 03 Oct 2006) Log Message: ----------- Deleting obsolete nextBuildNumber.properties Removed Paths: ------------- trunk/daimonin/nextBuildNumber.properties Deleted: trunk/daimonin/nextBuildNumber.properties =================================================================== --- trunk/daimonin/nextBuildNumber.properties 2006-10-03 17:42:48 UTC (rev 473) +++ trunk/daimonin/nextBuildNumber.properties 2006-10-03 17:47:02 UTC (rev 474) @@ -1,3 +0,0 @@ -#Build Number for ANT. Do not edit! -#Tue Oct 03 13:59:48 CEST 2006 -build.number=2934 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-03 17:42:54
|
Revision: 473 http://svn.sourceforge.net/gridarta/?rev=473&view=rev Author: christianhujer Date: 2006-10-03 10:42:48 -0700 (Tue, 03 Oct 2006) Log Message: ----------- Changed build number to be the svn repository revision. Modified Paths: -------------- trunk/daimonin/build.xml Modified: trunk/daimonin/build.xml =================================================================== --- trunk/daimonin/build.xml 2006-10-03 17:21:26 UTC (rev 472) +++ trunk/daimonin/build.xml 2006-10-03 17:42:48 UTC (rev 473) @@ -24,7 +24,6 @@ <!-- set properties and clean build directory --> <target name="init"> <property file="developer.properties" /> - <property file="nextBuildNumber.properties" /> <property name="src.dir" value="src" /> <property name="lib.dir" value="lib" /> <property name="devlib.dir" value="devlib/" /><!-- Don't forget trailing / ! --> @@ -49,6 +48,7 @@ <property name="build.developer" value="unknown" /> <property name="javac.args" value="-Xlint:all,-path,-unchecked,-fallthrough,-serial" /> <tstamp><format property="build.tstamp" pattern="yyyy-MM-dd HH:mm:ss z" timezone="UTC"/></tstamp> + <exec executable="svnversion" outputproperty="build.number" /> <echoproperties destfile="build.properties"> <propertyset negate="true"> <propertyref prefix="user.ftp"/> @@ -311,10 +311,6 @@ <include name="update.properties" /> </fileset> </scp> - <buildnumber file="nextBuildNumber.properties" /> - <exec executable="svn"> - <arg line="commit -m "(This is an automatic message!) Released new update version, committing next build number." nextBuildNumber.properties" /> - </exec> </target> <target This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-03 17:22:00
|
Revision: 472 http://svn.sourceforge.net/gridarta/?rev=472&view=rev Author: christianhujer Date: 2006-10-03 10:21:26 -0700 (Tue, 03 Oct 2006) Log Message: ----------- Replaced CFileReader and CFileInputStream with corresponding factory methods in newly added class IOUtils. Modified Paths: -------------- trunk/crossfire/src/cfeditor/AutojoinList.java trunk/crossfire/src/cfeditor/CFArchTypeList.java trunk/crossfire/src/cfeditor/CFTreasureListTree.java trunk/crossfire/src/cfeditor/CMapFileDecode.java trunk/crossfire/src/cfeditor/FaceObject.java trunk/crossfire/src/cfeditor/MultiPositionData.java trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/CFTreasureListTree.java trunk/daimonin/src/daieditor/CMapFileDecode.java trunk/daimonin/src/daieditor/CMapFileEncode.java trunk/daimonin/src/daieditor/MultiPositionData.java trunk/daimonin/src/daieditor/Spells.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java trunk/daimonin/src/daieditor/gui/map/MapTilePane.java trunk/src/app/net/sf/gridarta/textedit/scripteditor/CFPythonPopup.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/io/IOUtils.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/io/CFileInputStream.java trunk/src/app/net/sf/gridarta/io/CFileReader.java Modified: trunk/crossfire/src/cfeditor/AutojoinList.java =================================================================== --- trunk/crossfire/src/cfeditor/AutojoinList.java 2006-10-03 17:11:54 UTC (rev 471) +++ trunk/crossfire/src/cfeditor/AutojoinList.java 2006-10-03 17:21:26 UTC (rev 472) @@ -30,7 +30,8 @@ import java.awt.Point; import java.io.FileNotFoundException; import java.io.IOException; -import net.sf.gridarta.io.CFileReader; +import java.io.BufferedReader; +import net.sf.gridarta.io.IOUtils; import org.apache.log4j.Logger; import org.jetbrains.annotations.Nullable; @@ -96,74 +97,75 @@ // open the resource file final String baseDir = IGUIConstants.CONFIG_DIR; - final CFileReader stream = new CFileReader(baseDir, filename); + final BufferedReader stream = IOUtils.createReader(baseDir, filename); + try { - // read the file - while ((line = stream.readLine()) != null) { - if (!line.startsWith("#") && line.length() > 0) { - line = line.trim(); // remove whitespace at both ends + // read the file + while ((line = stream.readLine()) != null) { + if (!line.startsWith("#") && line.length() > 0) { + line = line.trim(); // remove whitespace at both ends - if (!sectionFlag) { - // we are outside a section - if (line.equals("start")) { - sectionFlag = true; - count = 0; - } - } else { - // we are inside a section - if (line.equals("end")) { - if (count == 16) { - // we have 16 valid entries, now stick it into an AutojoinList - if (success) { - // attach a new element to the linked list - jlist.next = new AutojoinList(); - jlist = jlist.next; - } + if (!sectionFlag) { + // we are outside a section + if (line.equals("start")) { + sectionFlag = true; + count = 0; + } + } else { + // we are inside a section + if (line.equals("end")) { + if (count == 16) { + // we have 16 valid entries, now stick it into an AutojoinList + if (success) { + // attach a new element to the linked list + jlist.next = new AutojoinList(); + jlist = jlist.next; + } - jlist.stack = archstack; // set link to arch stack - jlist.archnames = new String[16]; // array to store the archetype names - for (int i = 0; i < 16; i++) { - jlist.archnames[i] = nbuf[i]; // store archetype name in the list - archstack.getArchetype(nbuf[i]).setJoinList(jlist); // set the link in the def. arch - if (log.isDebugEnabled()) { - log.debug("(" + i + ") arch: '" + archstack.getArchetype(nbuf[i]).getArchetypeName() + "' -> (" + nbuf[i] + ")"); + jlist.stack = archstack; // set link to arch stack + jlist.archnames = new String[16]; // array to store the archetype names + for (int i = 0; i < 16; i++) { + jlist.archnames[i] = nbuf[i]; // store archetype name in the list + archstack.getArchetype(nbuf[i]).setJoinList(jlist); // set the link in the def. arch + if (log.isDebugEnabled()) { + log.debug("(" + i + ") arch: '" + archstack.getArchetype(nbuf[i]).getArchetypeName() + "' -> (" + nbuf[i] + ")"); + } } + + success = true; // we did it! + } else if (count > 16) { + log.warn("In file " + filename + ": List with more than 16 valid entries!"); + } else if (archstack.getArchetypeCount() >= 1) { + log.warn("In file " + filename + ": List with less than 16 valid entries!"); } + sectionFlag = false; + } else if (count < 16) { + // add a new archid to the buffer - success = true; // we did it! - } else if (count > 16) { - log.warn("In file " + filename + ": List with more than 16 valid entries!"); - } else if (archstack.getArchetypeCount() >= 1) { - log.warn("In file " + filename + ": List with less than 16 valid entries!"); - } - sectionFlag = false; - } else if (count < 16) { - // add a new archid to the buffer + final GameObject arch = archstack.getArchetype(line); + if (arch != null) { + nbuf[count] = line; - final GameObject arch = archstack.getArchetype(line); - if (arch != null) { - nbuf[count] = line; - - if (!arch.isMulti()) { - count++; // no multipart, this one's okay + if (!arch.isMulti()) { + count++; // no multipart, this one's okay + } else { + log.warn("In file " + filename + ": Arch '" + line + "' is a multipart."); + } } else { - log.warn("In file " + filename + ": Arch '" + line + "' is a multipart."); + // (If no arches exist at all, errormessages are suppressed here) + if (archstack.getArchetypeCount() >= 1) { + log.warn("In file " + filename + ": Arch '" + line + "' not found."); + } } } else { - // (If no arches exist at all, errormessages are suppressed here) - if (archstack.getArchetypeCount() >= 1) { - log.warn("In file " + filename + ": Arch '" + line + "' not found."); - } + count++; // too many arches } - } else { - count++; // too many arches } } } + } finally { + stream.close(); } - - // close filestream - stream.close(); } catch (FileNotFoundException e) { if (log.isInfoEnabled()) { log.info("Autojoin definitions file '" + filename + "' not found."); @@ -271,7 +273,7 @@ /** * Looking up the given node in the archnames-array of this class. - * @param node node to lookup + * @param archname node to lookup * @return index of the node in the array. */ private int getIndex(final String archname) { Modified: trunk/crossfire/src/cfeditor/CFArchTypeList.java =================================================================== --- trunk/crossfire/src/cfeditor/CFArchTypeList.java 2006-10-03 17:11:54 UTC (rev 471) +++ trunk/crossfire/src/cfeditor/CFArchTypeList.java 2006-10-03 17:21:26 UTC (rev 472) @@ -39,7 +39,7 @@ import java.util.Vector; import javax.swing.JFileChooser; import javax.swing.filechooser.FileFilter; -import net.sf.gridarta.io.CFileReader; +import net.sf.gridarta.io.IOUtils; import org.apache.log4j.Logger; import org.jdom.Attribute; import org.jdom.DataConversionException; @@ -90,7 +90,7 @@ try { // open ascii filestream to the xml data final String baseDir = IGUIConstants.CONFIG_DIR; - final CFileReader fread = new CFileReader(baseDir, IGUIConstants.TYPEDEF_FILE); + final BufferedReader fread = IOUtils.createReader(baseDir, IGUIConstants.TYPEDEF_FILE); try { // parse xml document @@ -296,7 +296,7 @@ try { // open reading stream to the spells xml file final String baseDir = IGUIConstants.CONFIG_DIR; - final CFileReader reader = new CFileReader(baseDir, IGUIConstants.SPELL_FILE); + final BufferedReader reader = IOUtils.createReader(baseDir, IGUIConstants.SPELL_FILE); try { // parse xml document final SAXBuilder builder = new SAXBuilder(); @@ -418,17 +418,17 @@ fileReader = new FileReader(spellfile.getAbsolutePath()); bufferedReader = new BufferedReader(fileReader); - CFileReader.readUntil(bufferedReader, "spell spells", null); - CFileReader.readUntil(bufferedReader, "{", null); + IOUtils.readUntil(bufferedReader, "spell spells", null); + IOUtils.readUntil(bufferedReader, "{", null); // reading spellnames one after the other, // this loop is terminated by an EOFException int i = 0; // index for insertion in the vector for (int counter = 0; true; counter++) { - CFileReader.readUntil(bufferedReader, "{", "}"); - CFileReader.readUntil(bufferedReader, "\"", null); - String name = CFileReader.readUntil(bufferedReader, "\""); - CFileReader.readUntil(bufferedReader, "}", null); + IOUtils.readUntil(bufferedReader, "{", "}"); + IOUtils.readUntil(bufferedReader, "\"", null); + String name = IOUtils.readUntil(bufferedReader, "\""); + IOUtils.readUntil(bufferedReader, "}", null); name = name.trim(); // now insert this string lexographically into the vector Modified: trunk/crossfire/src/cfeditor/CFTreasureListTree.java =================================================================== --- trunk/crossfire/src/cfeditor/CFTreasureListTree.java 2006-10-03 17:11:54 UTC (rev 471) +++ trunk/crossfire/src/cfeditor/CFTreasureListTree.java 2006-10-03 17:21:26 UTC (rev 472) @@ -29,7 +29,6 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; -import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.BufferedReader; @@ -53,7 +52,7 @@ import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.TreePath; import net.sf.gridarta.help.Help; -import net.sf.gridarta.io.CFileReader; +import net.sf.gridarta.io.IOUtils; import org.apache.log4j.Logger; import org.jetbrains.annotations.Nullable; @@ -238,7 +237,7 @@ // first step: parsing datafile, adding all treasurelists to the tmpList vector try { final String baseDir = IGUIConstants.CONFIG_DIR; - final CFileReader reader = new CFileReader(baseDir, IGUIConstants.TREASURES_FILE); + final BufferedReader reader = IOUtils.createReader(baseDir, IGUIConstants.TREASURES_FILE); String line = null; // read line of file // read the whole file line by line Modified: trunk/crossfire/src/cfeditor/CMapFileDecode.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapFileDecode.java 2006-10-03 17:11:54 UTC (rev 471) +++ trunk/crossfire/src/cfeditor/CMapFileDecode.java 2006-10-03 17:21:26 UTC (rev 472) @@ -34,7 +34,7 @@ import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; -import net.sf.gridarta.io.CFileReader; +import net.sf.gridarta.io.IOUtils; import org.apache.log4j.Logger; import org.jetbrains.annotations.Nullable; @@ -75,7 +75,7 @@ * @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), CFileReader.MAP_ENCODING)); + final BufferedReader myInput = new BufferedReader(new InputStreamReader(new FileInputStream(file), IOUtils.MAP_ENCODING)); try { maxxlen = 0; maxylen = 0; Modified: trunk/crossfire/src/cfeditor/FaceObject.java =================================================================== --- trunk/crossfire/src/cfeditor/FaceObject.java 2006-10-03 17:11:54 UTC (rev 471) +++ trunk/crossfire/src/cfeditor/FaceObject.java 2006-10-03 17:21:26 UTC (rev 472) @@ -27,10 +27,11 @@ import com.sixlegs.image.png.PngImage; import java.awt.Toolkit; import java.io.ByteArrayInputStream; +import java.io.InputStream; import java.lang.ref.Reference; import java.lang.ref.SoftReference; import javax.swing.ImageIcon; -import net.sf.gridarta.io.CFileInputStream; +import net.sf.gridarta.io.IOUtils; import org.apache.log4j.Logger; import org.jetbrains.annotations.Nullable; @@ -97,17 +98,21 @@ if (log.isDebugEnabled()) { log.debug("Lazy loading " + name); } - final CFileInputStream fi = new CFileInputStream(ressourceDirectory, ressourceName); - if (dataStartIndex > 0) { - fi.skip(dataStartIndex); + final InputStream fi = IOUtils.createStream(ressourceDirectory, ressourceName); + try { + if (dataStartIndex > 0) { + fi.skip(dataStartIndex); // FIXME: result of skip is ignored. + } + final byte[] data = new byte[dataSize]; + fi.read(data); // FIXME: result of read is ignored. + final PngImage png = new PngImage(new ByteArrayInputStream(data)); // read png data from bytestream + png.setFlushAfterNextProduction(true); + final ImageIcon im = new ImageIcon(Toolkit.getDefaultToolkit().createImage(png)); + setFace(im); + return im; + } finally { + fi.close(); } - final byte[] data = new byte[dataSize]; - fi.read(data); - final PngImage png = new PngImage(new ByteArrayInputStream(data)); // read png data from bytestream - png.setFlushAfterNextProduction(true); - final ImageIcon im = new ImageIcon(Toolkit.getDefaultToolkit().createImage(png)); - setFace(im); - return im; } catch (final Exception e) { log.warn("Problem lazy loading face " + name, e); return null; Modified: trunk/crossfire/src/cfeditor/MultiPositionData.java =================================================================== --- trunk/crossfire/src/cfeditor/MultiPositionData.java 2006-10-03 17:11:54 UTC (rev 471) +++ trunk/crossfire/src/cfeditor/MultiPositionData.java 2006-10-03 17:21:26 UTC (rev 472) @@ -27,8 +27,9 @@ 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.CFileReader; +import net.sf.gridarta.io.IOUtils; import org.apache.log4j.Logger; /** @@ -74,7 +75,7 @@ private void load() { // read datafile line by line, parsing numbers into the array try { - final CFileReader reader = new CFileReader(CMainControl.getInstance().getArchDefaultFolder() + File.separator + IGUIConstants.CONFIG_DIR, IGUIConstants.ARCHDEF_FILE); + final BufferedReader reader = IOUtils.createReader(CMainControl.getInstance().getArchDefaultFolder() + File.separator + IGUIConstants.CONFIG_DIR, IGUIConstants.ARCHDEF_FILE); try { String num; // number, still in string format int xp = 0; // x-index in the data array Modified: trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java 2006-10-03 17:11:54 UTC (rev 471) +++ trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java 2006-10-03 17:21:26 UTC (rev 472) @@ -35,7 +35,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import net.sf.gridarta.io.CFileReader; +import net.sf.gridarta.io.IOUtils; import org.apache.log4j.Logger; import org.jdom.DataConversionException; import org.jdom.Document; @@ -85,7 +85,7 @@ try { // open reading stream to the spells xml file final String baseDir = IGUIConstants.CONFIG_DIR; - final CFileReader reader = new CFileReader(baseDir, IGUIConstants.TYPENR_FILE); + final BufferedReader reader = IOUtils.createReader(baseDir, IGUIConstants.TYPENR_FILE); try { // parse xml document Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-10-03 17:11:54 UTC (rev 471) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-10-03 17:21:26 UTC (rev 472) @@ -44,6 +44,7 @@ import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; +import java.io.InputStream; import java.util.Arrays; import java.util.Date; import java.util.HashMap; @@ -56,8 +57,7 @@ import javax.swing.JPanel; import javax.swing.JProgressBar; import javax.swing.SwingConstants; -import net.sf.gridarta.io.CFileInputStream; -import net.sf.gridarta.io.CFileReader; +import net.sf.gridarta.io.IOUtils; import net.sf.gridarta.gameobject.AbstractArchetypeSet; import org.apache.log4j.Logger; import org.jetbrains.annotations.Nullable; @@ -191,7 +191,7 @@ try { // open the resource file - final CFileReader stream = new CFileReader(IGUIConstants.CONFIG_DIR, IGUIConstants.ARCH_FILE); + final BufferedReader stream = IOUtils.createReader(IGUIConstants.CONFIG_DIR, IGUIConstants.ARCH_FILE); try { // load all arches mainControl.getArchObjectParser().parseDefArchFromStream(stream, 0); @@ -201,7 +201,7 @@ } loadAllCrossfirePNGFromCollect(); } catch (final FileNotFoundException e) { - // no need for a message here, CFileReader takes care of this + log.error("Error:", e); } catch (final IOException e) { log.error("Error:", e); } @@ -339,7 +339,7 @@ try { // open a bytestream to the resource file final String baseDir = IGUIConstants.CONFIG_DIR; - final CFileInputStream stream = new CFileInputStream(baseDir, IGUIConstants.PNG_FILE); + final InputStream stream = IOUtils.createStream(baseDir, IGUIConstants.PNG_FILE); try { int r; Modified: trunk/daimonin/src/daieditor/CFTreasureListTree.java =================================================================== --- trunk/daimonin/src/daieditor/CFTreasureListTree.java 2006-10-03 17:11:54 UTC (rev 471) +++ trunk/daimonin/src/daieditor/CFTreasureListTree.java 2006-10-03 17:21:26 UTC (rev 472) @@ -64,7 +64,7 @@ import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.TreePath; import net.sf.gridarta.help.Help; -import net.sf.gridarta.io.CFileReader; +import net.sf.gridarta.io.IOUtils; import net.sf.japi.util.EnumerationIterator; import org.jetbrains.annotations.Nullable; @@ -222,7 +222,6 @@ final List<TreasureTreeNode> tmpList = new ArrayList<TreasureTreeNode>(); // tmp. container for all treasurelists final List<TreasureTreeNode> needLink = new ArrayList<TreasureTreeNode>(); // all sub-treasurelist nodes that need linking treasureTable = new HashMap<String, TreasureTreeNode>(); // hashtable for all treasureTreeNodes - final CFileReader reader = null; // first step: parsing datafile, adding all treasurelists to the tmpList vector loadTreasureList(IGUIConstants.TREASURES_FILE, tmpList, needLink); @@ -328,7 +327,7 @@ } else { baseDir = CMainControl.getInstance().getArchDefaultFolder(); } - final CFileReader reader = new CFileReader(baseDir, fname); + final BufferedReader reader = IOUtils.createReader(baseDir, fname); // read the whole file line by line try { for (String rawLine; (rawLine = reader.readLine()) != null;) { Modified: trunk/daimonin/src/daieditor/CMapFileDecode.java =================================================================== --- trunk/daimonin/src/daieditor/CMapFileDecode.java 2006-10-03 17:11:54 UTC (rev 471) +++ trunk/daimonin/src/daieditor/CMapFileDecode.java 2006-10-03 17:21:26 UTC (rev 472) @@ -35,7 +35,7 @@ import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; -import net.sf.gridarta.io.CFileReader; +import net.sf.gridarta.io.IOUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -75,7 +75,7 @@ * @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), CFileReader.MAP_ENCODING)); + 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) Modified: trunk/daimonin/src/daieditor/CMapFileEncode.java =================================================================== --- trunk/daimonin/src/daieditor/CMapFileEncode.java 2006-10-03 17:11:54 UTC (rev 471) +++ trunk/daimonin/src/daieditor/CMapFileEncode.java 2006-10-03 17:21:26 UTC (rev 472) @@ -34,7 +34,7 @@ import java.io.IOException; import java.util.Formatter; import net.sf.gridarta.Size2D; -import net.sf.gridarta.io.CFileReader; +import net.sf.gridarta.io.IOUtils; /** * The <code>CMapFileEncode</code> is used to write a map to a file. @@ -63,7 +63,7 @@ public void encodeMapFile(final File file, final MapModel mapModel) throws FileNotFoundException, IOException { final MapArchObject mapArch = mapModel.getMapArchObject(); try { - format = new Formatter(file, CFileReader.MAP_ENCODING); + format = new Formatter(file, IOUtils.MAP_ENCODING); //GameObject multi; // write map header: map arch Modified: trunk/daimonin/src/daieditor/MultiPositionData.java =================================================================== --- trunk/daimonin/src/daieditor/MultiPositionData.java 2006-10-03 17:11:54 UTC (rev 471) +++ trunk/daimonin/src/daieditor/MultiPositionData.java 2006-10-03 17:21:26 UTC (rev 472) @@ -29,7 +29,8 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; -import net.sf.gridarta.io.CFileReader; +import java.io.BufferedReader; +import net.sf.gridarta.io.IOUtils; import org.apache.log4j.Logger; /** @@ -74,7 +75,7 @@ private void load() { // read datafile line by line, parsing numbers into the array try { - final CFileReader reader = new CFileReader(CMainControl.getInstance().getArchDefaultFolder() + File.separator + IGUIConstants.CONFIG_DIR, IGUIConstants.ARCHDEF_FILE); + final BufferedReader reader = IOUtils.createReader(CMainControl.getInstance().getArchDefaultFolder() + File.separator + IGUIConstants.CONFIG_DIR, IGUIConstants.ARCHDEF_FILE); try { final Dimension d = new Dimension(); final Point p = new Point(); Modified: trunk/daimonin/src/daieditor/Spells.java =================================================================== --- trunk/daimonin/src/daieditor/Spells.java 2006-10-03 17:11:54 UTC (rev 471) +++ trunk/daimonin/src/daieditor/Spells.java 2006-10-03 17:21:26 UTC (rev 472) @@ -39,7 +39,7 @@ import javax.swing.JFileChooser; import javax.swing.filechooser.FileFilter; import javax.xml.parsers.DocumentBuilder; -import net.sf.gridarta.io.CFileReader; +import net.sf.gridarta.io.IOUtils; import net.sf.japi.swing.ActionFactory; import static net.sf.japi.swing.ActionFactory.getFactory; import net.sf.japi.util.filter.file.FilenameFileFilter; @@ -109,14 +109,14 @@ try { final BufferedReader in = new BufferedReader(new FileReader(spellfile.getAbsolutePath())); try { - CFileReader.readUntil(in, "spell spells", null); - CFileReader.readUntil(in, "{", null); + IOUtils.readUntil(in, "spell spells", null); + IOUtils.readUntil(in, "{", null); for (int counter = 0; true; counter++) { // XXX this is ugly! - CFileReader.readUntil(in, "{", "}"); - CFileReader.readUntil(in, "\"", null); - final String name = CFileReader.readUntil(in, "\"").trim(); - CFileReader.readUntil(in, "}", null); + IOUtils.readUntil(in, "{", "}"); + IOUtils.readUntil(in, "\"", null); + final String name = IOUtils.readUntil(in, "\"").trim(); + IOUtils.readUntil(in, "}", null); spells.put(name, Integer.toString(counter)); } Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-10-03 17:11:54 UTC (rev 471) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-10-03 17:21:26 UTC (rev 472) @@ -58,7 +58,7 @@ import java.util.List; import java.util.Map; import javax.swing.ImageIcon; -import net.sf.gridarta.io.CFileReader; +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; @@ -297,7 +297,7 @@ loadAllDaimoninAnimationsFromCollect(); // open the resource file final String baseDir = CMainControl.getInstance().getArchDefaultFolder(); - final CFileReader stream = new CFileReader(baseDir, IGUIConstants.ARCH_FILE); + final BufferedReader stream = IOUtils.createReader(baseDir, IGUIConstants.ARCH_FILE); try { // load all arches mainControl.getArchObjectParser().parseDefArchFromStream(stream, 0, IGUIConstants.ARCH_FILE); @@ -409,7 +409,7 @@ /** Loading all animations from the big collected animations file. */ private void loadAllDaimoninAnimationsFromCollect() { try { - final Reader in = new CFileReader(mainControl.getArchDefaultFolder(), "animations"); + final Reader in = IOUtils.createReader(mainControl.getArchDefaultFolder(), "animations"); try { mainControl.getAnimationObjects().loadAnims(in, null); } finally { @@ -492,7 +492,7 @@ try { final File dfile = new File(mainControl.getArchDefaultFolder(), IGUIConstants.ARCH_FILE); // now open the output-stream - final BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(dfile), CFileReader.MAP_ENCODING)); + final BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(dfile), IOUtils.MAP_ENCODING)); try { int artifactCount = 0; @@ -662,7 +662,7 @@ */ private void collectDaimoninAnimations(final Progress pbar) { try { - final BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(mainControl.getArchDefaultFolder(), "animations")), CFileReader.MAP_ENCODING)); + final BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(mainControl.getArchDefaultFolder(), "animations")), IOUtils.MAP_ENCODING)); try { final AnimationObjects animationObjects = mainControl.getAnimationObjects(); pbar.setLabel(ACTION_FACTORY.getString("archCollectAnimations"), animationObjects.size()); @@ -692,7 +692,7 @@ */ private void collectDaimoninAnimationTree(final Progress pbar) { try { - final BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(new File(mainControl.getArchDefaultFolder(), IGUIConstants.CONFIG_DIR), IGUIConstants.ANIMTREE_FILE)), CFileReader.MAP_ENCODING)); + final BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(new File(mainControl.getArchDefaultFolder(), IGUIConstants.CONFIG_DIR), IGUIConstants.ANIMTREE_FILE)), IOUtils.MAP_ENCODING)); try { final AnimationObjects animationObjects = mainControl.getAnimationObjects(); final Map<String, String> tree = animationObjects.getAnimPathTree(); Modified: trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java 2006-10-03 17:11:54 UTC (rev 471) +++ trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java 2006-10-03 17:21:26 UTC (rev 472) @@ -36,7 +36,7 @@ import java.io.Reader; import java.util.HashMap; import java.util.Map; -import net.sf.gridarta.io.CFileReader; +import net.sf.gridarta.io.IOUtils; import org.jetbrains.annotations.Nullable; @@ -102,7 +102,7 @@ * @throws DuplicateAnimationException in case an animation was not unique */ public void loadAnims(final File animFile) throws FileNotFoundException, IOException, AnimationParseException, DuplicateAnimationException { - final Reader in = new InputStreamReader(new FileInputStream(animFile), CFileReader.MAP_ENCODING); + final Reader in = new InputStreamReader(new FileInputStream(animFile), IOUtils.MAP_ENCODING); try { final String path = (new File(PathManager.getArchPath(animFile.getPath()))).getParent().replace('\\', '/'); loadAnims(in, path); @@ -180,7 +180,7 @@ * @throws FileNotFoundException in case the file couldn't be opened */ public void loadAnimTree(final File animTreeFile) throws FileNotFoundException, IOException { - final Reader in = new InputStreamReader(new FileInputStream(animTreeFile), CFileReader.MAP_ENCODING); + final Reader in = new InputStreamReader(new FileInputStream(animTreeFile), IOUtils.MAP_ENCODING); try { loadAnimTree(in); } finally { Modified: trunk/daimonin/src/daieditor/gui/map/MapTilePane.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/MapTilePane.java 2006-10-03 17:11:54 UTC (rev 471) +++ trunk/daimonin/src/daieditor/gui/map/MapTilePane.java 2006-10-03 17:21:26 UTC (rev 472) @@ -58,7 +58,7 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import net.sf.gridarta.Size2D; -import net.sf.gridarta.io.CFileReader; +import net.sf.gridarta.io.IOUtils; import net.sf.japi.swing.ActionFactory; import static net.sf.japi.swing.ActionFactory.getFactory; import org.jetbrains.annotations.Nullable; @@ -632,7 +632,7 @@ for (final TileMapHeader tileHeader : tileHeaders) { if (tileHeader != null) { try { - final BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(tileHeader.mapfile), CFileReader.MAP_ENCODING)); + final BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(tileHeader.mapfile), IOUtils.MAP_ENCODING)); try { tileHeader.maparch.writeMapArch(bufferedWriter); final String tail = tileHeader.maptail.toString().trim(); @@ -772,7 +772,7 @@ @Nullable private static TileMapHeader loadMapFileHeader(final File file) { TileMapHeader maphead = null; try { - final BufferedReader myInput = new BufferedReader(new InputStreamReader(new FileInputStream(file), CFileReader.MAP_ENCODING)); + final BufferedReader myInput = new BufferedReader(new InputStreamReader(new FileInputStream(file), IOUtils.MAP_ENCODING)); try { // first of all we read the map arch (if that fails we throw an exception) Deleted: trunk/src/app/net/sf/gridarta/io/CFileInputStream.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/CFileInputStream.java 2006-10-03 17:11:54 UTC (rev 471) +++ trunk/src/app/net/sf/gridarta/io/CFileInputStream.java 2006-10-03 17:21:26 UTC (rev 472) @@ -1,127 +0,0 @@ -/* - * Daimonin Java Editor. - * Copyright (C) 2000 Michael Toennies - * Copyright (C) 2001 Andreas Vogl - * Copyright (C) 2005 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 net.sf.gridarta.io; - -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.net.URI; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Class for opening and reading a buffered stream to a BINARY resource-file. - * If no such file is found, the file is loaded from the jar archive. - * This class is very similar to {@link CFileReader}. - * The file is tried to open in the following order: - * <ol> - * <li>Try opening it with the given directory. The directory path is relative - * to the current working directory, the file path relative to that - * directory..</li> - * <li>Try opening it without the given directory. The file path is relative to - * the current working directory.</li> - * <li>Try opening the file as a system resource through the class loader.</li> - * </ol> - * Only if all tries failed, creating the stream fails. - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @see CFileReader - * @todo eventually remove this class in terms of instantiability. All functionality provided by CFileInputStream is static. - */ -public final class CFileInputStream extends BufferedInputStream { - - /** - * Creates a new CFileInputStream to a specified resource file. - * @param dname name of directory that the file is in (<code>null</code> - * means the file is located in the editor root dir) - * @param fname name of the resource file - * @throws FileNotFoundException In case all three tries to open the file failed - */ - public CFileInputStream(@Nullable final String dname, @NotNull final String fname) throws FileNotFoundException { - super(createStream(dname, fname)); - } - - /** - * Open the resource file for reading. - * @param dname directory name to read from - * @param fname file name of file to read - * @return Stream for reading from <var>fname</var> - * @throws FileNotFoundException In case all tries to open the file failed - */ - @SuppressWarnings({"MethodWithMultipleReturnPoints", "MethodWithMoreThanThreeNegations"}) - @NotNull private static InputStream createStream(@Nullable final String dname, @NotNull final String fname) throws FileNotFoundException { - try { // 1st try normal binary file relative to specified directory - return new FileInputStream(new File(dname, fname)); - } catch (final Exception e) { - // ignore - } - try { // 2nd try binary file relative to user's current working directory - return new FileInputStream(fname); - } catch (final Exception e) { // 3rd try via system resource from class loader - // ignore - } - final URI currentDir = new File(System.getProperty("user.dir")).toURI(); - final String relWithDir = currentDir.relativize(new File(dname, fname).toURI()).toString(); - final String relPlain = currentDir.relativize(new File(fname).toURI()).toString(); - final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); - try { // 3rd try context class loader relative to specified directory - @Nullable final InputStream stream = contextClassLoader.getResourceAsStream(relWithDir); - if (stream != null) { - return stream; - } - } catch (final Exception e) { - // ignore - } - try { // 4th try context class loader relative to class loader's top level directory - @Nullable final InputStream stream = contextClassLoader.getResourceAsStream(relPlain); - if (stream != null) { - return stream; - } - } catch (final Exception e) { - // ignore - } - try { // 5th try system class loader relative to specified directory - @Nullable final InputStream stream = ClassLoader.getSystemResourceAsStream(relWithDir); - if (stream != null) { - return stream; - } - } catch (final Exception e) { - // ignore - } - try { // 6th try system class loader relative to class loader's top level directory - @Nullable final InputStream stream = ClassLoader.getSystemResourceAsStream(relPlain); - if (stream != null) { - return stream; - } - } catch (final Exception e) { - // ignore - } - throw new FileNotFoundException("CFileInputStream couldn't find " + new File(dname, fname) + "."); - } - -} // class CFileInputStream Deleted: trunk/src/app/net/sf/gridarta/io/CFileReader.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/CFileReader.java 2006-10-03 17:11:54 UTC (rev 471) +++ trunk/src/app/net/sf/gridarta/io/CFileReader.java 2006-10-03 17:21:26 UTC (rev 472) @@ -1,187 +0,0 @@ -/* - * Daimonin Java Editor. - * Copyright (C) 2000 Michael Toennies - * Copyright (C) 2001 Andreas Vogl - * Copyright (C) 2005 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 net.sf.gridarta.io; - -import java.io.BufferedReader; -import java.io.EOFException; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.Reader; -import java.io.UnsupportedEncodingException; - -/** - * Class for opening and reading a buffered stream to an ASCII resource-file. - * If no such file is found, the file is loaded from the jar archive. - * This class is very similar to {@link CFileInputStream}. - * The file is tried to open in the following order: - * <ol> - * <li>Try opening it with the given directory. The directory path is relative to the current working directory, the file path relative to that - * directory..</li> - * <li>Try opening it without the given directory. The file path is relative to the current working directory.</li> - * <li>Try opening the file as a system resource through the class loader.</li> - * </ol> - * Only if all tries failed, creating the stream fails. - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @todo eventually remove readUntil - this is afaik only used for reading arches and such, and since there should be an integrated arch editor... - * @todo eventually remove this class in terms of instantiability. All functionality provided by CFileReader is static. - * @see CFileInputStream - */ -public final class CFileReader extends BufferedReader { - - /** Maximum number of characters to read in readUntil. */ - private static final long READ_MAX = 10000L; - - /** - * Encoding to use for maps and other data. - * The encoding given here is used for reading and writing maps. - * You shouldn't change this only because you use an UTF-8 system or so, since the encoding used here MUST be compatible with the server and the - * client. The paragraph sign § is the critical character. - * @todo once the mailing list decided on the § character, eventually replace by "us-ascii". - */ - public static final String MAP_ENCODING = "iso-8859-1"; - - /** - * Open an ascii-stream to the specified resource file. - * @param dname name of directory that the file is in (<code>null</code> means the file is located in the editor root dir) - * @param fname name of the resource file - * @throws FileNotFoundException in case all three tries to open the file failed - */ - public CFileReader(final String dname, final String fname) throws FileNotFoundException { - super(createReader(dname, fname)); - } - - /** - * Open the resource file for reading. - * @param dname name of directory that the file is in (null means the file is located in the editor root dir) - * @param fname name of the resource file - * @return Stream for reading from <var>fname</var> - * @throws FileNotFoundException In case all three tries to open the file failed - */ - private static Reader createReader(final String dname, final String fname) throws FileNotFoundException { - try { - return new InputStreamReader(new CFileInputStream(dname, fname), MAP_ENCODING); - } catch (final UnsupportedEncodingException e) { - throw new Error(e); - } - } - - /** - * Reads characters from the BufferedReader stream till 'tag' is found. If - * found, the method returns with stream pointing right after the - * appearance of 'tag'. - * @param stream ascii input stream to read from - * @param tag stop reading at the string 'tag' - * @param abort throw <code>EOFException</code> at string 'abort' (this can be null) - * @throws IOException an I/O-error occurred while reading the file - * @throws EOFException the end of file was reached, or the 'abort' string - * has been encountered - * @todo Should the encounter of the abort string before the tag really be - * an EOFException? That's semantically wrong, but current usage code - * relies on this :( - */ - public static void readUntil(final BufferedReader stream, final String tag, final String abort) throws IOException { - int c; // character value, read from the stream - int t = 0; // tag index - int a = 0; // abort index - - if (abort != null) { - // look both for 'tag' and 'abort' - do { - c = stream.read(); - if (c == tag.charAt(t)) { - t++; - } else { - t = 0; - } - if (c == abort.charAt(a)) { - a++; - } else { - a = 0; - } - } while (t < tag.length() && a < abort.length() && c != -1); - } else { - // look only for 'tag' - do { - c = stream.read(); - if (c == tag.charAt(t)) { - t++; - } else { - t = 0; - } - } while (t < tag.length() && c != -1); - } - - // if we did not find the tag, an EOFException is thrown - if (c == -1) { - throw new EOFException(); - } - - // if we found the string 'abort', throw EOFException as well - if (abort != null && a == abort.length()) { - throw new EOFException(); - } - } - - /** - * Reads characters from the BufferedReader stream till 'tag' is found. - * Similar to readUntil(), except that the read String is returned. 'tag' - * is not included in the returned String. - * @param stream ascii input stream to read from - * @param tag stop reading at the string 'tag' - * @return the string between the starting pos. of 'stream' (inclusive) and - * the first character of 'tag' (exclusive). - * @throws IOException an I/O-error occurred while reading the file - * @throws EOFException the end of file was reached - */ - public static String readUntil(final BufferedReader stream, final String tag) throws IOException { - final StringBuilder sb = new StringBuilder(); - int c; // character value, read from the stream - int t = 0; // index - - long count = 0; // counter (to realize when shooting past EOF) - final long maxCount = READ_MAX; // bail out when counter exceeds this value - - do { - c = stream.read(); // read one character - sb.append((char) c); - if (c == tag.charAt(t)) { - t++; - } else { - t = 0; - } - } while (t < tag.length() && c != -1 && count++ < maxCount); - - // if we did not find the tag, an EOFException is thrown - if (c == -1 || count >= maxCount) { - throw new EOFException(); - } - // cut 'tag' off, at the end of the string - return sb.substring(0, sb.length() - tag.length()); - } - -} // class CFileReader Added: trunk/src/app/net/sf/gridarta/io/IOUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/IOUtils.java (rev 0) +++ trunk/src/app/net/sf/gridarta/io/IOUtils.java 2006-10-03 17:21:26 UTC (rev 472) @@ -0,0 +1,229 @@ +package net.sf.gridarta.io; + +import java.io.Reader; +import java.io.FileNotFoundException; +import java.io.InputStreamReader; +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; + +/** + * Utility-class for Gridarta's I/O. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public final class IOUtils { + + /** Maximum number of characters to read in readUntil. */ + public static final long READ_MAX = 10000L; + + /** + * Encoding to use for maps and other data. + * The encoding given here is used for reading and writing maps. + * You shouldn't change this only because you use an UTF-8 system or so, since the encoding used here MUST be compatible with the server and the + * client. The paragraph sign § is the critical character. + * @todo once the mailing list decided on the § character, eventually replace by "us-ascii". + */ + public static final String MAP_ENCODING = "iso-8859-1"; + + /** Utility class - do not instanciate. */ + private IOUtils() { + } + + /** + * Open the resource file for reading. + * @param dname directory name to read from + * @param fname file name of file to read + * @return Stream for reading from <var>fname</var> + * @throws FileNotFoundException In case all tries to open the file failed + */ + @NotNull public static BufferedInputStream createStream(@Nullable final String dname, @NotNull final String fname) throws FileNotFoundException { + return new BufferedInputStream(createStreamImpl(dname, fname)); + } + + /** + * Open the resource file for reading. + * @param dname directory name to read from + * @param fname file name of file to read + * @return Stream for reading from <var>fname</var> + * @throws FileNotFoundException In case all tries to open the file failed + */ + @SuppressWarnings({"MethodWithMultipleReturnPoints", "MethodWithMoreThanThreeNegations"}) + @NotNull private static InputStream createStreamImpl(@Nullable final String dname, @NotNull final String fname) throws FileNotFoundException { + try { // 1st try normal binary file relative to specified directory + return new FileInputStream(new File(dname, fname)); + } catch (final Exception e) { + // ignore + } + try { // 2nd try binary file relative to user's current working directory + return new FileInputStream(fname); + } catch (final Exception e) { // 3rd try via system resource from class loader + // ignore + } + final URI currentDir = new File(System.getProperty("user.dir")).toURI(); + final String relWithDir = currentDir.relativize(new File(dname, fname).toURI()).toString(); + final String relPlain = currentDir.relativize(new File(fname).toURI()).toString(); + final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); + try { // 3rd try context class loader relative to specified directory + @Nullable final InputStream stream = contextClassLoader.getResourceAsStream(relWithDir); + if (stream != null) { + return stream; + } + } catch (final Exception e) { + // ignore + } + try { // 4th try context class loader relative to class loader's top level directory + @Nullable final InputStream stream = contextClassLoader.getResourceAsStream(relPlain); + if (stream != null) { + return stream; + } + } catch (final Exception e) { + // ignore + } + try { // 5th try system class loader relative to specified directory + @Nullable final InputStream stream = ClassLoader.getSystemResourceAsStream(relWithDir); + if (stream != null) { + return stream; + } + } catch (final Exception e) { + // ignore + } + try { // 6th try system class loader relative to class loader's top level directory + @Nullable final InputStream stream = ClassLoader.getSystemResourceAsStream(relPlain); + if (stream != null) { + return stream; + } + } catch (final Exception e) { + // ignore + } + throw new FileNotFoundException("couldn't find " + new File(dname, fname) + "."); + } + + /** + * Open the resource file for reading. + * @param dname name of directory that the file is in (null means the file is located in the editor root dir) + * @param fname name of the resource file + * @return Stream for reading from <var>fname</var> + * @throws FileNotFoundException In case all three tries to open the file failed + */ + @NotNull public static BufferedReader createReader(@Nullable final String dname, @NotNull final String fname) throws FileNotFoundException { + return new BufferedReader(createReaderImpl(dname, fname)); + } + + /** + * Open the resource file for reading. + * @param dname name of directory that the file is in (null means the file is located in the editor root dir) + * @param fname name of the resource file + * @return Stream for reading from <var>fname</var> + * @throws FileNotFoundException In case all three tries to open the file failed + */ + @NotNull private static Reader createReaderImpl(@Nullable final String dname, @NotNull final String fname) throws FileNotFoundException { + try { + return new InputStreamReader(createStreamImpl(dname, fname), MAP_ENCODING); + } catch (final UnsupportedEncodingException e) { + throw new Error(e); + } + } + + /** + * Reads characters from the BufferedReader stream till 'tag' is found. If + * found, the method returns with stream pointing right after the + * appearance of 'tag'. + * @param stream ascii input stream to read from + * @param tag stop reading at the string 'tag' + * @param abort throw <code>EOFException</code> at string 'abort' (this can be null) + * @throws IOException an I/O-error occurred while reading the file + * @throws EOFException the end of file was reached, or the 'abort' string + * has been encountered + * @todo Should the encounter of the abort string before the tag really be + * an EOFException? That's semantically wrong, but current usage code + * relies on this :( + */ + public static void readUntil(@NotNull final BufferedReader stream, @NotNull final String tag, @Nullable final String abort) throws IOException { + int c; // character value, read from the stream + int t = 0; // tag index + int a = 0; // abort index + + if (abort != null) { + // look both for 'tag' and 'abort' + do { + c = stream.read(); + if (c == tag.charAt(t)) { + t++; + } else { + t = 0; + } + if (c == abort.charAt(a)) { + a++; + } else { + a = 0; + } + } while (t < tag.length() && a < abort.length() && c != -1); + } else { + // look only for 'tag' + do { + c = stream.read(); + if (c == tag.charAt(t)) { + t++; + } else { + t = 0; + } + } while (t < tag.length() && c != -1); + } + + // if we did not find the tag, an EOFException is thrown + if (c == -1) { + throw new EOFException(); + } + + // if we found the string 'abort', throw EOFException as well + if (abort != null && a == abort.length()) { + throw new EOFException(); + } + } + + /** + * Reads characters from the BufferedReader stream till 'tag' is found. + * Similar to readUntil(), except that the read String is returned. 'tag' + * is not included in the returned String. + * @param stream ascii input stream to read from + * @param tag stop reading at the string 'tag' + * @return the string between the starting pos. of 'stream' (inclusive) and + * the first character of 'tag' (exclusive). + * @throws java.io.IOException an I/O-error occurred while reading the file + * @throws java.io.EOFException the end of file was reached + */ + public static String readUntil(@NotNull final BufferedReader stream, @NotNull final String tag) throws IOException { + final StringBuilder sb = new StringBuilder(); + int c; // character value, read from the stream + int t = 0; // index + + long count = 0; // counter (to realize when shooting past EOF) + final long maxCount = READ_MAX; // bail out when counter exceeds this value + + do { + c = stream.read(); // read one character + sb.append((char) c); + if (c == tag.charAt(t)) { + t++; + } else { + t = 0; + } + } while (t < tag.length() && c != -1 && count++ < maxCount); + + // if we did not find the tag, an EOFException is thrown + if (c == -1 || count >= maxCount) { + throw new EOFException(); + } + // cut 'tag' off, at the end of the string + return sb.substring(0, sb.length() - tag.length()); + } + +} // class IOUtils Property changes on: trunk/src/app/net/sf/gridarta/io/IOUtils.java ___________... [truncated message content] |
From: <aki...@us...> - 2006-10-03 17:12:20
|
Revision: 471 http://svn.sourceforge.net/gridarta/?rev=471&view=rev Author: akirschbaum Date: 2006-10-03 10:11:54 -0700 (Tue, 03 Oct 2006) Log Message: ----------- Unify MapSquare implementation. Modified Paths: -------------- trunk/crossfire/src/cfeditor/AutojoinList.java trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/CMapArchPanel.java trunk/crossfire/src/cfeditor/CMapFileDecode.java trunk/crossfire/src/cfeditor/CMapFileEncode.java trunk/crossfire/src/cfeditor/CMapTileList.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/CopyBuffer.java trunk/crossfire/src/cfeditor/ReplaceDialog.java trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/crossfire/src/cfeditor/map/MapControl.java trunk/crossfire/src/cfeditor/map/MapModel.java Added Paths: ----------- trunk/crossfire/src/cfeditor/gameobject/GameObjectContainer.java trunk/crossfire/src/cfeditor/gameobject/RecursiveGameObjectIterator.java trunk/crossfire/src/cfeditor/map/MapSquare.java Removed Paths: ------------- trunk/crossfire/src/cfeditor/gameobject/GameObjectIterator.java trunk/crossfire/src/cfeditor/gameobject/GameObjectIteratorDeleteGameMapObject.java trunk/crossfire/src/cfeditor/gameobject/GameObjectIteratorDeleteMapGame.java Modified: trunk/crossfire/src/cfeditor/AutojoinList.java =================================================================== --- trunk/crossfire/src/cfeditor/AutojoinList.java 2006-10-03 16:45:57 UTC (rev 470) +++ trunk/crossfire/src/cfeditor/AutojoinList.java 2006-10-03 17:11:54 UTC (rev 471) @@ -27,6 +27,7 @@ import cfeditor.gameobject.ArchetypeSet; import cfeditor.gameobject.GameObject; import cfeditor.map.MapModel; +import java.awt.Point; import java.io.FileNotFoundException; import java.io.IOException; import net.sf.gridarta.io.CFileReader; @@ -310,9 +311,8 @@ * @return arch which is part of this joinlist, null if no such arch exists */ @Nullable private GameObject findArchOfJoinlist(final MapModel map, final int x, final int y) { - GameObject tmpArch = map.getTopArchObject(x, y); // we look through the arches at the given location (top to bottom): - for (; tmpArch != null; tmpArch = tmpArch.getPrev()) { + for (final GameObject tmpArch : map.getMapSquare(new Point(x, y)).reverse()) { if (stack.getArchetype(tmpArch.getArchetypeName()).getJoinList() == this) { return tmpArch; // we found an arch } Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-10-03 16:45:57 UTC (rev 470) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-10-03 17:11:54 UTC (rev 471) @@ -274,11 +274,11 @@ } void moveTileUp(final GameObject arch, final boolean refresh) { - currentMap.getMapModel().moveTileUp(arch, refresh); + arch.moveUp(); // XXX: ignores refresh } void moveTileDown(final GameObject arch, final boolean refresh) { - currentMap.getMapModel().moveTileDown(arch, refresh); + arch.moveDown(); // XXX: ignores refresh } /** collect CF arches */ Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2006-10-03 16:45:57 UTC (rev 470) +++ trunk/crossfire/src/cfeditor/CMainView.java 2006-10-03 17:11:54 UTC (rev 471) @@ -307,7 +307,7 @@ // now try to get the topmost object GameObject arch = null; if (pmap.isPointValid(pmap.getMapView().getHighlightStart())) { - arch = pmap.getMapModel().getBottomArchObject(pmap.getMapView().getHighlightStart()); + arch = pmap.getMapModel().getMapSquare(pmap.getMapView().getHighlightStart()).getFirst(); } if (arch != null) { // so here we return the arch from the pickmap Modified: trunk/crossfire/src/cfeditor/CMapArchPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapArchPanel.java 2006-10-03 16:45:57 UTC (rev 470) +++ trunk/crossfire/src/cfeditor/CMapArchPanel.java 2006-10-03 17:11:54 UTC (rev 471) @@ -284,7 +284,7 @@ invnew = arch.createClone(inv.getMapX(), inv.getMapY()); } - inv.addInvObj(invnew); + inv.addLast(invnew); mainControl.getArchObjectParser().postParseMapArch(invnew, 0); mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), inv.getMyID()); mainControl.getCurrentMap().setLevelChangedFlag(); // the map has been modified Modified: trunk/crossfire/src/cfeditor/CMapFileDecode.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapFileDecode.java 2006-10-03 16:45:57 UTC (rev 470) +++ trunk/crossfire/src/cfeditor/CMapFileDecode.java 2006-10-03 17:11:54 UTC (rev 471) @@ -165,7 +165,7 @@ // ok, we have setup our arch, now check for inventory if (container != null) { - container.addInvObj(arch); + container.addLast(arch); } } } Modified: trunk/crossfire/src/cfeditor/CMapFileEncode.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapFileEncode.java 2006-10-03 16:45:57 UTC (rev 470) +++ trunk/crossfire/src/cfeditor/CMapFileEncode.java 2006-10-03 17:11:54 UTC (rev 471) @@ -85,9 +85,7 @@ 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++) { - final Iterator it = mapModel.getArchObjects(pos); - while (it.hasNext()) { - final GameObject node = (GameObject) it.next(); + for (final GameObject node : mapModel.getMapSquare(pos)) { // only non multi suckers if (!node.isMulti()) { if (!writeMapArch(node, false)) { @@ -101,9 +99,7 @@ // 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++) { - final Iterator it = mapModel.getArchObjects(pos); - while (it.hasNext()) { - final GameObject node = (GameObject) it.next(); + for (final GameObject node : mapModel.getMapSquare(pos)) { // search only for heads! if (node.isMulti() && node.isHead()) { // only the heads get stored in the mapfile Modified: trunk/crossfire/src/cfeditor/CMapTileList.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapTileList.java 2006-10-03 16:45:57 UTC (rev 470) +++ trunk/crossfire/src/cfeditor/CMapTileList.java 2006-10-03 17:11:54 UTC (rev 471) @@ -314,33 +314,29 @@ postSelect = -1; listCounter = 0; currentSquare = map.getMapModel().getMouseRightPos(); - GameObject node = map.getMapModel().getMouseRightPosObject(); - // Jump to the end of the list - for (; node != null && node.getNext() != null; node = node.getNext()) { - ; - } + if (currentSquare != null) { + // Now go through the list backwards and put all arches + // on the panel in this order + for (final GameObject node : map.getMapModel().getMapSquare(currentSquare).reverse()) { + // add the node + if (node.getMyID() == archid) { + postSelect = listCounter; + } + final String num = Integer.toString(node.getMyID()); + String liststring = listDef.substring(0, 10 - num.length()) + num; + liststring += listDef; + listCounter++; + model.addElement(liststring); - // Now go through the list backwards and put all arches - // on the panel in this order - for (; node != null; node = node.getPrev()) { - // add the node - if (node.getMyID() == archid) { - postSelect = listCounter; - } - final String num = Integer.toString(node.getMyID()); - String liststring = listDef.substring(0, 10 - num.length()) + num; - liststring += listDef; - listCounter++; - model.addElement(liststring); + // if view-settings are applied, mark topmost "visible" tile for selection + if (mainControl.isTileEditSet() && !foundSIndex && mainControl.isTileEdit(node.getEditType())) { + sIndex = listCounter - 1; // select this tile + foundSIndex = true; // this is it - don't select any other tile + } - // if view-settings are applied, mark topmost "visible" tile for selection - if (mainControl.isTileEditSet() && !foundSIndex && mainControl.isTileEdit(node.getEditType())) { - sIndex = listCounter - 1; // select this tile - foundSIndex = true; // this is it - don't select any other tile + addInvObjects(node, archid, 1); // browse the inventory of the map object } - - addInvObjects(node, archid, 1); // browse the inventory of the map object } if (postSelect != -1) { Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-10-03 16:45:57 UTC (rev 470) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-10-03 17:11:54 UTC (rev 471) @@ -729,9 +729,7 @@ mainControl.getUnknownTileIconX().paintIcon(this, grfx, x * 32 + bOffset, y * 32 + bOffset); } } else { - final Iterator it = mapModel.getArchObjects(x, y); - while (it.hasNext()) { - final GameObject node = (GameObject) it.next(); + for (final GameObject node : mapModel.getMapSquare(new Point(x, y))) { filter.objectInSquare(node); if (!filter.canShow(node)) { continue; @@ -835,10 +833,7 @@ } else { tmpGrfx.fillRect(0, 0, 32, 32); // loop through all arches on that square and draw em - final Iterator it = mapModel.getArchObjects(x, y); - while (it.hasNext()) { - final GameObject node = (GameObject) it.next(); - + for (final GameObject node : mapModel.getMapSquare(new Point(x, y))) { filter.objectInSquare(node); if (!filter.canShow(node)) { continue; @@ -1242,23 +1237,20 @@ } else { // delete the topmost arch (matching the view settings) // on that square and redraw the map - GameObject tmpArch = mapControl.getBottomArchObject(temp); - if (tmpArch != null) { - // go to the topmost arch (end of the list) - for (; tmpArch.getNext() != null; tmpArch = tmpArch.getNext()) { - ; - } + GameObject tmpArch = null; + final Iterator<GameObject> it = mapControl.getMapModel().getMapSquare(temp).reverse().iterator(); + while (it.hasNext()) { + tmpArch = it.next(); // now search backwards for matching view settings - for (; tmpArch != null && mainControl.getTileEdit() != 0 && - !mainControl.isTileEdit(tmpArch.getEditType()); tmpArch = tmpArch.getPrev()) { - ; + if (mainControl.getTileEdit() == 0 || mainControl.isTileEdit(tmpArch.getEditType())) { + break; } - if (tmpArch != null) { - needRedraw = calcArchRedraw(tmpArch); // get redraw info - mapControl.deleteMapArch(tmpArch.getMyID(), temp, false, MapModel.JOIN_ENABLE); - } } + if (tmpArch != null) { + needRedraw = calcArchRedraw(tmpArch); // get redraw info + mapControl.deleteMapArch(tmpArch.getMyID(), temp, false, MapModel.JOIN_ENABLE); + } needMpanelUpdate[1] = true; // when dragging is done, update map panel } @@ -1367,23 +1359,18 @@ // delete the topmost arch (matching the view settings) on that square // and redraw the map - GameObject tmpArch = mapControl.getBottomArchObject(mapLoc); - if (tmpArch != null) { - // go to the topmost arch (end of the list) - for (; tmpArch.getNext() != null; tmpArch = tmpArch.getNext()) { - ; + GameObject tmpArch = null; + final Iterator<GameObject> it = mapControl.getMapModel().getMapSquare(mapLoc).reverse().iterator(); + while (it.hasNext()) { + tmpArch = it.next(); + if (mainControl.getTileEdit() == 0 || mainControl.isTileEdit(tmpArch.getEditType())) { + break; } + } + if (tmpArch != null) { + needRedraw = calcArchRedraw(tmpArch); // get redraw info + mapControl.deleteMapArch(tmpArch.getMyID(), mapLoc, false, MapModel.JOIN_ENABLE); - // now search backwards for matching view settings - for (; tmpArch != null && mainControl.getTileEdit() != 0 && - !mainControl.isTileEdit(tmpArch.getEditType()); tmpArch = tmpArch.getPrev()) { - ; - } - if (tmpArch != null) { - needRedraw = calcArchRedraw(tmpArch); // get redraw info - mapControl.deleteMapArch(tmpArch.getMyID(), mapLoc, false, MapModel.JOIN_ENABLE); - } - // update mapArch panel mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), -1); } @@ -1426,9 +1413,7 @@ boolean insertAllowed = true; // are we allowed to insert this? if (!allowMany) { // check if there is already an arch of that kind - final Iterator it = mapControl.getArchObjects(pos); - while (it.hasNext()) { - final GameObject t = (GameObject) it.next(); + for (final GameObject t : mapControl.getMapModel().getMapSquare(pos)) { if (t.getArchetypeName().equals(newarch.getArchetypeName()) && t.getArchTypNr() == newarch.getArchTypNr()) { insertAllowed = false; // there's a match - don't insert a second one Modified: trunk/crossfire/src/cfeditor/CopyBuffer.java =================================================================== --- trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-10-03 16:45:57 UTC (rev 470) +++ trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-10-03 17:11:54 UTC (rev 471) @@ -30,7 +30,9 @@ import cfeditor.map.MapControl; import cfeditor.map.MapModel; import java.awt.Point; +import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import net.sf.gridarta.Size2D; import org.apache.log4j.Logger; @@ -150,7 +152,6 @@ } // recycle and resize buffer - mapData.freeMapArchObject(); // free old map (/buffer) object bufWidth = Math.abs(offset.x) + 1; // new width bufHeight = Math.abs(offset.y) + 1; // new height mapArch.setMapSize(new Size2D(bufWidth, bufHeight)); @@ -162,10 +163,11 @@ // cycle through all tile coordinates which are highlighted: final Point pos = new Point(); + final List<GameObject> archesToDelete = 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.getArchObjectsDeleteMapArch(pos, false, MapModel.JOIN_DISABLE); + final Iterator<GameObject> it = mapControl.getMapModel().getMapSquare(pos).iterator(); while (it.hasNext()) { final GameObject arch = it.next(); @@ -173,7 +175,7 @@ // (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.getContainer() == null && + 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)); @@ -190,13 +192,17 @@ // 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)) { - it.remove(); + archesToDelete.add(arch); } } } } } + for (final GameObject arch : archesToDelete) { + arch.remove(); + } + // finally redraw the map if (mode != DO_COPY) { mainControl.refreshCurrentMap(); @@ -223,9 +229,7 @@ if (mapControl.isPointValid(pos)) { sourcePos.x = pos.x - startp.x; sourcePos.y = pos.y - startp.y; - final Iterator<GameObject> it = buffCtrl.getArchObjects(sourcePos); - while (it.hasNext()) { - final GameObject arch = it.next(); + for (final GameObject arch : buffCtrl.getMapModel().getMapSquare(sourcePos)) { if (!arch.isMulti()) { // read arch from buffer and stick in on the map final GameObject clone = arch.createClone(pos.x, pos.y); @@ -243,9 +247,7 @@ if (mapControl.isPointValid(pos)) { sourcePos.x = pos.x - startp.x; sourcePos.y = pos.y - startp.y; - final Iterator<GameObject> it = buffCtrl.getArchObjects(sourcePos); - while (it.hasNext()) { - final GameObject arch = it.next(); + for (final GameObject arch : buffCtrl.getMapModel().getMapSquare(sourcePos)) { if (arch.isMulti()) { addArchToMap(mapControl, arch, pos, -1, false); } Modified: trunk/crossfire/src/cfeditor/ReplaceDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/ReplaceDialog.java 2006-10-03 16:45:57 UTC (rev 470) +++ trunk/crossfire/src/cfeditor/ReplaceDialog.java 2006-10-03 17:11:54 UTC (rev 471) @@ -33,6 +33,7 @@ import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.util.ArrayList; import java.util.Iterator; import javax.swing.BorderFactory; import javax.swing.Box; @@ -321,35 +322,54 @@ // cycle through all tile coordinates between startpoint and offset: final Point pos = new Point(); int replaceCount = 0; + final ArrayList<GameObject> objectsToReplace = 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++) { - final Iterator<GameObject> it = mapControl.getArchObjectsDeleteMapArch(pos, false, false); - while (it.hasNext()) { - final GameObject node = it.next(); + // find objects to replace + objectsToReplace.clear(); + for (final GameObject node : mapControl.getMapModel().getMapSquare(pos)) { if (node.isHead() && ((matchCriteria == MATCH_ARCH_NAME && node.getArchetypeName() != null && node.getArchetypeName().equalsIgnoreCase(matchString)) || (matchCriteria == MATCH_OBJ_NAME && node.getBestName().equalsIgnoreCase(matchString)))) { - // first, delete the old arch - final GameObject prevArch = node.getPrev(); - it.remove(); + objectsToReplace.add(node); + } + } - if (replaceArch != null && !deleteOnly) { - // insert replacement object - if (replaceArch.isMulti()) { - // multi's cannot be inserted properly, so we just put them ontop - replaceArch = replaceArch.getHead(); - mapControl.addArchToMap(replaceArch.getArchetypeName(), pos, 0, false); + // actually replace the objects + for (final GameObject objectToDelete : objectsToReplace) { + final Iterator<GameObject> it = mapControl.getMapModel().getMapSquare(pos).iterator(); + GameObject prevArch = null; + GameObject node = null; + while (it.hasNext()) { + node = it.next(); - // TODO: if from pickmap it could have special attributes -> copy them - } else { - mapControl.insertArchToMap(replaceArch, null, prevArch, pos, false); - } + if (node == objectToDelete) { + break; } - replaceCount++; + + prevArch = node; } + assert node != null; + + // first, delete the old arch + node.remove(); + + if (replaceArch != null && !deleteOnly) { + // insert replacement object + if (replaceArch.isMulti()) { + // multi's cannot be inserted properly, so we just put them ontop + replaceArch = replaceArch.getHead(); + mapControl.addArchToMap(replaceArch.getArchetypeName(), pos, 0, false); + + // TODO: if from pickmap it could have special attributes -> copy them + } else { + mapControl.insertArchToMap(replaceArch, null, prevArch, pos, false); + } + } + replaceCount++; } } } Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-10-03 16:45:57 UTC (rev 470) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-10-03 17:11:54 UTC (rev 471) @@ -31,6 +31,7 @@ import cfeditor.IGUIConstants; import cfeditor.MultiArchData; import cfeditor.ScriptArchData; +import cfeditor.map.MapSquare; import java.io.BufferedReader; import java.io.IOException; import java.io.StringReader; @@ -49,7 +50,7 @@ * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -public class GameObject implements Cloneable, net.sf.gridarta.gameobject.GameObject, Iterable<GameObject> { +public class GameObject extends GameObjectContainer implements Cloneable, net.sf.gridarta.gameobject.GameObject, Iterable<GameObject> { private static final Logger log = Logger.getLogger(GameObject.class); @@ -147,9 +148,13 @@ /** * Container of this GameObject. - * The Crossfire implementation only knows <code>null</code> (map or unlinked) or being an inventory item. + * There are two possibilities for the container: + * <ul> + * <li>Another GameObject, which means this object is in the inventory of that GameObject.</li> + * <li>A MapSquare, which means that this GameObject is top level on that MapSquare.</li> + * </ul> */ - @Nullable private GameObject container = null; + private GameObjectContainer container; /** * All inventory objects. Set to {@link Collections#EMPTY_LIST} @@ -440,23 +445,82 @@ } /** {@inheritDoc} */ - @Nullable public GameObject getContainer() { + @NotNull public GameObjectContainer getContainer() { return container; } /** {@inheritDoc} */ @NotNull public GameObject getTopContainer() { - GameObject tmpArch; + return isInContainer() ? ((GameObject) container).getTopContainer() : this; + } - for (tmpArch = this; tmpArch.getContainer() != null; - tmpArch = tmpArch.getContainer()) { - ; - } + /** + * Sets container of this GameObject. + * There are two possibilities for the container: + * <ul> + * <li>Another GameObject, which means this object is in the inventory of that GameObject.</li> + * <li>A MapSquare, which means that this GameObject is top level on that MapSquare.</li> + * </ul> + * @param container container of this GameObject. + */ + public void setContainer(final GameObjectContainer container) { + this.container = container; + } - return tmpArch; + /** + * Check whether this GameObject is in a Container (in Daimonin sense, + * which means being in a MapSquare isn't, but being in an GameObject is). + * @return <code>true</code> if this GameObject has a Container and the + * Container is an GameObject, otherwise (no Container or Container is not + * an GameObject) false + */ + public boolean isInContainer() { + return container != null && container instanceof GameObject; } + /** {@inheritDoc} */ + @Override public MapSquare getMapSquare() { + return container != null ? container.getMapSquare() : null; + } + + /** Move this GameObject top. */ + public void moveTop() { + container.moveTop(this); + } + + /** Move this GameObject up. */ + public void moveUp() { + container.moveUp(this); + } + + /** Move this GameObject down. */ + public void moveDown() { + container.moveDown(this); + } + + /** Move this GameObject bottom. */ + public void moveBottom() { + container.moveBottom(this); + } + /** + * Remove this GameObject from its container. Do nothing if the object is + * not inside a container. + * This method also takes perfectly well care of multihead arches. + */ + public void remove() { + final GameObject head = getHead(); + for (GameObject tail = head.getMultiNext(); tail != null; tail = tail.getMultiNext()) { + if (tail.container != null) { + tail.container.remove(tail); + } + } + if (head.container != null) { + head.container.remove(head); + } + } + + /** * Set the String of an arch attribute in the objectText. * @param attributeName search for "attributeName <string>" * @param value value to set @@ -572,59 +636,21 @@ } /** - * The given <code>GameObject</code> 'arch' is placed as inventory - * into 'this' <code>GameObject</code>. (Keep in mind that 'arch' - * has to be a free (unlinked) instance of <code>GameObject</code>.) - * @param arch the <code>GameObject</code> to be placed in the inventory + * Insert an GameObject before this GameObject. + * @param node GameObject to append */ - public void addInvObj(final GameObject arch) { - // arch must not be already in a container - if (arch.container != null) { - throw new IllegalArgumentException(); - } - - if (inv == Collections.EMPTY_LIST) { - inv = new LinkedList<GameObject>(); - } - - inv.add(arch); - arch.container = this; - - arch.setMapX(getMapX()); - arch.setMapY(getMapY()); + public void insertBefore(final GameObject node) { + getContainer().insertBefore(node, this); } - /** Remove 'this' arch from the inventory-list and delete all it's pointers */ - public void removeInvObj() { - // object's inventory must have already been deleted - if (inv != Collections.EMPTY_LIST) { - throw new IllegalArgumentException(); - } - - // object must be in a container - if (container == null) { - throw new IllegalArgumentException(); - } - - // remove this object from its parent container - if (!container.inv.remove(this)) { - throw new AssertionError(); - } - - if (container.inv.size() == 0) { - container.inv = Collections.EMPTY_LIST; - } + /** + * Insert an GameObject after this GameObject. + * @param node GameObject to append + */ + public void insertAfter(final GameObject node) { + getContainer().insertAfter(this, node); } - /** Remove all inventory objects. */ - public void clearInventory() { - while (inv.size() > 0) { - final GameObject inv = this.inv.get(0); - inv.clearInventory(); - inv.removeInvObj(); - } - } - /** {@inheritDoc} */ public int countInvObjects() { int count = 0; @@ -821,38 +847,24 @@ return mapy; } - /** - * Set Next link. - * @param arch Arch to point next to - */ - public void setNext(final GameObject arch) { - next = arch; + /** {@inheritDoc} */ + @Override public void addLast(final GameObject arch) { + super.addLast(arch); + // force type change when a MONSTER is put in a spawn point + if (typeList.getTypeOfArch(this) != null && typeList.getTypeOfArch(this).getTypeNr() == 81 && typeList.getTypeOfArch(arch).getTypeNr() == 80) { + arch.archType = 83; // change to SPAWN_POINT_MOB + } } - /** - * Set Prev link. - * @param arch Arch to point prev to - */ - public void setPrev(final GameObject arch) { - prev = arch; + /** {@inheritDoc} */ + @Override public void addFirst(final GameObject arch) { + super.addFirst(arch); + // force type change when a MONSTER is put in a spawn point + if (typeList.getTypeOfArch(this).getTypeNr() == 81 && typeList.getTypeOfArch(arch).getTypeNr() == 80) { + arch.archType = 83; // change to SPAWN_POINT_MOB + } } - /** - * Get Next link. - * @return next link - */ - public GameObject getNext() { - return next; - } - - /** - * Get Prev link. - * @return prev link - */ - public GameObject getPrev() { - return prev; - } - /* Set the default face. Number is index of face list */ public void setFaceNr(final int nr) { facenr = nr; @@ -1203,20 +1215,12 @@ // If 'this' arch is a container, we have to create clones // of the whole inventory (recursively) and link them in: for (final GameObject invItem : inv) { - clone.addInvObj(invItem.createClone(posx, posy)); + clone.addLast(invItem.createClone(posx, posy)); } return clone; } - /** - * @return true if 'this' arch is a container (has something - * inside), otherwise false - */ - public boolean isContainer() { - return inv.size() > 0; - } - /** @return true if 'this' arch is part of a multisquare object */ public boolean isMulti() { return multi != null; @@ -1458,9 +1462,4 @@ return cachedAttribute.get(name); } - /** {@inheritDoc} */ - public Iterator<GameObject> iterator() { - return inv.iterator(); - } - } // class GameObject Added: trunk/crossfire/src/cfeditor/gameobject/GameObjectContainer.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObjectContainer.java (rev 0) +++ trunk/crossfire/src/cfeditor/gameobject/GameObjectContainer.java 2006-10-03 17:11:54 UTC (rev 471) @@ -0,0 +1,427 @@ +/* + * 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 cfeditor.gameobject; + +import cfeditor.map.MapSquare; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Base class for classes that contain GameObjects as children in the sense of containment. + * The interface serves 2 main purposes: + * <ul> + * <li>{@link GameObject} extends this class for containing other GameObjects, like inventory contents e.g. of a bag or attached events.</li> + * <li>{@link MapSquare} extends this class to list the tiles on a MapSquare.</li> + * </ul> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @todo: In case of MapSquares, this class is most likely bogus regarding multipart objects. This needs to be fixed. + */ +@SuppressWarnings({"ClassReferencesSubclass"}) +public abstract class GameObjectContainer implements Iterable<GameObject>, Serializable { + + /** Serial Version. */ + private static final long serialVersionUID = 1L; + + /** + * The contents of this container. + * @note the order of this container is bottom to top. + */ + @NotNull private List<GameObject> contents; + + /** Iterable implementation for recursice traversal. */ + @NotNull private transient Iterable<GameObject> recursive; + + /** Iterable implementation for reverse traversal. */ + @NotNull private transient Iterable<GameObject> reverse; + + /** Create a new GameObjectContainer. */ + protected GameObjectContainer() { + initData(); + } + + /** + * Initialize the fields. + * This is needed because there are two ways of object construction, + * <ul> + * <li>regular object construction via constructor invocation and</li> + * <li>cloning of objects via {@link #clone()}.</li> + * </ul> + */ + private void initData() { + contents = new ArrayList<GameObject>(); + recursive = new Iterable<GameObject>() { + /** {@inheritDoc} */ + public Iterator<GameObject> iterator() { + return new RecursiveGameObjectIterator(GameObjectContainer.this); + } + }; + reverse = new Iterable<GameObject>() { + /** {@inheritDoc} */ + public Iterator<GameObject> iterator() { + return new ReverseIterator<GameObject>(contents); + } + }; // Iterable<GameObject> reverse + } + + /** + * {@inheritDoc} + * The Iterator returned does not recurse, it only contains objects on the first level. + * The Iterator returned is transparent, that means modifying the iterator's collection actually modifies the underlying GameObjectContainer. + */ + @NotNull public final Iterator<GameObject> iterator() { + // Do not return contents.iterator() directly because otherwise the remove() operation will not properly unlink the removed GameObject from its container. + return new Iterator<GameObject>() { + + /** The basic iterator. */ + private Iterator<GameObject> delegate = contents.iterator(); + private GameObject current; + + /** {@inheritDoc} */ + public boolean hasNext() { + return delegate.hasNext(); + } + + /** {@inheritDoc} */ + public GameObject next() { + return current = delegate.next(); + } + + /** {@inheritDoc} */ + public void remove() { + // keep this in sync with GameObjectContainer#remove(GameObject) + // we can't simply invoke GameObjectContainer#remove(current) because that would result in a ConcurrentModificationException. + delegate.remove(); + current.setContainer(null); + squareChanged(); + } + }; + } + + /** + * Return an object that is the reverse representation. + * Invoke this method if you want to iterate over the contained GameObjects in reverse order. + * @return reverse representation + */ + @NotNull public final Iterable<GameObject> reverse() { + return reverse; + } + + /** + * Return an object that is a recursive representation. + * Invoke this method if you want to iterate over the contained GameObjects recursively. + * @return recursive representation + */ + @NotNull public final Iterable<GameObject> recursive() { + return recursive; + } + + /** + * Check whether this square is empty. + * @return <code>true</code> if this square is empty, otherwise <code>false</code> + */ + public boolean isEmpty() { + return contents.isEmpty(); + } + + /** + * Return the first GameObject contained in this container. + * @return first GameObject contained or <code>null</code> if {@link #isEmpty()} returns <code>true</code> + */ + @Nullable public final GameObject getFirst() { + return contents.isEmpty() ? null : contents.get(0); + } + + /** + * Return the last GameObject contained in this container. + * You should not invoke this method to iterate over GameObjects, such invocation is regarded deprecated. + * @return last GameObject contained or <code>null</code> if {@link #isEmpty()} returns <code>true</code> + */ + @Nullable public final GameObject getLast() { + return contents.isEmpty() ? null : contents.get(contents.size() - 1); + } + + /** + * Remove a GameObject from this container. + * @param gameObject GameObject to remove + * @throws IllegalArgumentException if <var>gameObject</var> isn't in this container + */ + final void remove(@NotNull final GameObject gameObject) { + // keep this in sync with iterator() + if (!contents.remove(gameObject)) { + throw new IllegalArgumentException(gameObject + " wasn't inside container " + this); + } + gameObject.setContainer(null); + squareChanged(); + } + + /** Remove all GameObjects from this container. */ + public final void removeAll() { + if (contents.size() <= 0) { + return; + } + + for (final GameObject gameObject : contents) { + gameObject.setContainer(null); + } + contents.clear(); + squareChanged(); + } + + /** + * Move an item to top. + * @param gameObject item to move to top + * @throws IllegalArgumentException if <var>gameObject</var> isn't in this container + */ + public final void moveTop(@NotNull final GameObject gameObject) { + final int oldIndex = contents.indexOf(gameObject); + if (oldIndex != contents.size() - 1) { + if (!contents.remove(gameObject)) { + throw new IllegalArgumentException(gameObject + " wasn't inside container " + this); + } + contents.add(gameObject); + squareChanged(); + } + } + + /** + * Move an item up. + * @param gameObject item to move up + * @throws IllegalArgumentException if <var>gameObject</var> isn't in this container + */ + public final void moveUp(@NotNull final GameObject gameObject) { + final int oldIndex = contents.indexOf(gameObject); + if (oldIndex < contents.size() - 1) { + if (!contents.remove(gameObject)) { + throw new IllegalArgumentException(gameObject + " wasn't inside container " + this); + } + contents.add(oldIndex + 1, gameObject); + squareChanged(); + } + } + + /** + * Move an item down. + * @param gameObject item to move down + * @throws IllegalArgumentException if <var>gameObject</var> isn't in this container + */ + public final void moveDown(@NotNull final GameObject gameObject) { + final int oldIndex = contents.indexOf(gameObject); + if (oldIndex > 0) { + if (!contents.remove(gameObject)) { + throw new IllegalArgumentException(gameObject + " wasn't inside container " + this); + } + contents.add(oldIndex - 1, gameObject); + squareChanged(); + } + } + + /** + * Move an item to bottom. + * @param gameObject item to move to bottom + * @throws IllegalArgumentException if <var>gameObject</var> isn't in this container + */ + public final void moveBottom(@NotNull final GameObject gameObject) { + final int oldIndex = contents.indexOf(gameObject); + if (oldIndex != 0) { + if (!contents.remove(gameObject)) { + throw new IllegalArgumentException(gameObject + " wasn't inside container " + this); + } + contents.add(0, gameObject); + squareChanged(); + } + } + + /** + * Get the X coordinate on the map. + * @return X coordinate on map + */ + public abstract int getMapX(); + + /** + * Get the Y coordinate on the map. + * @return Y coordinate on map + */ + public abstract int getMapY(); + + /** + * Add the given GameObject at the end of this Container. + * @param gameObject the free yet unlinked <code>GameObject</code> to be placed in the inventory + * @throws IllegalArgumentException if <var>gameObject</var> already is inside another container + */ + public void addLast(@NotNull final GameObject gameObject) { + if (gameObject.isInContainer()) { + throw new IllegalArgumentException("Can't add " + gameObject + " to " + this + " because it's already inside " + gameObject.getContainer()); + } + contents.add(gameObject); + gameObject.setContainer(this); + squareChanged(); + } + + /** + * Add the given GameObject at the end of this Container. + * @param gameObject the free yet unlinked <code>GameObject</code> to be placed in the inventory + * @throws IllegalArgumentException if <var>gameObject</var> already is inside another container + */ + public void addFirst(@NotNull final GameObject gameObject) { + if (gameObject.isInContainer()) { + throw new IllegalArgumentException("Can't add " + gameObject + " to " + this + " because it's already inside " + gameObject.getContainer()); + } + contents.add(0, gameObject); + gameObject.setContainer(this); + squareChanged(); + } + + /** + * Add a GameObject after another. + * @param previousGameObject previous anchor + * @param newGameObject GameObject to insert + * @throws IllegalArgumentException if <var>newGameObject</var> already is inside another container or <var>previousGameObject</var> isn't inside this container + */ + public void insertAfter(@NotNull final GameObject previousGameObject, @NotNull final GameObject newGameObject) { + if (newGameObject.isInContainer()) { + throw new IllegalArgumentException("Can't add " + newGameObject + " to " + this + " because it's already inside " + newGameObject.getContainer()); + } + final int insertIndex = contents.indexOf(previousGameObject); + if (insertIndex == -1) { + throw new IllegalArgumentException("Can't insert " + newGameObject + " after " + previousGameObject + " because that isn't inside " + this); + } + contents.add(insertIndex, newGameObject); + newGameObject.setContainer(this); + squareChanged(); + } + + /** + * Add a GameObject before another. + * @param newGameObject GameObject to insert + * @param nextGameObject nextGameObject anchor + * @throws IllegalArgumentException if <var>newGameObject</var> already is inside another container or <var>prev</var> isn't inside this container + */ + public void insertBefore(@NotNull final GameObject newGameObject, @NotNull final GameObject nextGameObject) { + if (newGameObject.isInContainer()) { + throw new IllegalArgumentException("Can't add " + newGameObject + " to " + this + " because it's already inside " + newGameObject.getContainer()); + } + final int insertIndex = contents.indexOf(nextGameObject); + if (insertIndex == -1) { + throw new IllegalArgumentException("Can't insert " + newGameObject + " before " + nextGameObject + " because that isn't inside " + this); + } + contents.add(insertIndex + 1, newGameObject); + newGameObject.setContainer(this); + squareChanged(); + } + + /** + * Replace an GameObject with another one. + * @param oldGameObject old GameObject to be replaced + * @param newGameObject new GameObject that replaces oldGameObject + * @throws IllegalArgumentException if <var>oldGameObject</var> isn't in this container + */ + public void replace(@NotNull final GameObject oldGameObject, @NotNull final GameObject newGameObject) { + final int insertIndex = contents.indexOf(oldGameObject); + if (insertIndex == -1) { + throw new IllegalArgumentException(oldGameObject + " wasn't inside container " + this); + } + contents.remove(oldGameObject); + oldGameObject.setContainer(null); + contents.add(insertIndex, newGameObject); + newGameObject.setContainer(this); + squareChanged(); + } + + /** + * Get the MapSquare of this GameObjectContainer. + * @return MapSquare of this GameObjectContainer or <code>null</code> if this GameObjectContainer is not (yet?) connected to a map (a {@link MapSquare} would return itself) + */ + @Nullable public abstract MapSquare getMapSquare(); + + /** + * Tell the model that this MapSquare has changed. + * This method must be invoked by all other methods that change something. + */ + protected final void squareChanged() { + final MapSquare square = getMapSquare(); + if (square != null) { + square.getModel().squareChanged(square); + } + } + + /** {@inheritDoc} */ + @NotNull @Override protected GameObjectContainer clone() throws CloneNotSupportedException { + try { + final GameObjectContainer clone = (GameObjectContainer) super.clone(); + clone.initData(); + return clone; + } catch (final CloneNotSupportedException e) { + assert false; + throw new AssertionError(); + } + } + + /** {@inheritDoc} */ + // writeObject() is not required because this class doesn't require special handling during serialization. + private void readObject(final ObjectInputStream stream) throws IOException, ClassNotFoundException { + stream.defaultReadObject(); + // initialize transients + initData(); + } + + /** + * An iterator for iterating over a list in reverse order. + * @todo move this class to JAPI + */ + private static class ReverseIterator<T> implements Iterator<T> { + + /** The iterator used for delegation. */ + @NotNull private final ListIterator<T> delegate; + + /** + * Create a reverse iterator. + * @param list to iterate over in reverse order + */ + public ReverseIterator(final List<T> list) { + delegate = list.listIterator(list.size()); + } + + /** {@inheritDoc} */ + public boolean hasNext() { + return delegate.hasPrevious(); + } + + /** {@inheritDoc} */ + @NotNull public T next() { + return delegate.previous(); + } + + /** {@inheritDoc} */ + public void remove() { + delegate.remove(); + } + + } // class ReverseIterator + +} // interface GameObjectContainer Property changes on: trunk/crossfire/src/cfeditor/gameobject/GameObjectContainer.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Deleted: trunk/crossfire/src/cfeditor/gameobject/GameObjectIterator.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObjectIterator.java 2006-10-03 16:45:57 UTC (rev 470) +++ trunk/crossfire/src/cfeditor/gameobject/GameObjectIterator.java 2006-10-03 17:11:54 UTC (rev 471) @@ -1,99 +0,0 @@ -/* - * Daimonin 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.gameobject; - -import java.util.Iterator; -import java.util.NoSuchElementException; - -/** - * Iterator for ArchObjects. - * This class is only meant for usage during the transition from manually linked lists to encapslued Collections lists in arch handling. - * This Iterator is believed to be safe against concurrent modification. - * Therefore it is not fail-fast, it does not throw ConcurrentModificationException. - * The next link is future-fetched, which means that the invocation of {@link #next()} already prepares the next invocation of {@link #hasNext()} or {@link #next()}. - * This allows to safely perform manipulations on the current object, especially deletion, without loosing traversal. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public class GameObjectIterator implements Iterator<GameObject> { - -// /** Current GameObject, used for {@link #remove()}. */ -// private GameObject current; - - /** Traversal direction. */ - private final boolean forward; - - /** GameObject for first iteration step. */ - private GameObject next; - - /** - * Creates a new instance of GameObjectIterator (forward iteration). - * @param first first GameObject to start forward iteration on - */ - public GameObjectIterator(final GameObject first) { - this(first, true); - } - - /** - * Creates a new instance of GameObjectIterator. - * @param first first GameObject to start iteration on - * @param forward <code>true</code> for forward iteration, <code>false</code> for backward iteration - */ - GameObjectIterator(final GameObject first, final boolean forward) { - next = first; - this.forward = forward; - } - - /** {@inheritDoc} */ - public boolean hasNext() { - return next != null; - } - - /** {@inheritDoc} */ - public GameObject next() { - try { - return next; - } finally { - try { - next = forward ? next.getNext() : next.getPrev(); - } catch (final NullPointerException e) { - //noinspection ThrowFromFinallyBlock - throw new NoSuchElementException(); - } - } - } - - /** - * {@inheritDoc} - * @todo eventually, multitile-removal should go here. - */ - public void remove() { - throw new UnsupportedOperationException(); -// GameObject prev = current.getPrevArch(); -// GameObject next = current.getNextArch(); -// if (next != null) { next.setPrevArch(prev); } -// if (prev != null) { prev.setPrevArch(next); } - } - -} // class GameObjectIterator Deleted: trunk/crossfire/src/cfeditor/gameobject/GameObjectIteratorDeleteGameMapObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObjectIteratorDeleteGameMapObject.java 2006-10-03 16:45:57 UTC (rev 470) +++ trunk/crossfire/src/cfeditor/gameobject/GameObjectIteratorDeleteGameMapObject.java 2006-10-03 17:11:54 UTC (rev 471) @@ -1,46 +0,0 @@ -/* $Id: GameObjectIteratorDeleteGameMapObject.java,v 1.1 2006/04/06 17:16:03 akirschbaum Exp $ */ - -package cfeditor.gameobject; - -import cfeditor.map.MapModel; -import java.util.Iterator; - -/** - * The class GameObjectIterator implements an {@link GameObjectIterator} that - * implements the {@link Iterator#remove()} operation via {@link - * MapModel#deleteArchMapObject(GameObject)}. - * @author Andreas Kirschbaum - */ -public class GameObjectIteratorDeleteGameMapObject extends GameObjectIterator { - - private final MapModel model; - - public GameObjectIteratorDeleteGameMapObject(final MapModel model, final GameObject archObject) { - super(archObject); - - if (model == null) { - throw new IllegalArgumentException(); - } - - this.model = model; - } - - /** {@inheritDoc} */ - public GameObject next() { - currArchObject = super.next(); - return currArchObject; - } - - /** {@inheritDoc} */ - @Override public void remove() { - if (currArchObject == null) { - throw new IllegalStateException(); - } - - model.deleteArchMapObject(currArchObject); - currArchObject = null; - } - - private GameObject currArchObject = null; - -} // class GameObjectIteratorDeleteGameMapObject Deleted: trunk/crossfire/src/cfeditor/gameobject/GameObjectIteratorDeleteMapGame.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObjectIteratorDeleteMapGame.java 2006-10-03 16:45:57 UTC (rev 470) +++ trunk/crossfire/src/cfeditor/gameobject/GameObjectIteratorDeleteMapGame.java 2006-10-03 17:11:54 UTC (rev 471) @@ -1,69 +0,0 @@ -/* $Id: GameObjectIteratorDeleteMapGame.java,v 1.1 2006/04/06 17:16:03 akirschbaum Exp $ */ - -package cfeditor.gameobject; - -import cfeditor.map.MapModel; -import java.awt.Point; -import java.util.Iterator; - -/** - * The class GameObjectIterator implements an {@link GameObjectIterator} that - * implements the {@link Iterator#remove()} operation via {@link - * MapModel#deleteMapArch(int, int, int, boolean, boolean)}. - * @author Andreas Kirschbaum - */ -public class GameObjectIteratorDeleteMapGame extends GameObjectIterator { - - private final MapModel mapModel; - - private final Point pos; - - private final boolean refreshMap; - - private final boolean join; - - public GameObjectIteratorDeleteMapGame(final MapModel mapModel, final GameObject archObject, final Point pos, final boolean refreshMap, final boolean join) { - super(archObject); - - if (mapModel == null) { - throw new IllegalArgumentException(); - } - - this.mapModel = mapModel; - this.pos = pos; - this.refreshMap = refreshMap; - this.join = join; - } - - /** - * @param mapModel - * @param archObject - * @param x - * @param y - * @param refreshMap - * @param join - * @deprecated use {@link #ArchObjectIteratorDeleteMapArch(MapModel,GameObject, Point, boolean, boolean)} instead - */ - @Deprecated public GameObjectIteratorDeleteMapGame(final MapModel mapModel, final GameObject archObject, final int x, final int y, final boolean refreshMap, final boolean join) { - this(mapModel, archObject, new Point(x, y), refreshMap, join); - } - - /** {@inheritDoc} */ - public GameObject next() { - currArchObject = super.next(); - return currArchObject; - } - - /** {@inheritDoc} */ - @Override public void remove() { - if (currArchObject == null) { - throw new IllegalStateException(); - } - - mapModel.deleteMapArch(currArchObject.getMyID(), pos, refreshMap, join); - currArchObject = null; - } - - private GameObject currArchObject = null; - -} // class GameObjectIteratorDeleteMapGame Added: trunk/crossfire/src/cfeditor/gameobject/RecursiveGameObjectIterator.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/RecursiveGameObjectIterator.java (rev 0) +++ trunk/crossfire/src/cfeditor/gameobject/RecursiveGameObjectIterator.java 2006-10-03 17:11:54 UTC (rev 471) @@ -0,0 +1,58 @@ +package cfeditor.gameobject; + +import java.util.EmptyStackException; +import java.util.Iterator; +import java.util.Stack; + +/** + * Iterator for recursively iterating over ArchObjectContainers. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +class RecursiveGameObjectIterator implements Iterator<GameObject> { + + /** The Iterator stack. */ + private Stack<Iterator<GameObject>> iteratorStack = new Stack... [truncated message content] |
From: <chr...@us...> - 2006-10-03 16:46:15
|
Revision: 470 http://svn.sourceforge.net/gridarta/?rev=470&view=rev Author: christianhujer Date: 2006-10-03 09:45:57 -0700 (Tue, 03 Oct 2006) Log Message: ----------- Made archetypeMap private. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-10-03 16:20:17 UTC (rev 469) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-10-03 16:45:57 UTC (rev 470) @@ -48,6 +48,7 @@ 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; @@ -507,7 +508,7 @@ private void connectFaces() { // run through arches - for (final GameObject arch : archetypeMap.values()) { + for (final GameObject arch : getArchetypes()) { final String faceName = arch.getFaceName(); if (faceName != null) { final Integer num = (Integer) faceMap.get(faceName); @@ -830,8 +831,13 @@ CMainStatusbar.getInstance().setText("Collect Archetypes: done."); } + /** + * Returns an array with all Archetypes. + * @return An array with all Archetypes. + */ public GameObject[] getArchList() { - return archetypeMap.values().toArray(new GameObject[archetypeMap.size()]); + final Collection<GameObject> archetypes = getArchetypes(); + return archetypes.toArray(new GameObject[archetypes.size()]); } /** Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-10-03 16:20:17 UTC (rev 469) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-10-03 16:45:57 UTC (rev 470) @@ -452,7 +452,7 @@ } private void connectFaces() { - for (final GameObject arch : archetypeMap.values()) { + for (final GameObject arch : getArchetypes()) { arch.setObjectFace(); } } @@ -498,7 +498,7 @@ int count = 0; // count how much arches we've collected - for (final GameObject arch : archetypeMap.values()) { + for (final GameObject arch : getArchetypes()) { // exclude arches generated from artifacts file from collection if (arch.isArtifact()) { Modified: trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java 2006-10-03 16:20:17 UTC (rev 469) +++ trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java 2006-10-03 16:45:57 UTC (rev 470) @@ -2,6 +2,8 @@ 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; @@ -15,7 +17,7 @@ private LoadStatus loadStatus = LoadStatus.EMPTY; /** The defined Archetypes. */ - protected final Map<String, T> archetypeMap = new TreeMap<String, T>(); + private final Map<String, T> archetypeMap = new TreeMap<String, T>(); /** * Whether Archetypes were loaded form an archive. @@ -55,10 +57,11 @@ if (!archetype.isArchetype()) { throw new IllegalArgumentException("Supplied GameObject " + archetype + " is not an Archetype."); } - if (archetypeMap.containsKey(archetype.getArchetypeName())) { + final String name = archetype.getArchetypeName(); + if (archetypeMap.containsKey(name)) { handleDuplicate(archetype); } else { - archetypeMap.put(archetype.getArchetypeName(), archetype); + archetypeMap.put(name, archetype); } } @@ -86,4 +89,12 @@ this.loadedFromArchive = loadedFromArchive; } + /** + * Returns a read-only collection of all Archetypes. + * @return A read-only collection of all Archetypes. + */ + protected Collection<T> getArchetypes() { + return Collections.unmodifiableCollection(archetypeMap.values()); + } + } // class AbstractArchetypeSet This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-03 16:20:44
|
Revision: 469 http://svn.sourceforge.net/gridarta/?rev=469&view=rev Author: christianhujer Date: 2006-10-03 09:20:17 -0700 (Tue, 03 Oct 2006) Log Message: ----------- Removed manual arch object counting - it was only used for the status bar, and documented nullability. Modified Paths: -------------- trunk/crossfire/src/cfeditor/AutojoinList.java trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainStatusbar.java trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainStatusbar.java trunk/daimonin/src/daieditor/gameobject/ArchObjectParser.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/messages.properties trunk/daimonin/src/daieditor/messages_de.properties trunk/daimonin/src/daieditor/messages_sv.properties trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java trunk/src/app/net/sf/gridarta/gameobject/ArchetypeSet.java Modified: trunk/crossfire/src/cfeditor/AutojoinList.java =================================================================== --- trunk/crossfire/src/cfeditor/AutojoinList.java 2006-10-03 14:57:14 UTC (rev 468) +++ trunk/crossfire/src/cfeditor/AutojoinList.java 2006-10-03 16:20:17 UTC (rev 469) @@ -132,7 +132,7 @@ success = true; // we did it! } else if (count > 16) { log.warn("In file " + filename + ": List with more than 16 valid entries!"); - } else if (archstack.getArchCount() >= 1) { + } else if (archstack.getArchetypeCount() >= 1) { log.warn("In file " + filename + ": List with less than 16 valid entries!"); } sectionFlag = false; @@ -150,7 +150,7 @@ } } else { // (If no arches exist at all, errormessages are suppressed here) - if (archstack.getArchCount() >= 1) { + if (archstack.getArchetypeCount() >= 1) { log.warn("In file " + filename + ": Arch '" + line + "' not found."); } } Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-10-03 14:57:14 UTC (rev 468) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-10-03 16:20:17 UTC (rev 469) @@ -367,12 +367,8 @@ archetypeSet.addArchetype(data); } - public void incArchObjCount() { - archetypeSet.incArchetypeCount(); - } - public int getArchCount() { - return archetypeSet.getArchCount(); + return archetypeSet.getArchetypeCount(); } public GameObject getArch(final String archname) { Modified: trunk/crossfire/src/cfeditor/CMainStatusbar.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainStatusbar.java 2006-10-03 14:57:14 UTC (rev 468) +++ trunk/crossfire/src/cfeditor/CMainStatusbar.java 2006-10-03 16:20:17 UTC (rev 469) @@ -124,7 +124,6 @@ final long usedMem = totMem - freeMem; memory.setText(" ( " + mainControl.getArchetypeSet().getArchetypeCount() - + "/" + mainControl.getArchetypeSet().getArchCount() + "/" + mainControl.getArchetypeSet().getFaceCount() + " ) Memory Use:" + getMemoryString(usedMem) + "/" + getMemoryString(totMem)); repaint(); Modified: trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java 2006-10-03 14:57:14 UTC (rev 468) +++ trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java 2006-10-03 16:20:17 UTC (rev 469) @@ -289,8 +289,6 @@ // add to head our x/y position so he can setup refmax firstArch.addTailPart(arch); } else { - mainControl.incArchObjCount(); - // add arch to the archpanel - only if it is not the map arch if (!arch.getArchetypeName().equals(STARTARCH_NAME)) { if (!mainControl.getArchetypeSet().isLoadedFromArchive() || archName != null) { Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-10-03 14:57:14 UTC (rev 468) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-10-03 16:20:17 UTC (rev 469) @@ -48,7 +48,6 @@ import java.util.Date; import java.util.HashMap; import java.util.Map; -import java.util.TreeMap; import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JDialog; @@ -61,7 +60,6 @@ import net.sf.gridarta.gameobject.AbstractArchetypeSet; import org.apache.log4j.Logger; import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.NotNull; /** * The <code>ArchetypeSet</code> contains all the Archetypes. @@ -161,7 +159,7 @@ CMainStatusbar.getInstance().setText(" Ready."); // print message if no arches were found - if (getArchCount() == 0) { + if (getArchetypeCount() == 0) { setLoadStatus(LoadStatus.EMPTY); // status: stack is empty mainControl.showMessage("No Archfiles", "No archfiles could be found. If you have no archfiles\n" + "yet, you need to download them. If you do, make sure\n" + @@ -536,7 +534,7 @@ CMainStatusbar.getInstance().setText("Collect Archfile: write archetypes"); // open the process bar - final CollectProgressBar pbar = new CollectProgressBar(mainControl.getArchetypeSet().getArchCount(), + final CollectProgressBar pbar = new CollectProgressBar(mainControl.getArchetypeSet().getArchetypeCount(), "Collecting Archetypes..."); File dfile; Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-10-03 14:57:14 UTC (rev 468) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-10-03 16:20:17 UTC (rev 469) @@ -678,12 +678,8 @@ archetypeSet.addArchetype(data); } - public void incArchObjCount() { - archetypeSet.incArchetypeCount(); - } - public int getArchCount() { - return archetypeSet.getArchCount(); + return archetypeSet.getArchetypeCount(); } /** Set all global settings from the preferences. */ Modified: trunk/daimonin/src/daieditor/CMainStatusbar.java =================================================================== --- trunk/daimonin/src/daieditor/CMainStatusbar.java 2006-10-03 14:57:14 UTC (rev 468) +++ trunk/daimonin/src/daieditor/CMainStatusbar.java 2006-10-03 16:20:17 UTC (rev 469) @@ -133,7 +133,6 @@ memory.setText(ACTION_FACTORY.format("memory", mainControl.getArchetypeSet().getArchetypeCount(), - mainControl.getArchetypeSet().getArchCount(), mainControl.getFaceObjects().size(), getMemoryString(usedMem), getMemoryString(freeMem), getMemoryString(totMem) )); Modified: trunk/daimonin/src/daieditor/gameobject/ArchObjectParser.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchObjectParser.java 2006-10-03 14:57:14 UTC (rev 468) +++ trunk/daimonin/src/daieditor/gameobject/ArchObjectParser.java 2006-10-03 16:20:17 UTC (rev 469) @@ -236,8 +236,6 @@ log.log(Level.WARNING, "defArchWithInvalidMpartNr", new Object[]{arch.getArchetypeName(), firstArch.getArchetypeName(), Integer.toString(multiShapeID), Integer.toString(firstArch.getMultiShapeID())}); } } else { - mainControl.incArchObjCount(); - // add arch to the archpanel - only if it is not the map arch and not in the intern folder if (!isInternPath && !(newCat != null && newCat.contains("intern"))) { if (!mainControl.getArchetypeSet().isLoadedFromArchive() || archName != null) { Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-10-03 14:57:14 UTC (rev 468) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-10-03 16:20:17 UTC (rev 469) @@ -57,7 +57,6 @@ import java.util.Arrays; import java.util.List; import java.util.Map; -import java.util.TreeMap; import javax.swing.ImageIcon; import net.sf.gridarta.io.CFileReader; import net.sf.gridarta.gameobject.AbstractArchetypeSet; @@ -65,8 +64,6 @@ import static net.sf.japi.swing.ActionFactory.getFactory; import net.sf.japi.swing.Progress; import net.sf.japi.swing.ProgressDisplay; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.NotNull; /** * The <code>ArchetypeSet</code> contains all the Archetypes. @@ -166,7 +163,7 @@ mainControl.setStatusText(" Ready."); // print message if no arches were found - if (getArchCount() == 0) { + if (getArchetypeCount() == 0) { setLoadStatus(LoadStatus.EMPTY); // status: stack is empty ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "loadArchesNoArchfiles"); } else { @@ -476,7 +473,7 @@ */ /** {@inheritDoc} */ public void run() { - final Progress pbar = new ProgressDisplay(mainControl.getMainView(), ""/*FIXME*/, mainControl.getArchetypeSet().getArchCount(), ACTION_FACTORY.getString("archCollectArches")); + final Progress pbar = new ProgressDisplay(mainControl.getMainView(), ""/*FIXME*/, mainControl.getArchetypeSet().getArchetypeCount(), ACTION_FACTORY.getString("archCollectArches")); collectDaimoninArchetypes(pbar); collectDaimoninAnimations(pbar); collectDaimoninAnimationTree(pbar); Modified: trunk/daimonin/src/daieditor/messages.properties =================================================================== --- trunk/daimonin/src/daieditor/messages.properties 2006-10-03 14:57:14 UTC (rev 468) +++ trunk/daimonin/src/daieditor/messages.properties 2006-10-03 16:20:17 UTC (rev 469) @@ -939,7 +939,7 @@ ############# # Status Bar -memory=({0}/{1}/{2}) Memory: {3} used, {4} free, {5} total. +memory=({0}/{1}) Memory: {2} used, {3} free, {4} total. dialogDontShowAgain=Show this dialog again next time. Modified: trunk/daimonin/src/daieditor/messages_de.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_de.properties 2006-10-03 14:57:14 UTC (rev 468) +++ trunk/daimonin/src/daieditor/messages_de.properties 2006-10-03 16:20:17 UTC (rev 469) @@ -466,6 +466,6 @@ ############# # Status Bar -memory=({0}/{1}/{2}) Speicher: {3} belegt, {4} frei, {5} gesamt. +memory=({0}/{1}) Speicher: {2} belegt, {3} frei, {4} gesamt. dialogDontShowAgain=Diesen Dialog n\xE4chstes Mal wieder anzeigen. Modified: trunk/daimonin/src/daieditor/messages_sv.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_sv.properties 2006-10-03 14:57:14 UTC (rev 468) +++ trunk/daimonin/src/daieditor/messages_sv.properties 2006-10-03 16:20:17 UTC (rev 469) @@ -916,7 +916,7 @@ ############# # Status Bar -memory=({0}/{1}/{2}) Minne: {3} anv\xE4nt, {4} ledigt, {5} totalt. +memory=({0}/{1}) Minne: {2} anv\xE4nt, {3} ledigt, {4} totalt. dialogDontShowAgain=Visa inte denna dialog igen Modified: trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java 2006-10-03 14:57:14 UTC (rev 468) +++ trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java 2006-10-03 16:20:17 UTC (rev 469) @@ -11,11 +11,6 @@ */ public abstract class AbstractArchetypeSet<T extends GameObject> implements ArchetypeSet<T> { - /** - * Counter of all archetypes, multi tile archetypes = 1. - */ - private int archObjCount; - /** The load status of this ArchetypeSet. */ private LoadStatus loadStatus = LoadStatus.EMPTY; @@ -36,17 +31,7 @@ } /** {@inheritDoc} */ - public final void incArchetypeCount() { - archObjCount++; - } - - /** {@inheritDoc} */ - public final int getArchetypeCount() { - return archObjCount; - } - - /** {@inheritDoc} */ - public final LoadStatus getLoadStatus() { + @NotNull public final LoadStatus getLoadStatus() { return loadStatus; } @@ -56,7 +41,7 @@ } /** {@inheritDoc} */ - public final int getArchCount() { + public final int getArchetypeCount() { return archetypeMap.size(); } @@ -66,7 +51,7 @@ } /** {@inheritDoc} */ - public final void addArchetype(final T archetype) { + public final void addArchetype(@NotNull final T archetype) { if (!archetype.isArchetype()) { throw new IllegalArgumentException("Supplied GameObject " + archetype + " is not an Archetype."); } Modified: trunk/src/app/net/sf/gridarta/gameobject/ArchetypeSet.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/ArchetypeSet.java 2006-10-03 14:57:14 UTC (rev 468) +++ trunk/src/app/net/sf/gridarta/gameobject/ArchetypeSet.java 2006-10-03 16:20:17 UTC (rev 469) @@ -10,22 +10,10 @@ public interface ArchetypeSet<T extends GameObject> { /** - * Increments the internal counter for the number of Archetypes. - * @deprecated only for transition, must only be used by the loaders of Archetypes and not any other purpose. - */ - @Deprecated void incArchetypeCount(); - - /** - * Returns the number of Archetypes loaded. - * @return The number of Archetypes loaded. - */ - int getArchetypeCount(); - - /** * Returns the load status of this ArchetypeSet. * @return The load status of this ArchetypeSet. */ - LoadStatus getLoadStatus(); + @NotNull LoadStatus getLoadStatus(); /** * Returns whether the Archetypes in this ArchetypeSet were loaded from an archive. @@ -37,7 +25,7 @@ * Returns the number of Archetypes available. * @return The number of Archetypes available */ - int getArchCount(); + int getArchetypeCount(); /** * Get an Archetype by its name. @@ -52,7 +40,7 @@ * @param archetype Archetype to add. * @throws IllegalArgumentException in case the added GameObject is not an Archetype. */ - void addArchetype(final T archetype) throws IllegalArgumentException; + void addArchetype(@NotNull final T archetype) throws IllegalArgumentException; /** * Instructs this ArchetypeSet to load its Archetypes. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-03 14:57:25
|
Revision: 468 http://svn.sourceforge.net/gridarta/?rev=468&view=rev Author: christianhujer Date: 2006-10-03 07:57:14 -0700 (Tue, 03 Oct 2006) Log Message: ----------- Removed duplicate javadoc. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gameobject/GameObject.java Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-10-03 14:54:22 UTC (rev 467) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-10-03 14:57:14 UTC (rev 468) @@ -879,10 +879,7 @@ this.archetypeName = archetypeName != null ? archetypeName.intern() : null; } - /** - * Return the archetype name. - * @return the archetype name - */ + /** {@inheritDoc} */ public String getArchetypeName() { return archetypeName; } Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2006-10-03 14:54:22 UTC (rev 467) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2006-10-03 14:57:14 UTC (rev 468) @@ -788,10 +788,7 @@ this.archetypeName = archetypeName != null ? archetypeName.intern() : null; } - /** - * Return the archetype name. - * @return the archetype name - */ + /** {@inheritDoc} */ public String getArchetypeName() { return archetypeName; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-03 14:54:40
|
Revision: 467 http://svn.sourceforge.net/gridarta/?rev=467&view=rev Author: christianhujer Date: 2006-10-03 07:54:22 -0700 (Tue, 03 Oct 2006) Log Message: ----------- Extracted equal implementation of ArchetypeSets into an abstract common superclass. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-10-03 14:33:49 UTC (rev 466) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-10-03 14:54:22 UTC (rev 467) @@ -58,6 +58,7 @@ import javax.swing.SwingConstants; import net.sf.gridarta.io.CFileInputStream; import net.sf.gridarta.io.CFileReader; +import net.sf.gridarta.gameobject.AbstractArchetypeSet; import org.apache.log4j.Logger; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.NotNull; @@ -67,23 +68,10 @@ * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -public final class ArchetypeSet implements net.sf.gridarta.gameobject.ArchetypeSet<GameObject> { +public final class ArchetypeSet extends AbstractArchetypeSet<GameObject> { private static final Logger log = Logger.getLogger(ArchetypeSet.class); - /** The load status of this ArchetypeSet. */ - private LoadStatus loadStatus = LoadStatus.EMPTY; - - /** - * Whether Archetypes were loaded form an archive. - * @val <code>true</code> when Archetypes were loaded from the big collected archive files, - * @val <code>false</code> when Archetypes were loaded from individual .arc-files - */ - private boolean loadedFromArchive = false; - - /** The defined Archetypes. */ - private final Map<String, GameObject> archetypeMap = new TreeMap<String, GameObject>(); - private final FaceObject[] faceObjects = new FaceObject[10000]; // The hash tables hold the name and the index for the field @@ -91,8 +79,6 @@ // in the table is faster than in the static arrays, we can change this private static final Map<String, Integer> faceMap = new HashMap<String, Integer>(); - private int archObjCount; // all objects, multi tile arches = 1 object - private int faceListCount; // all loaded face pictures private final CMainControl mainControl; @@ -106,30 +92,9 @@ public ArchetypeSet(final CMainControl mainControl) { this.mainControl = mainControl; faceListCount = 0; - archObjCount = 0; GameObject.setArchetypeSet(this); // add static reference to GameObject } - /** {@inheritDoc} */ - public void incArchetypeCount() { - archObjCount++; - } - - /** {@inheritDoc} */ - public int getArchetypeCount() { - return archObjCount; - } - - /** {@inheritDoc} */ - public LoadStatus getLoadStatus() { - return loadStatus; - } - - /** {@inheritDoc} */ - public boolean isLoadedFromArchive() { - return loadedFromArchive; - } - /** Returns the index of a face in the face map or -1. * @param faceName name of face to get index for * @return index of face in map or -1 if face is not in map @@ -155,36 +120,18 @@ return null; } - /** {@inheritDoc} */ - public int getArchCount() { - return archetypeMap.size(); - } - public int getFaceCount() { return faceListCount; } - /** {@inheritDoc} */ - @Nullable public GameObject getArchetype(@NotNull final String archetypeName) { - return archetypeMap.get(archetypeName); + protected void handleDuplicate(final GameObject archetype) { + log.warn("addArchToList: duplicate archetype '" + archetype.getArchetypeName() + "'"); } - /** {@inheritDoc} */ - public void addArchetype(final GameObject archetype) { - if (!archetype.isArchetype()) { - throw new IllegalArgumentException("Supplied GameObject " + archetype + " is not an Archetype."); - } - if (archetypeMap.containsKey(archetype.getArchetypeName())) { - log.warn("addArchToList: duplicate archetype '" + archetype.getArchetypeName() + "'"); - } else { - archetypeMap.put(archetype.getArchetypeName(), archetype); - } - } - /** load the arches */ public void loadArchetypes() { final Date timeStart = new Date(); // get starting time - loadStatus = LoadStatus.LOADING; // status: loading + setLoadStatus(LoadStatus.LOADING); // status: loading log.info("Start to collect archetypes..."); CMainStatusbar.getInstance().setText(" Loading Archetypes... "); @@ -215,13 +162,13 @@ // print message if no arches were found if (getArchCount() == 0) { - loadStatus = LoadStatus.EMPTY; // status: stack is empty + setLoadStatus(LoadStatus.EMPTY); // status: stack is empty mainControl.showMessage("No Archfiles", "No archfiles could be found. If you have no archfiles\n" + "yet, you need to download them. If you do, make sure\n" + "the path is correct under menu 'File->Options'.\n"); } else { // display the time it took to collect arches: - loadStatus = LoadStatus.COMPLETE; // status: stack completed + setLoadStatus(LoadStatus.COMPLETE); // status: stack completed final Date timeFinish = new Date(); // get finishing time final long diff = timeFinish.getTime() - timeStart.getTime(); if (log.isInfoEnabled()) { @@ -241,7 +188,7 @@ * "archtypes" and "crossfire.0" */ private void loadArchFromCollected() { - loadedFromArchive = true; // load from the collected files + setLoadedFromArchive(true); // load from the collected files try { // open the resource file @@ -270,7 +217,7 @@ private void loadArchetypesFromFiles(final File f, int index) { final String name = f.getName(); - loadedFromArchive = false; // don't load from the collected files + setLoadedFromArchive(false); // don't load from the collected files if (f.isDirectory()) { // now, setup the arch panels if (!"cvs".equalsIgnoreCase(name) && !"dev".equalsIgnoreCase(name) && !name.startsWith(".")) { Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-10-03 14:33:49 UTC (rev 466) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-10-03 14:54:22 UTC (rev 467) @@ -60,6 +60,7 @@ import java.util.TreeMap; import javax.swing.ImageIcon; import net.sf.gridarta.io.CFileReader; +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; @@ -73,7 +74,7 @@ * @author <a href="mailto:and...@gm...">Andreas Vogl</a> * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public final class ArchetypeSet implements net.sf.gridarta.gameobject.ArchetypeSet<GameObject> { +public final class ArchetypeSet extends AbstractArchetypeSet<GameObject> { /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = getFactory("daieditor"); @@ -81,21 +82,6 @@ /** Size of the image buffer. */ private static final int IMAGE_BUFFER_SIZE = 50 * 1024; - /** The load status of this ArchetypeSet. */ - private LoadStatus loadStatus = LoadStatus.EMPTY; - - /** - * Whether Archetypes were loaded form an archive. - * @val <code>true</code> when Archetypes were loaded from the big collected archive files, - * @val <code>false</code> when Archetypes were loaded from individual .arc-files - */ - private boolean loadedFromArchive; - - /** The defined Archetypes. */ - private final Map<String, GameObject> archetypeMap = new TreeMap<String, GameObject>(); - - private int archObjCount; // all objects, multi tile arches = 1 object - private final CMainControl mainControl; private int folderLevel; @@ -114,26 +100,6 @@ this.mainControl = mainControl; } - /** {@inheritDoc} */ - public void incArchetypeCount() { - archObjCount++; - } - - /** {@inheritDoc} */ - public int getArchetypeCount() { - return archObjCount; - } - - /** {@inheritDoc} */ - public LoadStatus getLoadStatus() { - return loadStatus; - } - - /** {@inheritDoc} */ - public boolean isLoadedFromArchive() { - return loadedFromArchive; - } - /** * Get the face ImageIcon with a certain face name. * @param faceName faceName of face ImageIcon @@ -160,33 +126,15 @@ return face; } - /** {@inheritDoc} */ - public int getArchCount() { - return archetypeMap.size(); + protected void handleDuplicate(final GameObject archetype) { + ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "loadDuplicateArch", archetype.getArchetypeName(), currentFile); + //throw new DuplicateArchetypeException(data); } - /** {@inheritDoc} */ - @Nullable public GameObject getArchetype(@NotNull final String archetypeName) { - return archetypeMap.get(archetypeName); - } - - /** {@inheritDoc} */ - public void addArchetype(final GameObject archetype) /*throws DuplicateArchetypeException*/ { - if (!archetype.isArchetype()) { - throw new IllegalArgumentException("Supplied GameObject " + archetype + " is not an Archetype."); - } - if (archetypeMap.containsKey(archetype.getArchetypeName())) { - ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "loadDuplicateArch", archetype.getArchetypeName(), currentFile); - //throw new DuplicateArchetypeException(data); - } else { - archetypeMap.put(archetype.getArchetypeName(), archetype); - } - } - /** load the arches */ public void loadArchetypes() { final long timeStart = System.currentTimeMillis(); - loadStatus = LoadStatus.LOADING; // status: loading + setLoadStatus(LoadStatus.LOADING); // status: loading System.err.println("Start to collect archetypes..."); mainControl.setStatusText(" Loading Archetypes... "); @@ -200,7 +148,7 @@ loadArchFromCollected(); // collect arches & images from collection } else { FaceFacade.setNormal(new ArchFaceProvider()); - loadedFromArchive = false; // don't load from the collected files + setLoadedFromArchive(false); // don't load from the collected files animFiles = new ArrayList<File>(); loadArchFromFiles(new File(mainControl.getArchDefaultFolder()), 0, false); // collect arches & images from individual files loadAnimsFromFiles(); @@ -219,11 +167,11 @@ // print message if no arches were found if (getArchCount() == 0) { - loadStatus = LoadStatus.EMPTY; // status: stack is empty + setLoadStatus(LoadStatus.EMPTY); // status: stack is empty ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "loadArchesNoArchfiles"); } else { // display the time it took to collect arches: - loadStatus = LoadStatus.COMPLETE; // status: stack completed + setLoadStatus(LoadStatus.COMPLETE); // status: stack completed System.err.println("Arch collect took " + (System.currentTimeMillis() - timeStart) / 1000.0 + " Seconds"); // load pickmaps @@ -345,7 +293,7 @@ /** Load all arches and pngs from the collected files "archtypes" and "daimonin.0" */ private void loadArchFromCollected() { - loadedFromArchive = true; // load from the collected files + setLoadedFromArchive(true); // load from the collected files try { mainControl.getAnimationObjects().loadAnimTree( new File(new File(mainControl.getArchDefaultFolder(), IGUIConstants.CONFIG_DIR), IGUIConstants.ANIMTREE_FILE)); Added: trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java 2006-10-03 14:54:22 UTC (rev 467) @@ -0,0 +1,104 @@ +package net.sf.gridarta.gameobject; + +import java.util.Map; +import java.util.TreeMap; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Base implementation of ArchetypeSet. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public abstract class AbstractArchetypeSet<T extends GameObject> implements ArchetypeSet<T> { + + /** + * Counter of all archetypes, multi tile archetypes = 1. + */ + private int archObjCount; + + /** The load status of this ArchetypeSet. */ + private LoadStatus loadStatus = LoadStatus.EMPTY; + + /** The defined Archetypes. */ + protected final Map<String, T> archetypeMap = new TreeMap<String, T>(); + + /** + * Whether Archetypes were loaded form an archive. + * @val <code>true</code> when Archetypes were loaded from the big collected archive files, + * @val <code>false</code> when Archetypes were loaded from individual .arc-files + */ + private boolean loadedFromArchive; + + /** + * Create an AbstractArchetypeSet. + */ + protected AbstractArchetypeSet() { + } + + /** {@inheritDoc} */ + public final void incArchetypeCount() { + archObjCount++; + } + + /** {@inheritDoc} */ + public final int getArchetypeCount() { + return archObjCount; + } + + /** {@inheritDoc} */ + public final LoadStatus getLoadStatus() { + return loadStatus; + } + + /** {@inheritDoc} */ + public final boolean isLoadedFromArchive() { + return loadedFromArchive; + } + + /** {@inheritDoc} */ + public final int getArchCount() { + return archetypeMap.size(); + } + + /** {@inheritDoc} */ + @Nullable public final T getArchetype(@NotNull final String archetypeName) { + return archetypeMap.get(archetypeName); + } + + /** {@inheritDoc} */ + public final void addArchetype(final T archetype) { + if (!archetype.isArchetype()) { + throw new IllegalArgumentException("Supplied GameObject " + archetype + " is not an Archetype."); + } + if (archetypeMap.containsKey(archetype.getArchetypeName())) { + handleDuplicate(archetype); + } else { + archetypeMap.put(archetype.getArchetypeName(), archetype); + } + } + + /** + * Handle a duplicate Archetype + * @param archetype Dupliate Archetype to handle + */ + protected abstract void handleDuplicate(final T archetype); + + /** + * Sets the load status + * @param loadStatus new load status + * @see #getLoadStatus() + */ + protected void setLoadStatus(final LoadStatus loadStatus) { + this.loadStatus = loadStatus; + } + + /** + * Set whether Archetypes were loaded from an archive. + * @param loadedFromArchive <code>true</code> when loaded from archive, otherwise <code>false</code> + * @see #isLoadedFromArchive() + */ + protected void setLoadedFromArchive(final boolean loadedFromArchive) { + this.loadedFromArchive = loadedFromArchive; + } + +} // class AbstractArchetypeSet Property changes on: trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-10-03 14:33:49 UTC (rev 466) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-10-03 14:54:22 UTC (rev 467) @@ -143,6 +143,13 @@ @NotNull GameObject getArchetype(); /** + * Get the name of the Archetype this GameObject is based on. + * For an Archetype this method simply returns its name. + * @return the name of the Archetype this GameObject is based on + */ + @NotNull String getArchetypeName(); + + /** * Returns whether this GameObject is an Archetype. * @return <code>true</code> if this GameObject is an Archetype, otherwise <code>false</code> * @see #getArchetype() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-03 14:34:01
|
Revision: 466 http://svn.sourceforge.net/gridarta/?rev=466&view=rev Author: christianhujer Date: 2006-10-03 07:33:49 -0700 (Tue, 03 Oct 2006) Log Message: ----------- Fixed HTML bug in javadoc. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-10-03 14:29:10 UTC (rev 465) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-10-03 14:33:49 UTC (rev 466) @@ -77,7 +77,7 @@ /** * Whether Archetypes were loaded form an archive. * @val <code>true</code> when Archetypes were loaded from the big collected archive files, - * @val <code>false<7code> when Archetypes were loaded from individual .arc-files + * @val <code>false</code> when Archetypes were loaded from individual .arc-files */ private boolean loadedFromArchive = false; Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-10-03 14:29:10 UTC (rev 465) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-10-03 14:33:49 UTC (rev 466) @@ -87,7 +87,7 @@ /** * Whether Archetypes were loaded form an archive. * @val <code>true</code> when Archetypes were loaded from the big collected archive files, - * @val <code>false<7code> when Archetypes were loaded from individual .arc-files + * @val <code>false</code> when Archetypes were loaded from individual .arc-files */ private boolean loadedFromArchive; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-03 14:29:16
|
Revision: 465 http://svn.sourceforge.net/gridarta/?rev=465&view=rev Author: christianhujer Date: 2006-10-03 07:29:10 -0700 (Tue, 03 Oct 2006) Log Message: ----------- Fixed bug in documentation. Modified Paths: -------------- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-10-03 14:21:46 UTC (rev 464) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-10-03 14:29:10 UTC (rev 465) @@ -68,7 +68,7 @@ import org.jetbrains.annotations.NotNull; /** - * The <code>ArchetypeSet</code> contains all the default arches. + * The <code>ArchetypeSet</code> contains all the Archetypes. * @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> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-03 14:22:24
|
Revision: 464 http://svn.sourceforge.net/gridarta/?rev=464&view=rev Author: christianhujer Date: 2006-10-03 07:21:46 -0700 (Tue, 03 Oct 2006) Log Message: ----------- Major rework of ArchetypeSet: * Improved method naming. * Unified method naming. * Extracted common interface. Modified Paths: -------------- trunk/crossfire/src/cfeditor/AutojoinList.java trunk/crossfire/src/cfeditor/CArchPanelPan.java trunk/crossfire/src/cfeditor/CFTreasureListTree.java trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainMenu.java trunk/crossfire/src/cfeditor/CMainStatusbar.java trunk/crossfire/src/cfeditor/CMapArchPanel.java trunk/crossfire/src/cfeditor/CNewMapDialog.java trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/crossfire/src/cfeditor/parameter/ArchParameter.java trunk/daimonin/src/daieditor/CArchPanelPan.java trunk/daimonin/src/daieditor/CFTreasureListTree.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainStatusbar.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/ScriptArchData.java trunk/daimonin/src/daieditor/gameobject/ArchObjectParser.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gameobject/ArchetypeSet.java Modified: trunk/crossfire/src/cfeditor/AutojoinList.java =================================================================== --- trunk/crossfire/src/cfeditor/AutojoinList.java 2006-10-03 13:06:41 UTC (rev 463) +++ trunk/crossfire/src/cfeditor/AutojoinList.java 2006-10-03 14:21:46 UTC (rev 464) @@ -123,9 +123,9 @@ jlist.archnames = new String[16]; // array to store the archetype names for (int i = 0; i < 16; i++) { jlist.archnames[i] = nbuf[i]; // store archetype name in the list - archstack.getArch(nbuf[i]).setJoinList(jlist); // set the link in the def. arch + archstack.getArchetype(nbuf[i]).setJoinList(jlist); // set the link in the def. arch if (log.isDebugEnabled()) { - log.debug("(" + i + ") arch: '" + archstack.getArch(nbuf[i]).getArchetypeName() + "' -> (" + nbuf[i] + ")"); + log.debug("(" + i + ") arch: '" + archstack.getArchetype(nbuf[i]).getArchetypeName() + "' -> (" + nbuf[i] + ")"); } } @@ -139,7 +139,7 @@ } else if (count < 16) { // add a new archid to the buffer - final GameObject arch = archstack.getArch(line); + final GameObject arch = archstack.getArchetype(line); if (arch != null) { nbuf[count] = line; @@ -313,7 +313,7 @@ GameObject tmpArch = map.getTopArchObject(x, y); // we look through the arches at the given location (top to bottom): for (; tmpArch != null; tmpArch = tmpArch.getPrev()) { - if (stack.getArch(tmpArch.getArchetypeName()).getJoinList() == this) { + if (stack.getArchetype(tmpArch.getArchetypeName()).getJoinList() == this) { return tmpArch; // we found an arch } } @@ -326,7 +326,7 @@ * by changing archtype and face. */ private void connectArch(final GameObject arch, final String archname) { - final GameObject defarch = stack.getArch(archname); // new default arch + final GameObject defarch = stack.getArchetype(archname); // new default arch if (!arch.getArchetypeName().equals(archname)) { // set new archtype Modified: trunk/crossfire/src/cfeditor/CArchPanelPan.java =================================================================== --- trunk/crossfire/src/cfeditor/CArchPanelPan.java 2006-10-03 13:06:41 UTC (rev 463) +++ trunk/crossfire/src/cfeditor/CArchPanelPan.java 2006-10-03 14:21:46 UTC (rev 464) @@ -125,7 +125,7 @@ if (index != -1) { final String archname = theList.getSelectedValue().toString(); - arch = mainControl.getArchetypeSet().getArch(archname); + arch = mainControl.getArchetypeSet().getArchetype(archname); } return arch; } @@ -136,7 +136,7 @@ if (index != -1) { try { final String archname = theList.getSelectedValue().toString(); - arch = mainControl.getArchetypeSet().getArch(archname); + arch = mainControl.getArchetypeSet().getArchetype(archname); } catch (final NullPointerException e) { /* log.info("NullPointerException in showArchListObject()!", e); @@ -270,7 +270,7 @@ /* We additionally set the JLabels icon property here. */ - final GameObject arch = mainControl.getArchetypeSet().getArch(value.toString()); + final GameObject arch = mainControl.getArchetypeSet().getArchetype(value.toString()); if (isSelected) { archPanel.setPanelArch(value.toString()); mainControl.setStatusText(" " + value + " "); Modified: trunk/crossfire/src/cfeditor/CFTreasureListTree.java =================================================================== --- trunk/crossfire/src/cfeditor/CFTreasureListTree.java 2006-10-03 13:06:41 UTC (rev 463) +++ trunk/crossfire/src/cfeditor/CFTreasureListTree.java 2006-10-03 14:21:46 UTC (rev 464) @@ -954,7 +954,7 @@ } } else if (content.getType() != TreasureObj.FOLDER) { // normal arch: display the face icon - if (ArchetypeSet.getLoadStatus() == ArchetypeSet.IS_COMPLETE) { + if (CMainControl.getInstance().getArchetypeSet().getLoadStatus() == ArchetypeSet.LoadStatus.COMPLETE) { final String archname = content.getName(); final GameObject arch = CMainControl.getInstance().getArch(archname); if (arch != null) { Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-10-03 13:06:41 UTC (rev 463) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-10-03 14:21:46 UTC (rev 464) @@ -283,7 +283,7 @@ /** collect CF arches */ public void collectCFArches() { - if (ArchetypeSet.getLoadStatus() != ArchetypeSet.IS_COMPLETE) { + if (archetypeSet.getLoadStatus() != ArchetypeSet.LoadStatus.COMPLETE) { // must not collect arches while arch stack not complete showMessage("Arches still Loading", "You have to wait for all arches to be loaded\nbefore you can collect them."); return; @@ -364,23 +364,19 @@ // access to ArchNodeList // remark: i use before some weird access to it, use this instead when you find it public void addArchToList(final GameObject data) { - archetypeSet.addArchToList(data); + archetypeSet.addArchetype(data); } public void incArchObjCount() { - archetypeSet.incArchObjCount(); + archetypeSet.incArchetypeCount(); } - public int getArchObjCount() { - return archetypeSet.getArchObjCount(); - } - public int getArchCount() { return archetypeSet.getArchCount(); } public GameObject getArch(final String archname) { - return archetypeSet.getArch(archname); + return archetypeSet.getArchetype(archname); } public CopyBuffer getCopyBuffer() { @@ -824,7 +820,7 @@ final int returnVal = fileChooser.showOpenDialog(mainView); if (returnVal == JFileChooser.APPROVE_OPTION) { - if (ArchetypeSet.getLoadStatus() == ArchetypeSet.IS_LOADING) { + if (archetypeSet.getLoadStatus() == ArchetypeSet.LoadStatus.LOADING) { // ArchStack still loading -> abort! showMessage("Cannot open Map", "Are you nuts?! :-)\n" + "All arches have to be loaded before you can open a map.\n" + @@ -832,7 +828,7 @@ return; } - if (ArchetypeSet.getLoadStatus() == ArchetypeSet.IS_EMPTY) { + if (archetypeSet.getLoadStatus() == ArchetypeSet.LoadStatus.EMPTY) { // ArchStack is empty -> abort! showMessage("Cannot open Map", "There are currently no arches avaliable!\n" + "You need to have arches loaded before opening a map.\n" + @@ -968,7 +964,7 @@ // first: attach our map sucker to a default arch we have loaded for (final Iterator<GameObject> it = objects.iterator(); it.hasNext();) { final GameObject arch = it.next(); - final GameObject defarch = archetypeSet.getArch(arch.getArchetypeName()); + final GameObject defarch = archetypeSet.getArchetype(arch.getArchetypeName()); if (defarch == null) { // we had an unknown arch here!! // showMessage("Error Loading Map File "+file.getName(), "\n Found Unknown Arch < "+arch.getArchetypeName()+" >"); Modified: trunk/crossfire/src/cfeditor/CMainMenu.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainMenu.java 2006-10-03 13:06:41 UTC (rev 463) +++ trunk/crossfire/src/cfeditor/CMainMenu.java 2006-10-03 14:21:46 UTC (rev 464) @@ -801,7 +801,7 @@ mainControl.setPickmapsLocked(m_lockPickmaps.isChecked()); m_newPickmap.setEnabled(!m_lockPickmaps.isChecked()); - final boolean isArchLoadComplete = ArchetypeSet.getLoadStatus() == ArchetypeSet.IS_COMPLETE; + final boolean isArchLoadComplete = mainControl.getArchetypeSet().getLoadStatus() == ArchetypeSet.LoadStatus.COMPLETE; if (isArchLoadComplete) { m_deletePickmap.setEnabled(!m_lockPickmaps.isChecked()); m_loadPickmap.setEnabled(!m_lockPickmaps.isChecked()); @@ -1197,7 +1197,7 @@ /** Refreshes the state of items in this toolbar. */ public void refresh() { - final boolean isArchLoadComplete = ArchetypeSet.getLoadStatus() == ArchetypeSet.IS_COMPLETE; + final boolean isArchLoadComplete = mainControl.getArchetypeSet().getLoadStatus() == ArchetypeSet.LoadStatus.COMPLETE; m_spellC.setEnabled(true); //m_scriptMenu.setEnabled(false); @@ -1209,7 +1209,7 @@ m_autojoin.setEnabled(mainControl.getJoinlist() != null); // collect arches is only allowed if we run from individual archfiles - m_collectArch.setEnabled(isArchLoadComplete && !ArchetypeSet.isLoadedFromArchive()); + m_collectArch.setEnabled(isArchLoadComplete && !mainControl.getArchetypeSet().isLoadedFromArchive()); if (isArchLoadComplete) { m_viewTreasure.setEnabled(true); Modified: trunk/crossfire/src/cfeditor/CMainStatusbar.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainStatusbar.java 2006-10-03 13:06:41 UTC (rev 463) +++ trunk/crossfire/src/cfeditor/CMainStatusbar.java 2006-10-03 14:21:46 UTC (rev 464) @@ -123,7 +123,7 @@ final long totMem = runtime.totalMemory(); final long usedMem = totMem - freeMem; - memory.setText(" ( " + mainControl.getArchetypeSet().getArchObjCount() + memory.setText(" ( " + mainControl.getArchetypeSet().getArchetypeCount() + "/" + mainControl.getArchetypeSet().getArchCount() + "/" + mainControl.getArchetypeSet().getFaceCount() + " ) Memory Use:" + getMemoryString(usedMem) + "/" + getMemoryString(totMem)); Modified: trunk/crossfire/src/cfeditor/CMapArchPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapArchPanel.java 2006-10-03 13:06:41 UTC (rev 463) +++ trunk/crossfire/src/cfeditor/CMapArchPanel.java 2006-10-03 14:21:46 UTC (rev 464) @@ -758,8 +758,8 @@ // black: the attributes from the default archetype // that don't exist among the "special" ones StyleConstants.setForeground(currentAttributes, Color.black); - if (arch.getObjectText() != null && mainControl.getArchetypeSet().getArch(arch.getArchetypeName()) != null) { - doc.insertString(doc.getLength(), arch.diffArchText(mainControl.getArchetypeSet().getArch(arch.getArchetypeName()).getObjectText(), true), currentAttributes); + if (arch.getObjectText() != null && mainControl.getArchetypeSet().getArchetype(arch.getArchetypeName()) != null) { + doc.insertString(doc.getLength(), arch.diffArchText(mainControl.getArchetypeSet().getArchetype(arch.getArchetypeName()).getObjectText(), true), currentAttributes); } } catch (final BadLocationException e) { // TODO Modified: trunk/crossfire/src/cfeditor/CNewMapDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/CNewMapDialog.java 2006-10-03 13:06:41 UTC (rev 463) +++ trunk/crossfire/src/cfeditor/CNewMapDialog.java 2006-10-03 14:21:46 UTC (rev 464) @@ -238,7 +238,7 @@ } // arches must be loaded to create a new map - if (ArchetypeSet.getLoadStatus() != ArchetypeSet.IS_COMPLETE) { + if (mainControl.getArchetypeSet().getLoadStatus() != ArchetypeSet.LoadStatus.COMPLETE) { mainControl.showMessage("Cannot Create Map", "All arches have to be loaded before you can open a map.\n" + "Just be patient and wait a few seconds..."); Modified: trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java 2006-10-03 13:06:41 UTC (rev 463) +++ trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java 2006-10-03 14:21:46 UTC (rev 464) @@ -293,7 +293,7 @@ // add arch to the archpanel - only if it is not the map arch if (!arch.getArchetypeName().equals(STARTARCH_NAME)) { - if (!ArchetypeSet.isLoadedFromArchive() || archName != null) { + 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); Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-10-03 13:06:41 UTC (rev 463) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-10-03 14:21:46 UTC (rev 464) @@ -60,33 +60,29 @@ import net.sf.gridarta.io.CFileReader; import org.apache.log4j.Logger; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; /** * The <code>ArchetypeSet</code> contains all the Archetypes. * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -public final class ArchetypeSet { +public final class ArchetypeSet implements net.sf.gridarta.gameobject.ArchetypeSet<GameObject> { private static final Logger log = Logger.getLogger(ArchetypeSet.class); - // load status: is the ArchetypeSet fully loaded? - public static final int IS_EMPTY = 0; + /** The load status of this ArchetypeSet. */ + private LoadStatus loadStatus = LoadStatus.EMPTY; - public static final int IS_LOADING = 1; - - public static final int IS_COMPLETE = 2; - - private static int loadStatus = IS_EMPTY; - /** - * true when Archetypes were loaded from the big collected archive files, - * false when Archetypes were loaded from individual .arc-files + * Whether Archetypes were loaded form an archive. + * @val <code>true</code> when Archetypes were loaded from the big collected archive files, + * @val <code>false<7code> when Archetypes were loaded from individual .arc-files */ - private static boolean loadedFromArchive = false; + private boolean loadedFromArchive = false; - /** The defined default arches. */ - private final TreeMap<String, GameObject> arches = new TreeMap<String, GameObject>(); + /** The defined Archetypes. */ + private final Map<String, GameObject> archetypeMap = new TreeMap<String, GameObject>(); private final FaceObject[] faceObjects = new FaceObject[10000]; @@ -114,23 +110,23 @@ GameObject.setArchetypeSet(this); // add static reference to GameObject } - public void incArchObjCount() { + /** {@inheritDoc} */ + public void incArchetypeCount() { archObjCount++; } - /** - * Gets the number of loaded arch objects (only default arches). - * @return number of loaded arch objects (default arches) - */ - public int getArchObjCount() { + /** {@inheritDoc} */ + public int getArchetypeCount() { return archObjCount; } - public static int getLoadStatus() { + /** {@inheritDoc} */ + public LoadStatus getLoadStatus() { return loadStatus; } - public static boolean isLoadedFromArchive() { + /** {@inheritDoc} */ + public boolean isLoadedFromArchive() { return loadedFromArchive; } @@ -159,49 +155,38 @@ return null; } + /** {@inheritDoc} */ public int getArchCount() { - return arches.size(); + return archetypeMap.size(); } public int getFaceCount() { return faceListCount; } - /** - * Get a default GameObject by its archetype name. - * - * @param archname name of default archetype GameObject to get - * - * @return default GameObject for <var>archname</var> or <code>null</code> - * if no such GameObject exists - * - * @see GameObject#createArch() for a similar method that instantiates. - */ - @Nullable public GameObject getArch(final String archname) { - return arches.get(archname); + /** {@inheritDoc} */ + @Nullable public GameObject getArchetype(@NotNull final String archetypeName) { + return archetypeMap.get(archetypeName); } - /** - * Adds an GameObject to the stack. - * Only invoke this method if the GameObject is an Archetype. - * Do not invoke this method on map arches. - * @param data GameObject with DefaultArch to add - * @todo check whether the GameObject is a default arch and reject no default arches with an exception - */ - public void addArchToList(final GameObject data) { - if (arches.containsKey(data.getArchetypeName())) { - log.warn("addArchToList: duplicate archetype '" + data.getArchetypeName() + "'"); + /** {@inheritDoc} */ + public void addArchetype(final GameObject archetype) { + if (!archetype.isArchetype()) { + throw new IllegalArgumentException("Supplied GameObject " + archetype + " is not an Archetype."); + } + if (archetypeMap.containsKey(archetype.getArchetypeName())) { + log.warn("addArchToList: duplicate archetype '" + archetype.getArchetypeName() + "'"); } else { - arches.put(data.getArchetypeName(), data); + archetypeMap.put(archetype.getArchetypeName(), archetype); } } /** load the arches */ public void loadArchetypes() { final Date timeStart = new Date(); // get starting time - loadStatus = IS_LOADING; // status: loading - log.info("Start to collect arches..."); - CMainStatusbar.getInstance().setText(" Loading Arches... "); + loadStatus = LoadStatus.LOADING; // status: loading + log.info("Start to collect archetypes..."); + CMainStatusbar.getInstance().setText(" Loading Archetypes... "); // browse arch archive // load object from a arch file you found @@ -230,13 +215,13 @@ // print message if no arches were found if (getArchCount() == 0) { - loadStatus = IS_EMPTY; // status: stack is empty + loadStatus = LoadStatus.EMPTY; // status: stack is empty mainControl.showMessage("No Archfiles", "No archfiles could be found. If you have no archfiles\n" + "yet, you need to download them. If you do, make sure\n" + "the path is correct under menu 'File->Options'.\n"); } else { // display the time it took to collect arches: - loadStatus = IS_COMPLETE; // status: stack completed + loadStatus = LoadStatus.COMPLETE; // status: stack completed final Date timeFinish = new Date(); // get finishing time final long diff = timeFinish.getTime() - timeStart.getTime(); if (log.isInfoEnabled()) { @@ -575,9 +560,9 @@ faceListCount++; } - public void connectFaces() { + private void connectFaces() { // run through arches - for (final GameObject arch : arches.values()) { + for (final GameObject arch : archetypeMap.values()) { final String faceName = arch.getFaceName(); if (faceName != null) { final Integer num = (Integer) faceMap.get(faceName); @@ -589,10 +574,7 @@ } } - /** - * Wrapper method for arch collecting. Either Crossfire or Daimonin method - * for collecting arches is chosen here. - */ + /** {@inheritDoc} */ public void collectArchetypes() { collectCrossfireArchetypes(); } @@ -904,7 +886,7 @@ } public GameObject[] getArchList() { - return arches.values().toArray(new GameObject[arches.size()]); + return archetypeMap.values().toArray(new GameObject[archetypeMap.size()]); } /** Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-10-03 13:06:41 UTC (rev 463) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-10-03 14:21:46 UTC (rev 464) @@ -1429,11 +1429,7 @@ } } - /** - * Create a new GameObject from this Archetype. - * If this GameObject is not an Archetype, this method recursively forwards to its Archetype. - * @return new GameObject - */ + /** {@inheritDoc} */ public GameObject createArch() { if (!isArchetype()) { return archetype.createArch(); Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-10-03 13:06:41 UTC (rev 463) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-10-03 14:21:46 UTC (rev 464) @@ -1190,7 +1190,7 @@ * <code>archName</code>, or <code>null</code> if it does not exist */ private GameObject getDefaultArch(final String archName) { - return mainControl.getArchetypeSet().getArch(archName); + return mainControl.getArchetypeSet().getArchetype(archName); } } // class DefaultMapModel Modified: trunk/crossfire/src/cfeditor/parameter/ArchParameter.java =================================================================== --- trunk/crossfire/src/cfeditor/parameter/ArchParameter.java 2006-10-03 13:06:41 UTC (rev 463) +++ trunk/crossfire/src/cfeditor/parameter/ArchParameter.java 2006-10-03 14:21:46 UTC (rev 464) @@ -32,16 +32,16 @@ @Nullable private GameObject locateArch(final String name) { final ArchetypeSet stack = CMainControl.getInstance().getArchetypeSet(); - if (ArchetypeSet.getLoadStatus() != ArchetypeSet.IS_COMPLETE) { + if (CMainControl.getInstance().getArchetypeSet().getLoadStatus() != ArchetypeSet.LoadStatus.COMPLETE) { return null; } - return stack.getArch(name); + return stack.getArchetype(name); } @Override public void fromXML(final Element e) { super.fromXML(e); valueString = e.getChildTextTrim("value"); - if (ArchetypeSet.getLoadStatus() == ArchetypeSet.IS_COMPLETE) { + if (CMainControl.getInstance().getArchetypeSet().getLoadStatus() == ArchetypeSet.LoadStatus.COMPLETE) { setValue(locateArch(valueString)); } } Modified: trunk/daimonin/src/daieditor/CArchPanelPan.java =================================================================== --- trunk/daimonin/src/daieditor/CArchPanelPan.java 2006-10-03 13:06:41 UTC (rev 463) +++ trunk/daimonin/src/daieditor/CArchPanelPan.java 2006-10-03 14:21:46 UTC (rev 464) @@ -168,7 +168,7 @@ @Nullable private GameObject getArchListObject(final int index) { if (index != -1) { try { - return mainControl.getArchetypeSet().getArch((String) theList.getSelectedValue()); + return mainControl.getArchetypeSet().getArchetype((String) theList.getSelectedValue()); } catch (final NullPointerException e) { /* ignore */ } @@ -271,7 +271,7 @@ final ArchetypeSet archetypeSet = mainControl.getArchetypeSet(); final String archname = (String) value; - final GameObject arch = archetypeSet.getArch(archname); + final GameObject arch = archetypeSet.getArchetype(archname); if (isSelected) { // XXX it is not a good idea to query the selection information at this place. archPanel.setSelectedArch(archname); mainControl.setStatusText(' ' + value.toString() + ' '); Modified: trunk/daimonin/src/daieditor/CFTreasureListTree.java =================================================================== --- trunk/daimonin/src/daieditor/CFTreasureListTree.java 2006-10-03 13:06:41 UTC (rev 463) +++ trunk/daimonin/src/daieditor/CFTreasureListTree.java 2006-10-03 14:21:46 UTC (rev 464) @@ -943,7 +943,7 @@ } } else if (content.getType() != TreasureObj.FOLDER) { // normal arch: display the face icon - final GameObject arch = CMainControl.getInstance().getArchetypeSet().getArch(content.getName()); + final GameObject arch = CMainControl.getInstance().getArchetypeSet().getArchetype(content.getName()); if (arch != null) { if (!arch.hasFaceObject()) { setIcon(CMainControl.getInstance().getArchetypeSet().getFace(arch.getFaceObjName())); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-10-03 13:06:41 UTC (rev 463) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-10-03 14:21:46 UTC (rev 464) @@ -96,7 +96,6 @@ import static java.util.prefs.Preferences.userNodeForPackage; import javax.swing.AbstractAction; import javax.swing.ImageIcon; -import javax.swing.JComponent; import javax.swing.JFileChooser; import static javax.swing.JOptionPane.CANCEL_OPTION; import static javax.swing.JOptionPane.CLOSED_OPTION; @@ -316,7 +315,7 @@ tileEdit = 0; init(); refreshMenusAndToolbars(); - archetypeSet.loadArches(); + archetypeSet.loadArchetypes(); validators = createMapValidators(); } @@ -518,7 +517,7 @@ /** Collect CF arches, animations and faces. */ @ActionMethod public void collectArches() { - archetypeSet.collectArches(); + archetypeSet.collectArchetypes(); } /** Collect Spells. */ @@ -676,11 +675,11 @@ // access to ArchNodeList // remark: i use before some weird access to it, use this instead when you find it public void addArchToList(final GameObject data) { - archetypeSet.addArchToList(data); + archetypeSet.addArchetype(data); } public void incArchObjCount() { - archetypeSet.incArchObjCount(); + archetypeSet.incArchetypeCount(); } public int getArchCount() { @@ -1111,7 +1110,7 @@ } final int returnVal = fileChooser.showOpenDialog(mainView); if (returnVal == JFileChooser.APPROVE_OPTION) { - if (ArchetypeSet.getLoadStatus() == ArchetypeSet.IS_EMPTY) { + if (archetypeSet.getLoadStatus() == ArchetypeSet.LoadStatus.EMPTY) { // ArchStack is empty -> abort! ACTION_FACTORY.showMessageDialog(mainView, "openFileWantedNoArches"); } else { @@ -1280,7 +1279,7 @@ //noinspection ForLoopWithMissingComponent for (final Iterator<GameObject> it = objects.iterator(); it.hasNext();) { final GameObject arch = it.next(); - final GameObject defarch = archetypeSet.getArch(arch.getArchetypeName()); + final GameObject defarch = archetypeSet.getArchetype(arch.getArchetypeName()); if (defarch == null) { noarch.append(arch.getArchetypeName()).append('\n'); noarchcount++; Modified: trunk/daimonin/src/daieditor/CMainStatusbar.java =================================================================== --- trunk/daimonin/src/daieditor/CMainStatusbar.java 2006-10-03 13:06:41 UTC (rev 463) +++ trunk/daimonin/src/daieditor/CMainStatusbar.java 2006-10-03 14:21:46 UTC (rev 464) @@ -132,7 +132,7 @@ final long usedMem = totMem - freeMem; memory.setText(ACTION_FACTORY.format("memory", - mainControl.getArchetypeSet().getArchObjCount(), + mainControl.getArchetypeSet().getArchetypeCount(), mainControl.getArchetypeSet().getArchCount(), mainControl.getFaceObjects().size(), getMemoryString(usedMem), getMemoryString(freeMem), getMemoryString(totMem) Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2006-10-03 13:06:41 UTC (rev 463) +++ trunk/daimonin/src/daieditor/CMainView.java 2006-10-03 14:21:46 UTC (rev 464) @@ -802,8 +802,8 @@ aEnterExit.setEnabled(false); // collect arches is only allowed if we run from individual archfiles - aCollectArches.setEnabled(!ArchetypeSet.isLoadedFromArchive()); - aReloadFaces.setEnabled(!ArchetypeSet.isLoadedFromArchive()); + aCollectArches.setEnabled(!mainControl.getArchetypeSet().isLoadedFromArchive()); + aReloadFaces.setEnabled(!mainControl.getArchetypeSet().isLoadedFromArchive()); aViewTreasurelists.setEnabled(true); final boolean pickmapState = !mainControl.isLockAllPickmaps() && mainControl.getMainView().pickmapActive; Modified: trunk/daimonin/src/daieditor/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/ScriptArchData.java 2006-10-03 13:06:41 UTC (rev 463) +++ trunk/daimonin/src/daieditor/ScriptArchData.java 2006-10-03 14:21:46 UTC (rev 464) @@ -590,7 +590,7 @@ event = new GameObject(); // FIXME: This arch has no default arch event.setArchTypNr(118); event.setArchetypeName("event_obj"); - event.setArchetype(CMainControl.getInstance().getArchetypeSet().getArch("event_obj")); + event.setArchetype(CMainControl.getInstance().getArchetypeSet().getArchetype("event_obj")); event.setObjectFace(); setEventData(eventType, pluginName, filePath, options); } Modified: trunk/daimonin/src/daieditor/gameobject/ArchObjectParser.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchObjectParser.java 2006-10-03 13:06:41 UTC (rev 463) +++ trunk/daimonin/src/daieditor/gameobject/ArchObjectParser.java 2006-10-03 14:21:46 UTC (rev 464) @@ -119,7 +119,7 @@ final boolean isInternPath; // path is needed when we don't read from collection because there is no editor_folder in arc files final String path; - if (!ArchetypeSet.isLoadedFromArchive() && archName == null) { + if (!mainControl.getArchetypeSet().isLoadedFromArchive() && archName == null) { String tmpPath = (new File(PathManager.getArchPath(fname))).getParent().replace('\\', '/'); if (tmpPath == null) { tmpPath = "/"; @@ -240,7 +240,7 @@ // add arch to the archpanel - only if it is not the map arch and not in the intern folder if (!isInternPath && !(newCat != null && newCat.contains("intern"))) { - if (!ArchetypeSet.isLoadedFromArchive() || archName != null) { + 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); Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-10-03 13:06:41 UTC (rev 463) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-10-03 14:21:46 UTC (rev 464) @@ -64,6 +64,8 @@ import static net.sf.japi.swing.ActionFactory.getFactory; import net.sf.japi.swing.Progress; import net.sf.japi.swing.ProgressDisplay; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; /** * The <code>ArchetypeSet</code> contains all the default arches. @@ -71,7 +73,7 @@ * @author <a href="mailto:and...@gm...">Andreas Vogl</a> * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public final class ArchetypeSet { +public final class ArchetypeSet implements net.sf.gridarta.gameobject.ArchetypeSet<GameObject> { /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = getFactory("daieditor"); @@ -79,24 +81,19 @@ /** Size of the image buffer. */ private static final int IMAGE_BUFFER_SIZE = 50 * 1024; - // load status: is archstack fully loaded? - public static final int IS_EMPTY = 0; + /** The load status of this ArchetypeSet. */ + private LoadStatus loadStatus = LoadStatus.EMPTY; - public static final int IS_LOADING = 1; + /** + * Whether Archetypes were loaded form an archive. + * @val <code>true</code> when Archetypes were loaded from the big collected archive files, + * @val <code>false<7code> when Archetypes were loaded from individual .arc-files + */ + private boolean loadedFromArchive; - public static final int IS_COMPLETE = 2; + /** The defined Archetypes. */ + private final Map<String, GameObject> archetypeMap = new TreeMap<String, GameObject>(); - private static int loadStatus = IS_EMPTY; - - // true when arches were loaded from the big collected archive files, - // false when arches were loaded from individual archfiles - private static boolean loadedFromArchive; - - private final List<GameObject> archObjects = new ArrayList<GameObject>(); - - /** The defined default arches. */ - private final Map<String, GameObject> arches = new TreeMap<String, GameObject>(); - private int archObjCount; // all objects, multi tile arches = 1 object private final CMainControl mainControl; @@ -117,23 +114,23 @@ this.mainControl = mainControl; } - public void incArchObjCount() { + /** {@inheritDoc} */ + public void incArchetypeCount() { archObjCount++; } - /** - * Gets the number of loaded arch objects (only default arches). - * @return number of loaded arch objects (default arches) - */ - public int getArchObjCount() { + /** {@inheritDoc} */ + public int getArchetypeCount() { return archObjCount; } - public static int getLoadStatus() { + /** {@inheritDoc} */ + public LoadStatus getLoadStatus() { return loadStatus; } - public static boolean isLoadedFromArchive() { + /** {@inheritDoc} */ + public boolean isLoadedFromArchive() { return loadedFromArchive; } @@ -163,42 +160,35 @@ return face; } + /** {@inheritDoc} */ public int getArchCount() { - return arches.size(); + return archetypeMap.size(); } - /** - * Get a Default GameObject by its archName. - * @param archName name of Default Archetype GameObject to get - * @return Default GameObject for <var>archName</var> or <code>null</code> if no such GameObject - */ - public GameObject getArch(final String archName) { - return arches.get(archName); + /** {@inheritDoc} */ + @Nullable public GameObject getArchetype(@NotNull final String archetypeName) { + return archetypeMap.get(archetypeName); } - /** - * Adds an GameObject to the stack. - * Only invoke this method if the GameObject is a default arch. - * Do not invoke this method on map arches. - * @param data GameObject with DefaultArch to add - * @todo check whether the GameObject is a default arch and reject no default arches with an exception - */ - public void addArchToList(final GameObject data) /*throws DuplicateArchetypeException*/ { - if (arches.containsKey(data.getArchetypeName())) { - ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "loadDuplicateArch", data.getArchetypeName(), currentFile); + /** {@inheritDoc} */ + public void addArchetype(final GameObject archetype) /*throws DuplicateArchetypeException*/ { + if (!archetype.isArchetype()) { + throw new IllegalArgumentException("Supplied GameObject " + archetype + " is not an Archetype."); + } + if (archetypeMap.containsKey(archetype.getArchetypeName())) { + ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "loadDuplicateArch", archetype.getArchetypeName(), currentFile); //throw new DuplicateArchetypeException(data); } else { - archObjects.add(data); - arches.put(data.getArchetypeName(), data); + archetypeMap.put(archetype.getArchetypeName(), archetype); } } /** load the arches */ - public void loadArches() { + public void loadArchetypes() { final long timeStart = System.currentTimeMillis(); - loadStatus = IS_LOADING; // status: loading - System.err.println("Start to collect arches..."); - mainControl.setStatusText(" Loading Arches... "); + loadStatus = LoadStatus.LOADING; // status: loading + System.err.println("Start to collect archetypes..."); + mainControl.setStatusText(" Loading Archetypes... "); // browse arch archive // load object from a arch file you found @@ -229,11 +219,11 @@ // print message if no arches were found if (getArchCount() == 0) { - loadStatus = IS_EMPTY; // status: stack is empty + loadStatus = LoadStatus.EMPTY; // status: stack is empty ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "loadArchesNoArchfiles"); } else { // display the time it took to collect arches: - loadStatus = IS_COMPLETE; // status: stack completed + loadStatus = LoadStatus.COMPLETE; // status: stack completed System.err.println("Arch collect took " + (System.currentTimeMillis() - timeStart) / 1000.0 + " Seconds"); // load pickmaps @@ -321,7 +311,7 @@ // TODO: Allow not having a def arch // at this point we MUST have a legal name and def arch // TODO:Then why not check this and throw an exception if not? - final GameObject defArch = getArch(defArchName); + final GameObject defArch = getArchetype(defArchName); if (name == null || defArchName == null || name.length() == 0 || defArchName.length() == 0 || defArch == null) { System.err.println("Artifacts file: Line " + lineCount + " Object >" + defArchName + "< / >" + name + "< / >" + objTitle + "< has missing name or defArch"); } else if (editorCode != 0 && editorCode != 2) { // the next line of our file is part of a arch parse until a "end" comes @@ -516,32 +506,33 @@ } } - public void connectFaces() { - for (final GameObject arch : archObjects) { + private void connectFaces() { + for (final GameObject arch : archetypeMap.values()) { arch.setObjectFace(); } } - /** - * Collect the existing arches and create archive-files for editor use as - * well as the Daimonin server. The arches also get a special path variable - * included which is used in the editor to categorize the arches. - * <p/> - * Output is: "archetypes", "daimonin.0", "animations", "bmaps" - */ - public void collectArches() { + /** {@inheritDoc} */ + public void collectArchetypes() { new Thread(archCollector).start(); } /** Thread code for collecting the arches. */ private final Runnable archCollector = new Runnable() { + /* + * Collect the existing arches and create archive-files for editor use as + * well as the Daimonin server. The arches also get a special path variable + * included which is used in the editor to categorize the arches. + * <p/> + * Output is: "archetypes", "daimonin.0", "animations", "bmaps" + */ /** {@inheritDoc} */ public void run() { final Progress pbar = new ProgressDisplay(mainControl.getMainView(), ""/*FIXME*/, mainControl.getArchetypeSet().getArchCount(), ACTION_FACTORY.getString("archCollectArches")); - collectDaimoninArchesArches(pbar); - collectDaimoninArchesAnimations(pbar); - collectDaimoninArchesAnimationTree(pbar); - collectDaimoninArchesImages(pbar); + collectDaimoninArchetypes(pbar); + collectDaimoninAnimations(pbar); + collectDaimoninAnimationTree(pbar); + collectDaimoninImages(pbar); pbar.finished(); mainControl.setStatusText(ACTION_FACTORY.getString("archCollectDone")); } @@ -551,7 +542,7 @@ * Collect arches. * @param pbar progress bar to update */ - private void collectDaimoninArchesArches(final Progress pbar) { + private void collectDaimoninArchetypes(final Progress pbar) { // WARNING: do not use out.println() because the server will crash if it's not "\n" but e.g. "\r"! try { final File dfile = new File(mainControl.getArchDefaultFolder(), IGUIConstants.ARCH_FILE); @@ -562,7 +553,7 @@ int count = 0; // count how much arches we've collected - for (final GameObject arch : archObjects) { + for (final GameObject arch : archetypeMap.values()) { // exclude arches generated from artifacts file from collection if (arch.isArtifact()) { @@ -724,7 +715,7 @@ * Collect Animations. * @param pbar progress bar to update */ - private void collectDaimoninArchesAnimations(final Progress pbar) { + private void collectDaimoninAnimations(final Progress pbar) { try { final BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(mainControl.getArchDefaultFolder(), "animations")), CFileReader.MAP_ENCODING)); try { @@ -754,7 +745,7 @@ * Collect Animation Tree. * @param pbar progress bar to update */ - private void collectDaimoninArchesAnimationTree(final Progress pbar) { + private void collectDaimoninAnimationTree(final Progress pbar) { try { final BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(new File(mainControl.getArchDefaultFolder(), IGUIConstants.CONFIG_DIR), IGUIConstants.ANIMTREE_FILE)), CFileReader.MAP_ENCODING)); try { @@ -785,7 +776,7 @@ * @param pbar progress bar to update * @todo I/O handling sucks here, this could be nicer. */ - private void collectDaimoninArchesImages(final Progress pbar) { + private void collectDaimoninImages(final Progress pbar) { DataOutputStream binFile = null; BufferedWriter textFile = null; BufferedWriter treeFile = null; Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2006-10-03 13:06:41 UTC (rev 463) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2006-10-03 14:21:46 UTC (rev 464) @@ -1294,11 +1294,7 @@ } } - /** - * Create a new GameObject from this Archetype. - * If this GameObject is not an Archetype, this method recursively forwards to its Archetype. - * @return new GameObject - */ + /** {@inheritDoc} */ public GameObject createArch() { if (!isArchetype()) { return archetype.createArch(); Modified: trunk/daimonin/src/daieditor/map/DefaultMapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-10-03 13:06:41 UTC (rev 463) +++ trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-10-03 14:21:46 UTC (rev 464) @@ -632,7 +632,7 @@ * <code>archName</code>, or <code>null</code> if it does not exist */ private GameObject getDefaultArch(final String archName) { - return mainControl.getArchetypeSet().getArch(archName); + return mainControl.getArchetypeSet().getArchetype(archName); } } // class DefaultMapModel Added: trunk/src/app/net/sf/gridarta/gameobject/ArchetypeSet.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/ArchetypeSet.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gameobject/ArchetypeSet.java 2006-10-03 14:21:46 UTC (rev 464) @@ -0,0 +1,84 @@ +package net.sf.gridarta.gameobject; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Interface that captures similarities between different ArchetypeSet implementations. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public interface ArchetypeSet<T extends GameObject> { + + /** + * Increments the internal counter for the number of Archetypes. + * @deprecated only for transition, must only be used by the loaders of Archetypes and not any other purpose. + */ + @Deprecated void incArchetypeCount(); + + /** + * Returns the number of Archetypes loaded. + * @return The number of Archetypes loaded. + */ + int getArchetypeCount(); + + /** + * Returns the load status of this ArchetypeSet. + * @return The load status of this ArchetypeSet. + */ + LoadStatus getLoadStatus(); + + /** + * Returns whether the Archetypes in this ArchetypeSet were loaded from an archive. + * @return <code>true</code> if loaded from an archive, otherwise <code>false</code>. + */ + boolean isLoadedFromArchive(); + + /** + * Returns the number of Archetypes available. + * @return The number of Archetypes available + */ + int getArchCount(); + + /** + * Get an Archetype by its name. + * @param archetypeName name of the Archetype to get + * @return Archetype for <var>archetypeName</var> or <code>null</code> if no such Archetype + * @see GameObject#createArch() for a similar method that instantiates. + */ + @Nullable GameObject getArchetype(@NotNull final String archetypeName); + + /** + * Adds an Archetype to this Set. + * @param archetype Archetype to add. + * @throws IllegalArgumentException in case the added GameObject is not an Archetype. + */ + void addArchetype(final T archetype) throws IllegalArgumentException; + + /** + * Instructs this ArchetypeSet to load its Archetypes. + */ + void loadArchetypes(); + + /** + * Start collecting the Archetypes and other resource files to create an archive. + */ + void collectArchetypes(); + + + /** + * The load status of the ArchetypeSet. + */ + enum LoadStatus { + + /** The ArchetypeSet is empty, loading hasn't started yet. */ + EMPTY, + + /** The ArchetypeSet is loading right now. */ + LOADING, + + /** The ArchetypeSet has completed loading and is ready to use. */ + COMPLETE + + } // enum LoadStatus + +} // interface ArchetypeSet Property changes on: trunk/src/app/net/sf/gridarta/gameobject/ArchetypeSet.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-10-03 13:06:41 UTC (rev 463) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-10-03 14:21:46 UTC (rev 464) @@ -222,4 +222,11 @@ */ int getMapY(); + /** + * Create a new GameObject from this Archetype. + * If this GameObject is not an Archetype, this method recursively forwards to its Archetype. + * @return new GameObject + */ + GameObject createArch(); + } // interface GameObject This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-03 13:06:48
|
Revision: 463 http://svn.sourceforge.net/gridarta/?rev=463&view=rev Author: christianhujer Date: 2006-10-03 06:06:41 -0700 (Tue, 03 Oct 2006) Log Message: ----------- Added missing @Deprecated annotation. 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-10-03 12:56:09 UTC (rev 462) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2006-10-03 13:06:41 UTC (rev 463) @@ -13,7 +13,7 @@ * Refresh menus and toolbars. * @deprecated This method is bullshit for being a severe violation of MVC and therefore MUST be removed some day. Do not use it for other than unification purposes. */ - void refreshMenusAndToolbars(); + @Deprecated void refreshMenusAndToolbars(); /** * Get the default folder of arches. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-03 12:56:50
|
Revision: 462 http://svn.sourceforge.net/gridarta/?rev=462&view=rev Author: christianhujer Date: 2006-10-03 05:56:09 -0700 (Tue, 03 Oct 2006) Log Message: ----------- Some naming unification regarding MainControl and ArchetypeSet. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CArchPanelPan.java trunk/crossfire/src/cfeditor/CAttribDialog.java trunk/crossfire/src/cfeditor/CFJavaEditor.java trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainStatusbar.java trunk/crossfire/src/cfeditor/CMapArchPanel.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/CScriptController.java trunk/crossfire/src/cfeditor/ReplaceDialog.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/crossfire/src/cfeditor/gui/ArchComboBox.java trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/crossfire/src/cfeditor/parameter/ArchParameter.java trunk/daimonin/src/daieditor/CArchPanelPan.java trunk/daimonin/src/daieditor/CAttribDialog.java trunk/daimonin/src/daieditor/CFTreasureListTree.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainStatusbar.java trunk/daimonin/src/daieditor/CMapTileList.java trunk/daimonin/src/daieditor/ReplaceDialog.java trunk/daimonin/src/daieditor/ScriptArchData.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java trunk/src/app/net/sf/gridarta/MainControl.java Modified: trunk/crossfire/src/cfeditor/CArchPanelPan.java =================================================================== --- trunk/crossfire/src/cfeditor/CArchPanelPan.java 2006-10-03 12:38:53 UTC (rev 461) +++ trunk/crossfire/src/cfeditor/CArchPanelPan.java 2006-10-03 12:56:09 UTC (rev 462) @@ -125,7 +125,7 @@ if (index != -1) { final String archname = theList.getSelectedValue().toString(); - arch = mainControl.getArchObjectStack().getArch(archname); + arch = mainControl.getArchetypeSet().getArch(archname); } return arch; } @@ -136,7 +136,7 @@ if (index != -1) { try { final String archname = theList.getSelectedValue().toString(); - arch = mainControl.getArchObjectStack().getArch(archname); + arch = mainControl.getArchetypeSet().getArch(archname); } catch (final NullPointerException e) { /* log.info("NullPointerException in showArchListObject()!", e); @@ -270,7 +270,7 @@ /* We additionally set the JLabels icon property here. */ - final GameObject arch = mainControl.getArchObjectStack().getArch(value.toString()); + final GameObject arch = mainControl.getArchetypeSet().getArch(value.toString()); if (isSelected) { archPanel.setPanelArch(value.toString()); mainControl.setStatusText(" " + value + " "); Modified: trunk/crossfire/src/cfeditor/CAttribDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-10-03 12:38:53 UTC (rev 461) +++ trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-10-03 12:56:09 UTC (rev 462) @@ -454,7 +454,7 @@ final JPanel layout1 = new JPanel(new BorderLayout()); // face, name & type - imagePanel = new JLabel(mainControl.getArchObjectStack().getFace(gameObject.getFaceNr())); + imagePanel = new JLabel(mainControl.getArchetypeSet().getFace(gameObject.getFaceNr())); imagePanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); layout1.add(imagePanel, BorderLayout.WEST); Modified: trunk/crossfire/src/cfeditor/CFJavaEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/CFJavaEditor.java 2006-10-03 12:38:53 UTC (rev 461) +++ trunk/crossfire/src/cfeditor/CFJavaEditor.java 2006-10-03 12:56:09 UTC (rev 462) @@ -107,7 +107,7 @@ // Initialise the application mainControl.init(doShow); mainControl.refreshMenusAndToolbars(); - mainControl.getArchObjectStack().loadArchetypes(); + mainControl.getArchetypeSet().loadArchetypes(); System.gc(); // process commandline parameters: Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-10-03 12:38:53 UTC (rev 461) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-10-03 12:56:09 UTC (rev 462) @@ -31,7 +31,6 @@ import cfeditor.map.MapArchObject; import cfeditor.map.MapControl; import cfeditor.map.MapModel; -import java.awt.Font; import java.awt.Point; import java.awt.Rectangle; import java.awt.Toolkit; @@ -45,7 +44,6 @@ import java.util.Random; import java.util.Vector; import javax.swing.ImageIcon; -import javax.swing.JComponent; import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.JOptionPane; @@ -142,7 +140,7 @@ private ImageIcon noarchTileIconX; - private final ArchetypeSet archList; // the one and only arch list + private final ArchetypeSet archetypeSet; // the one and only arch list /** All open maps. */ private final Vector<MapControl> levels = new Vector<MapControl>(1, 2); @@ -199,7 +197,7 @@ /** Constructs the main controller and its model and view. */ public CMainControl() { - archList = new ArchetypeSet(this); + archetypeSet = new ArchetypeSet(this); mainView = new CMainView(this); instance = this; @@ -266,11 +264,11 @@ /** * Loading the joinList from file and attaching all to 'joinlist'. * (This method must not be called before all arches are loaded - * into the ArchetypeSet 'archList'!) + * into the ArchetypeSet 'archetypeSet'!) */ public void loadJoinlist() { joinList = new AutojoinList(); - if (!joinList.loadList(archList)) { + if (!joinList.loadList(archetypeSet)) { joinList = null; } } @@ -291,7 +289,7 @@ return; } - archList.collectArchetypes(); + archetypeSet.collectArchetypes(); } /** @@ -366,23 +364,23 @@ // access to ArchNodeList // remark: i use before some weird access to it, use this instead when you find it public void addArchToList(final GameObject data) { - archList.addArchToList(data); + archetypeSet.addArchToList(data); } public void incArchObjCount() { - archList.incArchObjCount(); + archetypeSet.incArchObjCount(); } public int getArchObjCount() { - return archList.getArchObjCount(); + return archetypeSet.getArchObjCount(); } public int getArchCount() { - return archList.getArchCount(); + return archetypeSet.getArchCount(); } public GameObject getArch(final String archname) { - return archList.getArch(archname); + return archetypeSet.getArch(archname); } public CopyBuffer getCopyBuffer() { @@ -567,23 +565,20 @@ } public ImageIcon getFace(final int i) { - return archList.getFace(i); + return archetypeSet.getFace(i); } public String getFaceName(final int i) { - return archList.getFaceName(i); + return archetypeSet.getFaceName(i); } public void setStatusText(final String string) { mainView.setStatusText(string); } - /** - * Get the ArchetypeSet. - * @return ArchetypeSet - */ - public ArchetypeSet getArchObjectStack() { - return archList; + /** {@inheritDoc} */ + public ArchetypeSet getArchetypeSet() { + return archetypeSet; } /** @@ -973,7 +968,7 @@ // first: attach our map sucker to a default arch we have loaded for (final Iterator<GameObject> it = objects.iterator(); it.hasNext();) { final GameObject arch = it.next(); - final GameObject defarch = archList.getArch(arch.getArchetypeName()); + final GameObject defarch = archetypeSet.getArch(arch.getArchetypeName()); if (defarch == null) { // we had an unknown arch here!! // showMessage("Error Loading Map File "+file.getName(), "\n Found Unknown Arch < "+arch.getArchetypeName()+" >"); @@ -1802,8 +1797,4 @@ return null; } - public GameObject[] getArchList() { - return archList.getArchList(); - } - } // class CMainControl Modified: trunk/crossfire/src/cfeditor/CMainStatusbar.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainStatusbar.java 2006-10-03 12:38:53 UTC (rev 461) +++ trunk/crossfire/src/cfeditor/CMainStatusbar.java 2006-10-03 12:56:09 UTC (rev 462) @@ -123,9 +123,9 @@ final long totMem = runtime.totalMemory(); final long usedMem = totMem - freeMem; - memory.setText(" ( " + mainControl.getArchObjectStack().getArchObjCount() - + "/" + mainControl.getArchObjectStack().getArchCount() - + "/" + mainControl.getArchObjectStack().getFaceCount() + memory.setText(" ( " + mainControl.getArchetypeSet().getArchObjCount() + + "/" + mainControl.getArchetypeSet().getArchCount() + + "/" + mainControl.getArchetypeSet().getFaceCount() + " ) Memory Use:" + getMemoryString(usedMem) + "/" + getMemoryString(totMem)); repaint(); } Modified: trunk/crossfire/src/cfeditor/CMapArchPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapArchPanel.java 2006-10-03 12:38:53 UTC (rev 461) +++ trunk/crossfire/src/cfeditor/CMapArchPanel.java 2006-10-03 12:56:09 UTC (rev 462) @@ -758,8 +758,8 @@ // black: the attributes from the default archetype // that don't exist among the "special" ones StyleConstants.setForeground(currentAttributes, Color.black); - if (arch.getObjectText() != null && mainControl.getArchObjectStack().getArch(arch.getArchetypeName()) != null) { - doc.insertString(doc.getLength(), arch.diffArchText(mainControl.getArchObjectStack().getArch(arch.getArchetypeName()).getObjectText(), true), currentAttributes); + if (arch.getObjectText() != null && mainControl.getArchetypeSet().getArch(arch.getArchetypeName()) != null) { + doc.insertString(doc.getLength(), arch.diffArchText(mainControl.getArchetypeSet().getArch(arch.getArchetypeName()).getObjectText(), true), currentAttributes); } } catch (final BadLocationException e) { // TODO Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-10-03 12:38:53 UTC (rev 461) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-10-03 12:56:09 UTC (rev 462) @@ -705,7 +705,7 @@ * "screenshot"-image, false for normal drawing */ public void paintComponent(final Graphics2D grfx, final boolean isSnapshot) { - final ArchetypeSet archlist = mainControl.getArchObjectStack(); + final ArchetypeSet archlist = mainControl.getArchetypeSet(); if (isPickmap) { // draw greenisch background for pickmaps @@ -818,7 +818,7 @@ } else { grfx = backBuffer.getGraphics(); } - final ArchetypeSet archlist = mainControl.getArchObjectStack(); // arch stack + final ArchetypeSet archlist = mainControl.getArchetypeSet(); // arch stack // ---------- draw tile for rectangular view (non-iso) -------------- final CFilterControl filter = mainControl.getFilterControl(); Modified: trunk/crossfire/src/cfeditor/CScriptController.java =================================================================== --- trunk/crossfire/src/cfeditor/CScriptController.java 2006-10-03 12:38:53 UTC (rev 461) +++ trunk/crossfire/src/cfeditor/CScriptController.java 2006-10-03 12:56:09 UTC (rev 462) @@ -201,7 +201,7 @@ private void setInterpreterValues(final Interpreter i, final String mode) throws EvalError { i.set("mainControl", mainControl); i.set("mainView", mainControl.getMainView()); - i.set("archList", mainControl.getArchObjectStack()); + i.set("archList", mainControl.getArchetypeSet()); i.set("runMode", mode); } Modified: trunk/crossfire/src/cfeditor/ReplaceDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/ReplaceDialog.java 2006-10-03 12:38:53 UTC (rev 461) +++ trunk/crossfire/src/cfeditor/ReplaceDialog.java 2006-10-03 12:56:09 UTC (rev 462) @@ -182,7 +182,7 @@ iconLabel = new JLabel(); if (replaceArch != null) { colonLabel = new JLabel(":"); - iconLabel.setIcon(mainControl.getArchObjectStack().getFace(replaceArch.getFaceNr())); + iconLabel.setIcon(mainControl.getArchetypeSet().getFace(replaceArch.getFaceNr())); rfArchName = new JLabel(" " + replaceArch.getBestName()); } else { colonLabel = new JLabel(""); @@ -231,7 +231,7 @@ colonLabel.setText(""); } else { replaceWithBox.setSelectedIndex(0); - iconLabel.setIcon(mainControl.getArchObjectStack().getFace(replaceArch.getFaceNr())); + iconLabel.setIcon(mainControl.getArchetypeSet().getFace(replaceArch.getFaceNr())); rfArchName.setText(" " + replaceArch.getBestName()); colonLabel.setText(":"); } @@ -261,7 +261,7 @@ if (newArch != null) { final Icon oldIcon = iconLabel.getIcon(); - iconLabel.setIcon(mainControl.getArchObjectStack().getFace(newArch.getFaceNr())); + iconLabel.setIcon(mainControl.getArchetypeSet().getFace(newArch.getFaceNr())); rfArchName.setText(" " + newArch.getBestName()); colonLabel.setText(":"); Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-10-03 12:38:53 UTC (rev 461) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-10-03 12:56:09 UTC (rev 462) @@ -607,7 +607,7 @@ CMainStatusbar.getInstance().setText("Collect Archfile: write archetypes"); // open the process bar - final CollectProgressBar pbar = new CollectProgressBar(mainControl.getArchObjectStack().getArchCount(), + final CollectProgressBar pbar = new CollectProgressBar(mainControl.getArchetypeSet().getArchCount(), "Collecting Archetypes..."); File dfile; Modified: trunk/crossfire/src/cfeditor/gui/ArchComboBox.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ArchComboBox.java 2006-10-03 12:38:53 UTC (rev 461) +++ trunk/crossfire/src/cfeditor/gui/ArchComboBox.java 2006-10-03 12:56:09 UTC (rev 462) @@ -308,7 +308,7 @@ private static final long serialVersionUID = 1L; public ArchComboBoxModel() { - archList = mainControl.getArchList(); + archList = mainControl.getArchetypeSet().getArchList(); Arrays.sort(archList, new Comparator<GameObject>() { public int compare(final GameObject o1, final GameObject o2) { return o1.getArchetypeName().toLowerCase().compareTo(o2.getArchetypeName().toLowerCase()); Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-10-03 12:38:53 UTC (rev 461) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-10-03 12:56:09 UTC (rev 462) @@ -1190,7 +1190,7 @@ * <code>archName</code>, or <code>null</code> if it does not exist */ private GameObject getDefaultArch(final String archName) { - return mainControl.getArchObjectStack().getArch(archName); + return mainControl.getArchetypeSet().getArch(archName); } } // class DefaultMapModel Modified: trunk/crossfire/src/cfeditor/parameter/ArchParameter.java =================================================================== --- trunk/crossfire/src/cfeditor/parameter/ArchParameter.java 2006-10-03 12:38:53 UTC (rev 461) +++ trunk/crossfire/src/cfeditor/parameter/ArchParameter.java 2006-10-03 12:56:09 UTC (rev 462) @@ -31,7 +31,7 @@ } @Nullable private GameObject locateArch(final String name) { - final ArchetypeSet stack = CMainControl.getInstance().getArchObjectStack(); + final ArchetypeSet stack = CMainControl.getInstance().getArchetypeSet(); if (ArchetypeSet.getLoadStatus() != ArchetypeSet.IS_COMPLETE) { return null; } Modified: trunk/daimonin/src/daieditor/CArchPanelPan.java =================================================================== --- trunk/daimonin/src/daieditor/CArchPanelPan.java 2006-10-03 12:38:53 UTC (rev 461) +++ trunk/daimonin/src/daieditor/CArchPanelPan.java 2006-10-03 12:56:09 UTC (rev 462) @@ -168,7 +168,7 @@ @Nullable private GameObject getArchListObject(final int index) { if (index != -1) { try { - return mainControl.getArchObjectStack().getArch((String) theList.getSelectedValue()); + return mainControl.getArchetypeSet().getArch((String) theList.getSelectedValue()); } catch (final NullPointerException e) { /* ignore */ } @@ -269,7 +269,7 @@ public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - final ArchetypeSet archetypeSet = mainControl.getArchObjectStack(); + final ArchetypeSet archetypeSet = mainControl.getArchetypeSet(); final String archname = (String) value; final GameObject arch = archetypeSet.getArch(archname); if (isSelected) { // XXX it is not a good idea to query the selection information at this place. Modified: trunk/daimonin/src/daieditor/CAttribDialog.java =================================================================== --- trunk/daimonin/src/daieditor/CAttribDialog.java 2006-10-03 12:38:53 UTC (rev 461) +++ trunk/daimonin/src/daieditor/CAttribDialog.java 2006-10-03 12:56:09 UTC (rev 462) @@ -428,7 +428,7 @@ gbc.weightx = 0.0; gbc.weighty = 3.0; gbc.gridheight = 3; - imagePanel = new JLabel(mainControl.getArchObjectStack().getFace(gameObject.getFaceObjName())); + imagePanel = new JLabel(mainControl.getArchetypeSet().getFace(gameObject.getFaceObjName())); imagePanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); header.add(imagePanel, gbc); gbc.gridheight = 1; @@ -1245,7 +1245,7 @@ // now lets assign the visible face - perhaps we have still a anim gameObject.setObjectFace(); - imagePanel.setIcon(mainControl.getArchObjectStack().getFace(gameObject.getFaceObjName())); + imagePanel.setIcon(mainControl.getArchetypeSet().getFace(gameObject.getFaceObjName())); if (newMsg != null) { // set new msg text only when it is not equal to default gameObject Modified: trunk/daimonin/src/daieditor/CFTreasureListTree.java =================================================================== --- trunk/daimonin/src/daieditor/CFTreasureListTree.java 2006-10-03 12:38:53 UTC (rev 461) +++ trunk/daimonin/src/daieditor/CFTreasureListTree.java 2006-10-03 12:56:09 UTC (rev 462) @@ -943,10 +943,10 @@ } } else if (content.getType() != TreasureObj.FOLDER) { // normal arch: display the face icon - final GameObject arch = CMainControl.getInstance().getArchObjectStack().getArch(content.getName()); + final GameObject arch = CMainControl.getInstance().getArchetypeSet().getArch(content.getName()); if (arch != null) { if (!arch.hasFaceObject()) { - setIcon(CMainControl.getInstance().getArchObjectStack().getFace(arch.getFaceObjName())); + setIcon(CMainControl.getInstance().getArchetypeSet().getFace(arch.getFaceObjName())); } else { setIcon(noface); } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-10-03 12:38:53 UTC (rev 461) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-10-03 12:56:09 UTC (rev 462) @@ -842,11 +842,8 @@ mainView.setStatusText(string); } - /** - * Get the ArchetypeSet. - * @return ArchetypeSet - */ - public ArchetypeSet getArchObjectStack() { + /** {@inheritDoc} */ + public ArchetypeSet getArchetypeSet() { return archetypeSet; } Modified: trunk/daimonin/src/daieditor/CMainStatusbar.java =================================================================== --- trunk/daimonin/src/daieditor/CMainStatusbar.java 2006-10-03 12:38:53 UTC (rev 461) +++ trunk/daimonin/src/daieditor/CMainStatusbar.java 2006-10-03 12:56:09 UTC (rev 462) @@ -132,8 +132,8 @@ final long usedMem = totMem - freeMem; memory.setText(ACTION_FACTORY.format("memory", - mainControl.getArchObjectStack().getArchObjCount(), - mainControl.getArchObjectStack().getArchCount(), + mainControl.getArchetypeSet().getArchObjCount(), + mainControl.getArchetypeSet().getArchCount(), mainControl.getFaceObjects().size(), getMemoryString(usedMem), getMemoryString(freeMem), getMemoryString(totMem) )); Modified: trunk/daimonin/src/daieditor/CMapTileList.java =================================================================== --- trunk/daimonin/src/daieditor/CMapTileList.java 2006-10-03 12:38:53 UTC (rev 461) +++ trunk/daimonin/src/daieditor/CMapTileList.java 2006-10-03 12:56:09 UTC (rev 462) @@ -440,7 +440,7 @@ setIcon(CMainControl.nofaceTileIcon); } else { final String faceObjName = arch.getFaceObjName(); - final ImageIcon icon = faceObjName != null ? mainControl.getArchObjectStack().getFace(faceObjName) : null; + final ImageIcon icon = faceObjName != null ? mainControl.getArchetypeSet().getFace(faceObjName) : null; setIcon(icon != null ? icon : CMainControl.unknownTileIcon); } Modified: trunk/daimonin/src/daieditor/ReplaceDialog.java =================================================================== --- trunk/daimonin/src/daieditor/ReplaceDialog.java 2006-10-03 12:38:53 UTC (rev 461) +++ trunk/daimonin/src/daieditor/ReplaceDialog.java 2006-10-03 12:56:09 UTC (rev 462) @@ -196,7 +196,7 @@ iconLabel = new JLabel(); if (replaceArch != null) { colonLabel = new JLabel(":"); - iconLabel.setIcon(mainControl.getArchObjectStack().getFace(replaceArch.getFaceObjName())); + iconLabel.setIcon(mainControl.getArchetypeSet().getFace(replaceArch.getFaceObjName())); rfArchName = new JLabel(" " + replaceArch.getBestName()); } else { colonLabel = new JLabel(""); @@ -231,7 +231,7 @@ colonLabel.setText(""); } else { replaceWithBox.setSelectedIndex(0); - iconLabel.setIcon(mainControl.getArchObjectStack().getFace(replaceArch.getFaceObjName())); + iconLabel.setIcon(mainControl.getArchetypeSet().getFace(replaceArch.getFaceObjName())); rfArchName.setText(" " + replaceArch.getBestName()); colonLabel.setText(":"); } @@ -261,7 +261,7 @@ if (newArch != null) { final Icon oldIcon = iconLabel.getIcon(); - iconLabel.setIcon(mainControl.getArchObjectStack().getFace(newArch.getFaceObjName())); + iconLabel.setIcon(mainControl.getArchetypeSet().getFace(newArch.getFaceObjName())); rfArchName.setText(" " + newArch.getBestName()); colonLabel.setText(":"); Modified: trunk/daimonin/src/daieditor/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/ScriptArchData.java 2006-10-03 12:38:53 UTC (rev 461) +++ trunk/daimonin/src/daieditor/ScriptArchData.java 2006-10-03 12:56:09 UTC (rev 462) @@ -590,7 +590,7 @@ event = new GameObject(); // FIXME: This arch has no default arch event.setArchTypNr(118); event.setArchetypeName("event_obj"); - event.setArchetype(CMainControl.getInstance().getArchObjectStack().getArch("event_obj")); + event.setArchetype(CMainControl.getInstance().getArchetypeSet().getArch("event_obj")); event.setObjectFace(); setEventData(eventType, pluginName, filePath, options); } Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-10-03 12:38:53 UTC (rev 461) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-10-03 12:56:09 UTC (rev 462) @@ -537,7 +537,7 @@ private final Runnable archCollector = new Runnable() { /** {@inheritDoc} */ public void run() { - final Progress pbar = new ProgressDisplay(mainControl.getMainView(), ""/*FIXME*/, mainControl.getArchObjectStack().getArchCount(), ACTION_FACTORY.getString("archCollectArches")); + final Progress pbar = new ProgressDisplay(mainControl.getMainView(), ""/*FIXME*/, mainControl.getArchetypeSet().getArchCount(), ACTION_FACTORY.getString("archCollectArches")); collectDaimoninArchesArches(pbar); collectDaimoninArchesAnimations(pbar); collectDaimoninArchesAnimationTree(pbar); Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2006-10-03 12:38:53 UTC (rev 461) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2006-10-03 12:56:09 UTC (rev 462) @@ -1013,8 +1013,8 @@ normalFace = CMainControl.nofaceTileIcon; transFace = normalFace; } else { - normalFace = CMainControl.getInstance().getArchObjectStack().getFace(faceObjName); - transFace = CMainControl.getInstance().getArchObjectStack().getTrans(faceObjName); + normalFace = CMainControl.getInstance().getArchetypeSet().getFace(faceObjName); + transFace = CMainControl.getInstance().getArchetypeSet().getTrans(faceObjName); } } Modified: trunk/daimonin/src/daieditor/map/DefaultMapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-10-03 12:38:53 UTC (rev 461) +++ trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-10-03 12:56:09 UTC (rev 462) @@ -632,7 +632,7 @@ * <code>archName</code>, or <code>null</code> if it does not exist */ private GameObject getDefaultArch(final String archName) { - return mainControl.getArchObjectStack().getArch(archName); + return mainControl.getArchetypeSet().getArch(archName); } } // class DefaultMapModel Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2006-10-03 12:38:53 UTC (rev 461) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2006-10-03 12:56:09 UTC (rev 462) @@ -36,4 +36,10 @@ */ String getScriptSuffix(); + /** + * Get the ArchetypeSet for the available Archetypes. + * @return ArchetypeSet + */ + Object getArchetypeSet(); + } // interface MainControl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-03 12:38:59
|
Revision: 461 http://svn.sourceforge.net/gridarta/?rev=461&view=rev Author: christianhujer Date: 2006-10-03 05:38:53 -0700 (Tue, 03 Oct 2006) Log Message: ----------- MainControl is no longer regarded deprecated itself (bug: forgot to remove deprecation annotation in previous commit). 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-10-03 12:37:34 UTC (rev 460) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2006-10-03 12:38:53 UTC (rev 461) @@ -7,7 +7,7 @@ * It should become obsolete after a while. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -@Deprecated public interface MainControl { +public interface MainControl { /** * Refresh menus and toolbars. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-03 12:37:39
|
Revision: 460 http://svn.sourceforge.net/gridarta/?rev=460&view=rev Author: christianhujer Date: 2006-10-03 05:37:34 -0700 (Tue, 03 Oct 2006) Log Message: ----------- MainControl is no longer regarded deprecated itself. 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-10-03 12:35:02 UTC (rev 459) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2006-10-03 12:37:34 UTC (rev 460) @@ -6,7 +6,6 @@ * This interface is only for unification. * It should become obsolete after a while. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @deprecated don't intentionally use this for other than unification purposes. */ @Deprecated public interface MainControl { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |