You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(103) |
Jun
(121) |
Jul
(16) |
Aug
(67) |
Sep
(126) |
Oct
(161) |
Nov
(164) |
Dec
(588) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(394) |
Feb
(181) |
Mar
(131) |
Apr
(180) |
May
(255) |
Jun
(11) |
Jul
(79) |
Aug
(70) |
Sep
(274) |
Oct
(138) |
Nov
(195) |
Dec
(8) |
2008 |
Jan
(3) |
Feb
(142) |
Mar
(162) |
Apr
(124) |
May
(148) |
Jun
(157) |
Jul
(425) |
Aug
(373) |
Sep
(264) |
Oct
(315) |
Nov
(225) |
Dec
(6) |
2009 |
Jan
(67) |
Feb
(78) |
Mar
(279) |
Apr
(294) |
May
(92) |
Jun
(65) |
Jul
(134) |
Aug
(41) |
Sep
(138) |
Oct
(125) |
Nov
(126) |
Dec
(122) |
2010 |
Jan
(15) |
Feb
(48) |
Mar
(9) |
Apr
(195) |
May
(373) |
Jun
(507) |
Jul
(42) |
Aug
(16) |
Sep
(38) |
Oct
(81) |
Nov
(64) |
Dec
(18) |
2011 |
Jan
(13) |
Feb
(12) |
Mar
(39) |
Apr
(1) |
May
(2) |
Jun
(27) |
Jul
(27) |
Aug
(31) |
Sep
(14) |
Oct
(102) |
Nov
(20) |
Dec
(37) |
2012 |
Jan
(22) |
Feb
(1) |
Mar
(1) |
Apr
(2) |
May
(2) |
Jun
(18) |
Jul
(6) |
Aug
(1) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
2013 |
Jan
(1) |
Feb
(2) |
Mar
(1) |
Apr
(1) |
May
(47) |
Jun
(7) |
Jul
(107) |
Aug
|
Sep
|
Oct
(112) |
Nov
(31) |
Dec
(17) |
2014 |
Jan
(29) |
Feb
(111) |
Mar
(34) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(18) |
Dec
(10) |
From: <aki...@us...> - 2013-10-08 21:37:00
|
Revision: 9410 http://sourceforge.net/p/gridarta/code/9410 Author: akirschbaum Date: 2013-10-08 21:36:56 +0000 (Tue, 08 Oct 2013) Log Message: ----------- Reorder initialization code. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java 2013-10-08 21:32:57 UTC (rev 9409) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java 2013-10-08 21:36:56 UTC (rev 9410) @@ -284,10 +284,6 @@ final InsertionMode<G, A, R> topmostInsertionMode = new TopmostInsertionMode<G, A, R>(); final AutojoinLists<G, A, R> autojoinLists = new AutojoinLists<G, A, R>(mapViewSettings); final MapWriter<G, A, R> mapWriter = new DefaultMapWriter<G, A, R>(mapArchObjectParserFactory, gameObjectParser); - final MapModelFactory<G, A, R> mapModelFactory = new MapModelFactory<G, A, R>(archetypeChooserModel, autojoinLists, mapViewSettings, gameObjectFactory, gameObjectMatchers, topmostInsertionMode); - final MapControlFactory<G, A, R> mapControlFactory = editorFactory.newMapControlFactory(mapWriter, projectSettings, mapModelFactory); - final AbstractMapManager<G, A, R> mapManager = new DefaultMapManager<G, A, R>(mapReaderFactory, mapControlFactory, projectSettings, faceObjectProviders); - final MapManager<G, A, R> pickmapManager = new DefaultPickmapManager<G, A, R>(mapReaderFactory, mapControlFactory, projectSettings, faceObjectProviders); final PluginModel<G, A, R> pluginModel = new PluginModel<G, A, R>(); final ValidatorPreferences validatorPreferences = new DefaultValidatorPreferences(); final DelegatingMapValidator<G, A, R> validators = new DelegatingMapValidator<G, A, R>(validatorPreferences); @@ -296,7 +292,6 @@ final AbstractArchetypeParser<G, A, R, ?> archetypeParser = editorFactory.newArchetypeParser(errorView, gameObjectParser, animationObjects, archetypeSet, gameObjectFactory, projectSettings); final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); final AbstractResources<G, A, R> resources = editorFactory.newResources(gameObjectParser, archetypeSet, archetypeParser, mapViewSettings, faceObjects, animationObjects, archFaceProvider, faceObjectProviders); - final PluginParameterFactory<G, A, R> pluginParameterFactory = new PluginParameterFactory<G, A, R>(archetypeSet, mapManager, defaultFilterList, projectSettings); final XmlHelper xmlHelper; try { @@ -313,6 +308,11 @@ final ScriptArchUtils scriptArchUtils = DefaultMainControl.loadScriptArchUtils(errorView, editorFactory, projectSettings, archetypeTypeSet, xmlHelper); DefaultMainControl.loadArchetypes(errorView, projectSettings, archetypeSet, archetypeChooserModel, resources, configSource); final ScriptedEventFactory<G, A, R> scriptedEventFactory = editorFactory.newScriptedEventFactory(scriptArchUtils, gameObjectFactory, scriptedEventEditor, archetypeSet); + final MapModelFactory<G, A, R> mapModelFactory = new MapModelFactory<G, A, R>(archetypeChooserModel, autojoinLists, mapViewSettings, gameObjectFactory, gameObjectMatchers, topmostInsertionMode); + final MapControlFactory<G, A, R> mapControlFactory = editorFactory.newMapControlFactory(mapWriter, projectSettings, mapModelFactory); + final AbstractMapManager<G, A, R> mapManager = new DefaultMapManager<G, A, R>(mapReaderFactory, mapControlFactory, projectSettings, faceObjectProviders); + final MapManager<G, A, R> pickmapManager = new DefaultPickmapManager<G, A, R>(mapReaderFactory, mapControlFactory, projectSettings, faceObjectProviders); + final PluginParameterFactory<G, A, R> pluginParameterFactory = new PluginParameterFactory<G, A, R>(archetypeSet, mapManager, defaultFilterList, projectSettings); final ScriptArchEditor<G, A, R> scriptArchEditor = new ScriptArchEditor<G, A, R>(scriptedEventFactory, editorFactory.getScriptExtension(), editorFactory.getScriptName(), scriptArchUtils, editorFactory.getScriptFileFilter(), projectSettings, mapManager, pathManager); final ScriptArchDataUtils<G, A, R> scriptArchDataUtils = editorFactory.newScriptArchDataUtils(scriptArchUtils, scriptedEventFactory, scriptedEventEditor); final Spells<GameObjectSpell<G, A, R>> gameObjectSpells = DefaultMainControl.loadArchetypeSpells(editorFactory.getSpellType(), gameObjectFactory, archetypeSet); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-08 21:33:00
|
Revision: 9409 http://sourceforge.net/p/gridarta/code/9409 Author: akirschbaum Date: 2013-10-08 21:32:57 +0000 (Tue, 08 Oct 2013) Log Message: ----------- Simplify code. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 21:29:32 UTC (rev 9408) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 21:32:57 UTC (rev 9409) @@ -109,19 +109,15 @@ */ public DefaultMainControl(@NotNull final XmlHelper xmlHelper, final ErrorView errorView, @NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final ProjectSettings projectSettings, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<G, A, R> mapWriter) { final EnvironmentChecker<G, A, R> environmentChecker = new EnvironmentChecker<G, A, R>(validatorPreferences); - AttributeRangeChecker<G, A, R> attributeRangeChecker = null; try { loadGameObjectMatchers(xmlHelper, errorView, projectSettings, gameObjectMatchers); - - final ValidatorFactory<G, A, R> validatorFactory = new ValidatorFactory<G, A, R>(validatorPreferences, gameObjectMatchers, projectSettings, mapWriter); - loadValidators(validators, validatorFactory, errorView); - attributeRangeChecker = editorFactory.loadAttributeRangeChecker(validators, new ErrorViewCollector(errorView, new File("GameObjectMatchers.xml")), projectSettings, gameObjectMatchers, validatorPreferences); } catch (final FileNotFoundException ex) { errorView.addWarning(ErrorViewCategory.GAMEOBJECTMATCHERS_FILE_INVALID, "GameObjectMatchers.xml: " + ex.getMessage()); } - if (attributeRangeChecker != null) { - validators.addValidator(attributeRangeChecker); - } + final ValidatorFactory<G, A, R> validatorFactory = new ValidatorFactory<G, A, R>(validatorPreferences, gameObjectMatchers, projectSettings, mapWriter); + loadValidators(validators, validatorFactory, errorView); + final AttributeRangeChecker<G, A, R> attributeRangeChecker = editorFactory.loadAttributeRangeChecker(validators, new ErrorViewCollector(errorView, new File("GameObjectMatchers.xml")), projectSettings, gameObjectMatchers, validatorPreferences); + validators.addValidator(attributeRangeChecker); validators.addValidator(environmentChecker); ArchetypeTypeChecks.addChecks(archetypeTypeSet, attributeRangeChecker, environmentChecker); final GameObjectMatcher shopSquareMatcher = gameObjectMatchers.getMatcher("system_shop_square", "shop_square"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-08 21:29:35
|
Revision: 9408 http://sourceforge.net/p/gridarta/code/9408 Author: akirschbaum Date: 2013-10-08 21:29:32 +0000 (Tue, 08 Oct 2013) Log Message: ----------- Fix typo. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 21:28:43 UTC (rev 9407) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 21:29:32 UTC (rev 9408) @@ -115,7 +115,7 @@ final ValidatorFactory<G, A, R> validatorFactory = new ValidatorFactory<G, A, R>(validatorPreferences, gameObjectMatchers, projectSettings, mapWriter); loadValidators(validators, validatorFactory, errorView); - attributeRangeChecker = editorFactory.loadAttributeRangeChecker(validators, new ErrorViewCollector(errorView, new File("GamEObjectMatchers.xml")), projectSettings, gameObjectMatchers, validatorPreferences); + attributeRangeChecker = editorFactory.loadAttributeRangeChecker(validators, new ErrorViewCollector(errorView, new File("GameObjectMatchers.xml")), projectSettings, gameObjectMatchers, validatorPreferences); } catch (final FileNotFoundException ex) { errorView.addWarning(ErrorViewCategory.GAMEOBJECTMATCHERS_FILE_INVALID, "GameObjectMatchers.xml: " + ex.getMessage()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-08 21:28:49
|
Revision: 9407 http://sourceforge.net/p/gridarta/code/9407 Author: akirschbaum Date: 2013-10-08 21:28:43 +0000 (Tue, 08 Oct 2013) Log Message: ----------- Extract code into function. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 21:25:06 UTC (rev 9406) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 21:28:43 UTC (rev 9407) @@ -19,6 +19,7 @@ package net.sf.gridarta.maincontrol; +import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; @@ -110,23 +111,11 @@ final EnvironmentChecker<G, A, R> environmentChecker = new EnvironmentChecker<G, A, R>(validatorPreferences); AttributeRangeChecker<G, A, R> attributeRangeChecker = null; try { - final URL url = IOUtils.getResource(projectSettings.getConfigurationDirectory(), "GameObjectMatchers.xml"); - final ErrorViewCollector gameObjectMatchersErrorViewCollector = new ErrorViewCollector(errorView, url); - try { - xmlHelper.getDocumentBuilder().setErrorHandler(new ErrorViewCollectorErrorHandler(gameObjectMatchersErrorViewCollector, ErrorViewCategory.GAMEOBJECTMATCHERS_FILE_INVALID)); - try { - final GameObjectMatchersParser gameObjectMatchersParser = new GameObjectMatchersParser(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath()); - gameObjectMatchersParser.readGameObjectMatchers(url, gameObjectMatchers, gameObjectMatchersErrorViewCollector); - } finally { - xmlHelper.getDocumentBuilder().setErrorHandler(null); - } - } catch (final IOException ex) { - gameObjectMatchersErrorViewCollector.addWarning(ErrorViewCategory.GAMEOBJECTMATCHERS_FILE_INVALID, ex.getMessage()); - } + loadGameObjectMatchers(xmlHelper, errorView, projectSettings, gameObjectMatchers); final ValidatorFactory<G, A, R> validatorFactory = new ValidatorFactory<G, A, R>(validatorPreferences, gameObjectMatchers, projectSettings, mapWriter); loadValidators(validators, validatorFactory, errorView); - attributeRangeChecker = editorFactory.loadAttributeRangeChecker(validators, gameObjectMatchersErrorViewCollector, projectSettings, gameObjectMatchers, validatorPreferences); + attributeRangeChecker = editorFactory.loadAttributeRangeChecker(validators, new ErrorViewCollector(errorView, new File("GamEObjectMatchers.xml")), projectSettings, gameObjectMatchers, validatorPreferences); } catch (final FileNotFoundException ex) { errorView.addWarning(ErrorViewCategory.GAMEOBJECTMATCHERS_FILE_INVALID, "GameObjectMatchers.xml: " + ex.getMessage()); } @@ -150,6 +139,22 @@ } } + private void loadGameObjectMatchers(@NotNull final XmlHelper xmlHelper, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final GameObjectMatchers gameObjectMatchers) throws FileNotFoundException { + final URL url = IOUtils.getResource(projectSettings.getConfigurationDirectory(), "GameObjectMatchers.xml"); + final ErrorViewCollector gameObjectMatchersErrorViewCollector = new ErrorViewCollector(errorView, url); + try { + xmlHelper.getDocumentBuilder().setErrorHandler(new ErrorViewCollectorErrorHandler(gameObjectMatchersErrorViewCollector, ErrorViewCategory.GAMEOBJECTMATCHERS_FILE_INVALID)); + try { + final GameObjectMatchersParser gameObjectMatchersParser = new GameObjectMatchersParser(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath()); + gameObjectMatchersParser.readGameObjectMatchers(url, gameObjectMatchers, gameObjectMatchersErrorViewCollector); + } finally { + xmlHelper.getDocumentBuilder().setErrorHandler(null); + } + } catch (final IOException ex) { + gameObjectMatchersErrorViewCollector.addWarning(ErrorViewCategory.GAMEOBJECTMATCHERS_FILE_INVALID, ex.getMessage()); + } + } + @NotNull public static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> ScriptArchUtils loadScriptArchUtils(@NotNull final ErrorView errorView, final EditorFactory<G, A, R> editorFactory, @NotNull final ProjectSettings projectSettings, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final XmlHelper xmlHelper) { final ArchetypeAttributeFactory archetypeAttributeFactory = new DefaultArchetypeAttributeFactory(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-08 21:25:12
|
Revision: 9406 http://sourceforge.net/p/gridarta/code/9406 Author: akirschbaum Date: 2013-10-08 21:25:06 +0000 (Tue, 08 Oct 2013) Log Message: ----------- Unify EditorFactory implementations. Modified Paths: -------------- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java Modified: trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2013-10-08 21:11:26 UTC (rev 9405) +++ trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2013-10-08 21:25:06 UTC (rev 9406) @@ -67,6 +67,7 @@ import net.sf.gridarta.model.gameobject.IsoMapSquareInfo; import net.sf.gridarta.model.gameobject.MultiPositionData; import net.sf.gridarta.model.io.AbstractArchetypeParser; +import net.sf.gridarta.model.io.CacheFiles; import net.sf.gridarta.model.io.DefaultMapReaderFactory; import net.sf.gridarta.model.io.GameObjectParser; import net.sf.gridarta.model.io.GameObjectParserFactory; @@ -480,7 +481,7 @@ @NotNull @Override public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final PluginExecutor<GameObject, MapArchObject, Archetype> pluginExecutor, @NotNull final PluginParameters pluginParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapModelFactory<GameObject, MapArchObject, Archetype> mapModelFactory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects faceObjects, @NotNull final ProjectSettings projectSettings, @NotNull final EditorSettings editorSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final TreasureTree treasureTree, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final PluginModel<GameObject, MapArchObject, Archetype> pluginModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final ScriptArchDataUtils<GameObject, MapArchObject, Archetype> scriptArchDataUtils, @NotNull final ScriptArchUtils scriptArchUtils, @NotNull final ScriptArchEditor<GameObject, MapArchObject, Archetype> scriptArchEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { - return new GUIMainControl<GameObject, MapArchObject, Archetype>(true, mapManager, pickmapManager, archetypeSet, faceObjects, projectSettings, editorSettings, mapViewSettings, mapModelFactory, mapReaderFactory, mapArchObjectFactory, treasureTree, archetypeTypeSet, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "AtrinikEditor.jar", GuiFileFilters.mapFileFilter, GuiFileFilters.pythonFileFilter, getScriptExtension(), validators, resources, gameObjectMatchers, errorView, 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, }, IGUIConstants.SCRIPTS_DIR, pluginModel, archetypeChooserModel, animationObjects, scriptArchEditor, scriptedEventEditor, scriptArchDataUtils, scriptArchUtils, PREFERENCES_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SPELL_FILE, false, new Direction[] { Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH, }, this, faceObjectProviders, pluginParameterFactory, gameObjectFactory, pathManager, new SubDirectoryCacheFiles(".dedit"), gameObjectSpells, numberSpells, -1, systemIcons, configSourceFactory, topmostInsertionMode, rendererFactory, filterControl, pluginExecutor, pluginParameters); + return new GUIMainControl<GameObject, MapArchObject, Archetype>(isCreateDirectionPane(), mapManager, pickmapManager, archetypeSet, faceObjects, projectSettings, editorSettings, mapViewSettings, mapModelFactory, mapReaderFactory, mapArchObjectFactory, treasureTree, archetypeTypeSet, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "AtrinikEditor.jar", GuiFileFilters.mapFileFilter, GuiFileFilters.pythonFileFilter, getScriptExtension(), validators, resources, gameObjectMatchers, errorView, 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, }, IGUIConstants.SCRIPTS_DIR, pluginModel, archetypeChooserModel, animationObjects, scriptArchEditor, scriptedEventEditor, scriptArchDataUtils, scriptArchUtils, PREFERENCES_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SPELL_FILE, isAllowRandomMapParameters(), getDirectionMap(), this, faceObjectProviders, pluginParameterFactory, gameObjectFactory, pathManager, getCacheFiles(), gameObjectSpells, numberSpells, getUndefinedSpellIndex(), systemIcons, configSourceFactory, topmostInsertionMode, rendererFactory, filterControl, pluginExecutor, pluginParameters); } /** @@ -554,4 +555,46 @@ return "Python"; } + /** + * {@inheritDoc} + */ + @Override + public boolean isCreateDirectionPane() { + return true; + } + + /** + * {@inheritDoc} + */ + @Override + public int getUndefinedSpellIndex() { + return -1; + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public CacheFiles getCacheFiles() { + return new SubDirectoryCacheFiles(".dedit"); + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public Direction[] getDirectionMap() { + return new Direction[] { Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH, }; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean isAllowRandomMapParameters() { + return false; + } + } Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2013-10-08 21:11:26 UTC (rev 9405) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2013-10-08 21:25:06 UTC (rev 9406) @@ -62,6 +62,7 @@ import net.sf.gridarta.model.face.FaceObjects; import net.sf.gridarta.model.gameobject.GameObjectFactory; import net.sf.gridarta.model.io.AbstractArchetypeParser; +import net.sf.gridarta.model.io.CacheFiles; import net.sf.gridarta.model.io.DefaultMapReaderFactory; import net.sf.gridarta.model.io.DirectoryCacheFiles; import net.sf.gridarta.model.io.GameObjectParser; @@ -388,7 +389,7 @@ @NotNull @Override public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final PluginExecutor<GameObject, MapArchObject, Archetype> pluginExecutor, @NotNull final PluginParameters pluginParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapModelFactory<GameObject, MapArchObject, Archetype> mapModelFactory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects faceObjects, @NotNull final ProjectSettings projectSettings, @NotNull final EditorSettings editorSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final TreasureTree treasureTree, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final PluginModel<GameObject, MapArchObject, Archetype> pluginModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final ScriptArchDataUtils<GameObject, MapArchObject, Archetype> scriptArchDataUtils, @NotNull final ScriptArchUtils scriptArchUtils, @NotNull final ScriptArchEditor<GameObject, MapArchObject, Archetype> scriptArchEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { - return new GUIMainControl<GameObject, MapArchObject, Archetype>(false, mapManager, pickmapManager, archetypeSet, faceObjects, projectSettings, editorSettings, mapViewSettings, mapModelFactory, mapReaderFactory, mapArchObjectFactory, treasureTree, archetypeTypeSet, null, "CrossfireEditor.jar", GuiFileFilters.mapFileFilter, GuiFileFilters.pythonFileFilter, getScriptExtension(), validators, resources, gameObjectMatchers, errorView, 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, }, IGUIConstants.SCRIPTS_DIR, pluginModel, archetypeChooserModel, animationObjects, scriptArchEditor, scriptedEventEditor, scriptArchDataUtils, scriptArchUtils, PREFERENCES_VALIDATOR_AUTO_DEFAULT, null, true, new Direction[] { Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, }, this, faceObjectProviders, pluginParameterFactory, gameObjectFactory, pathManager, new DirectoryCacheFiles(ConfigFileUtils.getHomeFile("thumbnails"), ".png"), gameObjectSpells, numberSpells, 0, systemIcons, configSourceFactory, topmostInsertionMode, rendererFactory, filterControl, pluginExecutor, pluginParameters); + return new GUIMainControl<GameObject, MapArchObject, Archetype>(isCreateDirectionPane(), mapManager, pickmapManager, archetypeSet, faceObjects, projectSettings, editorSettings, mapViewSettings, mapModelFactory, mapReaderFactory, mapArchObjectFactory, treasureTree, archetypeTypeSet, null, "CrossfireEditor.jar", GuiFileFilters.mapFileFilter, GuiFileFilters.pythonFileFilter, getScriptExtension(), validators, resources, gameObjectMatchers, errorView, 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, }, IGUIConstants.SCRIPTS_DIR, pluginModel, archetypeChooserModel, animationObjects, scriptArchEditor, scriptedEventEditor, scriptArchDataUtils, scriptArchUtils, PREFERENCES_VALIDATOR_AUTO_DEFAULT, null, isAllowRandomMapParameters(), getDirectionMap(), this, faceObjectProviders, pluginParameterFactory, gameObjectFactory, pathManager, getCacheFiles(), gameObjectSpells, numberSpells, getUndefinedSpellIndex(), systemIcons, configSourceFactory, topmostInsertionMode, rendererFactory, filterControl, pluginExecutor, pluginParameters); } /** @@ -464,4 +465,46 @@ return "Python"; } + /** + * {@inheritDoc} + */ + @Override + public boolean isCreateDirectionPane() { + return false; + } + + /** + * {@inheritDoc} + */ + @Override + public int getUndefinedSpellIndex() { + return 0; + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public CacheFiles getCacheFiles() { + return new DirectoryCacheFiles(ConfigFileUtils.getHomeFile("thumbnails"), ".png"); + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public Direction[] getDirectionMap() { + return new Direction[] { Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, }; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean isAllowRandomMapParameters() { + return true; + } + } Modified: trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2013-10-08 21:11:26 UTC (rev 9405) +++ trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2013-10-08 21:25:06 UTC (rev 9406) @@ -67,6 +67,7 @@ import net.sf.gridarta.model.gameobject.IsoMapSquareInfo; import net.sf.gridarta.model.gameobject.MultiPositionData; import net.sf.gridarta.model.io.AbstractArchetypeParser; +import net.sf.gridarta.model.io.CacheFiles; import net.sf.gridarta.model.io.DefaultMapReaderFactory; import net.sf.gridarta.model.io.GameObjectParser; import net.sf.gridarta.model.io.GameObjectParserFactory; @@ -479,7 +480,7 @@ @NotNull @Override public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final PluginExecutor<GameObject, MapArchObject, Archetype> pluginExecutor, @NotNull final PluginParameters pluginParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapModelFactory<GameObject, MapArchObject, Archetype> mapModelFactory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects faceObjects, @NotNull final ProjectSettings projectSettings, @NotNull final EditorSettings editorSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final TreasureTree treasureTree, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final PluginModel<GameObject, MapArchObject, Archetype> pluginModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final ScriptArchDataUtils<GameObject, MapArchObject, Archetype> scriptArchDataUtils, @NotNull final ScriptArchUtils scriptArchUtils, @NotNull final ScriptArchEditor<GameObject, MapArchObject, Archetype> scriptArchEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { - return new GUIMainControl<GameObject, MapArchObject, Archetype>(true, mapManager, pickmapManager, archetypeSet, faceObjects, projectSettings, editorSettings, mapViewSettings, mapModelFactory, mapReaderFactory, mapArchObjectFactory, treasureTree, archetypeTypeSet, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", GuiFileFilters.mapFileFilter, GuiFileFilters.luaFileFilter, getScriptExtension(), validators, resources, gameObjectMatchers, errorView, 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, }, IGUIConstants.SCRIPTS_DIR, pluginModel, archetypeChooserModel, animationObjects, scriptArchEditor, scriptedEventEditor, scriptArchDataUtils, scriptArchUtils, PREFERENCES_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SPELL_FILE, false, new Direction[] { Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH, }, this, faceObjectProviders, pluginParameterFactory, gameObjectFactory, pathManager, new SubDirectoryCacheFiles(".dedit"), gameObjectSpells, numberSpells, -1, systemIcons, configSourceFactory, topmostInsertionMode, rendererFactory, filterControl, pluginExecutor, pluginParameters); + return new GUIMainControl<GameObject, MapArchObject, Archetype>(isCreateDirectionPane(), mapManager, pickmapManager, archetypeSet, faceObjects, projectSettings, editorSettings, mapViewSettings, mapModelFactory, mapReaderFactory, mapArchObjectFactory, treasureTree, archetypeTypeSet, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", GuiFileFilters.mapFileFilter, GuiFileFilters.luaFileFilter, getScriptExtension(), validators, resources, gameObjectMatchers, errorView, 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, }, IGUIConstants.SCRIPTS_DIR, pluginModel, archetypeChooserModel, animationObjects, scriptArchEditor, scriptedEventEditor, scriptArchDataUtils, scriptArchUtils, PREFERENCES_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SPELL_FILE, isAllowRandomMapParameters(), getDirectionMap(), this, faceObjectProviders, pluginParameterFactory, gameObjectFactory, pathManager, getCacheFiles(), gameObjectSpells, numberSpells, getUndefinedSpellIndex(), systemIcons, configSourceFactory, topmostInsertionMode, rendererFactory, filterControl, pluginExecutor, pluginParameters); } /** @@ -553,4 +554,46 @@ return "Lua"; } + /** + * {@inheritDoc} + */ + @Override + public boolean isCreateDirectionPane() { + return true; + } + + /** + * {@inheritDoc} + */ + @Override + public int getUndefinedSpellIndex() { + return -1; + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public CacheFiles getCacheFiles() { + return new SubDirectoryCacheFiles(".dedit"); + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public Direction[] getDirectionMap() { + return new Direction[] { Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH, }; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean isAllowRandomMapParameters() { + return false; + } + } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java 2013-10-08 21:11:26 UTC (rev 9405) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java 2013-10-08 21:25:06 UTC (rev 9406) @@ -40,6 +40,7 @@ import net.sf.gridarta.model.archetypetype.ArchetypeTypeList; import net.sf.gridarta.model.archetypetype.ArchetypeTypeSet; import net.sf.gridarta.model.configsource.ConfigSourceFactory; +import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.model.errorview.ErrorView; import net.sf.gridarta.model.errorview.ErrorViewCollector; import net.sf.gridarta.model.exitconnector.ExitConnectorModel; @@ -49,6 +50,7 @@ import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.gameobject.GameObjectFactory; import net.sf.gridarta.model.io.AbstractArchetypeParser; +import net.sf.gridarta.model.io.CacheFiles; import net.sf.gridarta.model.io.DefaultMapReaderFactory; import net.sf.gridarta.model.io.GameObjectParser; import net.sf.gridarta.model.io.GameObjectParserFactory; @@ -442,4 +444,36 @@ @NotNull String getScriptName(); + /** + * Returns whether the direction panel should be created. + * @return whether the direction panel should be created + */ + boolean isCreateDirectionPane(); + + /** + * Returns the index for "no spell". + * @return tne index + */ + int getUndefinedSpellIndex(); + + /** + * Returns the cache files for icon and preview images. + * @return the cache files + */ + @NotNull + CacheFiles getCacheFiles(); + + /** + * Returns a map of relative direction to map window direction. + * @return the map + */ + @NotNull + Direction[] getDirectionMap(); + + /** + * Returns whether exit paths may point to random map parameters. + * @return whether exit paths may point to random map parameters + */ + boolean isAllowRandomMapParameters(); + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-08 21:11:29
|
Revision: 9405 http://sourceforge.net/p/gridarta/code/9405 Author: akirschbaum Date: 2013-10-08 21:11:26 +0000 (Tue, 08 Oct 2013) Log Message: ----------- Remove DefaultMainControl.createGUIMainControl(). Modified Paths: -------------- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java Modified: trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2013-10-08 21:00:49 UTC (rev 9404) +++ trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2013-10-08 21:11:26 UTC (rev 9405) @@ -480,7 +480,7 @@ @NotNull @Override public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final PluginExecutor<GameObject, MapArchObject, Archetype> pluginExecutor, @NotNull final PluginParameters pluginParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapModelFactory<GameObject, MapArchObject, Archetype> mapModelFactory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects faceObjects, @NotNull final ProjectSettings projectSettings, @NotNull final EditorSettings editorSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final TreasureTree treasureTree, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final PluginModel<GameObject, MapArchObject, Archetype> pluginModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final ScriptArchDataUtils<GameObject, MapArchObject, Archetype> scriptArchDataUtils, @NotNull final ScriptArchUtils scriptArchUtils, @NotNull final ScriptArchEditor<GameObject, MapArchObject, Archetype> scriptArchEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { - return mainControl.createGUIMainControl(GuiFileFilters.pythonFileFilter, getScriptExtension(), true, mapManager, pickmapManager, archetypeSet, mapModelFactory, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "AtrinikEditor.jar", 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, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SPELL_FILE, this, errorView, new SubDirectoryCacheFiles(".dedit"), configSourceFactory, rendererFactory, filterControl, pluginExecutor, pluginParameters, faceObjects, projectSettings, editorSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, -1, archetypeTypeSet, mapArchObjectFactory, treasureTree, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, pluginModel, animationObjects, archetypeChooserModel, false, scriptedEventEditor, scriptArchDataUtils, scriptArchUtils, scriptArchEditor, new Direction[] { Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH, }, resources, gameObjectSpells, numberSpells, pluginParameterFactory); + return new GUIMainControl<GameObject, MapArchObject, Archetype>(true, mapManager, pickmapManager, archetypeSet, faceObjects, projectSettings, editorSettings, mapViewSettings, mapModelFactory, mapReaderFactory, mapArchObjectFactory, treasureTree, archetypeTypeSet, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "AtrinikEditor.jar", GuiFileFilters.mapFileFilter, GuiFileFilters.pythonFileFilter, getScriptExtension(), validators, resources, gameObjectMatchers, errorView, 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, }, IGUIConstants.SCRIPTS_DIR, pluginModel, archetypeChooserModel, animationObjects, scriptArchEditor, scriptedEventEditor, scriptArchDataUtils, scriptArchUtils, PREFERENCES_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SPELL_FILE, false, new Direction[] { Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH, }, this, faceObjectProviders, pluginParameterFactory, gameObjectFactory, pathManager, new SubDirectoryCacheFiles(".dedit"), gameObjectSpells, numberSpells, -1, systemIcons, configSourceFactory, topmostInsertionMode, rendererFactory, filterControl, pluginExecutor, pluginParameters); } /** Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2013-10-08 21:00:49 UTC (rev 9404) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2013-10-08 21:11:26 UTC (rev 9405) @@ -388,7 +388,7 @@ @NotNull @Override public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final PluginExecutor<GameObject, MapArchObject, Archetype> pluginExecutor, @NotNull final PluginParameters pluginParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapModelFactory<GameObject, MapArchObject, Archetype> mapModelFactory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects faceObjects, @NotNull final ProjectSettings projectSettings, @NotNull final EditorSettings editorSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final TreasureTree treasureTree, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final PluginModel<GameObject, MapArchObject, Archetype> pluginModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final ScriptArchDataUtils<GameObject, MapArchObject, Archetype> scriptArchDataUtils, @NotNull final ScriptArchUtils scriptArchUtils, @NotNull final ScriptArchEditor<GameObject, MapArchObject, Archetype> scriptArchEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { - return mainControl.createGUIMainControl(GuiFileFilters.pythonFileFilter, getScriptExtension(), false, mapManager, pickmapManager, archetypeSet, mapModelFactory, null, "CrossfireEditor.jar", 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, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, null, this, errorView, new DirectoryCacheFiles(ConfigFileUtils.getHomeFile("thumbnails"), ".png"), configSourceFactory, rendererFactory, filterControl, pluginExecutor, pluginParameters, faceObjects, projectSettings, editorSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, 0, archetypeTypeSet, mapArchObjectFactory, treasureTree, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, pluginModel, animationObjects, archetypeChooserModel, true, scriptedEventEditor, scriptArchDataUtils, scriptArchUtils, scriptArchEditor, new Direction[] { Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, }, resources, gameObjectSpells, numberSpells, pluginParameterFactory); + return new GUIMainControl<GameObject, MapArchObject, Archetype>(false, mapManager, pickmapManager, archetypeSet, faceObjects, projectSettings, editorSettings, mapViewSettings, mapModelFactory, mapReaderFactory, mapArchObjectFactory, treasureTree, archetypeTypeSet, null, "CrossfireEditor.jar", GuiFileFilters.mapFileFilter, GuiFileFilters.pythonFileFilter, getScriptExtension(), validators, resources, gameObjectMatchers, errorView, 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, }, IGUIConstants.SCRIPTS_DIR, pluginModel, archetypeChooserModel, animationObjects, scriptArchEditor, scriptedEventEditor, scriptArchDataUtils, scriptArchUtils, PREFERENCES_VALIDATOR_AUTO_DEFAULT, null, true, new Direction[] { Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, }, this, faceObjectProviders, pluginParameterFactory, gameObjectFactory, pathManager, new DirectoryCacheFiles(ConfigFileUtils.getHomeFile("thumbnails"), ".png"), gameObjectSpells, numberSpells, 0, systemIcons, configSourceFactory, topmostInsertionMode, rendererFactory, filterControl, pluginExecutor, pluginParameters); } /** @@ -407,8 +407,7 @@ * {@inheritDoc} */ @Nullable - @Override - public EditorAction newServerActions(@NotNull final MapViewManager<GameObject, MapArchObject, Archetype> mapViewManager, @NotNull final FileControl<GameObject, MapArchObject, Archetype> fileControl, @NotNull final PathManager pathManager) { + @Override public EditorAction newServerActions(@NotNull final MapViewManager<GameObject, MapArchObject, Archetype> mapViewManager, @NotNull final FileControl<GameObject, MapArchObject, Archetype> fileControl, @NotNull final PathManager pathManager) { return null; // action not supported } Modified: trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2013-10-08 21:00:49 UTC (rev 9404) +++ trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2013-10-08 21:11:26 UTC (rev 9405) @@ -479,7 +479,7 @@ @NotNull @Override public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final PluginExecutor<GameObject, MapArchObject, Archetype> pluginExecutor, @NotNull final PluginParameters pluginParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapModelFactory<GameObject, MapArchObject, Archetype> mapModelFactory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects faceObjects, @NotNull final ProjectSettings projectSettings, @NotNull final EditorSettings editorSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final TreasureTree treasureTree, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final PluginModel<GameObject, MapArchObject, Archetype> pluginModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final ScriptArchDataUtils<GameObject, MapArchObject, Archetype> scriptArchDataUtils, @NotNull final ScriptArchUtils scriptArchUtils, @NotNull final ScriptArchEditor<GameObject, MapArchObject, Archetype> scriptArchEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { - return mainControl.createGUIMainControl(GuiFileFilters.luaFileFilter, getScriptExtension(), true, mapManager, pickmapManager, archetypeSet, mapModelFactory, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", 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, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SPELL_FILE, this, errorView, new SubDirectoryCacheFiles(".dedit"), configSourceFactory, rendererFactory, filterControl, pluginExecutor, pluginParameters, faceObjects, projectSettings, editorSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, -1, archetypeTypeSet, mapArchObjectFactory, treasureTree, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, pluginModel, animationObjects, archetypeChooserModel, false, scriptedEventEditor, scriptArchDataUtils, scriptArchUtils, scriptArchEditor, new Direction[] { Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH, }, resources, gameObjectSpells, numberSpells, pluginParameterFactory); + return new GUIMainControl<GameObject, MapArchObject, Archetype>(true, mapManager, pickmapManager, archetypeSet, faceObjects, projectSettings, editorSettings, mapViewSettings, mapModelFactory, mapReaderFactory, mapArchObjectFactory, treasureTree, archetypeTypeSet, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", GuiFileFilters.mapFileFilter, GuiFileFilters.luaFileFilter, getScriptExtension(), validators, resources, gameObjectMatchers, errorView, 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, }, IGUIConstants.SCRIPTS_DIR, pluginModel, archetypeChooserModel, animationObjects, scriptArchEditor, scriptedEventEditor, scriptArchDataUtils, scriptArchUtils, PREFERENCES_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SPELL_FILE, false, new Direction[] { Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH, }, this, faceObjectProviders, pluginParameterFactory, gameObjectFactory, pathManager, new SubDirectoryCacheFiles(".dedit"), gameObjectSpells, numberSpells, -1, systemIcons, configSourceFactory, topmostInsertionMode, rendererFactory, filterControl, pluginExecutor, pluginParameters); } /** Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 21:00:49 UTC (rev 9404) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 21:11:26 UTC (rev 9405) @@ -25,15 +25,7 @@ import java.net.URL; import java.util.Collections; import java.util.Map; -import javax.swing.ImageIcon; -import javax.swing.filechooser.FileFilter; import javax.xml.parsers.DocumentBuilder; -import net.sf.gridarta.gui.filter.FilterControl; -import net.sf.gridarta.gui.map.renderer.RendererFactory; -import net.sf.gridarta.gui.scripts.ScriptArchDataUtils; -import net.sf.gridarta.gui.scripts.ScriptArchEditor; -import net.sf.gridarta.gui.scripts.ScriptedEventEditor; -import net.sf.gridarta.model.anim.AnimationObjects; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.model.archetypeset.ArchetypeSet; @@ -45,33 +37,19 @@ import net.sf.gridarta.model.archetypetype.ArchetypeTypeSetParser; import net.sf.gridarta.model.archetypetype.DefaultArchetypeAttributeFactory; import net.sf.gridarta.model.configsource.ConfigSource; -import net.sf.gridarta.model.configsource.ConfigSourceFactory; -import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.model.errorview.ErrorView; import net.sf.gridarta.model.errorview.ErrorViewCategory; import net.sf.gridarta.model.errorview.ErrorViewCollector; import net.sf.gridarta.model.errorview.ErrorViewCollectorErrorHandler; -import net.sf.gridarta.model.face.FaceObjectProviders; -import net.sf.gridarta.model.face.FaceObjects; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.gameobject.GameObjectFactory; -import net.sf.gridarta.model.io.CacheFiles; -import net.sf.gridarta.model.io.DefaultMapReaderFactory; import net.sf.gridarta.model.io.MapWriter; -import net.sf.gridarta.model.io.PathManager; import net.sf.gridarta.model.maparchobject.MapArchObject; -import net.sf.gridarta.model.maparchobject.MapArchObjectFactory; -import net.sf.gridarta.model.mapmanager.AbstractMapManager; -import net.sf.gridarta.model.mapmanager.MapManager; -import net.sf.gridarta.model.mapmodel.InsertionMode; -import net.sf.gridarta.model.mapmodel.MapModelFactory; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.match.GameObjectMatcher; import net.sf.gridarta.model.match.GameObjectMatchers; import net.sf.gridarta.model.match.GameObjectMatchersParser; import net.sf.gridarta.model.resource.AbstractResources; import net.sf.gridarta.model.scripts.ScriptArchUtils; -import net.sf.gridarta.model.settings.EditorSettings; import net.sf.gridarta.model.settings.ProjectSettings; import net.sf.gridarta.model.spells.ArchetypeSetSpellLoader; import net.sf.gridarta.model.spells.GameObjectSpell; @@ -79,7 +57,6 @@ import net.sf.gridarta.model.spells.Spells; import net.sf.gridarta.model.spells.XMLSpellLoader; import net.sf.gridarta.model.treasurelist.TreasureListsParser; -import net.sf.gridarta.model.treasurelist.TreasureTree; import net.sf.gridarta.model.treasurelist.TreasureTreeNode; import net.sf.gridarta.model.validation.DelegatingMapValidator; import net.sf.gridarta.model.validation.NoSuchValidatorException; @@ -90,15 +67,9 @@ import net.sf.gridarta.model.validation.checks.PaidItemShopSquareChecker; import net.sf.gridarta.model.validation.checks.ShopSquareChecker; import net.sf.gridarta.model.validation.checks.ValidatorFactory; -import net.sf.gridarta.plugin.PluginExecutor; -import net.sf.gridarta.plugin.PluginModel; -import net.sf.gridarta.plugin.PluginParameters; -import net.sf.gridarta.plugin.parameter.PluginParameterFactory; import net.sf.gridarta.utils.CommonConstants; -import net.sf.gridarta.utils.GuiFileFilters; import net.sf.gridarta.utils.IOUtils; import net.sf.gridarta.utils.StringUtils; -import net.sf.gridarta.utils.SystemIcons; import net.sf.gridarta.utils.XmlHelper; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; @@ -330,67 +301,4 @@ } } - /** - * Creates a new {@link GUIMainControl} instance. - * @param scriptFileFilter the file filter for script files - * @param scriptExtension the file extension for script files - * @param createDirectionPane whether the direction panel should be created - * @param mapManager the map manager - * @param pickmapManager the pickmap manager - * @param archetypeSet the archetype set - * @param mapModelFactory the map model factory - * @param compassIcon the icon to display in the selected square view; - * <code>null</code> to not show an icon - * @param gridartaJarFilename the filename of the editor's .jar file - * @param lockedItemsTypeNumbers the type numbers of game objects being - * locked items - * @param autoValidatorDefault whether the auto validator is enabled by - * default - * @param spellFile the spell file to load; <code>null</code> to not load a - * spell file - * @param editorFactory the editor factory to use - * @param errorView the error view to add errors to - * @param cacheFiles the cache files for icon and preview images - * @param configSourceFactory the config source factory to use - * @param rendererFactory the renderer factory - * @param filterControl the filter control to use - * @param pluginExecutor the script executor to use - * @param pluginParameters the script parameters to use - * @param faceObjects the face objects - * @param projectSettings the project settings - * @param editorSettings the editor settings - * @param mapViewSettings the map view settings - * @param faceObjectProviders the face object providers - * @param pathManager the path manager - * @param topmostInsertionMode the "topmost" insertion mode - * @param gameObjectFactory the game object factory - * @param systemIcons the system icons for creating icons - * @param undefinedSpellIndex the index for no spell - * @param archetypeTypeSet the archetype type set - * @param mapArchObjectFactory the map arch object factory to use - * @param treasureTree the treasure tree - * @param mapReaderFactory the map reader factory to use - * @param validators the map validators - * @param gameObjectMatchers the game object matchers - * @param scriptsDir the plugin scripts directory - * @param pluginModel the script model - * @param animationObjects the animation objects - * @param archetypeChooserModel the archetype chooser model - * @param allowRandomMapParameters whether exit paths may point to random - * map parameters - * @param scriptedEventEditor the scripted event editor - * @param scriptArchDataUtils the script arch data utils - * @param scriptArchUtils the script arch utils - * @param scriptArchEditor the script arch editor - * @param directionMap maps relative direction to map window direction - * @param resources the resources - * @param gameObjectSpells the game object spells to use - * @param numberSpells the number spells to use - * @param pluginParameterFactory the plugin parameter factory to use - * @return the new instance - */ - public GUIMainControl<G, A, R> createGUIMainControl(@NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, final boolean createDirectionPane, @NotNull final AbstractMapManager<G, A, R> mapManager, @NotNull final MapManager<G, A, R> pickmapManager, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final MapModelFactory<G, A, R> mapModelFactory, @Nullable final ImageIcon compassIcon, @NotNull final String gridartaJarFilename, @NotNull final int[] lockedItemsTypeNumbers, final boolean autoValidatorDefault, @Nullable final String spellFile, @NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final ErrorView errorView, @NotNull final CacheFiles cacheFiles, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final FilterControl<G, A, R> filterControl, @NotNull final PluginExecutor<G, A, R> pluginExecutor, @NotNull final PluginParameters pluginParameters, @NotNull final FaceObjects faceObjects, @NotNull final ProjectSettings projectSettings, @NotNull final EditorSettings editorSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<G, A, R> topmostInsertionMode, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final SystemIcons systemIcons, final int undefinedSpellIndex, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final TreasureTree treasureTree, @NotNull final DefaultMapReaderFactory<G, A, R> mapReaderFactory, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final String scriptsDir, @NotNull final PluginModel<G, A, R> pluginModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, final boolean allowRandomMapParameters, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final ScriptArchDataUtils<G, A, R> scriptArchDataUtils, @NotNull final ScriptArchUtils scriptArchUtils, @NotNull final ScriptArchEditor<G, A, R> scriptArchEditor, @NotNull final Direction[] directionMap, @NotNull final AbstractResources<G, A, R> resources, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final PluginParameterFactory<G, A, R> pluginParameterFactory) { - return new GUIMainControl<G, A, R>(createDirectionPane, mapManager, pickmapManager, archetypeSet, faceObjects, projectSettings, editorSettings, mapViewSettings, mapModelFactory, mapReaderFactory, mapArchObjectFactory, treasureTree, archetypeTypeSet, compassIcon, gridartaJarFilename, GuiFileFilters.mapFileFilter, scriptFileFilter, scriptExtension, validators, resources, gameObjectMatchers, errorView, lockedItemsTypeNumbers, scriptsDir, pluginModel, archetypeChooserModel, animationObjects, scriptArchEditor, scriptedEventEditor, scriptArchDataUtils, scriptArchUtils, autoValidatorDefault, spellFile, allowRandomMapParameters, directionMap, editorFactory, faceObjectProviders, pluginParameterFactory, gameObjectFactory, pathManager, cacheFiles, gameObjectSpells, numberSpells, undefinedSpellIndex, systemIcons, configSourceFactory, topmostInsertionMode, rendererFactory, filterControl, pluginExecutor, pluginParameters); - } - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-08 21:00:52
|
Revision: 9404 http://sourceforge.net/p/gridarta/code/9404 Author: akirschbaum Date: 2013-10-08 21:00:49 +0000 (Tue, 08 Oct 2013) Log Message: ----------- Move code from DefaultMainControl to GridartaEditor. Modified Paths: -------------- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java Modified: trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2013-10-08 20:15:38 UTC (rev 9403) +++ trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2013-10-08 21:00:49 UTC (rev 9404) @@ -22,6 +22,7 @@ import java.awt.Component; import java.io.IOException; import java.net.URL; +import javax.swing.filechooser.FileFilter; import net.sf.gridarta.gui.dialog.mapproperties.MapPropertiesDialogFactory; import net.sf.gridarta.gui.dialog.newmap.NewMapDialogFactory; import net.sf.gridarta.gui.dialog.prefs.AppPreferences; @@ -41,6 +42,7 @@ import net.sf.gridarta.gui.map.renderer.GridMapSquarePainter; import net.sf.gridarta.gui.map.renderer.RendererFactory; import net.sf.gridarta.gui.scripts.ScriptArchDataUtils; +import net.sf.gridarta.gui.scripts.ScriptArchEditor; import net.sf.gridarta.gui.scripts.ScriptedEventEditor; import net.sf.gridarta.maincontrol.DefaultMainControl; import net.sf.gridarta.maincontrol.EditorFactory; @@ -92,6 +94,7 @@ import net.sf.gridarta.model.spells.GameObjectSpell; import net.sf.gridarta.model.spells.NumberSpell; import net.sf.gridarta.model.spells.Spells; +import net.sf.gridarta.model.treasurelist.TreasureTree; import net.sf.gridarta.model.validation.DelegatingMapValidator; import net.sf.gridarta.model.validation.ValidatorPreferences; import net.sf.gridarta.model.validation.checks.AttributeRangeChecker; @@ -183,8 +186,8 @@ */ @NotNull @Override - public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(@NotNull final XmlHelper xmlHelper, final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter) { - return new DefaultMainControl<GameObject, MapArchObject, Archetype>(xmlHelper, GuiFileFilters.pythonFileFilter, ".py", "Python", errorView, this, forceReadFromFiles, projectSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, mapManager, validators, scriptedEventEditor, resources, validatorPreferences, mapWriter); + public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(@NotNull final XmlHelper xmlHelper, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter) { + return new DefaultMainControl<GameObject, MapArchObject, Archetype>(xmlHelper, errorView, this, projectSettings, gameObjectMatchers, archetypeTypeSet, validators, validatorPreferences, mapWriter); } /** @@ -476,8 +479,8 @@ */ @NotNull @Override - public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final PluginExecutor<GameObject, MapArchObject, Archetype> pluginExecutor, @NotNull final PluginParameters pluginParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapModelFactory<GameObject, MapArchObject, Archetype> mapModelFactory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects faceObjects, @NotNull final ProjectSettings projectSettings, @NotNull final EditorSettings editorSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final PluginModel<GameObject, MapArchObject, Archetype> pluginModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { - return mainControl.createGUIMainControl(GuiFileFilters.pythonFileFilter, ".py", true, mapManager, pickmapManager, archetypeSet, mapModelFactory, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "AtrinikEditor.jar", 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, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SPELL_FILE, this, errorView, new SubDirectoryCacheFiles(".dedit"), configSourceFactory, rendererFactory, filterControl, pluginExecutor, pluginParameters, faceObjects, projectSettings, editorSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, -1, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, pluginModel, animationObjects, archetypeChooserModel, false, scriptedEventEditor, new Direction[] { Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH, }, resources, gameObjectSpells, numberSpells, pluginParameterFactory); + public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final PluginExecutor<GameObject, MapArchObject, Archetype> pluginExecutor, @NotNull final PluginParameters pluginParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapModelFactory<GameObject, MapArchObject, Archetype> mapModelFactory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects faceObjects, @NotNull final ProjectSettings projectSettings, @NotNull final EditorSettings editorSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final TreasureTree treasureTree, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final PluginModel<GameObject, MapArchObject, Archetype> pluginModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final ScriptArchDataUtils<GameObject, MapArchObject, Archetype> scriptArchDataUtils, @NotNull final ScriptArchUtils scriptArchUtils, @NotNull final ScriptArchEditor<GameObject, MapArchObject, Archetype> scriptArchEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { + return mainControl.createGUIMainControl(GuiFileFilters.pythonFileFilter, getScriptExtension(), true, mapManager, pickmapManager, archetypeSet, mapModelFactory, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "AtrinikEditor.jar", 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, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SPELL_FILE, this, errorView, new SubDirectoryCacheFiles(".dedit"), configSourceFactory, rendererFactory, filterControl, pluginExecutor, pluginParameters, faceObjects, projectSettings, editorSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, -1, archetypeTypeSet, mapArchObjectFactory, treasureTree, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, pluginModel, animationObjects, archetypeChooserModel, false, scriptedEventEditor, scriptArchDataUtils, scriptArchUtils, scriptArchEditor, new Direction[] { Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH, }, resources, gameObjectSpells, numberSpells, pluginParameterFactory); } /** @@ -524,4 +527,31 @@ return 0; } + /** + * {@inheritDoc} + */ + @NotNull + @Override + public FileFilter getScriptFileFilter() { + return GuiFileFilters.pythonFileFilter; + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public String getScriptExtension() { + return ".py"; + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public String getScriptName() { + return "Python"; + } + } Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2013-10-08 20:15:38 UTC (rev 9403) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2013-10-08 21:00:49 UTC (rev 9404) @@ -20,6 +20,7 @@ package net.sf.gridarta.var.crossfire.maincontrol; import java.awt.Component; +import javax.swing.filechooser.FileFilter; import net.sf.gridarta.gui.dialog.mapproperties.MapPropertiesDialogFactory; import net.sf.gridarta.gui.dialog.newmap.NewMapDialogFactory; import net.sf.gridarta.gui.dialog.prefs.AppPreferences; @@ -39,6 +40,7 @@ import net.sf.gridarta.gui.map.renderer.GridMapSquarePainter; import net.sf.gridarta.gui.map.renderer.RendererFactory; import net.sf.gridarta.gui.scripts.ScriptArchDataUtils; +import net.sf.gridarta.gui.scripts.ScriptArchEditor; import net.sf.gridarta.gui.scripts.ScriptedEventEditor; import net.sf.gridarta.maincontrol.DefaultMainControl; import net.sf.gridarta.maincontrol.EditorFactory; @@ -88,6 +90,7 @@ import net.sf.gridarta.model.spells.GameObjectSpell; import net.sf.gridarta.model.spells.NumberSpell; import net.sf.gridarta.model.spells.Spells; +import net.sf.gridarta.model.treasurelist.TreasureTree; import net.sf.gridarta.model.validation.DelegatingMapValidator; import net.sf.gridarta.model.validation.ValidatorPreferences; import net.sf.gridarta.model.validation.checks.AttributeRangeChecker; @@ -152,8 +155,8 @@ */ @NotNull @Override - public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(@NotNull final XmlHelper xmlHelper, final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter) { - return new DefaultMainControl<GameObject, MapArchObject, Archetype>(xmlHelper, GuiFileFilters.pythonFileFilter, ".py", "Python", errorView, this, false, projectSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, mapManager, validators, scriptedEventEditor, resources, validatorPreferences, mapWriter); + public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(@NotNull final XmlHelper xmlHelper, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter) { + return new DefaultMainControl<GameObject, MapArchObject, Archetype>(xmlHelper, errorView, this, projectSettings, gameObjectMatchers, archetypeTypeSet, validators, validatorPreferences, mapWriter); } /** @@ -384,8 +387,8 @@ */ @NotNull @Override - public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final PluginExecutor<GameObject, MapArchObject, Archetype> pluginExecutor, @NotNull final PluginParameters pluginParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapModelFactory<GameObject, MapArchObject, Archetype> mapModelFactory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects faceObjects, @NotNull final ProjectSettings projectSettings, @NotNull final EditorSettings editorSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final PluginModel<GameObject, MapArchObject, Archetype> pluginModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { - return mainControl.createGUIMainControl(GuiFileFilters.pythonFileFilter, ".py", false, mapManager, pickmapManager, archetypeSet, mapModelFactory, null, "CrossfireEditor.jar", 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, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, null, this, errorView, new DirectoryCacheFiles(ConfigFileUtils.getHomeFile("thumbnails"), ".png"), configSourceFactory, rendererFactory, filterControl, pluginExecutor, pluginParameters, faceObjects, projectSettings, editorSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, 0, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, pluginModel, animationObjects, archetypeChooserModel, true, scriptedEventEditor, new Direction[] { Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, }, resources, gameObjectSpells, numberSpells, pluginParameterFactory); + public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final PluginExecutor<GameObject, MapArchObject, Archetype> pluginExecutor, @NotNull final PluginParameters pluginParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapModelFactory<GameObject, MapArchObject, Archetype> mapModelFactory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects faceObjects, @NotNull final ProjectSettings projectSettings, @NotNull final EditorSettings editorSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final TreasureTree treasureTree, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final PluginModel<GameObject, MapArchObject, Archetype> pluginModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final ScriptArchDataUtils<GameObject, MapArchObject, Archetype> scriptArchDataUtils, @NotNull final ScriptArchUtils scriptArchUtils, @NotNull final ScriptArchEditor<GameObject, MapArchObject, Archetype> scriptArchEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { + return mainControl.createGUIMainControl(GuiFileFilters.pythonFileFilter, getScriptExtension(), false, mapManager, pickmapManager, archetypeSet, mapModelFactory, null, "CrossfireEditor.jar", 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, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, null, this, errorView, new DirectoryCacheFiles(ConfigFileUtils.getHomeFile("thumbnails"), ".png"), configSourceFactory, rendererFactory, filterControl, pluginExecutor, pluginParameters, faceObjects, projectSettings, editorSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, 0, archetypeTypeSet, mapArchObjectFactory, treasureTree, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, pluginModel, animationObjects, archetypeChooserModel, true, scriptedEventEditor, scriptArchDataUtils, scriptArchUtils, scriptArchEditor, new Direction[] { Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, }, resources, gameObjectSpells, numberSpells, pluginParameterFactory); } /** @@ -435,4 +438,31 @@ return Archetype.TYPE_SPELL; } + /** + * {@inheritDoc} + */ + @NotNull + @Override + public FileFilter getScriptFileFilter() { + return GuiFileFilters.pythonFileFilter; + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public String getScriptExtension() { + return ".py"; + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public String getScriptName() { + return "Python"; + } + } Modified: trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2013-10-08 20:15:38 UTC (rev 9403) +++ trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2013-10-08 21:00:49 UTC (rev 9404) @@ -22,6 +22,7 @@ import java.awt.Component; import java.io.IOException; import java.net.URL; +import javax.swing.filechooser.FileFilter; import net.sf.gridarta.gui.dialog.mapproperties.MapPropertiesDialogFactory; import net.sf.gridarta.gui.dialog.newmap.NewMapDialogFactory; import net.sf.gridarta.gui.dialog.prefs.AppPreferences; @@ -41,6 +42,7 @@ import net.sf.gridarta.gui.map.renderer.GridMapSquarePainter; import net.sf.gridarta.gui.map.renderer.RendererFactory; import net.sf.gridarta.gui.scripts.ScriptArchDataUtils; +import net.sf.gridarta.gui.scripts.ScriptArchEditor; import net.sf.gridarta.gui.scripts.ScriptedEventEditor; import net.sf.gridarta.maincontrol.DefaultMainControl; import net.sf.gridarta.maincontrol.EditorFactory; @@ -92,6 +94,7 @@ import net.sf.gridarta.model.spells.GameObjectSpell; import net.sf.gridarta.model.spells.NumberSpell; import net.sf.gridarta.model.spells.Spells; +import net.sf.gridarta.model.treasurelist.TreasureTree; import net.sf.gridarta.model.validation.DelegatingMapValidator; import net.sf.gridarta.model.validation.ValidatorPreferences; import net.sf.gridarta.model.validation.checks.AttributeRangeChecker; @@ -182,8 +185,8 @@ */ @NotNull @Override - public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(@NotNull final XmlHelper xmlHelper, final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter) { - return new DefaultMainControl<GameObject, MapArchObject, Archetype>(xmlHelper, GuiFileFilters.luaFileFilter, ".lua", "Lua", errorView, this, forceReadFromFiles, projectSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, mapManager, validators, scriptedEventEditor, resources, validatorPreferences, mapWriter); + public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(@NotNull final XmlHelper xmlHelper, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter) { + return new DefaultMainControl<GameObject, MapArchObject, Archetype>(xmlHelper, errorView, this, projectSettings, gameObjectMatchers, archetypeTypeSet, validators, validatorPreferences, mapWriter); } /** @@ -475,8 +478,8 @@ */ @NotNull @Override - public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final PluginExecutor<GameObject, MapArchObject, Archetype> pluginExecutor, @NotNull final PluginParameters pluginParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapModelFactory<GameObject, MapArchObject, Archetype> mapModelFactory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects faceObjects, @NotNull final ProjectSettings projectSettings, @NotNull final EditorSettings editorSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final PluginModel<GameObject, MapArchObject, Archetype> pluginModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { - return mainControl.createGUIMainControl(GuiFileFilters.luaFileFilter, ".lua", true, mapManager, pickmapManager, archetypeSet, mapModelFactory, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", 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, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SPELL_FILE, this, errorView, new SubDirectoryCacheFiles(".dedit"), configSourceFactory, rendererFactory, filterControl, pluginExecutor, pluginParameters, faceObjects, projectSettings, editorSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, -1, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, pluginModel, animationObjects, archetypeChooserModel, false, scriptedEventEditor, new Direction[] { Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH, }, resources, gameObjectSpells, numberSpells, pluginParameterFactory); + public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final PluginExecutor<GameObject, MapArchObject, Archetype> pluginExecutor, @NotNull final PluginParameters pluginParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapModelFactory<GameObject, MapArchObject, Archetype> mapModelFactory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects faceObjects, @NotNull final ProjectSettings projectSettings, @NotNull final EditorSettings editorSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final TreasureTree treasureTree, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final PluginModel<GameObject, MapArchObject, Archetype> pluginModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final ScriptArchDataUtils<GameObject, MapArchObject, Archetype> scriptArchDataUtils, @NotNull final ScriptArchUtils scriptArchUtils, @NotNull final ScriptArchEditor<GameObject, MapArchObject, Archetype> scriptArchEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { + return mainControl.createGUIMainControl(GuiFileFilters.luaFileFilter, getScriptExtension(), true, mapManager, pickmapManager, archetypeSet, mapModelFactory, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", 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, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SPELL_FILE, this, errorView, new SubDirectoryCacheFiles(".dedit"), configSourceFactory, rendererFactory, filterControl, pluginExecutor, pluginParameters, faceObjects, projectSettings, editorSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, -1, archetypeTypeSet, mapArchObjectFactory, treasureTree, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, pluginModel, animationObjects, archetypeChooserModel, false, scriptedEventEditor, scriptArchDataUtils, scriptArchUtils, scriptArchEditor, new Direction[] { Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH, }, resources, gameObjectSpells, numberSpells, pluginParameterFactory); } /** @@ -523,4 +526,31 @@ return 0; } + /** + * {@inheritDoc} + */ + @NotNull + @Override + public FileFilter getScriptFileFilter() { + return GuiFileFilters.luaFileFilter; + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public String getScriptExtension() { + return ".lua"; + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public String getScriptName() { + return "Lua"; + } + } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 20:15:38 UTC (rev 9403) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 21:00:49 UTC (rev 9404) @@ -71,7 +71,6 @@ import net.sf.gridarta.model.match.GameObjectMatchersParser; import net.sf.gridarta.model.resource.AbstractResources; import net.sf.gridarta.model.scripts.ScriptArchUtils; -import net.sf.gridarta.model.scripts.ScriptedEventFactory; import net.sf.gridarta.model.settings.EditorSettings; import net.sf.gridarta.model.settings.ProjectSettings; import net.sf.gridarta.model.spells.ArchetypeSetSpellLoader; @@ -80,7 +79,6 @@ import net.sf.gridarta.model.spells.Spells; import net.sf.gridarta.model.spells.XMLSpellLoader; import net.sf.gridarta.model.treasurelist.TreasureListsParser; -import net.sf.gridarta.model.treasurelist.TreasureLoader; import net.sf.gridarta.model.treasurelist.TreasureTree; import net.sf.gridarta.model.treasurelist.TreasureTreeNode; import net.sf.gridarta.model.validation.DelegatingMapValidator; @@ -125,44 +123,19 @@ @NotNull private static final Category log = Logger.getLogger(DefaultMainControl.class); - @NotNull - private final TreasureTree treasureTree; - - @NotNull - private final ScriptArchEditor<G, A, R> scriptArchEditor; - - @NotNull - private final ScriptArchDataUtils<G, A, R> scriptArchDataUtils; - - @NotNull - private final ScriptArchUtils scriptArchUtils; - /** * Creates a new instance. * @param xmlHelper the xml helper instance for loading XML files - * @param scriptFileFilter the file filter for script files - * @param scriptExtension the file extension for script files - * @param scriptName the display name for script files * @param errorView the error view to add errors to * @param editorFactory the editor factory to use - * @param forceReadFromFiles if set, read resources from individual files - * ignoring the user's settings * @param projectSettings the project settings to use - * @param configSourceFactory the config source factory to use - * @param pathManager the path manager to use * @param gameObjectMatchers the game object matchers to use - * @param gameObjectFactory the game object factory to use * @param archetypeTypeSet the archetype type set to use - * @param archetypeSet the archetype set to use - * @param archetypeChooserModel the archetype chooser model to use - * @param mapManager the map manager * @param validators the map validators - * @param scriptedEventEditor the scripted event editor - * @param resources the resources * @param validatorPreferences the validator preferences to use * @param mapWriter the map writer for writing temporary map files */ - public DefaultMainControl(@NotNull final XmlHelper xmlHelper, @NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, @NotNull final String scriptName, final ErrorView errorView, @NotNull final EditorFactory<G, A, R> editorFactory, final boolean forceReadFromFiles, @NotNull final ProjectSettings projectSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final AbstractMapManager<G, A, R> mapManager, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final AbstractResources<G, A, R> resources, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<G, A, R> mapWriter) { + public DefaultMainControl(@NotNull final XmlHelper xmlHelper, final ErrorView errorView, @NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final ProjectSettings projectSettings, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<G, A, R> mapWriter) { final EnvironmentChecker<G, A, R> environmentChecker = new EnvironmentChecker<G, A, R>(validatorPreferences); AttributeRangeChecker<G, A, R> attributeRangeChecker = null; try { @@ -204,18 +177,10 @@ validators.addValidator(new PaidItemShopSquareChecker<G, A, R>(validatorPreferences, shopSquareMatcher, paidItemMatcher)); } } - final Map<String, TreasureTreeNode> specialTreasureLists = loadSpecialTreasureLists(errorView, xmlHelper.getDocumentBuilder(), projectSettings); - final ConfigSource configSource = forceReadFromFiles ? configSourceFactory.getFilesConfigSource() : configSourceFactory.getConfigSource(projectSettings.getConfigSourceName()); - treasureTree = TreasureLoader.parseTreasures(errorView, specialTreasureLists, configSource, projectSettings); - scriptArchUtils = loadScriptArchUtils(errorView, editorFactory, projectSettings, archetypeTypeSet, xmlHelper); - loadArchetypes(errorView, projectSettings, archetypeSet, archetypeChooserModel, resources, configSource); - final ScriptedEventFactory<G, A, R> scriptedEventFactory = editorFactory.newScriptedEventFactory(scriptArchUtils, gameObjectFactory, scriptedEventEditor, archetypeSet); - scriptArchEditor = new ScriptArchEditor<G, A, R>(scriptedEventFactory, scriptExtension, scriptName, scriptArchUtils, scriptFileFilter, projectSettings, mapManager, pathManager); - scriptArchDataUtils = editorFactory.newScriptArchDataUtils(scriptArchUtils, scriptedEventFactory, scriptedEventEditor); } @NotNull - private ScriptArchUtils loadScriptArchUtils(@NotNull final ErrorView errorView, final EditorFactory<G, A, R> editorFactory, @NotNull final ProjectSettings projectSettings, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final XmlHelper xmlHelper) { + public static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> ScriptArchUtils loadScriptArchUtils(@NotNull final ErrorView errorView, final EditorFactory<G, A, R> editorFactory, @NotNull final ProjectSettings projectSettings, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final XmlHelper xmlHelper) { final ArchetypeAttributeFactory archetypeAttributeFactory = new DefaultArchetypeAttributeFactory(); final ArchetypeAttributeParser archetypeAttributeParser = new ArchetypeAttributeParser(archetypeAttributeFactory); final ArchetypeTypeParser archetypeTypeParser = new ArchetypeTypeParser(archetypeAttributeParser); @@ -245,7 +210,7 @@ return editorFactory.newScriptArchUtils(eventTypeSet); } - private static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void loadArchetypes(@NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final AbstractResources<G, A, R> resources, @NotNull final ConfigSource configSource) { + public static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void loadArchetypes(@NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final AbstractResources<G, A, R> resources, @NotNull final ConfigSource configSource) { final long timeStart = System.currentTimeMillis(); if (log.isInfoEnabled()) { log.info("Start to load archetypes..."); @@ -306,7 +271,7 @@ } @NotNull - private static Map<String, TreasureTreeNode> loadSpecialTreasureLists(@NotNull final ErrorView errorView, @NotNull final DocumentBuilder documentBuilder, @NotNull final ProjectSettings projectSettings) { + public static Map<String, TreasureTreeNode> loadSpecialTreasureLists(@NotNull final ErrorView errorView, @NotNull final DocumentBuilder documentBuilder, @NotNull final ProjectSettings projectSettings) { Map<String, TreasureTreeNode> specialTreasureLists; try { final URL url = IOUtils.getResource(projectSettings.getConfigurationDirectory(), "TreasureLists.xml"); @@ -403,6 +368,7 @@ * @param undefinedSpellIndex the index for no spell * @param archetypeTypeSet the archetype type set * @param mapArchObjectFactory the map arch object factory to use + * @param treasureTree the treasure tree * @param mapReaderFactory the map reader factory to use * @param validators the map validators * @param gameObjectMatchers the game object matchers @@ -413,6 +379,9 @@ * @param allowRandomMapParameters whether exit paths may point to random * map parameters * @param scriptedEventEditor the scripted event editor + * @param scriptArchDataUtils the script arch data utils + * @param scriptArchUtils the script arch utils + * @param scriptArchEditor the script arch editor * @param directionMap maps relative direction to map window direction * @param resources the resources * @param gameObjectSpells the game object spells to use @@ -420,7 +389,7 @@ * @param pluginParameterFactory the plugin parameter factory to use * @return the new instance */ - public GUIMainControl<G, A, R> createGUIMainControl(@NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, final boolean createDirectionPane, @NotNull final AbstractMapManager<G, A, R> mapManager, @NotNull final MapManager<G, A, R> pickmapManager, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final MapModelFactory<G, A, R> mapModelFactory, @Nullable final ImageIcon compassIcon, @NotNull final String gridartaJarFilename, @NotNull final int[] lockedItemsTypeNumbers, final boolean autoValidatorDefault, @Nullable final String spellFile, @NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final ErrorView errorView, @NotNull final CacheFiles cacheFiles, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final FilterControl<G, A, R> filterControl, @NotNull final PluginExecutor<G, A, R> pluginExecutor, @NotNull final PluginParameters pluginParameters, @NotNull final FaceObjects faceObjects, @NotNull final ProjectSettings projectSettings, @NotNull final EditorSettings editorSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<G, A, R> topmostInsertionMode, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final SystemIcons systemIcons, final int undefinedSpellIndex, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<G, A, R> mapReaderFactory, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final String scriptsDir, @NotNull final PluginModel<G, A, R> pluginModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, final boolean allowRandomMapParameters, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final Direction[] directionMap, @NotNull final AbstractResources<G, A, R> resources, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final PluginParameterFactory<G, A, R> pluginParameterFactory) { + public GUIMainControl<G, A, R> createGUIMainControl(@NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, final boolean createDirectionPane, @NotNull final AbstractMapManager<G, A, R> mapManager, @NotNull final MapManager<G, A, R> pickmapManager, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final MapModelFactory<G, A, R> mapModelFactory, @Nullable final ImageIcon compassIcon, @NotNull final String gridartaJarFilename, @NotNull final int[] lockedItemsTypeNumbers, final boolean autoValidatorDefault, @Nullable final String spellFile, @NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final ErrorView errorView, @NotNull final CacheFiles cacheFiles, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final FilterControl<G, A, R> filterControl, @NotNull final PluginExecutor<G, A, R> pluginExecutor, @NotNull final PluginParameters pluginParameters, @NotNull final FaceObjects faceObjects, @NotNull final ProjectSettings projectSettings, @NotNull final EditorSettings editorSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<G, A, R> topmostInsertionMode, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final SystemIcons systemIcons, final int undefinedSpellIndex, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final TreasureTree treasureTree, @NotNull final DefaultMapReaderFactory<G, A, R> mapReaderFactory, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final String scriptsDir, @NotNull final PluginModel<G, A, R> pluginModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, final boolean allowRandomMapParameters, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final ScriptArchDataUtils<G, A, R> scriptArchDataUtils, @NotNull final ScriptArchUtils scriptArchUtils, @NotNull final ScriptArchEditor<G, A, R> scriptArchEditor, @NotNull final Direction[] directionMap, @NotNull final AbstractResources<G, A, R> resources, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final PluginParameterFactory<G, A, R> pluginParameterFactory) { return new GUIMainControl<G, A, R>(createDirectionPane, mapManager, pickmapManager, archetypeSet, faceObjects, projectSettings, editorSettings, mapViewSettings, mapModelFactory, mapReaderFactory, mapArchObjectFactory, treasureTree, archetypeTypeSet, compassIcon, gridartaJarFilename, GuiFileFilters.mapFileFilter, scriptFileFilter, scriptExtension, validators, resources, gameObjectMatchers, errorView, lockedItemsTypeNumbers, scriptsDir, pluginModel, archetypeChooserModel, animationObjects, scriptArchEditor, scriptedEventEditor, scriptArchDataUtils, scriptArchUtils, autoValidatorDefault, spellFile, allowRandomMapParameters, directionMap, editorFactory, faceObjectProviders, pluginParameterFactory, gameObjectFactory, pathManager, cacheFiles, gameObjectSpells, numberSpells, undefinedSpellIndex, systemIcons, configSourceFactory, topmostInsertionMode, rendererFactory, filterControl, pluginExecutor, pluginParameters); } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java 2013-10-08 20:15:38 UTC (rev 9403) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java 2013-10-08 21:00:49 UTC (rev 9404) @@ -20,6 +20,7 @@ package net.sf.gridarta.maincontrol; import java.awt.Component; +import javax.swing.filechooser.FileFilter; import net.sf.gridarta.gui.dialog.mapproperties.MapPropertiesDialogFactory; import net.sf.gridarta.gui.dialog.newmap.NewMapDialogFactory; import net.sf.gridarta.gui.dialog.prefs.AppPreferencesModel; @@ -29,6 +30,7 @@ import net.sf.gridarta.gui.map.mapview.MapViewsManager; import net.sf.gridarta.gui.map.renderer.RendererFactory; import net.sf.gridarta.gui.scripts.ScriptArchDataUtils; +import net.sf.gridarta.gui.scripts.ScriptArchEditor; import net.sf.gridarta.gui.scripts.ScriptedEventEditor; import net.sf.gridarta.model.anim.AnimationObjects; import net.sf.gridarta.model.archetype.Archetype; @@ -73,6 +75,7 @@ import net.sf.gridarta.model.spells.GameObjectSpell; import net.sf.gridarta.model.spells.NumberSpell; import net.sf.gridarta.model.spells.Spells; +import net.sf.gridarta.model.treasurelist.TreasureTree; import net.sf.gridarta.model.validation.DelegatingMapValidator; import net.sf.gridarta.model.validation.ValidatorPreferences; import net.sf.gridarta.model.validation.checks.AttributeRangeChecker; @@ -97,27 +100,17 @@ /** * Creates a new {@link DefaultMainControl} instance. * @param xmlHelper the xml helper instance for loading XML files - * @param forceReadFromFiles whether the current config source should be - * ignored * @param errorView the error view for reporting errors * @param projectSettings the project settings to use - * @param configSourceFactory the config source factory to use - * @param pathManager the path manager to use * @param gameObjectMatchers the game object matchers to use - * @param gameObjectFactory the game object factory to use * @param archetypeTypeSet the archetype type set to use - * @param archetypeSet the archetype set to use - * @param archetypeChooserModel the archetype chooser model to use - * @param mapManager the map manager * @param validators the map validators - * @param scriptedEventEditor the scripted event editor - * @param resources the resources * @param validatorPreferences the validator preferences to use * @param mapWriter the map writer for saving temporary maps * @return the new instance */ @NotNull - DefaultMainControl<G, A, R> newMainControl(@NotNull XmlHelper xmlHelper, boolean forceReadFromFiles, @NotNull ErrorView errorView, @NotNull ProjectSettings projectSettings, @NotNull ConfigSourceFactory configSourceFactory, @NotNull PathManager pathManager, @NotNull GameObjectMatchers gameObjectMatchers, @NotNull GameObjectFactory<G, A, R> gameObjectFactory, @NotNull ArchetypeTypeSet archetypeTypeSet, @NotNull ArchetypeSet<G, A, R> archetypeSet, @NotNull ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull AbstractMapManager<G, A, R> mapManager, @NotNull DelegatingMapValidator<G, A, R> validators, @NotNull ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull AbstractResources<G, A, R> resources, @NotNull ValidatorPreferences validatorPreferences, @NotNull MapWriter<G, A, R> mapWriter); + DefaultMainControl<G, A, R> newMainControl(@NotNull XmlHelper xmlHelper, @NotNull ErrorView errorView, @NotNull ProjectSettings projectSettings, @NotNull GameObjectMatchers gameObjectMatchers, @NotNull ArchetypeTypeSet archetypeTypeSet, @NotNull DelegatingMapValidator<G, A, R> validators, @NotNull ValidatorPreferences validatorPreferences, @NotNull MapWriter<G, A, R> mapWriter); /** * Returns the offset for drawing double faces. @@ -361,6 +354,7 @@ * @param systemIcons the system icons for creating icons * @param archetypeTypeSet the archetype type set * @param mapArchObjectFactory the map arch object factory to use + * @param treasureTree the treasure tree * @param mapReaderFactory the map reader factory to use * @param validators the map validators * @param gameObjectMatchers the game object matchers @@ -368,6 +362,9 @@ * @param animationObjects the animation objects * @param archetypeChooserModel the archetype chooser model * @param scriptedEventEditor the scripted event editor + * @param scriptArchDataUtils the script arch data utils + * @param scriptArchUtils the script arch utils + * @param scriptArchEditor the script arch editor * @param resources the resources * @param numberSpells the number spells to use * @param gameObjectSpells the game object spells to use @@ -375,7 +372,7 @@ * @return the new instance */ @NotNull - GUIMainControl<G, A, R> createGUIMainControl(@NotNull DefaultMainControl<G, A, R> mainControl, @NotNull ErrorView errorView, @NotNull GUIUtils guiUtils, @NotNull ConfigSourceFactory configSourceFactory, @NotNull RendererFactory<G, A, R> rendererFactory, @NotNull FilterControl<G, A, R> filterControl, @NotNull PluginExecutor<G, A, R> pluginExecutor, @NotNull PluginParameters pluginParameters, @NotNull AbstractMapManager<G, A, R> mapManager, @NotNull MapManager<G, A, R> pickmapManager, @NotNull MapModelFactory<G, A, R> mapModelFactory, @NotNull ArchetypeSet<G, A, R> archetypeSet, @NotNull FaceObjects faceObjects, @NotNull ProjectSettings projectSettings, @NotNull EditorSettings editorSettings, @NotNull MapViewSettings mapViewSettings, @NotNull FaceObjectProviders faceObjectProviders, @NotNull PathManager pathManager, @NotNull InsertionMode<G, A, R> topmostInsertionMode, @NotNull GameObjectFactory<G, A, R> gameObjectFactory, @NotNull SystemIcons systemIcons, @NotNull ArchetypeTypeSet archetypeTypeSet, @NotNull MapArchObjectFactory<A> mapArchObjectFactory, @NotNull DefaultMapReaderFactory<G, A, R> mapReaderFactory, @NotNull DelegatingMapValidator<G, A, R> validators, @NotNull GameObjectMatchers gameObjectMatchers, @NotNull PluginModel<G, A, R> pluginModel, @NotNull AnimationObjects animationObjects, @NotNull ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull AbstractResources<G, A, R> resources, @NotNull Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull PluginParameterFactory<G, A, R> pluginParameterFactory); + GUIMainControl<G, A, R> createGUIMainControl(@NotNull DefaultMainControl<G, A, R> mainControl, @NotNull ErrorView errorView, @NotNull GUIUtils guiUtils, @NotNull ConfigSourceFactory configSourceFactory, @NotNull RendererFactory<G, A, R> rendererFactory, @NotNull FilterControl<G, A, R> filterControl, @NotNull PluginExecutor<G, A, R> pluginExecutor, @NotNull PluginParameters pluginParameters, @No... [truncated message content] |
From: <aki...@us...> - 2013-10-08 20:15:45
|
Revision: 9403 http://sourceforge.net/p/gridarta/code/9403 Author: akirschbaum Date: 2013-10-08 20:15:38 +0000 (Tue, 08 Oct 2013) Log Message: ----------- Merge DefaultScriptArchEditor into ScriptArchEditor. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/ScriptArchEditor.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java Removed Paths: ------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java Deleted: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java 2013-10-08 19:52:14 UTC (rev 9402) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java 2013-10-08 20:15:38 UTC (rev 9403) @@ -1,409 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2011 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.gui.scripts; - -import java.awt.Color; -import java.awt.Component; -import java.awt.Container; -import java.awt.FlowLayout; -import java.awt.Frame; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import java.io.IOException; -import javax.swing.AbstractButton; -import javax.swing.BorderFactory; -import javax.swing.Box; -import javax.swing.BoxLayout; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JDialog; -import javax.swing.JFileChooser; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JTextField; -import javax.swing.WindowConstants; -import javax.swing.filechooser.FileFilter; -import javax.swing.text.JTextComponent; -import net.sf.gridarta.model.archetype.Archetype; -import net.sf.gridarta.model.gameobject.GameObject; -import net.sf.gridarta.model.io.PathManager; -import net.sf.gridarta.model.maparchobject.MapArchObject; -import net.sf.gridarta.model.mapmanager.MapManager; -import net.sf.gridarta.model.scripts.ScriptArchData; -import net.sf.gridarta.model.scripts.ScriptArchUtils; -import net.sf.gridarta.model.scripts.ScriptUtils; -import net.sf.gridarta.model.scripts.ScriptedEvent; -import net.sf.gridarta.model.scripts.ScriptedEventFactory; -import net.sf.gridarta.model.scripts.UndefinedEventArchetypeException; -import net.sf.gridarta.model.settings.ProjectSettings; -import net.sf.gridarta.textedit.scripteditor.ScriptEditControl; -import net.sf.gridarta.utils.FileChooserUtils; -import net.sf.japi.swing.action.ActionBuilder; -import net.sf.japi.swing.action.ActionBuilderFactory; -import net.sf.japi.util.Arrays2; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class DefaultScriptArchEditor<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements ScriptArchEditor<G, A, R> { - - /** - * Action Builder. - */ - @NotNull - private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); - - /** - * The {@link ScriptArchUtils} instance to use. - */ - @NotNull - private final ScriptArchUtils scriptArchUtils; - - /** - * The ending for scripts. - */ - @NotNull - private final String scriptEnding; - - /** - * The {@link PathManager} for converting path names. - */ - @NotNull - private final PathManager pathManager; - - /** - * The {@link ScriptEditControl} to use. - */ - @Nullable - private ScriptEditControl scriptEditControl; - - @NotNull - private final JComboBox eventTypeBox; - - @NotNull - private final FileFilter scriptFileFilter; - - /** - * The {@link ProjectSettings} to use. - */ - @NotNull - private final ProjectSettings projectSettings; - - /** - * The {@link MapManager} to use. - */ - @NotNull - private final MapManager<?, ?, ?> mapManager; - - @NotNull - private final JComboBox pluginNameBox; - - @NotNull - private JTextComponent inputScriptPath; - - @NotNull - private JTextComponent inputOptions; - - /** - * The {@link ScriptedEventFactory} instance to use. - */ - @NotNull - private final ScriptedEventFactory<G, A, R> scriptedEventFactory; - - /** - * Creates a new instance. - * @param scriptedEventFactory the scripted event factory instance to use - * @param scriptEnding the suffix for script files - * @param name the default event type - * @param scriptArchUtils the script arch utils to use - * @param scriptFileFilter the script file filter to use - * @param projectSettings the project settings to use - * @param mapManager the map manager instance to use - * @param pathManager the path manager for converting path names - */ - public DefaultScriptArchEditor(@NotNull final ScriptedEventFactory<G, A, R> scriptedEventFactory, final String scriptEnding, final String name, @NotNull final ScriptArchUtils scriptArchUtils, @NotNull final FileFilter scriptFileFilter, @NotNull final ProjectSettings projectSettings, @NotNull final MapManager<?, ?, ?> mapManager, @NotNull final PathManager pathManager) { - this.scriptedEventFactory = scriptedEventFactory; - this.scriptEnding = scriptEnding; - this.scriptArchUtils = scriptArchUtils; - this.pathManager = pathManager; - - pluginNameBox = new JComboBox(new String[] { name }); - pluginNameBox.setSelectedIndex(0); - - eventTypeBox = createEventTypeBox(scriptArchUtils); - this.scriptFileFilter = scriptFileFilter; - this.projectSettings = projectSettings; - this.mapManager = mapManager; - } - - @NotNull - private static JComboBox createEventTypeBox(@NotNull final ScriptArchUtils scriptArchUtils) { - final String[] valuesArray = scriptArchUtils.getEventNames(); - final JComboBox tmpEventTypeBox = new JComboBox(valuesArray); - tmpEventTypeBox.setSelectedIndex(Arrays2.linearEqualitySearch("say", valuesArray)); - return tmpEventTypeBox; - } - - /** - * {@inheritDoc} - */ - @Deprecated - @Override - public void setScriptEditControl(@Nullable final ScriptEditControl scriptEditControl) { - this.scriptEditControl = scriptEditControl; - } - - /** - * {@inheritDoc} - */ - @Override - public void addEventScript(@NotNull final G gameObject, @NotNull final ScriptArchData<G, A, R> scriptArchData, @NotNull final Frame parent) { - final String archName = gameObject.getBestName(); - // create a reasonable default script name for lazy users :-) - final String defScriptName = ScriptUtils.chooseDefaultScriptName(mapManager.getLocalMapDir(), archName, scriptEnding, pathManager); - - // initialize popup frame - final JDialog newScriptFrame = new JDialog(parent, "New Scripted Event", true); - newScriptFrame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); - - final JPanel mainPanel = new JPanel(); - mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); - mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 2, 5)); - - // first line: heading - final Container line1 = new JPanel(new FlowLayout(FlowLayout.LEFT)); - final Component headingLabel = new JLabel("New scripted event for \"" + archName + "\":"); - headingLabel.setForeground(Color.black); - line1.add(headingLabel); - mainPanel.add(line1); - - // event type - mainPanel.add(Box.createVerticalStrut(10)); - final Container line2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); - final Component typeLabel = new JLabel("Event type:"); - line2.add(typeLabel); - line2.add(eventTypeBox); - //mainPanel.add(line2); - line2.add(Box.createHorizontalStrut(10)); - - // plugin name - final Component pluginLabel = new JLabel("Plugin:"); - line2.add(pluginLabel); - line2.add(pluginNameBox); - mainPanel.add(line2); - - // path - mainPanel.add(Box.createVerticalStrut(5)); - final Container line3 = new JPanel(new FlowLayout(FlowLayout.LEFT)); - final Component scriptFileLabel = new JLabel("Script file:"); - line3.add(scriptFileLabel); - mainPanel.add(line3); - inputScriptPath = new JTextField(defScriptName, 20); - final AbstractButton browseButton = new JButton("..."); - browseButton.setMargin(new Insets(0, 10, 0, 10)); - browseButton.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(final ActionEvent e) { - final File home = mapManager.getLocalMapDir(); - - final JFileChooser fileChooser = new JFileChooser(); - fileChooser.setDialogTitle("Select Script File"); - fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - FileChooserUtils.setCurrentDirectory(fileChooser, home); - fileChooser.setMultiSelectionEnabled(false); - fileChooser.setFileFilter(scriptFileFilter); - - if (fileChooser.showOpenDialog(newScriptFrame) == JFileChooser.APPROVE_OPTION) { - // user has selected a file - final File f = fileChooser.getSelectedFile(); - inputScriptPath.setText(ScriptUtils.localizeEventPath(mapManager.getLocalMapDir(), f, projectSettings.getMapsDirectory())); - } - } - }); - line3.add(inputScriptPath); - line3.add(browseButton); - mainPanel.add(line3); - - // options - mainPanel.add(Box.createVerticalStrut(5)); - final Container line4 = new JPanel(new FlowLayout(FlowLayout.LEFT)); - line4.add(new JLabel("Script options:")); - inputOptions = new JTextField("", 20); - line4.add(inputOptions); - mainPanel.add(line4); - - // description - final Container line5 = new JPanel(new FlowLayout(FlowLayout.LEFT)); - final JPanel textPanel = new JPanel(); - textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.Y_AXIS)); - final Component label1 = new JLabel("When you specify an existing file, the new event will be linked"); - textPanel.add(label1); - final Component label2 = new JLabel("to that existing script. Otherwise a new script file is created."); - textPanel.add(label2); - line5.add(textPanel); - mainPanel.add(line5); - - // button panel: - mainPanel.add(Box.createVerticalStrut(10)); - final Container line6 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - final AbstractButton nsOkButton = new JButton("OK"); - nsOkButton.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(final ActionEvent e) { - createNewEvent(newScriptFrame, scriptArchData, gameObject); - } - - }); - line6.add(nsOkButton); - - final AbstractButton cancelButton = new JButton("Cancel"); - cancelButton.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(final ActionEvent e) { - newScriptFrame.setVisible(false); - } - - }); - line6.add(cancelButton); - mainPanel.add(line6); - - newScriptFrame.getContentPane().add(mainPanel); - newScriptFrame.pack(); - newScriptFrame.setLocationRelativeTo(parent); - newScriptFrame.setVisible(true); - } - - /** - * {@inheritDoc} - */ - @Override - public void createNewEvent(@NotNull final JDialog frame, @NotNull final ScriptArchData<G, A, R> scriptArchData, @NotNull final G gameObject) { - final StringBuilder scriptPath = new StringBuilder(inputScriptPath.getText().trim().replace('\\', '/')); - final String options = inputOptions.getText().trim(); - final int eventType = scriptArchUtils.indexToEventType(eventTypeBox.getSelectedIndex()); - final String pluginName = ((String) pluginNameBox.getSelectedItem()).trim(); - - final File localMapDir = mapManager.getLocalMapDir(); - - // first check if that event type is not already in use - final GameObject<G, A, R> 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) { - // bail out - return; - } - } - - String absScriptPath; - if (scriptPath.length() > 0 && scriptPath.charAt(0) == '/') { - // script path is absolute - final File mapDir = projectSettings.getMapsDirectory(); - if (!mapDir.exists()) { - // if map dir doesn't exist, this is not going to work - frame.setVisible(false); - ACTION_BUILDER.showMessageDialog(frame, "mapDirDoesntExist", mapDir); - return; - } - - absScriptPath = mapDir.getAbsolutePath() + scriptPath; - } else { - // script path is relative - absScriptPath = localMapDir.getAbsolutePath() + "/" + scriptPath; - } - - // now check if the specified path points to an existing script - File newScriptFile = new File(absScriptPath); - if (!newScriptFile.exists() && !absScriptPath.endsWith(scriptEnding)) { - absScriptPath += scriptEnding; - scriptPath.append(scriptEnding); - newScriptFile = new File(absScriptPath); - } - - if (newScriptFile.exists()) { - if (newScriptFile.isFile()) { - // file exists -> link it to the event - final ScriptedEvent<G, A, R> event; - try { - event = scriptedEventFactory.newScriptedEvent(eventType, pluginName, scriptPath.toString(), options); - } catch (final UndefinedEventArchetypeException ex) { - JOptionPane.showMessageDialog(frame, "Cannot create event of type " + eventType + ":\n" + ex.getMessage() + ".", "Cannot create event", JOptionPane.ERROR_MESSAGE); - return; - } - if (replaceObject != null) { - replaceObject.remove(); - } - gameObject.addLast(event.getEventArch()); - frame.setVisible(false); // close dialog - } - - return; - } - - if (!absScriptPath.endsWith(scriptEnding)) { - absScriptPath += scriptEnding; - scriptPath.append(scriptEnding); - newScriptFile = new File(absScriptPath); - } - - // file does not exist -> aks user: create new file? - if (JOptionPane.showConfirmDialog(frame, "Create new script '" + newScriptFile.getName() + "'?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) != JOptionPane.YES_OPTION) { - return; - } - - boolean couldCreateFile = false; // true when file creation successful - try { - // try to create new empty file - couldCreateFile = newScriptFile.createNewFile(); - } catch (final IOException e) { - /* ignore (really?) */ - } - - if (!couldCreateFile) { - JOptionPane.showMessageDialog(frame, "File '" + newScriptFile.getName() + "' could not be created.\n" + "Please check your path and write permissions.", "Cannot create file", JOptionPane.ERROR_MESSAGE); - return; - } - - // file has been created, now link it to the event - final ScriptedEvent<G, A, R> event; - try { - event = scriptedEventFactory.newScriptedEvent(eventType, pluginName, scriptPath.toString(), options); - } catch (final UndefinedEventArchetypeException ex) { - JOptionPane.showMessageDialog(frame, "Cannot create event of type " + eventType + ":\n" + ex.getMessage() + ".", "Cannot create event", JOptionPane.ERROR_MESSAGE); - return; - } - if (replaceObject != null) { - replaceObject.remove(); - } - gameObject.addLast(event.getEventArch()); - frame.setVisible(false); // close dialog - - // open new script file - if (scriptEditControl != null) { - scriptEditControl.openScriptFile(newScriptFile.getAbsolutePath()); - } - } - -} Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/ScriptArchEditor.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/ScriptArchEditor.java 2013-10-08 19:52:14 UTC (rev 9402) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/ScriptArchEditor.java 2013-10-08 20:15:38 UTC (rev 9403) @@ -19,21 +19,156 @@ package net.sf.gridarta.gui.scripts; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.FlowLayout; import java.awt.Frame; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.IOException; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.JButton; +import javax.swing.JComboBox; import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.WindowConstants; +import javax.swing.filechooser.FileFilter; +import javax.swing.text.JTextComponent; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.io.PathManager; import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapmanager.MapManager; import net.sf.gridarta.model.scripts.ScriptArchData; +import net.sf.gridarta.model.scripts.ScriptArchUtils; +import net.sf.gridarta.model.scripts.ScriptUtils; +import net.sf.gridarta.model.scripts.ScriptedEvent; +import net.sf.gridarta.model.scripts.ScriptedEventFactory; +import net.sf.gridarta.model.scripts.UndefinedEventArchetypeException; +import net.sf.gridarta.model.settings.ProjectSettings; import net.sf.gridarta.textedit.scripteditor.ScriptEditControl; +import net.sf.gridarta.utils.FileChooserUtils; +import net.sf.japi.swing.action.ActionBuilder; +import net.sf.japi.swing.action.ActionBuilderFactory; +import net.sf.japi.util.Arrays2; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public interface ScriptArchEditor<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { +public class ScriptArchEditor<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { - void createNewEvent(JDialog frame, ScriptArchData<G, A, R> scriptArchData, @NotNull G gameObject); + /** + * Action Builder. + */ + @NotNull + private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); /** + * The {@link ScriptArchUtils} instance to use. + */ + @NotNull + private final ScriptArchUtils scriptArchUtils; + + /** + * The ending for scripts. + */ + @NotNull + private final String scriptEnding; + + /** + * The {@link PathManager} for converting path names. + */ + @NotNull + private final PathManager pathManager; + + /** + * The {@link ScriptEditControl} to use. + */ + @Nullable + private ScriptEditControl scriptEditControl; + + @NotNull + private final JComboBox eventTypeBox; + + @NotNull + private final FileFilter scriptFileFilter; + + /** + * The {@link ProjectSettings} to use. + */ + @NotNull + private final ProjectSettings projectSettings; + + /** + * The {@link MapManager} to use. + */ + @NotNull + private final MapManager<?, ?, ?> mapManager; + + @NotNull + private final JComboBox pluginNameBox; + + @NotNull + private JTextComponent inputScriptPath; + + @NotNull + private JTextComponent inputOptions; + + /** + * The {@link ScriptedEventFactory} instance to use. + */ + @NotNull + private final ScriptedEventFactory<G, A, R> scriptedEventFactory; + + /** + * Creates a new instance. + * @param scriptedEventFactory the scripted event factory instance to use + * @param scriptEnding the suffix for script files + * @param name the default event type + * @param scriptArchUtils the script arch utils to use + * @param scriptFileFilter the script file filter to use + * @param projectSettings the project settings to use + * @param mapManager the map manager instance to use + * @param pathManager the path manager for converting path names + */ + public ScriptArchEditor(@NotNull final ScriptedEventFactory<G, A, R> scriptedEventFactory, final String scriptEnding, final String name, @NotNull final ScriptArchUtils scriptArchUtils, @NotNull final FileFilter scriptFileFilter, @NotNull final ProjectSettings projectSettings, @NotNull final MapManager<?, ?, ?> mapManager, @NotNull final PathManager pathManager) { + this.scriptedEventFactory = scriptedEventFactory; + this.scriptEnding = scriptEnding; + this.scriptArchUtils = scriptArchUtils; + this.pathManager = pathManager; + + pluginNameBox = new JComboBox(new String[] { name }); + pluginNameBox.setSelectedIndex(0); + + eventTypeBox = createEventTypeBox(scriptArchUtils); + this.scriptFileFilter = scriptFileFilter; + this.projectSettings = projectSettings; + this.mapManager = mapManager; + } + + @NotNull + private static JComboBox createEventTypeBox(@NotNull final ScriptArchUtils scriptArchUtils) { + final String[] valuesArray = scriptArchUtils.getEventNames(); + final JComboBox tmpEventTypeBox = new JComboBox(valuesArray); + tmpEventTypeBox.setSelectedIndex(Arrays2.linearEqualitySearch("say", valuesArray)); + return tmpEventTypeBox; + } + + @Deprecated + public void setScriptEditControl(@Nullable final ScriptEditControl scriptEditControl) { + this.scriptEditControl = scriptEditControl; + } + + /** * A popup is opened and the user can create a new scripting event which * gets attached to this gameObject. * @param gameObject the game object to add event to @@ -41,9 +176,230 @@ * display * @param parent the parent frame for the editor */ - void addEventScript(@NotNull G gameObject, @NotNull ScriptArchData<G, A, R> scriptArchData, @NotNull Frame parent); + public void addEventScript(@NotNull final G gameObject, @NotNull final ScriptArchData<G, A, R> scriptArchData, @NotNull final Frame parent) { + final String archName = gameObject.getBestName(); + // create a reasonable default script name for lazy users :-) + final String defScriptName = ScriptUtils.chooseDefaultScriptName(mapManager.getLocalMapDir(), archName, scriptEnding, pathManager); - @Deprecated - void setScriptEditControl(@Nullable ScriptEditControl scriptEditControl); + // initialize popup frame + final JDialog newScriptFrame = new JDialog(parent, "New Scripted Event", true); + newScriptFrame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); + final JPanel mainPanel = new JPanel(); + mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); + mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 2, 5)); + + // first line: heading + final Container line1 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + final Component headingLabel = new JLabel("New scripted event for \"" + archName + "\":"); + headingLabel.setForeground(Color.black); + line1.add(headingLabel); + mainPanel.add(line1); + + // event type + mainPanel.add(Box.createVerticalStrut(10)); + final Container line2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + final Component typeLabel = new JLabel("Event type:"); + line2.add(typeLabel); + line2.add(eventTypeBox); + //mainPanel.add(line2); + line2.add(Box.createHorizontalStrut(10)); + + // plugin name + final Component pluginLabel = new JLabel("Plugin:"); + line2.add(pluginLabel); + line2.add(pluginNameBox); + mainPanel.add(line2); + + // path + mainPanel.add(Box.createVerticalStrut(5)); + final Container line3 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + final Component scriptFileLabel = new JLabel("Script file:"); + line3.add(scriptFileLabel); + mainPanel.add(line3); + inputScriptPath = new JTextField(defScriptName, 20); + final AbstractButton browseButton = new JButton("..."); + browseButton.setMargin(new Insets(0, 10, 0, 10)); + browseButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(final ActionEvent e) { + final File home = mapManager.getLocalMapDir(); + + final JFileChooser fileChooser = new JFileChooser(); + fileChooser.setDialogTitle("Select Script File"); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + FileChooserUtils.setCurrentDirectory(fileChooser, home); + fileChooser.setMultiSelectionEnabled(false); + fileChooser.setFileFilter(scriptFileFilter); + + if (fileChooser.showOpenDialog(newScriptFrame) == JFileChooser.APPROVE_OPTION) { + // user has selected a file + final File f = fileChooser.getSelectedFile(); + inputScriptPath.setText(ScriptUtils.localizeEventPath(mapManager.getLocalMapDir(), f, projectSettings.getMapsDirectory())); + } + } + }); + line3.add(inputScriptPath); + line3.add(browseButton); + mainPanel.add(line3); + + // options + mainPanel.add(Box.createVerticalStrut(5)); + final Container line4 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + line4.add(new JLabel("Script options:")); + inputOptions = new JTextField("", 20); + line4.add(inputOptions); + mainPanel.add(line4); + + // description + final Container line5 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + final JPanel textPanel = new JPanel(); + textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.Y_AXIS)); + final Component label1 = new JLabel("When you specify an existing file, the new event will be linked"); + textPanel.add(label1); + final Component label2 = new JLabel("to that existing script. Otherwise a new script file is created."); + textPanel.add(label2); + line5.add(textPanel); + mainPanel.add(line5); + + // button panel: + mainPanel.add(Box.createVerticalStrut(10)); + final Container line6 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + final AbstractButton nsOkButton = new JButton("OK"); + nsOkButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(final ActionEvent e) { + createNewEvent(newScriptFrame, scriptArchData, gameObject); + } + + }); + line6.add(nsOkButton); + + final AbstractButton cancelButton = new JButton("Cancel"); + cancelButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(final ActionEvent e) { + newScriptFrame.setVisible(false); + } + + }); + line6.add(cancelButton); + mainPanel.add(line6); + + newScriptFrame.getContentPane().add(mainPanel); + newScriptFrame.pack(); + newScriptFrame.setLocationRelativeTo(parent); + newScriptFrame.setVisible(true); + } + + public void createNewEvent(@NotNull final JDialog frame, @NotNull final ScriptArchData<G, A, R> scriptArchData, @NotNull final G gameObject) { + final StringBuilder scriptPath = new StringBuilder(inputScriptPath.getText().trim().replace('\\', '/')); + final String options = inputOptions.getText().trim(); + final int eventType = scriptArchUtils.indexToEventType(eventTypeBox.getSelectedIndex()); + final String pluginName = ((String) pluginNameBox.getSelectedItem()).trim(); + + final File localMapDir = mapManager.getLocalMapDir(); + + // first check if that event type is not already in use + final GameObject<G, A, R> 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) { + // bail out + return; + } + } + + String absScriptPath; + if (scriptPath.length() > 0 && scriptPath.charAt(0) == '/') { + // script path is absolute + final File mapDir = projectSettings.getMapsDirectory(); + if (!mapDir.exists()) { + // if map dir doesn't exist, this is not going to work + frame.setVisible(false); + ACTION_BUILDER.showMessageDialog(frame, "mapDirDoesntExist", mapDir); + return; + } + + absScriptPath = mapDir.getAbsolutePath() + scriptPath; + } else { + // script path is relative + absScriptPath = localMapDir.getAbsolutePath() + "/" + scriptPath; + } + + // now check if the specified path points to an existing script + File newScriptFile = new File(absScriptPath); + if (!newScriptFile.exists() && !absScriptPath.endsWith(scriptEnding)) { + absScriptPath += scriptEnding; + scriptPath.append(scriptEnding); + newScriptFile = new File(absScriptPath); + } + + if (newScriptFile.exists()) { + if (newScriptFile.isFile()) { + // file exists -> link it to the event + final ScriptedEvent<G, A, R> event; + try { + event = scriptedEventFactory.newScriptedEvent(eventType, pluginName, scriptPath.toString(), options); + } catch (final UndefinedEventArchetypeException ex) { + JOptionPane.showMessageDialog(frame, "Cannot create event of type " + eventType + ":\n" + ex.getMessage() + ".", "Cannot create event", JOptionPane.ERROR_MESSAGE); + return; + } + if (replaceObject != null) { + replaceObject.remove(); + } + gameObject.addLast(event.getEventArch()); + frame.setVisible(false); // close dialog + } + + return; + } + + if (!absScriptPath.endsWith(scriptEnding)) { + absScriptPath += scriptEnding; + scriptPath.append(scriptEnding); + newScriptFile = new File(absScriptPath); + } + + // file does not exist -> aks user: create new file? + if (JOptionPane.showConfirmDialog(frame, "Create new script '" + newScriptFile.getName() + "'?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) != JOptionPane.YES_OPTION) { + return; + } + + boolean couldCreateFile = false; // true when file creation successful + try { + // try to create new empty file + couldCreateFile = newScriptFile.createNewFile(); + } catch (final IOException e) { + /* ignore (really?) */ + } + + if (!couldCreateFile) { + JOptionPane.showMessageDialog(frame, "File '" + newScriptFile.getName() + "' could not be created.\n" + "Please check your path and write permissions.", "Cannot create file", JOptionPane.ERROR_MESSAGE); + return; + } + + // file has been created, now link it to the event + final ScriptedEvent<G, A, R> event; + try { + event = scriptedEventFactory.newScriptedEvent(eventType, pluginName, scriptPath.toString(), options); + } catch (final UndefinedEventArchetypeException ex) { + JOptionPane.showMessageDialog(frame, "Cannot create event of type " + eventType + ":\n" + ex.getMessage() + ".", "Cannot create event", JOptionPane.ERROR_MESSAGE); + return; + } + if (replaceObject != null) { + replaceObject.remove(); + } + gameObject.addLast(event.getEventArch()); + frame.setVisible(false); // close dialog + + // open new script file + if (scriptEditControl != null) { + scriptEditControl.openScriptFile(newScriptFile.getAbsolutePath()); + } + } + } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 19:52:14 UTC (rev 9402) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 20:15:38 UTC (rev 9403) @@ -30,7 +30,6 @@ import javax.xml.parsers.DocumentBuilder; import net.sf.gridarta.gui.filter.FilterControl; import net.sf.gridarta.gui.map.renderer.RendererFactory; -import net.sf.gridarta.gui.scripts.DefaultScriptArchEditor; import net.sf.gridarta.gui.scripts.ScriptArchDataUtils; import net.sf.gridarta.gui.scripts.ScriptArchEditor; import net.sf.gridarta.gui.scripts.ScriptedEventEditor; @@ -211,7 +210,7 @@ scriptArchUtils = loadScriptArchUtils(errorView, editorFactory, projectSettings, archetypeTypeSet, xmlHelper); loadArchetypes(errorView, projectSettings, archetypeSet, archetypeChooserModel, resources, configSource); final ScriptedEventFactory<G, A, R> scriptedEventFactory = editorFactory.newScriptedEventFactory(scriptArchUtils, gameObjectFactory, scriptedEventEditor, archetypeSet); - scriptArchEditor = new DefaultScriptArchEditor<G, A, R>(scriptedEventFactory, scriptExtension, scriptName, scriptArchUtils, scriptFileFilter, projectSettings, mapManager, pathManager); + scriptArchEditor = new ScriptArchEditor<G, A, R>(scriptedEventFactory, scriptExtension, scriptName, scriptArchUtils, scriptFileFilter, projectSettings, mapManager, pathManager); scriptArchDataUtils = editorFactory.newScriptArchDataUtils(scriptArchUtils, scriptedEventFactory, scriptedEventEditor); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-08 19:52:20
|
Revision: 9402 http://sourceforge.net/p/gridarta/code/9402 Author: akirschbaum Date: 2013-10-08 19:52:14 +0000 (Tue, 08 Oct 2013) Log Message: ----------- Remove PathButtonListener2. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java Removed Paths: ------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonListener2.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java 2013-10-08 19:45:57 UTC (rev 9401) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java 2013-10-08 19:52:14 UTC (rev 9402) @@ -117,23 +117,12 @@ @NotNull private final JComboBox pluginNameBox; - // popup frame for new scripts: - - @Nullable - private JDialog newScriptFrame; - @NotNull - private JLabel headingLabel; - - @NotNull private JTextComponent inputScriptPath; @NotNull private JTextComponent inputOptions; - @NotNull - private PathButtonListener2<G, A, R> nsOkListener; - /** * The {@link ScriptedEventFactory} instance to use. */ @@ -192,122 +181,118 @@ // create a reasonable default script name for lazy users :-) final String defScriptName = ScriptUtils.chooseDefaultScriptName(mapManager.getLocalMapDir(), archName, scriptEnding, pathManager); - if (newScriptFrame == null) { - // initialize popup frame - newScriptFrame = new JDialog(parent, "New Scripted Event", true); - newScriptFrame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); + // initialize popup frame + final JDialog newScriptFrame = new JDialog(parent, "New Scripted Event", true); + newScriptFrame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); - final JPanel mainPanel = new JPanel(); - mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); - mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 2, 5)); + final JPanel mainPanel = new JPanel(); + mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); + mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 2, 5)); - // first line: heading - final Container line1 = new JPanel(new FlowLayout(FlowLayout.LEFT)); - headingLabel = new JLabel("New scripted event for \"" + archName + "\":"); - headingLabel.setForeground(Color.black); - line1.add(headingLabel); - mainPanel.add(line1); + // first line: heading + final Container line1 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + final Component headingLabel = new JLabel("New scripted event for \"" + archName + "\":"); + headingLabel.setForeground(Color.black); + line1.add(headingLabel); + mainPanel.add(line1); - // event type - mainPanel.add(Box.createVerticalStrut(10)); - final Container line2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); - final Component typeLabel = new JLabel("Event type:"); - line2.add(typeLabel); - line2.add(eventTypeBox); - //mainPanel.add(line2); - line2.add(Box.createHorizontalStrut(10)); + // event type + mainPanel.add(Box.createVerticalStrut(10)); + final Container line2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + final Component typeLabel = new JLabel("Event type:"); + line2.add(typeLabel); + line2.add(eventTypeBox); + //mainPanel.add(line2); + line2.add(Box.createHorizontalStrut(10)); - // plugin name - final Component pluginLabel = new JLabel("Plugin:"); - line2.add(pluginLabel); - line2.add(pluginNameBox); - mainPanel.add(line2); + // plugin name + final Component pluginLabel = new JLabel("Plugin:"); + line2.add(pluginLabel); + line2.add(pluginNameBox); + mainPanel.add(line2); - // path - mainPanel.add(Box.createVerticalStrut(5)); - final Container line3 = new JPanel(new FlowLayout(FlowLayout.LEFT)); - final Component scriptFileLabel = new JLabel("Script file:"); - line3.add(scriptFileLabel); - mainPanel.add(line3); - inputScriptPath = new JTextField(defScriptName, 20); - final AbstractButton browseButton = new JButton("..."); - browseButton.setMargin(new Insets(0, 10, 0, 10)); - browseButton.addActionListener(new ActionListener() { + // path + mainPanel.add(Box.createVerticalStrut(5)); + final Container line3 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + final Component scriptFileLabel = new JLabel("Script file:"); + line3.add(scriptFileLabel); + mainPanel.add(line3); + inputScriptPath = new JTextField(defScriptName, 20); + final AbstractButton browseButton = new JButton("..."); + browseButton.setMargin(new Insets(0, 10, 0, 10)); + browseButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(final ActionEvent e) { - final File home = mapManager.getLocalMapDir(); + @Override + public void actionPerformed(final ActionEvent e) { + final File home = mapManager.getLocalMapDir(); - final JFileChooser fileChooser = new JFileChooser(); - fileChooser.setDialogTitle("Select Script File"); - fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - FileChooserUtils.setCurrentDirectory(fileChooser, home); - fileChooser.setMultiSelectionEnabled(false); - fileChooser.setFileFilter(scriptFileFilter); + final JFileChooser fileChooser = new JFileChooser(); + fileChooser.setDialogTitle("Select Script File"); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + FileChooserUtils.setCurrentDirectory(fileChooser, home); + fileChooser.setMultiSelectionEnabled(false); + fileChooser.setFileFilter(scriptFileFilter); - if (fileChooser.showOpenDialog(newScriptFrame) == JFileChooser.APPROVE_OPTION) { - // user has selected a file - final File f = fileChooser.getSelectedFile(); - inputScriptPath.setText(ScriptUtils.localizeEventPath(mapManager.getLocalMapDir(), f, projectSettings.getMapsDirectory())); - } + if (fileChooser.showOpenDialog(newScriptFrame) == JFileChooser.APPROVE_OPTION) { + // user has selected a file + final File f = fileChooser.getSelectedFile(); + inputScriptPath.setText(ScriptUtils.localizeEventPath(mapManager.getLocalMapDir(), f, projectSettings.getMapsDirectory())); } - }); - line3.add(inputScriptPath); - line3.add(browseButton); - mainPanel.add(line3); + } + }); + line3.add(inputScriptPath); + line3.add(browseButton); + mainPanel.add(line3); - // options - mainPanel.add(Box.createVerticalStrut(5)); - final Container line4 = new JPanel(new FlowLayout(FlowLayout.LEFT)); - line4.add(new JLabel("Script options:")); - inputOptions = new JTextField("", 20); - line4.add(inputOptions); - mainPanel.add(line4); + // options + mainPanel.add(Box.createVerticalStrut(5)); + final Container line4 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + line4.add(new JLabel("Script options:")); + inputOptions = new JTextField("", 20); + line4.add(inputOptions); + mainPanel.add(line4); - // description - final Container line5 = new JPanel(new FlowLayout(FlowLayout.LEFT)); - final JPanel textPanel = new JPanel(); - textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.Y_AXIS)); - final Component label1 = new JLabel("When you specify an existing file, the new event will be linked"); - textPanel.add(label1); - final Component label2 = new JLabel("to that existing script. Otherwise a new script file is created."); - textPanel.add(label2); - line5.add(textPanel); - mainPanel.add(line5); + // description + final Container line5 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + final JPanel textPanel = new JPanel(); + textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.Y_AXIS)); + final Component label1 = new JLabel("When you specify an existing file, the new event will be linked"); + textPanel.add(label1); + final Component label2 = new JLabel("to that existing script. Otherwise a new script file is created."); + textPanel.add(label2); + line5.add(textPanel); + mainPanel.add(line5); - // button panel: - mainPanel.add(Box.createVerticalStrut(10)); - final Container line6 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - final AbstractButton nsOkButton = new JButton("OK"); - nsOkListener = new PathButtonListener2<G, A, R>(newScriptFrame, scriptArchData, gameObject, this); - nsOkButton.addActionListener(nsOkListener); - line6.add(nsOkButton); + // button panel: + mainPanel.add(Box.createVerticalStrut(10)); + final Container line6 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + final AbstractButton nsOkButton = new JButton("OK"); + nsOkButton.addActionListener(new ActionListener() { - final AbstractButton cancelButton = new JButton("Cancel"); - cancelButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(final ActionEvent e) { + createNewEvent(newScriptFrame, scriptArchData, gameObject); + } - @Override - public void actionPerformed(final ActionEvent e) { - newScriptFrame.setVisible(false); - } + }); + line6.add(nsOkButton); - }); - line6.add(cancelButton); - mainPanel.add(line6); + final AbstractButton cancelButton = new JButton("Cancel"); + cancelButton.addActionListener(new ActionListener() { - newScriptFrame.getContentPane().add(mainPanel); - newScriptFrame.pack(); - newScriptFrame.setLocationRelativeTo(parent); - newScriptFrame.setVisible(true); - } else { - // just set fields and show - headingLabel.setText("New scripted event for \"" + archName + "\":"); - inputScriptPath.setText(defScriptName); - inputOptions.setText(""); - nsOkListener.setScriptArchData(scriptArchData, gameObject); - newScriptFrame.toFront(); - newScriptFrame.setVisible(true); - } + @Override + public void actionPerformed(final ActionEvent e) { + newScriptFrame.setVisible(false); + } + + }); + line6.add(cancelButton); + mainPanel.add(line6); + + newScriptFrame.getContentPane().add(mainPanel); + newScriptFrame.pack(); + newScriptFrame.setLocationRelativeTo(parent); + newScriptFrame.setVisible(true); } /** Deleted: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonListener2.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonListener2.java 2013-10-08 19:45:57 UTC (rev 9401) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonListener2.java 2013-10-08 19:52:14 UTC (rev 9402) @@ -1,92 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2011 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.gui.scripts; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import javax.swing.JDialog; -import net.sf.gridarta.model.archetype.Archetype; -import net.sf.gridarta.model.gameobject.GameObject; -import net.sf.gridarta.model.maparchobject.MapArchObject; -import net.sf.gridarta.model.scripts.ScriptArchData; -import org.jetbrains.annotations.NotNull; - -/** - * Small class, listening for button-press events in the popup frame for script - * paths or create-new-event frame. - * @author Andreas Kirschbaum - */ -public class PathButtonListener2<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements ActionListener { - - @NotNull - private final JDialog frame; - - /** - * The ScriptArchData to operate on. - */ - @NotNull - private ScriptArchData<G, A, R> scriptArchData; - - /** - * The affected game object. - */ - @NotNull - private G gameObject; - - /** - * The {@link ScriptArchEditor} instance to use. - */ - @NotNull - private final ScriptArchEditor<G, A, R> scriptArchEditor; - - /** - * Create a PathButtonListener. - * @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 - * @param scriptArchEditor the script arch editor to use - */ - public PathButtonListener2(@NotNull final JDialog frame, @NotNull final ScriptArchData<G, A, R> scriptArchData, @NotNull final G gameObject, @NotNull final ScriptArchEditor<G, A, R> scriptArchEditor) { - this.frame = frame; - this.scriptArchData = scriptArchData; - this.gameObject = gameObject; - this.scriptArchEditor = scriptArchEditor; - } - - /** - * Set the ScriptArchData to operate on. - * @param scriptArchData the script arch data to operate on - * @param gameObject the affected game object - */ - public void setScriptArchData(@NotNull final ScriptArchData<G, A, R> scriptArchData, @NotNull final G gameObject) { - this.scriptArchData = scriptArchData; - this.gameObject = gameObject; - } - - /** - * {@inheritDoc} - */ - @Override - public void actionPerformed(@NotNull final ActionEvent e) { - scriptArchEditor.createNewEvent(frame, scriptArchData, gameObject); - } - -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-08 19:46:00
|
Revision: 9401 http://sourceforge.net/p/gridarta/code/9401 Author: akirschbaum Date: 2013-10-08 19:45:57 +0000 (Tue, 08 Oct 2013) Log Message: ----------- Remove PathButtonListener. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/ScriptedEventEditor.java Removed Paths: ------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonListener.java Deleted: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonListener.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonListener.java 2013-10-08 19:39:40 UTC (rev 9400) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonListener.java 2013-10-08 19:45:57 UTC (rev 9401) @@ -1,75 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2011 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.gui.scripts; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import javax.swing.JDialog; -import net.sf.gridarta.model.archetype.Archetype; -import net.sf.gridarta.model.gameobject.GameObject; -import net.sf.gridarta.model.maparchobject.MapArchObject; -import net.sf.gridarta.model.scripts.ScriptedEvent; -import org.jetbrains.annotations.NotNull; - -/** - * Small class, listening for button-press events in the popup frame for script - * paths or create-new-event frame. - * @author Andreas Kirschbaum - */ -public class PathButtonListener<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements ActionListener { - - @NotNull - private final JDialog frame; - - - /** - * The target event to script. - */ - @NotNull - private ScriptedEvent<G, A, R> scriptedEvent; - - /** - * Create a PathButtonListener. - * @param frame frame this listener belongs to - * @param scriptedEvent the target event to script - */ - public PathButtonListener(@NotNull final JDialog frame, @NotNull final ScriptedEvent<G, A, R> scriptedEvent) { - this.frame = frame; - this.scriptedEvent = scriptedEvent; - } - - /** - * Set the target event to script. - * @param scriptedEvent the new target event to script - */ - public void setTargetEvent(@NotNull final ScriptedEvent<G, A, R> scriptedEvent) { - this.scriptedEvent = scriptedEvent; - } - - /** - * {@inheritDoc} - */ - @Override - public void actionPerformed(@NotNull final ActionEvent e) { - scriptedEvent.modifyEventPath(); - frame.setVisible(false); - } - -} Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/ScriptedEventEditor.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/ScriptedEventEditor.java 2013-10-08 19:39:40 UTC (rev 9400) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/ScriptedEventEditor.java 2013-10-08 19:45:57 UTC (rev 9401) @@ -78,14 +78,6 @@ @NotNull private JTextComponent inputOptions; - @NotNull - private PathButtonListener<G, A, R> okListener; - - // popup frame to edit script paths: - - @Nullable - private JDialog pathFrame; - /** * Creates a new instance. * @param projectSettings the project settings instance @@ -135,73 +127,69 @@ * @param parent the parent frame for dialog boxes */ public void editParameters(@NotNull final ScriptedEvent<G, A, R> scriptedEvent, @NotNull final Frame parent) { - if (pathFrame == null) { - // initialize popup frame - pathFrame = new JDialog(parent, "Edit Parameters", true); - pathFrame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); + final JDialog pathFrame = new JDialog(parent, "Edit Parameters", true); + pathFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - final JPanel mainPanel = new JPanel(); - mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); - mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 2, 5)); + final JPanel mainPanel = new JPanel(); + mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); + mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 2, 5)); - // input line: script path - final Container line1 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - final Component text1 = new JLabel("Script:"); - line1.add(text1); - inputScriptPath = new JTextField(scriptedEvent.getScriptPath(), 20); - line1.add(inputScriptPath); - mainPanel.add(line1); + // input line: script path + final Container line1 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + final Component text1 = new JLabel("Script:"); + line1.add(text1); + inputScriptPath = new JTextField(scriptedEvent.getScriptPath(), 20); + line1.add(inputScriptPath); + mainPanel.add(line1); - // input line: plugin options - final Container line2 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - final Component text2 = new JLabel("Script options:"); - line2.add(text2); - inputOptions = new JTextField(scriptedEvent.getOptions(), 20); - line2.add(inputOptions); - mainPanel.add(line2); - mainPanel.add(Box.createVerticalStrut(5)); + // input line: plugin options + final Container line2 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + final Component text2 = new JLabel("Script options:"); + line2.add(text2); + inputOptions = new JTextField(scriptedEvent.getOptions(), 20); + line2.add(inputOptions); + mainPanel.add(line2); + mainPanel.add(Box.createVerticalStrut(5)); - // input line: plugin name - final Container line3 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - final Component text3 = new JLabel("Plugin name:"); - line3.add(text3); - inputPluginName = new JTextField(scriptedEvent.getPluginName(), 20); - line3.add(inputPluginName); - mainPanel.add(line3); - mainPanel.add(Box.createVerticalStrut(5)); + // input line: plugin name + final Container line3 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + final Component text3 = new JLabel("Plugin name:"); + line3.add(text3); + inputPluginName = new JTextField(scriptedEvent.getPluginName(), 20); + line3.add(inputPluginName); + mainPanel.add(line3); + mainPanel.add(Box.createVerticalStrut(5)); - // button panel: - final Container line4 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - final AbstractButton okButton = new JButton("OK"); - okListener = new PathButtonListener<G, A, R>(pathFrame, scriptedEvent); - okButton.addActionListener(okListener); - line4.add(okButton); + // button panel: + final Container line4 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + final AbstractButton okButton = new JButton("OK"); + okButton.addActionListener(new ActionListener() { - final AbstractButton cancelButton = new JButton("Cancel"); - cancelButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(final ActionEvent e) { + scriptedEvent.modifyEventPath(); + pathFrame.dispose(); + } - @Override - public void actionPerformed(final ActionEvent e) { - pathFrame.setVisible(false); - } + }); + line4.add(okButton); - }); - line4.add(cancelButton); - mainPanel.add(line4); + final AbstractButton cancelButton = new JButton("Cancel"); + cancelButton.addActionListener(new ActionListener() { - pathFrame.getContentPane().add(mainPanel); - pathFrame.pack(); - pathFrame.setLocationRelativeTo(parent); - pathFrame.setVisible(true); - } else { - // just set fields and show - okListener.setTargetEvent(scriptedEvent); - inputScriptPath.setText(scriptedEvent.getScriptPath()); - inputPluginName.setText(scriptedEvent.getPluginName()); - inputOptions.setText(scriptedEvent.getOptions()); - pathFrame.toFront(); - pathFrame.setVisible(true); - } + @Override + public void actionPerformed(final ActionEvent e) { + pathFrame.dispose(); + } + + }); + line4.add(cancelButton); + mainPanel.add(line4); + + pathFrame.getContentPane().add(mainPanel); + pathFrame.pack(); + pathFrame.setLocationRelativeTo(parent); + pathFrame.setVisible(true); } @NotNull This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-08 19:39:48
|
Revision: 9400 http://sourceforge.net/p/gridarta/code/9400 Author: akirschbaum Date: 2013-10-08 19:39:40 +0000 (Tue, 08 Oct 2013) Log Message: ----------- Add nullable annotations. Simplify code accordingly. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonListener.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonListener2.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/ScriptArchEditor.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java 2013-10-08 19:34:58 UTC (rev 9399) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java 2013-10-08 19:39:40 UTC (rev 9400) @@ -187,7 +187,7 @@ * {@inheritDoc} */ @Override - public void addEventScript(final G gameObject, final ScriptArchData<G, A, R> scriptArchData, @NotNull final Frame parent) { + public void addEventScript(@NotNull final G gameObject, @NotNull final ScriptArchData<G, A, R> scriptArchData, @NotNull final Frame parent) { final String archName = gameObject.getBestName(); // create a reasonable default script name for lazy users :-) final String defScriptName = ScriptUtils.chooseDefaultScriptName(mapManager.getLocalMapDir(), archName, scriptEnding, pathManager); Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonListener.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonListener.java 2013-10-08 19:34:58 UTC (rev 9399) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonListener.java 2013-10-08 19:39:40 UTC (rev 9400) @@ -27,7 +27,6 @@ import net.sf.gridarta.model.maparchobject.MapArchObject; import net.sf.gridarta.model.scripts.ScriptedEvent; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; /** * Small class, listening for button-press events in the popup frame for script @@ -43,7 +42,7 @@ /** * The target event to script. */ - @Nullable + @NotNull private ScriptedEvent<G, A, R> scriptedEvent; /** @@ -51,7 +50,7 @@ * @param frame frame this listener belongs to * @param scriptedEvent the target event to script */ - public PathButtonListener(@NotNull final JDialog frame, @Nullable final ScriptedEvent<G, A, R> scriptedEvent) { + public PathButtonListener(@NotNull final JDialog frame, @NotNull final ScriptedEvent<G, A, R> scriptedEvent) { this.frame = frame; this.scriptedEvent = scriptedEvent; } @@ -69,11 +68,8 @@ */ @Override public void actionPerformed(@NotNull final ActionEvent e) { - if (scriptedEvent != null) { - scriptedEvent.modifyEventPath(); // ok button for modifying path - } - - frame.setVisible(false); // hide dialog + scriptedEvent.modifyEventPath(); + frame.setVisible(false); } } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonListener2.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonListener2.java 2013-10-08 19:34:58 UTC (rev 9399) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonListener2.java 2013-10-08 19:39:40 UTC (rev 9400) @@ -27,7 +27,6 @@ import net.sf.gridarta.model.maparchobject.MapArchObject; import net.sf.gridarta.model.scripts.ScriptArchData; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; /** * Small class, listening for button-press events in the popup frame for script @@ -42,13 +41,13 @@ /** * The ScriptArchData to operate on. */ - @Nullable + @NotNull private ScriptArchData<G, A, R> scriptArchData; /** * The affected game object. */ - @Nullable + @NotNull private G gameObject; /** @@ -65,7 +64,7 @@ * @param gameObject the affected game object * @param scriptArchEditor the script arch editor to use */ - public PathButtonListener2(@NotNull final JDialog frame, @Nullable final ScriptArchData<G, A, R> scriptArchData, @Nullable final G gameObject, @NotNull final ScriptArchEditor<G, A, R> scriptArchEditor) { + public PathButtonListener2(@NotNull final JDialog frame, @NotNull final ScriptArchData<G, A, R> scriptArchData, @NotNull final G gameObject, @NotNull final ScriptArchEditor<G, A, R> scriptArchEditor) { this.frame = frame; this.scriptArchData = scriptArchData; this.gameObject = gameObject; @@ -87,12 +86,7 @@ */ @Override public void actionPerformed(@NotNull final ActionEvent e) { - if (scriptArchData != null && gameObject != null) { - // ok button for creating a new event/script - scriptArchEditor.createNewEvent(frame, scriptArchData, gameObject); - } else { - frame.setVisible(false); // hide dialog - } + scriptArchEditor.createNewEvent(frame, scriptArchData, gameObject); } } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/ScriptArchEditor.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/ScriptArchEditor.java 2013-10-08 19:34:58 UTC (rev 9399) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/ScriptArchEditor.java 2013-10-08 19:39:40 UTC (rev 9400) @@ -41,7 +41,7 @@ * display * @param parent the parent frame for the editor */ - void addEventScript(G gameObject, ScriptArchData<G, A, R> scriptArchData, @NotNull Frame parent); + void addEventScript(@NotNull G gameObject, @NotNull ScriptArchData<G, A, R> scriptArchData, @NotNull Frame parent); @Deprecated void setScriptEditControl(@Nullable ScriptEditControl scriptEditControl); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-08 19:35:04
|
Revision: 9399 http://sourceforge.net/p/gridarta/code/9399 Author: akirschbaum Date: 2013-10-08 19:34:58 +0000 (Tue, 08 Oct 2013) Log Message: ----------- Split off PathButtonListener2 from PathButtonListener. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonListener.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/ScriptedEventEditor.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java Added Paths: ----------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonListener2.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java 2013-10-08 19:26:53 UTC (rev 9398) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java 2013-10-08 19:34:58 UTC (rev 9399) @@ -132,7 +132,7 @@ private JTextComponent inputOptions; @NotNull - private PathButtonListener<G, A, R> nsOkListener; + private PathButtonListener2<G, A, R> nsOkListener; /** * The {@link ScriptedEventFactory} instance to use. @@ -279,7 +279,7 @@ mainPanel.add(Box.createVerticalStrut(10)); final Container line6 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final AbstractButton nsOkButton = new JButton("OK"); - nsOkListener = new PathButtonListener<G, A, R>(newScriptFrame, scriptArchData, gameObject, this, null); + nsOkListener = new PathButtonListener2<G, A, R>(newScriptFrame, scriptArchData, gameObject, this); nsOkButton.addActionListener(nsOkListener); line6.add(nsOkButton); Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonListener.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonListener.java 2013-10-08 19:26:53 UTC (rev 9398) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonListener.java 2013-10-08 19:34:58 UTC (rev 9399) @@ -25,7 +25,6 @@ import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; -import net.sf.gridarta.model.scripts.ScriptArchData; import net.sf.gridarta.model.scripts.ScriptedEvent; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -48,37 +47,12 @@ private ScriptedEvent<G, A, R> scriptedEvent; /** - * The ScriptArchData to operate on. - */ - @Nullable - private ScriptArchData<G, A, R> scriptArchData; - - /** - * The affected game object. - */ - @Nullable - private G gameObject; - - /** - * The {@link ScriptArchEditor} instance to use. - */ - @NotNull - private final ScriptArchEditor<G, A, R> scriptArchEditor; - - /** * Create a PathButtonListener. * @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 - * @param scriptArchEditor the script arch editor to use * @param scriptedEvent the target event to script */ - public PathButtonListener(@NotNull final JDialog frame, @Nullable final ScriptArchData<G, A, R> scriptArchData, @Nullable final G gameObject, @NotNull final ScriptArchEditor<G, A, R> scriptArchEditor, @Nullable final ScriptedEvent<G, A, R> scriptedEvent) { + public PathButtonListener(@NotNull final JDialog frame, @Nullable final ScriptedEvent<G, A, R> scriptedEvent) { this.frame = frame; - this.scriptArchData = scriptArchData; - this.gameObject = gameObject; - this.scriptArchEditor = scriptArchEditor; this.scriptedEvent = scriptedEvent; } @@ -91,30 +65,15 @@ } /** - * Set the ScriptArchData to operate on. - * @param scriptArchData the script arch data to operate on - * @param gameObject the affected game object - */ - public void setScriptArchData(@NotNull final ScriptArchData<G, A, R> scriptArchData, @NotNull final G gameObject) { - this.scriptArchData = scriptArchData; - this.gameObject = gameObject; - } - - /** * {@inheritDoc} */ @Override public void actionPerformed(@NotNull final ActionEvent e) { - if (scriptArchData == null && scriptedEvent != null) { + if (scriptedEvent != null) { scriptedEvent.modifyEventPath(); // ok button for modifying path } - if (scriptArchData != null && gameObject != null) { - // ok button for creating a new event/script - scriptArchEditor.createNewEvent(frame, scriptArchData, gameObject); - } else { - frame.setVisible(false); // hide dialog - } + frame.setVisible(false); // hide dialog } } Copied: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonListener2.java (from rev 9397, trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonListener.java) =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonListener2.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonListener2.java 2013-10-08 19:34:58 UTC (rev 9399) @@ -0,0 +1,98 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.gui.scripts; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.JDialog; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.scripts.ScriptArchData; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Small class, listening for button-press events in the popup frame for script + * paths or create-new-event frame. + * @author Andreas Kirschbaum + */ +public class PathButtonListener2<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements ActionListener { + + @NotNull + private final JDialog frame; + + /** + * The ScriptArchData to operate on. + */ + @Nullable + private ScriptArchData<G, A, R> scriptArchData; + + /** + * The affected game object. + */ + @Nullable + private G gameObject; + + /** + * The {@link ScriptArchEditor} instance to use. + */ + @NotNull + private final ScriptArchEditor<G, A, R> scriptArchEditor; + + /** + * Create a PathButtonListener. + * @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 + * @param scriptArchEditor the script arch editor to use + */ + public PathButtonListener2(@NotNull final JDialog frame, @Nullable final ScriptArchData<G, A, R> scriptArchData, @Nullable final G gameObject, @NotNull final ScriptArchEditor<G, A, R> scriptArchEditor) { + this.frame = frame; + this.scriptArchData = scriptArchData; + this.gameObject = gameObject; + this.scriptArchEditor = scriptArchEditor; + } + + /** + * Set the ScriptArchData to operate on. + * @param scriptArchData the script arch data to operate on + * @param gameObject the affected game object + */ + public void setScriptArchData(@NotNull final ScriptArchData<G, A, R> scriptArchData, @NotNull final G gameObject) { + this.scriptArchData = scriptArchData; + this.gameObject = gameObject; + } + + /** + * {@inheritDoc} + */ + @Override + public void actionPerformed(@NotNull final ActionEvent e) { + if (scriptArchData != null && gameObject != null) { + // ok button for creating a new event/script + scriptArchEditor.createNewEvent(frame, scriptArchData, gameObject); + } else { + frame.setVisible(false); // hide dialog + } + } + +} Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/ScriptedEventEditor.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/ScriptedEventEditor.java 2013-10-08 19:26:53 UTC (rev 9398) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/ScriptedEventEditor.java 2013-10-08 19:34:58 UTC (rev 9399) @@ -64,12 +64,6 @@ private final ProjectSettings projectSettings; /** - * The {@link ScriptArchEditor} to use. - */ - @NotNull - private ScriptArchEditor<G, A, R> scriptArchEditor; - - /** * The {@link ScriptEditControl} to use. */ @Nullable @@ -101,11 +95,6 @@ } @Deprecated - public void setScriptArchEditor(@NotNull final ScriptArchEditor<G, A, R> scriptArchEditor) { - this.scriptArchEditor = scriptArchEditor; - } - - @Deprecated public void setScriptEditControl(@Nullable final ScriptEditControl scriptEditControl) { this.scriptEditControl = scriptEditControl; } @@ -184,7 +173,7 @@ // button panel: final Container line4 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final AbstractButton okButton = new JButton("OK"); - okListener = new PathButtonListener<G, A, R>(pathFrame, null, null, scriptArchEditor, scriptedEvent); + okListener = new PathButtonListener<G, A, R>(pathFrame, scriptedEvent); okButton.addActionListener(okListener); line4.add(okButton); Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 19:26:53 UTC (rev 9398) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 19:34:58 UTC (rev 9399) @@ -212,7 +212,6 @@ loadArchetypes(errorView, projectSettings, archetypeSet, archetypeChooserModel, resources, configSource); final ScriptedEventFactory<G, A, R> scriptedEventFactory = editorFactory.newScriptedEventFactory(scriptArchUtils, gameObjectFactory, scriptedEventEditor, archetypeSet); scriptArchEditor = new DefaultScriptArchEditor<G, A, R>(scriptedEventFactory, scriptExtension, scriptName, scriptArchUtils, scriptFileFilter, projectSettings, mapManager, pathManager); - scriptedEventEditor.setScriptArchEditor(scriptArchEditor); scriptArchDataUtils = editorFactory.newScriptArchDataUtils(scriptArchUtils, scriptedEventFactory, scriptedEventEditor); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-08 19:26:59
|
Revision: 9398 http://sourceforge.net/p/gridarta/code/9398 Author: akirschbaum Date: 2013-10-08 19:26:53 +0000 (Tue, 08 Oct 2013) Log Message: ----------- Inline PathButtonCancelListener. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/ScriptedEventEditor.java Removed Paths: ------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonCancelListener.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java 2013-10-08 19:23:55 UTC (rev 9397) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java 2013-10-08 19:26:53 UTC (rev 9398) @@ -284,7 +284,14 @@ line6.add(nsOkButton); final AbstractButton cancelButton = new JButton("Cancel"); - cancelButton.addActionListener(new PathButtonCancelListener<G, A, R>(newScriptFrame)); + cancelButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(final ActionEvent e) { + newScriptFrame.setVisible(false); + } + + }); line6.add(cancelButton); mainPanel.add(line6); Deleted: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonCancelListener.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonCancelListener.java 2013-10-08 19:23:55 UTC (rev 9397) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonCancelListener.java 2013-10-08 19:26:53 UTC (rev 9398) @@ -1,56 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2011 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.gui.scripts; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import javax.swing.JDialog; -import net.sf.gridarta.model.archetype.Archetype; -import net.sf.gridarta.model.gameobject.GameObject; -import net.sf.gridarta.model.maparchobject.MapArchObject; -import org.jetbrains.annotations.NotNull; - -/** - * Small class, listening for button-press events in the popup frame for script - * paths or create-new-event frame. - * @author Andreas Kirschbaum - */ -public class PathButtonCancelListener<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements ActionListener { - - @NotNull - private final JDialog frame; - - /** - * Create a PathButtonListener. - * @param frame frame this listener belongs to - */ - public PathButtonCancelListener(@NotNull final JDialog frame) { - this.frame = frame; - } - - /** - * {@inheritDoc} - */ - @Override - public void actionPerformed(@NotNull final ActionEvent e) { - frame.setVisible(false); // hide dialog - } - -} Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/ScriptedEventEditor.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/ScriptedEventEditor.java 2013-10-08 19:23:55 UTC (rev 9397) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/ScriptedEventEditor.java 2013-10-08 19:26:53 UTC (rev 9398) @@ -23,6 +23,8 @@ import java.awt.Container; import java.awt.FlowLayout; import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.io.File; import javax.swing.AbstractButton; import javax.swing.BorderFactory; @@ -83,9 +85,6 @@ private JTextComponent inputOptions; @NotNull - private PathButtonCancelListener<G, A, R> cancelListener; - - @NotNull private PathButtonListener<G, A, R> okListener; // popup frame to edit script paths: @@ -190,8 +189,14 @@ line4.add(okButton); final AbstractButton cancelButton = new JButton("Cancel"); - cancelListener = new PathButtonCancelListener<G, A, R>(pathFrame); - cancelButton.addActionListener(cancelListener); + cancelButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(final ActionEvent e) { + pathFrame.setVisible(false); + } + + }); line4.add(cancelButton); mainPanel.add(line4); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-08 19:24:01
|
Revision: 9397 http://sourceforge.net/p/gridarta/code/9397 Author: akirschbaum Date: 2013-10-08 19:23:55 +0000 (Tue, 08 Oct 2013) Log Message: ----------- Split off PathButtonCancelListener from PathButtonListener. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonListener.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/ScriptedEventEditor.java Added Paths: ----------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonCancelListener.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java 2013-10-08 18:32:39 UTC (rev 9396) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java 2013-10-08 19:23:55 UTC (rev 9397) @@ -279,12 +279,12 @@ mainPanel.add(Box.createVerticalStrut(10)); final Container line6 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final AbstractButton nsOkButton = new JButton("OK"); - nsOkListener = new PathButtonListener<G, A, R>(true, newScriptFrame, scriptArchData, gameObject, this, null); + nsOkListener = new PathButtonListener<G, A, R>(newScriptFrame, scriptArchData, gameObject, this, null); nsOkButton.addActionListener(nsOkListener); line6.add(nsOkButton); final AbstractButton cancelButton = new JButton("Cancel"); - cancelButton.addActionListener(new PathButtonListener<G, A, R>(false, newScriptFrame, null, null, this, null)); + cancelButton.addActionListener(new PathButtonCancelListener<G, A, R>(newScriptFrame)); line6.add(cancelButton); mainPanel.add(line6); Copied: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonCancelListener.java (from rev 9370, trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonListener.java) =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonCancelListener.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonCancelListener.java 2013-10-08 19:23:55 UTC (rev 9397) @@ -0,0 +1,56 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.gui.scripts; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.JDialog; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import org.jetbrains.annotations.NotNull; + +/** + * Small class, listening for button-press events in the popup frame for script + * paths or create-new-event frame. + * @author Andreas Kirschbaum + */ +public class PathButtonCancelListener<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements ActionListener { + + @NotNull + private final JDialog frame; + + /** + * Create a PathButtonListener. + * @param frame frame this listener belongs to + */ + public PathButtonCancelListener(@NotNull final JDialog frame) { + this.frame = frame; + } + + /** + * {@inheritDoc} + */ + @Override + public void actionPerformed(@NotNull final ActionEvent e) { + frame.setVisible(false); // hide dialog + } + +} Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonListener.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonListener.java 2013-10-08 18:32:39 UTC (rev 9396) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/PathButtonListener.java 2013-10-08 19:23:55 UTC (rev 9397) @@ -40,7 +40,6 @@ @NotNull private final JDialog frame; - private final boolean isOkButton; /** * The target event to script. @@ -68,7 +67,6 @@ /** * 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 @@ -76,8 +74,7 @@ * @param scriptArchEditor the script arch editor to use * @param scriptedEvent the target event to script */ - public PathButtonListener(final boolean isOkButton, @NotNull final JDialog frame, @Nullable final ScriptArchData<G, A, R> scriptArchData, @Nullable final G gameObject, @NotNull final ScriptArchEditor<G, A, R> scriptArchEditor, @Nullable final ScriptedEvent<G, A, R> scriptedEvent) { - this.isOkButton = isOkButton; + public PathButtonListener(@NotNull final JDialog frame, @Nullable final ScriptArchData<G, A, R> scriptArchData, @Nullable final G gameObject, @NotNull final ScriptArchEditor<G, A, R> scriptArchEditor, @Nullable final ScriptedEvent<G, A, R> scriptedEvent) { this.frame = frame; this.scriptArchData = scriptArchData; this.gameObject = gameObject; @@ -108,11 +105,11 @@ */ @Override public void actionPerformed(@NotNull final ActionEvent e) { - if (isOkButton && scriptArchData == null && scriptedEvent != null) { + if (scriptArchData == null && scriptedEvent != null) { scriptedEvent.modifyEventPath(); // ok button for modifying path } - if (isOkButton && scriptArchData != null && gameObject != null) { + if (scriptArchData != null && gameObject != null) { // ok button for creating a new event/script scriptArchEditor.createNewEvent(frame, scriptArchData, gameObject); } else { Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/ScriptedEventEditor.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/ScriptedEventEditor.java 2013-10-08 18:32:39 UTC (rev 9396) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/scripts/ScriptedEventEditor.java 2013-10-08 19:23:55 UTC (rev 9397) @@ -83,7 +83,7 @@ private JTextComponent inputOptions; @NotNull - private PathButtonListener<G, A, R> cancelListener; + private PathButtonCancelListener<G, A, R> cancelListener; @NotNull private PathButtonListener<G, A, R> okListener; @@ -185,12 +185,12 @@ // button panel: final Container line4 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final AbstractButton okButton = new JButton("OK"); - okListener = new PathButtonListener<G, A, R>(true, pathFrame, null, null, scriptArchEditor, scriptedEvent); + okListener = new PathButtonListener<G, A, R>(pathFrame, null, null, scriptArchEditor, scriptedEvent); okButton.addActionListener(okListener); line4.add(okButton); final AbstractButton cancelButton = new JButton("Cancel"); - cancelListener = new PathButtonListener<G, A, R>(false, pathFrame, null, null, scriptArchEditor, scriptedEvent); + cancelListener = new PathButtonCancelListener<G, A, R>(pathFrame); cancelButton.addActionListener(cancelListener); line4.add(cancelButton); mainPanel.add(line4); @@ -202,7 +202,6 @@ } else { // just set fields and show okListener.setTargetEvent(scriptedEvent); - cancelListener.setTargetEvent(scriptedEvent); inputScriptPath.setText(scriptedEvent.getScriptPath()); inputPluginName.setText(scriptedEvent.getPluginName()); inputOptions.setText(scriptedEvent.getOptions()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-08 18:32:46
|
Revision: 9396 http://sourceforge.net/p/gridarta/code/9396 Author: akirschbaum Date: 2013-10-08 18:32:39 +0000 (Tue, 08 Oct 2013) Log Message: ----------- Reorder code. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 18:26:25 UTC (rev 9395) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 18:32:39 UTC (rev 9396) @@ -209,11 +209,11 @@ final ConfigSource configSource = forceReadFromFiles ? configSourceFactory.getFilesConfigSource() : configSourceFactory.getConfigSource(projectSettings.getConfigSourceName()); treasureTree = TreasureLoader.parseTreasures(errorView, specialTreasureLists, configSource, projectSettings); scriptArchUtils = loadScriptArchUtils(errorView, editorFactory, projectSettings, archetypeTypeSet, xmlHelper); + loadArchetypes(errorView, projectSettings, archetypeSet, archetypeChooserModel, resources, configSource); final ScriptedEventFactory<G, A, R> scriptedEventFactory = editorFactory.newScriptedEventFactory(scriptArchUtils, gameObjectFactory, scriptedEventEditor, archetypeSet); scriptArchEditor = new DefaultScriptArchEditor<G, A, R>(scriptedEventFactory, scriptExtension, scriptName, scriptArchUtils, scriptFileFilter, projectSettings, mapManager, pathManager); scriptedEventEditor.setScriptArchEditor(scriptArchEditor); scriptArchDataUtils = editorFactory.newScriptArchDataUtils(scriptArchUtils, scriptedEventFactory, scriptedEventEditor); - loadArchetypes(errorView, projectSettings, archetypeSet, archetypeChooserModel, resources, configSource); } @NotNull This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-08 18:26:28
|
Revision: 9395 http://sourceforge.net/p/gridarta/code/9395 Author: akirschbaum Date: 2013-10-08 18:26:25 +0000 (Tue, 08 Oct 2013) Log Message: ----------- Move code from DefaultMainControl to GridartaEditor. Modified Paths: -------------- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java Modified: trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2013-10-08 18:19:08 UTC (rev 9394) +++ trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2013-10-08 18:26:25 UTC (rev 9395) @@ -183,8 +183,8 @@ */ @NotNull @Override - public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(@NotNull final XmlHelper xmlHelper, final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter) { - return new DefaultMainControl<GameObject, MapArchObject, Archetype>(xmlHelper, GuiFileFilters.pythonFileFilter, ".py", "Python", 0, errorView, this, forceReadFromFiles, projectSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, mapManager, validators, scriptedEventEditor, resources, gameObjectSpells, validatorPreferences, mapWriter); + public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(@NotNull final XmlHelper xmlHelper, final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter) { + return new DefaultMainControl<GameObject, MapArchObject, Archetype>(xmlHelper, GuiFileFilters.pythonFileFilter, ".py", "Python", errorView, this, forceReadFromFiles, projectSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, mapManager, validators, scriptedEventEditor, resources, validatorPreferences, mapWriter); } /** @@ -516,4 +516,12 @@ return IGUIConstants.SPELL_FILE; } + /** + * {@inheritDoc} + */ + @Override + public int getSpellType() { + return 0; + } + } Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2013-10-08 18:19:08 UTC (rev 9394) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2013-10-08 18:26:25 UTC (rev 9395) @@ -152,8 +152,8 @@ */ @NotNull @Override - public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(@NotNull final XmlHelper xmlHelper, final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter) { - return new DefaultMainControl<GameObject, MapArchObject, Archetype>(xmlHelper, GuiFileFilters.pythonFileFilter, ".py", "Python", Archetype.TYPE_SPELL, errorView, this, false, projectSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, mapManager, validators, scriptedEventEditor, resources, gameObjectSpells, validatorPreferences, mapWriter); + public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(@NotNull final XmlHelper xmlHelper, final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter) { + return new DefaultMainControl<GameObject, MapArchObject, Archetype>(xmlHelper, GuiFileFilters.pythonFileFilter, ".py", "Python", errorView, this, false, projectSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, mapManager, validators, scriptedEventEditor, resources, validatorPreferences, mapWriter); } /** @@ -427,4 +427,12 @@ return null; } + /** + * {@inheritDoc} + */ + @Override + public int getSpellType() { + return Archetype.TYPE_SPELL; + } + } Modified: trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2013-10-08 18:19:08 UTC (rev 9394) +++ trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2013-10-08 18:26:25 UTC (rev 9395) @@ -182,8 +182,8 @@ */ @NotNull @Override - public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(@NotNull final XmlHelper xmlHelper, final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter) { - return new DefaultMainControl<GameObject, MapArchObject, Archetype>(xmlHelper, GuiFileFilters.luaFileFilter, ".lua", "Lua", 0, errorView, this, forceReadFromFiles, projectSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, mapManager, validators, scriptedEventEditor, resources, gameObjectSpells, validatorPreferences, mapWriter); + public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(@NotNull final XmlHelper xmlHelper, final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter) { + return new DefaultMainControl<GameObject, MapArchObject, Archetype>(xmlHelper, GuiFileFilters.luaFileFilter, ".lua", "Lua", errorView, this, forceReadFromFiles, projectSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, mapManager, validators, scriptedEventEditor, resources, validatorPreferences, mapWriter); } /** @@ -515,4 +515,12 @@ return IGUIConstants.SPELL_FILE; } + /** + * {@inheritDoc} + */ + @Override + public int getSpellType() { + return 0; + } + } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 18:19:08 UTC (rev 9394) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 18:26:25 UTC (rev 9395) @@ -144,8 +144,6 @@ * @param scriptFileFilter the file filter for script files * @param scriptExtension the file extension for script files * @param scriptName the display name for script files - * @param spellType the object id for spell objects or <code>0</code> to not - * collect game objects spells * @param errorView the error view to add errors to * @param editorFactory the editor factory to use * @param forceReadFromFiles if set, read resources from individual files @@ -162,11 +160,10 @@ * @param validators the map validators * @param scriptedEventEditor the scripted event editor * @param resources the resources - * @param gameObjectSpells the game object spells to use * @param validatorPreferences the validator preferences to use * @param mapWriter the map writer for writing temporary map files */ - public DefaultMainControl(@NotNull final XmlHelper xmlHelper, @NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, @NotNull final String scriptName, final int spellType, final ErrorView errorView, @NotNull final EditorFactory<G, A, R> editorFactory, final boolean forceReadFromFiles, @NotNull final ProjectSettings projectSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final AbstractMapManager<G, A, R> mapManager, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final AbstractResources<G, A, R> resources, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<G, A, R> mapWriter) { + public DefaultMainControl(@NotNull final XmlHelper xmlHelper, @NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, @NotNull final String scriptName, final ErrorView errorView, @NotNull final EditorFactory<G, A, R> editorFactory, final boolean forceReadFromFiles, @NotNull final ProjectSettings projectSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final AbstractMapManager<G, A, R> mapManager, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final AbstractResources<G, A, R> resources, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<G, A, R> mapWriter) { final EnvironmentChecker<G, A, R> environmentChecker = new EnvironmentChecker<G, A, R>(validatorPreferences); AttributeRangeChecker<G, A, R> attributeRangeChecker = null; try { @@ -217,7 +214,6 @@ scriptedEventEditor.setScriptArchEditor(scriptArchEditor); scriptArchDataUtils = editorFactory.newScriptArchDataUtils(scriptArchUtils, scriptedEventFactory, scriptedEventEditor); loadArchetypes(errorView, projectSettings, archetypeSet, archetypeChooserModel, resources, configSource); - loadArchetypeSpells(spellType, gameObjectFactory, archetypeSet, gameObjectSpells); } @NotNull @@ -263,11 +259,14 @@ } } - private static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void loadArchetypeSpells(final int spellType, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells) { + @NotNull + public static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> Spells<GameObjectSpell<G, A, R>> loadArchetypeSpells(final int spellType, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final ArchetypeSet<G, A, R> archetypeSet) { + final Spells<GameObjectSpell<G, A, R>> gameObjectSpells = new Spells<GameObjectSpell<G, A, R>>(); if (spellType != 0) { new ArchetypeSetSpellLoader<G, A, R>(gameObjectFactory).load(archetypeSet, spellType, gameObjectSpells); gameObjectSpells.sort(); } + return gameObjectSpells; } @NotNull Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java 2013-10-08 18:19:08 UTC (rev 9394) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java 2013-10-08 18:26:25 UTC (rev 9395) @@ -112,13 +112,12 @@ * @param validators the map validators * @param scriptedEventEditor the scripted event editor * @param resources the resources - * @param gameObjectSpells the game object spells to use * @param validatorPreferences the validator preferences to use * @param mapWriter the map writer for saving temporary maps * @return the new instance */ @NotNull - DefaultMainControl<G, A, R> newMainControl(@NotNull XmlHelper xmlHelper, boolean forceReadFromFiles, @NotNull ErrorView errorView, @NotNull ProjectSettings projectSettings, @NotNull ConfigSourceFactory configSourceFactory, @NotNull PathManager pathManager, @NotNull GameObjectMatchers gameObjectMatchers, @NotNull GameObjectFactory<G, A, R> gameObjectFactory, @NotNull ArchetypeTypeSet archetypeTypeSet, @NotNull ArchetypeSet<G, A, R> archetypeSet, @NotNull ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull AbstractMapManager<G, A, R> mapManager, @NotNull DelegatingMapValidator<G, A, R> validators, @NotNull ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull AbstractResources<G, A, R> resources, @NotNull Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull ValidatorPreferences validatorPreferences, @NotNull MapWriter<G, A, R> mapWriter); + DefaultMainControl<G, A, R> newMainControl(@NotNull XmlHelper xmlHelper, boolean forceReadFromFiles, @NotNull ErrorView errorView, @NotNull ProjectSettings projectSettings, @NotNull ConfigSourceFactory configSourceFactory, @NotNull PathManager pathManager, @NotNull GameObjectMatchers gameObjectMatchers, @NotNull GameObjectFactory<G, A, R> gameObjectFactory, @NotNull ArchetypeTypeSet archetypeTypeSet, @NotNull ArchetypeSet<G, A, R> archetypeSet, @NotNull ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull AbstractMapManager<G, A, R> mapManager, @NotNull DelegatingMapValidator<G, A, R> validators, @NotNull ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull AbstractResources<G, A, R> resources, @NotNull ValidatorPreferences validatorPreferences, @NotNull MapWriter<G, A, R> mapWriter); /** * Returns the offset for drawing double faces. @@ -419,4 +418,10 @@ @Nullable String getSpellFile(); + /** + * Returns the archetype type for game object spells. + * @return the archetype type or {@code 0} to not load gameo object spells + */ + int getSpellType(); + } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java 2013-10-08 18:19:08 UTC (rev 9394) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java 2013-10-08 18:26:25 UTC (rev 9395) @@ -287,7 +287,6 @@ final AbstractArchetypeParser<G, A, R, ?> archetypeParser = editorFactory.newArchetypeParser(errorView, gameObjectParser, animationObjects, archetypeSet, gameObjectFactory, projectSettings); final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); final AbstractResources<G, A, R> resources = editorFactory.newResources(gameObjectParser, archetypeSet, archetypeParser, mapViewSettings, faceObjects, animationObjects, archFaceProvider, faceObjectProviders); - final Spells<GameObjectSpell<G, A, R>> gameObjectSpells = new Spells<GameObjectSpell<G, A, R>>(); final PluginParameterFactory<G, A, R> pluginParameterFactory = new PluginParameterFactory<G, A, R>(archetypeSet, mapManager, defaultFilterList, projectSettings); final XmlHelper xmlHelper; @@ -298,9 +297,9 @@ //noinspection ThrowInsideCatchBlockWhichIgnoresCaughtException throw new MissingResourceException("Cannot create XML parser: " + ex.getMessage(), null, null); } - final DefaultMainControl<G, A, R> mainControl = editorFactory.newMainControl(xmlHelper, mode == GridartaRunMode.COLLECT_ARCHES, errorView, projectSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, mapManager, validators, scriptedEventEditor, resources, gameObjectSpells, validatorPreferences, mapWriter); - final Spells<NumberSpell> numberSpells = - DefaultMainControl.loadSpellFile(editorFactory.getSpellFile(), errorView, projectSettings, xmlHelper); + final DefaultMainControl<G, A, R> mainControl = editorFactory.newMainControl(xmlHelper, mode == GridartaRunMode.COLLECT_ARCHES, errorView, projectSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, mapManager, validators, scriptedEventEditor, resources, validatorPreferences, mapWriter); + final Spells<GameObjectSpell<G, A, R>> gameObjectSpells = DefaultMainControl.loadArchetypeSpells(editorFactory.getSpellType(), gameObjectFactory, archetypeSet); + final Spells<NumberSpell> numberSpells = DefaultMainControl.loadSpellFile(editorFactory.getSpellFile(), errorView, projectSettings, xmlHelper); final PluginModelParser<G, A, R> pluginModelParser = new PluginModelParser<G, A, R>(pluginParameterFactory); final File scriptsFile = new File(projectSettings.getMapsDirectory(), editorFactory.getScriptsDir()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-08 18:19:14
|
Revision: 9394 http://sourceforge.net/p/gridarta/code/9394 Author: akirschbaum Date: 2013-10-08 18:19:08 +0000 (Tue, 08 Oct 2013) Log Message: ----------- Move code from DefaultMainControl to GridartaEditor. Modified Paths: -------------- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java Modified: trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2013-10-08 18:10:48 UTC (rev 9393) +++ trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2013-10-08 18:19:08 UTC (rev 9394) @@ -128,6 +128,7 @@ import org.apache.log4j.Category; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * An {@link EditorFactory} that creates Crossfire objects. @@ -182,8 +183,8 @@ */ @NotNull @Override - public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(@NotNull final XmlHelper xmlHelper, final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter) { - return new DefaultMainControl<GameObject, MapArchObject, Archetype>(xmlHelper, GuiFileFilters.pythonFileFilter, ".py", "Python", 0, IGUIConstants.SPELL_FILE, errorView, this, forceReadFromFiles, projectSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, mapManager, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, validatorPreferences, mapWriter); + public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(@NotNull final XmlHelper xmlHelper, final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter) { + return new DefaultMainControl<GameObject, MapArchObject, Archetype>(xmlHelper, GuiFileFilters.pythonFileFilter, ".py", "Python", 0, errorView, this, forceReadFromFiles, projectSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, mapManager, validators, scriptedEventEditor, resources, gameObjectSpells, validatorPreferences, mapWriter); } /** @@ -506,4 +507,13 @@ return IGUIConstants.SCRIPTS_DIR; } + /** + * {@inheritDoc} + */ + @Nullable + @Override + public String getSpellFile() { + return IGUIConstants.SPELL_FILE; + } + } Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2013-10-08 18:10:48 UTC (rev 9393) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2013-10-08 18:19:08 UTC (rev 9394) @@ -152,8 +152,8 @@ */ @NotNull @Override - public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(@NotNull final XmlHelper xmlHelper, final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter) { - return new DefaultMainControl<GameObject, MapArchObject, Archetype>(xmlHelper, GuiFileFilters.pythonFileFilter, ".py", "Python", Archetype.TYPE_SPELL, null, errorView, this, false, projectSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, mapManager, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, validatorPreferences, mapWriter); + public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(@NotNull final XmlHelper xmlHelper, final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter) { + return new DefaultMainControl<GameObject, MapArchObject, Archetype>(xmlHelper, GuiFileFilters.pythonFileFilter, ".py", "Python", Archetype.TYPE_SPELL, errorView, this, false, projectSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, mapManager, validators, scriptedEventEditor, resources, gameObjectSpells, validatorPreferences, mapWriter); } /** @@ -418,4 +418,13 @@ return IGUIConstants.SCRIPTS_DIR; } + /** + * {@inheritDoc} + */ + @Nullable + @Override + public String getSpellFile() { + return null; + } + } Modified: trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2013-10-08 18:10:48 UTC (rev 9393) +++ trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2013-10-08 18:19:08 UTC (rev 9394) @@ -182,8 +182,8 @@ */ @NotNull @Override - public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(@NotNull final XmlHelper xmlHelper, final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter) { - return new DefaultMainControl<GameObject, MapArchObject, Archetype>(xmlHelper, GuiFileFilters.luaFileFilter, ".lua", "Lua", 0, IGUIConstants.SPELL_FILE, errorView, this, forceReadFromFiles, projectSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, mapManager, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, validatorPreferences, mapWriter); + public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(@NotNull final XmlHelper xmlHelper, final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter) { + return new DefaultMainControl<GameObject, MapArchObject, Archetype>(xmlHelper, GuiFileFilters.luaFileFilter, ".lua", "Lua", 0, errorView, this, forceReadFromFiles, projectSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, mapManager, validators, scriptedEventEditor, resources, gameObjectSpells, validatorPreferences, mapWriter); } /** @@ -506,4 +506,13 @@ return IGUIConstants.SCRIPTS_DIR; } + /** + * {@inheritDoc} + */ + @Nullable + @Override + public String getSpellFile() { + return IGUIConstants.SPELL_FILE; + } + } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 18:10:48 UTC (rev 9393) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 18:19:08 UTC (rev 9394) @@ -146,8 +146,6 @@ * @param scriptName the display name 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 * @param errorView the error view to add errors to * @param editorFactory the editor factory to use * @param forceReadFromFiles if set, read resources from individual files @@ -164,12 +162,11 @@ * @param validators the map validators * @param scriptedEventEditor the scripted event editor * @param resources the resources - * @param numberSpells the number spells to use * @param gameObjectSpells the game object spells to use * @param validatorPreferences the validator preferences to use * @param mapWriter the map writer for writing temporary map files */ - public DefaultMainControl(@NotNull final XmlHelper xmlHelper, @NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, @NotNull final String scriptName, final int spellType, @Nullable final String spellFile, final ErrorView errorView, @NotNull final EditorFactory<G, A, R> editorFactory, final boolean forceReadFromFiles, @NotNull final ProjectSettings projectSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final AbstractMapManager<G, A, R> mapManager, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final AbstractResources<G, A, R> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<G, A, R> mapWriter) { + public DefaultMainControl(@NotNull final XmlHelper xmlHelper, @NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, @NotNull final String scriptName, final int spellType, final ErrorView errorView, @NotNull final EditorFactory<G, A, R> editorFactory, final boolean forceReadFromFiles, @NotNull final ProjectSettings projectSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final AbstractMapManager<G, A, R> mapManager, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final AbstractResources<G, A, R> resources, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<G, A, R> mapWriter) { final EnvironmentChecker<G, A, R> environmentChecker = new EnvironmentChecker<G, A, R>(validatorPreferences); AttributeRangeChecker<G, A, R> attributeRangeChecker = null; try { @@ -221,7 +218,6 @@ scriptArchDataUtils = editorFactory.newScriptArchDataUtils(scriptArchUtils, scriptedEventFactory, scriptedEventEditor); loadArchetypes(errorView, projectSettings, archetypeSet, archetypeChooserModel, resources, configSource); loadArchetypeSpells(spellType, gameObjectFactory, archetypeSet, gameObjectSpells); - loadSpellFile(spellFile, errorView, projectSettings, numberSpells, xmlHelper); } @NotNull @@ -274,9 +270,11 @@ } } - private static void loadSpellFile(@Nullable final String spellFile, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final XmlHelper xmlHelper) { + @NotNull + public static Spells<NumberSpell> loadSpellFile(@Nullable final String spellFile, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final XmlHelper xmlHelper) { + @NotNull final Spells<NumberSpell> numberSpells = new Spells<NumberSpell>(); if (spellFile == null) { - return; + return numberSpells; } try { @@ -293,6 +291,7 @@ errorView.addWarning(ErrorViewCategory.SPELLS_FILE_INVALID, spellFile + ": " + ex.getMessage()); } numberSpells.sort(); + return numberSpells; } private static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void addArchetypes(@NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final ArchetypeSet<G, A, R> archetypeSet) { Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java 2013-10-08 18:10:48 UTC (rev 9393) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java 2013-10-08 18:19:08 UTC (rev 9394) @@ -112,14 +112,13 @@ * @param validators the map validators * @param scriptedEventEditor the scripted event editor * @param resources the resources - * @param numberSpells the number spells to use * @param gameObjectSpells the game object spells to use * @param validatorPreferences the validator preferences to use * @param mapWriter the map writer for saving temporary maps * @return the new instance */ @NotNull - DefaultMainControl<G, A, R> newMainControl(@NotNull XmlHelper xmlHelper, boolean forceReadFromFiles, @NotNull ErrorView errorView, @NotNull ProjectSettings projectSettings, @NotNull ConfigSourceFactory configSourceFactory, @NotNull PathManager pathManager, @NotNull GameObjectMatchers gameObjectMatchers, @NotNull GameObjectFactory<G, A, R> gameObjectFactory, @NotNull ArchetypeTypeSet archetypeTypeSet, @NotNull ArchetypeSet<G, A, R> archetypeSet, @NotNull ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull AbstractMapManager<G, A, R> mapManager, @NotNull DelegatingMapValidator<G, A, R> validators, @NotNull ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull AbstractResources<G, A, R> resources, @NotNull Spells<NumberSpell> numberSpells, @NotNull Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull ValidatorPreferences validatorPreferences, @NotNull MapWriter<G, A, R> mapWriter); + DefaultMainControl<G, A, R> newMainControl(@NotNull XmlHelper xmlHelper, boolean forceReadFromFiles, @NotNull ErrorView errorView, @NotNull ProjectSettings projectSettings, @NotNull ConfigSourceFactory configSourceFactory, @NotNull PathManager pathManager, @NotNull GameObjectMatchers gameObjectMatchers, @NotNull GameObjectFactory<G, A, R> gameObjectFactory, @NotNull ArchetypeTypeSet archetypeTypeSet, @NotNull ArchetypeSet<G, A, R> archetypeSet, @NotNull ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull AbstractMapManager<G, A, R> mapManager, @NotNull DelegatingMapValidator<G, A, R> validators, @NotNull ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull AbstractResources<G, A, R> resources, @NotNull Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull ValidatorPreferences validatorPreferences, @NotNull MapWriter<G, A, R> mapWriter); /** * Returns the offset for drawing double faces. @@ -413,4 +412,11 @@ */ String getScriptsDir(); + /** + * Returns the spell file name to load. + * @return the spell file name or {@code null} to not load numbered spells + */ + @Nullable + String getSpellFile(); + } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java 2013-10-08 18:10:48 UTC (rev 9393) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java 2013-10-08 18:19:08 UTC (rev 9394) @@ -287,7 +287,6 @@ final AbstractArchetypeParser<G, A, R, ?> archetypeParser = editorFactory.newArchetypeParser(errorView, gameObjectParser, animationObjects, archetypeSet, gameObjectFactory, projectSettings); final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); final AbstractResources<G, A, R> resources = editorFactory.newResources(gameObjectParser, archetypeSet, archetypeParser, mapViewSettings, faceObjects, animationObjects, archFaceProvider, faceObjectProviders); - final Spells<NumberSpell> numberSpells = new Spells<NumberSpell>(); final Spells<GameObjectSpell<G, A, R>> gameObjectSpells = new Spells<GameObjectSpell<G, A, R>>(); final PluginParameterFactory<G, A, R> pluginParameterFactory = new PluginParameterFactory<G, A, R>(archetypeSet, mapManager, defaultFilterList, projectSettings); @@ -299,7 +298,9 @@ //noinspection ThrowInsideCatchBlockWhichIgnoresCaughtException throw new MissingResourceException("Cannot create XML parser: " + ex.getMessage(), null, null); } - final DefaultMainControl<G, A, R> mainControl = editorFactory.newMainControl(xmlHelper, mode == GridartaRunMode.COLLECT_ARCHES, errorView, projectSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, mapManager, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, validatorPreferences, mapWriter); + final DefaultMainControl<G, A, R> mainControl = editorFactory.newMainControl(xmlHelper, mode == GridartaRunMode.COLLECT_ARCHES, errorView, projectSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, mapManager, validators, scriptedEventEditor, resources, gameObjectSpells, validatorPreferences, mapWriter); + final Spells<NumberSpell> numberSpells = + DefaultMainControl.loadSpellFile(editorFactory.getSpellFile(), errorView, projectSettings, xmlHelper); final PluginModelParser<G, A, R> pluginModelParser = new PluginModelParser<G, A, R>(pluginParameterFactory); final File scriptsFile = new File(projectSettings.getMapsDirectory(), editorFactory.getScriptsDir()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-08 18:10:55
|
Revision: 9393 http://sourceforge.net/p/gridarta/code/9393 Author: akirschbaum Date: 2013-10-08 18:10:48 +0000 (Tue, 08 Oct 2013) Log Message: ----------- Add static modifiers. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 18:06:54 UTC (rev 9392) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 18:10:48 UTC (rev 9393) @@ -255,7 +255,7 @@ return editorFactory.newScriptArchUtils(eventTypeSet); } - private void loadArchetypes(@NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final AbstractResources<G, A, R> resources, @NotNull final ConfigSource configSource) { + private static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void loadArchetypes(@NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final AbstractResources<G, A, R> resources, @NotNull final ConfigSource configSource) { final long timeStart = System.currentTimeMillis(); if (log.isInfoEnabled()) { log.info("Start to load archetypes..."); @@ -267,14 +267,14 @@ } } - private void loadArchetypeSpells(final int spellType, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells) { + private static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void loadArchetypeSpells(final int spellType, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells) { if (spellType != 0) { new ArchetypeSetSpellLoader<G, A, R>(gameObjectFactory).load(archetypeSet, spellType, gameObjectSpells); gameObjectSpells.sort(); } } - private void loadSpellFile(@Nullable final String spellFile, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final XmlHelper xmlHelper) { + private static void loadSpellFile(@Nullable final String spellFile, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final XmlHelper xmlHelper) { if (spellFile == null) { return; } @@ -295,7 +295,7 @@ numberSpells.sort(); } - private void addArchetypes(@NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final ArchetypeSet<G, A, R> archetypeSet) { + private static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void addArchetypes(@NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final ArchetypeSet<G, A, R> archetypeSet) { for (final R archetype : archetypeSet.getArchetypes()) { final CharSequence editorFolder = archetype.getEditorFolder(); if (editorFolder != null && !editorFolder.equals(GameObject.EDITOR_FOLDER_INTERN)) { @@ -310,7 +310,7 @@ } @NotNull - private Map<String, TreasureTreeNode> loadSpecialTreasureLists(@NotNull final ErrorView errorView, @NotNull final DocumentBuilder documentBuilder, @NotNull final ProjectSettings projectSettings) { + private static Map<String, TreasureTreeNode> loadSpecialTreasureLists(@NotNull final ErrorView errorView, @NotNull final DocumentBuilder documentBuilder, @NotNull final ProjectSettings projectSettings) { Map<String, TreasureTreeNode> specialTreasureLists; try { final URL url = IOUtils.getResource(projectSettings.getConfigurationDirectory(), "TreasureLists.xml"); @@ -349,7 +349,7 @@ * validators * @param errorView the error view to add error messages to */ - private void loadValidators(@NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final ValidatorFactory<G, A, R> validatorFactory, @NotNull final ErrorView errorView) { + private static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void loadValidators(@NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final ValidatorFactory<G, A, R> validatorFactory, @NotNull final ErrorView errorView) { final ActionBuilder actionBuilder = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); int id = 0; while (true) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-08 18:07:07
|
Revision: 9392 http://sourceforge.net/p/gridarta/code/9392 Author: akirschbaum Date: 2013-10-08 18:06:54 +0000 (Tue, 08 Oct 2013) Log Message: ----------- Move creation of XmlHelper from DefaultMainControl to GridartaEditor. Modified Paths: -------------- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java Modified: trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2013-10-08 17:53:57 UTC (rev 9391) +++ trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2013-10-08 18:06:54 UTC (rev 9392) @@ -105,6 +105,7 @@ import net.sf.gridarta.utils.GuiFileFilters; import net.sf.gridarta.utils.IOUtils; import net.sf.gridarta.utils.SystemIcons; +import net.sf.gridarta.utils.XmlHelper; import net.sf.gridarta.var.atrinik.IGUIConstants; import net.sf.gridarta.var.atrinik.actions.AtrinikServerActions; import net.sf.gridarta.var.atrinik.gui.map.renderer.DefaultRendererFactory; @@ -181,8 +182,8 @@ */ @NotNull @Override - public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter) { - return new DefaultMainControl<GameObject, MapArchObject, Archetype>(GuiFileFilters.pythonFileFilter, ".py", "Python", 0, IGUIConstants.SPELL_FILE, errorView, this, forceReadFromFiles, projectSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, mapManager, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, validatorPreferences, mapWriter); + public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(@NotNull final XmlHelper xmlHelper, final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter) { + return new DefaultMainControl<GameObject, MapArchObject, Archetype>(xmlHelper, GuiFileFilters.pythonFileFilter, ".py", "Python", 0, IGUIConstants.SPELL_FILE, errorView, this, forceReadFromFiles, projectSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, mapManager, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, validatorPreferences, mapWriter); } /** Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2013-10-08 17:53:57 UTC (rev 9391) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2013-10-08 18:06:54 UTC (rev 9392) @@ -101,6 +101,7 @@ import net.sf.gridarta.utils.GUIUtils; import net.sf.gridarta.utils.GuiFileFilters; import net.sf.gridarta.utils.SystemIcons; +import net.sf.gridarta.utils.XmlHelper; import net.sf.gridarta.var.crossfire.IGUIConstants; import net.sf.gridarta.var.crossfire.gui.map.renderer.DefaultRendererFactory; import net.sf.gridarta.var.crossfire.gui.mappropertiesdialog.DefaultMapPropertiesDialogFactory; @@ -151,8 +152,8 @@ */ @NotNull @Override - public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter) { - return new DefaultMainControl<GameObject, MapArchObject, Archetype>(GuiFileFilters.pythonFileFilter, ".py", "Python", Archetype.TYPE_SPELL, null, errorView, this, false, projectSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, mapManager, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, validatorPreferences, mapWriter); + public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(@NotNull final XmlHelper xmlHelper, final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter) { + return new DefaultMainControl<GameObject, MapArchObject, Archetype>(xmlHelper, GuiFileFilters.pythonFileFilter, ".py", "Python", Archetype.TYPE_SPELL, null, errorView, this, false, projectSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, mapManager, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, validatorPreferences, mapWriter); } /** Modified: trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2013-10-08 17:53:57 UTC (rev 9391) +++ trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2013-10-08 18:06:54 UTC (rev 9392) @@ -105,6 +105,7 @@ import net.sf.gridarta.utils.GuiFileFilters; import net.sf.gridarta.utils.IOUtils; import net.sf.gridarta.utils.SystemIcons; +import net.sf.gridarta.utils.XmlHelper; import net.sf.gridarta.var.daimonin.IGUIConstants; import net.sf.gridarta.var.daimonin.gui.map.renderer.DefaultRendererFactory; import net.sf.gridarta.var.daimonin.gui.mappropertiesdialog.DefaultMapPropertiesDialogFactory; @@ -181,8 +182,8 @@ */ @NotNull @Override - public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter) { - return new DefaultMainControl<GameObject, MapArchObject, Archetype>(GuiFileFilters.luaFileFilter, ".lua", "Lua", 0, IGUIConstants.SPELL_FILE, errorView, this, forceReadFromFiles, projectSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, mapManager, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, validatorPreferences, mapWriter); + public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(@NotNull final XmlHelper xmlHelper, final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter) { + return new DefaultMainControl<GameObject, MapArchObject, Archetype>(xmlHelper, GuiFileFilters.luaFileFilter, ".lua", "Lua", 0, IGUIConstants.SPELL_FILE, errorView, this, forceReadFromFiles, projectSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, mapManager, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, validatorPreferences, mapWriter); } /** Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 17:53:57 UTC (rev 9391) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 18:06:54 UTC (rev 9392) @@ -25,11 +25,9 @@ import java.net.URL; import java.util.Collections; import java.util.Map; -import java.util.MissingResourceException; import javax.swing.ImageIcon; import javax.swing.filechooser.FileFilter; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.ParserConfigurationException; import net.sf.gridarta.gui.filter.FilterControl; import net.sf.gridarta.gui.map.renderer.RendererFactory; import net.sf.gridarta.gui.scripts.DefaultScriptArchEditor; @@ -142,6 +140,7 @@ /** * Creates a new instance. + * @param xmlHelper the xml helper instance for loading XML files * @param scriptFileFilter the file filter for script files * @param scriptExtension the file extension for script files * @param scriptName the display name for script files @@ -170,18 +169,9 @@ * @param validatorPreferences the validator preferences to use * @param mapWriter the map writer for writing temporary map files */ - public DefaultMainControl(@NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, @NotNull final String scriptName, final int spellType, @Nullable final String spellFile, final ErrorView errorView, @NotNull final EditorFactory<G, A, R> editorFactory, final boolean forceReadFromFiles, @NotNull final ProjectSettings projectSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final AbstractMapManager<G, A, R> mapManager, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final AbstractResources<G, A, R> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<G, A, R> mapWriter) { - final XmlHelper xmlHelper; - try { - xmlHelper = new XmlHelper(); - } catch (final ParserConfigurationException ex) { - log.fatal("Cannot create XML parser: " + ex.getMessage()); - //noinspection ThrowInsideCatchBlockWhichIgnoresCaughtException - throw new MissingResourceException("Cannot create XML parser: " + ex.getMessage(), null, null); - } - + public DefaultMainControl(@NotNull final XmlHelper xmlHelper, @NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, @NotNull final String scriptName, final int spellType, @Nullable final String spellFile, final ErrorView errorView, @NotNull final EditorFactory<G, A, R> editorFactory, final boolean forceReadFromFiles, @NotNull final ProjectSettings projectSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final AbstractMapManager<G, A, R> mapManager, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final AbstractResources<G, A, R> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final ValidatorPreferences validatorPreferences, @NotNull final MapWriter<G, A, R> mapWriter) { + final EnvironmentChecker<G, A, R> environmentChecker = new EnvironmentChecker<G, A, R>(validatorPreferences); AttributeRangeChecker<G, A, R> attributeRangeChecker = null; - final EnvironmentChecker<G, A, R> environmentChecker = new EnvironmentChecker<G, A, R>(validatorPreferences); try { final URL url = IOUtils.getResource(projectSettings.getConfigurationDirectory(), "GameObjectMatchers.xml"); final ErrorViewCollector gameObjectMatchersErrorViewCollector = new ErrorViewCollector(errorView, url); @@ -207,6 +197,7 @@ validators.addValidator(attributeRangeChecker); } validators.addValidator(environmentChecker); + ArchetypeTypeChecks.addChecks(archetypeTypeSet, attributeRangeChecker, environmentChecker); final GameObjectMatcher shopSquareMatcher = gameObjectMatchers.getMatcher("system_shop_square", "shop_square"); if (shopSquareMatcher != null) { final GameObjectMatcher noSpellsMatcher = gameObjectMatchers.getMatcher("system_no_spells", "no_spells"); @@ -231,7 +222,6 @@ loadArchetypes(errorView, projectSettings, archetypeSet, archetypeChooserModel, resources, configSource); loadArchetypeSpells(spellType, gameObjectFactory, archetypeSet, gameObjectSpells); loadSpellFile(spellFile, errorView, projectSettings, numberSpells, xmlHelper); - ArchetypeTypeChecks.addChecks(archetypeTypeSet, attributeRangeChecker, environmentChecker); } @NotNull Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java 2013-10-08 17:53:57 UTC (rev 9391) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java 2013-10-08 18:06:54 UTC (rev 9392) @@ -83,6 +83,7 @@ import net.sf.gridarta.utils.EditorAction; import net.sf.gridarta.utils.GUIUtils; import net.sf.gridarta.utils.SystemIcons; +import net.sf.gridarta.utils.XmlHelper; import net.sf.japi.swing.prefs.PreferencesGroup; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -95,6 +96,7 @@ /** * Creates a new {@link DefaultMainControl} instance. + * @param xmlHelper the xml helper instance for loading XML files * @param forceReadFromFiles whether the current config source should be * ignored * @param errorView the error view for reporting errors @@ -117,7 +119,7 @@ * @return the new instance */ @NotNull - DefaultMainControl<G, A, R> newMainControl(boolean forceReadFromFiles, @NotNull ErrorView errorView, @NotNull ProjectSettings projectSettings, @NotNull ConfigSourceFactory configSourceFactory, @NotNull PathManager pathManager, @NotNull GameObjectMatchers gameObjectMatchers, @NotNull GameObjectFactory<G, A, R> gameObjectFactory, @NotNull ArchetypeTypeSet archetypeTypeSet, @NotNull ArchetypeSet<G, A, R> archetypeSet, @NotNull ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull AbstractMapManager<G, A, R> mapManager, @NotNull DelegatingMapValidator<G, A, R> validators, @NotNull ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull AbstractResources<G, A, R> resources, @NotNull Spells<NumberSpell> numberSpells, @NotNull Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull ValidatorPreferences validatorPreferences, @NotNull MapWriter<G, A, R> mapWriter); + DefaultMainControl<G, A, R> newMainControl(@NotNull XmlHelper xmlHelper, boolean forceReadFromFiles, @NotNull ErrorView errorView, @NotNull ProjectSettings projectSettings, @NotNull ConfigSourceFactory configSourceFactory, @NotNull PathManager pathManager, @NotNull GameObjectMatchers gameObjectMatchers, @NotNull GameObjectFactory<G, A, R> gameObjectFactory, @NotNull ArchetypeTypeSet archetypeTypeSet, @NotNull ArchetypeSet<G, A, R> archetypeSet, @NotNull ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull AbstractMapManager<G, A, R> mapManager, @NotNull DelegatingMapValidator<G, A, R> validators, @NotNull ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull AbstractResources<G, A, R> resources, @NotNull Spells<NumberSpell> numberSpells, @NotNull Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull ValidatorPreferences validatorPreferences, @NotNull MapWriter<G, A, R> mapWriter); /** * Returns the offset for drawing double faces. Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java 2013-10-08 17:53:57 UTC (rev 9391) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java 2013-10-08 18:06:54 UTC (rev 9392) @@ -32,6 +32,7 @@ import java.util.ResourceBundle; import java.util.prefs.Preferences; import javax.swing.SwingUtilities; +import javax.xml.parsers.ParserConfigurationException; import net.sf.gridarta.MainControl; import net.sf.gridarta.commands.BatchPngCommand; import net.sf.gridarta.commands.CollectArchesCommand; @@ -108,6 +109,7 @@ import net.sf.gridarta.utils.GUIUtils; import net.sf.gridarta.utils.SyntaxErrorException; import net.sf.gridarta.utils.SystemIcons; +import net.sf.gridarta.utils.XmlHelper; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; import org.apache.log4j.Category; @@ -288,8 +290,17 @@ final Spells<NumberSpell> numberSpells = new Spells<NumberSpell>(); final Spells<GameObjectSpell<G, A, R>> gameObjectSpells = new Spells<GameObjectSpell<G, A, R>>(); final PluginParameterFactory<G, A, R> pluginParameterFactory = new PluginParameterFactory<G, A, R>(archetypeSet, mapManager, defaultFilterList, projectSettings); - final DefaultMainControl<G, A, R> mainControl = editorFactory.newMainControl(mode == GridartaRunMode.COLLECT_ARCHES, errorView, projectSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, mapManager, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, validatorPreferences, mapWriter); + final XmlHelper xmlHelper; + try { + xmlHelper = new XmlHelper(); + } catch (final ParserConfigurationException ex) { + log.fatal("Cannot create XML parser: " + ex.getMessage()); + //noinspection ThrowInsideCatchBlockWhichIgnoresCaughtException + throw new MissingResourceException("Cannot create XML parser: " + ex.getMessage(), null, null); + } + final DefaultMainControl<G, A, R> mainControl = editorFactory.newMainControl(xmlHelper, mode == GridartaRunMode.COLLECT_ARCHES, errorView, projectSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, mapManager, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, validatorPreferences, mapWriter); + final PluginModelParser<G, A, R> pluginModelParser = new PluginModelParser<G, A, R>(pluginParameterFactory); final File scriptsFile = new File(projectSettings.getMapsDirectory(), editorFactory.getScriptsDir()); new PluginModelLoader<G, A, R>(pluginModelParser).loadPlugins(errorView, scriptsFile, pluginModel); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-08 17:54:00
|
Revision: 9391 http://sourceforge.net/p/gridarta/code/9391 Author: akirschbaum Date: 2013-10-08 17:53:57 +0000 (Tue, 08 Oct 2013) Log Message: ----------- Extract code into function. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 17:50:02 UTC (rev 9390) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 17:53:57 UTC (rev 9391) @@ -223,6 +223,19 @@ final Map<String, TreasureTreeNode> specialTreasureLists = loadSpecialTreasureLists(errorView, xmlHelper.getDocumentBuilder(), projectSettings); final ConfigSource configSource = forceReadFromFiles ? configSourceFactory.getFilesConfigSource() : configSourceFactory.getConfigSource(projectSettings.getConfigSourceName()); treasureTree = TreasureLoader.parseTreasures(errorView, specialTreasureLists, configSource, projectSettings); + scriptArchUtils = loadScriptArchUtils(errorView, editorFactory, projectSettings, archetypeTypeSet, xmlHelper); + final ScriptedEventFactory<G, A, R> scriptedEventFactory = editorFactory.newScriptedEventFactory(scriptArchUtils, gameObjectFactory, scriptedEventEditor, archetypeSet); + scriptArchEditor = new DefaultScriptArchEditor<G, A, R>(scriptedEventFactory, scriptExtension, scriptName, scriptArchUtils, scriptFileFilter, projectSettings, mapManager, pathManager); + scriptedEventEditor.setScriptArchEditor(scriptArchEditor); + scriptArchDataUtils = editorFactory.newScriptArchDataUtils(scriptArchUtils, scriptedEventFactory, scriptedEventEditor); + loadArchetypes(errorView, projectSettings, archetypeSet, archetypeChooserModel, resources, configSource); + loadArchetypeSpells(spellType, gameObjectFactory, archetypeSet, gameObjectSpells); + loadSpellFile(spellFile, errorView, projectSettings, numberSpells, xmlHelper); + ArchetypeTypeChecks.addChecks(archetypeTypeSet, attributeRangeChecker, environmentChecker); + } + + @NotNull + private ScriptArchUtils loadScriptArchUtils(@NotNull final ErrorView errorView, final EditorFactory<G, A, R> editorFactory, @NotNull final ProjectSettings projectSettings, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final XmlHelper xmlHelper) { final ArchetypeAttributeFactory archetypeAttributeFactory = new DefaultArchetypeAttributeFactory(); final ArchetypeAttributeParser archetypeAttributeParser = new ArchetypeAttributeParser(archetypeAttributeFactory); final ArchetypeTypeParser archetypeTypeParser = new ArchetypeTypeParser(archetypeAttributeParser); @@ -249,15 +262,7 @@ if (eventTypeSet == null) { eventTypeSet = new ArchetypeTypeList(); } - scriptArchUtils = editorFactory.newScriptArchUtils(eventTypeSet); - final ScriptedEventFactory<G, A, R> scriptedEventFactory = editorFactory.newScriptedEventFactory(scriptArchUtils, gameObjectFactory, scriptedEventEditor, archetypeSet); - scriptArchEditor = new DefaultScriptArchEditor<G, A, R>(scriptedEventFactory, scriptExtension, scriptName, scriptArchUtils, scriptFileFilter, projectSettings, mapManager, pathManager); - scriptedEventEditor.setScriptArchEditor(scriptArchEditor); - scriptArchDataUtils = editorFactory.newScriptArchDataUtils(scriptArchUtils, scriptedEventFactory, scriptedEventEditor); - loadArchetypes(errorView, projectSettings, archetypeSet, archetypeChooserModel, resources, configSource); - loadArchetypeSpells(spellType, gameObjectFactory, archetypeSet, gameObjectSpells); - loadSpellFile(spellFile, errorView, projectSettings, numberSpells, xmlHelper); - ArchetypeTypeChecks.addChecks(archetypeTypeSet, attributeRangeChecker, environmentChecker); + return editorFactory.newScriptArchUtils(eventTypeSet); } private void loadArchetypes(@NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final AbstractResources<G, A, R> resources, @NotNull final ConfigSource configSource) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-08 17:50:05
|
Revision: 9390 http://sourceforge.net/p/gridarta/code/9390 Author: akirschbaum Date: 2013-10-08 17:50:02 +0000 (Tue, 08 Oct 2013) Log Message: ----------- Extract code into function. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 17:48:41 UTC (rev 9389) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 17:50:02 UTC (rev 9390) @@ -254,6 +254,13 @@ scriptArchEditor = new DefaultScriptArchEditor<G, A, R>(scriptedEventFactory, scriptExtension, scriptName, scriptArchUtils, scriptFileFilter, projectSettings, mapManager, pathManager); scriptedEventEditor.setScriptArchEditor(scriptArchEditor); scriptArchDataUtils = editorFactory.newScriptArchDataUtils(scriptArchUtils, scriptedEventFactory, scriptedEventEditor); + loadArchetypes(errorView, projectSettings, archetypeSet, archetypeChooserModel, resources, configSource); + loadArchetypeSpells(spellType, gameObjectFactory, archetypeSet, gameObjectSpells); + loadSpellFile(spellFile, errorView, projectSettings, numberSpells, xmlHelper); + ArchetypeTypeChecks.addChecks(archetypeTypeSet, attributeRangeChecker, environmentChecker); + } + + private void loadArchetypes(@NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final AbstractResources<G, A, R> resources, @NotNull final ConfigSource configSource) { final long timeStart = System.currentTimeMillis(); if (log.isInfoEnabled()) { log.info("Start to load archetypes..."); @@ -263,9 +270,6 @@ if (log.isInfoEnabled()) { log.info("Archetype loading took " + (double) (System.currentTimeMillis() - timeStart) / 1000.0 + " seconds."); } - loadArchetypeSpells(spellType, gameObjectFactory, archetypeSet, gameObjectSpells); - loadSpellFile(spellFile, errorView, projectSettings, numberSpells, xmlHelper); - ArchetypeTypeChecks.addChecks(archetypeTypeSet, attributeRangeChecker, environmentChecker); } private void loadArchetypeSpells(final int spellType, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-08 17:48:44
|
Revision: 9389 http://sourceforge.net/p/gridarta/code/9389 Author: akirschbaum Date: 2013-10-08 17:48:41 +0000 (Tue, 08 Oct 2013) Log Message: ----------- Extract code into function. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 17:47:32 UTC (rev 9388) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 17:48:41 UTC (rev 9389) @@ -263,12 +263,16 @@ if (log.isInfoEnabled()) { log.info("Archetype loading took " + (double) (System.currentTimeMillis() - timeStart) / 1000.0 + " seconds."); } + loadArchetypeSpells(spellType, gameObjectFactory, archetypeSet, gameObjectSpells); + loadSpellFile(spellFile, errorView, projectSettings, numberSpells, xmlHelper); + ArchetypeTypeChecks.addChecks(archetypeTypeSet, attributeRangeChecker, environmentChecker); + } + + private void loadArchetypeSpells(final int spellType, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells) { if (spellType != 0) { new ArchetypeSetSpellLoader<G, A, R>(gameObjectFactory).load(archetypeSet, spellType, gameObjectSpells); gameObjectSpells.sort(); } - loadSpellFile(spellFile, errorView, projectSettings, numberSpells, xmlHelper); - ArchetypeTypeChecks.addChecks(archetypeTypeSet, attributeRangeChecker, environmentChecker); } private void loadSpellFile(@Nullable final String spellFile, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final XmlHelper xmlHelper) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-08 17:47:35
|
Revision: 9388 http://sourceforge.net/p/gridarta/code/9388 Author: akirschbaum Date: 2013-10-08 17:47:32 +0000 (Tue, 08 Oct 2013) Log Message: ----------- Extract code into function. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 17:46:15 UTC (rev 9387) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 17:47:32 UTC (rev 9388) @@ -267,22 +267,29 @@ new ArchetypeSetSpellLoader<G, A, R>(gameObjectFactory).load(archetypeSet, spellType, gameObjectSpells); gameObjectSpells.sort(); } - if (spellFile != null) { + loadSpellFile(spellFile, errorView, projectSettings, numberSpells, xmlHelper); + ArchetypeTypeChecks.addChecks(archetypeTypeSet, attributeRangeChecker, environmentChecker); + } + + private void loadSpellFile(@Nullable final String spellFile, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final XmlHelper xmlHelper) { + if (spellFile == null) { + return; + } + + try { + final URL url = IOUtils.getResource(projectSettings.getConfigurationDirectory(), spellFile); + final ErrorViewCollector errorViewCollector = new ErrorViewCollector(errorView, url); + final DocumentBuilder documentBuilder = xmlHelper.getDocumentBuilder(); + documentBuilder.setErrorHandler(new ErrorViewCollectorErrorHandler(errorViewCollector, ErrorViewCategory.SPELLS_FILE_INVALID)); try { - final URL url = IOUtils.getResource(projectSettings.getConfigurationDirectory(), spellFile); - final ErrorViewCollector errorViewCollector = new ErrorViewCollector(errorView, url); - xmlHelper.getDocumentBuilder().setErrorHandler(new ErrorViewCollectorErrorHandler(errorViewCollector, ErrorViewCategory.SPELLS_FILE_INVALID)); - try { - XMLSpellLoader.load(errorViewCollector, url, xmlHelper.getDocumentBuilder(), numberSpells); - } finally { - xmlHelper.getDocumentBuilder().setErrorHandler(null); - } - } catch (final FileNotFoundException ex) { - errorView.addWarning(ErrorViewCategory.SPELLS_FILE_INVALID, spellFile + ": " + ex.getMessage()); + XMLSpellLoader.load(errorViewCollector, url, documentBuilder, numberSpells); + } finally { + documentBuilder.setErrorHandler(null); } - numberSpells.sort(); + } catch (final FileNotFoundException ex) { + errorView.addWarning(ErrorViewCategory.SPELLS_FILE_INVALID, spellFile + ": " + ex.getMessage()); } - ArchetypeTypeChecks.addChecks(archetypeTypeSet, attributeRangeChecker, environmentChecker); + numberSpells.sort(); } private void addArchetypes(@NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final ArchetypeSet<G, A, R> archetypeSet) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-08 17:46:18
|
Revision: 9387 http://sourceforge.net/p/gridarta/code/9387 Author: akirschbaum Date: 2013-10-08 17:46:15 +0000 (Tue, 08 Oct 2013) Log Message: ----------- Fix comment. Modified Paths: -------------- trunk/src/model/src/main/java/net/sf/gridarta/model/validation/checks/ArchetypeTypeChecks.java Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/validation/checks/ArchetypeTypeChecks.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/validation/checks/ArchetypeTypeChecks.java 2013-10-08 17:44:36 UTC (rev 9386) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/validation/checks/ArchetypeTypeChecks.java 2013-10-08 17:46:15 UTC (rev 9387) @@ -75,7 +75,8 @@ /** * Adds attribute range checks for all defined attributes. * @param attributeRangeChecker the attribute range checker to add to - * @param environmentChecker the environment checker to add to + * @param environmentChecker the environment checker to add to or {@code + * null} to do nothing * @param archetypeTypeSet the archetype type set to use */ public static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void addChecks(@NotNull final ArchetypeTypeSet archetypeTypeSet, @Nullable final AttributeRangeChecker<G, A, R> attributeRangeChecker, @NotNull final EnvironmentChecker<G, A, R> environmentChecker) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-08 17:44:42
|
Revision: 9386 http://sourceforge.net/p/gridarta/code/9386 Author: akirschbaum Date: 2013-10-08 17:44:36 +0000 (Tue, 08 Oct 2013) Log Message: ----------- Move check for null value into function. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java trunk/src/model/src/main/java/net/sf/gridarta/model/validation/checks/ArchetypeTypeChecks.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 17:43:13 UTC (rev 9385) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/DefaultMainControl.java 2013-10-08 17:44:36 UTC (rev 9386) @@ -282,9 +282,7 @@ } numberSpells.sort(); } - if (attributeRangeChecker != null) { - ArchetypeTypeChecks.addChecks(archetypeTypeSet, attributeRangeChecker, environmentChecker); - } + ArchetypeTypeChecks.addChecks(archetypeTypeSet, attributeRangeChecker, environmentChecker); } private void addArchetypes(@NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final ArchetypeSet<G, A, R> archetypeSet) { Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/validation/checks/ArchetypeTypeChecks.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/validation/checks/ArchetypeTypeChecks.java 2013-10-08 17:43:13 UTC (rev 9385) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/validation/checks/ArchetypeTypeChecks.java 2013-10-08 17:44:36 UTC (rev 9386) @@ -53,6 +53,7 @@ import org.apache.log4j.Category; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Creates checks from {@link ArchetypeType ArchetypeTypes}. @@ -77,7 +78,11 @@ * @param environmentChecker the environment checker to add to * @param archetypeTypeSet the archetype type set to use */ - public static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void addChecks(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final AttributeRangeChecker<G, A, R> attributeRangeChecker, @NotNull final EnvironmentChecker<G, A, R> environmentChecker) { + public static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void addChecks(@NotNull final ArchetypeTypeSet archetypeTypeSet, @Nullable final AttributeRangeChecker<G, A, R> attributeRangeChecker, @NotNull final EnvironmentChecker<G, A, R> environmentChecker) { + if (attributeRangeChecker == null) { + return; + } + final Set<Integer> allowsAllInvTypes = new HashSet<Integer>(); for (final ArchetypeType archetypeType : archetypeTypeSet) { if (archetypeType.isAllowsAllInv()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |