From: <aki...@us...> - 2008-08-21 22:11:42
|
Revision: 4971 http://gridarta.svn.sourceforge.net/gridarta/?rev=4971&view=rev Author: akirschbaum Date: 2008-08-21 22:11:50 +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 22:07:18 UTC (rev 4970) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-21 22:11:50 UTC (rev 4971) @@ -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.NumberSpell; -import net.sf.gridarta.spells.Spells; import net.sf.gridarta.textedit.scripteditor.ScriptEditControlInstance; import net.sf.gridarta.treasurelist.CFTreasureListTree; import net.sf.gridarta.treasurelist.TreasureListsParser; @@ -131,9 +129,6 @@ /** Preferences default value for using System.exit(). */ public static final boolean PREFS_SYSTEM_EXIT_DEFAULT = true; - /** The Spells. */ - private final Spells<NumberSpell> numberSpells = new Spells<NumberSpell>(); - /** The current script controller. */ private final ScriptController scriptControl; @@ -158,10 +153,8 @@ * @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", Archetype.TYPE_SPELL); + 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, null); - // load the list with archtype-data from "types.xml" - numberSpells.sort(); try { final String filename = IOUtils.getResourceURLAsString(getConfigurationDirectory(), "GameObjectMatchers.xml"); gameObjectMatchers.readGameObjectMatchers(filename); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-08-21 22:07:18 UTC (rev 4970) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-08-21 22:11:50 UTC (rev 4971) @@ -110,10 +110,7 @@ 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.NumberSpell; -import net.sf.gridarta.spells.Spells; import net.sf.gridarta.spells.SpellsUtils; -import net.sf.gridarta.spells.XMLSpellLoader; import net.sf.gridarta.textedit.scripteditor.ScriptEditControlInstance; import net.sf.gridarta.treasurelist.CFTreasureListTree; import net.sf.gridarta.treasurelist.TreasureListsParser; @@ -176,9 +173,6 @@ /** Bit field of edit types to show transparent. */ private int alphaType; - /** The Spells. */ - private final Spells<NumberSpell> numberSpells = new Spells<NumberSpell>(); - /** Whether to display double arches like stacked walls in stacked version. */ private boolean drawDouble; @@ -221,11 +215,8 @@ * @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", 0); + 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, IGUIConstants.SPELL_FILE); - // load the list with archtype-data from "types.xml" - XMLSpellLoader.load(getConfigurationDirectory(), IGUIConstants.SPELL_FILE, xmlHelper.getDocumentBuilder(), numberSpells); - numberSpells.sort(); try { final String filename = IOUtils.getResourceURLAsString(getConfigurationDirectory(), "GameObjectMatchers.xml"); gameObjectMatchers.readGameObjectMatchers(filename); Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-08-21 22:07:18 UTC (rev 4970) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-08-21 22:11:50 UTC (rev 4971) @@ -72,7 +72,9 @@ import net.sf.gridarta.map.validation.DelegatingMapValidator; 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.spells.XMLSpellLoader; import net.sf.gridarta.textedit.scripteditor.ScriptEditControlInstance; import net.sf.gridarta.updater.UpdaterManager; import net.sf.japi.swing.ActionFactory; @@ -247,6 +249,12 @@ protected final Spells<GameObjectSpell<G, A, R>> gameObjectSpells = new Spells<GameObjectSpell<G, A, R>>(); /** + * The Spells. + */ + @NotNull + protected final Spells<NumberSpell> numberSpells = new Spells<NumberSpell>(); + + /** * Creates a new instance. * @param gridartaObjectsFactory the gridarta objects factory * @param rendererFactory the renderer factory @@ -265,8 +273,10 @@ * @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 + * @param spellFile the spell file name to load or <code>null</code> to not + * load numbered 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, final int spellType) { + 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, @Nullable final String spellFile) { this.globalSettings = globalSettings; this.mapControlFactory = mapControlFactory; final DefaultMapManager<G, A, R, V> tmpMapManager = new DefaultMapManager<G, A, R, V>(this, key, gridartaObjectsFactory, mapControlFactory, globalSettings); @@ -322,6 +332,10 @@ new ArchetypeSetSpellLoader<G, A, R>().load(archetypeSet, spellType, gameObjectSpells); gameObjectSpells.sort(); } + if (spellFile != null) { + XMLSpellLoader.load(getConfigurationDirectory(), spellFile, xmlHelper.getDocumentBuilder(), numberSpells); + numberSpells.sort(); + } } /** Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-08-21 22:07:18 UTC (rev 4970) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-08-21 22:11:50 UTC (rev 4971) @@ -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", 0); + super(gridartaObjectsFactory, rendererFactory, key, globalSettings, animationObjects, faceObjects, mapControlFactory, true, null, null, "test.jar", new TestFileFilter(), ".script", 0, null); } /** {@inheritDoc} */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |