From: <aki...@us...> - 2008-08-15 22:11:51
|
Revision: 4870 http://gridarta.svn.sourceforge.net/gridarta/?rev=4870&view=rev Author: akirschbaum Date: 2008-08-15 22:11:57 +0000 (Fri, 15 Aug 2008) Log Message: ----------- Move code to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObject.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gameobject/anim/AnimationObject.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObject.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-15 21:40:56 UTC (rev 4869) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-15 22:11:57 UTC (rev 4870) @@ -24,7 +24,7 @@ import cfeditor.gameobject.ArchetypeParser; import cfeditor.gameobject.ArchetypeSet; import cfeditor.gameobject.GameObject; -import cfeditor.gameobject.anim.AnimationObject; +import cfeditor.gameobject.anim.AnimationObjects; import cfeditor.gameobject.face.FaceObjects; import cfeditor.gameobject.scripts.ScriptArchUtils; import cfeditor.gameobject.scripts.ScriptedEvent; @@ -59,7 +59,6 @@ import net.sf.gridarta.archtype.ArchetypeTypeParser; import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.archtype.ArchetypeTypeSetParser; -import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gameobject.match.GameObjectMatchers; import net.sf.gridarta.gameobject.match.GameObjectMatchersInstance; @@ -214,8 +213,7 @@ * @throws RuntimeException If the controller cannot be initialized. */ public CMainControl() { - super(new CrossfireObjectsFactory(), "cfeditor", new GlobalSettingsImpl()); - final AnimationObjects<AnimationObject> animationObjects = new cfeditor.gameobject.anim.AnimationObjects(); + super(new CrossfireObjectsFactory(), "cfeditor", new GlobalSettingsImpl(), new AnimationObjects()); final ArchetypeSet archetypeSet = new ArchetypeSet(this, globalSettings, editTypes, animationObjects, faceObjects, ((GlobalSettingsImpl) globalSettings).getImageSet(), gridartaObjectsFactory); ScriptedEvent.setArchetypeSet(archetypeSet); final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, MainView.MAP_TILE_LIST_BOTTOM_DEFAULT); Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-08-15 21:40:56 UTC (rev 4869) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-08-15 22:11:57 UTC (rev 4870) @@ -21,7 +21,6 @@ import cfeditor.CMainControl; import cfeditor.IGUIConstants; -import cfeditor.gameobject.anim.AnimationObject; import cfeditor.gui.map.CMapViewBasic; import cfeditor.map.MapArchObject; import java.io.BufferedReader; @@ -42,6 +41,7 @@ import net.sf.gridarta.GridartaObjectsFactory; import net.sf.gridarta.gameobject.AbstractArchetypeParser; import net.sf.gridarta.gameobject.AbstractArchetypeSet; +import net.sf.gridarta.gameobject.anim.AnimationObject; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.anim.AnimationParseException; import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; @@ -81,7 +81,7 @@ private final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes; @NotNull - private final AnimationObjects<AnimationObject> animationObjects; + private final AnimationObjects<? extends AnimationObject> animationObjects; /** The FaceObjects instance to use. */ @NotNull @@ -104,7 +104,7 @@ * @param gridartaObjectsFactory the gridarta objects factory instance to * use */ - public ArchetypeSet(@NotNull final CMainControl mainControl, @NotNull final GlobalSettings globalSettings, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final AnimationObjects<AnimationObject> animationObjects, @NotNull final FaceObjects faceObjects, @Nullable final String imageSet, @NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory) { + public ArchetypeSet(@NotNull final CMainControl mainControl, @NotNull final GlobalSettings globalSettings, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final FaceObjects faceObjects, @Nullable final String imageSet, @NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory) { super(gridartaObjectsFactory); this.mainControl = mainControl; this.globalSettings = globalSettings; Modified: trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObject.java 2008-08-15 21:40:56 UTC (rev 4869) +++ trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObject.java 2008-08-15 22:11:57 UTC (rev 4870) @@ -56,4 +56,9 @@ return null; // TODO } + /** {@inheritDoc} */ + public String getFirstFrame(final int facing) { + return null; + } + } // class AnimationObject Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-08-15 21:40:56 UTC (rev 4869) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-08-15 22:11:57 UTC (rev 4870) @@ -23,7 +23,7 @@ import daieditor.gameobject.ArchetypeParser; import daieditor.gameobject.ArchetypeSet; import daieditor.gameobject.GameObject; -import daieditor.gameobject.anim.AnimationObject; +import daieditor.gameobject.anim.AnimationObjects; import daieditor.gameobject.face.FaceObjects; import daieditor.gameobject.scripts.ScriptArchUtils; import daieditor.gameobject.scripts.ScriptedEvent; @@ -64,7 +64,6 @@ import net.sf.gridarta.archtype.ArchetypeTypeParser; import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.archtype.ArchetypeTypeSetParser; -import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.face.FaceObjectProviders; import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gameobject.match.GameObjectMatchers; @@ -269,8 +268,7 @@ * @throws RuntimeException If the controller cannot be initialized. */ public CMainControl() { - super(new DaimoninObjectsFactory(), "daieditor", new GlobalSettingsImpl()); - final AnimationObjects<AnimationObject> animationObjects = new daieditor.gameobject.anim.AnimationObjects(); + super(new DaimoninObjectsFactory(), "daieditor", new GlobalSettingsImpl(), new AnimationObjects()); final ArchetypeSet archetypeSet = new ArchetypeSet(this, globalSettings, editTypes, animationObjects, faceObjects, gridartaObjectsFactory); GameObject.setArchetypeSet(archetypeSet); ScriptedEvent.setArchetypeSet(archetypeSet); Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-08-15 21:40:56 UTC (rev 4869) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-08-15 22:11:57 UTC (rev 4870) @@ -21,7 +21,6 @@ import daieditor.CMainControl; import daieditor.IGUIConstants; -import daieditor.gameobject.anim.AnimationObject; import daieditor.gui.map.CMapViewBasic; import daieditor.map.MapArchObject; import java.io.BufferedReader; @@ -43,6 +42,7 @@ import net.sf.gridarta.GridartaObjectsFactory; import net.sf.gridarta.gameobject.AbstractArchetypeParser; import net.sf.gridarta.gameobject.AbstractArchetypeSet; +import net.sf.gridarta.gameobject.anim.AnimationObject; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.anim.AnimationParseException; import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; @@ -85,7 +85,7 @@ private final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes; @NotNull - private final AnimationObjects<AnimationObject> animationObjects; + private final AnimationObjects<? extends AnimationObject> animationObjects; /** The FaceObjects instance to use. */ @NotNull @@ -108,7 +108,7 @@ * @param gridartaObjectsFactory the gridarta objects factory instance to * use */ - public ArchetypeSet(@NotNull final CMainControl mainControl, @NotNull final GlobalSettings globalSettings, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final AnimationObjects<AnimationObject> animationObjects, @NotNull final FaceObjects faceObjects, @NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory) { + public ArchetypeSet(@NotNull final CMainControl mainControl, @NotNull final GlobalSettings globalSettings, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final FaceObjects faceObjects, @NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory) { super(gridartaObjectsFactory); this.mainControl = mainControl; this.globalSettings = globalSettings; Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-08-15 21:40:56 UTC (rev 4869) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-08-15 22:11:57 UTC (rev 4870) @@ -19,13 +19,13 @@ package daieditor.gameobject; -import daieditor.gameobject.anim.AnimationObject; import daieditor.gameobject.scripts.ScriptArchData; import daieditor.map.MapArchObject; import java.awt.Frame; import javax.swing.ImageIcon; import javax.swing.JList; import net.sf.gridarta.MapManager; +import net.sf.gridarta.gameobject.anim.AnimationObject; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.scripts.AbstractScriptArchEditor; import net.sf.gridarta.gui.gameobjectattributespanel.ScriptTab; @@ -54,7 +54,7 @@ private static final long serialVersionUID = 1; @Nullable - private static AnimationObjects<AnimationObject> animationObjects = null; + private static AnimationObjects<? extends AnimationObject> animationObjects = null; /** * Face name, can be from animation or face. This is determined by taking @@ -98,7 +98,7 @@ @Nullable private static ImageIcon noFace = null; - public static void setAnimationObjects(@Nullable final AnimationObjects<AnimationObject> animationObjects, @NotNull final ImageIcon noFace) { + public static void setAnimationObjects(@Nullable final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final ImageIcon noFace) { GameObject.animationObjects = animationObjects; GameObject.noFace = noFace; } Modified: trunk/daimonin/src/daieditor/gameobject/anim/AnimationObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/anim/AnimationObject.java 2008-08-15 21:40:56 UTC (rev 4869) +++ trunk/daimonin/src/daieditor/gameobject/anim/AnimationObject.java 2008-08-15 22:11:57 UTC (rev 4870) @@ -95,11 +95,7 @@ return frameCount; } - /** - * Get the first frame. - * @param facing facing to get frame for, usually a direction - * @return frame - */ + /** {@inheritDoc} */ public String getFirstFrame(final int facing) { return getFrame(facing, 0); } Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-08-15 21:40:56 UTC (rev 4869) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-08-15 22:11:57 UTC (rev 4870) @@ -29,6 +29,8 @@ import javax.swing.filechooser.FileFilter; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gameobject.anim.AnimationObject; +import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.scripts.ScriptedEventEditor; import net.sf.gridarta.gui.HideFileFilterProxy; import net.sf.gridarta.gui.StatusBar; @@ -94,6 +96,12 @@ /** The map manager. */ protected final MapManager<G, A, R, V> mapManager; + /** + * The animation objects instance. + */ + @NotNull + protected final AnimationObjects<? extends AnimationObject> animationObjects; + /** The updater instance. */ protected UpdaterManager updaterManager = null; @@ -106,12 +114,13 @@ * @param key The action factory key * @param globalSettings the global settings instance */ - protected AbstractMainControl(@NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull final String key, @NotNull final GlobalSettings globalSettings) { + protected AbstractMainControl(@NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull final String key, @NotNull final GlobalSettings globalSettings, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects) { this.globalSettings = globalSettings; final DefaultMapManager<G, A, R, V> tmpMapManager = new DefaultMapManager<G, A, R, V>(this, key, gridartaObjectsFactory, globalSettings, autojoinLists); editTypes = new EditTypes<G, A, R, V>(tmpMapManager); tmpMapManager.setEditTypes(editTypes); mapManager = tmpMapManager; + this.animationObjects = animationObjects; copyBuffer = new CopyBuffer<G, A, R, V>(this, editTypes, gridartaObjectsFactory, autojoinLists); this.gridartaObjectsFactory = gridartaObjectsFactory; globalSettings.readGlobalSettings(); Modified: trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObject.java 2008-08-15 21:40:56 UTC (rev 4869) +++ trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObject.java 2008-08-15 22:11:57 UTC (rev 4870) @@ -49,4 +49,11 @@ */ int getFacings(); + /** + * Get the first frame. + * @param facing facing to get frame for, usually a direction + * @return frame + */ + String getFirstFrame(int facing); + } // interface AnimationObject Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-08-15 21:40:56 UTC (rev 4869) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-08-15 22:11:57 UTC (rev 4870) @@ -25,6 +25,8 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.io.Reader; +import java.util.Iterator; import java.util.List; import java.util.SortedSet; import java.util.TreeSet; @@ -43,12 +45,18 @@ import net.sf.gridarta.MapImageCache; import net.sf.gridarta.MapManager; import net.sf.gridarta.Size2D; +import net.sf.gridarta.data.NamedTreeNode; import net.sf.gridarta.gameobject.AbstractArchetypeParser; import net.sf.gridarta.gameobject.AbstractArchetypeSet; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.ArchetypeParser; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gameobject.anim.AbstractAnimationObject; +import net.sf.gridarta.gameobject.anim.AnimationObject; +import net.sf.gridarta.gameobject.anim.AnimationObjects; +import net.sf.gridarta.gameobject.anim.AnimationParseException; +import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.MainView; @@ -382,7 +390,8 @@ public void setUp() { gridartaObjectsFactory = new TestGridartaObjectsFactory(); final GlobalSettings globalSettings = new TestGlobalSettings(); - final TestMainControl mainControl = new TestMainControl(gridartaObjectsFactory, "test", globalSettings); + final AnimationObjects<TestAnimationObject> animationObjects = new TestAnimationObjects(); + final TestMainControl mainControl = new TestMainControl(gridartaObjectsFactory, "test", globalSettings, animationObjects); final TestMapArchObject mapArchObject = new TestMapArchObject(); final TestArchetypeSet archetypeSet = new TestArchetypeSet(gridartaObjectsFactory); final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> archetypeChooserModel = new ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(archetypeSet); @@ -408,9 +417,10 @@ * @param gridartaObjectsFactory the gridaarta objects factory to use * @param key the action factory key to use * @param globalSettings the global settings instance to use + * @param animationObjects the animation objects instance to use */ - protected TestMainControl(@NotNull final GridartaObjectsFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> gridartaObjectsFactory, @NotNull final String key, @NotNull final GlobalSettings globalSettings) { - super(gridartaObjectsFactory, key, globalSettings); + protected TestMainControl(@NotNull final GridartaObjectsFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> gridartaObjectsFactory, @NotNull final String key, @NotNull final GlobalSettings globalSettings, @NotNull final AnimationObjects<TestAnimationObject> animationObjects) { + super(gridartaObjectsFactory, key, globalSettings, animationObjects); } /** {@inheritDoc} */ @@ -944,4 +954,104 @@ } + /** + * An {@link AnimationObject} implementation for testing purposes. + */ + private static class TestAnimationObject extends AbstractAnimationObject { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1; + + /** + * Creates a new instance. + * @param animName name of the animation + * @param animList list of animations + * @param path the path + */ + protected TestAnimationObject(final String animName, final String animList, final String path) { + super(animName, animList, path); + } + + /** {@inheritDoc} */ + @Nullable + public ImageIcon getDisplayIcon() { + throw new AssertionError(); + } + + /** {@inheritDoc} */ + public String getFirstFrame(final int facing) { + throw new AssertionError(); + } + + } + + /** + * An {@link AnimationObjects} implementation for testing purposes. + */ + private static class TestAnimationObjects implements AnimationObjects<TestAnimationObject> { + + /** {@inheritDoc} */ + public void addAnimationObject(final String animName, final String list) throws DuplicateAnimationException { + throw new AssertionError(); + } + + /** {@inheritDoc} */ + public void addAnimPath(final String name, final String path) { + throw new AssertionError(); + } + + /** {@inheritDoc} */ + public void loadAnims(final File animFile, @NotNull final String startKey, final boolean ignoreOtherText) throws FileNotFoundException, IOException, AnimationParseException, DuplicateAnimationException { + throw new AssertionError(); + } + + /** {@inheritDoc} */ + public void loadAnims(final Reader reader, @NotNull final String startKey, final boolean ignoreOtherText, @Nullable final String path) throws IOException, AnimationParseException, DuplicateAnimationException { + throw new AssertionError(); + } + + /** {@inheritDoc} */ + public void loadAnimTree(final File animTreeFile) throws FileNotFoundException, IOException { + throw new AssertionError(); + } + + /** {@inheritDoc} */ + public void collect(@NotNull final Progress progress, @NotNull final File dir) throws IOException { + throw new AssertionError(); + } + + /** {@inheritDoc} */ + public NamedTreeNode<TestAnimationObject> getTreeRoot() { + throw new AssertionError(); + } + + /** {@inheritDoc} */ + public int size() { + throw new AssertionError(); + } + + /** {@inheritDoc} */ + public TestAnimationObject get(final String objectName) { + throw new AssertionError(); + } + + /** {@inheritDoc} */ + public boolean containsKey(final String name) { + throw new AssertionError(); + } + + /** {@inheritDoc} */ + public Iterator<TestAnimationObject> iterator() { + throw new AssertionError(); + } + + /** {@inheritDoc} */ + public String showNodeChooserDialog(final Component parentComponent, final String initial) { + throw new AssertionError(); + } + + } + } // class DefaultMapModelTest This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |