From: <aki...@us...> - 2008-09-13 12:26:30
|
Revision: 5123 http://gridarta.svn.sourceforge.net/gridarta/?rev=5123&view=rev Author: akirschbaum Date: 2008-09-13 12:26:36 +0000 (Sat, 13 Sep 2008) Log Message: ----------- Remove GridartaObjectsFactory.newGameObject() and GridartaObjectsFactory.newGameObjectParser(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java trunk/crossfire/src/cfeditor/io/GameObjectParser.java trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java trunk/daimonin/src/daieditor/io/GameObjectParser.java trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java trunk/src/app/net/sf/gridarta/io/DefaultMapReader.java trunk/src/app/net/sf/gridarta/io/DefaultMapWriter.java trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java trunk/src/app/net/sf/gridarta/map/MapControlFactory.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Added Paths: ----------- trunk/crossfire/src/cfeditor/gameobject/CrossfireGameObjectFactory.java trunk/daimonin/src/daieditor/gameobject/DaimoninGameObjectFactory.java trunk/src/app/net/sf/gridarta/gameobject/GameObjectFactory.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-09-13 11:51:51 UTC (rev 5122) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-09-13 12:26:36 UTC (rev 5123) @@ -24,6 +24,7 @@ import cfeditor.gameobject.ArchetypeParser; import cfeditor.gameobject.ArchetypeSet; import cfeditor.gameobject.ArchetypeSetLoader; +import cfeditor.gameobject.CrossfireGameObjectFactory; import cfeditor.gameobject.GameObject; import cfeditor.gameobject.anim.AnimationObjects; import cfeditor.gameobject.face.FaceObjects; @@ -53,6 +54,7 @@ import net.sf.gridarta.MapManager; import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.AbstractArchetypeParser; +import net.sf.gridarta.gameobject.GameObjectFactory; import net.sf.gridarta.gameobject.anim.AnimationObject; import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.MainView; @@ -70,6 +72,7 @@ import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.io.ConfigFileUtils; +import net.sf.gridarta.io.GameObjectParser; import net.sf.gridarta.map.validation.DelegatingMapValidator; import net.sf.gridarta.map.validation.checks.AttributeRangeChecker; import net.sf.gridarta.map.validation.checks.ConnectedInsideContainerChecker; @@ -120,12 +123,26 @@ } /** {@inheritDoc} */ + @NotNull @Override - protected AbstractArchetypeParser<GameObject, MapArchObject, Archetype> newArchetypeParser(final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final net.sf.gridarta.gameobject.anim.AnimationObjects<? extends AnimationObject> animationObjects, final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { - return new ArchetypeParser(gridartaObjectsFactory, archetypeChooserControl, animationObjects, archetypeSet); + protected GameObjectFactory<GameObject, MapArchObject, Archetype> newGameObjectFactory() { + return new CrossfireGameObjectFactory(); } /** {@inheritDoc} */ + @NotNull + @Override + protected GameObjectParser<GameObject, MapArchObject, Archetype> newGameObjectParser(@NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory) { + return new cfeditor.io.GameObjectParser(gameObjectFactory); + } + + /** {@inheritDoc} */ + @Override + protected AbstractArchetypeParser<GameObject, MapArchObject, Archetype> newArchetypeParser(final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final net.sf.gridarta.gameobject.anim.AnimationObjects<? extends AnimationObject> animationObjects, final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { + return new ArchetypeParser(gameObjectParser, archetypeChooserControl, animationObjects, archetypeSet); + } + + /** {@inheritDoc} */ protected void createActions() { } @@ -186,8 +203,8 @@ /** {@inheritDoc} */ @Override - protected void init4(@NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final net.sf.gridarta.gameobject.face.FaceObjects faceObjects, @NotNull final net.sf.gridarta.gameobject.anim.AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView) { - new ArchetypeSetLoader(globalSettings, gridartaObjectsFactory, getCollectedDirectory(), getConfigurationDirectory(), archetypeSet, archetypeParser, editTypes, faceObjects, animationObjects).loadArchetypes(mainView); + protected void init4(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final net.sf.gridarta.gameobject.face.FaceObjects faceObjects, @NotNull final net.sf.gridarta.gameobject.anim.AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView) { + new ArchetypeSetLoader(globalSettings, gameObjectParser, getCollectedDirectory(), getConfigurationDirectory(), archetypeSet, archetypeParser, editTypes, faceObjects, animationObjects).loadArchetypes(mainView); } /** {@inheritDoc} */ Modified: trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-09-13 11:51:51 UTC (rev 5122) +++ trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-09-13 12:26:36 UTC (rev 5123) @@ -20,6 +20,7 @@ package cfeditor; import cfeditor.gameobject.Archetype; +import cfeditor.gameobject.CrossfireGameObjectFactory; import cfeditor.gameobject.GameObject; import cfeditor.gameobject.UndefinedArchetype; import cfeditor.gui.map.CMapViewBasic; @@ -89,12 +90,6 @@ /** {@inheritDoc} */ @NotNull - public GameObject newGameObject() { - return new GameObject(); - } - - /** {@inheritDoc} */ - @NotNull public MapArchObject newMapArchObject(final boolean addDefaultAttributes) { final MapArchObject mapArchObject = new MapArchObject(); if (addDefaultAttributes) { @@ -106,7 +101,7 @@ /** {@inheritDoc} */ @NotNull public MapReader<GameObject, MapArchObject> newMapReader(@NotNull final File file) throws FileNotFoundException { - return new DefaultMapReader<GameObject, MapArchObject, Archetype>(this, mainView, archetypeSet, editTypes, file); + return new DefaultMapReader<GameObject, MapArchObject, Archetype>(this, new GameObjectParser(new CrossfireGameObjectFactory()), mainView, archetypeSet, editTypes, file); } /** {@inheritDoc} */ @@ -121,11 +116,6 @@ } /** {@inheritDoc} */ - public GameObjectParser newGameObjectParser() { - return new GameObjectParser(this); - } - - /** {@inheritDoc} */ @NotNull public MapView<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapView(@NotNull final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, @Nullable final Point viewPosition, final int viewCounter) { return new MapView<GameObject, MapArchObject, Archetype, CMapViewBasic>(mainView, mapControl, viewCounter, new CMapViewBasic(filterControl, editTypes, mapControl, viewPosition, toolPalette, 32, 32, selectedSquareView), ACTION_FACTORY, mapImageCache); Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2008-09-13 11:51:51 UTC (rev 5122) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2008-09-13 12:26:36 UTC (rev 5123) @@ -25,12 +25,12 @@ import java.io.File; import java.io.IOException; import java.util.List; -import net.sf.gridarta.GridartaObjectsFactory; import net.sf.gridarta.gameobject.AbstractArchetypeParser; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; +import net.sf.gridarta.io.GameObjectParser; import net.sf.gridarta.io.PathManager; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; @@ -55,9 +55,9 @@ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); /** - * The gridarta objects factory instance. + * The game object parser instance. */ - private final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory; + private final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser; /** * The animation objects instance. @@ -73,15 +73,14 @@ /** * Creates an ArchetypeParser. - * @param gridartaObjectsFactory the gridarta objects factory instance to - * use + * @param gameObjectParser the game object parser instance to use * @param archetypeChooserControl an archetype chooser to add parsed * archetypes to * @param animationObjects the animation objects instance to use * @param archetypeSet the archetype set */ - public ArchetypeParser(final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final AnimationObjects<?> animationObjects, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { - this.gridartaObjectsFactory = gridartaObjectsFactory; + public ArchetypeParser(final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final AnimationObjects<?> animationObjects, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { + this.gameObjectParser = gameObjectParser; this.archetypeChooserControl = archetypeChooserControl; this.animationObjects = animationObjects; this.archetypeSet = archetypeSet; @@ -204,7 +203,7 @@ } else if (thisLine.startsWith("Object ")) { log.warn(ACTION_FACTORY.format("logInventoryInDefArch", thisLine)); } else if (thisLine.startsWith("arch ")) { - final GameObject invObject = gridartaObjectsFactory.newGameObjectParser().load(in, thisLine, invObjects); + final GameObject invObject = gameObjectParser.load(in, thisLine, invObjects); assert invObject != null; archetype.addLast(invObject); } else if (thisLine.equals("end")) { Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java 2008-09-13 11:51:51 UTC (rev 5122) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java 2008-09-13 12:26:36 UTC (rev 5123) @@ -34,7 +34,6 @@ import java.util.List; import net.sf.gridarta.EditTypes; import net.sf.gridarta.GlobalSettings; -import net.sf.gridarta.GridartaObjectsFactory; import net.sf.gridarta.gameobject.AbstractArchetypeParser; import net.sf.gridarta.gameobject.AbstractArchetypeSetLoader; import net.sf.gridarta.gameobject.ArchetypeSet; @@ -46,6 +45,7 @@ import net.sf.gridarta.gameobject.face.DuplicateFaceException; import net.sf.gridarta.gameobject.face.FaceObjectProviders; import net.sf.gridarta.gameobject.face.FaceObjects; +import net.sf.gridarta.io.GameObjectParser; import net.sf.gridarta.io.IOUtils; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; @@ -73,10 +73,10 @@ private final GlobalSettings globalSettings; /** - * The gridarta objects factory instance. + * The game object parser instance. */ @NotNull - private final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory; + private final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser; /** * The collected directory. @@ -123,7 +123,7 @@ /** * Creates a new instance. * @param globalSettings the global settings instance - * @param gridartaObjectsFactory the gridarta objects factory instance + * @param gameObjectParser the game object parser instance * @param collectedDirectory the collected directory * @param configurationDirectory the configuration directory * @param archetypeSet the archetype set to update @@ -132,9 +132,9 @@ * @param faceObjects the face objects instance * @param animationObjects the animation objects instance */ - public ArchetypeSetLoader(@NotNull final GlobalSettings globalSettings, @NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final String collectedDirectory, @NotNull final String configurationDirectory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects) { + public ArchetypeSetLoader(@NotNull final GlobalSettings globalSettings, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final String collectedDirectory, @NotNull final String configurationDirectory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects) { this.globalSettings = globalSettings; - this.gridartaObjectsFactory = gridartaObjectsFactory; + this.gameObjectParser = gameObjectParser; this.collectedDirectory = collectedDirectory; this.configurationDirectory = configurationDirectory; this.archetypeSet = archetypeSet; @@ -170,7 +170,7 @@ } archetypeSet.reportErrors(parent); - gridartaObjectsFactory.newGameObjectParser().collectTempList(parent, archetypeSet, editTypes, invObjects, fname, true); + gameObjectParser.collectTempList(parent, archetypeSet, editTypes, invObjects, fname, true); archetypeSet.connectFaces(); // attach faces to arches // print message if no arches were found Added: trunk/crossfire/src/cfeditor/gameobject/CrossfireGameObjectFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/CrossfireGameObjectFactory.java (rev 0) +++ trunk/crossfire/src/cfeditor/gameobject/CrossfireGameObjectFactory.java 2008-09-13 12:26:36 UTC (rev 5123) @@ -0,0 +1,38 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package cfeditor.gameobject; + +import cfeditor.map.MapArchObject; +import net.sf.gridarta.gameobject.GameObjectFactory; +import org.jetbrains.annotations.NotNull; + +/** + * The {@link GameObjectFactory} to create Crossfire related game objects. + * @author Andreas Kirschbaum + */ +public class CrossfireGameObjectFactory implements GameObjectFactory<GameObject, MapArchObject, Archetype> { + + /** {@inheritDoc} */ + @NotNull + public GameObject newGameObject() { + return new GameObject(); + } + +} // class CrossfireGameObjectFactory Property changes on: trunk/crossfire/src/cfeditor/gameobject/CrossfireGameObjectFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/crossfire/src/cfeditor/io/GameObjectParser.java =================================================================== --- trunk/crossfire/src/cfeditor/io/GameObjectParser.java 2008-09-13 11:51:51 UTC (rev 5122) +++ trunk/crossfire/src/cfeditor/io/GameObjectParser.java 2008-09-13 12:26:36 UTC (rev 5123) @@ -19,7 +19,6 @@ package cfeditor.io; -import cfeditor.CrossfireObjectsFactory; import cfeditor.gameobject.Archetype; import cfeditor.gameobject.GameObject; import cfeditor.map.MapArchObject; @@ -29,6 +28,7 @@ import java.util.Map; import java.util.TreeMap; import java.util.regex.Pattern; +import net.sf.gridarta.gameobject.GameObjectFactory; import net.sf.gridarta.io.AbstractGameObjectParser; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; @@ -330,11 +330,11 @@ /** * Create a new instance. - * @param gridartaObjectsFactory The gridarta objects factory for creating - * new game object instances. + * @param gameObjectFactory the game object factory for creating new game + * object instances */ - public GameObjectParser(@NotNull final CrossfireObjectsFactory gridartaObjectsFactory) { - super(gridartaObjectsFactory); + public GameObjectParser(@NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory) { + super(gameObjectFactory); } /** {@inheritDoc} */ Modified: trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java 2008-09-13 11:51:51 UTC (rev 5122) +++ trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java 2008-09-13 12:26:36 UTC (rev 5123) @@ -33,6 +33,7 @@ import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.gui.map.RendererFactory; +import net.sf.gridarta.io.GameObjectParser; import net.sf.gridarta.map.AbstractMapControlFactory; import net.sf.gridarta.map.DefaultMapControl; import net.sf.gridarta.map.MapControl; @@ -53,6 +54,12 @@ private GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory; /** + * The {@link GameObjectParser} instance to use. + */ + @NotNull + private GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser; + + /** * The {@link RendererFactory} instance to use. */ @NotNull @@ -97,8 +104,9 @@ } /** {@inheritDoc} */ - public void init(@NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final MapActions mapActions, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final GameObjectMatcher exitTypeGameObjectMatcher) { + public void init(@NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final MapActions mapActions, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final GameObjectMatcher exitTypeGameObjectMatcher) { this.gridartaObjectsFactory = gridartaObjectsFactory; + this.gameObjectParser = gameObjectParser; this.rendererFactory = rendererFactory; this.mapActions = mapActions; this.archetypeChooserModel = archetypeChooserModel; @@ -110,7 +118,7 @@ /** {@inheritDoc} */ @NotNull public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControl(@NotNull final Component parent, @Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @NotNull final String mapName, @Nullable final File file) { - final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(gridartaObjectsFactory, rendererFactory, parent, autojoinLists, mapImageCache, objects, mapArchObject, false, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); + final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(gridartaObjectsFactory, gameObjectParser, rendererFactory, parent, autojoinLists, mapImageCache, objects, mapArchObject, false, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); mapControl.setMapFile(file); mapControl.setMapFileName(mapName); return mapControl; @@ -122,7 +130,7 @@ final MapArchObject mapArchObject = gridartaObjectsFactory.newMapArchObject(true); mapArchObject.setMapSize(mapSize); mapArchObject.setMapName(pickmapName); - final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(gridartaObjectsFactory, rendererFactory, parent, autojoinLists, mapImageCache, null, mapArchObject, true, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); + final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(gridartaObjectsFactory, gameObjectParser, rendererFactory, parent, autojoinLists, mapImageCache, null, mapArchObject, true, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); mapControl.setMapFile(file); mapControl.setMapFileName(file.getPath()); mapControl.resetModified(); @@ -132,7 +140,7 @@ /** {@inheritDoc} */ @NotNull public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newPickmapControl(@NotNull final Component parent, @Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @NotNull final File file) { - final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(gridartaObjectsFactory, rendererFactory, parent, autojoinLists, mapImageCache, objects, mapArchObject, true, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); + final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(gridartaObjectsFactory, gameObjectParser, rendererFactory, parent, autojoinLists, mapImageCache, objects, mapArchObject, true, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); mapControl.setMapFile(file); mapControl.setMapFileName(file.getPath()); mapControl.resetModified(); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-09-13 11:51:51 UTC (rev 5122) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-09-13 12:26:36 UTC (rev 5123) @@ -23,6 +23,7 @@ import daieditor.gameobject.ArchetypeParser; import daieditor.gameobject.ArchetypeSet; import daieditor.gameobject.ArchetypeSetLoader; +import daieditor.gameobject.DaimoninGameObjectFactory; import daieditor.gameobject.GameObject; import daieditor.gameobject.anim.AnimationObjects; import daieditor.gameobject.face.FaceObjects; @@ -55,6 +56,7 @@ import net.sf.gridarta.MapManager; import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.AbstractArchetypeParser; +import net.sf.gridarta.gameobject.GameObjectFactory; import net.sf.gridarta.gameobject.anim.AnimationObject; import net.sf.gridarta.gameobject.face.FaceObjectProviders; import net.sf.gridarta.gameobject.match.GameObjectMatcher; @@ -76,6 +78,7 @@ import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.gui.utils.GUIUtils; +import net.sf.gridarta.io.GameObjectParser; import net.sf.gridarta.map.MapControl; import net.sf.gridarta.map.MapModel; import net.sf.gridarta.map.MapSquare; @@ -180,8 +183,22 @@ } /** {@inheritDoc} */ + @NotNull @Override - protected AbstractArchetypeParser<GameObject, MapArchObject, Archetype> newArchetypeParser(final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final net.sf.gridarta.gameobject.anim.AnimationObjects<? extends AnimationObject> animationObjects, final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { + protected GameObjectFactory<GameObject, MapArchObject, Archetype> newGameObjectFactory() { + return new DaimoninGameObjectFactory(); + } + + /** {@inheritDoc} */ + @NotNull + @Override + protected GameObjectParser<GameObject, MapArchObject, Archetype> newGameObjectParser(@NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory) { + return new daieditor.io.GameObjectParser(gameObjectFactory); + } + + /** {@inheritDoc} */ + @Override + protected AbstractArchetypeParser<GameObject, MapArchObject, Archetype> newArchetypeParser(final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final net.sf.gridarta.gameobject.anim.AnimationObjects<? extends AnimationObject> animationObjects, final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { return new ArchetypeParser(archetypeChooserControl, animationObjects, archetypeSet); } @@ -241,9 +258,9 @@ /** {@inheritDoc} */ @Override - protected void init4(@NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final net.sf.gridarta.gameobject.face.FaceObjects faceObjects, @NotNull final net.sf.gridarta.gameobject.anim.AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView) { + protected void init4(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final net.sf.gridarta.gameobject.face.FaceObjects faceObjects, @NotNull final net.sf.gridarta.gameobject.anim.AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView) { MultiPositionData.init(getConfigurationDirectory()); - new ArchetypeSetLoader(globalSettings, gridartaObjectsFactory, getCollectedDirectory(), getConfigurationDirectory(), archetypeSet, archetypeParser, editTypes, faceObjects, animationObjects, this).loadArchetypes(mainView); + new ArchetypeSetLoader(globalSettings, gameObjectParser, getCollectedDirectory(), getConfigurationDirectory(), archetypeSet, archetypeParser, editTypes, faceObjects, animationObjects, this).loadArchetypes(mainView); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java =================================================================== --- trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java 2008-09-13 11:51:51 UTC (rev 5122) +++ trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java 2008-09-13 12:26:36 UTC (rev 5123) @@ -20,6 +20,7 @@ package daieditor; import daieditor.gameobject.Archetype; +import daieditor.gameobject.DaimoninGameObjectFactory; import daieditor.gameobject.GameObject; import daieditor.gameobject.UndefinedArchetype; import daieditor.gui.map.CMapViewBasic; @@ -93,12 +94,6 @@ /** {@inheritDoc} */ @NotNull - public GameObject newGameObject() { - return new GameObject(); - } - - /** {@inheritDoc} */ - @NotNull public MapArchObject newMapArchObject(final boolean addDefaultAttributes) { final MapArchObject mapArchObject = new MapArchObject(); if (addDefaultAttributes) { @@ -110,7 +105,7 @@ /** {@inheritDoc} */ @NotNull public MapReader<GameObject, MapArchObject> newMapReader(@NotNull final File file) throws FileNotFoundException { - return new DefaultMapReader<GameObject, MapArchObject, Archetype>(this, mainView, archetypeSet, editTypes, file); + return new DefaultMapReader<GameObject, MapArchObject, Archetype>(this, new GameObjectParser(new DaimoninGameObjectFactory()), mainView, archetypeSet, editTypes, file); } /** {@inheritDoc} */ @@ -125,11 +120,6 @@ } /** {@inheritDoc} */ - public GameObjectParser newGameObjectParser() { - return new GameObjectParser(this); - } - - /** {@inheritDoc} */ @NotNull public MapView<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapView(@NotNull final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, @Nullable final Point viewPosition, final int viewCounter) { return new MapView<GameObject, MapArchObject, Archetype, CMapViewBasic>(mainView, mapControl, viewCounter, new CMapViewBasic((CMainControl) mainControl, editTypes, mapControl, viewPosition, faceObjects, toolPalette, IGUIConstants.TILE_ISO_XLEN, IGUIConstants.TILE_ISO_YLEN, selectedSquareView), ACTION_FACTORY, mapImageCache); Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java 2008-09-13 11:51:51 UTC (rev 5122) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java 2008-09-13 12:26:36 UTC (rev 5123) @@ -36,7 +36,6 @@ import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.EditTypes; import net.sf.gridarta.GlobalSettings; -import net.sf.gridarta.GridartaObjectsFactory; import net.sf.gridarta.gameobject.AbstractArchetypeParser; import net.sf.gridarta.gameobject.AbstractArchetypeSetLoader; import net.sf.gridarta.gameobject.ArchetypeSet; @@ -48,6 +47,7 @@ import net.sf.gridarta.gameobject.face.DuplicateFaceException; import net.sf.gridarta.gameobject.face.FaceObjectProviders; import net.sf.gridarta.gameobject.face.FaceObjects; +import net.sf.gridarta.io.GameObjectParser; import net.sf.gridarta.io.IOUtils; import net.sf.japi.swing.ActionFactory; import net.sf.japi.util.ThrowableHandler; @@ -80,7 +80,7 @@ * The gridarta objects factory instance. */ @NotNull - private final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory; + private final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser; /** * The collected directory. @@ -140,7 +140,7 @@ /** * Creates a new instance. * @param globalSettings the global settings instance - * @param gridartaObjectsFactory the gridarta objects factory instance + * @param gameObjectParser the game object parser instance * @param collectedDirectory the collected directory * @param configurationDirectory the configuration directory * @param archetypeSet the archetype set to update @@ -150,9 +150,9 @@ * @param animationObjects the animation objects instance * @param throwableHandler the throwable handler to use */ - public ArchetypeSetLoader(@NotNull final GlobalSettings globalSettings, @NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final String collectedDirectory, @NotNull final String configurationDirectory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final ThrowableHandler<Throwable> throwableHandler) { + public ArchetypeSetLoader(@NotNull final GlobalSettings globalSettings, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final String collectedDirectory, @NotNull final String configurationDirectory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final ThrowableHandler<Throwable> throwableHandler) { this.globalSettings = globalSettings; - this.gridartaObjectsFactory = gridartaObjectsFactory; + this.gameObjectParser = gameObjectParser; this.collectedDirectory = collectedDirectory; this.configurationDirectory = configurationDirectory; this.archetypeSet = archetypeSet; @@ -195,7 +195,7 @@ loadArchesFromArtifacts(archetypeParser, collectedDirectory + "/" + IGUIConstants.ARTIFACTS_FILE, "Artifacts", "artifacts", invObjects); loadArchesFromArtifacts(archetypeParser, globalSettings.getMapDefaultFolder(), "Artifacts", "maps", invObjects); - gridartaObjectsFactory.newGameObjectParser().collectTempList(parent, archetypeSet, editTypes, invObjects, fname, true); + gameObjectParser.collectTempList(parent, archetypeSet, editTypes, invObjects, fname, true); archetypeSet.connectFaces(); // attach faces to arches // print message if no arches were found Added: trunk/daimonin/src/daieditor/gameobject/DaimoninGameObjectFactory.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/DaimoninGameObjectFactory.java (rev 0) +++ trunk/daimonin/src/daieditor/gameobject/DaimoninGameObjectFactory.java 2008-09-13 12:26:36 UTC (rev 5123) @@ -0,0 +1,38 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package daieditor.gameobject; + +import daieditor.map.MapArchObject; +import net.sf.gridarta.gameobject.GameObjectFactory; +import org.jetbrains.annotations.NotNull; + +/** + * The {@link GameObjectFactory} to create Daimonin related game objects. + * @author Andreas Kirschbaum + */ +public class DaimoninGameObjectFactory implements GameObjectFactory<GameObject, MapArchObject, Archetype> { + + /** {@inheritDoc} */ + @NotNull + public GameObject newGameObject() { + return new GameObject(); + } + +} // class DaimoninGameObjectFactory Property changes on: trunk/daimonin/src/daieditor/gameobject/DaimoninGameObjectFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/daimonin/src/daieditor/io/GameObjectParser.java =================================================================== --- trunk/daimonin/src/daieditor/io/GameObjectParser.java 2008-09-13 11:51:51 UTC (rev 5122) +++ trunk/daimonin/src/daieditor/io/GameObjectParser.java 2008-09-13 12:26:36 UTC (rev 5123) @@ -19,12 +19,12 @@ package daieditor.io; -import daieditor.DaimoninObjectsFactory; import daieditor.gameobject.Archetype; import daieditor.gameobject.GameObject; import daieditor.map.MapArchObject; import java.io.IOException; import java.util.Formatter; +import net.sf.gridarta.gameobject.GameObjectFactory; import net.sf.gridarta.io.AbstractGameObjectParser; import org.jetbrains.annotations.NotNull; @@ -37,11 +37,11 @@ /** * Create a new instance. - * @param gridartaObjectsFactory The gridarta objects factory for creating - * new game object instances. + * @param gameObjectFactory the game object factory for creating new game + * object instances */ - public GameObjectParser(@NotNull final DaimoninObjectsFactory gridartaObjectsFactory) { - super(gridartaObjectsFactory); + public GameObjectParser(@NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory) { + super(gameObjectFactory); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java 2008-09-13 11:51:51 UTC (rev 5122) +++ trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java 2008-09-13 12:26:36 UTC (rev 5123) @@ -33,6 +33,7 @@ import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.gui.map.RendererFactory; +import net.sf.gridarta.io.GameObjectParser; import net.sf.gridarta.map.AbstractMapControlFactory; import net.sf.gridarta.map.DefaultMapControl; import net.sf.gridarta.map.MapControl; @@ -53,6 +54,12 @@ private GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory; /** + * The {@link GameObjectParser} instance to use. + */ + @NotNull + private GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser; + + /** * The {@link RendererFactory} instance to use. */ @NotNull @@ -97,8 +104,9 @@ } /** {@inheritDoc} */ - public void init(@NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final MapActions mapActions, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final GameObjectMatcher exitTypeGameObjectMatcher) { + public void init(@NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final MapActions mapActions, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final GameObjectMatcher exitTypeGameObjectMatcher) { this.gridartaObjectsFactory = gridartaObjectsFactory; + this.gameObjectParser = gameObjectParser; this.rendererFactory = rendererFactory; this.mapActions = mapActions; this.archetypeChooserModel = archetypeChooserModel; @@ -110,7 +118,7 @@ /** {@inheritDoc} */ @NotNull public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControl(@NotNull final Component parent, @Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @NotNull final String mapName, @Nullable final File file) { - final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(gridartaObjectsFactory, rendererFactory, parent, autojoinLists, mapImageCache, objects, mapArchObject, false, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); + final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(gridartaObjectsFactory, gameObjectParser, rendererFactory, parent, autojoinLists, mapImageCache, objects, mapArchObject, false, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); mapControl.setMapFile(file); mapControl.setMapFileName(mapName); return mapControl; @@ -123,7 +131,7 @@ mapArchObject.setMapSize(mapSize); mapArchObject.setMapName(pickmapName); mapArchObject.setDifficulty(1); - final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(gridartaObjectsFactory, rendererFactory, parent, autojoinLists, mapImageCache, null, mapArchObject, true, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); + final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(gridartaObjectsFactory, gameObjectParser, rendererFactory, parent, autojoinLists, mapImageCache, null, mapArchObject, true, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); mapControl.setMapFile(file); mapControl.setMapFileName(file.getPath()); mapControl.resetModified(); @@ -134,7 +142,7 @@ @NotNull public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newPickmapControl(@NotNull final Component parent, @Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @NotNull final File file) { mapArchObject.setDifficulty(1); - final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(gridartaObjectsFactory, rendererFactory, parent, autojoinLists, mapImageCache, objects, mapArchObject, true, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); + final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(gridartaObjectsFactory, gameObjectParser, rendererFactory, parent, autojoinLists, mapImageCache, objects, mapArchObject, true, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); mapControl.setMapFile(file); mapControl.setMapFileName(file.getPath()); mapControl.resetModified(); Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-09-13 11:51:51 UTC (rev 5122) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-09-13 12:26:36 UTC (rev 5123) @@ -44,6 +44,7 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gameobject.GameObjectFactory; import net.sf.gridarta.gameobject.anim.AnimationObject; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.face.FaceObjects; @@ -88,6 +89,7 @@ import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.gui.undo.UndoControl; import net.sf.gridarta.help.Help; +import net.sf.gridarta.io.GameObjectParser; import net.sf.gridarta.io.IOUtils; import net.sf.gridarta.io.PathManager; import net.sf.gridarta.map.AutoValidator; @@ -434,11 +436,13 @@ mainView.init(gameObjectAttributesControl, selectedSquareView, archetypeTypeSet, mapTileListBottom, gameObjectMatchers, archetypeChooserControl, pickmapChooserControl, objectChooser, leftPanel); mapActions.updateMenuState(); init3(); - final AbstractArchetypeParser<G, A, R> archetypeParser = newArchetypeParser(gridartaObjectsFactory, archetypeChooserControl, animationObjects, archetypeSet); + final GameObjectFactory<G, A, R> gameObjectFactory = newGameObjectFactory(); + final GameObjectParser<G, A, R> gameObjectParser = newGameObjectParser(gameObjectFactory); + final AbstractArchetypeParser<G, A, R> archetypeParser = newArchetypeParser(gameObjectParser, archetypeChooserControl, animationObjects, archetypeSet); gridartaObjectsFactory.init(faceObjects, selectedSquareView, this, mainView, editTypes, mapImageCache, archetypeSet, toolPalette); - mapControlFactory.init(gridartaObjectsFactory, rendererFactory, mapActions, archetypeChooserModel, mapImageCache, autojoinLists, exitMatcher); + mapControlFactory.init(gridartaObjectsFactory, gameObjectParser, rendererFactory, mapActions, archetypeChooserModel, mapImageCache, autojoinLists, exitMatcher); GameObject.initialize(archetypeSet, archetypeTypeSet, gameObjectMatchers, animationObjects, SystemIcons.getNofaceTileIcon()); - init4(archetypeParser, editTypes, faceObjects, animationObjects, mainView); + init4(gameObjectParser, archetypeParser, editTypes, faceObjects, animationObjects, mainView); if (globalSettings.isAutoPopupDocu()) { // do an automated help popup because the docu version has increased @@ -468,8 +472,14 @@ fileControl = new FileControl<G, A, R, V>(globalSettings, archetypeSet, mapPreviewAccessory, mapManager, mainView, mapFileFilter, scriptFileFilter, newMapDialogFactory, scriptExtension); } - protected abstract AbstractArchetypeParser<G, A, R> newArchetypeParser(final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, final ArchetypeChooserControl<G, A, R, V> archetypeChooserControl, final AnimationObjects<? extends AnimationObject> animationObjects, final ArchetypeSet<G, A, R> archetypeSet); + @NotNull + protected abstract GameObjectFactory<G, A, R> newGameObjectFactory(); + @NotNull + protected abstract GameObjectParser<G, A, R> newGameObjectParser(@NotNull final GameObjectFactory<G, A, R> gameObjectFactory); + + protected abstract AbstractArchetypeParser<G, A, R> newArchetypeParser(final GameObjectParser<G, A, R> gameObjectParser, final ArchetypeChooserControl<G, A, R, V> archetypeChooserControl, final AnimationObjects<? extends AnimationObject> animationObjects, final ArchetypeSet<G, A, R> archetypeSet); + protected abstract void createActions(); @NotNull @@ -488,7 +498,7 @@ protected abstract void init3(); - protected abstract void init4(@NotNull final AbstractArchetypeParser<G, A, R> archetypeParser, @NotNull final EditTypes<G, A, R, V> editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, final MainView<G, A, R, V> mainView); + protected abstract void init4(@NotNull final GameObjectParser<G, A, R> gameObjectParser, @NotNull final AbstractArchetypeParser<G, A, R> archetypeParser, @NotNull final EditTypes<G, A, R, V> editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, final MainView<G, A, R, V> mainView); protected abstract void deleteLibraries(); Modified: trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java 2008-09-13 11:51:51 UTC (rev 5122) +++ trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java 2008-09-13 12:26:36 UTC (rev 5123) @@ -31,7 +31,6 @@ import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.gui.map.tools.ToolPalette; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; -import net.sf.gridarta.io.GameObjectParser; import net.sf.gridarta.io.MapArchObjectParser; import net.sf.gridarta.io.MapReader; import net.sf.gridarta.map.MapArchObject; @@ -55,13 +54,6 @@ A newMapArchObject(boolean addDefaultAttributes); /** - * Create a new {@link GameObject} instance. - * @return The new game object. - */ - @NotNull - G newGameObject(); - - /** * Open a file for reading it as a map. * @param file File to open. * @return The new map reader. @@ -85,12 +77,6 @@ MapArchObjectParser<A> newMapArchObjectParser(); /** - * Create a new game object parser instance. - * @return The new game object parser instance. - */ - GameObjectParser<G, A, R> newGameObjectParser(); - - /** * Creates a new map view instance for a map control. * @param mapControl the map control * @param viewPosition the initiali view position; may be <code>null</code> Added: trunk/src/app/net/sf/gridarta/gameobject/GameObjectFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObjectFactory.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObjectFactory.java 2008-09-13 12:26:36 UTC (rev 5123) @@ -0,0 +1,38 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gameobject; + +import net.sf.gridarta.map.MapArchObject; +import org.jetbrains.annotations.NotNull; + +/** + * Abstract factory for creating {@link GameObject} instances. + * @author Andreas Kirschbaum + */ +public interface GameObjectFactory<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { + + /** + * Creates a new {@link GameObject} instance. + * @return the new game object + */ + @NotNull + G newGameObject(); + +} // interface GameObjectFactory Property changes on: trunk/src/app/net/sf/gridarta/gameobject/GameObjectFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java 2008-09-13 11:51:51 UTC (rev 5122) +++ trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java 2008-09-13 12:26:36 UTC (rev 5123) @@ -28,10 +28,10 @@ import java.util.Set; import java.util.TreeSet; import net.sf.gridarta.EditTypes; -import net.sf.gridarta.GridartaObjectsFactory; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gameobject.GameObjectFactory; import net.sf.gridarta.map.MapArchObject; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; @@ -53,17 +53,19 @@ /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); - /** The gridarta objects factory for creating new game object instances. */ + /** + * The game object factory for creating new game object instances. + */ @NotNull - private final GridartaObjectsFactory<G, A, R, ?> gridartaObjectsFactory; + private final GameObjectFactory<G, A, R> gameObjectFactory; /** * Create a new instance. - * @param gridartaObjectsFactory The gridarta objects factory for creating - * new game object instances. + * @param gameObjectFactory the game object factory for creating new game + * object instances */ - protected AbstractGameObjectParser(@NotNull final GridartaObjectsFactory<G, A, R, ?> gridartaObjectsFactory) { - this.gridartaObjectsFactory = gridartaObjectsFactory; + protected AbstractGameObjectParser(@NotNull final GameObjectFactory<G, A, R> gameObjectFactory) { + this.gameObjectFactory = gameObjectFactory; } /** {@inheritDoc} */ @@ -89,7 +91,7 @@ return null; } - final G gameObject = gridartaObjectsFactory.newGameObject(); + final G gameObject = gameObjectFactory.newGameObject(); gameObject.setArchetypeName(archName); boolean msgflag = false; Modified: trunk/src/app/net/sf/gridarta/io/DefaultMapReader.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/DefaultMapReader.java 2008-09-13 11:51:51 UTC (rev 5122) +++ trunk/src/app/net/sf/gridarta/io/DefaultMapReader.java 2008-09-13 12:26:36 UTC (rev 5123) @@ -53,6 +53,12 @@ private final GridartaObjectsFactory<G, A, R, ?> gridartaObjectsFactory; /** + * The game object parser instance. + */ + @NotNull + private final GameObjectParser<G, A, R> gameObjectParser; + + /** * The component for showing dialog boxes. */ @NotNull @@ -99,14 +105,16 @@ /** * Open a file for reading it as a map. * @param gridartaObjectsFactory the objects factory instance + * @param gameObjectParser the game object parser instance * @param parent the parent component for showing dialog boxes * @param archetypeSet the archetype set * @param editTypes the edit types instance * @param file File to open. * @throws FileNotFoundException in case the file was not found. */ - public DefaultMapReader(@NotNull final GridartaObjectsFactory<G, A, R, ?> gridartaObjectsFactory, @NotNull final Component parent, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final EditTypes<G, A, R, ?> editTypes, @NotNull final File file) throws FileNotFoundException { + public DefaultMapReader(@NotNull final GridartaObjectsFactory<G, A, R, ?> gridartaObjectsFactory, @NotNull final GameObjectParser<G, A, R> gameObjectParser, @NotNull final Component parent, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final EditTypes<G, A, R, ?> editTypes, @NotNull final File file) throws FileNotFoundException { this.gridartaObjectsFactory = gridartaObjectsFactory; + this.gameObjectParser = gameObjectParser; this.parent = parent; this.archetypeSet = archetypeSet; this.editTypes = editTypes; @@ -147,7 +155,6 @@ mapArchObject = gridartaObjectsFactory.newMapArchObject(false); gridartaObjectsFactory.newMapArchObjectParser().load(myInput, mapArchObject); - final GameObjectParser<G, A, R> gameObjectParser = gridartaObjectsFactory.newGameObjectParser(); while (gameObjectParser.load(myInput, objects) != null) { } Modified: trunk/src/app/net/sf/gridarta/io/DefaultMapWriter.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/DefaultMapWriter.java 2008-09-13 11:51:51 UTC (rev 5122) +++ trunk/src/app/net/sf/gridarta/io/DefaultMapWriter.java 2008-09-13 12:26:36 UTC (rev 5123) @@ -48,6 +48,12 @@ @NotNull private final GridartaObjectsFactory<G, A, R, ?> gridartaObjectsFactory; + /** + * The game object parser instance. + */ + @NotNull + private final GameObjectParser<G, A, R> gameObjectParser; + /** The reader to read from. */ private final OutputStreamWriter myOutput; @@ -58,8 +64,9 @@ * @throws FileNotFoundException in case the file couldn't be opened for * writing */ - public DefaultMapWriter(@NotNull final GridartaObjectsFactory<G, A, R, ?> gridartaObjectsFactory, @NotNull final File file) throws FileNotFoundException { + public DefaultMapWriter(@NotNull final GridartaObjectsFactory<G, A, R, ?> gridartaObjectsFactory, @NotNull final GameObjectParser<G, A, R> gameObjectParser, @NotNull final File file) throws FileNotFoundException { this.gridartaObjectsFactory = gridartaObjectsFactory; + this.gameObjectParser = gameObjectParser; ... [truncated message content] |