From: <aki...@us...> - 2008-08-21 21:39:56
|
Revision: 4967 http://gridarta.svn.sourceforge.net/gridarta/?rev=4967&view=rev Author: akirschbaum Date: 2008-08-21 21:39:46 +0000 (Thu, 21 Aug 2008) Log Message: ----------- Move code to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/AbstractMainControl.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-21 21:33:04 UTC (rev 4966) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-21 21:39:46 UTC (rev 4967) @@ -92,8 +92,6 @@ import net.sf.gridarta.map.validation.checks.MapDifficultyChecker; import net.sf.gridarta.map.validation.checks.UndefinedArchetypeChecker; import net.sf.gridarta.map.validation.checks.UnsetSlayingChecker; -import net.sf.gridarta.spells.ArchetypeSetSpellLoader; -import net.sf.gridarta.spells.GameObjectSpell; import net.sf.gridarta.spells.NumberSpell; import net.sf.gridarta.spells.Spells; import net.sf.gridarta.textedit.scripteditor.ScriptEditControlInstance; @@ -136,9 +134,6 @@ /** The Spells. */ private final Spells<NumberSpell> numberSpells = new Spells<NumberSpell>(); - /** The Spells. */ - private final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells = new Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>>(); - /** The current script controller. */ private final ScriptController scriptControl; @@ -163,11 +158,9 @@ * @throws RuntimeException If the controller cannot be initialized. */ public CMainControl(@NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory) { - super(gridartaObjectsFactory, new DefaultRendererFactory(), "cfeditor", new GlobalSettingsImpl(), new AnimationObjects(), new FaceObjects(), new DefaultMapControlFactory(gridartaObjectsFactory), false, CResourceLoader.getHomeFile("thumbnails"), null, "DaimoninEditor.jar", pythonFileFilter, ".py"); + super(gridartaObjectsFactory, new DefaultRendererFactory(), "cfeditor", new GlobalSettingsImpl(), new AnimationObjects(), new FaceObjects(), new DefaultMapControlFactory(gridartaObjectsFactory), false, CResourceLoader.getHomeFile("thumbnails"), null, "DaimoninEditor.jar", pythonFileFilter, ".py", Archetype.TYPE_SPELL); // load the list with archtype-data from "types.xml" - new ArchetypeSetSpellLoader<GameObject, MapArchObject, Archetype>().load(archetypeSet, Archetype.TYPE_SPELL, gameObjectSpells); - gameObjectSpells.sort(); numberSpells.sort(); try { final String filename = IOUtils.getResourceURLAsString(getConfigurationDirectory(), "GameObjectMatchers.xml"); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-08-21 21:33:04 UTC (rev 4966) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-08-21 21:39:46 UTC (rev 4967) @@ -110,8 +110,6 @@ import net.sf.gridarta.map.validation.checks.SysObjectNotOnLayerZeroChecker; import net.sf.gridarta.map.validation.checks.UndefinedArchetypeChecker; import net.sf.gridarta.map.validation.checks.UnsetSlayingChecker; -import net.sf.gridarta.spells.GameObjectSpell; -import net.sf.gridarta.spells.Spells; import net.sf.gridarta.spells.XMLSpellLoader; import net.sf.gridarta.textedit.scripteditor.ScriptEditControlInstance; import net.sf.gridarta.treasurelist.CFTreasureListTree; @@ -178,9 +176,6 @@ /** The Spells. */ private final daieditor.spells.Spells numberSpells = new daieditor.spells.Spells(); - /** The Spells. */ - private final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells = new Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>>(); - /** Whether to display double arches like stacked walls in stacked version. */ private boolean drawDouble; @@ -223,10 +218,9 @@ * @throws RuntimeException If the controller cannot be initialized. */ public CMainControl(@NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory) { - super(gridartaObjectsFactory, new DefaultRendererFactory(), "daieditor", new GlobalSettingsImpl(), new AnimationObjects(), new FaceObjects(), new DefaultMapControlFactory(gridartaObjectsFactory), true, null, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), "CrossfireEditor.jar", luaFileFilter, ".lua"); + super(gridartaObjectsFactory, new DefaultRendererFactory(), "daieditor", new GlobalSettingsImpl(), new AnimationObjects(), new FaceObjects(), new DefaultMapControlFactory(gridartaObjectsFactory), true, null, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), "CrossfireEditor.jar", luaFileFilter, ".lua", 0); // load the list with archtype-data from "types.xml" - gameObjectSpells.sort(); XMLSpellLoader.load(getConfigurationDirectory(), CommonConstants.SPELL_FILE, xmlHelper.getDocumentBuilder(), numberSpells); numberSpells.sort(); try { Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-08-21 21:33:04 UTC (rev 4966) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-08-21 21:39:46 UTC (rev 4967) @@ -70,6 +70,9 @@ import net.sf.gridarta.map.MapControl; import net.sf.gridarta.map.MapControlFactory; import net.sf.gridarta.map.validation.DelegatingMapValidator; +import net.sf.gridarta.spells.ArchetypeSetSpellLoader; +import net.sf.gridarta.spells.GameObjectSpell; +import net.sf.gridarta.spells.Spells; import net.sf.gridarta.textedit.scripteditor.ScriptEditControlInstance; import net.sf.gridarta.updater.UpdaterManager; import net.sf.japi.swing.ActionFactory; @@ -238,6 +241,12 @@ protected final GameObjectMatchers gameObjectMatchers; /** + * The Spells. + */ + @NotNull + protected final Spells<GameObjectSpell<G, A, R>> gameObjectSpells = new Spells<GameObjectSpell<G, A, R>>(); + + /** * Creates a new instance. * @param gridartaObjectsFactory the gridarta objects factory * @param rendererFactory the renderer factory @@ -254,8 +263,10 @@ * @param gridartaJarFilename the filename of the editor's .jar file * @param scriptFileFilter the file filter for script files * @param scriptExtension the file extension for script files + * @param spellType the object id for spell objects or <code>0</code> to + * not collect game objects spells */ - protected AbstractMainControl(@NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final String key, @NotNull final GlobalSettings globalSettings, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final FaceObjects faceObjects, @NotNull final MapControlFactory<G, A, R, V> mapControlFactory, final boolean createDirectionPane, @Nullable final File mapImageCacheDir, @Nullable final ImageIcon compassIcon, @NotNull final String gridartaJarFilename, @NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension) { + protected AbstractMainControl(@NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final String key, @NotNull final GlobalSettings globalSettings, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final FaceObjects faceObjects, @NotNull final MapControlFactory<G, A, R, V> mapControlFactory, final boolean createDirectionPane, @Nullable final File mapImageCacheDir, @Nullable final ImageIcon compassIcon, @NotNull final String gridartaJarFilename, @NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, final int spellType) { this.globalSettings = globalSettings; this.mapControlFactory = mapControlFactory; final DefaultMapManager<G, A, R, V> tmpMapManager = new DefaultMapManager<G, A, R, V>(this, key, gridartaObjectsFactory, mapControlFactory, globalSettings); @@ -307,6 +318,10 @@ throw new MissingResourceException("Cannot create XML parser: " + ex.getMessage(), null, null); } gameObjectMatchers = new GameObjectMatchers(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath()); + if (spellType != 0) { + new ArchetypeSetSpellLoader<G, A, R>().load(archetypeSet, spellType, gameObjectSpells); + gameObjectSpells.sort(); + } } /** Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-08-21 21:33:04 UTC (rev 4966) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-08-21 21:39:46 UTC (rev 4967) @@ -434,7 +434,7 @@ * @param mapControlFactory the map control factory instance to use */ protected TestMainControl(@NotNull final GridartaObjectsFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> gridartaObjectsFactory, @NotNull final RendererFactory<TestGameObject, TestMapArchObject, TestArchetype> rendererFactory, @NotNull final String key, @NotNull final GlobalSettings globalSettings, @NotNull final AnimationObjects<TestAnimationObject> animationObjects, @NotNull final FaceObjects faceObjects, @NotNull final MapControlFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapControlFactory) { - super(gridartaObjectsFactory, rendererFactory, key, globalSettings, animationObjects, faceObjects, mapControlFactory, true, null, null, "test.jar", new TestFileFilter(), ".script"); + super(gridartaObjectsFactory, rendererFactory, key, globalSettings, animationObjects, faceObjects, mapControlFactory, true, null, null, "test.jar", new TestFileFilter(), ".script", 0); } /** {@inheritDoc} */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |