From: <aki...@us...> - 2008-08-19 23:50:13
|
Revision: 4909 http://gridarta.svn.sourceforge.net/gridarta/?rev=4909&view=rev Author: akirschbaum Date: 2008-08-19 23:50:18 +0000 (Tue, 19 Aug 2008) Log Message: ----------- Split off MapControlFactory from GridartaObjectsFactory. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Pickmap.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Added Paths: ----------- trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java trunk/src/app/net/sf/gridarta/map/AbstractMapControlFactory.java trunk/src/app/net/sf/gridarta/map/MapControlFactory.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-19 05:15:57 UTC (rev 4908) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-19 23:50:18 UTC (rev 4909) @@ -325,7 +325,7 @@ mapActions.updateMenuState(); scriptControl.getView().setMenu((JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "plugins")); final ArchetypeParser archetypeParser = new ArchetypeParser(gridartaObjectsFactory, archetypeChooserControl, animationObjects, archetypeSet); - gridartaObjectsFactory.init(faceObjects, archetypeChooserModel, selectedSquareView, this, mainView, editTypes, mapImageCache, mapActions, archetypeParser, archetypeSet, toolPalette); + gridartaObjectsFactory.init(faceObjects, archetypeChooserModel, selectedSquareView, this, mainView, editTypes, mapImageCache, mapActions, archetypeParser, archetypeSet, toolPalette, autojoinLists, exitMatcher); archetypeSet.loadArchetypes(archetypeParser); if (globalSettings.isAutoPopupDocu()) { Modified: trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-08-19 05:15:57 UTC (rev 4908) +++ trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-08-19 23:50:18 UTC (rev 4909) @@ -26,6 +26,7 @@ import cfeditor.gui.map.SimpleLevelRenderer; import cfeditor.io.GameObjectParser; import cfeditor.io.MapArchObjectParser; +import cfeditor.map.DefaultMapControlFactory; import cfeditor.map.MapArchObject; import java.awt.Component; import java.awt.Point; @@ -43,7 +44,7 @@ import net.sf.gridarta.gameobject.ArchetypeParser; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.face.FaceObjects; -import net.sf.gridarta.gameobject.match.GameObjectMatchersInstance; +import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.gui.map.LevelRenderer; @@ -52,8 +53,8 @@ import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.io.DefaultMapReader; import net.sf.gridarta.io.MapReader; -import net.sf.gridarta.map.DefaultMapControl; import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.map.MapControlFactory; import net.sf.gridarta.map.MapModel; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; @@ -71,10 +72,6 @@ /** Preferences. */ private static final Preferences prefs = Preferences.userNodeForPackage(MainControl.class); - /** The {@link ArchetypeChooserModel} instance to use. */ - @NotNull - private ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel = null; - /** The {@link SelectedSquareView} instance to use. */ @NotNull private SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView = null; @@ -91,10 +88,6 @@ @NotNull private MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache = null; - /** The {@link MapActions} instance to use. */ - @NotNull - private MapActions mapActions = null; - /** The {@link ArchetypeParser} instance to use. */ @NotNull private ArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser = null; @@ -110,6 +103,10 @@ @NotNull private ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette = null; + /** The map control factory instance. */ + @NotNull + private MapControlFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControlFactory = null; + /** {@inheritDoc} */ @NotNull public GameObject newGameObject() { @@ -151,13 +148,13 @@ /** {@inheritDoc} */ @NotNull public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @NotNull final Component parent, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists) { - return new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, parent, autojoinLists, mapImageCache, objects, mapArchObject, false, GameObjectMatchersInstance.getInstance().getMatcher("exit"), archetypeChooserModel, mapActions); + return mapControlFactory.newMapControl(this, parent, objects, mapArchObject); } /** {@inheritDoc} */ @NotNull - public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newPickmapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @NotNull final Component parent, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists) { - return new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, parent, autojoinLists, mapImageCache, objects, mapArchObject, true, GameObjectMatchersInstance.getInstance().getMatcher("exit"), archetypeChooserModel, mapActions); + public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newPickmapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @NotNull final Component parent, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final File file) { + return mapControlFactory.newPickmapControl(this, parent, objects, mapArchObject, file); } /** {@inheritDoc} */ @@ -173,16 +170,15 @@ } /** {@inheritDoc} */ - public void init(@NotNull final FaceObjects faceObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final MapActions mapActions, @NotNull final ArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette) { - this.archetypeChooserModel = archetypeChooserModel; + public void init(@NotNull final FaceObjects faceObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final MapActions mapActions, @NotNull final ArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final GameObjectMatcher exitTypeGameObjectMatcher) { this.selectedSquareView = selectedSquareView; this.mainView = mainView; this.editTypes = editTypes; this.mapImageCache = mapImageCache; - this.mapActions = mapActions; this.archetypeParser = archetypeParser; this.archetypeSet = archetypeSet; this.toolPalette = toolPalette; + mapControlFactory = new DefaultMapControlFactory(mapActions, archetypeChooserModel, mapImageCache, autojoinLists, exitTypeGameObjectMatcher); } public void setFilterControl(@NotNull final CFilterControl filterControl) { Added: trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java (rev 0) +++ trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java 2008-08-19 23:50:18 UTC (rev 4909) @@ -0,0 +1,109 @@ +/* + * 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.map; + +import cfeditor.gameobject.Archetype; +import cfeditor.gameobject.GameObject; +import cfeditor.gui.map.CMapViewBasic; +import java.awt.Component; +import java.io.File; +import java.util.List; +import net.sf.gridarta.AutojoinLists; +import net.sf.gridarta.GridartaObjectsFactory; +import net.sf.gridarta.MapActions; +import net.sf.gridarta.MapImageCache; +import net.sf.gridarta.gameobject.match.GameObjectMatcher; +import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; +import net.sf.gridarta.map.AbstractMapControlFactory; +import net.sf.gridarta.map.DefaultMapControl; +import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.map.MapControlFactory; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * A {@link MapControlFactory} to create Crossfire instance. + * @author Andreas Kirschbaum + */ +public class DefaultMapControlFactory extends AbstractMapControlFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> { + + /** + * The {@link MapActions} instance to use. + */ + @NotNull + private final MapActions mapActions; + + /** + * The {@link ArchetypeChooserModel} instance to use. + */ + @NotNull + private final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel; + + /** + * The {@link MapImageCache} instance to use. + */ + @NotNull + private final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache; + + /** + * The {@link AutojoinLists} instacne to use. + */ + @NotNull + private final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists; + + /** + * The matcher for exit objects. + */ + @NotNull + private final GameObjectMatcher exitTypeGameObjectMatcher; + + /** + * Creates a new instance. + * @param mapActions the map actions to use + * @param archetypeChooserModel the archetype chooser model to use + * @param mapImageCache the map image cache to use + * @param autojoinLists the autojoin lists to use + * @param exitTypeGameObjectMatcher the matcher for exit objects + */ + public DefaultMapControlFactory(@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.mapActions = mapActions; + this.archetypeChooserModel = archetypeChooserModel; + this.mapImageCache = mapImageCache; + this.autojoinLists = autojoinLists; + this.exitTypeGameObjectMatcher = exitTypeGameObjectMatcher; + } + + /** {@inheritDoc} */ + @NotNull + public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControl(@NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final Component parent, @Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject) { + return new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(gridartaObjectsFactory, parent, autojoinLists, mapImageCache, objects, mapArchObject, false, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); + } + + /** {@inheritDoc} */ + @NotNull + public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newPickmapControl(@NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @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, parent, autojoinLists, mapImageCache, objects, mapArchObject, true, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); + mapControl.setMapFile(file); + mapControl.setMapFileName(file.getPath()); + mapControl.resetModified(); + return mapControl; + } + +} // class DefaultMapControlFactory Property changes on: trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-08-19 05:15:57 UTC (rev 4908) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-08-19 23:50:18 UTC (rev 4909) @@ -377,7 +377,7 @@ mainView.init(gameObjectAttributesControl, selectedSquareView, archetypeTypeSet, mapTileListBottom, gameObjectMatchers, archetypeChooserControl, pickmapChooserControl, objectChooser, leftPanel); mapActions.updateMenuState(); final ArchetypeParser archetypeParser = new ArchetypeParser(archetypeChooserControl, animationObjects, archetypeSet); - gridartaObjectsFactory.init(faceObjects, archetypeChooserModel, selectedSquareView, this, mainView, editTypes, mapImageCache, mapActions, archetypeParser, archetypeSet, toolPalette); + gridartaObjectsFactory.init(faceObjects, archetypeChooserModel, selectedSquareView, this, mainView, editTypes, mapImageCache, mapActions, archetypeParser, archetypeSet, toolPalette, autojoinLists, exitMatcher); archetypeSet.loadArchetypes(archetypeParser); if (globalSettings.isAutoPopupDocu()) { Modified: trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java =================================================================== --- trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java 2008-08-19 05:15:57 UTC (rev 4908) +++ trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java 2008-08-19 23:50:18 UTC (rev 4909) @@ -26,6 +26,7 @@ import daieditor.gui.map.SimpleLevelRenderer; import daieditor.io.GameObjectParser; import daieditor.io.MapArchObjectParser; +import daieditor.map.DefaultMapControlFactory; import daieditor.map.MapArchObject; import java.awt.Component; import java.awt.Point; @@ -43,7 +44,7 @@ import net.sf.gridarta.gameobject.ArchetypeParser; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.face.FaceObjects; -import net.sf.gridarta.gameobject.match.GameObjectMatchersInstance; +import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.gui.map.LevelRenderer; @@ -52,8 +53,8 @@ import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.io.DefaultMapReader; import net.sf.gridarta.io.MapReader; -import net.sf.gridarta.map.DefaultMapControl; import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.map.MapControlFactory; import net.sf.gridarta.map.MapModel; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; @@ -74,10 +75,6 @@ /** The {@link FaceObjects} instance to use. */ private FaceObjects faceObjects = null; - /** The {@link ArchetypeChooserModel} instance to use. */ - @NotNull - private ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel = null; - /** The {@link SelectedSquareView} instance to use. */ @NotNull private SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView = null; @@ -98,10 +95,6 @@ @NotNull private MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache = null; - /** The {@link MapActions} instance to use. */ - @NotNull - private MapActions mapActions = null; - /** The {@link ArchetypeParser} instance to use. */ @NotNull private ArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser = null; @@ -114,6 +107,10 @@ @NotNull private ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette = null; + /** The map control factory instance. */ + @NotNull + private MapControlFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControlFactory = null; + /** {@inheritDoc} */ @NotNull public GameObject newGameObject() { @@ -155,15 +152,13 @@ /** {@inheritDoc} */ @NotNull public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @NotNull final Component parent, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists) { - return new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, parent, autojoinLists, mapImageCache, objects, mapArchObject, false, GameObjectMatchersInstance.getInstance().getMatcher("exit"), archetypeChooserModel, mapActions); + return mapControlFactory.newMapControl(this, parent, objects, mapArchObject); } /** {@inheritDoc} */ @NotNull - public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newPickmapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @NotNull final Component parent, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists) { - final DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, parent, autojoinLists, mapImageCache, objects, mapArchObject, true, GameObjectMatchersInstance.getInstance().getMatcher("exit"), archetypeChooserModel, mapActions); - mapArchObject.setDifficulty(1); - return mapControl; + public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newPickmapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @NotNull final Component parent, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final File file) { + return mapControlFactory.newPickmapControl(this, parent, objects, mapArchObject, file); } /** {@inheritDoc} */ @@ -179,18 +174,17 @@ } /** {@inheritDoc} */ - public void init(@NotNull final FaceObjects faceObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final MapActions mapActions, @NotNull final ArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette) { + public void init(@NotNull final FaceObjects faceObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final MapActions mapActions, @NotNull final ArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final GameObjectMatcher exitTypeGameObjectMatcher) { this.faceObjects = faceObjects; - this.archetypeChooserModel = archetypeChooserModel; this.selectedSquareView = selectedSquareView; this.mainControl = mainControl; this.mainView = mainView; this.editTypes = editTypes; this.mapImageCache = mapImageCache; - this.mapActions = mapActions; this.archetypeParser = archetypeParser; this.archetypeSet = archetypeSet; this.toolPalette = toolPalette; + mapControlFactory = new DefaultMapControlFactory(mapActions, archetypeChooserModel, mapImageCache, autojoinLists, exitTypeGameObjectMatcher); } } // class DaimoninObjectsFactory Added: trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java (rev 0) +++ trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java 2008-08-19 23:50:18 UTC (rev 4909) @@ -0,0 +1,110 @@ +/* + * 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.map; + +import daieditor.gameobject.Archetype; +import daieditor.gameobject.GameObject; +import daieditor.gui.map.CMapViewBasic; +import java.awt.Component; +import java.io.File; +import java.util.List; +import net.sf.gridarta.AutojoinLists; +import net.sf.gridarta.GridartaObjectsFactory; +import net.sf.gridarta.MapActions; +import net.sf.gridarta.MapImageCache; +import net.sf.gridarta.gameobject.match.GameObjectMatcher; +import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; +import net.sf.gridarta.map.AbstractMapControlFactory; +import net.sf.gridarta.map.DefaultMapControl; +import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.map.MapControlFactory; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * A {@link MapControlFactory} to create Crossfire instance. + * @author Andreas Kirschbaum + */ +public class DefaultMapControlFactory extends AbstractMapControlFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> { + + /** + * The {@link MapActions} instance to use. + */ + @NotNull + private final MapActions mapActions; + + /** + * The {@link ArchetypeChooserModel} instance to use. + */ + @NotNull + private final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel; + + /** + * The {@link MapImageCache} instance to use. + */ + @NotNull + private final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache; + + /** + * The {@link AutojoinLists} instacne to use. + */ + @NotNull + private final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists; + + /** + * The matcher for exit objects. + */ + @NotNull + private final GameObjectMatcher exitTypeGameObjectMatcher; + + /** + * Creates a new instance. + * @param mapActions the map actions to use + * @param archetypeChooserModel the archetype chooser model to use + * @param mapImageCache the map image cache to use + * @param autojoinLists the autojoin lists to use + * @param exitTypeGameObjectMatcher the matcher for exit objects + */ + public DefaultMapControlFactory(@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.mapActions = mapActions; + this.archetypeChooserModel = archetypeChooserModel; + this.mapImageCache = mapImageCache; + this.autojoinLists = autojoinLists; + this.exitTypeGameObjectMatcher = exitTypeGameObjectMatcher; + } + + /** {@inheritDoc} */ + @NotNull + public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControl(@NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final Component parent, @Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject) { + return new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(gridartaObjectsFactory, parent, autojoinLists, mapImageCache, objects, mapArchObject, false, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); + } + + /** {@inheritDoc} */ + @NotNull + public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newPickmapControl(@NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @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, parent, autojoinLists, mapImageCache, objects, mapArchObject, true, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); + mapControl.setMapFile(file); + mapControl.setMapFileName(file.getPath()); + mapControl.resetModified(); + return mapControl; + } + +} // class DefaultMapControlFactory Property changes on: trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java 2008-08-19 05:15:57 UTC (rev 4908) +++ trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java 2008-08-19 23:50:18 UTC (rev 4909) @@ -29,6 +29,7 @@ import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gameobject.face.FaceObjects; +import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.gui.map.LevelRenderer; @@ -113,10 +114,11 @@ * @param mapArchObject The map arch object to use for the new pickmap. * @param parent the parent component for error messages * @param autojoinLists the autojoin lists + * @param file the associated file * @return The new pickmap map control instance. */ @NotNull - MapControl<G, A, R, V> newPickmapControl(@Nullable List<G> objects, @NotNull A mapArchObject, @NotNull Component parent, @NotNull AutojoinLists<G, A, R> autojoinLists); + MapControl<G, A, R, V> newPickmapControl(@Nullable List<G> objects, @NotNull A mapArchObject, @NotNull Component parent, @NotNull AutojoinLists<G, A, R> autojoinLists, @NotNull File file); /** * Create a new level renderer instance. @@ -150,7 +152,9 @@ * @param archetypeParser the archetype parser instance * @param archetypeSet the archetype set instance * @param toolPalette the tool palette instance + * @param autojoinLists the autojoin lists instance + * @param exitTypeGameObjectMatcher the matcher for exit objects */ - void init(@NotNull FaceObjects faceObjects, @NotNull ArchetypeChooserModel<G, A, R, V> archetypeChooserModel, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull MainControl<G, A, R, V> mainControl, @NotNull MainView<G, A, R, V> mainView, @NotNull EditTypes<G, A, R, V> editTypes, @NotNull MapImageCache<G, A, R, V> mapImageCache, @NotNull MapActions mapActions, @NotNull ArchetypeParser<G, A, R> archetypeParser, @NotNull ArchetypeSet<G, A, R> archetypeSet, @NotNull ToolPalette<G, A, R, V> toolPalette); + void init(@NotNull FaceObjects faceObjects, @NotNull ArchetypeChooserModel<G, A, R, V> archetypeChooserModel, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull MainControl<G, A, R, V> mainControl, @NotNull MainView<G, A, R, V> mainView, @NotNull EditTypes<G, A, R, V> editTypes, @NotNull MapImageCache<G, A, R, V> mapImageCache, @NotNull MapActions mapActions, @NotNull ArchetypeParser<G, A, R> archetypeParser, @NotNull ArchetypeSet<G, A, R> archetypeSet, @NotNull ToolPalette<G, A, R, V> toolPalette, @NotNull final AutojoinLists<G, A, R> autojoinLists, @NotNull final GameObjectMatcher exitTypeGameObjectMatcher); } // interface GridartaObjectsFactory Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Pickmap.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Pickmap.java 2008-08-19 05:15:57 UTC (rev 4908) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Pickmap.java 2008-08-19 23:50:18 UTC (rev 4909) @@ -160,10 +160,7 @@ decoder.close(); } - pickmap = gridartaObjectsFactory.newPickmapControl(decoder.getGameObjects(), decoder.getMapArchObject(), parent, autojoinLists); - pickmap.setMapFile(file); - pickmap.setMapFileName(file.getPath()); - pickmap.resetModified(); + pickmap = gridartaObjectsFactory.newPickmapControl(decoder.getGameObjects(), decoder.getMapArchObject(), parent, autojoinLists, file); pickmapView = pickmap.createView(null); } Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2008-08-19 05:15:57 UTC (rev 4908) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2008-08-19 23:50:18 UTC (rev 4909) @@ -269,10 +269,7 @@ } } - final MapControl<G, A, R, V> mapControl = gridartaObjectsFactory.newPickmapControl(null, mapArchObject, mainControl.getMainView(), autojoinLists); - mapControl.setMapFile(mapFile); - mapControl.setMapFileName(mapFile.getPath()); - mapControl.resetModified(); + final MapControl<G, A, R, V> mapControl = gridartaObjectsFactory.newPickmapControl(null, mapArchObject, mainControl.getMainView(), autojoinLists, mapFile); mapControl.save(); final Pickmap<G, A, R, V> pickmap; Added: trunk/src/app/net/sf/gridarta/map/AbstractMapControlFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapControlFactory.java (rev 0) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapControlFactory.java 2008-08-19 23:50:18 UTC (rev 4909) @@ -0,0 +1,32 @@ +/* + * 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.map; + +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.map.MapViewBasic; + +/** + * Abstract base class of {@link MapControlFactory} classes. + * @author Andreas Kirschbaum + */ +public abstract class AbstractMapControlFactory<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> implements MapControlFactory<G, A, R, V> { + +} // class AbstractMapControlFactory Property changes on: trunk/src/app/net/sf/gridarta/map/AbstractMapControlFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/map/MapControlFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapControlFactory.java (rev 0) +++ trunk/src/app/net/sf/gridarta/map/MapControlFactory.java 2008-08-19 23:50:18 UTC (rev 4909) @@ -0,0 +1,61 @@ +/* + * 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.map; + +import java.awt.Component; +import java.io.File; +import java.util.List; +import net.sf.gridarta.GridartaObjectsFactory; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.map.MapViewBasic; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Factory for creating {@link MapControl} instances. + * @author Andreas Kirschbaum + */ +public interface MapControlFactory<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> { + + /** + * Create a new map control instance. + * @param gridartaObjectsFactory the gridarta objects factory + * @param parent the parent component for error messages + * @param objects the objects to insert into the new map + * @param mapArchObject the map arch object to use for the new map + * @return the new map control instance + */ + @NotNull + MapControl<G, A, R, V> newMapControl(@NotNull GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull Component parent, @Nullable final List<G> objects, @NotNull A mapArchObject); + + /** + * Create a new pickmap map control instance. + * @param gridartaObjectsFactory the gridarta objects factory + * @param parent the parent component for error messages + * @param objects the objects to insert into the new pickmap + * @param mapArchObject the map arch object to use for the new pickmap + * @param file the associated file + * @return the new pickmap map control instance + */ + @NotNull + MapControl<G, A, R, V> newPickmapControl(@NotNull GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull Component parent, @Nullable List<G> objects, @NotNull A mapArchObject, @NotNull File file); + +} // interface MapControlFactory Property changes on: trunk/src/app/net/sf/gridarta/map/MapControlFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-08-19 05:15:57 UTC (rev 4908) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-08-19 23:50:18 UTC (rev 4909) @@ -881,7 +881,7 @@ /** {@inheritDoc} */ @NotNull - public MapControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> newPickmapControl(@Nullable final List<TestGameObject> objects, @NotNull final TestMapArchObject mapArchObject, @NotNull final Component parent, @NotNull final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists) { + public MapControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> newPickmapControl(@Nullable final List<TestGameObject> objects, @NotNull final TestMapArchObject mapArchObject, @NotNull final Component parent, @NotNull final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists, @NotNull final File file) { throw new AssertionError(); } @@ -898,7 +898,7 @@ } /** {@inheritDoc} */ - public void init(@NotNull final FaceObjects faceObjects, @NotNull final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> archetypeChooserModel, @NotNull final SelectedSquareView<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> selectedSquareView, @NotNull final MainControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mainControl, @NotNull final MainView<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mainView, @NotNull final EditTypes<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> editTypes, @NotNull final MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapImageCache, @NotNull final MapActions mapActions, @NotNull final ArchetypeParser<TestGameObject, TestMapArchObject, TestArchetype> archetypeParser, @NotNull final ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeSet, @NotNull final ToolPalette<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> toolPalette) { + public void init(@NotNull final FaceObjects faceObjects, @NotNull final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> archetypeChooserModel, @NotNull final SelectedSquareView<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> selectedSquareView, @NotNull final MainControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mainControl, @NotNull final MainView<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mainView, @NotNull final EditTypes<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> editTypes, @NotNull final MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapImageCache, @NotNull final MapActions mapActions, @NotNull final ArchetypeParser<TestGameObject, TestMapArchObject, TestArchetype> archetypeParser, @NotNull final ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeSet, @NotNull final ToolPalette<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> toolPalette, @NotNull final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists, @NotNull final GameObjectMatcher exitTypeGameObjectMatcher) { throw new AssertionError(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |