From: <aki...@us...> - 2008-10-12 17:24:17
|
Revision: 5507 http://gridarta.svn.sourceforge.net/gridarta/?rev=5507&view=rev Author: akirschbaum Date: 2008-10-12 17:24:12 +0000 (Sun, 12 Oct 2008) Log Message: ----------- Remove FaceObjects.writeTreeFileLine(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java Modified: trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-10-12 17:19:18 UTC (rev 5506) +++ trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-10-12 17:24:12 UTC (rev 5507) @@ -20,11 +20,8 @@ package cfeditor.gameobject.face; import cfeditor.IGUIConstants; -import java.io.BufferedWriter; -import java.io.IOException; import java.util.regex.Pattern; import net.sf.gridarta.gameobject.face.AbstractFaceObjects; -import org.jetbrains.annotations.NotNull; /** * This class manages the FaceObjects. @@ -36,13 +33,7 @@ * Creates a new instance. */ public FaceObjects() { - super(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^(?:\\\\[0-9]+\t\\.?)?(.*)")); + super(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^(?:\\\\[0-9]+\t\\.?)?(.*)"), "\\%05d\t.%s\n"); } - /** {@inheritDoc} */ - @Override - protected void writeTreeFileLine(@NotNull final BufferedWriter treeFile, final int faceNo, @NotNull final String faceName) throws IOException { - treeFile.append(String.format("\\%05d\t.%s\n", faceNo, faceName)); - } - } // class FaceObjects Modified: trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-10-12 17:19:18 UTC (rev 5506) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-10-12 17:24:12 UTC (rev 5507) @@ -20,11 +20,8 @@ package daieditor.gameobject.face; import daieditor.IGUIConstants; -import java.io.BufferedWriter; -import java.io.IOException; import java.util.regex.Pattern; import net.sf.gridarta.gameobject.face.AbstractFaceObjects; -import org.jetbrains.annotations.NotNull; /** * This class manages the FaceObjects. @@ -36,13 +33,7 @@ * Creates a new instance. */ public FaceObjects() { - super(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^(.*)")); + super(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^(.*)"), "%s"); } - /** {@inheritDoc} */ - @Override - protected void writeTreeFileLine(@NotNull final BufferedWriter treeFile, final int faceNo, @NotNull final String faceName) throws IOException { - treeFile.append(faceName).append('\n'); - } - } // class FaceObjects Modified: trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2008-10-12 17:19:18 UTC (rev 5506) +++ trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2008-10-12 17:24:12 UTC (rev 5507) @@ -95,16 +95,25 @@ private final Pattern faceTreeInputPattern; /** + * The format string for writing face tree files. + */ + @NotNull + private final String faceTreeOutputFormat; + + /** * Creates a new instance. * @param pngFile the filename of the collected image file * @param faceTreeFile the filename of the face tree file * @param faceTreeInputPattern the pattern for parsing face tree files + * @param faceTreeOutputFormat the format string for writing face tree + * files */ - protected AbstractFaceObjects(@NotNull final String pngFile, @NotNull final String faceTreeFile, @NotNull final Pattern faceTreeInputPattern) { + protected AbstractFaceObjects(@NotNull final String pngFile, @NotNull final String faceTreeFile, @NotNull final Pattern faceTreeInputPattern, @NotNull final String faceTreeOutputFormat) { super(ACTION_FACTORY.getString("nameOfFaceObject")); this.pngFile = pngFile; this.faceTreeFile = faceTreeFile; this.faceTreeInputPattern = faceTreeInputPattern; + this.faceTreeOutputFormat = faceTreeOutputFormat; } /** @@ -195,7 +204,7 @@ assert path.startsWith(baseDir.getAbsolutePath()); assert path.endsWith(".png"); final String name = path.substring(stripPath, path.length() - 4).replace('\\', '/'); - writeTreeFileLine(treeFile, i, name); + treeFile.append(String.format(faceTreeOutputFormat, i, name)).append('\n'); if (i++ % 100 == 0) { progress.setValue(i); } @@ -242,15 +251,6 @@ } /** - * Writes one line to the face tree file. - * @param treeFile the face tree file to write - * @param faceNo the face number - * @param faceName the face name - * @throws IOException if writing fails - */ - protected abstract void writeTreeFileLine(@NotNull final BufferedWriter treeFile, final int faceNo, @NotNull final String faceName) throws IOException; - - /** * Returns a file that is a regular file on the file system. Returns the * passed file if it is a regular file. Otherwise copies the passed file * into a temporary regular file and returns the copy. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-12 18:06:10
|
Revision: 5508 http://gridarta.svn.sourceforge.net/gridarta/?rev=5508&view=rev Author: akirschbaum Date: 2008-10-12 18:05:59 +0000 (Sun, 12 Oct 2008) Log Message: ----------- Remove cfeditor/daieditor's FaceObjects classes. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gui/map/DefaultMapViewFactory.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gui/map/DefaultMapViewFactory.java trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java Removed Paths: ------------- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-10-12 17:24:12 UTC (rev 5507) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-10-12 18:05:59 UTC (rev 5508) @@ -27,7 +27,6 @@ import cfeditor.gameobject.DefaultGameObjectFactory; import cfeditor.gameobject.GameObject; import cfeditor.gameobject.anim.AnimationObjects; -import cfeditor.gameobject.face.FaceObjects; import cfeditor.gameobject.scripts.ScriptArchUtils; import cfeditor.gui.map.CMapViewBasic; import cfeditor.gui.map.DefaultMapPropertiesDialogFactory; @@ -42,6 +41,7 @@ import java.io.File; import java.util.List; import java.util.Map; +import java.util.regex.Pattern; import javax.swing.JComboBox; import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.CommonConstants; @@ -55,6 +55,8 @@ import net.sf.gridarta.gameobject.ArchetypeFactory; import net.sf.gridarta.gameobject.GameObjectFactory; import net.sf.gridarta.gameobject.anim.AnimationObject; +import net.sf.gridarta.gameobject.face.AbstractFaceObjects; +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.MapViewManager; @@ -119,7 +121,7 @@ * @throws RuntimeException If the controller cannot be initialized. */ public CMainControl() { - super(new DefaultRendererFactory(), "cfeditor", new GlobalSettingsImpl(), new AnimationObjects(), new FaceObjects(), false, ConfigFileUtils.getHomeFile("thumbnails"), null, "CrossfireEditor.jar", pythonFileFilter, ".py", "Python", Archetype.TYPE_SPELL, null, Archetype.TYPE_EVENT_CONNECTOR, false, 0, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SCRIPTS_DIR); + super(new DefaultRendererFactory(), "cfeditor", new GlobalSettingsImpl(), new AnimationObjects(), new AbstractFaceObjects(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^(.*)"), "%s"), false, ConfigFileUtils.getHomeFile("thumbnails"), null, "CrossfireEditor.jar", pythonFileFilter, ".py", "Python", Archetype.TYPE_SPELL, null, Archetype.TYPE_EVENT_CONNECTOR, false, 0, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SCRIPTS_DIR); } /** {@inheritDoc} */ @@ -132,8 +134,8 @@ /** {@inheritDoc} */ @NotNull @Override - protected MapViewFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapViewFactory(@NotNull final net.sf.gridarta.gameobject.face.FaceObjects faceObjects, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final AbstractMainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final EditTypes editTypes, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, @NotNull final FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl) { - return new DefaultMapViewFactory((FaceObjects) faceObjects, selectedSquareView, mainControl, mainView, editTypes, mapImageCache, toolPalette, filterControl); + protected MapViewFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapViewFactory(@NotNull final FaceObjects faceObjects, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final AbstractMainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final EditTypes editTypes, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, @NotNull final FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl) { + return new DefaultMapViewFactory(faceObjects, selectedSquareView, mainControl, mainView, editTypes, mapImageCache, toolPalette, filterControl); } /** {@inheritDoc} */ @@ -242,7 +244,7 @@ /** {@inheritDoc} */ @Override - protected void init4(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes 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, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { + protected void init4(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final net.sf.gridarta.gameobject.anim.AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { new ArchetypeSetLoader(globalSettings, gameObjectParser, globalSettings.getCollectedDirectory(), globalSettings.getConfigurationDirectory(), archetypeSet, archetypeParser, editTypes, faceObjects, animationObjects, this).loadArchetypes(mainView); } Deleted: trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-10-12 17:24:12 UTC (rev 5507) +++ trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-10-12 18:05:59 UTC (rev 5508) @@ -1,39 +0,0 @@ -/* - * 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.face; - -import cfeditor.IGUIConstants; -import java.util.regex.Pattern; -import net.sf.gridarta.gameobject.face.AbstractFaceObjects; - -/** - * This class manages the FaceObjects. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public final class FaceObjects extends AbstractFaceObjects { - - /** - * Creates a new instance. - */ - public FaceObjects() { - super(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^(?:\\\\[0-9]+\t\\.?)?(.*)"), "\\%05d\t.%s\n"); - } - -} // class FaceObjects Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultMapViewFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultMapViewFactory.java 2008-10-12 17:24:12 UTC (rev 5507) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultMapViewFactory.java 2008-10-12 18:05:59 UTC (rev 5508) @@ -21,13 +21,13 @@ import cfeditor.gameobject.Archetype; import cfeditor.gameobject.GameObject; -import cfeditor.gameobject.face.FaceObjects; import cfeditor.map.MapArchObject; import java.awt.Point; import net.sf.gridarta.EditTypes; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapImageCache; import net.sf.gridarta.filter.FilterControl; +import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewFactory; Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-10-12 17:24:12 UTC (rev 5507) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-10-12 18:05:59 UTC (rev 5508) @@ -27,7 +27,6 @@ import daieditor.gameobject.DefaultGameObjectFactory; import daieditor.gameobject.GameObject; import daieditor.gameobject.anim.AnimationObjects; -import daieditor.gameobject.face.FaceObjects; import daieditor.gameobject.scripts.ScriptArchUtils; import daieditor.gui.map.CMapViewBasic; import daieditor.gui.map.DefaultMapPropertiesDialogFactory; @@ -46,6 +45,7 @@ import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.regex.Pattern; import javax.swing.JComboBox; import javax.swing.JOptionPane; import net.sf.gridarta.AbstractMainControl; @@ -60,7 +60,9 @@ import net.sf.gridarta.gameobject.ArchetypeFactory; import net.sf.gridarta.gameobject.GameObjectFactory; import net.sf.gridarta.gameobject.anim.AnimationObject; +import net.sf.gridarta.gameobject.face.AbstractFaceObjects; import net.sf.gridarta.gameobject.face.FaceObjectProviders; +import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gameobject.match.MutableOrGameObjectMatcher; import net.sf.gridarta.gameobject.match.ViewGameObjectMatcherManager; @@ -165,7 +167,7 @@ * @throws RuntimeException If the controller cannot be initialized. */ public CMainControl() { - super(new DefaultRendererFactory(), "daieditor", new GlobalSettingsImpl(), new AnimationObjects(), new FaceObjects(), true, null, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", luaFileFilter, ".lua", "Lua", 0, IGUIConstants.SPELL_FILE, 0, true, -1, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SCRIPTS_DIR); + super(new DefaultRendererFactory(), "daieditor", new GlobalSettingsImpl(), new AnimationObjects(), new AbstractFaceObjects(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^(.*)"), "%s"), true, null, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", luaFileFilter, ".lua", "Lua", 0, IGUIConstants.SPELL_FILE, 0, true, -1, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SCRIPTS_DIR); } /** {@inheritDoc} */ @@ -178,8 +180,8 @@ /** {@inheritDoc} */ @NotNull @Override - protected MapViewFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapViewFactory(@NotNull final net.sf.gridarta.gameobject.face.FaceObjects faceObjects, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final AbstractMainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final EditTypes editTypes, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, @NotNull final FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl) { - return new DefaultMapViewFactory((FaceObjects) faceObjects, selectedSquareView, mainControl, mainView, editTypes, mapImageCache, toolPalette, filterControl); + protected MapViewFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapViewFactory(@NotNull final FaceObjects faceObjects, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final AbstractMainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final EditTypes editTypes, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, @NotNull final FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl) { + return new DefaultMapViewFactory(faceObjects, selectedSquareView, mainControl, mainView, editTypes, mapImageCache, toolPalette, filterControl); } /** {@inheritDoc} */ @@ -290,7 +292,7 @@ /** {@inheritDoc} */ @Override - protected void init4(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes 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, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { + protected void init4(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final net.sf.gridarta.gameobject.anim.AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { MultiPositionData.init(globalSettings.getConfigurationDirectory()); new ArchetypeSetLoader(globalSettings, gameObjectParser, globalSettings.getCollectedDirectory(), globalSettings.getConfigurationDirectory(), archetypeSet, archetypeParser, editTypes, faceObjects, animationObjects, this).loadArchetypes(mainView); } Deleted: trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-10-12 17:24:12 UTC (rev 5507) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-10-12 18:05:59 UTC (rev 5508) @@ -1,39 +0,0 @@ -/* - * 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.face; - -import daieditor.IGUIConstants; -import java.util.regex.Pattern; -import net.sf.gridarta.gameobject.face.AbstractFaceObjects; - -/** - * This class manages the FaceObjects. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public final class FaceObjects extends AbstractFaceObjects { - - /** - * Creates a new instance. - */ - public FaceObjects() { - super(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^(.*)"), "%s"); - } - -} // class FaceObjects Modified: trunk/daimonin/src/daieditor/gui/map/DefaultMapViewFactory.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/DefaultMapViewFactory.java 2008-10-12 17:24:12 UTC (rev 5507) +++ trunk/daimonin/src/daieditor/gui/map/DefaultMapViewFactory.java 2008-10-12 18:05:59 UTC (rev 5508) @@ -23,13 +23,13 @@ import daieditor.IGUIConstants; import daieditor.gameobject.Archetype; import daieditor.gameobject.GameObject; -import daieditor.gameobject.face.FaceObjects; import daieditor.map.MapArchObject; import java.awt.Point; import net.sf.gridarta.EditTypes; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapImageCache; import net.sf.gridarta.filter.FilterControl; +import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewFactory; Modified: trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2008-10-12 17:24:12 UTC (rev 5507) +++ trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2008-10-12 18:05:59 UTC (rev 5508) @@ -52,7 +52,7 @@ * Abstract base implementation of {@link FaceObjects}. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public abstract class AbstractFaceObjects extends AbstractNamedObjects<FaceObject> implements FaceObjects { +public class AbstractFaceObjects extends AbstractNamedObjects<FaceObject> implements FaceObjects { /** The Logger for printing log messages. */ private static final Logger log = Logger.getLogger(AbstractFaceObjects.class); @@ -108,7 +108,7 @@ * @param faceTreeOutputFormat the format string for writing face tree * files */ - protected AbstractFaceObjects(@NotNull final String pngFile, @NotNull final String faceTreeFile, @NotNull final Pattern faceTreeInputPattern, @NotNull final String faceTreeOutputFormat) { + public AbstractFaceObjects(@NotNull final String pngFile, @NotNull final String faceTreeFile, @NotNull final Pattern faceTreeInputPattern, @NotNull final String faceTreeOutputFormat) { super(ACTION_FACTORY.getString("nameOfFaceObject")); this.pngFile = pngFile; this.faceTreeFile = faceTreeFile; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-12 18:31:34
|
Revision: 5509 http://gridarta.svn.sourceforge.net/gridarta/?rev=5509&view=rev Author: akirschbaum Date: 2008-10-12 18:31:28 +0000 (Sun, 12 Oct 2008) Log Message: ----------- Rename AbstractFaceObjects to DefaultFaceObjects since it is not abstract anymore. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/gameobject/face/FaceObjectProviders.java trunk/src/app/net/sf/gridarta/gui/SystemIcons.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gameobject/face/DefaultFaceObjects.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-10-12 18:05:59 UTC (rev 5508) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-10-12 18:31:28 UTC (rev 5509) @@ -55,7 +55,7 @@ import net.sf.gridarta.gameobject.ArchetypeFactory; import net.sf.gridarta.gameobject.GameObjectFactory; import net.sf.gridarta.gameobject.anim.AnimationObject; -import net.sf.gridarta.gameobject.face.AbstractFaceObjects; +import net.sf.gridarta.gameobject.face.DefaultFaceObjects; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.MainView; @@ -121,7 +121,7 @@ * @throws RuntimeException If the controller cannot be initialized. */ public CMainControl() { - super(new DefaultRendererFactory(), "cfeditor", new GlobalSettingsImpl(), new AnimationObjects(), new AbstractFaceObjects(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^(.*)"), "%s"), false, ConfigFileUtils.getHomeFile("thumbnails"), null, "CrossfireEditor.jar", pythonFileFilter, ".py", "Python", Archetype.TYPE_SPELL, null, Archetype.TYPE_EVENT_CONNECTOR, false, 0, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SCRIPTS_DIR); + super(new DefaultRendererFactory(), "cfeditor", new GlobalSettingsImpl(), new AnimationObjects(), new DefaultFaceObjects(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^(.*)"), "%s"), false, ConfigFileUtils.getHomeFile("thumbnails"), null, "CrossfireEditor.jar", pythonFileFilter, ".py", "Python", Archetype.TYPE_SPELL, null, Archetype.TYPE_EVENT_CONNECTOR, false, 0, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SCRIPTS_DIR); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-10-12 18:05:59 UTC (rev 5508) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-10-12 18:31:28 UTC (rev 5509) @@ -60,7 +60,7 @@ import net.sf.gridarta.gameobject.ArchetypeFactory; import net.sf.gridarta.gameobject.GameObjectFactory; import net.sf.gridarta.gameobject.anim.AnimationObject; -import net.sf.gridarta.gameobject.face.AbstractFaceObjects; +import net.sf.gridarta.gameobject.face.DefaultFaceObjects; import net.sf.gridarta.gameobject.face.FaceObjectProviders; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gameobject.match.GameObjectMatcher; @@ -167,7 +167,7 @@ * @throws RuntimeException If the controller cannot be initialized. */ public CMainControl() { - super(new DefaultRendererFactory(), "daieditor", new GlobalSettingsImpl(), new AnimationObjects(), new AbstractFaceObjects(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^(.*)"), "%s"), true, null, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", luaFileFilter, ".lua", "Lua", 0, IGUIConstants.SPELL_FILE, 0, true, -1, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SCRIPTS_DIR); + super(new DefaultRendererFactory(), "daieditor", new GlobalSettingsImpl(), new AnimationObjects(), new DefaultFaceObjects(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^(.*)"), "%s"), true, null, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", luaFileFilter, ".lua", "Lua", 0, IGUIConstants.SPELL_FILE, 0, true, -1, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SCRIPTS_DIR); } /** {@inheritDoc} */ Deleted: trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2008-10-12 18:05:59 UTC (rev 5508) +++ trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2008-10-12 18:31:28 UTC (rev 5509) @@ -1,392 +0,0 @@ -/* - * 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.face; - -import java.awt.image.ImageFilter; -import java.awt.image.RGBImageFilter; -import java.io.BufferedInputStream; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.io.PrintStream; -import java.io.PrintWriter; -import java.nio.channels.FileChannel; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import net.sf.gridarta.CommonConstants; -import net.sf.gridarta.data.AbstractNamedObjects; -import net.sf.gridarta.utils.ArrayUtils; -import net.sf.gridarta.utils.IOUtils; -import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.misc.Progress; -import org.apache.log4j.Logger; -import org.jetbrains.annotations.NotNull; - -/** - * Abstract base implementation of {@link FaceObjects}. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public class AbstractFaceObjects extends AbstractNamedObjects<FaceObject> implements FaceObjects { - - /** The Logger for printing log messages. */ - private static final Logger log = Logger.getLogger(AbstractFaceObjects.class); - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); - - /** Transparency filter to make transparent images. */ - public static final ImageFilter ALPHA_FILTER = new RGBImageFilter() { - - /** - * Converts a pixel by increasing the transparency. - * {@inheritDoc} - */ - @Override - public int filterRGB(final int x, final int y, final int rgb) { - // This is sufficient since alpha channel isn't used in the graphics this is required for. - return rgb >>> 24 == 0 ? rgb : rgb & 0x00FFFFFF | 0x80000000; - } - - }; // ALPHA_FILTER - - /** - * The filename of the collected image file. - */ - @NotNull - private final String pngFile; - - /** - * The filename of the face tree file. - */ - @NotNull - private final String faceTreeFile; - - /** - * The {@link Pattern} for parsing face tree files. The pattern must return - * the face name in the first capturing group. - */ - @NotNull - private final Pattern faceTreeInputPattern; - - /** - * The format string for writing face tree files. - */ - @NotNull - private final String faceTreeOutputFormat; - - /** - * Creates a new instance. - * @param pngFile the filename of the collected image file - * @param faceTreeFile the filename of the face tree file - * @param faceTreeInputPattern the pattern for parsing face tree files - * @param faceTreeOutputFormat the format string for writing face tree - * files - */ - public AbstractFaceObjects(@NotNull final String pngFile, @NotNull final String faceTreeFile, @NotNull final Pattern faceTreeInputPattern, @NotNull final String faceTreeOutputFormat) { - super(ACTION_FACTORY.getString("nameOfFaceObject")); - this.pngFile = pngFile; - this.faceTreeFile = faceTreeFile; - this.faceTreeInputPattern = faceTreeInputPattern; - this.faceTreeOutputFormat = faceTreeOutputFormat; - } - - /** - * {@inheritDoc} Collects the faces. The graphics information is written to - * "crossfire.0" resp. "daimonin.0". The meta information (offsets etc.) is - * written to "bmaps". The tree information for the editor is written to - * "bmaps.paths" resp. "facetree". - * <p/> - * Theoretically it would also be possible to recode the images. But the - * Java image encoder isn't as good as that of gimp in many cases (yet much - * better as the old visualtek's). - */ - public void collect(@NotNull final Progress progress, @NotNull final File dir, @NotNull final File baseDir) throws IOException { - collectTreeFile(progress, dir, baseDir); - collectBmapsFile(progress, dir); - collectImageFile(progress, dir); - } - - /** - * Creates the image file. - * @param progress Progress to report progress to. - * @param dir Destination directory to collect data to. - * @throws IOException in case of I/O problems during collection - */ - private void collectImageFile(@NotNull final Progress progress, @NotNull final File dir) throws IOException { - final File dfile = new File(dir, pngFile); - final FileOutputStream fout = new FileOutputStream(dfile); - //It's safely closed because the stream is closed and that closes the channel. - //noinspection ChannelOpenedButNotSafelyClosed - final FileChannel outChannel = fout.getChannel(); - final PrintStream binFile = new PrintStream(fout); - try { - final int numOfFaceObjects = size(); - progress.setLabel(ACTION_FACTORY.getString("archCollectImages"), numOfFaceObjects); - int i = 0; - for (final FaceObject faceObject : this) { - final String face = faceObject.getFaceName(); - final String path = ((ArchFaceProvider) FaceObjectProviders.normal).getFilename(face); - try { - final FileInputStream fin = new FileInputStream(path); - try { - //It's safely closed because the stream is closed and that closes the channel. - //noinspection ChannelOpenedButNotSafelyClosed - final FileChannel inChannel = fin.getChannel(); - final int imageSize = (int) inChannel.size(); - binFile.format("IMAGE %d %d %s\n", i, imageSize, face); - inChannel.transferTo(0, imageSize, outChannel); - } finally { - fin.close(); - } - } catch (final FileNotFoundException e) { - ACTION_FACTORY.showMessageDialog(progress.getParentComponent(), "archCollectErrorFileNotFound", path); - return; - } catch (final IOException e) { - ACTION_FACTORY.showMessageDialog(progress.getParentComponent(), "archCollectErrorIOException", path, e); - return; - } - - if (i++ % 100 == 0) { - progress.setValue(i); - } - } - progress.setValue(size()); // finished - progress.finished(); //getArchetypeCount(), faceListCount); - } finally { - binFile.close(); - } - } - - /** - * Creates the tree file. - * @param progress Progress to report progress to. - * @param dir Destination directory to collect data to. - * @param baseDir the base directory from where the archetypes has been - * collected - * @throws IOException in case of I/O problems during collection - */ - private void collectTreeFile(@NotNull final Progress progress, @NotNull final File dir, @NotNull final File baseDir) throws IOException { - final int stripPath = baseDir.getAbsolutePath().length(); - final BufferedWriter treeFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(dir, faceTreeFile)), "us-ascii")); - try { - final int numOfFaceObjects = size(); - progress.setLabel(ACTION_FACTORY.getString("archCollectTree"), numOfFaceObjects); - int i = 0; - for (final FaceObject faceObject : this) { - final String face = faceObject.getFaceName(); - final String path = ((ArchFaceProvider) FaceObjectProviders.normal).getFilename(face); - assert path.startsWith(baseDir.getAbsolutePath()); - assert path.endsWith(".png"); - final String name = path.substring(stripPath, path.length() - 4).replace('\\', '/'); - treeFile.append(String.format(faceTreeOutputFormat, i, name)).append('\n'); - if (i++ % 100 == 0) { - progress.setValue(i); - } - } - progress.setValue(numOfFaceObjects); - } finally { - treeFile.close(); - } - } - - /** - * Creates the bmaps file. - * @param progress Progress to report progress to. - * @param dir Destination directory to collect data to. - * @throws IOException in case of I/O problems during collection - */ - protected void collectBmapsFile(@NotNull final Progress progress, @NotNull final File dir) throws IOException { - final PrintWriter textFile = new PrintWriter(new BufferedWriter(new FileWriter(new File(dir, CommonConstants.BMAPS_FILE))), false); - try { - final int numOfFaceObjects = size(); - progress.setLabel(ACTION_FACTORY.getString("archCollectBmaps"), numOfFaceObjects); - int i = 0; - for (final FaceObject faceObject : this) { - final String face = faceObject.getFaceName(); - textFile.format("%05d %s\n", i, face); - if (i++ % 100 == 0) { - progress.setValue(i); - } - } - progress.setValue(numOfFaceObjects); - } finally { - textFile.close(); - } - } - - /** {@inheritDoc} */ - public void addFaceObject(final String faceName, final String originalFilename, final String actualFilename, final int offset, final int size) throws DuplicateFaceException { - final FaceObject faceObject = new DefaultFaceObject(faceName, originalFilename, actualFilename, offset, size); - final FaceObject otherFaceObject = get(faceName); - if (otherFaceObject != null) { - throw new DuplicateFaceException(faceObject, otherFaceObject); - } - put(faceObject); - } - - /** - * Returns a file that is a regular file on the file system. Returns the - * passed file if it is a regular file. Otherwise copies the passed file - * into a temporary regular file and returns the copy. - * @param faceFile the input file - * @return the output file which is a regular file on the file system - * @todo remove this method when CrossfireEditor does not anymore embed crossfire.0 - */ - protected static File makeTmpFaceFile(final File faceFile) { - if (faceFile.exists()) { - return faceFile; - } - - final File tmpFaceFile; - try { - tmpFaceFile = File.createTempFile("gridarta", null); - tmpFaceFile.deleteOnExit(); - final BufferedInputStream inputStream = IOUtils.createStream(null, faceFile.getPath()); - try { - final FileOutputStream outputStream = new FileOutputStream(tmpFaceFile); - try { - final byte[] buf = new byte[65536]; - for (;;) { - final int len = inputStream.read(buf); - if (len == -1) { - break; - } - - outputStream.write(buf, 0, len); - } - } - finally { - outputStream.close(); - } - } - finally { - inputStream.close(); - } - } catch (final IOException ex) { - return faceFile; - } - return tmpFaceFile; - } - - /** {@inheritDoc} */ - public void loadFacesCollection(final File faceFile, final File treeFile) throws IOException, FileNotFoundException, DuplicateFaceException { - final File tmpFaceFile = makeTmpFaceFile(faceFile); - FaceObjectProviders.setNormal(new CollectedFaceProvider(tmpFaceFile)); - final String actualFilename = tmpFaceFile.toString(); - final InputStream inputStream = new FileInputStream(tmpFaceFile); - final ByteArrayOutputStream bufOut = new ByteArrayOutputStream((int) tmpFaceFile.length()); - try { - final byte[] buf = new byte[4096]; - for (; ;) { - final int len = inputStream.read(buf); - if (len == -1) { - break; - } - bufOut.write(buf, 0, len); - } - } finally { - inputStream.close(); - } - final byte[] data = bufOut.toByteArray(); - - // Note: treeIn might stay null, this is optional data. - BufferedReader treeIn = null; - try { - //cher: it is safely closed but optional. InspectionGadgets doesn't detect where it's closed. - //noinspection IOResourceOpenedButNotSafelyClosed - treeIn = new BufferedReader(new InputStreamReader(new FileInputStream(treeFile), "us-ascii")); - } catch (final FileNotFoundException e) { - log.warn(ACTION_FACTORY.format("logCantLoadFaceTree", treeFile)); - } - final byte[] tag = "IMAGE ".getBytes(); // this is the starting string for a new png - final StringBuilder faceB = new StringBuilder(); // face name of png - try { - int offset = 0; - while (offset < data.length) { - // File: Structure* - // Structure: "IMAGE " seqnr ' ' size ' ' facename '\n' PNGBinary - if (!ArrayUtils.contains(data, offset, tag)) { // check for IMAGE - throw new IOException("Error in file " + pngFile + " at position " + offset); - } - offset += 6; // skip "IMAGE "; - while (data[offset++] != (byte) 0x20) { - ; // skip seqnr ' ' - } - int size = 0; - char c; - while ((c = (char) data[offset++]) != ' ') { // read size ' ' - if (c < '0' || c > '9') { - log.warn("Syntax error in file " + pngFile + " at position " + offset + "."); - throw new IOException("syntax error at position " + offset + ": not a digit"); - } - size *= 10; - size += c - '0'; - } - faceB.setLength(0); - while ((c = (char) data[offset++]) != '\n') { // read facename '\n' - if (c == '/') { - faceB.setLength(0); - } else { - faceB.append(c); - } - } - final String faceName = faceB.toString().intern(); - - if (offset + size > data.length) { - throw new IOException("Truncated face data in file " + pngFile + " at position " + offset); - } - - if (treeIn != null) { - final String originalFilename = treeIn.readLine(); - if (originalFilename == null) { - log.warn(ACTION_FACTORY.format("logFaceObjectWithoutOriginalName", faceName)); - } else { - final Matcher matcher = faceTreeInputPattern.matcher(originalFilename); - if (!matcher.matches()) { - log.warn("Syntax error in " + treeFile + ": " + originalFilename); - } else { - addFaceObject(faceName, matcher.group(1), actualFilename, offset, size); - } - } - } - ((CollectedFaceProvider) FaceObjectProviders.normal).addInfo(faceName, offset, size); // TODO Remove me - offset += size; - } - } finally { - try { - if (treeIn != null) { - treeIn.close(); - } - } catch (final IOException e) { - /* ignore */ - } - } - } - -} // class AbstractFaceObjects Copied: trunk/src/app/net/sf/gridarta/gameobject/face/DefaultFaceObjects.java (from rev 5508, trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/DefaultFaceObjects.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gameobject/face/DefaultFaceObjects.java 2008-10-12 18:31:28 UTC (rev 5509) @@ -0,0 +1,392 @@ +/* + * 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.face; + +import java.awt.image.ImageFilter; +import java.awt.image.RGBImageFilter; +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.io.PrintStream; +import java.io.PrintWriter; +import java.nio.channels.FileChannel; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import net.sf.gridarta.CommonConstants; +import net.sf.gridarta.data.AbstractNamedObjects; +import net.sf.gridarta.utils.ArrayUtils; +import net.sf.gridarta.utils.IOUtils; +import net.sf.japi.swing.ActionFactory; +import net.sf.japi.swing.misc.Progress; +import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; + +/** + * Abstract base implementation of {@link FaceObjects}. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class DefaultFaceObjects extends AbstractNamedObjects<FaceObject> implements FaceObjects { + + /** The Logger for printing log messages. */ + private static final Logger log = Logger.getLogger(DefaultFaceObjects.class); + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); + + /** Transparency filter to make transparent images. */ + public static final ImageFilter ALPHA_FILTER = new RGBImageFilter() { + + /** + * Converts a pixel by increasing the transparency. + * {@inheritDoc} + */ + @Override + public int filterRGB(final int x, final int y, final int rgb) { + // This is sufficient since alpha channel isn't used in the graphics this is required for. + return rgb >>> 24 == 0 ? rgb : rgb & 0x00FFFFFF | 0x80000000; + } + + }; // ALPHA_FILTER + + /** + * The filename of the collected image file. + */ + @NotNull + private final String pngFile; + + /** + * The filename of the face tree file. + */ + @NotNull + private final String faceTreeFile; + + /** + * The {@link Pattern} for parsing face tree files. The pattern must return + * the face name in the first capturing group. + */ + @NotNull + private final Pattern faceTreeInputPattern; + + /** + * The format string for writing face tree files. + */ + @NotNull + private final String faceTreeOutputFormat; + + /** + * Creates a new instance. + * @param pngFile the filename of the collected image file + * @param faceTreeFile the filename of the face tree file + * @param faceTreeInputPattern the pattern for parsing face tree files + * @param faceTreeOutputFormat the format string for writing face tree + * files + */ + public DefaultFaceObjects(@NotNull final String pngFile, @NotNull final String faceTreeFile, @NotNull final Pattern faceTreeInputPattern, @NotNull final String faceTreeOutputFormat) { + super(ACTION_FACTORY.getString("nameOfFaceObject")); + this.pngFile = pngFile; + this.faceTreeFile = faceTreeFile; + this.faceTreeInputPattern = faceTreeInputPattern; + this.faceTreeOutputFormat = faceTreeOutputFormat; + } + + /** + * {@inheritDoc} Collects the faces. The graphics information is written to + * "crossfire.0" resp. "daimonin.0". The meta information (offsets etc.) is + * written to "bmaps". The tree information for the editor is written to + * "bmaps.paths" resp. "facetree". + * <p/> + * Theoretically it would also be possible to recode the images. But the + * Java image encoder isn't as good as that of gimp in many cases (yet much + * better as the old visualtek's). + */ + public void collect(@NotNull final Progress progress, @NotNull final File dir, @NotNull final File baseDir) throws IOException { + collectTreeFile(progress, dir, baseDir); + collectBmapsFile(progress, dir); + collectImageFile(progress, dir); + } + + /** + * Creates the image file. + * @param progress Progress to report progress to. + * @param dir Destination directory to collect data to. + * @throws IOException in case of I/O problems during collection + */ + private void collectImageFile(@NotNull final Progress progress, @NotNull final File dir) throws IOException { + final File dfile = new File(dir, pngFile); + final FileOutputStream fout = new FileOutputStream(dfile); + //It's safely closed because the stream is closed and that closes the channel. + //noinspection ChannelOpenedButNotSafelyClosed + final FileChannel outChannel = fout.getChannel(); + final PrintStream binFile = new PrintStream(fout); + try { + final int numOfFaceObjects = size(); + progress.setLabel(ACTION_FACTORY.getString("archCollectImages"), numOfFaceObjects); + int i = 0; + for (final FaceObject faceObject : this) { + final String face = faceObject.getFaceName(); + final String path = ((ArchFaceProvider) FaceObjectProviders.normal).getFilename(face); + try { + final FileInputStream fin = new FileInputStream(path); + try { + //It's safely closed because the stream is closed and that closes the channel. + //noinspection ChannelOpenedButNotSafelyClosed + final FileChannel inChannel = fin.getChannel(); + final int imageSize = (int) inChannel.size(); + binFile.format("IMAGE %d %d %s\n", i, imageSize, face); + inChannel.transferTo(0, imageSize, outChannel); + } finally { + fin.close(); + } + } catch (final FileNotFoundException e) { + ACTION_FACTORY.showMessageDialog(progress.getParentComponent(), "archCollectErrorFileNotFound", path); + return; + } catch (final IOException e) { + ACTION_FACTORY.showMessageDialog(progress.getParentComponent(), "archCollectErrorIOException", path, e); + return; + } + + if (i++ % 100 == 0) { + progress.setValue(i); + } + } + progress.setValue(size()); // finished + progress.finished(); //getArchetypeCount(), faceListCount); + } finally { + binFile.close(); + } + } + + /** + * Creates the tree file. + * @param progress Progress to report progress to. + * @param dir Destination directory to collect data to. + * @param baseDir the base directory from where the archetypes has been + * collected + * @throws IOException in case of I/O problems during collection + */ + private void collectTreeFile(@NotNull final Progress progress, @NotNull final File dir, @NotNull final File baseDir) throws IOException { + final int stripPath = baseDir.getAbsolutePath().length(); + final BufferedWriter treeFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(dir, faceTreeFile)), "us-ascii")); + try { + final int numOfFaceObjects = size(); + progress.setLabel(ACTION_FACTORY.getString("archCollectTree"), numOfFaceObjects); + int i = 0; + for (final FaceObject faceObject : this) { + final String face = faceObject.getFaceName(); + final String path = ((ArchFaceProvider) FaceObjectProviders.normal).getFilename(face); + assert path.startsWith(baseDir.getAbsolutePath()); + assert path.endsWith(".png"); + final String name = path.substring(stripPath, path.length() - 4).replace('\\', '/'); + treeFile.append(String.format(faceTreeOutputFormat, i, name)).append('\n'); + if (i++ % 100 == 0) { + progress.setValue(i); + } + } + progress.setValue(numOfFaceObjects); + } finally { + treeFile.close(); + } + } + + /** + * Creates the bmaps file. + * @param progress Progress to report progress to. + * @param dir Destination directory to collect data to. + * @throws IOException in case of I/O problems during collection + */ + protected void collectBmapsFile(@NotNull final Progress progress, @NotNull final File dir) throws IOException { + final PrintWriter textFile = new PrintWriter(new BufferedWriter(new FileWriter(new File(dir, CommonConstants.BMAPS_FILE))), false); + try { + final int numOfFaceObjects = size(); + progress.setLabel(ACTION_FACTORY.getString("archCollectBmaps"), numOfFaceObjects); + int i = 0; + for (final FaceObject faceObject : this) { + final String face = faceObject.getFaceName(); + textFile.format("%05d %s\n", i, face); + if (i++ % 100 == 0) { + progress.setValue(i); + } + } + progress.setValue(numOfFaceObjects); + } finally { + textFile.close(); + } + } + + /** {@inheritDoc} */ + public void addFaceObject(final String faceName, final String originalFilename, final String actualFilename, final int offset, final int size) throws DuplicateFaceException { + final FaceObject faceObject = new DefaultFaceObject(faceName, originalFilename, actualFilename, offset, size); + final FaceObject otherFaceObject = get(faceName); + if (otherFaceObject != null) { + throw new DuplicateFaceException(faceObject, otherFaceObject); + } + put(faceObject); + } + + /** + * Returns a file that is a regular file on the file system. Returns the + * passed file if it is a regular file. Otherwise copies the passed file + * into a temporary regular file and returns the copy. + * @param faceFile the input file + * @return the output file which is a regular file on the file system + * @todo remove this method when CrossfireEditor does not anymore embed crossfire.0 + */ + protected static File makeTmpFaceFile(final File faceFile) { + if (faceFile.exists()) { + return faceFile; + } + + final File tmpFaceFile; + try { + tmpFaceFile = File.createTempFile("gridarta", null); + tmpFaceFile.deleteOnExit(); + final BufferedInputStream inputStream = IOUtils.createStream(null, faceFile.getPath()); + try { + final FileOutputStream outputStream = new FileOutputStream(tmpFaceFile); + try { + final byte[] buf = new byte[65536]; + for (;;) { + final int len = inputStream.read(buf); + if (len == -1) { + break; + } + + outputStream.write(buf, 0, len); + } + } + finally { + outputStream.close(); + } + } + finally { + inputStream.close(); + } + } catch (final IOException ex) { + return faceFile; + } + return tmpFaceFile; + } + + /** {@inheritDoc} */ + public void loadFacesCollection(final File faceFile, final File treeFile) throws IOException, FileNotFoundException, DuplicateFaceException { + final File tmpFaceFile = makeTmpFaceFile(faceFile); + FaceObjectProviders.setNormal(new CollectedFaceProvider(tmpFaceFile)); + final String actualFilename = tmpFaceFile.toString(); + final InputStream inputStream = new FileInputStream(tmpFaceFile); + final ByteArrayOutputStream bufOut = new ByteArrayOutputStream((int) tmpFaceFile.length()); + try { + final byte[] buf = new byte[4096]; + for (; ;) { + final int len = inputStream.read(buf); + if (len == -1) { + break; + } + bufOut.write(buf, 0, len); + } + } finally { + inputStream.close(); + } + final byte[] data = bufOut.toByteArray(); + + // Note: treeIn might stay null, this is optional data. + BufferedReader treeIn = null; + try { + //cher: it is safely closed but optional. InspectionGadgets doesn't detect where it's closed. + //noinspection IOResourceOpenedButNotSafelyClosed + treeIn = new BufferedReader(new InputStreamReader(new FileInputStream(treeFile), "us-ascii")); + } catch (final FileNotFoundException e) { + log.warn(ACTION_FACTORY.format("logCantLoadFaceTree", treeFile)); + } + final byte[] tag = "IMAGE ".getBytes(); // this is the starting string for a new png + final StringBuilder faceB = new StringBuilder(); // face name of png + try { + int offset = 0; + while (offset < data.length) { + // File: Structure* + // Structure: "IMAGE " seqnr ' ' size ' ' facename '\n' PNGBinary + if (!ArrayUtils.contains(data, offset, tag)) { // check for IMAGE + throw new IOException("Error in file " + pngFile + " at position " + offset); + } + offset += 6; // skip "IMAGE "; + while (data[offset++] != (byte) 0x20) { + ; // skip seqnr ' ' + } + int size = 0; + char c; + while ((c = (char) data[offset++]) != ' ') { // read size ' ' + if (c < '0' || c > '9') { + log.warn("Syntax error in file " + pngFile + " at position " + offset + "."); + throw new IOException("syntax error at position " + offset + ": not a digit"); + } + size *= 10; + size += c - '0'; + } + faceB.setLength(0); + while ((c = (char) data[offset++]) != '\n') { // read facename '\n' + if (c == '/') { + faceB.setLength(0); + } else { + faceB.append(c); + } + } + final String faceName = faceB.toString().intern(); + + if (offset + size > data.length) { + throw new IOException("Truncated face data in file " + pngFile + " at position " + offset); + } + + if (treeIn != null) { + final String originalFilename = treeIn.readLine(); + if (originalFilename == null) { + log.warn(ACTION_FACTORY.format("logFaceObjectWithoutOriginalName", faceName)); + } else { + final Matcher matcher = faceTreeInputPattern.matcher(originalFilename); + if (!matcher.matches()) { + log.warn("Syntax error in " + treeFile + ": " + originalFilename); + } else { + addFaceObject(faceName, matcher.group(1), actualFilename, offset, size); + } + } + } + ((CollectedFaceProvider) FaceObjectProviders.normal).addInfo(faceName, offset, size); // TODO Remove me + offset += size; + } + } finally { + try { + if (treeIn != null) { + treeIn.close(); + } + } catch (final IOException e) { + /* ignore */ + } + } + } + +} // class DefaultFaceObjects Property changes on: trunk/src/app/net/sf/gridarta/gameobject/face/DefaultFaceObjects.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gameobject/face/FaceObjectProviders.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/FaceObjectProviders.java 2008-10-12 18:05:59 UTC (rev 5508) +++ trunk/src/app/net/sf/gridarta/gameobject/face/FaceObjectProviders.java 2008-10-12 18:31:28 UTC (rev 5509) @@ -76,7 +76,7 @@ public static FaceProvider normal; /** The FaceProvider for alpha faces. */ - public static final FaceProvider ALPHA = new FilterFaceProvider(AbstractFaceObjects.ALPHA_FILTER); + public static final FaceProvider ALPHA = new FilterFaceProvider(DefaultFaceObjects.ALPHA_FILTER); /** Private constructor to prevent instantiation. */ private FaceObjectProviders() { Modified: trunk/src/app/net/sf/gridarta/gui/SystemIcons.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/SystemIcons.java 2008-10-12 18:05:59 UTC (rev 5508) +++ trunk/src/app/net/sf/gridarta/gui/SystemIcons.java 2008-10-12 18:31:28 UTC (rev 5509) @@ -25,7 +25,7 @@ import java.awt.image.ImageFilter; import java.awt.image.ImageProducer; import javax.swing.ImageIcon; -import net.sf.gridarta.gameobject.face.AbstractFaceObjects; +import net.sf.gridarta.gameobject.face.DefaultFaceObjects; import net.sf.gridarta.gui.utils.GUIUtils; /** @@ -90,7 +90,7 @@ } private static ImageIcon createWarningSquareIcon() { - final ImageFilter alphaFilter = AbstractFaceObjects.ALPHA_FILTER; + final ImageFilter alphaFilter = DefaultFaceObjects.ALPHA_FILTER; final ImageIcon sysIcon = GUIUtils.getSysIcon(GUIConstants.TILE_WARNING); final Image image = sysIcon.getImage(); final ImageProducer source = image.getSource(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-12 18:51:22
|
Revision: 5510 http://gridarta.svn.sourceforge.net/gridarta/?rev=5510&view=rev Author: akirschbaum Date: 2008-10-12 18:51:16 +0000 (Sun, 12 Oct 2008) Log Message: ----------- Remove empty packages. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gameobject/face/package-info.java Removed Paths: ------------- trunk/crossfire/src/cfeditor/gameobject/face/ trunk/daimonin/src/daieditor/gameobject/face/ Modified: trunk/src/app/net/sf/gridarta/gameobject/face/package-info.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/package-info.java 2008-10-12 18:31:28 UTC (rev 5509) +++ trunk/src/app/net/sf/gridarta/gameobject/face/package-info.java 2008-10-12 18:51:16 UTC (rev 5510) @@ -19,7 +19,68 @@ /** * The face is the appearance of an object. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * <p/> + * This package contains classes for managing icons in memory sensitive caches. + * Currently, the keys to lookup the icons are Strings (usually the facename of an arch), and lookup is done in Hashmaps. + * <p/> + * Hashmaps are fast, but, of course, never as fast as an indexed array. + * Though, Hashmaps are easier to maintain. + * In case someone complains about the usage of Hashmaps instead of arrays in this package, I have documented my performance considerations. + * <dl> + * <dt>How fast is String hashCode generation?</dt> + * <dd>Extremely fast. Strings are often used as Hash keys, therefore a String's hash code is ached and only calculated the first time a it is + * queried. All subsequent invocations return the previously calculated, cached hash code.</dd> + * <dt>How fast is Hashmap lookup compared with Array indexing?</dt> + * <dd> + * To index an Array gives a constant speed of <var>O[array] = O(c)</var> where <var>c</var> is the time it takes to address and offset. + * To lookup in a Hashmap gives a performance of approximately <var>O[hashmap] = O(2*c + log2(n)*c*2)</var> where <var>n</var> is the + * number of HashMap entries. + * In general, a Hashmap gives a very good performance, but not compared with an array when an index can be used. + * </dd> + * <dt>How does lookup scale?</dt> + * <dd> + * Lookup is used every time the code needs an image, which is nearly every time some painting is done by Java. + * Since maps are 2.5-dimensional structures, the lookup part of painting maps gives a general perforamnce of <var>O[paintLookup] = O(O[lookup] * x * y * z)</var>. + * For a map with the size 24*24 and an average tile coverage of 2 faces requires 24*24*2 lookups which is 1152 lookups. And let + * <var>n</var>, the number of HashMap entries, be 3688. + * If <var>O[lookup] == O[array]</var>, the performance is + * <var>O[paintLookup] = O(c * x * y * z) = O(c * 1152)</var>. + * If <var>O[lookup] == O[hashmap]</var>, the performance is + * <var>O[paintLookup] = O((2*c + log2(n)*c*2) * x * y * z) = O((2*c + log2(3688)*c*2) * 1152) = O((2*c + 24*c) * 1152) = O(c * 29952)</var> + * It is a realistic asumption that the number of effective cycles required for performing a lookup in Java is always smaller than 10 + * times the performance. + * That means, a complete map paint lookup for the given exmaple map takes less than 300,000 cycles when using a HashMap. Current CPUs + * execute about 5,000,000,000 cycles per second. + * </dd> + * <dt>How often is lookup needed?</dt> + * <dd> + * Repainting is done when a new tile was painted, the map scrolls, a map was loaded, hidden or otherwise gets completely refreshed, an + * archpanel scrolls or a pickmap is used. + * Lookup does not happen more than 2-3 times per second, except for scrolling. + * </dd> + * <dt>Other considerations</dt> + * <dd> + * The design to generate artificial indices for faces has some flaws. + * Keeping several arrays in parallel to hold the same information can cause serious, eventually difficult to find bugs. + * Such a design also prevents the implementation of dynamic arch handling, where arches and faces should be loadable, editable and + * unloadable during editor runtime. + * The allocation of several large arrays also is a serious indicator for design flaws when using artificial indices, also these arrays + * need to be anxiously oversized to not get into ArrayIndexOutOfBounds trouble. + * The natural index of a face is its name, the object oriented index of a face is its own reference. + * Mapping face names to face references therefore is a good and clear design and very resistent against bugs or overflouws. + * <p /> + * Also, an arch first naturally comes with a face name. + * To get an index for a face name, it is required to first do a linear search. + * Linear search is always wrong and averages to <var>O(n * c)</var> which is worse than HashMap performance. + * If the indices are sorted, a binary search with a performance of <var>O(2*c + log2(n)*c*2)</var>, which is exactly what a Hashmap does. + * That means, the term that best describes the usage of artificial face indices for increasing face lookup performance is "Augenauswischerei". + * </dd> + * </dl> + * <h4>Conclusions</h4> + * <ul> + * <li>Do not use the face number for face lookup, use the face name instead.</li> + * <li>Future: Refactor all code to eliminate artificial indices for faces and arches</li> + * </ul> */ package net.sf.gridarta.gameobject.face; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-13 18:34:28
|
Revision: 5511 http://gridarta.svn.sourceforge.net/gridarta/?rev=5511&view=rev Author: akirschbaum Date: 2008-10-13 18:34:11 +0000 (Mon, 13 Oct 2008) Log Message: ----------- (Somewhat) fix "reload faces". Modified Paths: -------------- trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gameobject/face/ArchFaceProvider.java Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-10-12 18:51:16 UTC (rev 5510) +++ trunk/daimonin/ChangeLog 2008-10-13 18:34:11 UTC (rev 5511) @@ -1,3 +1,7 @@ +2008-10-13 Andreas Kirschbaum + + * (Somewhat) fix "reload faces". + 2008-10-10 Andreas Kirschbaum * Make replace dialog work again. Modified: trunk/src/app/net/sf/gridarta/gameobject/face/ArchFaceProvider.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/ArchFaceProvider.java 2008-10-12 18:51:16 UTC (rev 5510) +++ trunk/src/app/net/sf/gridarta/gameobject/face/ArchFaceProvider.java 2008-10-13 18:34:11 UTC (rev 5511) @@ -20,6 +20,8 @@ package net.sf.gridarta.gameobject.face; import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; import java.util.HashMap; import java.util.Map; import javax.swing.ImageIcon; @@ -64,16 +66,32 @@ @Nullable @Override protected ImageIcon createImage(@NotNull final String faceName) { + final String filename = files.get(faceName); + if (filename == null) { + return null; + } + + final File file = new File(filename); + final long length = file.length(); + if (length <= 0 || length >= Integer.MAX_VALUE) { + return null; + } + + final byte[] buf = new byte[(int) length]; try { - final File file = new File(files.get(faceName)); - if (!file.exists()) { - return null; + final FileInputStream fis = new FileInputStream(file); + try { + if (fis.read(buf) != (int) length) { + return null; + } + } finally { + fis.close(); } - //System.err.println("Loading new image for " + faceName); - return new ImageIcon(files.get(faceName)); - } catch (final Exception e) { + } catch (final IOException ex) { return null; } + + return new ImageIcon(buf); } } // class ArchFaceProvider This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-13 18:56:09
|
Revision: 5513 http://gridarta.svn.sourceforge.net/gridarta/?rev=5513&view=rev Author: akirschbaum Date: 2008-10-13 18:55:42 +0000 (Mon, 13 Oct 2008) Log Message: ----------- Move ScriptArchData.getScriptedEvent() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-10-13 18:41:01 UTC (rev 5512) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-10-13 18:55:42 UTC (rev 5513) @@ -31,7 +31,6 @@ import net.sf.gridarta.gui.gameobjectattributespanel.ScriptTab; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; /** * Stores and manages information about scripted events. This data is only @@ -48,18 +47,6 @@ /** Serial Version. */ private static final long serialVersionUID = 1L; - private final GameObject owner; - - /** - * The attribute name for the subtype field. - */ - private final String subtypeAttribute; - - /** - * The object type for event objects. - */ - private final int eventTypeNo; - private boolean changed; /** @@ -69,23 +56,10 @@ * @param eventTypeNo the object type for event objects */ public ScriptArchData(final GameObject owner, @NotNull final String subtypeAttribute, final int eventTypeNo) { - this.owner = owner; - this.subtypeAttribute = subtypeAttribute; - this.eventTypeNo = eventTypeNo; + super(owner, subtypeAttribute, eventTypeNo); } /** {@inheritDoc} */ - @Nullable - public GameObject getScriptedEvent(final int eventSubtype) { - for (final GameObject tmp : owner) { - if (tmp.getTypeNo() == eventTypeNo && tmp.getAttributeInt(subtypeAttribute) == eventSubtype) { - return tmp; - } - } - return null; - } - - /** {@inheritDoc} */ @Override public void validateAllEvents() { final Iterator<GameObject> it = owner.iterator(); Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-10-13 18:41:01 UTC (rev 5512) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-10-13 18:55:42 UTC (rev 5513) @@ -31,7 +31,6 @@ import net.sf.gridarta.gui.gameobjectattributespanel.ScriptTab; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; /** * Stores and manages information about scripted events. This data is only @@ -48,18 +47,6 @@ /** Serial Version. */ private static final long serialVersionUID = 1L; - private final GameObject owner; - - /** - * The attribute name for the subtype field. - */ - private final String subtypeAttribute; - - /** - * The object type for event objects. - */ - private final int eventTypeNo; - private boolean changed; /** @@ -69,23 +56,10 @@ * @param eventTypeNo the object type for event objects */ public ScriptArchData(final GameObject owner, @NotNull final String subtypeAttribute, final int eventTypeNo) { - this.owner = owner; - this.subtypeAttribute = subtypeAttribute; - this.eventTypeNo = eventTypeNo; + super(owner, subtypeAttribute, eventTypeNo); } /** {@inheritDoc} */ - @Nullable - public GameObject getScriptedEvent(final int eventSubtype) { - for (final GameObject tmp : owner) { - if (tmp.getTypeNo() == eventTypeNo && tmp.getAttributeInt(subtypeAttribute) == eventSubtype) { - return tmp; - } - } - return null; - } - - /** {@inheritDoc} */ @Override public void validateAllEvents() { final Iterator<GameObject> it = owner.iterator(); Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java 2008-10-13 18:41:01 UTC (rev 5512) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java 2008-10-13 18:55:42 UTC (rev 5513) @@ -40,7 +40,31 @@ /** The serial version UID. */ private static final long serialVersionUID = 1; + protected final G owner; + /** + * The attribute name for the subtype field. + */ + protected final String subtypeAttribute; + + /** + * The object type for event objects. + */ + protected final int eventTypeNo; + + /** + * Create a ScriptArchData. + * @param owner owner of this ScriptArchData + * @param subtypeAttribute the attribute name for the subtype field + * @param eventTypeNo the object type for event objects + */ + protected ScriptArchData(final G owner, @NotNull final String subtypeAttribute, final int eventTypeNo) { + this.owner = owner; + this.subtypeAttribute = subtypeAttribute; + this.eventTypeNo = eventTypeNo; + } + + /** * The user has chosen to create a new event, now it is to be done. * @param frame the parent window of the create-new-event dialog */ @@ -67,8 +91,16 @@ * type exists */ @Nullable - public abstract G getScriptedEvent(final int eventSubtype); + public G getScriptedEvent(final int eventSubtype) { + for (final G tmp : owner) { + if (tmp.getTypeNo() == eventTypeNo && tmp.getAttributeInt(subtypeAttribute) == eventSubtype) { + return tmp; + } + } + return null; + } + /** * This method is called for each arch after loading a map. It checks * whether all events have enough data to be valid. Invalid or insufficient This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-13 18:59:55
|
Revision: 5514 http://gridarta.svn.sourceforge.net/gridarta/?rev=5514&view=rev Author: akirschbaum Date: 2008-10-13 18:59:42 +0000 (Mon, 13 Oct 2008) Log Message: ----------- Move ScriptArchData.addEventsToJList() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-10-13 18:55:42 UTC (rev 5513) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-10-13 18:59:42 UTC (rev 5514) @@ -22,7 +22,6 @@ import cfeditor.gameobject.GameObject; import java.awt.Frame; import java.util.Iterator; -import java.util.Vector; import javax.swing.JDialog; import javax.swing.JList; import javax.swing.JOptionPane; @@ -81,22 +80,6 @@ /** {@inheritDoc} */ @Override - public void addEventsToJList(final JList list) { - //cher: JList expects Vector, so we MUST use an obsolete concrete collection. - //noinspection CollectionDeclaredAsConcreteClass,UseOfObsoleteCollectionType - final Vector<String> content = new Vector<String>(); - for (final GameObject tmp : owner) { - if (tmp.getTypeNo() == eventTypeNo) { - content.add(" " + ScriptArchUtils.typeName(tmp.getAttributeInt(subtypeAttribute))); - } - } - - list.setListData(content); - list.setSelectedIndex(0); - } - - /** {@inheritDoc} */ - @Override public void modifyEventScript(int eventIndex, final int task, @NotNull final JList panelList, @NotNull final MapManager<?, ?, ?, ?> mapManager, @NotNull final Frame parent) { GameObject oldEvent = null; @@ -159,6 +142,13 @@ } /** {@inheritDoc} */ + @NotNull + @Override + protected String typeName(final int attributeInt) { + return ScriptArchUtils.typeName(attributeInt); + } + + /** {@inheritDoc} */ public GameObject getOwner() { return owner; } Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-10-13 18:55:42 UTC (rev 5513) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-10-13 18:59:42 UTC (rev 5514) @@ -22,7 +22,6 @@ import daieditor.gameobject.GameObject; import java.awt.Frame; import java.util.Iterator; -import java.util.Vector; import javax.swing.JDialog; import javax.swing.JList; import javax.swing.JOptionPane; @@ -81,22 +80,6 @@ /** {@inheritDoc} */ @Override - public void addEventsToJList(final JList list) { - //cher: JList expects Vector, so we MUST use an obsolete concrete collection. - //noinspection CollectionDeclaredAsConcreteClass,UseOfObsoleteCollectionType - final Vector<String> content = new Vector<String>(); - for (final GameObject tmp : owner) { - if (tmp.getTypeNo() == eventTypeNo) { - content.add(" " + ScriptArchUtils.typeName(tmp.getAttributeInt(subtypeAttribute))); - } - } - - list.setListData(content); - list.setSelectedIndex(0); - } - - /** {@inheritDoc} */ - @Override public void modifyEventScript(int eventIndex, final int task, @NotNull final JList panelList, @NotNull final MapManager<?, ?, ?, ?> mapManager, @NotNull final Frame parent) { GameObject oldEvent = null; @@ -159,6 +142,13 @@ } /** {@inheritDoc} */ + @NotNull + @Override + protected String typeName(final int attributeInt) { + return ScriptArchUtils.typeName(attributeInt); + } + + /** {@inheritDoc} */ public GameObject getOwner() { return owner; } Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java 2008-10-13 18:55:42 UTC (rev 5513) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java 2008-10-13 18:59:42 UTC (rev 5514) @@ -21,6 +21,7 @@ import java.awt.Frame; import java.io.Serializable; +import java.util.Vector; import javax.swing.JDialog; import javax.swing.JList; import net.sf.gridarta.MapManager; @@ -79,8 +80,28 @@ * fast because it may be executed when user clicks on map objects. * @param list JList */ - public abstract void addEventsToJList(final JList list); + public void addEventsToJList(final JList list) { + //cher: JList expects Vector, so we MUST use an obsolete concrete collection. + //noinspection CollectionDeclaredAsConcreteClass,UseOfObsoleteCollectionType + final Vector<String> content = new Vector<String>(); + for (final G tmp : owner) { + if (tmp.getTypeNo() == eventTypeNo) { + content.add(" " + typeName(tmp.getAttributeInt(subtypeAttribute))); + } + } + list.setListData(content); + list.setSelectedIndex(0); + } + + /** + * Returns a description for a script type. + * @param attributeInt the script type + * @return the description + */ + @NotNull + protected abstract String typeName(final int attributeInt); + public abstract G getOwner(); /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-13 19:02:28
|
Revision: 5515 http://gridarta.svn.sourceforge.net/gridarta/?rev=5515&view=rev Author: akirschbaum Date: 2008-10-13 19:02:16 +0000 (Mon, 13 Oct 2008) Log Message: ----------- Move ScriptArchData.getOwner() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-10-13 18:59:42 UTC (rev 5514) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-10-13 19:02:16 UTC (rev 5515) @@ -148,9 +148,4 @@ return ScriptArchUtils.typeName(attributeInt); } - /** {@inheritDoc} */ - public GameObject getOwner() { - return owner; - } - } // class ScriptArchData Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-10-13 18:59:42 UTC (rev 5514) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-10-13 19:02:16 UTC (rev 5515) @@ -148,9 +148,4 @@ return ScriptArchUtils.typeName(attributeInt); } - /** {@inheritDoc} */ - public GameObject getOwner() { - return owner; - } - } // class ScriptArchData Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java 2008-10-13 18:59:42 UTC (rev 5514) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java 2008-10-13 19:02:16 UTC (rev 5515) @@ -41,6 +41,9 @@ /** The serial version UID. */ private static final long serialVersionUID = 1; + /** + * The owner of this script arch data instance. + */ protected final G owner; /** @@ -102,7 +105,13 @@ @NotNull protected abstract String typeName(final int attributeInt); - public abstract G getOwner(); + /** + * Returns the owner of this script arch data instance. + * @return the owner + */ + public G getOwner() { + return owner; + } /** * Search the owner game object for an event object of the specified event This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-13 19:05:27
|
Revision: 5516 http://gridarta.svn.sourceforge.net/gridarta/?rev=5516&view=rev Author: akirschbaum Date: 2008-10-13 19:05:15 +0000 (Mon, 13 Oct 2008) Log Message: ----------- Move ScriptArchData.changed and accessor functions to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-10-13 19:02:16 UTC (rev 5515) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-10-13 19:05:15 UTC (rev 5516) @@ -46,8 +46,6 @@ /** Serial Version. */ private static final long serialVersionUID = 1L; - private boolean changed; - /** * Create a ScriptArchData. * @param owner owner of this ScriptArchData @@ -132,16 +130,6 @@ } /** {@inheritDoc} */ - public void setChanged(final boolean changed) { - this.changed = changed; - } - - /** {@inheritDoc} */ - public boolean isChanged() { - return changed; - } - - /** {@inheritDoc} */ @NotNull @Override protected String typeName(final int attributeInt) { Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-10-13 19:02:16 UTC (rev 5515) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-10-13 19:05:15 UTC (rev 5516) @@ -46,8 +46,6 @@ /** Serial Version. */ private static final long serialVersionUID = 1L; - private boolean changed; - /** * Create a ScriptArchData. * @param owner owner of this ScriptArchData @@ -132,16 +130,6 @@ } /** {@inheritDoc} */ - public void setChanged(final boolean changed) { - this.changed = changed; - } - - /** {@inheritDoc} */ - public boolean isChanged() { - return changed; - } - - /** {@inheritDoc} */ @NotNull @Override protected String typeName(final int attributeInt) { Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java 2008-10-13 19:02:16 UTC (rev 5515) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java 2008-10-13 19:05:15 UTC (rev 5516) @@ -56,6 +56,8 @@ */ protected final int eventTypeNo; + private boolean changed = false; + /** * Create a ScriptArchData. * @param owner owner of this ScriptArchData @@ -74,9 +76,13 @@ */ public abstract void createNewEvent(final JDialog frame); - public abstract void setChanged(final boolean changed); + public void setChanged(final boolean changed) { + this.changed = changed; + } - public abstract boolean isChanged(); + public boolean isChanged() { + return changed; + } /** * Set all ScriptedEvents to appear in the given JList This method should be This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-13 19:07:31
|
Revision: 5517 http://gridarta.svn.sourceforge.net/gridarta/?rev=5517&view=rev Author: akirschbaum Date: 2008-10-13 19:07:16 +0000 (Mon, 13 Oct 2008) Log Message: ----------- Move ScriptArchData.isEmpty() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-10-13 19:05:15 UTC (rev 5516) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-10-13 19:07:16 UTC (rev 5517) @@ -119,17 +119,6 @@ } /** {@inheritDoc} */ - @Override - public boolean isEmpty() { - for (final GameObject tmp : owner) { - if (tmp.getTypeNo() == eventTypeNo) { - return false; - } - } - return true; - } - - /** {@inheritDoc} */ @NotNull @Override protected String typeName(final int attributeInt) { Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-10-13 19:05:15 UTC (rev 5516) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-10-13 19:07:16 UTC (rev 5517) @@ -119,17 +119,6 @@ } /** {@inheritDoc} */ - @Override - public boolean isEmpty() { - for (final GameObject tmp : owner) { - if (tmp.getTypeNo() == eventTypeNo) { - return false; - } - } - return true; - } - - /** {@inheritDoc} */ @NotNull @Override protected String typeName(final int attributeInt) { Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java 2008-10-13 19:05:15 UTC (rev 5516) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java 2008-10-13 19:07:16 UTC (rev 5517) @@ -150,8 +150,16 @@ * @return <code>true</code> if this ScriptArchData contains no events, * otherwise <code>false</code> */ - public abstract boolean isEmpty(); + public boolean isEmpty() { + for (final G tmp : owner) { + if (tmp.getTypeNo() == eventTypeNo) { + return false; + } + } + return true; + } + /** * If there is a scripted event of the specified type, the script pad is * opened and the appropriate script displayed. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-13 19:11:47
|
Revision: 5518 http://gridarta.svn.sourceforge.net/gridarta/?rev=5518&view=rev Author: akirschbaum Date: 2008-10-13 19:11:39 +0000 (Mon, 13 Oct 2008) Log Message: ----------- Extract common code into function. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-10-13 19:07:16 UTC (rev 5517) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-10-13 19:11:39 UTC (rev 5518) @@ -63,7 +63,7 @@ while (it.hasNext()) { final GameObject tmp = it.next(); if (tmp.getTypeNo() == eventTypeNo) { - final ScriptedEvent se = new ScriptedEvent(tmp); + final ScriptedEvent se = newScriptedEvent(tmp); // validate this event if (!se.isValid()) { // this event is invalid @@ -94,7 +94,7 @@ } if (oldEvent != null) { - final ScriptedEvent event = new ScriptedEvent(oldEvent); + final ScriptedEvent event = newScriptedEvent(oldEvent); // now decide what to do: if (task == ScriptTab.SCRIPT_OPEN) { ScriptedEventEditor.openScript(mapManager, event.getScriptPath(), parent); @@ -113,6 +113,11 @@ } } + @NotNull + private ScriptedEvent newScriptedEvent(@NotNull final GameObject event) { + return new ScriptedEvent(event); + } + /** {@inheritDoc} */ public void createNewEvent(final JDialog frame) { ScriptArchEditor.createNewEvent(frame, this); Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-10-13 19:07:16 UTC (rev 5517) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-10-13 19:11:39 UTC (rev 5518) @@ -63,7 +63,7 @@ while (it.hasNext()) { final GameObject tmp = it.next(); if (tmp.getTypeNo() == eventTypeNo) { - final ScriptedEvent se = new ScriptedEvent(tmp); + final ScriptedEvent se = newScriptedEvent(tmp); // validate this event if (!se.isValid()) { // this event is invalid @@ -94,7 +94,7 @@ } if (oldEvent != null) { - final ScriptedEvent event = new ScriptedEvent(oldEvent); + final ScriptedEvent event = newScriptedEvent(oldEvent); // now decide what to do: if (task == ScriptTab.SCRIPT_OPEN) { ScriptedEventEditor.openScript(mapManager, event.getScriptPath(), parent); @@ -113,6 +113,11 @@ } } + @NotNull + private ScriptedEvent newScriptedEvent(@NotNull final GameObject event) { + return new ScriptedEvent(event); + } + /** {@inheritDoc} */ public void createNewEvent(final JDialog frame) { ScriptArchEditor.createNewEvent(frame, this); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-13 19:16:08
|
Revision: 5519 http://gridarta.svn.sourceforge.net/gridarta/?rev=5519&view=rev Author: akirschbaum Date: 2008-10-13 19:15:55 +0000 (Mon, 13 Oct 2008) Log Message: ----------- Move ScriptArchData.validateAllEvents() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptedEvent.java Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-10-13 19:11:39 UTC (rev 5518) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-10-13 19:15:55 UTC (rev 5519) @@ -21,7 +21,6 @@ import cfeditor.gameobject.GameObject; import java.awt.Frame; -import java.util.Iterator; import javax.swing.JDialog; import javax.swing.JList; import javax.swing.JOptionPane; @@ -58,26 +57,6 @@ /** {@inheritDoc} */ @Override - public void validateAllEvents() { - final Iterator<GameObject> it = owner.iterator(); - while (it.hasNext()) { - final GameObject tmp = it.next(); - if (tmp.getTypeNo() == eventTypeNo) { - final ScriptedEvent se = newScriptedEvent(tmp); - // validate this event - if (!se.isValid()) { - // this event is invalid - if (log.isInfoEnabled()) { - log.info("-> Deleting invalid event..."); - } - it.remove(); - } - } - } - } - - /** {@inheritDoc} */ - @Override public void modifyEventScript(int eventIndex, final int task, @NotNull final JList panelList, @NotNull final MapManager<?, ?, ?, ?> mapManager, @NotNull final Frame parent) { GameObject oldEvent = null; @@ -113,8 +92,10 @@ } } + /** {@inheritDoc} */ @NotNull - private ScriptedEvent newScriptedEvent(@NotNull final GameObject event) { + @Override + protected ScriptedEvent newScriptedEvent(@NotNull final GameObject event) { return new ScriptedEvent(event); } Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java 2008-10-13 19:11:39 UTC (rev 5518) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java 2008-10-13 19:15:55 UTC (rev 5519) @@ -63,10 +63,7 @@ setEventData(pluginName, scriptPath, options); } - /** - * Validate this event object: Check if there is sufficient data. - * @return true if this object is valid, otherwise false - */ + /** {@inheritDoc} */ public boolean isValid() { final String options = getOptions(); String scriptPath = getScriptPath(); Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-10-13 19:11:39 UTC (rev 5518) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-10-13 19:15:55 UTC (rev 5519) @@ -21,7 +21,6 @@ import daieditor.gameobject.GameObject; import java.awt.Frame; -import java.util.Iterator; import javax.swing.JDialog; import javax.swing.JList; import javax.swing.JOptionPane; @@ -58,26 +57,6 @@ /** {@inheritDoc} */ @Override - public void validateAllEvents() { - final Iterator<GameObject> it = owner.iterator(); - while (it.hasNext()) { - final GameObject tmp = it.next(); - if (tmp.getTypeNo() == eventTypeNo) { - final ScriptedEvent se = newScriptedEvent(tmp); - // validate this event - if (!se.isValid()) { - // this event is invalid - if (log.isInfoEnabled()) { - log.info("-> Deleting invalid event..."); - } - it.remove(); - } - } - } - } - - /** {@inheritDoc} */ - @Override public void modifyEventScript(int eventIndex, final int task, @NotNull final JList panelList, @NotNull final MapManager<?, ?, ?, ?> mapManager, @NotNull final Frame parent) { GameObject oldEvent = null; @@ -113,8 +92,10 @@ } } + /** {@inheritDoc} */ @NotNull - private ScriptedEvent newScriptedEvent(@NotNull final GameObject event) { + @Override + protected ScriptedEvent newScriptedEvent(@NotNull final GameObject event) { return new ScriptedEvent(event); } Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java 2008-10-13 19:11:39 UTC (rev 5518) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java 2008-10-13 19:15:55 UTC (rev 5519) @@ -62,10 +62,7 @@ setEventData(pluginName, scriptPath, options); } - /** - * Validate this event object: Check if there is sufficient data. - * @return true if this object is valid, otherwise false - */ + /** {@inheritDoc} */ public boolean isValid() { final String options = getOptions(); String scriptPath = getScriptPath(); Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java 2008-10-13 19:11:39 UTC (rev 5518) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java 2008-10-13 19:15:55 UTC (rev 5519) @@ -21,11 +21,13 @@ import java.awt.Frame; import java.io.Serializable; +import java.util.Iterator; import java.util.Vector; import javax.swing.JDialog; import javax.swing.JList; import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.GameObject; +import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -41,6 +43,9 @@ /** The serial version UID. */ private static final long serialVersionUID = 1; + /** The Logger for printing log messages. */ + private static final Logger log = Logger.getLogger(ScriptArchData.class); + /** * The owner of this script arch data instance. */ @@ -142,7 +147,23 @@ * whether all events have enough data to be valid. Invalid or insufficient * ScriptedEvent objects get removed. */ - public abstract void validateAllEvents(); + public void validateAllEvents() { + final Iterator<G> it = owner.iterator(); + while (it.hasNext()) { + final G tmp = it.next(); + if (tmp.getTypeNo() == eventTypeNo) { + final ScriptedEvent<G> se = newScriptedEvent(tmp); + // validate this event + if (!se.isValid()) { + // this event is invalid + if (log.isInfoEnabled()) { + log.info("-> Deleting invalid event..."); + } + it.remove(); + } + } + } + } /** * Returns whether this ScriptArchData is empty (contains no events). (Note @@ -172,4 +193,7 @@ */ public abstract void modifyEventScript(int eventIndex, final int task, @NotNull final JList panelList, @NotNull final MapManager<?, ?, ?, ?> mapManager, @NotNull final Frame parent); + @NotNull + protected abstract ScriptedEvent<G> newScriptedEvent(@NotNull final G event); + } // class ScriptArchData Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptedEvent.java 2008-10-13 19:11:39 UTC (rev 5518) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptedEvent.java 2008-10-13 19:15:55 UTC (rev 5519) @@ -47,4 +47,10 @@ int getEventType(); + /** + * Validate this event object: Check if there is sufficient data. + * @return true if this object is valid, otherwise false + */ + boolean isValid(); + } // class ScriptedEvent This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-13 19:19:51
|
Revision: 5520 http://gridarta.svn.sourceforge.net/gridarta/?rev=5520&view=rev Author: akirschbaum Date: 2008-10-13 19:19:43 +0000 (Mon, 13 Oct 2008) Log Message: ----------- Move ScriptArchData.modifyEventScript() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-10-13 19:15:55 UTC (rev 5519) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-10-13 19:19:43 UTC (rev 5520) @@ -20,13 +20,7 @@ package cfeditor.gameobject.scripts; import cfeditor.gameobject.GameObject; -import java.awt.Frame; import javax.swing.JDialog; -import javax.swing.JList; -import javax.swing.JOptionPane; -import net.sf.gridarta.MapManager; -import net.sf.gridarta.gameobject.scripts.ScriptedEventEditor; -import net.sf.gridarta.gui.gameobjectattributespanel.ScriptTab; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; @@ -56,43 +50,6 @@ } /** {@inheritDoc} */ - @Override - public void modifyEventScript(int eventIndex, final int task, @NotNull final JList panelList, @NotNull final MapManager<?, ?, ?, ?> mapManager, @NotNull final Frame parent) { - GameObject oldEvent = null; - - /* Find the event object */ - for (final GameObject tmp : owner) { - if (tmp.getTypeNo() == eventTypeNo) { - if (eventIndex == 0) { - oldEvent = tmp; - break; - } else { - eventIndex--; - } - } - } - - if (oldEvent != null) { - final ScriptedEvent event = newScriptedEvent(oldEvent); - // now decide what to do: - if (task == ScriptTab.SCRIPT_OPEN) { - ScriptedEventEditor.openScript(mapManager, event.getScriptPath(), parent); - } else if (task == ScriptTab.SCRIPT_EDIT_PATH) { - ScriptedEventEditor.editParameters(event, parent); - } else if (task == ScriptTab.SCRIPT_REMOVE) { - // first ask for confirmation - if (JOptionPane.showConfirmDialog(panelList, "Are you sure you want to remove this \"" + ScriptArchUtils.typeName(event.getEventType()) + "\" event which is\n" + "linked to the script: '" + event.getScriptPath() + "'?\n" + "(The script file itself is not going to be deleted)", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { - // remove this event from the GameObject - oldEvent.remove(); - addEventsToJList(panelList); // update panel JList - } - } - } else { - log.error("Error in modifyEventScript(): No event selected?"); - } - } - - /** {@inheritDoc} */ @NotNull @Override protected ScriptedEvent newScriptedEvent(@NotNull final GameObject event) { Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-10-13 19:15:55 UTC (rev 5519) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-10-13 19:19:43 UTC (rev 5520) @@ -20,13 +20,7 @@ package daieditor.gameobject.scripts; import daieditor.gameobject.GameObject; -import java.awt.Frame; import javax.swing.JDialog; -import javax.swing.JList; -import javax.swing.JOptionPane; -import net.sf.gridarta.MapManager; -import net.sf.gridarta.gameobject.scripts.ScriptedEventEditor; -import net.sf.gridarta.gui.gameobjectattributespanel.ScriptTab; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; @@ -56,43 +50,6 @@ } /** {@inheritDoc} */ - @Override - public void modifyEventScript(int eventIndex, final int task, @NotNull final JList panelList, @NotNull final MapManager<?, ?, ?, ?> mapManager, @NotNull final Frame parent) { - GameObject oldEvent = null; - - /* Find the event object */ - for (final GameObject tmp : owner) { - if (tmp.getTypeNo() == eventTypeNo) { - if (eventIndex == 0) { - oldEvent = tmp; - break; - } else { - eventIndex--; - } - } - } - - if (oldEvent != null) { - final ScriptedEvent event = newScriptedEvent(oldEvent); - // now decide what to do: - if (task == ScriptTab.SCRIPT_OPEN) { - ScriptedEventEditor.openScript(mapManager, event.getScriptPath(), parent); - } else if (task == ScriptTab.SCRIPT_EDIT_PATH) { - ScriptedEventEditor.editParameters(event, parent); - } else if (task == ScriptTab.SCRIPT_REMOVE) { - // first ask for confirmation - if (JOptionPane.showConfirmDialog(panelList, "Are you sure you want to remove this \"" + ScriptArchUtils.typeName(event.getEventType()) + "\" event which is\n" + "linked to the script: '" + event.getScriptPath() + "'?\n" + "(The script file itself is not going to be deleted)", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { - // remove this event from the GameObject - oldEvent.remove(); - addEventsToJList(panelList); // update panel JList - } - } - } else { - log.error("Error in modifyEventScript(): No event selected?"); - } - } - - /** {@inheritDoc} */ @NotNull @Override protected ScriptedEvent newScriptedEvent(@NotNull final GameObject event) { Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java 2008-10-13 19:15:55 UTC (rev 5519) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java 2008-10-13 19:19:43 UTC (rev 5520) @@ -25,8 +25,10 @@ import java.util.Vector; import javax.swing.JDialog; import javax.swing.JList; +import javax.swing.JOptionPane; import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.gameobjectattributespanel.ScriptTab; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -191,8 +193,41 @@ * @param mapManager the map manager instance * @param parent the parent frame for dialog boxes */ - public abstract void modifyEventScript(int eventIndex, final int task, @NotNull final JList panelList, @NotNull final MapManager<?, ?, ?, ?> mapManager, @NotNull final Frame parent); + public void modifyEventScript(int eventIndex, final int task, @NotNull final JList panelList, @NotNull final MapManager<?, ?, ?, ?> mapManager, @NotNull final Frame parent) { + G oldEvent = null; + /* Find the event object */ + for (final G tmp : owner) { + if (tmp.getTypeNo() == eventTypeNo) { + if (eventIndex == 0) { + oldEvent = tmp; + break; + } else { + eventIndex--; + } + } + } + + if (oldEvent != null) { + final ScriptedEvent<G> event = newScriptedEvent(oldEvent); + // now decide what to do: + if (task == ScriptTab.SCRIPT_OPEN) { + ScriptedEventEditor.openScript(mapManager, event.getScriptPath(), parent); + } else if (task == ScriptTab.SCRIPT_EDIT_PATH) { + ScriptedEventEditor.editParameters(event, parent); + } else if (task == ScriptTab.SCRIPT_REMOVE) { + // first ask for confirmation + if (JOptionPane.showConfirmDialog(panelList, "Are you sure you want to remove this \"" + typeName(event.getEventType()) + "\" event which is\n" + "linked to the script: '" + event.getScriptPath() + "'?\n" + "(The script file itself is not going to be deleted)", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { + // remove this event from the GameObject + oldEvent.remove(); + addEventsToJList(panelList); // update panel JList + } + } + } else { + log.error("Error in modifyEventScript(): No event selected?"); + } + } + @NotNull protected abstract ScriptedEvent<G> newScriptedEvent(@NotNull final G event); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-13 19:20:36
|
Revision: 5521 http://gridarta.svn.sourceforge.net/gridarta/?rev=5521&view=rev Author: akirschbaum Date: 2008-10-13 19:20:30 +0000 (Mon, 13 Oct 2008) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-10-13 19:19:43 UTC (rev 5520) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-10-13 19:20:30 UTC (rev 5521) @@ -21,7 +21,6 @@ import cfeditor.gameobject.GameObject; import javax.swing.JDialog; -import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; /** @@ -33,9 +32,6 @@ */ public final class ScriptArchData extends net.sf.gridarta.gameobject.scripts.ScriptArchData<GameObject> { - /** The Logger for printing log messages. */ - private static final Logger log = Logger.getLogger(ScriptArchData.class); - /** Serial Version. */ private static final long serialVersionUID = 1L; Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-10-13 19:19:43 UTC (rev 5520) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-10-13 19:20:30 UTC (rev 5521) @@ -21,7 +21,6 @@ import daieditor.gameobject.GameObject; import javax.swing.JDialog; -import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; /** @@ -33,9 +32,6 @@ */ public final class ScriptArchData extends net.sf.gridarta.gameobject.scripts.ScriptArchData<GameObject> { - /** The Logger for printing log messages. */ - private static final Logger log = Logger.getLogger(ScriptArchData.class); - /** Serial Version. */ private static final long serialVersionUID = 1L; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-13 19:33:27
|
Revision: 5524 http://gridarta.svn.sourceforge.net/gridarta/?rev=5524&view=rev Author: akirschbaum Date: 2008-10-13 19:33:15 +0000 (Mon, 13 Oct 2008) Log Message: ----------- Unify ScriptedEvent. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-10-13 19:28:50 UTC (rev 5523) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-10-13 19:33:15 UTC (rev 5524) @@ -48,8 +48,8 @@ /** {@inheritDoc} */ @NotNull @Override - protected ScriptedEvent newScriptedEvent(@NotNull final GameObject event) { - return new ScriptedEvent(event); + protected ScriptedEvent newScriptedEvent(@NotNull final GameObject event, @NotNull final String subtypeAttribute) { + return new ScriptedEvent(event, subtypeAttribute); } /** {@inheritDoc} */ Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java 2008-10-13 19:28:50 UTC (rev 5523) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java 2008-10-13 19:33:15 UTC (rev 5524) @@ -86,7 +86,7 @@ // file exists -> link it to the event final ScriptedEvent event; try { - event = new ScriptedEvent(eventType, pluginName, scriptPath, options); + event = new ScriptedEvent(eventType, "subtype", pluginName, scriptPath, options); } catch (final UndefinedEventArchetypeException ex) { JOptionPane.showMessageDialog(frame, "Cannot create event of type " + eventType + ":\n" + ex.getMessage() + ".", "Cannot create event", JOptionPane.ERROR_MESSAGE); return; @@ -121,7 +121,7 @@ // file has been created, now link it to the event final ScriptedEvent event; try { - event = new ScriptedEvent(eventType, pluginName, scriptPath, options); + event = new ScriptedEvent(eventType, "subtype", pluginName, scriptPath, options); } catch (final UndefinedEventArchetypeException ex) { JOptionPane.showMessageDialog(frame, "Cannot create event of type " + eventType + ":\n" + ex.getMessage() + ".", "Cannot create event", JOptionPane.ERROR_MESSAGE); return; Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java 2008-10-13 19:28:50 UTC (rev 5523) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java 2008-10-13 19:33:15 UTC (rev 5524) @@ -42,24 +42,34 @@ private final GameObject event; /** + * The attribute name for the subtype field. + */ + @NotNull + private final String subtypeAttribute; + + /** * Create a ScriptedEvent of given type (This is used for map-loading). * @param event GameObject that describes the event. + * @param subtypeAttribute the attribute name for the subtype field */ - ScriptedEvent(final GameObject event) { + ScriptedEvent(final GameObject event, @NotNull final String subtypeAttribute) { this.event = event; + this.subtypeAttribute = subtypeAttribute; } /** * Creates a fully initialized ScriptedEvent. * @param eventType type of the event + * @param subtypeAttribute the attribute name for the subtype field * @param pluginName name of the plugin * @param scriptPath path to the file for this event * @param options the options for this event * @throws UndefinedEventArchetypeException In case there is no Archetype to * create a ScriptedEvent. */ - ScriptedEvent(final int eventType, final String pluginName, final String scriptPath, final String options) throws UndefinedEventArchetypeException { + ScriptedEvent(final int eventType, @NotNull final String subtypeAttribute, final String pluginName, final String scriptPath, final String options) throws UndefinedEventArchetypeException { event = newEventGameObject(eventType); + this.subtypeAttribute = subtypeAttribute; setEventData(pluginName, scriptPath, options); } @@ -110,7 +120,7 @@ /** {@inheritDoc} */ public int getEventType() { - return event.getAttributeInt("subtype"); + return event.getAttributeInt(subtypeAttribute); } public String getPluginName() { @@ -141,8 +151,8 @@ private void setEventData(@NotNull final String pluginName, @NotNull final String scriptPath, @NotNull final String options) { final int eventType = getEventType(); event.resetObjectText(); - if (eventType != event.getArchetype().getAttributeInt("subtype")) { - event.addObjectText("subtype " + eventType); + if (eventType != event.getArchetype().getAttributeInt(subtypeAttribute)) { + event.addObjectText(subtypeAttribute + " " + eventType); } if (!pluginName.equals(event.getArchetype().getAttributeString("title"))) { event.addObjectText("title " + pluginName); Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-10-13 19:28:50 UTC (rev 5523) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-10-13 19:33:15 UTC (rev 5524) @@ -48,8 +48,8 @@ /** {@inheritDoc} */ @NotNull @Override - protected ScriptedEvent newScriptedEvent(@NotNull final GameObject event) { - return new ScriptedEvent(event); + protected ScriptedEvent newScriptedEvent(@NotNull final GameObject event, @NotNull final String subtypeAttribute) { + return new ScriptedEvent(event, subtypeAttribute); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java 2008-10-13 19:28:50 UTC (rev 5523) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java 2008-10-13 19:33:15 UTC (rev 5524) @@ -86,7 +86,7 @@ // file exists -> link it to the event final ScriptedEvent event; try { - event = new ScriptedEvent(eventType, pluginName, scriptPath, options); + event = new ScriptedEvent(eventType, "sub_type", pluginName, scriptPath, options); } catch (final UndefinedEventArchetypeException ex) { JOptionPane.showMessageDialog(frame, "Cannot create event of type " + eventType + ":\n" + ex.getMessage() + ".", "Cannot create event", JOptionPane.ERROR_MESSAGE); return; @@ -121,7 +121,7 @@ // file has been created, now link it to the event final ScriptedEvent event; try { - event = new ScriptedEvent(eventType, pluginName, scriptPath, options); + event = new ScriptedEvent(eventType, "sub_type", pluginName, scriptPath, options); } catch (final UndefinedEventArchetypeException ex) { JOptionPane.showMessageDialog(frame, "Cannot create event of type " + eventType + ":\n" + ex.getMessage() + ".", "Cannot create event", JOptionPane.ERROR_MESSAGE); return; Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java 2008-10-13 19:28:50 UTC (rev 5523) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java 2008-10-13 19:33:15 UTC (rev 5524) @@ -27,6 +27,7 @@ import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeNameException; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeTypeException; import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; /** * Class which stores information about one scripted event. @@ -41,24 +42,34 @@ private final GameObject event; /** + * The attribute name for the subtype field. + */ + @NotNull + private final String subtypeAttribute; + + /** * Create a ScriptedEvent of given type (This is used for map-loading). * @param event GameObject that describes the event. + * @param subtypeAttribute the attribute name for the subtype field */ - ScriptedEvent(final GameObject event) { + ScriptedEvent(final GameObject event, @NotNull final String subtypeAttribute) { this.event = event; + this.subtypeAttribute = subtypeAttribute; } /** * Creates a fully initialized ScriptedEvent. * @param eventType type of the event + * @param subtypeAttribute the attribute name for the subtype field * @param pluginName name of the plugin * @param scriptPath path to the file for this event * @param options the options for this event * @throws UndefinedEventArchetypeException In case there is no Archetype to * create a ScriptedEvent. */ - ScriptedEvent(final int eventType, final String pluginName, final String scriptPath, final String options) throws UndefinedEventArchetypeException { + ScriptedEvent(final int eventType, @NotNull final String subtypeAttribute, final String pluginName, final String scriptPath, final String options) throws UndefinedEventArchetypeException { event = newEventGameObject(eventType); + this.subtypeAttribute = subtypeAttribute; setEventData(pluginName, scriptPath, options); } @@ -111,7 +122,7 @@ /** {@inheritDoc} */ public int getEventType() { - return event.getAttributeInt("sub_type"); + return event.getAttributeInt(subtypeAttribute); } public String getPluginName() { @@ -141,7 +152,7 @@ private void setEventData(final String pluginName, final String scriptPath, final String options) { final int eventType = getEventType(); event.resetObjectText(); - event.addObjectText("sub_type " + eventType); + event.addObjectText(subtypeAttribute + " " + eventType); if (pluginName != null && pluginName.length() > 0) { event.setObjName(pluginName); } @@ -160,7 +171,7 @@ * @throws UndefinedEventArchetypeException if the event game object cannot * be created */ - private static GameObject newEventGameObject(final int eventType) throws UndefinedEventArchetypeException { + private GameObject newEventGameObject(final int eventType) throws UndefinedEventArchetypeException { final String eventArchetypeName = ScriptArchUtils.getArchetypeNameForEventType(eventType); if (eventArchetypeName == null) { throw new UndefinedEventArchetypeTypeException(eventType); @@ -173,7 +184,7 @@ throw new UndefinedEventArchetypeNameException(eventArchetypeName); } final GameObject event = eventArchetype.createGameObject(); - event.addObjectText("sub_type " + eventType); + event.addObjectText(subtypeAttribute + " " + eventType); event.postParseGameObject(0); return event; } Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java 2008-10-13 19:28:50 UTC (rev 5523) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java 2008-10-13 19:33:15 UTC (rev 5524) @@ -155,7 +155,7 @@ while (it.hasNext()) { final G tmp = it.next(); if (tmp.getTypeNo() == eventTypeNo) { - final ScriptedEvent<G> se = newScriptedEvent(tmp); + final ScriptedEvent<G> se = newScriptedEvent(tmp, subtypeAttribute); // validate this event if (!se.isValid()) { // this event is invalid @@ -210,7 +210,7 @@ } if (oldEvent != null) { - final ScriptedEvent<G> event = newScriptedEvent(oldEvent); + final ScriptedEvent<G> event = newScriptedEvent(oldEvent, subtypeAttribute); // now decide what to do: if (task == ScriptTab.SCRIPT_OPEN) { ScriptedEventEditor.openScript(mapManager, event.getScriptPath(), parent); @@ -230,6 +230,6 @@ } @NotNull - protected abstract ScriptedEvent<G> newScriptedEvent(@NotNull final G event); + protected abstract ScriptedEvent<G> newScriptedEvent(@NotNull final G event, @NotNull final String subtypeAttribute); } // class ScriptArchData This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-13 19:39:06
|
Revision: 5525 http://gridarta.svn.sourceforge.net/gridarta/?rev=5525&view=rev Author: akirschbaum Date: 2008-10-13 19:38:54 +0000 (Mon, 13 Oct 2008) Log Message: ----------- Move ScriptedEvent.isValid() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptedEvent.java Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java 2008-10-13 19:33:15 UTC (rev 5524) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java 2008-10-13 19:38:54 UTC (rev 5525) @@ -26,7 +26,6 @@ import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeException; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeNameException; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeTypeException; -import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; /** @@ -35,9 +34,6 @@ */ public final class ScriptedEvent extends AbstractScriptedEvent<GameObject> { - /** The Logger for printing log messages. */ - private static final Logger log = Logger.getLogger(ScriptedEvent.class); - /** The underlying game object that represents the event. */ private final GameObject event; @@ -74,31 +70,6 @@ } /** {@inheritDoc} */ - public boolean isValid() { - final String options = getOptions(); - String scriptPath = getScriptPath(); - String pluginName = getPluginName(); - final int eventType = getEventType(); - - if (scriptPath == null || scriptPath.length() <= 0) { - log.error("Map Error: Found " + ScriptArchUtils.typeName(eventType) + " event without file name!"); - return false; - } - - if (pluginName == null || pluginName.length() <= 0) { - pluginName = "Python"; - if (log.isInfoEnabled()) { - log.info("Found " + ScriptArchUtils.typeName(eventType) + " without plugin name. Setting to \"Python\"."); - } - } - - scriptPath = scriptPath.replace('\\', '/'); // just make sure there are only slashes: '/' - - setEventData(pluginName, scriptPath, options); - return true; - } - - /** {@inheritDoc} */ public void modifyEventPath() { final String newPath = ScriptedEventEditor.inputScriptPath.getText().trim(); final String newPluginName = ScriptedEventEditor.inputPluginName.getText().trim(); @@ -148,7 +119,16 @@ setEventData(getPluginName(), getScriptPath(), options); } - private void setEventData(@NotNull final String pluginName, @NotNull final String scriptPath, @NotNull final String options) { + /** {@inheritDoc} */ + @NotNull + @Override + protected String typeName(final int eventType) { + return ScriptArchUtils.typeName(eventType); + } + + /** {@inheritDoc} */ + @Override + protected void setEventData(@NotNull final String pluginName, @NotNull final String scriptPath, @NotNull final String options) { final int eventType = getEventType(); event.resetObjectText(); if (eventType != event.getArchetype().getAttributeInt(subtypeAttribute)) { Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java 2008-10-13 19:33:15 UTC (rev 5524) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java 2008-10-13 19:38:54 UTC (rev 5525) @@ -26,7 +26,6 @@ import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeException; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeNameException; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeTypeException; -import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; /** @@ -35,9 +34,6 @@ */ public final class ScriptedEvent extends AbstractScriptedEvent<GameObject> { - /** The Logger for printing log messages. */ - private static final Logger log = Logger.getLogger(ScriptedEvent.class); - /** The underlying game object that represents the event. */ private final GameObject event; @@ -74,31 +70,6 @@ } /** {@inheritDoc} */ - public boolean isValid() { - final String options = getOptions(); - String scriptPath = getScriptPath(); - String pluginName = getPluginName(); - final int eventType = getEventType(); - - if (scriptPath == null || scriptPath.length() <= 0) { - log.error("Map Error: Found " + ScriptArchUtils.typeName(eventType) + " event without file name!"); - return false; - } - - if (pluginName == null || pluginName.length() <= 0) { - pluginName = "Python"; - if (log.isInfoEnabled()) { - log.info("Found " + ScriptArchUtils.typeName(eventType) + " without plugin name. Setting to \"Python\"."); - } - } - - scriptPath = scriptPath.replace('\\', '/'); // just make sure there are only slashes: '/' - - setEventData(pluginName, scriptPath, options); - return true; - } - - /** {@inheritDoc} */ public void modifyEventPath() { final String newPath = ScriptedEventEditor.inputScriptPath.getText().trim(); final String newPluginName = ScriptedEventEditor.inputPluginName.getText().trim(); @@ -149,7 +120,17 @@ setEventData(getPluginName(), getScriptPath(), options); } - private void setEventData(final String pluginName, final String scriptPath, final String options) { + /** {@inheritDoc} */ + @NotNull + @Override + protected String typeName(final int eventType) { + return ScriptArchUtils.typeName(eventType); + } + + + /** {@inheritDoc} */ + @Override + protected void setEventData(@NotNull final String pluginName, @NotNull final String scriptPath, @NotNull final String options) { final int eventType = getEventType(); event.resetObjectText(); event.addObjectText(subtypeAttribute + " " + eventType); Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptedEvent.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptedEvent.java 2008-10-13 19:33:15 UTC (rev 5524) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptedEvent.java 2008-10-13 19:38:54 UTC (rev 5525) @@ -21,6 +21,8 @@ import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; +import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -29,6 +31,9 @@ */ public abstract class AbstractScriptedEvent<G extends GameObject<G, ?, ?>> implements ScriptedEvent<G>{ + /** The Logger for printing log messages. */ + private static final Logger log = Logger.getLogger(AbstractScriptedEvent.class); + /** * The archetype set to use. */ @@ -43,4 +48,34 @@ AbstractScriptedEvent.archetypeSet = archetypeSet; } + /** {@inheritDoc} */ + public boolean isValid() { + final String options = getOptions(); + String scriptPath = getScriptPath(); + String pluginName = getPluginName(); + final int eventType = getEventType(); + + if (scriptPath == null || scriptPath.length() <= 0) { + log.error("Map Error: Found " + typeName(eventType) + " event without file name!"); + return false; + } + + if (pluginName == null || pluginName.length() <= 0) { + pluginName = "Python"; + if (log.isInfoEnabled()) { + log.info("Found " + typeName(eventType) + " without plugin name. Setting to \"Python\"."); + } + } + + scriptPath = scriptPath.replace('\\', '/'); // just make sure there are only slashes: '/' + + setEventData(pluginName, scriptPath, options); + return true; + } + + @NotNull + protected abstract String typeName(final int eventType); + + protected abstract void setEventData(@NotNull final String pluginName, @NotNull final String scriptPath, @NotNull final String options); + } // class AbstractScriptedEvent This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-14 18:03:27
|
Revision: 5527 http://gridarta.svn.sourceforge.net/gridarta/?rev=5527&view=rev Author: akirschbaum Date: 2008-10-14 18:03:16 +0000 (Tue, 14 Oct 2008) Log Message: ----------- Fix incorrectly created event objects. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java 2008-10-14 06:31:32 UTC (rev 5526) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java 2008-10-14 18:03:16 UTC (rev 5527) @@ -64,8 +64,8 @@ * create a ScriptedEvent. */ ScriptedEvent(final int eventType, @NotNull final String subtypeAttribute, final String pluginName, final String scriptPath, final String options) throws UndefinedEventArchetypeException { + this.subtypeAttribute = subtypeAttribute; event = newEventGameObject(eventType); - this.subtypeAttribute = subtypeAttribute; setEventData(pluginName, scriptPath, options); } Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java 2008-10-14 06:31:32 UTC (rev 5526) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java 2008-10-14 18:03:16 UTC (rev 5527) @@ -64,8 +64,8 @@ * create a ScriptedEvent. */ ScriptedEvent(final int eventType, @NotNull final String subtypeAttribute, final String pluginName, final String scriptPath, final String options) throws UndefinedEventArchetypeException { + this.subtypeAttribute = subtypeAttribute; event = newEventGameObject(eventType); - this.subtypeAttribute = subtypeAttribute; setEventData(pluginName, scriptPath, options); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-14 18:58:22
|
Revision: 5530 http://gridarta.svn.sourceforge.net/gridarta/?rev=5530&view=rev Author: akirschbaum Date: 2008-10-14 18:47:37 +0000 (Tue, 14 Oct 2008) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java trunk/src/app/net/sf/gridarta/gameobject/scripts/PathButtonListener.java trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java 2008-10-14 18:28:37 UTC (rev 5529) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java 2008-10-14 18:47:37 UTC (rev 5530) @@ -42,8 +42,6 @@ final File localMapDir = mapManager.getLocalMapDir(); - scriptArchData.setChanged(false); - // first check if that event type is not already in use final GameObject replaceObject = scriptArchData.getScriptedEvent(eventType); if (replaceObject != null) { @@ -129,7 +127,6 @@ if (replaceObject != null) { replaceObject.remove(); } - scriptArchData.setChanged(true); scriptArchData.getOwner().addLast(event.getEventArch()); frame.setVisible(false); // close dialog Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java 2008-10-14 18:28:37 UTC (rev 5529) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java 2008-10-14 18:47:37 UTC (rev 5530) @@ -42,8 +42,6 @@ final File localMapDir = mapManager.getLocalMapDir(); - scriptArchData.setChanged(false); - // first check if that event type is not already in use final GameObject replaceObject = scriptArchData.getScriptedEvent(eventType); if (replaceObject != null) { @@ -129,7 +127,6 @@ if (replaceObject != null) { replaceObject.remove(); } - scriptArchData.setChanged(true); scriptArchData.getOwner().addLast(event.getEventArch()); frame.setVisible(false); // close dialog Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/PathButtonListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/PathButtonListener.java 2008-10-14 18:28:37 UTC (rev 5529) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/PathButtonListener.java 2008-10-14 18:47:37 UTC (rev 5530) @@ -79,7 +79,6 @@ if (isOkButton && scriptArchData != null) { // ok button for creating a new event/script scriptArchData.createNewEvent(frame); - scriptArchData.setChanged(true); } else { frame.setVisible(false); // hide dialog } Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java 2008-10-14 18:28:37 UTC (rev 5529) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java 2008-10-14 18:47:37 UTC (rev 5530) @@ -64,8 +64,6 @@ */ private final int eventTypeNo; - private boolean changed = false; - /** * Create a ScriptArchData. * @param owner owner of this ScriptArchData @@ -84,14 +82,6 @@ */ public abstract void createNewEvent(final JDialog frame); - public void setChanged(final boolean changed) { - this.changed = changed; - } - - public boolean isChanged() { - return changed; - } - /** * Set all ScriptedEvents to appear in the given JList This method should be * fast because it may be executed when user clicks on map objects. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-15 18:26:40
|
Revision: 5533 http://gridarta.svn.sourceforge.net/gridarta/?rev=5533&view=rev Author: akirschbaum Date: 2008-10-15 18:26:35 +0000 (Wed, 15 Oct 2008) Log Message: ----------- Create only one ScriptArchData instance. Reduces memory consumption. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-10-15 18:02:39 UTC (rev 5532) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-10-15 18:26:35 UTC (rev 5533) @@ -27,6 +27,7 @@ import cfeditor.gameobject.DefaultGameObjectFactory; import cfeditor.gameobject.GameObject; import cfeditor.gameobject.anim.AnimationObjects; +import cfeditor.gameobject.scripts.ScriptArchData; import cfeditor.gameobject.scripts.ScriptArchUtils; import cfeditor.gui.map.CMapViewBasic; import cfeditor.gui.map.DefaultMapPropertiesDialogFactory; @@ -128,6 +129,13 @@ /** {@inheritDoc} */ @NotNull @Override + protected ScriptArchData newScriptArchData() { + return new ScriptArchData("subtype", Archetype.TYPE_EVENT_CONNECTOR); + } + + /** {@inheritDoc} */ + @NotNull + @Override protected ArchetypeFactory<GameObject, MapArchObject, Archetype> newArchetypeFactory() { return new DefaultArchetypeFactory(); } Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-10-15 18:02:39 UTC (rev 5532) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-10-15 18:26:35 UTC (rev 5533) @@ -19,7 +19,6 @@ package cfeditor.gameobject; -import cfeditor.gameobject.scripts.ScriptArchData; import cfeditor.map.MapArchObject; import net.sf.gridarta.utils.StringUtils; import org.jetbrains.annotations.NotNull; @@ -48,10 +47,6 @@ @NotNull private String loreText = ""; // lore text buffer - public GameObject() { - scriptArchData = new ScriptArchData("subtype", TYPE_EVENT_CONNECTOR); - } - /** {@inheritDoc} */ @Override public void propagateElevation(@NotNull final GameObject gameObject) { @@ -121,7 +116,6 @@ clone.initMultiData(); } - clone.scriptArchData = new ScriptArchData("subtype", TYPE_EVENT_CONNECTOR); clone.setMapX(posx); clone.setMapY(posy); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-10-15 18:02:39 UTC (rev 5532) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-10-15 18:26:35 UTC (rev 5533) @@ -27,6 +27,7 @@ import daieditor.gameobject.DefaultGameObjectFactory; import daieditor.gameobject.GameObject; import daieditor.gameobject.anim.AnimationObjects; +import daieditor.gameobject.scripts.ScriptArchData; import daieditor.gameobject.scripts.ScriptArchUtils; import daieditor.gui.map.CMapViewBasic; import daieditor.gui.map.DefaultMapPropertiesDialogFactory; @@ -173,6 +174,13 @@ /** {@inheritDoc} */ @NotNull @Override + protected ScriptArchData newScriptArchData() { + return new ScriptArchData("sub_type", Archetype.TYPE_EVENT_OBJECT); + } + + /** {@inheritDoc} */ + @NotNull + @Override protected ArchetypeFactory<GameObject, MapArchObject, Archetype> newArchetypeFactory() { return new DefaultArchetypeFactory(); } Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-10-15 18:02:39 UTC (rev 5532) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-10-15 18:26:35 UTC (rev 5533) @@ -19,7 +19,6 @@ package daieditor.gameobject; -import daieditor.gameobject.scripts.ScriptArchData; import daieditor.map.MapArchObject; import javax.swing.ImageIcon; import net.sf.gridarta.gameobject.ArchetypeSet; @@ -60,10 +59,6 @@ @NotNull private ImageIcon transFace = noFace; - public GameObject() { - scriptArchData = new ScriptArchData("sub_type", TYPE_EVENT_OBJECT); - } - /** {@inheritDoc} */ public int getMultiShapeID() { return multi != null ? multi.getMultiShapeID() : 0; @@ -175,7 +170,6 @@ clone.setMultiShapeID(getMultiShapeID()); } - clone.scriptArchData = new ScriptArchData("sub_type", TYPE_EVENT_OBJECT); clone.setMapX(posx); clone.setMapY(posy); Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-10-15 18:02:39 UTC (rev 5532) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-10-15 18:26:35 UTC (rev 5533) @@ -61,6 +61,7 @@ import net.sf.gridarta.gameobject.scripts.AbstractScriptArchEditor; import net.sf.gridarta.gameobject.scripts.AbstractScriptedEvent; import net.sf.gridarta.gameobject.scripts.ScriptedEventEditor; +import net.sf.gridarta.gameobject.scripts.ScriptArchData; import net.sf.gridarta.gui.About; import net.sf.gridarta.gui.HideFileFilterProxy; import net.sf.gridarta.gui.LeftPanel; @@ -469,7 +470,7 @@ final MapViewFactory<G, A, R, V> mapViewFactory = newMapViewFactory(faceObjects, selectedSquareView, this, mainView, editTypes, mapImageCache, toolPalette, filterControl); mapControlFactory.init(mapViewFactory, gameObjectParser, rendererFactory, mapActions, archetypeChooserModel, mapImageCache, autojoinLists, exitMatcher); copyBuffer.init(mapArchObjectFactory.newMapArchObject(false), mainView); - GameObject.initialize(archetypeSet, archetypeTypeSet, gameObjectMatchers, animationObjects, SystemIcons.getNofaceTileIcon()); + GameObject.initialize(archetypeSet, archetypeTypeSet, gameObjectMatchers, animationObjects, SystemIcons.getNofaceTileIcon(), newScriptArchData()); init4(gameObjectParser, archetypeParser, editTypes, faceObjects, animationObjects, mainView, globalSettings, archetypeSet); if (globalSettings.isAutoPopupDocu()) { @@ -506,6 +507,9 @@ } @NotNull + protected abstract ScriptArchData<G> newScriptArchData(); + + @NotNull protected abstract ArchetypeFactory<G, A, R> newArchetypeFactory(); @NotNull Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-10-15 18:02:39 UTC (rev 5532) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-10-15 18:26:35 UTC (rev 5533) @@ -204,9 +204,11 @@ /** Data for scripted events. */ @NotNull - protected ScriptArchData<G> scriptArchData; + private static ScriptArchData<?> scriptArchData; - /** Constructor. */ + /** + * Creates a new instance. + */ protected GameObject() { } @@ -218,13 +220,15 @@ * @param gameObjectMatchers the instance to use * @param animationObjects the animation objects to use * @param noFace the image icons for game objects having no face + * @param scriptArchData the script arch data instance to use */ - public static void initialize(@Nullable final ArchetypeSet<?, ?, ?> archetypeSet, final ArchetypeTypeSet archetypeTypeSet, final GameObjectMatchers gameObjectMatchers, @Nullable final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final ImageIcon noFace) { + public static void initialize(@Nullable final ArchetypeSet<?, ?, ?> archetypeSet, final ArchetypeTypeSet archetypeTypeSet, final GameObjectMatchers gameObjectMatchers, @Nullable final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final ImageIcon noFace, @NotNull final ScriptArchData<?> scriptArchData) { GameObject.archetypeSet = archetypeSet; GameObject.archetypeTypeSet = archetypeTypeSet; GameObject.gameObjectMatchers = gameObjectMatchers; GameObject.animationObjects = animationObjects; GameObject.noFace = noFace; + GameObject.scriptArchData = scriptArchData; } /** {@inheritDoc} */ @@ -1423,7 +1427,7 @@ * @param list the JList which displays all events for this arch */ public void addEventsToJList(@NotNull final JList list) { - scriptArchData.addEventsToJList(list, (G) this); + ((ScriptArchData<G>) scriptArchData).addEventsToJList(list, (G) this); } @@ -1447,9 +1451,9 @@ * @xxx this method knows things it should never know, it is evil! */ public void modifyEventScript(final int eventType, final int task, @NotNull final JList eventList, @NotNull final ScriptTab<G, A, R> mapanel, @NotNull final MapManager<?, ?, ?, ?> mapManager, @NotNull final Frame parent) { - scriptArchData.modifyEventScript(eventType, task, eventList, mapManager, parent, (G) this); + ((ScriptArchData<G>) scriptArchData).modifyEventScript(eventType, task, eventList, mapManager, parent, (G) this); - if (scriptArchData.isEmpty((G) this)) { + if (((ScriptArchData<G>) scriptArchData).isEmpty((G) this)) { mapanel.setScriptPanelButtonState(true, false, false, false); } } @@ -1464,11 +1468,11 @@ * @param parent the parent frame for the editor */ public void addEventScript(@NotNull final JList eventList, @NotNull final ScriptTab<G, A, R> mapanel, @NotNull final Frame parent) { - AbstractScriptArchEditor.addEventScript((G) this, scriptArchData, parent); + AbstractScriptArchEditor.addEventScript((G) this, (ScriptArchData<G>) scriptArchData, parent); - if (!scriptArchData.isEmpty((G) this)) { + if (!((ScriptArchData<G>) scriptArchData).isEmpty((G) this)) { mapanel.setScriptPanelButtonState(true, true, true, true); - scriptArchData.addEventsToJList(eventList, (G) this); + ((ScriptArchData<G>) scriptArchData).addEventsToJList(eventList, (G) this); } else { mapanel.setScriptPanelButtonState(true, false, false, false); } @@ -1699,7 +1703,7 @@ * insufficient ScriptedEvent objects get removed. */ public void validateAllEvents() { - scriptArchData.validateAllEvents((G) this); + ((ScriptArchData<G>) scriptArchData).validateAllEvents((G) this); } // face name This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-15 19:22:20
|
Revision: 5532 http://gridarta.svn.sourceforge.net/gridarta/?rev=5532&view=rev Author: akirschbaum Date: 2008-10-15 18:02:39 +0000 (Wed, 15 Oct 2008) Log Message: ----------- Remove ScriptArchData.owner/getOwner(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java trunk/src/app/net/sf/gridarta/gameobject/scripts/PathButtonListener.java trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptedEventEditor.java Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-10-15 17:15:51 UTC (rev 5531) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-10-15 18:02:39 UTC (rev 5532) @@ -49,7 +49,7 @@ private String loreText = ""; // lore text buffer public GameObject() { - scriptArchData = new ScriptArchData(this, "subtype", TYPE_EVENT_CONNECTOR); + scriptArchData = new ScriptArchData("subtype", TYPE_EVENT_CONNECTOR); } /** {@inheritDoc} */ @@ -121,7 +121,7 @@ clone.initMultiData(); } - clone.scriptArchData = new ScriptArchData(clone, "subtype", TYPE_EVENT_CONNECTOR); + clone.scriptArchData = new ScriptArchData("subtype", TYPE_EVENT_CONNECTOR); clone.setMapX(posx); clone.setMapY(posy); Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-10-15 17:15:51 UTC (rev 5531) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-10-15 18:02:39 UTC (rev 5532) @@ -37,12 +37,11 @@ /** * Create a ScriptArchData. - * @param owner owner of this ScriptArchData * @param subtypeAttribute the attribute name for the subtype field * @param eventTypeNo the object type for event objects */ - public ScriptArchData(final GameObject owner, @NotNull final String subtypeAttribute, final int eventTypeNo) { - super(owner, subtypeAttribute, eventTypeNo); + public ScriptArchData(@NotNull final String subtypeAttribute, final int eventTypeNo) { + super(subtypeAttribute, eventTypeNo); } /** {@inheritDoc} */ @@ -53,8 +52,8 @@ } /** {@inheritDoc} */ - public void createNewEvent(final JDialog frame) { - ScriptArchEditor.createNewEvent(frame, this, owner); + public void createNewEvent(final JDialog frame, @NotNull final GameObject gameObject) { + ScriptArchEditor.createNewEvent(frame, this, gameObject); } /** {@inheritDoc} */ Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java 2008-10-15 17:15:51 UTC (rev 5531) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java 2008-10-15 18:02:39 UTC (rev 5532) @@ -35,7 +35,7 @@ /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); - public static void createNewEvent(final JDialog frame, final ScriptArchData scriptArchData, @NotNull final GameObject owner) { + public static void createNewEvent(final JDialog frame, final ScriptArchData scriptArchData, @NotNull final GameObject gameObject) { String scriptPath = inputScriptPath.getText().trim(); final String options = inputOptions.getText().trim(); final int eventType = ScriptArchUtils.indexToEventType(eventTypeBox.getSelectedIndex()); @@ -44,7 +44,7 @@ final File localMapDir = mapManager.getLocalMapDir(); // first check if that event type is not already in use - final GameObject replaceObject = scriptArchData.getScriptedEvent(eventType); + final GameObject replaceObject = scriptArchData.getScriptedEvent(eventType, gameObject); if (replaceObject != null) { // collision with existing event -> ask user: replace? if (JOptionPane.showConfirmDialog(frame, "An event of type \"" + ScriptArchUtils.typeName(eventType) + "\" already exists for this object.\n" + "Do you want to replace the existing event?", "Event exists", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.NO_OPTION) { @@ -93,7 +93,7 @@ if (replaceObject != null) { replaceObject.remove(); } - owner.addLast(event.getEventArch()); + gameObject.addLast(event.getEventArch()); frame.setVisible(false); // close dialog } } else { @@ -128,7 +128,7 @@ if (replaceObject != null) { replaceObject.remove(); } - owner.addLast(event.getEventArch()); + gameObject.addLast(event.getEventArch()); frame.setVisible(false); // close dialog // open new script file Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-10-15 17:15:51 UTC (rev 5531) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-10-15 18:02:39 UTC (rev 5532) @@ -61,7 +61,7 @@ private ImageIcon transFace = noFace; public GameObject() { - scriptArchData = new ScriptArchData(this, "sub_type", TYPE_EVENT_OBJECT); + scriptArchData = new ScriptArchData("sub_type", TYPE_EVENT_OBJECT); } /** {@inheritDoc} */ @@ -175,7 +175,7 @@ clone.setMultiShapeID(getMultiShapeID()); } - clone.scriptArchData = new ScriptArchData(clone, "sub_type", TYPE_EVENT_OBJECT); + clone.scriptArchData = new ScriptArchData("sub_type", TYPE_EVENT_OBJECT); clone.setMapX(posx); clone.setMapY(posy); Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-10-15 17:15:51 UTC (rev 5531) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-10-15 18:02:39 UTC (rev 5532) @@ -37,12 +37,11 @@ /** * Create a ScriptArchData. - * @param owner owner of this ScriptArchData * @param subtypeAttribute the attribute name for the subtype field * @param eventTypeNo the object type for event objects */ - public ScriptArchData(final GameObject owner, @NotNull final String subtypeAttribute, final int eventTypeNo) { - super(owner, subtypeAttribute, eventTypeNo); + public ScriptArchData(@NotNull final String subtypeAttribute, final int eventTypeNo) { + super(subtypeAttribute, eventTypeNo); } /** {@inheritDoc} */ @@ -53,8 +52,8 @@ } /** {@inheritDoc} */ - public void createNewEvent(final JDialog frame) { - ScriptArchEditor.createNewEvent(frame, this, owner); + public void createNewEvent(final JDialog frame, @NotNull final GameObject gameObject) { + ScriptArchEditor.createNewEvent(frame, this, gameObject); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java 2008-10-15 17:15:51 UTC (rev 5531) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java 2008-10-15 18:02:39 UTC (rev 5532) @@ -35,7 +35,7 @@ /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); - public static void createNewEvent(final JDialog frame, final ScriptArchData scriptArchData, @NotNull final GameObject owner) { + public static void createNewEvent(final JDialog frame, final ScriptArchData scriptArchData, @NotNull final GameObject gameObject) { String scriptPath = inputScriptPath.getText().trim(); final String options = inputOptions.getText().trim(); final int eventType = ScriptArchUtils.indexToEventType(eventTypeBox.getSelectedIndex()); @@ -44,7 +44,7 @@ final File localMapDir = mapManager.getLocalMapDir(); // first check if that event type is not already in use - final GameObject replaceObject = scriptArchData.getScriptedEvent(eventType); + final GameObject replaceObject = scriptArchData.getScriptedEvent(eventType, gameObject); if (replaceObject != null) { // collision with existing event -> ask user: replace? if (JOptionPane.showConfirmDialog(frame, "An event of type \"" + ScriptArchUtils.typeName(eventType) + "\" already exists for this object.\n" + "Do you want to replace the existing event?", "Event exists", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.NO_OPTION) { @@ -93,7 +93,7 @@ if (replaceObject != null) { replaceObject.remove(); } - owner.addLast(event.getEventArch()); + gameObject.addLast(event.getEventArch()); frame.setVisible(false); // close dialog } } else { @@ -128,7 +128,7 @@ if (replaceObject != null) { replaceObject.remove(); } - owner.addLast(event.getEventArch()); + gameObject.addLast(event.getEventArch()); frame.setVisible(false); // close dialog // open new script file Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-10-15 17:15:51 UTC (rev 5531) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-10-15 18:02:39 UTC (rev 5532) @@ -1423,7 +1423,7 @@ * @param list the JList which displays all events for this arch */ public void addEventsToJList(@NotNull final JList list) { - scriptArchData.addEventsToJList(list); + scriptArchData.addEventsToJList(list, (G) this); } @@ -1447,9 +1447,9 @@ * @xxx this method knows things it should never know, it is evil! */ public void modifyEventScript(final int eventType, final int task, @NotNull final JList eventList, @NotNull final ScriptTab<G, A, R> mapanel, @NotNull final MapManager<?, ?, ?, ?> mapManager, @NotNull final Frame parent) { - scriptArchData.modifyEventScript(eventType, task, eventList, mapManager, parent); + scriptArchData.modifyEventScript(eventType, task, eventList, mapManager, parent, (G) this); - if (scriptArchData.isEmpty()) { + if (scriptArchData.isEmpty((G) this)) { mapanel.setScriptPanelButtonState(true, false, false, false); } } @@ -1466,9 +1466,9 @@ public void addEventScript(@NotNull final JList eventList, @NotNull final ScriptTab<G, A, R> mapanel, @NotNull final Frame parent) { AbstractScriptArchEditor.addEventScript((G) this, scriptArchData, parent); - if (!scriptArchData.isEmpty()) { + if (!scriptArchData.isEmpty((G) this)) { mapanel.setScriptPanelButtonState(true, true, true, true); - scriptArchData.addEventsToJList(eventList); + scriptArchData.addEventsToJList(eventList, (G) this); } else { mapanel.setScriptPanelButtonState(true, false, false, false); } @@ -1699,7 +1699,7 @@ * insufficient ScriptedEvent objects get removed. */ public void validateAllEvents() { - scriptArchData.validateAllEvents(); + scriptArchData.validateAllEvents((G) this); } // face name Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java 2008-10-15 17:15:51 UTC (rev 5531) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java 2008-10-15 18:02:39 UTC (rev 5532) @@ -196,12 +196,12 @@ mainPanel.add(Box.createVerticalStrut(10)); final JPanel line6 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JButton nsOkButton = new JButton("OK"); - nsOkListener = new PathButtonListener(true, newScriptFrame, scriptArchData); + nsOkListener = new PathButtonListener(true, newScriptFrame, scriptArchData, gameObject); nsOkButton.addActionListener(nsOkListener); line6.add(nsOkButton); final JButton cancelButton = new JButton("Cancel"); - cancelButton.addActionListener(new PathButtonListener(false, newScriptFrame, null)); + cancelButton.addActionListener(new PathButtonListener(false, newScriptFrame, null, null)); line6.add(cancelButton); mainPanel.add(line6); @@ -214,7 +214,7 @@ headingLabel.setText("New scripted event for \"" + archName + "\":"); inputScriptPath.setText(defScriptName); inputOptions.setText(""); - nsOkListener.setScriptArchData(scriptArchData); + nsOkListener.setScriptArchData(scriptArchData, gameObject); newScriptFrame.toFront(); newScriptFrame.setVisible(true); } Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/PathButtonListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/PathButtonListener.java 2008-10-15 17:15:51 UTC (rev 5531) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/PathButtonListener.java 2008-10-15 18:02:39 UTC (rev 5532) @@ -22,6 +22,8 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JDialog; +import net.sf.gridarta.gameobject.GameObject; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -29,45 +31,52 @@ * paths or create-new-event frame. * @author Andreas Kirschbaum */ -public final class PathButtonListener implements ActionListener { +public final class PathButtonListener<G extends GameObject<G, ?, ?>> implements ActionListener { private final JDialog frame; private final boolean isOkButton; /** The target event to script. */ - private ScriptedEvent<?> scriptedEvent; // target event + private ScriptedEvent<G> scriptedEvent; // target event /** The ScriptArchData to operate on. */ - private ScriptArchData<?> scriptArchData; + private ScriptArchData<G> scriptArchData; + /** The affected game object. */ + private G gameObject; + /** * Create a PathButtonListener. * @param isOkButton true for ok-buttons * @param frame frame this listener belongs to * @param scriptArchData this is only set for the ok-button of "create new" * frame, otherwise null + * @param gameObject the affected game object */ - public PathButtonListener(final boolean isOkButton, final JDialog frame, @Nullable final ScriptArchData<?> scriptArchData) { + public PathButtonListener(final boolean isOkButton, final JDialog frame, @Nullable final ScriptArchData<G> scriptArchData, @Nullable final G gameObject) { this.isOkButton = isOkButton; this.frame = frame; this.scriptArchData = scriptArchData; + this.gameObject = gameObject; } /** * Set the target event to script. * @param scriptedEvent new target event to script. */ - public void setTargetEvent(final ScriptedEvent<?> scriptedEvent) { + public void setTargetEvent(final ScriptedEvent<G> scriptedEvent) { this.scriptedEvent = scriptedEvent; } /** * Set the ScriptArchData to operate on. * @param scriptArchData ScriptArchData to operate on. + * @param gameObject the affected game object */ - public void setScriptArchData(final ScriptArchData<?> scriptArchData) { + public void setScriptArchData(final ScriptArchData<G> scriptArchData, @NotNull final G gameObject) { this.scriptArchData = scriptArchData; + this.gameObject = gameObject; } /** {@inheritDoc} */ @@ -78,7 +87,7 @@ if (isOkButton && scriptArchData != null) { // ok button for creating a new event/script - scriptArchData.createNewEvent(frame); + scriptArchData.createNewEvent(frame, gameObject); } else { frame.setVisible(false); // hide dialog } Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java 2008-10-15 17:15:51 UTC (rev 5531) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java 2008-10-15 18:02:39 UTC (rev 5532) @@ -49,11 +49,6 @@ private static final Logger log = Logger.getLogger(ScriptArchData.class); /** - * The owner of this script arch data instance. - */ - protected final G owner; - - /** * The attribute name for the subtype field. */ @NotNull @@ -66,12 +61,10 @@ /** * Create a ScriptArchData. - * @param owner owner of this ScriptArchData * @param subtypeAttribute the attribute name for the subtype field * @param eventTypeNo the object type for event objects */ - protected ScriptArchData(final G owner, @NotNull final String subtypeAttribute, final int eventTypeNo) { - this.owner = owner; + protected ScriptArchData(@NotNull final String subtypeAttribute, final int eventTypeNo) { this.subtypeAttribute = subtypeAttribute; this.eventTypeNo = eventTypeNo; } @@ -79,19 +72,21 @@ /** * The user has chosen to create a new event, now it is to be done. * @param frame the parent window of the create-new-event dialog + * @param gameObject the gameObject to operate on */ - public abstract void createNewEvent(final JDialog frame); + public abstract void createNewEvent(final JDialog frame, @NotNull final G gameObject); /** * Set all ScriptedEvents to appear in the given JList This method should be * fast because it may be executed when user clicks on map objects. * @param list JList + * @param gameObject the game object to operate on */ - public void addEventsToJList(final JList list) { + public void addEventsToJList(final JList list, @NotNull final G gameObject) { //cher: JList expects Vector, so we MUST use an obsolete concrete collection. //noinspection CollectionDeclaredAsConcreteClass,UseOfObsoleteCollectionType final Vector<String> content = new Vector<String>(); - for (final G tmp : owner) { + for (final G tmp : gameObject) { if (tmp.getTypeNo() == eventTypeNo) { content.add(" " + typeName(tmp.getAttributeInt(subtypeAttribute))); } @@ -113,12 +108,13 @@ * Search the owner game object for an event object of the specified event * type. * @param eventSubtype look for a ScriptedEvent of this type + * @param gameObject the game object to operate on * @return the event game object, or <code>null</code> if no event of this * type exists */ @Nullable - public G getScriptedEvent(final int eventSubtype) { - for (final G tmp : owner) { + public G getScriptedEvent(final int eventSubtype, @NotNull final G gameObject) { + for (final G tmp : gameObject) { if (tmp.getTypeNo() == eventTypeNo && tmp.getAttributeInt(subtypeAttribute) == eventSubtype) { return tmp; } @@ -131,9 +127,10 @@ * This method is called for each arch after loading a map. It checks * whether all events have enough data to be valid. Invalid or insufficient * ScriptedEvent objects get removed. + * @param gameObject the game object to operate on */ - public void validateAllEvents() { - final Iterator<G> it = owner.iterator(); + public void validateAllEvents(@NotNull final G gameObject) { + final Iterator<G> it = gameObject.iterator(); while (it.hasNext()) { final G tmp = it.next(); if (tmp.getTypeNo() == eventTypeNo) { @@ -153,11 +150,12 @@ /** * Returns whether this ScriptArchData is empty (contains no events). (Note * that empty ScriptArchData objects always are removed ASAP.) + * @param gameObject the game object to operate on * @return <code>true</code> if this ScriptArchData contains no events, * otherwise <code>false</code> */ - public boolean isEmpty() { - for (final G tmp : owner) { + public boolean isEmpty(@NotNull final G gameObject) { + for (final G tmp : gameObject) { if (tmp.getTypeNo() == eventTypeNo) { return false; } @@ -175,12 +173,13 @@ * the events * @param mapManager the map manager instance * @param parent the parent frame for dialog boxes + * @param gameObject the game object to operate on */ - public void modifyEventScript(int eventIndex, final int task, @NotNull final JList panelList, @NotNull final MapManager<?, ?, ?, ?> mapManager, @NotNull final Frame parent) { + public void modifyEventScript(int eventIndex, final int task, @NotNull final JList panelList, @NotNull final MapManager<?, ?, ?, ?> mapManager, @NotNull final Frame parent, @NotNull final G gameObject) { G oldEvent = null; /* Find the event object */ - for (final G tmp : owner) { + for (final G tmp : gameObject) { if (tmp.getTypeNo() == eventTypeNo) { if (eventIndex == 0) { oldEvent = tmp; @@ -203,7 +202,7 @@ if (JOptionPane.showConfirmDialog(panelList, "Are you sure you want to remove this \"" + typeName(event.getEventType()) + "\" event which is\n" + "linked to the script: '" + event.getScriptPath() + "'?\n" + "(The script file itself is not going to be deleted)", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { // remove this event from the GameObject oldEvent.remove(); - addEventsToJList(panelList); // update panel JList + addEventsToJList(panelList, gameObject); // update panel JList } } } else { Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptedEventEditor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptedEventEditor.java 2008-10-15 17:15:51 UTC (rev 5531) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptedEventEditor.java 2008-10-15 18:02:39 UTC (rev 5532) @@ -151,13 +151,13 @@ // button panel: final JPanel line4 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JButton okButton = new JButton("OK"); - okListener = new PathButtonListener(true, pathFrame, null); + okListener = new PathButtonListener(true, pathFrame, null, null); okListener.setTargetEvent(scriptedEvent); okButton.addActionListener(okListener); line4.add(okButton); final JButton cancelButton = new JButton("Cancel"); - cancelListener = new PathButtonListener(false, pathFrame, null); + cancelListener = new PathButtonListener(false, pathFrame, null, null); cancelListener.setTargetEvent(scriptedEvent); cancelButton.addActionListener(cancelListener); line4.add(cancelButton); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-15 22:11:15
|
Revision: 5531 http://gridarta.svn.sourceforge.net/gridarta/?rev=5531&view=rev Author: akirschbaum Date: 2008-10-15 17:15:51 +0000 (Wed, 15 Oct 2008) Log Message: ----------- Remove ScriptArchData.getOwner(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-10-14 18:47:37 UTC (rev 5530) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-10-15 17:15:51 UTC (rev 5531) @@ -54,7 +54,7 @@ /** {@inheritDoc} */ public void createNewEvent(final JDialog frame) { - ScriptArchEditor.createNewEvent(frame, this); + ScriptArchEditor.createNewEvent(frame, this, owner); } /** {@inheritDoc} */ Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java 2008-10-14 18:47:37 UTC (rev 5530) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java 2008-10-15 17:15:51 UTC (rev 5531) @@ -28,13 +28,14 @@ import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeException; import net.sf.gridarta.textedit.scripteditor.ScriptEditControlInstance; import net.sf.japi.swing.ActionFactory; +import org.jetbrains.annotations.NotNull; public class ScriptArchEditor extends AbstractScriptArchEditor { /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); - public static void createNewEvent(final JDialog frame, final ScriptArchData scriptArchData) { + public static void createNewEvent(final JDialog frame, final ScriptArchData scriptArchData, @NotNull final GameObject owner) { String scriptPath = inputScriptPath.getText().trim(); final String options = inputOptions.getText().trim(); final int eventType = ScriptArchUtils.indexToEventType(eventTypeBox.getSelectedIndex()); @@ -92,7 +93,7 @@ if (replaceObject != null) { replaceObject.remove(); } - scriptArchData.getOwner().addLast(event.getEventArch()); + owner.addLast(event.getEventArch()); frame.setVisible(false); // close dialog } } else { @@ -127,7 +128,7 @@ if (replaceObject != null) { replaceObject.remove(); } - scriptArchData.getOwner().addLast(event.getEventArch()); + owner.addLast(event.getEventArch()); frame.setVisible(false); // close dialog // open new script file Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-10-14 18:47:37 UTC (rev 5530) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-10-15 17:15:51 UTC (rev 5531) @@ -54,7 +54,7 @@ /** {@inheritDoc} */ public void createNewEvent(final JDialog frame) { - ScriptArchEditor.createNewEvent(frame, this); + ScriptArchEditor.createNewEvent(frame, this, owner); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java 2008-10-14 18:47:37 UTC (rev 5530) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java 2008-10-15 17:15:51 UTC (rev 5531) @@ -28,13 +28,14 @@ import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeException; import net.sf.gridarta.textedit.scripteditor.ScriptEditControlInstance; import net.sf.japi.swing.ActionFactory; +import org.jetbrains.annotations.NotNull; public class ScriptArchEditor extends AbstractScriptArchEditor { /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); - public static void createNewEvent(final JDialog frame, final ScriptArchData scriptArchData) { + public static void createNewEvent(final JDialog frame, final ScriptArchData scriptArchData, @NotNull final GameObject owner) { String scriptPath = inputScriptPath.getText().trim(); final String options = inputOptions.getText().trim(); final int eventType = ScriptArchUtils.indexToEventType(eventTypeBox.getSelectedIndex()); @@ -92,7 +93,7 @@ if (replaceObject != null) { replaceObject.remove(); } - scriptArchData.getOwner().addLast(event.getEventArch()); + owner.addLast(event.getEventArch()); frame.setVisible(false); // close dialog } } else { @@ -127,7 +128,7 @@ if (replaceObject != null) { replaceObject.remove(); } - scriptArchData.getOwner().addLast(event.getEventArch()); + owner.addLast(event.getEventArch()); frame.setVisible(false); // close dialog // open new script file Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java 2008-10-14 18:47:37 UTC (rev 5530) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java 2008-10-15 17:15:51 UTC (rev 5531) @@ -51,7 +51,7 @@ /** * The owner of this script arch data instance. */ - private final G owner; + protected final G owner; /** * The attribute name for the subtype field. @@ -110,14 +110,6 @@ protected abstract String typeName(final int attributeInt); /** - * Returns the owner of this script arch data instance. - * @return the owner - */ - public G getOwner() { - return owner; - } - - /** * Search the owner game object for an event object of the specified event * type. * @param eventSubtype look for a ScriptedEvent of this type This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-16 05:39:31
|
Revision: 5534 http://gridarta.svn.sourceforge.net/gridarta/?rev=5534&view=rev Author: akirschbaum Date: 2008-10-16 05:39:26 +0000 (Thu, 16 Oct 2008) Log Message: ----------- Convert utility class ScriptArchUtils to normal class. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchUtils.java trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchUtils.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchUtils.java trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchUtils.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-10-15 18:26:35 UTC (rev 5533) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-10-16 05:39:26 UTC (rev 5534) @@ -129,13 +129,20 @@ /** {@inheritDoc} */ @NotNull @Override - protected ScriptArchData newScriptArchData() { - return new ScriptArchData("subtype", Archetype.TYPE_EVENT_CONNECTOR); + protected ScriptArchUtils newScriptArchUtils() { + return new ScriptArchUtils(); } /** {@inheritDoc} */ @NotNull @Override + protected ScriptArchData newScriptArchData(@NotNull final net.sf.gridarta.gameobject.scripts.ScriptArchUtils scriptArchUtils) { + return new ScriptArchData(scriptArchUtils, "subtype", Archetype.TYPE_EVENT_CONNECTOR); + } + + /** {@inheritDoc} */ + @NotNull + @Override protected ArchetypeFactory<GameObject, MapArchObject, Archetype> newArchetypeFactory() { return new DefaultArchetypeFactory(); } @@ -219,13 +226,6 @@ /** {@inheritDoc} */ @NotNull @Override - protected JComboBox createEventTypeBox() { - return ScriptArchUtils.createEventTypeBox(); - } - - /** {@inheritDoc} */ - @NotNull - @Override protected CFTreasureListTree<GameObject, MapArchObject, Archetype> createTreasureListTree(@NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final Map<String, TreasureTreeNode> specialTreasureLists) { return new CFTreasureListTree<GameObject, MapArchObject, Archetype>(getMainView(), archetypeSet, specialTreasureLists, new TreasureLocation(globalSettings.getCollectedDirectory(), IGUIConstants.TREASURES_FILE) @@ -235,8 +235,8 @@ /** {@inheritDoc} */ @NotNull @Override - protected MapActions init1(@NotNull final MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final GlobalSettings globalSettings, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final GameObjectMatcher exitMatcher) { - archetypeTypeSet.getListTable().put("event", ScriptArchUtils.getEventTypes()); + protected MapActions init1(@NotNull final net.sf.gridarta.gameobject.scripts.ScriptArchUtils scriptArchUtils, @NotNull final MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final GlobalSettings globalSettings, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final GameObjectMatcher exitMatcher) { + archetypeTypeSet.getListTable().put("event", scriptArchUtils.getEventTypes()); final int[] directionMap = new int[] { CommonConstants.NORTH, CommonConstants.EAST, Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-10-15 18:26:35 UTC (rev 5533) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-10-16 05:39:26 UTC (rev 5534) @@ -21,6 +21,7 @@ import cfeditor.gameobject.GameObject; import javax.swing.JDialog; +import net.sf.gridarta.gameobject.scripts.ScriptArchUtils; import org.jetbrains.annotations.NotNull; /** @@ -36,19 +37,27 @@ private static final long serialVersionUID = 1L; /** + * The {@link ScriptArchUtils} instance to use. + */ + @NotNull + private final ScriptArchUtils scriptArchUtils; + + /** * Create a ScriptArchData. + * @param scriptArchUtils the script arch utils instance to use * @param subtypeAttribute the attribute name for the subtype field * @param eventTypeNo the object type for event objects */ - public ScriptArchData(@NotNull final String subtypeAttribute, final int eventTypeNo) { + public ScriptArchData(@NotNull final ScriptArchUtils scriptArchUtils, @NotNull final String subtypeAttribute, final int eventTypeNo) { super(subtypeAttribute, eventTypeNo); + this.scriptArchUtils = scriptArchUtils; } /** {@inheritDoc} */ @NotNull @Override protected ScriptedEvent newScriptedEvent(@NotNull final GameObject event, @NotNull final String subtypeAttribute) { - return new ScriptedEvent(event, subtypeAttribute); + return new ScriptedEvent(scriptArchUtils, event, subtypeAttribute); } /** {@inheritDoc} */ @@ -60,7 +69,7 @@ @NotNull @Override protected String typeName(final int attributeInt) { - return ScriptArchUtils.typeName(attributeInt); + return scriptArchUtils.typeName(attributeInt); } } // class ScriptArchData Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java 2008-10-15 18:26:35 UTC (rev 5533) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java 2008-10-16 05:39:26 UTC (rev 5534) @@ -38,7 +38,7 @@ public static void createNewEvent(final JDialog frame, final ScriptArchData scriptArchData, @NotNull final GameObject gameObject) { String scriptPath = inputScriptPath.getText().trim(); final String options = inputOptions.getText().trim(); - final int eventType = ScriptArchUtils.indexToEventType(eventTypeBox.getSelectedIndex()); + final int eventType = scriptArchUtils.indexToEventType(eventTypeBox.getSelectedIndex()); final String pluginName = ((String) pluginNameBox.getSelectedItem()).trim(); final File localMapDir = mapManager.getLocalMapDir(); @@ -47,7 +47,7 @@ final GameObject replaceObject = scriptArchData.getScriptedEvent(eventType, gameObject); if (replaceObject != null) { // collision with existing event -> ask user: replace? - if (JOptionPane.showConfirmDialog(frame, "An event of type \"" + ScriptArchUtils.typeName(eventType) + "\" already exists for this object.\n" + "Do you want to replace the existing event?", "Event exists", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.NO_OPTION) { + if (JOptionPane.showConfirmDialog(frame, "An event of type \"" + scriptArchUtils.typeName(eventType) + "\" already exists for this object.\n" + "Do you want to replace the existing event?", "Event exists", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.NO_OPTION) { // bail out return; } @@ -85,7 +85,7 @@ // file exists -> link it to the event final ScriptedEvent event; try { - event = new ScriptedEvent(eventType, "subtype", pluginName, scriptPath, options); + event = new ScriptedEvent(scriptArchUtils, eventType, "subtype", pluginName, scriptPath, options); } catch (final UndefinedEventArchetypeException ex) { JOptionPane.showMessageDialog(frame, "Cannot create event of type " + eventType + ":\n" + ex.getMessage() + ".", "Cannot create event", JOptionPane.ERROR_MESSAGE); return; @@ -120,7 +120,7 @@ // file has been created, now link it to the event final ScriptedEvent event; try { - event = new ScriptedEvent(eventType, "subtype", pluginName, scriptPath, options); + event = new ScriptedEvent(scriptArchUtils, eventType, "subtype", pluginName, scriptPath, options); } catch (final UndefinedEventArchetypeException ex) { JOptionPane.showMessageDialog(frame, "Cannot create event of type " + eventType + ":\n" + ex.getMessage() + ".", "Cannot create event", JOptionPane.ERROR_MESSAGE); return; Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchUtils.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchUtils.java 2008-10-15 18:26:35 UTC (rev 5533) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchUtils.java 2008-10-16 05:39:26 UTC (rev 5534) @@ -24,28 +24,29 @@ import java.util.List; import java.util.Map; import javax.swing.JComboBox; +import net.sf.gridarta.gameobject.scripts.AbstractScriptArchUtils; import net.sf.japi.util.Arrays2; import org.jetbrains.annotations.Nullable; -public class ScriptArchUtils { +public class ScriptArchUtils extends AbstractScriptArchUtils { /** * Maps event type to event name. */ - private static final Map<Integer, String> allEventTypes = new HashMap<Integer, String>(); + private final Map<Integer, String> allEventTypes = new HashMap<Integer, String>(); /** * Maps index into {@link #eventNames} to event type. */ - private static final Map<Integer, Integer> indexToEventType = new HashMap<Integer, Integer>(); + private final Map<Integer, Integer> indexToEventType = new HashMap<Integer, Integer>(); /** * All event names. */ - private static final List<String> eventNames = new ArrayList<String>(); + private final List<String> eventNames = new ArrayList<String>(); // FIXME: This should NOT BE HERE. Instead, it should be read from types.xml. - static { + { add(1, "apply"); add(2, "attack"); add(11, "close"); @@ -63,9 +64,9 @@ }; /** - * Private constructor to prevent instantiation. + * Creates a new instance. */ - private ScriptArchUtils() { + public ScriptArchUtils() { } /** @@ -73,48 +74,36 @@ * @param eventType the event type * @param eventName the event name */ - private static void add(final int eventType, final String eventName) { + private void add(final int eventType, final String eventName) { assert !allEventTypes.containsKey(eventType); allEventTypes.put(eventType, eventName); indexToEventType.put(eventNames.size(), eventType); eventNames.add(eventName); } - /** - * Return a human readable name for an event type. - * @param eventType the event type - * @return the event type name - */ - public static String typeName(final int eventType) { + /** {@inheritDoc} */ + public String typeName(final int eventType) { final String typeName = allEventTypes.get(eventType); return typeName != null ? typeName : "<invalid type>"; } - /** - * Return the archetype for an event type. - * @param eventType the event type - * @return the archetype name, or <code>null</code> if the event type is - * invalid - */ + /** {@inheritDoc} */ @Nullable - public static String getArchetypeNameForEventType(final int eventType) { + public String getArchetypeNameForEventType(final int eventType) { final String typeName = allEventTypes.get(eventType); return typeName != null ? "event_" + typeName : null; } - public static JComboBox createEventTypeBox() { + /** {@inheritDoc} */ + public JComboBox createEventTypeBox() { final String[] valuesArray = eventNames.toArray(new String[eventNames.size()]); final JComboBox eventTypeBox = new JComboBox(valuesArray); eventTypeBox.setSelectedIndex(Arrays2.linearEqualitySearch("say", valuesArray)); return eventTypeBox; } - /** - * Converts a combo box index to an event type. - * @param index the combo box index - * @return the event type - */ - public static int indexToEventType(final int index) { + /** {@inheritDoc} */ + public int indexToEventType(final int index) { try { return indexToEventType.get(index); } catch (final NullPointerException ex) { @@ -122,11 +111,8 @@ } } - /** - * Returns all event types. - * @return the event types - */ - public static List<?> getEventTypes() { + /** {@inheritDoc} */ + public List<?> getEventTypes() { final List<Object> result = new ArrayList<Object>(); for (final Map.Entry<Integer, String> e : allEventTypes.entrySet()) { result.add(e.getKey()); Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java 2008-10-15 18:26:35 UTC (rev 5533) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java 2008-10-16 05:39:26 UTC (rev 5534) @@ -23,6 +23,7 @@ import cfeditor.gameobject.GameObject; import net.sf.gridarta.gameobject.scripts.AbstractScriptedEvent; import net.sf.gridarta.gameobject.scripts.ScriptedEventEditor; +import net.sf.gridarta.gameobject.scripts.ScriptArchUtils; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeException; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeNameException; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeTypeException; @@ -34,6 +35,12 @@ */ public final class ScriptedEvent extends AbstractScriptedEvent<GameObject> { + /** + * The {@link ScriptArchUtils} instance to use. + */ + @NotNull + private final ScriptArchUtils scriptArchUtils; + /** The underlying game object that represents the event. */ private final GameObject event; @@ -44,17 +51,8 @@ private final String subtypeAttribute; /** - * Create a ScriptedEvent of given type (This is used for map-loading). - * @param event GameObject that describes the event. - * @param subtypeAttribute the attribute name for the subtype field - */ - ScriptedEvent(final GameObject event, @NotNull final String subtypeAttribute) { - this.event = event; - this.subtypeAttribute = subtypeAttribute; - } - - /** * Creates a fully initialized ScriptedEvent. + * @param scriptArchUtils the script arch utils instance to use * @param eventType type of the event * @param subtypeAttribute the attribute name for the subtype field * @param pluginName name of the plugin @@ -63,12 +61,25 @@ * @throws UndefinedEventArchetypeException In case there is no Archetype to * create a ScriptedEvent. */ - ScriptedEvent(final int eventType, @NotNull final String subtypeAttribute, final String pluginName, final String scriptPath, final String options) throws UndefinedEventArchetypeException { + ScriptedEvent(@NotNull final ScriptArchUtils scriptArchUtils, final int eventType, @NotNull final String subtypeAttribute, final String pluginName, final String scriptPath, final String options) throws UndefinedEventArchetypeException { + this.scriptArchUtils = scriptArchUtils; this.subtypeAttribute = subtypeAttribute; event = newEventGameObject(eventType); setEventData(pluginName, scriptPath, options); } + /** + * Create a ScriptedEvent of given type (This is used for map-loading). + * @param scriptArchUtils the script arch utils instance to use + * @param event GameObject that describes the event. + * @param subtypeAttribute the attribute name for the subtype field + */ + ScriptedEvent(@NotNull final ScriptArchUtils scriptArchUtils, final GameObject event, @NotNull final String subtypeAttribute) { + this.scriptArchUtils = scriptArchUtils; + this.event = event; + this.subtypeAttribute = subtypeAttribute; + } + /** {@inheritDoc} */ public void modifyEventPath() { final String newPath = ScriptedEventEditor.inputScriptPath.getText().trim(); @@ -123,7 +134,7 @@ @NotNull @Override protected String typeName(final int eventType) { - return ScriptArchUtils.typeName(eventType); + return scriptArchUtils.typeName(eventType); } /** {@inheritDoc} */ @@ -154,8 +165,8 @@ * @throws UndefinedEventArchetypeException if the event game object cannot * be created */ - private static GameObject newEventGameObject(final int eventType) throws UndefinedEventArchetypeException { - final String eventArchetypeName = ScriptArchUtils.getArchetypeNameForEventType(eventType); + private GameObject newEventGameObject(final int eventType) throws UndefinedEventArchetypeException { + final String eventArchetypeName = scriptArchUtils.getArchetypeNameForEventType(eventType); if (eventArchetypeName == null) { throw new UndefinedEventArchetypeTypeException(eventType); } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-10-15 18:26:35 UTC (rev 5533) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-10-16 05:39:26 UTC (rev 5534) @@ -47,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.regex.Pattern; -import javax.swing.JComboBox; import javax.swing.JOptionPane; import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.CommonConstants; @@ -174,13 +173,20 @@ /** {@inheritDoc} */ @NotNull @Override - protected ScriptArchData newScriptArchData() { - return new ScriptArchData("sub_type", Archetype.TYPE_EVENT_OBJECT); + protected ScriptArchUtils newScriptArchUtils() { + return new ScriptArchUtils(); } /** {@inheritDoc} */ @NotNull @Override + protected ScriptArchData newScriptArchData(@NotNull final net.sf.gridarta.gameobject.scripts.ScriptArchUtils scriptArchUtils) { + return new ScriptArchData(scriptArchUtils, "sub_type", Archetype.TYPE_EVENT_OBJECT); + } + + /** {@inheritDoc} */ + @NotNull + @Override protected ArchetypeFactory<GameObject, MapArchObject, Archetype> newArchetypeFactory() { return new DefaultArchetypeFactory(); } @@ -266,13 +272,6 @@ /** {@inheritDoc} */ @NotNull @Override - protected JComboBox createEventTypeBox() { - return ScriptArchUtils.createEventTypeBox(); - } - - /** {@inheritDoc} */ - @NotNull - @Override protected CFTreasureListTree<GameObject, MapArchObject, Archetype> createTreasureListTree(@NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final Map<String, TreasureTreeNode> specialTreasureLists) { return new CFTreasureListTree<GameObject, MapArchObject, Archetype>(getMainView(), archetypeSet, specialTreasureLists, new TreasureLocation(globalSettings.getCollectedDirectory(), IGUIConstants.TREASURES_FILE), @@ -283,7 +282,7 @@ /** {@inheritDoc} */ @NotNull @Override - protected MapActions init1(@NotNull final MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final GlobalSettings globalSettings, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final GameObjectMatcher exitMatcher) { + protected MapActions init1(@NotNull final net.sf.gridarta.gameobject.scripts.ScriptArchUtils scriptArchUtils, @NotNull final MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final GlobalSettings globalSettings, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final GameObjectMatcher exitMatcher) { final int[] directionMap = new int[] { CommonConstants.NORTH_EAST, CommonConstants.SOUTH_EAST, Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-10-15 18:26:35 UTC (rev 5533) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-10-16 05:39:26 UTC (rev 5534) @@ -21,6 +21,7 @@ import daieditor.gameobject.GameObject; import javax.swing.JDialog; +import net.sf.gridarta.gameobject.scripts.ScriptArchUtils; import org.jetbrains.annotations.NotNull; /** @@ -36,19 +37,27 @@ private static final long serialVersionUID = 1L; /** + * The {@link ScriptArchUtils} instance to use. + */ + @NotNull + private final ScriptArchUtils scriptArchUtils; + + /** * Create a ScriptArchData. + * @param scriptArchUtils the script arch utils instance to use * @param subtypeAttribute the attribute name for the subtype field * @param eventTypeNo the object type for event objects */ - public ScriptArchData(@NotNull final String subtypeAttribute, final int eventTypeNo) { + public ScriptArchData(@NotNull final ScriptArchUtils scriptArchUtils, @NotNull final String subtypeAttribute, final int eventTypeNo) { super(subtypeAttribute, eventTypeNo); + this.scriptArchUtils = scriptArchUtils; } /** {@inheritDoc} */ @NotNull @Override protected ScriptedEvent newScriptedEvent(@NotNull final GameObject event, @NotNull final String subtypeAttribute) { - return new ScriptedEvent(event, subtypeAttribute); + return new ScriptedEvent(scriptArchUtils, event, subtypeAttribute); } /** {@inheritDoc} */ @@ -60,7 +69,7 @@ @NotNull @Override protected String typeName(final int attributeInt) { - return ScriptArchUtils.typeName(attributeInt); + return scriptArchUtils.typeName(attributeInt); } } // class ScriptArchData Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java 2008-10-15 18:26:35 UTC (rev 5533) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java 2008-10-16 05:39:26 UTC (rev 5534) @@ -38,7 +38,7 @@ public static void createNewEvent(final JDialog frame, final ScriptArchData scriptArchData, @NotNull final GameObject gameObject) { String scriptPath = inputScriptPath.getText().trim(); final String options = inputOptions.getText().trim(); - final int eventType = ScriptArchUtils.indexToEventType(eventTypeBox.getSelectedIndex()); + final int eventType = scriptArchUtils.indexToEventType(eventTypeBox.getSelectedIndex()); final String pluginName = ((String) pluginNameBox.getSelectedItem()).trim(); final File localMapDir = mapManager.getLocalMapDir(); @@ -47,7 +47,7 @@ final GameObject replaceObject = scriptArchData.getScriptedEvent(eventType, gameObject); if (replaceObject != null) { // collision with existing event -> ask user: replace? - if (JOptionPane.showConfirmDialog(frame, "An event of type \"" + ScriptArchUtils.typeName(eventType) + "\" already exists for this object.\n" + "Do you want to replace the existing event?", "Event exists", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.NO_OPTION) { + if (JOptionPane.showConfirmDialog(frame, "An event of type \"" + scriptArchUtils.typeName(eventType) + "\" already exists for this object.\n" + "Do you want to replace the existing event?", "Event exists", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.NO_OPTION) { // bail out return; } @@ -85,7 +85,7 @@ // file exists -> link it to the event final ScriptedEvent event; try { - event = new ScriptedEvent(eventType, "sub_type", pluginName, scriptPath, options); + event = new ScriptedEvent(scriptArchUtils, eventType, "sub_type", pluginName, scriptPath, options); } catch (final UndefinedEventArchetypeException ex) { JOptionPane.showMessageDialog(frame, "Cannot create event of type " + eventType + ":\n" + ex.getMessage() + ".", "Cannot create event", JOptionPane.ERROR_MESSAGE); return; @@ -120,7 +120,7 @@ // file has been created, now link it to the event final ScriptedEvent event; try { - event = new ScriptedEvent(eventType, "sub_type", pluginName, scriptPath, options); + event = new ScriptedEvent(scriptArchUtils, eventType, "sub_type", pluginName, scriptPath, options); } catch (final UndefinedEventArchetypeException ex) { JOptionPane.showMessageDialog(frame, "Cannot create event of type " + eventType + ":\n" + ex.getMessage() + ".", "Cannot create event", JOptionPane.ERROR_MESSAGE); return; Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchUtils.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchUtils.java 2008-10-15 18:26:35 UTC (rev 5533) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchUtils.java 2008-10-16 05:39:26 UTC (rev 5534) @@ -24,28 +24,29 @@ import java.util.List; import java.util.Map; import javax.swing.JComboBox; +import net.sf.gridarta.gameobject.scripts.AbstractScriptArchUtils; import net.sf.japi.util.Arrays2; import org.jetbrains.annotations.Nullable; -public class ScriptArchUtils { +public class ScriptArchUtils extends AbstractScriptArchUtils { /** * Maps event type to event name. */ - private static final Map<Integer, String> allEventTypes = new HashMap<Integer, String>(); + private final Map<Integer, String> allEventTypes = new HashMap<Integer, String>(); /** * Maps index into {@link #eventNames} to event type. */ - private static final Map<Integer, Integer> indexToEventType = new HashMap<Integer, Integer>(); + private final Map<Integer, Integer> indexToEventType = new HashMap<Integer, Integer>(); /** * All event names. */ - private static final List<String> eventNames = new ArrayList<String>(); + private final List<String> eventNames = new ArrayList<String>(); // FIXME: This should NOT BE HERE. Instead, it should be read from types.xml. - static { + { add(1, "apply"); add(2, "attack"); add(3, "death"); @@ -62,9 +63,9 @@ } /** - * Private constructor to prevent instantiation. + * Creates a new instance. */ - private ScriptArchUtils() { + public ScriptArchUtils() { } /** @@ -72,47 +73,35 @@ * @param eventType the event type * @param eventName the event name */ - private static void add(final int eventType, final String eventName) { + private void add(final int eventType, final String eventName) { assert !allEventTypes.containsKey(eventType); allEventTypes.put(eventType, eventName); indexToEventType.put(eventNames.size(), eventType); eventNames.add(eventName); } - /** - * Return a human readable name for an event type. - * @param eventType the event type - * @return the event type name - */ - public static String typeName(final int eventType) { + /** {@inheritDoc} */ + public String typeName(final int eventType) { final String typeName = allEventTypes.get(eventType); return typeName != null ? typeName : "<invalid type>"; } - /** - * Return the archetype for an event type. - * @param eventType the event type - * @return the archetype name, or <code>null</code> if the event type is - * invalid - */ + /** {@inheritDoc} */ @Nullable - public static String getArchetypeNameForEventType(final int eventType) { + public String getArchetypeNameForEventType(final int eventType) { return "event_obj"; } - public static JComboBox createEventTypeBox() { + /** {@inheritDoc} */ + public JComboBox createEventTypeBox() { final String[] valuesArray = eventNames.toArray(new String[eventNames.size()]); final JComboBox eventTypeBox = new JComboBox(valuesArray); eventTypeBox.setSelectedIndex(Arrays2.linearEqualitySearch("say", valuesArray)); return eventTypeBox; } - /** - * Converts a combo box index to an event type. - * @param index the combo box index - * @return the event type - */ - public static int indexToEventType(final int index) { + /** {@inheritDoc} */ + public int indexToEventType(final int index) { try { return indexToEventType.get(index); } catch (final NullPointerException ex) { @@ -120,4 +109,14 @@ } } + /** {@inheritDoc} */ + public List<?> getEventTypes() { + final List<Object> result = new ArrayList<Object>(); + for (final Map.Entry<Integer, String> e : allEventTypes.entrySet()) { + result.add(e.getKey()); + result.add(e.getValue()); + } + return result; + } + } // class ScriptArchUtils Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java 2008-10-15 18:26:35 UTC (rev 5533) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java 2008-10-16 05:39:26 UTC (rev 5534) @@ -23,6 +23,7 @@ import daieditor.gameobject.GameObject; import net.sf.gridarta.gameobject.scripts.AbstractScriptedEvent; import net.sf.gridarta.gameobject.scripts.ScriptedEventEditor; +import net.sf.gridarta.gameobject.scripts.ScriptArchUtils; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeException; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeNameException; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeTypeException; @@ -34,6 +35,12 @@ */ public final class ScriptedEvent extends AbstractScriptedEvent<GameObject> { + /** + * The {@link ScriptArchUtils} instance to use. + */ + @NotNull + private final ScriptArchUtils scriptArchUtils; + /** The underlying game object that represents the event. */ private final GameObject event; @@ -45,16 +52,19 @@ /** * Create a ScriptedEvent of given type (This is used for map-loading). + * @param scriptArchUtils the script arch utils instance to use * @param event GameObject that describes the event. * @param subtypeAttribute the attribute name for the subtype field */ - ScriptedEvent(final GameObject event, @NotNull final String subtypeAttribute) { + ScriptedEvent(@NotNull final ScriptArchUtils scriptArchUtils, final GameObject event, @NotNull final String subtypeAttribute) { + this.scriptArchUtils = scriptArchUtils; this.event = event; this.subtypeAttribute = subtypeAttribute; } /** * Creates a fully initialized ScriptedEvent. + * @param scriptArchUtils the script arch utils instance to use * @param eventType type of the event * @param subtypeAttribute the attribute name for the subtype field * @param pluginName name of the plugin @@ -63,7 +73,8 @@ * @throws UndefinedEventArchetypeException In case there is no Archetype to * create a ScriptedEvent. */ - ScriptedEvent(final int eventType, @NotNull final String subtypeAttribute, final String pluginName, final String scriptPath, final String options) throws UndefinedEventArchetypeException { + ScriptedEvent(@NotNull final ScriptArchUtils scriptArchUtils, final int eventType, @NotNull final String subtypeAttribute, final String pluginName, final String scriptPath, final String options) throws UndefinedEventArchetypeException { + this.scriptArchUtils = scriptArchUtils; this.subtypeAttribute = subtypeAttribute; event = newEventGameObject(eventType); setEventData(pluginName, scriptPath, options); @@ -124,7 +135,7 @@ @NotNull @Override protected String typeName(final int eventType) { - return ScriptArchUtils.typeName(eventType); + return scriptArchUtils.typeName(eventType); } @@ -153,7 +164,7 @@ * be created */ private GameObject newEventGameObject(final int eventType) throws UndefinedEventArchetypeException { - final String eventArchetypeName = ScriptArchUtils.getArchetypeNameForEventType(eventType); + final String eventArchetypeName = scriptArchUtils.getArchetypeNameForEventType(eventType); if (eventArchetypeName == null) { throw new UndefinedEventArchetypeTypeException(eventType); } Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-10-15 18:26:35 UTC (rev 5533) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-10-16 05:39:26 UTC (rev 5534) @@ -60,8 +60,9 @@ import net.sf.gridarta.gameobject.match.NamedGameObjectMatcher; import net.sf.gridarta.gameobject.scripts.AbstractScriptArchEditor; import net.sf.gridarta.gameobject.scripts.AbstractScriptedEvent; +import net.sf.gridarta.gameobject.scripts.ScriptArchData; +import net.sf.gridarta.gameobject.scripts.ScriptArchUtils; import net.sf.gridarta.gameobject.scripts.ScriptedEventEditor; -import net.sf.gridarta.gameobject.scripts.ScriptArchData; import net.sf.gridarta.gui.About; import net.sf.gridarta.gui.HideFileFilterProxy; import net.sf.gridarta.gui.LeftPanel; @@ -423,7 +424,8 @@ log.fatal("GameObjectMatcher 'exit' does not exist"); throw new MissingResourceException("GameObjectMatcher 'exit' does not exist", null, null); } - final MapActions mapActions = init1(mapArchObjectParserFactory, mapArchObjectFactory, globalSettings, mapManager, mapViewManager, archetypeTypeSet, selectedSquareView, exitMatcher); + final ScriptArchUtils scriptArchUtils = newScriptArchUtils(); + final MapActions mapActions = init1(scriptArchUtils, mapArchObjectParserFactory, mapArchObjectFactory, globalSettings, mapManager, mapViewManager, archetypeTypeSet, selectedSquareView, exitMatcher); Map<String, TreasureTreeNode> specialTreasureLists; try { final Document specialTreasureListsDocument = xmlHelper.getDocumentBuilder().parse(IOUtils.getResourceURLAsString(globalSettings.getConfigurationDirectory(), "TreasureLists.xml")); @@ -445,7 +447,7 @@ } catch (final FileNotFoundException ex) { log.error("Cannot read " + CommonConstants.TYPEDEF_FILE + ": " + ex.getMessage()); } - AbstractScriptArchEditor.initEventTypeBoxes(scriptExtension, scriptName, createEventTypeBox(), scriptFileFilter, globalSettings, mapManager); + AbstractScriptArchEditor.initEventTypeBoxes(scriptArchUtils, scriptExtension, scriptName, scriptArchUtils.createEventTypeBox(), scriptFileFilter, globalSettings, mapManager); final LockedItemsControl<G, A, R, V> lockedItemsControl = new LockedItemsControl<G, A, R, V>(mapManager, mapViewManager, lockedItemsTypeNumbers); final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel = new GameObjectAttributesModel<G, A, R>(); gameObjectAttributesControl = new GameObjectAttributesControl<G, A, R, V>(gameObjectAttributesModel, gameObjectAttributesDialogFactory, objectChooser, archetypeTypeSet, mapManager, mapViewManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); @@ -470,7 +472,7 @@ final MapViewFactory<G, A, R, V> mapViewFactory = newMapViewFactory(faceObjects, selectedSquareView, this, mainView, editTypes, mapImageCache, toolPalette, filterControl); mapControlFactory.init(mapViewFactory, gameObjectParser, rendererFactory, mapActions, archetypeChooserModel, mapImageCache, autojoinLists, exitMatcher); copyBuffer.init(mapArchObjectFactory.newMapArchObject(false), mainView); - GameObject.initialize(archetypeSet, archetypeTypeSet, gameObjectMatchers, animationObjects, SystemIcons.getNofaceTileIcon(), newScriptArchData()); + GameObject.initialize(archetypeSet, archetypeTypeSet, gameObjectMatchers, animationObjects, SystemIcons.getNofaceTileIcon(), newScriptArchData(scriptArchUtils)); init4(gameObjectParser, archetypeParser, editTypes, faceObjects, animationObjects, mainView, globalSettings, archetypeSet); if (globalSettings.isAutoPopupDocu()) { @@ -507,9 +509,12 @@ } @NotNull - protected abstract ScriptArchData<G> newScriptArchData(); + protected abstract ScriptArchUtils newScriptArchUtils(); @NotNull + protected abstract ScriptArchData<G> newScriptArchData(@NotNull final ScriptArchUtils scriptArchUtils); + + @NotNull protected abstract ArchetypeFactory<G, A, R> newArchetypeFactory(); @NotNull @@ -541,13 +546,10 @@ protected abstract void createActions(); @NotNull - protected abstract JComboBox createEventTypeBox(); - - @NotNull protected abstract CFTreasureListTree<G, A, R> createTreasureListTree(@NotNull final GlobalSettings globalSettings, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull Map<String, TreasureTreeNode> specialTreasureLists); @NotNull - protected abstract MapActions init1(@NotNull final MapArchObjectParserFactory<A> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final GlobalSettings globalSettings, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager, @NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull final GameObjectMatcher exitMatcher); + protected abstract MapActions init1(@NotNull final ScriptArchUtils scriptArchUtils, @NotNull final MapArchObjectParserFactory<A> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final GlobalSettings globalSettings, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager, @NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull final GameObjectMatcher exitMatcher); protected abstract void init4(@NotNull final GameObjectParser<G, A, R> gameObjectParser, @NotNull final AbstractArchetypeParser<G, A, R> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, final MainView<G, A, R, V> mainView, @NotNull final GlobalSettings globalSettings, @NotNull final ArchetypeSet<G, A, R> archetypeSet); Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java 2008-10-15 18:26:35 UTC (rev 5533) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java 2008-10-16 05:39:26 UTC (rev 5534) @@ -45,6 +45,12 @@ public abstract class AbstractScriptArchEditor { + /** + * The {@link ScriptArchUtils} instance to use. + */ + @NotNull + protected static ScriptArchUtils scriptArchUtils; + /** The ending for scripts. */ protected static String scriptEnding; @@ -80,13 +86,15 @@ /** * Initialize the JComboBox with the event types. + * @param scriptArchUtils the script arch utils instance to use * @param scriptEnding the suffix for script files * @param name the default event type * @param eventTypeBox the <code>JComboBox</code> containing all event * types * @param mapManager the map manager instance to use */ - public static synchronized void initEventTypeBoxes(final String scriptEnding, final String name, final JComboBox eventTypeBox, @NotNull final FileFilter scriptFileFilter, @NotNull final GlobalSettings globalSettings, @NotNull final MapManager<?, ?, ?, ?> mapManager) { + public static synchronized void initEventTypeBoxes(@NotNull final ScriptArchUtils scriptArchUtils, final String scriptEnding, final String name, final JComboBox eventTypeBox, @NotNull final FileFilter scriptFileFilter, @NotNull final GlobalSettings globalSettings, @NotNull final MapManager<?, ?, ?, ?> mapManager) { + AbstractScriptArchEditor.scriptArchUtils = scriptArchUtils; AbstractScriptArchEditor.scriptEnding = scriptEnding; pluginNameBox = new JComboBox(new String[] {name}); Added: trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchUtils.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchUtils.java 2008-10-16 05:39:26 UTC (rev 5534) @@ -0,0 +1,30 @@ +/* + * 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.scripts; + +public abstract class AbstractScriptArchUtils implements ScriptArchUtils { + + /** + * Creates a new instance. + */ + protected AbstractScriptArchUtils() { + } + +} // class AbstractScriptArchUtils Property changes on: trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchUtils.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchUtils.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchUtils.java 2008-10-16 05:39:26 UTC (rev 5534) @@ -0,0 +1,59 @@ +/* + * 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.scripts; + +import java.util.List; +import javax.swing.JComboBox; +import org.jetbrains.annotations.Nullable; + +public interface ScriptArchUtils { + + /** + * Returns a human readable name for an event type. + * @param eventType the event type + * @return the event type name + */ + String typeName(int eventType); + + /** + * Returns the archetype for an event type. + * @param eventType the event type + * @return the archetype name, or <code>null</code> if the event type is + * invalid + */ + @Nullable + String getArchetypeNameForEventType(int eventType); + + JComboBox createEventTypeBox(); + + /** + * Converts a combo box index to an event type. + * @param index the combo box index + * @return the event type + */ + int indexToEventType(int index); + + /** + * Returns all event types. + * @return the event types + */ + List<?> getEventTypes(); + +} // interface ScriptArchUtils Property changes on: trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchUtils.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-16 05:47:20
|
Revision: 5535 http://gridarta.svn.sourceforge.net/gridarta/?rev=5535&view=rev Author: akirschbaum Date: 2008-10-16 05:47:10 +0000 (Thu, 16 Oct 2008) Log Message: ----------- Move most of ScriptArchUtils to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchUtils.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchUtils.java trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchUtils.java Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchUtils.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchUtils.java 2008-10-16 05:39:26 UTC (rev 5534) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchUtils.java 2008-10-16 05:47:10 UTC (rev 5535) @@ -19,47 +19,26 @@ package cfeditor.gameobject.scripts; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javax.swing.JComboBox; import net.sf.gridarta.gameobject.scripts.AbstractScriptArchUtils; -import net.sf.japi.util.Arrays2; import org.jetbrains.annotations.Nullable; public class ScriptArchUtils extends AbstractScriptArchUtils { - /** - * Maps event type to event name. - */ - private final Map<Integer, String> allEventTypes = new HashMap<Integer, String>(); - - /** - * Maps index into {@link #eventNames} to event type. - */ - private final Map<Integer, Integer> indexToEventType = new HashMap<Integer, Integer>(); - - /** - * All event names. - */ - private final List<String> eventNames = new ArrayList<String>(); - // FIXME: This should NOT BE HERE. Instead, it should be read from types.xml. { add(1, "apply"); add(2, "attack"); - add(11, "close"); add(3, "death"); - add(13, "destroy"); add(4, "drop"); add(5, "pickup"); add(6, "say"); add(7, "stop"); - add(9, "throw"); add(8, "time"); - add(12, "timer"); + add(9, "throw"); add(10, "trigger"); + add(11, "close"); + add(12, "timer"); + add(13, "destroy"); add(31, "user"); }; @@ -69,56 +48,11 @@ public ScriptArchUtils() { } - /** - * Adds on event description. - * @param eventType the event type - * @param eventName the event name - */ - private void add(final int eventType, final String eventName) { - assert !allEventTypes.containsKey(eventType); - allEventTypes.put(eventType, eventName); - indexToEventType.put(eventNames.size(), eventType); - eventNames.add(eventName); - } - /** {@inheritDoc} */ - public String typeName(final int eventType) { - final String typeName = allEventTypes.get(eventType); - return typeName != null ? typeName : "<invalid type>"; - } - - /** {@inheritDoc} */ @Nullable public String getArchetypeNameForEventType(final int eventType) { final String typeName = allEventTypes.get(eventType); return typeName != null ? "event_" + typeName : null; } - /** {@inheritDoc} */ - public JComboBox createEventTypeBox() { - final String[] valuesArray = eventNames.toArray(new String[eventNames.size()]); - final JComboBox eventTypeBox = new JComboBox(valuesArray); - eventTypeBox.setSelectedIndex(Arrays2.linearEqualitySearch("say", valuesArray)); - return eventTypeBox; - } - - /** {@inheritDoc} */ - public int indexToEventType(final int index) { - try { - return indexToEventType.get(index); - } catch (final NullPointerException ex) { - return 0; - } - } - - /** {@inheritDoc} */ - public List<?> getEventTypes() { - final List<Object> result = new ArrayList<Object>(); - for (final Map.Entry<Integer, String> e : allEventTypes.entrySet()) { - result.add(e.getKey()); - result.add(e.getValue()); - } - return result; - } - } // class ScriptArchUtils Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchUtils.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchUtils.java 2008-10-16 05:39:26 UTC (rev 5534) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchUtils.java 2008-10-16 05:47:10 UTC (rev 5535) @@ -19,32 +19,11 @@ package daieditor.gameobject.scripts; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javax.swing.JComboBox; import net.sf.gridarta.gameobject.scripts.AbstractScriptArchUtils; -import net.sf.japi.util.Arrays2; import org.jetbrains.annotations.Nullable; public class ScriptArchUtils extends AbstractScriptArchUtils { - /** - * Maps event type to event name. - */ - private final Map<Integer, String> allEventTypes = new HashMap<Integer, String>(); - - /** - * Maps index into {@link #eventNames} to event type. - */ - private final Map<Integer, Integer> indexToEventType = new HashMap<Integer, Integer>(); - - /** - * All event names. - */ - private final List<String> eventNames = new ArrayList<String>(); - // FIXME: This should NOT BE HERE. Instead, it should be read from types.xml. { add(1, "apply"); @@ -68,55 +47,10 @@ public ScriptArchUtils() { } - /** - * Adds on event description. - * @param eventType the event type - * @param eventName the event name - */ - private void add(final int eventType, final String eventName) { - assert !allEventTypes.containsKey(eventType); - allEventTypes.put(eventType, eventName); - indexToEventType.put(eventNames.size(), eventType); - eventNames.add(eventName); - } - /** {@inheritDoc} */ - public String typeName(final int eventType) { - final String typeName = allEventTypes.get(eventType); - return typeName != null ? typeName : "<invalid type>"; - } - - /** {@inheritDoc} */ @Nullable public String getArchetypeNameForEventType(final int eventType) { return "event_obj"; } - /** {@inheritDoc} */ - public JComboBox createEventTypeBox() { - final String[] valuesArray = eventNames.toArray(new String[eventNames.size()]); - final JComboBox eventTypeBox = new JComboBox(valuesArray); - eventTypeBox.setSelectedIndex(Arrays2.linearEqualitySearch("say", valuesArray)); - return eventTypeBox; - } - - /** {@inheritDoc} */ - public int indexToEventType(final int index) { - try { - return indexToEventType.get(index); - } catch (final NullPointerException ex) { - return 0; - } - } - - /** {@inheritDoc} */ - public List<?> getEventTypes() { - final List<Object> result = new ArrayList<Object>(); - for (final Map.Entry<Integer, String> e : allEventTypes.entrySet()) { - result.add(e.getKey()); - result.add(e.getValue()); - } - return result; - } - } // class ScriptArchUtils Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchUtils.java 2008-10-16 05:39:26 UTC (rev 5534) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchUtils.java 2008-10-16 05:47:10 UTC (rev 5535) @@ -19,12 +19,79 @@ package net.sf.gridarta.gameobject.scripts; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.swing.JComboBox; +import net.sf.japi.util.Arrays2; + public abstract class AbstractScriptArchUtils implements ScriptArchUtils { /** + * Maps event type to event name. + */ + protected final Map<Integer, String> allEventTypes = new HashMap<Integer, String>(); + + /** + * Maps index into {@link #eventNames} to event type. + */ + private final Map<Integer, Integer> indexToEventType = new HashMap<Integer, Integer>(); + + /** + * All event names. + */ + private final List<String> eventNames = new ArrayList<String>(); + + /** * Creates a new instance. */ protected AbstractScriptArchUtils() { } + /** + * Adds on event description. + * @param eventType the event type + * @param eventName the event name + */ + protected void add(final int eventType, final String eventName) { + assert !allEventTypes.containsKey(eventType); + allEventTypes.put(eventType, eventName); + indexToEventType.put(eventNames.size(), eventType); + eventNames.add(eventName); + } + + /** {@inheritDoc} */ + public String typeName(final int eventType) { + final String typeName = allEventTypes.get(eventType); + return typeName != null ? typeName : "<invalid type>"; + } + + /** {@inheritDoc} */ + public JComboBox createEventTypeBox() { + final String[] valuesArray = eventNames.toArray(new String[eventNames.size()]); + final JComboBox eventTypeBox = new JComboBox(valuesArray); + eventTypeBox.setSelectedIndex(Arrays2.linearEqualitySearch("say", valuesArray)); + return eventTypeBox; + } + + /** {@inheritDoc} */ + public int indexToEventType(final int index) { + try { + return indexToEventType.get(index); + } catch (final NullPointerException ex) { + return 0; + } + } + + /** {@inheritDoc} */ + public List<?> getEventTypes() { + final List<Object> result = new ArrayList<Object>(); + for (final Map.Entry<Integer, String> e : allEventTypes.entrySet()) { + result.add(e.getKey()); + result.add(e.getValue()); + } + return result; + } + } // class AbstractScriptArchUtils This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-16 16:09:51
|
Revision: 5536 http://gridarta.svn.sourceforge.net/gridarta/?rev=5536&view=rev Author: akirschbaum Date: 2008-10-16 16:09:40 +0000 (Thu, 16 Oct 2008) Log Message: ----------- Move initializer block to constructor. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchUtils.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchUtils.java Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchUtils.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchUtils.java 2008-10-16 05:47:10 UTC (rev 5535) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchUtils.java 2008-10-16 16:09:40 UTC (rev 5536) @@ -24,8 +24,11 @@ public class ScriptArchUtils extends AbstractScriptArchUtils { - // FIXME: This should NOT BE HERE. Instead, it should be read from types.xml. - { + /** + * Creates a new instance. + */ + public ScriptArchUtils() { + // FIXME: This should NOT BE HERE. Instead, it should be read from types.xml. add(1, "apply"); add(2, "attack"); add(3, "death"); @@ -40,12 +43,6 @@ add(12, "timer"); add(13, "destroy"); add(31, "user"); - }; - - /** - * Creates a new instance. - */ - public ScriptArchUtils() { } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchUtils.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchUtils.java 2008-10-16 05:47:10 UTC (rev 5535) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchUtils.java 2008-10-16 16:09:40 UTC (rev 5536) @@ -24,8 +24,11 @@ public class ScriptArchUtils extends AbstractScriptArchUtils { - // FIXME: This should NOT BE HERE. Instead, it should be read from types.xml. - { + /** + * Creates a new instance. + */ + public ScriptArchUtils() { + // FIXME: This should NOT BE HERE. Instead, it should be read from types.xml. add(1, "apply"); add(2, "attack"); add(3, "death"); @@ -41,12 +44,6 @@ add(13, "talk"); } - /** - * Creates a new instance. - */ - public ScriptArchUtils() { - } - /** {@inheritDoc} */ @Nullable public String getArchetypeNameForEventType(final int eventType) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-16 16:43:07
|
Revision: 5537 http://gridarta.svn.sourceforge.net/gridarta/?rev=5537&view=rev Author: akirschbaum Date: 2008-10-16 16:43:03 +0000 (Thu, 16 Oct 2008) Log Message: ----------- Order import statements. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-10-16 16:09:40 UTC (rev 5536) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-10-16 16:43:03 UTC (rev 5537) @@ -43,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.regex.Pattern; -import javax.swing.JComboBox; import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.CommonConstants; import net.sf.gridarta.EditTypes; Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java 2008-10-16 16:09:40 UTC (rev 5536) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java 2008-10-16 16:43:03 UTC (rev 5537) @@ -22,8 +22,8 @@ import cfeditor.gameobject.Archetype; import cfeditor.gameobject.GameObject; import net.sf.gridarta.gameobject.scripts.AbstractScriptedEvent; +import net.sf.gridarta.gameobject.scripts.ScriptArchUtils; import net.sf.gridarta.gameobject.scripts.ScriptedEventEditor; -import net.sf.gridarta.gameobject.scripts.ScriptArchUtils; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeException; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeNameException; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeTypeException; Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java 2008-10-16 16:09:40 UTC (rev 5536) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java 2008-10-16 16:43:03 UTC (rev 5537) @@ -22,8 +22,8 @@ import daieditor.gameobject.Archetype; import daieditor.gameobject.GameObject; import net.sf.gridarta.gameobject.scripts.AbstractScriptedEvent; +import net.sf.gridarta.gameobject.scripts.ScriptArchUtils; import net.sf.gridarta.gameobject.scripts.ScriptedEventEditor; -import net.sf.gridarta.gameobject.scripts.ScriptArchUtils; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeException; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeNameException; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeTypeException; Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-10-16 16:09:40 UTC (rev 5536) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-10-16 16:43:03 UTC (rev 5537) @@ -32,7 +32,6 @@ import java.util.ResourceBundle; import java.util.prefs.Preferences; import javax.swing.ImageIcon; -import javax.swing.JComboBox; import javax.swing.JFileChooser; import javax.swing.JMenu; import javax.swing.JOptionPane; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |