From: <aki...@us...> - 2008-08-04 21:04:19
|
Revision: 4758 http://gridarta.svn.sourceforge.net/gridarta/?rev=4758&view=rev Author: akirschbaum Date: 2008-08-04 21:03:43 +0000 (Mon, 04 Aug 2008) Log Message: ----------- Remove ArchetypeChooserControl.getArchetypeChooserModel(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-04 20:43:35 UTC (rev 4757) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-04 21:03:43 UTC (rev 4758) @@ -80,6 +80,7 @@ import net.sf.gridarta.gui.StatusBar; import net.sf.gridarta.gui.SystemIcons; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; +import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; import net.sf.gridarta.gui.map.MapCursorControl; @@ -233,7 +234,8 @@ ACTION_FACTORY.createActions(true, this, "createNew", "open", "options", "exit", "newScript", "editScript", "zoom", "gc", "onlineHelp", "tod", "about"); final MapManagerActions<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager); PathManager.setGlobalSettings(globalSettings); - final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl = new ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, archetypeSet, false); + final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel = new ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeSet); + final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl = new ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, false, archetypeChooserModel); newMapDialogFactory = new NewMapDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, mapManager, gridartaObjectsFactory, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPSIZE, 0, false, false, IGUIConstants.DEF_PICKMAP_WIDTH, IGUIConstants.DEF_PICKMAP_HEIGHT); pickmapChooserControl = new PickmapChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(newMapDialogFactory, this, gridartaObjectsFactory, new File(globalSettings.getMapDir(), IGUIConstants.PICKMAP_DIR), mapManager); newMapDialogFactory.setPickmapChooserControl(pickmapChooserControl); @@ -329,14 +331,14 @@ final CFilterControl filterControl = new CFilterControl(null, mapManager, defaultNamedFilterList); ((CrossfireObjectsFactory) gridartaObjectsFactory).setFilterControl(filterControl); scriptControl = new ScriptController(this, filterControl, archetypeSet, mainView); - final ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChoiceDisplay = new ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, CMapViewBasic>(replaceDialogManager, archetypeTypeSet, objectChooser, archetypeChooserControl.getArchetypeChooserModel(), pickmapChooserControl); + final ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChoiceDisplay = new ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, CMapViewBasic>(replaceDialogManager, archetypeTypeSet, objectChooser, archetypeChooserModel, pickmapChooserControl); final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette = new ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic>(editTypes, selectedSquareView, objectChooser, pickmapChooserControl, copyBuffer); final LeftPanel leftPanel = new LeftPanel(objectChooser, toolPalette, objectChoiceDisplay); mainView.init(gameObjectAttributesPanel, selectedSquareView, archetypeTypeSet, mapTileListBottom, gameObjectMatchers, archetypeChooserControl, objectChooser, leftPanel); mapActions.updateMenuState(); scriptControl.getView().setMenu((JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "plugins")); final ArchetypeParser archetypeParser = new ArchetypeParser(gridartaObjectsFactory, archetypeChooserControl, animationObjects, archetypeSet); - gridartaObjectsFactory.init(faceObjects, archetypeChooserControl, selectedSquareView, this, editTypes, mapImageCache, mapActions, archetypeParser, archetypeSet, autojoinLists, toolPalette); + gridartaObjectsFactory.init(faceObjects, archetypeChooserModel, selectedSquareView, this, editTypes, mapImageCache, mapActions, archetypeParser, archetypeSet, autojoinLists, toolPalette); archetypeSet.loadArchetypes(archetypeParser); if (globalSettings.isAutoPopupDocu()) { Modified: trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-08-04 20:43:35 UTC (rev 4757) +++ trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-08-04 21:03:43 UTC (rev 4758) @@ -44,7 +44,7 @@ import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gameobject.match.GameObjectMatchersInstance; -import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; +import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.tools.ToolPalette; @@ -70,9 +70,9 @@ /** Preferences. */ private static final Preferences prefs = Preferences.userNodeForPackage(MainControl.class); - /** The {@link ArchetypeChooserControl} instance to use. */ + /** The {@link ArchetypeChooserModel} instance to use. */ @NotNull - private ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl = null; + private ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel = null; /** The {@link SelectedSquareView} instance to use. */ @NotNull @@ -154,13 +154,13 @@ /** {@inheritDoc} */ @NotNull public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @NotNull final Component parent) { - return new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, parent, autojoinLists, mapImageCache, objects, mapArchObject, false, GameObjectMatchersInstance.getInstance().getMatcher("exit"), archetypeChooserControl, mapActions); + return new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, parent, autojoinLists, mapImageCache, objects, mapArchObject, false, GameObjectMatchersInstance.getInstance().getMatcher("exit"), archetypeChooserModel, mapActions); } /** {@inheritDoc} */ @NotNull public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newPickmapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @NotNull final Component parent) { - return new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, parent, autojoinLists, mapImageCache, objects, mapArchObject, true, GameObjectMatchersInstance.getInstance().getMatcher("exit"), archetypeChooserControl, mapActions); + return new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, parent, autojoinLists, mapImageCache, objects, mapArchObject, true, GameObjectMatchersInstance.getInstance().getMatcher("exit"), archetypeChooserModel, mapActions); } /** {@inheritDoc} */ @@ -176,8 +176,8 @@ } /** {@inheritDoc} */ - public void init(@NotNull final FaceObjects faceObjects, @NotNull final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final MapActions mapActions, @NotNull final ArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette) { - this.archetypeChooserControl = archetypeChooserControl; + public void init(@NotNull final FaceObjects faceObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final MapActions mapActions, @NotNull final ArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette) { + this.archetypeChooserModel = archetypeChooserModel; this.selectedSquareView = selectedSquareView; this.mainControl = mainControl; this.editTypes = editTypes; Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-08-04 20:43:35 UTC (rev 4757) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-08-04 21:03:43 UTC (rev 4758) @@ -88,6 +88,7 @@ import net.sf.gridarta.gui.StatusBar; import net.sf.gridarta.gui.SystemIcons; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; +import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; import net.sf.gridarta.gui.map.MapCursorControl; @@ -296,7 +297,8 @@ ACTION_FACTORY.createAction(true, "collectSpells", this); final MapManagerActions<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager); PathManager.setGlobalSettings(globalSettings); - final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl = new ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, archetypeSet, true); + final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel = new ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeSet); + final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl = new ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, true, archetypeChooserModel); newMapDialogFactory = new NewMapDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, mapManager, gridartaObjectsFactory, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPDIFFICULTY, true, true, IGUIConstants.DEF_PICKMAP_WIDTH, IGUIConstants.DEF_PICKMAP_HEIGHT); pickmapChooserControl = new PickmapChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(newMapDialogFactory, this, gridartaObjectsFactory, new File(globalSettings.getArchDefaultFolder(), IGUIConstants.PICKMAP_DIR), mapManager); newMapDialogFactory.setPickmapChooserControl(pickmapChooserControl); @@ -390,13 +392,13 @@ // Initialize the main view final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, 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); gameObjectAttributesPanel = new GameObjectAttributesPanel(this, objectChooser, archetypeTypeSet, mapManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); - final ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChoiceDisplay = new ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, CMapViewBasic>(replaceDialogManager, archetypeTypeSet, objectChooser, archetypeChooserControl.getArchetypeChooserModel(), pickmapChooserControl); + final ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChoiceDisplay = new ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, CMapViewBasic>(replaceDialogManager, archetypeTypeSet, objectChooser, archetypeChooserModel, pickmapChooserControl); final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette = new ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic>(editTypes, selectedSquareView, objectChooser, pickmapChooserControl, copyBuffer); final LeftPanel leftPanel = new LeftPanel(objectChooser, toolPalette, objectChoiceDisplay); mainView.init(gameObjectAttributesPanel, selectedSquareView, archetypeTypeSet, mapTileListBottom, gameObjectMatchers, archetypeChooserControl, objectChooser, leftPanel); mapActions.updateMenuState(); final ArchetypeParser archetypeParser = new ArchetypeParser(archetypeChooserControl, animationObjects, archetypeSet); - gridartaObjectsFactory.init(faceObjects, archetypeChooserControl, selectedSquareView, this, editTypes, mapImageCache, mapActions, archetypeParser, archetypeSet, autojoinLists, toolPalette); + gridartaObjectsFactory.init(faceObjects, archetypeChooserModel, selectedSquareView, this, editTypes, mapImageCache, mapActions, archetypeParser, archetypeSet, autojoinLists, toolPalette); archetypeSet.loadArchetypes(archetypeParser); if (globalSettings.isAutoPopupDocu()) { Modified: trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java =================================================================== --- trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java 2008-08-04 20:43:35 UTC (rev 4757) +++ trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java 2008-08-04 21:03:43 UTC (rev 4758) @@ -44,7 +44,7 @@ import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gameobject.match.GameObjectMatchersInstance; -import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; +import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.tools.ToolPalette; @@ -73,9 +73,9 @@ /** The {@link FaceObjects} instance to use. */ private FaceObjects faceObjects = null; - /** The {@link ArchetypeChooserControl} instance to use. */ + /** The {@link ArchetypeChooserModel} instance to use. */ @NotNull - private ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl = null; + private ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel = null; /** The {@link SelectedSquareView} instance to use. */ @NotNull @@ -154,13 +154,13 @@ /** {@inheritDoc} */ @NotNull public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @NotNull final Component parent) { - return new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, parent, autojoinLists, mapImageCache, objects, mapArchObject, false, GameObjectMatchersInstance.getInstance().getMatcher("exit"), archetypeChooserControl, mapActions); + return new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, parent, autojoinLists, mapImageCache, objects, mapArchObject, false, GameObjectMatchersInstance.getInstance().getMatcher("exit"), archetypeChooserModel, mapActions); } /** {@inheritDoc} */ @NotNull public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newPickmapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @NotNull final Component parent) { - final DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, parent, autojoinLists, mapImageCache, objects, mapArchObject, true, GameObjectMatchersInstance.getInstance().getMatcher("exit"), archetypeChooserControl, mapActions); + final DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, parent, autojoinLists, mapImageCache, objects, mapArchObject, true, GameObjectMatchersInstance.getInstance().getMatcher("exit"), archetypeChooserModel, mapActions); mapArchObject.setDifficulty(1); return mapControl; } @@ -178,9 +178,9 @@ } /** {@inheritDoc} */ - public void init(@NotNull final FaceObjects faceObjects, @NotNull final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final MapActions mapActions, @NotNull final ArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette) { + public void init(@NotNull final FaceObjects faceObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final MapActions mapActions, @NotNull final ArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette) { this.faceObjects = faceObjects; - this.archetypeChooserControl = archetypeChooserControl; + this.archetypeChooserModel = archetypeChooserModel; this.selectedSquareView = selectedSquareView; this.mainControl = mainControl; this.editTypes = editTypes; Modified: trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java 2008-08-04 20:43:35 UTC (rev 4757) +++ trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java 2008-08-04 21:03:43 UTC (rev 4758) @@ -29,7 +29,7 @@ import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gameobject.face.FaceObjects; -import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; +import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; @@ -137,7 +137,7 @@ /** * Initializes the instance. * @param faceObjects the FaceObjects instance - * @param archetypeChooserControl the ArchetypeChooserControl instance + * @param archetypeChooserModel the archetype chooser model instance * @param selectedSquareView the selected square view instance * @param mainControl the main control instance * @param editTypes the edit types instance @@ -148,6 +148,6 @@ * @param autojoinLists the autojoin lists instance * @param toolPalette the tool palette instance */ - void init(@NotNull FaceObjects faceObjects, @NotNull ArchetypeChooserControl<G, A, R, V> archetypeChooserControl, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull MainControl<G, A, R, V> mainControl, @NotNull EditTypes<G, A, R, V> editTypes, @NotNull MapImageCache<G, A, R, V> mapImageCache, @NotNull MapActions mapActions, @NotNull ArchetypeParser<G, A, R> archetypeParser, @NotNull ArchetypeSet<G, A, R> archetypeSet, @NotNull final AutojoinLists<G, A, R> autojoinLists, @NotNull ToolPalette<G, A, R, V> toolPalette); + void init(@NotNull FaceObjects faceObjects, @NotNull ArchetypeChooserModel<G, A, R, V> archetypeChooserModel, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull MainControl<G, A, R, V> mainControl, @NotNull EditTypes<G, A, R, V> editTypes, @NotNull MapImageCache<G, A, R, V> mapImageCache, @NotNull MapActions mapActions, @NotNull ArchetypeParser<G, A, R> archetypeParser, @NotNull ArchetypeSet<G, A, R> archetypeSet, @NotNull final AutojoinLists<G, A, R> autojoinLists, @NotNull ToolPalette<G, A, R, V> toolPalette); } // interface GridartaObjectsFactory Modified: trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java 2008-08-04 20:43:35 UTC (rev 4757) +++ trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java 2008-08-04 21:03:43 UTC (rev 4758) @@ -28,7 +28,6 @@ import java.util.Map; import net.sf.gridarta.MainControl; import net.sf.gridarta.gameobject.Archetype; -import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.InsertionMode; @@ -64,11 +63,11 @@ /** * Creates a new instance. * @param mainControl The main control. - * @param archetypeSet the archetype set to display * @param createDirectionPane Whether to create a "direction" panel. + * @param archetypeChooserModel the archetype chooser model to use */ - public ArchetypeChooserControl(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ArchetypeSet<G, A, R> archetypeSet, final boolean createDirectionPane) { - archetypeChooserModel = new ArchetypeChooserModel<G, A, R, V>(archetypeSet); + public ArchetypeChooserControl(@NotNull final MainControl<G, A, R, V> mainControl, final boolean createDirectionPane, @NotNull final ArchetypeChooserModel<G, A, R, V> archetypeChooserModel) { + this.archetypeChooserModel = archetypeChooserModel; archetypeChooserView = new ArchetypeChooserView<G, A, R, V>(createDirectionPane, mainControl, archetypeChooserModel); } @@ -169,14 +168,4 @@ return archetypeChooserView; } - /** - * Returns the archetype chooser model. - * @return the archetype chooser model - */ - @Deprecated - @NotNull - public ArchetypeChooserModel<G, A, R, V> getArchetypeChooserModel() { - return archetypeChooserModel; - } - } // class ArchetypeChooserControl Modified: trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java 2008-08-04 20:43:35 UTC (rev 4757) +++ trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java 2008-08-04 21:03:43 UTC (rev 4758) @@ -37,7 +37,7 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gameobject.match.GameObjectMatcher; -import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; +import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; @@ -158,16 +158,16 @@ * @param mapArchObject the map arch object for this map * @param isPickmap true if this is a pickmap * @param exitTypeGameObjectMatcher the matcher to select exit objects - * @param archetypeChooserControl the archeype chooser control to use + * @param archetypeChooserModel the archeype chooser model to use * @param mapActions the map actions to use */ - public DefaultMapControl(@NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull final Component parent, @NotNull final AutojoinLists<G, A, R> autojoinLists, @NotNull final MapImageCache<G, A, R, V> mapImageCache, @Nullable final List<G> objects, @NotNull final A mapArchObject, final boolean isPickmap, @Nullable final GameObjectMatcher exitTypeGameObjectMatcher, @NotNull final ArchetypeChooserControl<G, A, R, V> archetypeChooserControl, @NotNull final MapActions mapActions) { + public DefaultMapControl(@NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull final Component parent, @NotNull final AutojoinLists<G, A, R> autojoinLists, @NotNull final MapImageCache<G, A, R, V> mapImageCache, @Nullable final List<G> objects, @NotNull final A mapArchObject, final boolean isPickmap, @Nullable final GameObjectMatcher exitTypeGameObjectMatcher, @NotNull final ArchetypeChooserModel<G, A, R, V> archetypeChooserModel, @NotNull final MapActions mapActions) { this.gridartaObjectsFactory = gridartaObjectsFactory; this.parent = parent; this.mapImageCache = mapImageCache; this.isPickmap = isPickmap; // we create model (= data) - mapModel = new DefaultMapModel<G, A, R>(parent, autojoinLists, this, objects, mapArchObject, exitTypeGameObjectMatcher, archetypeChooserControl.getArchetypeChooserModel(), mapActions); + mapModel = new DefaultMapModel<G, A, R>(parent, autojoinLists, this, objects, mapArchObject, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); mapModel.addMapModelListener(mapModelListener); } Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-08-04 20:43:35 UTC (rev 4757) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-08-04 21:03:43 UTC (rev 4758) @@ -53,7 +53,7 @@ import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.GameObjectAttributesPanel; import net.sf.gridarta.gui.MainView; -import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; +import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; @@ -385,13 +385,13 @@ final TestMainControl mainControl = new TestMainControl(gridartaObjectsFactory, "test", globalSettings); final TestMapArchObject mapArchObject = new TestMapArchObject(); final TestArchetypeSet archetypeSet = new TestArchetypeSet(gridartaObjectsFactory); - final ArchetypeChooserControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> archetypeChooserControl = new ArchetypeChooserControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(mainControl, archetypeSet, false); + final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> archetypeChooserModel = new ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(archetypeSet); final MapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(mainControl, "test", gridartaObjectsFactory); final MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapImageCache = new MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(null, mapManager, null, new ImageIcon(), new ImageIcon()); final MapActions mapActions = new TestMapActions(); final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists = new AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype>(); - final TestMapControl mapControl = new TestMapControl(gridartaObjectsFactory, autojoinLists, mapImageCache, null, mapArchObject, false, null, archetypeChooserControl, mapActions); - mapModel = new DefaultMapModel<TestGameObject, TestMapArchObject, TestArchetype>(new JPanel(), autojoinLists, mapControl, null, mapArchObject, null, archetypeChooserControl.getArchetypeChooserModel(), mapActions); + final TestMapControl mapControl = new TestMapControl(gridartaObjectsFactory, autojoinLists, mapImageCache, null, mapArchObject, false, null, archetypeChooserModel, mapActions); + mapModel = new DefaultMapModel<TestGameObject, TestMapArchObject, TestArchetype>(new JPanel(), autojoinLists, mapControl, null, mapArchObject, null, archetypeChooserModel, mapActions); result.setLength(0); mapModel.addMapModelListener(mapModelListener); @@ -490,11 +490,11 @@ * @param mapArchObject the map arch object to use * @param isPickmap whether this map control is a pickmap * @param exitTypeGameObjectMatcher the exit matcher to use - * @param archetypeChooserControl the archetype chooser control to use + * @param archetypeChooserModel the archetype chooser model to use * @param mapActions the map actions to use */ - public TestMapControl(@NotNull final GridartaObjectsFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> gridartaObjectsFactory, @NotNull final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists, @NotNull final MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapImageCache, @Nullable final List<TestGameObject> objects, @NotNull final TestMapArchObject mapArchObject, final boolean isPickmap, @Nullable final GameObjectMatcher exitTypeGameObjectMatcher, @NotNull final ArchetypeChooserControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> archetypeChooserControl, @NotNull final MapActions mapActions) { - super(gridartaObjectsFactory, new JPanel(), autojoinLists, mapImageCache, objects, mapArchObject, isPickmap, exitTypeGameObjectMatcher, archetypeChooserControl, mapActions); + public TestMapControl(@NotNull final GridartaObjectsFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> gridartaObjectsFactory, @NotNull final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists, @NotNull final MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapImageCache, @Nullable final List<TestGameObject> objects, @NotNull final TestMapArchObject mapArchObject, final boolean isPickmap, @Nullable final GameObjectMatcher exitTypeGameObjectMatcher, @NotNull final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> archetypeChooserModel, @NotNull final MapActions mapActions) { + super(gridartaObjectsFactory, new JPanel(), autojoinLists, mapImageCache, objects, mapArchObject, isPickmap, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); } } @@ -888,7 +888,7 @@ } /** {@inheritDoc} */ - public void init(@NotNull final FaceObjects faceObjects, @NotNull final ArchetypeChooserControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> testGameObjectTestMapArchObjectTestArchetypeTestMapViewBasicArchetypeChooserControl, @NotNull final SelectedSquareView<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> selectedSquareView, @NotNull final MainControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mainControl, @NotNull final EditTypes<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> editTypes, @NotNull final MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapImageCache, @NotNull final MapActions mapActions, @NotNull final ArchetypeParser<TestGameObject, TestMapArchObject, TestArchetype> archetypeParser, @NotNull final ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeSet, @NotNull final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists, @NotNull final ToolPalette<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> toolPalette) { + public void init(@NotNull final FaceObjects faceObjects, @NotNull final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> archetypeChooserModel, @NotNull final SelectedSquareView<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> selectedSquareView, @NotNull final MainControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mainControl, @NotNull final EditTypes<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> editTypes, @NotNull final MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapImageCache, @NotNull final MapActions mapActions, @NotNull final ArchetypeParser<TestGameObject, TestMapArchObject, TestArchetype> archetypeParser, @NotNull final ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeSet, @NotNull final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists, @NotNull final ToolPalette<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> toolPalette) { throw new AssertionError(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-08-05 19:19:57
|
Revision: 4761 http://gridarta.svn.sourceforge.net/gridarta/?rev=4761&view=rev Author: akirschbaum Date: 2008-08-05 19:19:39 +0000 (Tue, 05 Aug 2008) Log Message: ----------- Move GameObjectAttributesPanel into sparate package. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBox.java trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBoxEditor.java trunk/crossfire/src/cfeditor/gui/script/parameter/ArchParameterView.java trunk/crossfire/src/cfeditor/script/parameter/ArchParameter.java trunk/crossfire/src/cfeditor/script/parameter/PluginParameterFactory.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gui/MainView.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesPanel.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-08-05 04:39:30 UTC (rev 4760) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-08-05 19:19:39 UTC (rev 4761) @@ -27,7 +27,7 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.scripts.AbstractScriptArchEditor; -import net.sf.gridarta.gui.GameObjectAttributesPanel; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesPanel; import net.sf.gridarta.utils.StringUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-08-05 04:39:30 UTC (rev 4760) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-08-05 19:19:39 UTC (rev 4761) @@ -29,7 +29,7 @@ import javax.swing.JOptionPane; import net.sf.gridarta.MainControl; import net.sf.gridarta.gameobject.scripts.ScriptedEventEditor; -import net.sf.gridarta.gui.GameObjectAttributesPanel; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesPanel; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-08-05 04:39:30 UTC (rev 4760) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-08-05 19:19:39 UTC (rev 4761) @@ -42,7 +42,7 @@ * @author <a href="mailto:and...@gm...">Andreas Vogl</a> * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public final class GameObjectAttributesPanel extends net.sf.gridarta.gui.GameObjectAttributesPanel<GameObject, MapArchObject, Archetype, CMapViewBasic> { +public final class GameObjectAttributesPanel extends net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesPanel<GameObject, MapArchObject, Archetype, CMapViewBasic> { /** Serial Version UID. */ private static final long serialVersionUID = 1L; Modified: trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBox.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBox.java 2008-08-05 04:39:30 UTC (rev 4760) +++ trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBox.java 2008-08-05 19:19:39 UTC (rev 4761) @@ -26,7 +26,7 @@ import cfeditor.map.MapArchObject; import java.awt.Dimension; import javax.swing.JComboBox; -import net.sf.gridarta.gui.GameObjectAttributesPanel; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesPanel; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; Modified: trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBoxEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBoxEditor.java 2008-08-05 04:39:30 UTC (rev 4760) +++ trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBoxEditor.java 2008-08-05 19:19:39 UTC (rev 4761) @@ -44,7 +44,7 @@ import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import net.sf.gridarta.CommonConstants; -import net.sf.gridarta.gui.GameObjectAttributesPanel; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesPanel; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import org.jetbrains.annotations.Nullable; Modified: trunk/crossfire/src/cfeditor/gui/script/parameter/ArchParameterView.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/script/parameter/ArchParameterView.java 2008-08-05 04:39:30 UTC (rev 4760) +++ trunk/crossfire/src/cfeditor/gui/script/parameter/ArchParameterView.java 2008-08-05 19:19:39 UTC (rev 4761) @@ -30,7 +30,7 @@ import java.awt.event.ItemListener; import javax.swing.JComponent; import javax.swing.JPanel; -import net.sf.gridarta.gui.GameObjectAttributesPanel; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesPanel; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import org.jetbrains.annotations.NotNull; Modified: trunk/crossfire/src/cfeditor/script/parameter/ArchParameter.java =================================================================== --- trunk/crossfire/src/cfeditor/script/parameter/ArchParameter.java 2008-08-05 04:39:30 UTC (rev 4760) +++ trunk/crossfire/src/cfeditor/script/parameter/ArchParameter.java 2008-08-05 19:19:39 UTC (rev 4761) @@ -26,7 +26,7 @@ import cfeditor.gui.script.parameter.ArchParameterView; import cfeditor.gui.script.parameter.PluginParameterView; import cfeditor.map.MapArchObject; -import net.sf.gridarta.gui.GameObjectAttributesPanel; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesPanel; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import org.jdom.Element; import org.jetbrains.annotations.NotNull; Modified: trunk/crossfire/src/cfeditor/script/parameter/PluginParameterFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/script/parameter/PluginParameterFactory.java 2008-08-05 04:39:30 UTC (rev 4760) +++ trunk/crossfire/src/cfeditor/script/parameter/PluginParameterFactory.java 2008-08-05 19:19:39 UTC (rev 4761) @@ -27,7 +27,7 @@ import java.util.LinkedHashMap; import java.util.Map; import net.sf.gridarta.MapManager; -import net.sf.gridarta.gui.GameObjectAttributesPanel; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesPanel; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import org.apache.log4j.Logger; import org.jdom.Element; Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-08-05 04:39:30 UTC (rev 4760) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-08-05 19:19:39 UTC (rev 4761) @@ -28,7 +28,7 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.scripts.AbstractScriptArchEditor; -import net.sf.gridarta.gui.GameObjectAttributesPanel; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesPanel; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-08-05 04:39:30 UTC (rev 4760) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-08-05 19:19:39 UTC (rev 4761) @@ -29,7 +29,7 @@ import javax.swing.JOptionPane; import net.sf.gridarta.MainControl; import net.sf.gridarta.gameobject.scripts.ScriptedEventEditor; -import net.sf.gridarta.gui.GameObjectAttributesPanel; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesPanel; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-08-05 04:39:30 UTC (rev 4760) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-08-05 19:19:39 UTC (rev 4761) @@ -42,7 +42,7 @@ * @author <a href="mailto:and...@gm...">Andreas Vogl</a> * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public final class GameObjectAttributesPanel extends net.sf.gridarta.gui.GameObjectAttributesPanel<GameObject, MapArchObject, Archetype, CMapViewBasic> { +public final class GameObjectAttributesPanel extends net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesPanel<GameObject, MapArchObject, Archetype, CMapViewBasic> { /** Serial Version UID. */ private static final long serialVersionUID = 1L; Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-08-05 04:39:30 UTC (rev 4760) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-08-05 19:19:39 UTC (rev 4761) @@ -29,7 +29,7 @@ import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.match.GameObjectMatchers; import net.sf.gridarta.gui.GUIConstants; -import net.sf.gridarta.gui.GameObjectAttributesPanel; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesPanel; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapSquare; import net.sf.gridarta.utils.StringUtils; Deleted: trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java 2008-08-05 04:39:30 UTC (rev 4760) +++ trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java 2008-08-05 19:19:39 UTC (rev 4761) @@ -1,1065 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2007 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package net.sf.gridarta.gui; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.GridLayout; -import java.awt.Insets; -import java.awt.Toolkit; -import java.util.prefs.Preferences; -import javax.swing.Action; -import javax.swing.ButtonGroup; -import javax.swing.DefaultListModel; -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JSplitPane; -import javax.swing.JTabbedPane; -import javax.swing.JTextArea; -import javax.swing.JTextField; -import javax.swing.JToggleButton; -import javax.swing.ScrollPaneConstants; -import javax.swing.SwingConstants; -import javax.swing.border.EtchedBorder; -import net.sf.gridarta.MainControl; -import net.sf.gridarta.MapManager; -import net.sf.gridarta.MapManagerListener; -import net.sf.gridarta.archtype.ArchetypeType; -import net.sf.gridarta.archtype.ArchetypeTypeSet; -import net.sf.gridarta.gameobject.Archetype; -import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gameobject.anim.AnimationObjects; -import net.sf.gridarta.gameobject.match.GameObjectMatcher; -import net.sf.gridarta.gui.connectionview.ConnectionControl; -import net.sf.gridarta.gui.connectionview.LockedItemsControl; -import net.sf.gridarta.gui.connectionview.MonsterControl; -import net.sf.gridarta.gui.gameobjecttexteditor.GameObjectTextEditor; -import net.sf.gridarta.gui.map.MapView; -import net.sf.gridarta.gui.map.MapViewBasic; -import net.sf.gridarta.gui.objectchooser.ObjectChooser; -import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; -import net.sf.gridarta.gui.selectedsquare.SelectedSquareListener; -import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; -import net.sf.gridarta.map.MapArchObject; -import net.sf.gridarta.map.MapControl; -import net.sf.gridarta.map.MapModel; -import net.sf.gridarta.map.MapModelEvent; -import net.sf.gridarta.map.MapModelListener; -import net.sf.gridarta.map.MapSquare; -import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.ActionMethod; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Common base class for the panel that allows users to edit a GameObject's - * attributes. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public abstract class GameObjectAttributesPanel<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> extends JPanel { - - // constants for the 'task' parameter in editScriptWanted() - public static final int SCRIPT_OPEN = 0; - - public static final int SCRIPT_EDIT_PATH = 1; - - public static final int SCRIPT_REMOVE = 2; - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); - - private final Action aScriptAddNew = ACTION_FACTORY.createAction(false, "scriptAddNew", this); - - private final Action aScriptEditData = ACTION_FACTORY.createAction(false, "scriptEditData", this); - - private final Action aScriptEdit = ACTION_FACTORY.createAction(false, "scriptEdit", this); - - private final Action aScriptRemove = ACTION_FACTORY.createAction(false, "scriptRemove", this); - - /** The label that displays the current animation name. */ - private final JLabel archAnimText = new JLabel(); - - /** The Panel that displays animation information. */ - private final JPanel animationPanel = createAnimationPanel(); - - /** The Panel that displays scripting information. */ - private final JPanel scriptPanel = createScriptPanel(); - - /** The MainControl to use, e.g. for accessing AnimationObjects. */ - private final MainControl<G, A, R, V> mainControl; - - /** - * The object chooser instance. - */ - @NotNull - private final ObjectChooser<G, A, R> objectChooser; - - /** The archetype type set. */ - @NotNull - private final ArchetypeTypeSet<G, A, R> archetypeTypeSet; - - /** The map manager. */ - private final MapManager<G, A, R, V> mapManager; - - /** The animtation objects instance to use. */ - @NotNull - private final AnimationObjects<?> animationObjects; - - /** - * The parent frame for dialog boxes. - */ - @NotNull - private final Frame parent; - - /** The tabs of this GameObjectAttributesPanel. */ - private final JTabbedPane panelDesktop = new JTabbedPane(SwingConstants.TOP); - - /** The selected game object. */ - private G selectedGameObject = null; - - /** Last known active map. This map has {@link #mapModelListener} attached. */ - @Nullable - private MapControl<G, A, R, V> currentMap; - - /** Arch text field. */ - private final JTextArea archTextArea = new JTextArea(4, 25); - - private JList eventList; - - /** Preferences. */ - private static final Preferences prefs = Preferences.userNodeForPackage(MainControl.class); - - private static final String MAPARCHPANEL_LOCATION_KEY = "MainWindowMapArchPanel.dividerLocation"; - - /** - * The buttons for the direction panel. - * @see #directionButtonGroup - */ - private final JToggleButton[] directionButtons = new JToggleButton[9]; - - /** - * The ButtonGroup for the direction buttons. - * @see #directionButtons - */ - private final ButtonGroup directionButtonGroup = new ButtonGroup(); - - private final GSplitPane splitPane; - - /** The {@link ErrorListView} holding the error information. */ - private final ErrorListView<G, A, R, V> errorListView; - - /** Arch name field. */ - private final JTextField archNameField = new JTextField(14); - - private final JLabel archMapPos = new JLabel(); - - private final JLabel archFaceText = new JLabel(); - - private final JLabel archTypeText = new JLabel(); - - private final JPanel mapArchPanel = new JPanel(); - - private final Action aMapArchApply = ACTION_FACTORY.createAction(false, "mapArchApply", this); - - private final Action aMapArchAddInv = ACTION_FACTORY.createAction(false, "mapArchAddInv", this); - - private final Action aMapArchAttrib = ACTION_FACTORY.createAction(false, "mapArchAttrib", this); - - private final GameObjectTextEditor gameObjectTextEditor; - - /** The map manager listener which is attached to {@link #mainControl}. */ - private final MapManagerListener<G, A, R, V> mapManagerListener = new MapManagerListener<G, A, R, V>() { - - /** {@inheritDoc} */ - public void currentMapChanged(@Nullable final MapControl<G, A, R, V> mapControl) { - if (currentMap != null) { - currentMap.getMapModel().removeMapModelListener(mapModelListener); - } - currentMap = mapControl; - if (currentMap != null) { - currentMap.getMapModel().addMapModelListener(mapModelListener); - } - } - - /** {@inheritDoc} */ - public void currentMapViewChanged(@Nullable final MapView<G, A, R, V> mapView) { - // ignore - } - - /** {@inheritDoc} */ - public void mapCreated(@NotNull final MapControl<G, A, R, V> mapControl) { - // ignore - } - - /** {@inheritDoc} */ - public void mapViewCreated(@NotNull final MapView<G, A, R, V> mapView) { - // ignore - } - - /** {@inheritDoc} */ - public void mapClosing(@NotNull final MapControl<G, A, R, V> mapControl) { - // ignore - } - - /** {@inheritDoc} */ - public void mapViewClosing(@NotNull final MapView<G, A, R, V> mapView) { - // ignore - } - - }; - - /** The map model listener which is attached to {@link #currentMap}. */ - private final MapModelListener<G, A, R> mapModelListener = new MapModelListener<G, A, R>() { - - /** {@inheritDoc} */ - public void mapMetaChanged(@NotNull final A mapArchObject) { - // ignore - } - - /** {@inheritDoc} */ - public void mapSizeChanged(final MapModelEvent<G, A, R> e) { - // ignore - } - - /** {@inheritDoc} */ - public void mapSquaresChanged(final MapModelEvent<G, A, R> e) { - if (selectedGameObject == null) { - return; - } - - final G topGameObject = selectedGameObject.getTopContainer(); - for (final MapSquare<G, A, R> mapSquare : e.getSquares()) { - for (final G gameObject : mapSquare) { - if (gameObject == topGameObject) { - refreshDisplay(); - } - } - } - } - - /** {@inheritDoc} */ - public void mapObjectsChanged(final MapModelEvent<G, A, R> e) { - for (final G gameObject : e.getGameObjects()) { - if (selectedGameObject == gameObject) { - refreshDisplay(); - } - } - } - - /** {@inheritDoc} */ - public void errorsChanged(@NotNull final MapModel<G, A, R> mapModel) { - setErrors(mapModel); - } - - }; - - /** The listener to detect changes of the selected game object. */ - private final SelectedSquareListener<G, A, R> selectedSquareListener = new SelectedSquareListener<G, A, R>() { - - /** {@inheritDoc} */ - public void selectedGameObjectChanged(@Nullable final G gameObject) { - setSelectedGameObject(gameObject); - } - - }; - - /** - * Create the GameObjectAttributesPanel. - * @param mainControl MainControl to use, e.g. for accessing - * AnimationObjects. - * @param objectChooser the object chooser instance - * @param archetypeTypeSet the archetype type set - * @param monsterMatcher the <code>GameObjectMatcher</code> for matching - * monster objects - * @param parent the parent frame for dialog boxes - */ - protected GameObjectAttributesPanel(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<G, A, R, V> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<G, A, R, V> selectedSquareControl, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull final Frame parent) { - super(new BorderLayout()); - this.mainControl = mainControl; - this.objectChooser = objectChooser; - this.archetypeTypeSet = archetypeTypeSet; - this.mapManager = mapManager; - this.animationObjects = animationObjects; - this.parent = parent; - errorListView = new ErrorListView<G, A, R, V>(mapManager, selectedSquareView); - - gameObjectTextEditor = new GameObjectTextEditor(); - - mapArchPanel.setLayout(new BorderLayout()); - splitPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, mapArchPanel, gameObjectTextEditor); - splitPane.setContinuousLayout(true); - splitPane.setResizeWeight(1); - splitPane.setDividerLocation(prefs.getInt(MAPARCHPANEL_LOCATION_KEY, getMapArchPanelLocation())); - add(splitPane, BorderLayout.CENTER); - - final JPanel buttonPanel = createButtonPanel(); - buttonPanel.setLayout(new GridLayout(0, 1)); - mapArchPanel.add(buttonPanel, BorderLayout.WEST); - mapArchPanel.add(panelDesktop, BorderLayout.CENTER); - - panelDesktop.add(createArchPanel(), "Arch"); - panelDesktop.add(createTextPanel(), "Msg Text"); - panelDesktop.add(scriptPanel, "Scripts"); - panelDesktop.add(animationPanel, "Animation"); - panelDesktop.add(createConnectionPanel(), "Connection"); - panelDesktop.add(lockedItemsControl.getView(), "Locked Items"); - panelDesktop.add(createMonsterPanel(monsterMatcher), "Monster"); - panelDesktop.add(errorListView, "Warnings"); - - selectedSquareControl.addSelectedSquareListener(selectedSquareListener); - - refreshDisplay(); - currentMap = mapManager.getCurrentMap(); - if (currentMap != null) { - currentMap.getMapModel().addMapModelListener(mapModelListener); - } - mapManager.addMapManagerListener(mapManagerListener); - archTextArea.setLineWrap(true); - } - - // simple "white space test, to eliminate ' ' - // perhaps we should include here a real white space test - protected static boolean isNonwhitespaceText(final String text) { - return text.replaceAll("\\s+", "").length() > 0; - } - - /** - * Creates and returns the panel for displaying animation information. - * @return The newly created animation information panel. - */ - private JPanel createAnimationPanel() { - final JPanel panel = new JPanel(new BorderLayout()); - archAnimText.setText("Animation: "); - panel.add(archAnimText); - return panel; - } - - /** - * Sets the animation name. - * @param animationName Animation name - */ - protected void setAnimationName(@Nullable final String animationName) { - archAnimText.setText("Animation: " + (animationName != null ? animationName : "")); - } - - /** - * Return the selected game object. - * @return the selected game object, or <code>null</code> if no game object - * is selected - */ - @Nullable - public G getSelectedGameObject() { - return selectedGameObject; - } - - /** - * If a game object is selected, the MapArchPanels (bottom right windows) - * get updated. - * @param activeGameObject the selected arch - */ - private void setSelectedGameObject(@Nullable final G activeGameObject) { - selectedGameObject = activeGameObject; - refreshDisplay(); - } - - /** Update the displayed information for {@link #selectedGameObject}. */ - private void refreshDisplay() { - final G gameObject = selectedGameObject == null ? null : selectedGameObject.getHead(); - - aMapArchApply.setEnabled(gameObject != null); - aMapArchAddInv.setEnabled(gameObject != null); - aMapArchAttrib.setEnabled(gameObject != null); - - gameObjectTextEditor.refreshDisplay(gameObject); - refreshArchTab(gameObject); - refreshMsgTextTab(gameObject); - refreshScriptsTab(gameObject); - refreshAnimationTab(gameObject); - } - - /** - * Refresh the "Animation" tab in the Game Object Attributes Panel. - * @param gameObject The game object to set the contents from. - */ - protected void refreshAnimationTab(final G gameObject) { - if (gameObject == null) { - panelDesktop.setForegroundAt(3, Color.black); - setAnimationName(null); - } else { - String animName = gameObject.getAnimName(); - if (animName == null) { - animName = gameObject.getArchetype().getAnimName(); - } - if (animName != null) { - final StringBuilder animText = new StringBuilder(animName); - if (!animationObjects.containsKey(animName)) { - panelDesktop.setForegroundAt(3, Color.red); - animText.append(" (** unknown animation **)"); - } else { - panelDesktop.setForegroundAt(3, Color.blue); - } - setAnimationName(animText.toString()); - } else { - panelDesktop.setForegroundAt(3, Color.black); - setAnimationName(null); - } - } - } - - /** - * Apply changes in the "Msg Text" tab in the Game Object Attributes Panel. - * @param gameObject The game object to modify. - */ - protected void applyArchTextArea(final G gameObject) { - final R archetype = gameObject.getArchetype(); - // the msg TEXT!! ("msg ... endmsg") - // if there is an entry in the archTextArea (msg window), this - // overrules the default text (if any) - if (isNonwhitespaceText(archTextArea.getText())) { // there is something in the msg win - if (archetype.getMsgText() != null) { - // trim text from message window - String newMsgText = archTextArea.getText(); - if (newMsgText != null) { - newMsgText = newMsgText.trim(); - } else { - newMsgText = ""; - } - if (newMsgText.equals(archetype.getMsgText().trim())) { - gameObject.deleteMsgText(); // yes, we don't need it in map - } else { - gameObject.resetMsgText(); - gameObject.addMsgText(newMsgText); - } - } else { - gameObject.resetMsgText(); - gameObject.addMsgText(archTextArea.getText()); - } - } else { // there is nothing in the msg win - gameObject.deleteMsgText(); // always delete this... - if (archetype.getMsgText() != null) { - gameObject.addMsgText(""); // but here we must overrule default with msg/endmsg (empty msg) - } - } - } - - /** - * Create the "Msg Text" tab in the Game Object Attributes Panel. - * @return The Game Object Attributes Editor. - */ - protected JPanel createTextPanel() { - final JPanel textPanel = new JPanel(new GridLayout(1, 1)); - - // create ScrollPane for text scrolling - final JScrollPane sta = new JScrollPane(archTextArea); - sta.setBorder(new EtchedBorder()); - sta.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); - sta.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - - //textPanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED)); - textPanel.add(sta); - return textPanel; - } - - /** - * Refresh the "Msg Text" tab in the Game Object Attributes Panel. - * @param gameObject The game object to set the contents from. - */ - protected void refreshMsgTextTab(final G gameObject) { - final boolean hasMessage; - if (gameObject == null) { - archTextArea.setForeground(Color.black); - archTextArea.setText(""); - hasMessage = false; - } else { - final String msgText = gameObject.getMsgText(); - if (msgText != null) { - archTextArea.setForeground(Color.blue); - archTextArea.setText(msgText); - hasMessage = true; - } else { - archTextArea.setForeground(Color.black); - final String archMsgText = gameObject.getArchetype().getMsgText(); - if (archMsgText != null) { - archTextArea.setText(archMsgText); - hasMessage = true; - } else { - archTextArea.setText(""); - hasMessage = false; - } - } - archTextArea.setCaretPosition(0); - } - panelDesktop.setForegroundAt(1, hasMessage ? Color.blue : Color.black); - } - - /** - * Creates a script panel. - * @return newly created script panel. - */ - private JPanel createScriptPanel() { - eventList = new JList(); - - // create ScrollPane for jlist scrolling - final JScrollPane ssa = new JScrollPane(eventList); - ssa.setBorder(new EtchedBorder()); - ssa.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); - ssa.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - ssa.setPreferredSize(new Dimension(80, 40)); - - // create buttons - final JPanel grid = new JPanel(new GridLayout(4, 1)); - grid.add(new JButton(aScriptAddNew)); - grid.add(new JButton(aScriptEditData)); - grid.add(new JButton(aScriptEdit)); - grid.add(new JButton(aScriptRemove)); - - // disable all the buttons in the beginning - aScriptAddNew.setEnabled(false); - aScriptEditData.setEnabled(false); - aScriptEdit.setEnabled(false); - aScriptRemove.setEnabled(false); - - final JPanel panel = new JPanel(); // new panel - panel.setLayout(new BorderLayout()); - panel.add(ssa, BorderLayout.CENTER); - panel.add(grid, BorderLayout.EAST); - panel.setPreferredSize(new Dimension(100, 40)); - return panel; - } - - /** - * Refresh the "Scripts" tab in the Game Object Attributes Panel. - * @param gameObject The game object to set the contents from. - */ - protected void refreshScriptsTab(final G gameObject) { - if (gameObject == null || !gameObject.isScripted()) { - panelDesktop.setForegroundAt(2, Color.black); - if (eventList.getModel() != null && eventList.getModel().getSize() > 0) { - eventList.setModel(new DefaultListModel()); - } - - aScriptAddNew.setEnabled(gameObject != null); - aScriptEditData.setEnabled(false); - aScriptEdit.setEnabled(false); - aScriptRemove.setEnabled(false); - } else { - panelDesktop.setForegroundAt(2, Color.blue); - eventList.removeAll(); - gameObject.addEventsToJList(eventList); - - aScriptAddNew.setEnabled(true); - aScriptEditData.setEnabled(true); - aScriptEdit.setEnabled(true); - aScriptRemove.setEnabled(true); - } - } - - /** - * Set enable/disable states for the four buttons in the script panel. - * @param newButton Enabled state for the "new" button. - * @param modifyButton Enabled state for the "modify" button. - * @param pathButton Enabled state for the "path" button. - * @param removeButton Enabled state for the "remove" button. - */ - public void setScriptPanelButtonState(final boolean newButton, final boolean modifyButton, final boolean pathButton, final boolean removeButton) { - aScriptAddNew.setEnabled(newButton); - aScriptEditData.setEnabled(pathButton); - aScriptEdit.setEnabled(modifyButton); - aScriptRemove.setEnabled(removeButton); - } - - /** Action method for creating a new Script. */ - @ActionMethod - public void scriptAddNew() { - addNewScriptWanted(); - } - - /** Action method for editing the data of an existing Script. */ - @ActionMethod - public void scriptEditData() { - editScriptWanted(SCRIPT_EDIT_PATH); - } - - /** Action method for editing an existing Script. */ - @ActionMethod - public void scriptEdit() { - editScriptWanted(SCRIPT_OPEN); - } - - /** Action method for removing an existing script. */ - @ActionMethod - public void scriptRemove() { - editScriptWanted(SCRIPT_REMOVE); - } - - /** This method is invoked when the user pressed the "new script" button. */ - public void addNewScriptWanted() { - if (selectedGameObject != null) { - final MapSquare<G, A, R> mapSquare = selectedGameObject.getHead().getMapSquare(); - assert mapSquare != null; - mapSquare.getMapModel().beginTransaction("Add event script"); - selectedGameObject.getHead().addEventScript(eventList, this, parent); - mapSquare.getMapModel().endTransaction(); - } - } - - /** - * This method is invoked when the user pressed the "edit - * script"/"path"/"remove" button from the script panel. If there is a valid - * selection in the event list, the appropriate action for this script is - * triggered. - * @param task Script type to edit (?). - */ - public void editScriptWanted(final int task) { - if (selectedGameObject == null) { - return; - } - - // check for a valid selection in the event list - if (eventList.getModel() != null && eventList.getModel().getSize() > 0 && eventList.getSelectedIndex() >= 0) { - // there - final int index = eventList.getSelectedIndex(); - if (index >= 0) { - final MapSquare<G, A, R> mapSquare = selectedGameObject.getMapSquare(); - assert mapSquare != null; - mapSquare.getMapModel().beginTransaction("Modify event script"); - selectedGameObject.getHead().modifyEventScript(index, task, eventList, this, mainControl, parent); - mapSquare.getMapModel().endTransaction(); - } - } - } - - /** - * Update the displayed errors. - * @param mapModel the map model of which the errors have changed - */ - private void setErrors(@NotNull final MapModel<G, A, R> mapModel) { - panelDesktop.setForegroundAt(7, mapModel.getErrors().getErrors().iterator().hasNext() ? Color.blue : Color.black); - errorListView.setErrors(mapModel, mapModel.getErrors()); - } - - /** Action method for applying the changes made in the arch panel. */ - @ActionMethod - public void mapArchApply() { - applyArchPanelChanges(selectedGameObject); - } - - /** - * Action method for displaying the attributes of the currently selected - * object. - */ - @ActionMethod - public void mapArchAttrib() { - mainControl.openAttrDialog(selectedGameObject); - } - - /** - * Action method for adding an object to the inventory of the currently - * selected object. - */ - @ActionMethod - public void mapArchAddInv() { - final G arch = objectChooser.getObjectChooserHighlight(); - if (arch == null) { // nothing selected? - return; - } - - if (selectedGameObject == null) { - return; - } - - final G inv = selectedGameObject.getHead(); - - final G invnew; - if (arch.isArchetype()) { - // create a new copy of a default arch - invnew = arch.createGameObject(); - } else { - // create clone from a pickmap - invnew = arch.createClone(0, 0); - } - - invnew.setDirection(invnew.getArchetype().getDirection()); - invnew.postParseGameObject(0); - final MapSquare<G, A, R> mapSquare = inv.getMapSquare(); - assert mapSquare != null; - final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); - mapModel.beginTransaction("Add to inventory"); - inv.addLast(invnew); - invnew.setObjectFace(); - mapModel.endTransaction(); - } - - /** - * When the "apply"-button on the ArchPanel (at the bottom of the window) is - * pressed, this function updates the active arch object. - * @param activeArch the currently selected arch - */ - public void applyArchPanelChanges(final G activeArch) { - if (activeArch == null) { - return; - } - - // If the active gameObject is part of a multi, the multi-head's stats - // are taken instead: - final G gameObject = activeArch.getHead(); - - final R archetype = gameObject.getArchetype(); - - final MapSquare<G, A, R> mapSquare = gameObject.getMapSquare(); - assert mapSquare != null; - mapSquare.getMapModel().beginTransaction("Change object attributes"); - - // We update all panels: name, face, msg and archText (more to come...) - // the obj name: - if (isNonwhitespaceText(archNameField.getText())) { // there is something in - // if this equal the default name... - if (archetype.getObjName() != null) { - if (archNameField.getText().compareTo(archetype.getObjName()) == 0) { - gameObject.setObjName(null); // yes, we don't need it in map - } else { - gameObject.setObjName(archNameField.getText()); // overrule in map gameObject - } - } else - if (archNameField.getText().compareTo(gameObject.getArchetypeName()) == 0) { - gameObject.setObjName(null); - } else { // def is null, something is in panel, so we set it - gameObject.setObjName(archNameField.getText()); // overrule in map gameObject - } - } else { - gameObject.setObjName(null); // nothing in, nothing in map gameObject - // hm, there is no way yet to overrule a default gameObject name with "nothing" - // like <name > ore <name "">..?? - } - - applyArchTextArea(gameObject); - - gameObjectTextEditor.applyChanges(gameObject); - - /* check we have a face and set the real face obj for fast access */ - final String face = gameObject.getAttributeString("face", false); - // we have a new face name - gameObject.setRealFace(face); - if (gameObject.getAttributeString("animation", false).length() > 0) { - gameObject.setAnimName(gameObject.getAttributeString("animation", false)); - } else { - gameObject.setAnimName(archetype.getAnimName()); - } - - if (gameObject.getAttributeString("direction", false).length() > 0) { - final int dir = gameObject.getAttributeInt("direction", false); - if (archetype.getDirection() != dir) { - gameObject.setDirection(dir); - } - } else { - gameObject.setDirection(archetype.getDirection()); - } - gameObject.setObjectFace(); - - // we look for 'type' in the ArchText. In future maybe type should get - // a separate text field - if (gameObject.getAttributeString("type", false).length() > 0) { - gameObject.setArchTypNr(gameObject.getAttributeInt("type", false)); // specified type - } - - gameObject.updateEditType(gameObject.getMapSquare().getMapModel().getMapControl().getActiveEditType()); - - mapSquare.getMapModel().endTransaction(); - } - - /** Create the arch panel entry of the lower window. */ - private JPanel createArchPanel() { - final JPanel panel = new JPanel(); - final GridBagLayout gridbag = new GridBagLayout(); - final GridBagConstraints gbc = new GridBagConstraints(); - - panel.setLayout(gridbag); - gbc.fill = GridBagConstraints.BOTH; - gbc.weightx = 1.0; - gbc.weighty = 0; - gbc.anchor = GridBagConstraints.NORTHWEST; - gbc.insets = new Insets(4, 4, 0, 0); - - archNameField.setText(""); - archNameField.setForeground(Color.blue); - gbc.gridx = 0; - gbc.gridy = 0; - gbc.gridwidth = 1; - gbc.gridheight = 1; - gridbag.setConstraints(archNameField, gbc); - panel.add(archNameField); - - archFaceText.setText(""); - gbc.gridx = 0; - gbc.gridy = 1; - gbc.gridwidth = 1; - gbc.gridheight = 1; - gridbag.setConstraints(archFaceText, gbc); - panel.add(archFaceText); - - archTypeText.setText(""); - gbc.gridx = 0; - gbc.gridy = 2; - gbc.gridwidth = 1; - gbc.gridheight = 1; - gridbag.setConstraints(archTypeText, gbc); - panel.add(archTypeText); - - archMapPos.setText(""); - gbc.gridx = 0; - gbc.gridy = 3; - gbc.gridwidth = 1; - gbc.gridheight = 1; - gridbag.setConstraints(archMapPos, gbc); - panel.add(archMapPos); - - gbc.gridx = 1; - gbc.gridy = 0; - gbc.gridwidth = 1; - gbc.gridheight = 5; - gbc.weightx = 0.0; - panel.add(createDirPanel(), gbc); - - return panel; - } - - private JPanel createDirPanel() { - final JPanel dirPanel = new JPanel(new GridBagLayout()); - final GridBagConstraints gbc = new GridBagConstraints(); - gbc.fill = GridBagConstraints.BOTH; - gbc.anchor = GridBagConstraints.CENTER; - gbc.insets = new Insets(2, 2, 2, 2); - - createButton(7, dirPanel, gbc, 0, 0); - createButton(8, dirPanel, gbc, 1, 0); - createButton(1, dirPanel, gbc, 2, 0); - createButton(6, dirPanel, gbc, 0, 1); - createButton(0, dirPanel, gbc, 1, 1); - createButton(2, dirPanel, gbc, 2, 1); - createButton(5, dirPanel, gbc, 0, 2); - createButton(4, dirPanel, gbc, 1, 2); - createButton(3, dirPanel, gbc, 2, 2); - - return dirPanel; - } - - private void applyDirectionChanges(final G gameObject, final int dir) { - gameObjectTextEditor.applyDirectionChanges(dir, gameObject.getArchetype().getDirection()); - applyArchPanelChanges(gameObject); - setSelectedGameObject(gameObject); - } - - /** - * Action proxy for direction. - * @param direction Direction number - */ - private void direction(final int direction) { - applyDirectionChanges(selectedGameObject, direction); - } - - /** Action method for direction. */ - public void direction0() { - direction(0); - } - - /** Action method for direction. */ - public void direction1() { - direction(1); - } - - /** Action method for direction. */ - public void direction2() { - direction(2); - } - - /** Action method for direction. */ - public void direction3() { - direction(3); - } - - /** Action method for direction. */ - public void direction4() { - direction(4); - } - - /** Action method for direction. */ - public void direction5() { - direction(5); - } - - /** Action method for direction. */ - public void direction6() { - direction(6); - } - - /** Action method for direction. */ - public void direction7() { - direction(7); - } - - /** Action method for direction. */ - public void direction8() { - direction(8); - } - - /** - * Create a direction button. - * @param direction Direction for button - * @param panel Panel to add button to - * @param gbc GridBagConstraints to modify - * @param x x position of button - * @param y y position of button - */ - private void createButton(final int direction, final JPanel panel, final GridBagConstraints gbc, final int x, final int y) { - final JToggleButton button = new JToggleButton(ACTION_FACTORY.createAction(true, "direction" + direction, this)); - directionButtonGroup.add(button); - button.setFocusable(false); - button.setEnabled(false); - gbc.gridx = x; - gbc.gridy = y; - panel.add(button, gbc); - directionButtons[direction] = button; - } - - private JPanel createButtonPanel() { - final JPanel buttonPanel = new JPanel(); - buttonPanel.add(new JButton(aMapArchApply)); - buttonPanel.add(new JButton(aMapArchAddInv)); - buttonPanel.add(new JButton(aMapArchAttrib)); - return buttonPanel; - } - - public void appExitNotify() { - prefs.putInt(MAPARCHPANEL_LOCATION_KEY, splitPane.getDividerLocation()); - } - - /** - * Refresh the "Arch" tab in the Game Object Attributes Panel. - * @param gameObject The game object to set the contents from. - */ - private void refreshArchTab(final G gameObject) { - // tab color - panelDesktop.setForegroundAt(0, gameObject == null ? Color.black : Color.blue); - - // archNameField - if (gameObject == null) { - archNameField.setForeground(Color.black); - archNameField.setText(""); - } else { - final String objName = gameObject.getObjName(); - if (objName != null) { - archNameField.setForeground(Color.blue); - archNameField.setText(objName); - } else { - archNameField.setForeground(Color.black); - final String archObjName = gameObject.getArchetype().getObjName(); - archNameField.setText(archObjName != null ? archObjName : gameObject.getArchetypeName()); - } - } - - // archFaceText - if (gameObject == null) { - archFaceText.setText("Image:"); - } else { - final StringBuilder faceText = new StringBuilder("Image: "); - appendFaceSource(faceText, gameObject); - archFaceText.setText(faceText.toString()); - } - - // archTypeText - if (gameObject == null) { - archTypeText.setText("Type:"); - } else { - final StringBuilder typeText = new StringBuilder("Type: "); - final ArchetypeType archetypeType = archetypeTypeSet.getArchetypeType(gameObject.getArchetype()); - typeText.append(archetypeType.getTypeName()); - typeText.append(" (").append(archetypeType.getTypeNo()).append(')'); - typeText.append(" [").append(gameObject.getArchetypeName()).append(']'); - if (gameObject.isMulti()) { - typeText.append(" [").append(gameObject.getSizeX()).append('x').append(gameObject.getSizeY()).append(']'); - } else { - typeText.append(" [single]"); - } - archTypeText.setText(typeText.toString()); - } - - // archMapPos - if (gameObject == null) { - archMapPos.setText("Status: "); - } else { - final StringBuilder specialText = new StringBuilder("Status:"); - if (!gameObject.isInContainer()) { - specialText.append(" (map: ").append(gameObject.getMapX()).append(", ").append(gameObject.getMapY()).append(')'); - } - if (gameObject.isScripted()) { - specialText.append(" (script)"); - } - if (gameObject.getMsgText() != null || gameObject.getArchetype().getMsgText() != null) { - specialText.append(" (msg)"); - } - final int invObjects = gameObject.countInvObjects(); - if (invObjects > 0) { - specialText.append(" (inv: ").append(invObjects).append(')'); - } - if (gameObject.isInContainer()) { - final G cont = (G) gameObject.getContainer(); - specialText.append(" (env: ").append(cont.getArchetypeName()).append(')'); - } - archMapPos.setText(specialText.toString()); - } - - // directions - for (final JToggleButton button : directionButtons) { - button.setBackground(null); - } - final boolean enableDirButtons = gameObject != null && gameObject.usesDirection(); - for (final JToggleButton button : directionButtons) { - button.setEnabled(enableDirButtons); - } - final int direction = enableDirButtons ? gameObject.getDirection() : 0; - directionButtons[direction < directionButtons.length ? direction : 0].setSelected(true); - } - - // calculate default value in case there is no settings file - private static int getMapArchPanelLocation() { - final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - return (int) (0.49 * screen.getWidth()); - } - - private JPanel createConnectionPanel() { - final ConnectionControl<G, A, R, V> connectionControl = new ConnectionControl<G, A, R, V>(mapManager); - return connectionControl.getView(); - } - - private JPanel createMonsterPanel(@NotNull final GameObjectMatcher monsterMatcher) { - final MonsterControl<G, A, R, V> monsterControl = new MonsterControl<G, A, R, V>(mapManager, monsterMatcher); - return monsterControl.getView(); - } - - protected abstract void appendFaceSource(@NotNull final StringBuilder sb, @NotNull final G gameObject); - -} // class GameObjectAttributesPanel Modified: trunk/src/app/net/sf/gridarta/gui/MainView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-08-05 04:39:30 UTC (rev 4760) +++ trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-08-05 19:19:39 UTC (rev 4761) @@ -49,6 +49,7 @@ import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gameobject.match.GameObjectMatchers; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesPanel; import net.sf.gridarta.gui.map.MapFileActions; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; Copied: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesPanel.java (from rev 4758, trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesPanel.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesPanel.java 2008-08-05 19:19:39 UTC (rev 4761) @@ -0,0 +1,1067 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.gameobjectattributespanel; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.GridLayout; +import java.awt.Insets; +import java.awt.Toolkit; +import java.util.prefs.Preferences; +import javax.swing.Action; +import javax.swing.ButtonGroup; +import javax.swing.DefaultListModel; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTabbedPane; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.JToggleButton; +import javax.swing.ScrollPaneConstants; +import javax.swing.SwingConstants; +import javax.swing.border.EtchedBorder; +import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; +import net.sf.gridarta.MapManagerListener; +import net.sf.gridarta.archtype.ArchetypeType; +import net.sf.gridarta.archtype.ArchetypeTypeSet; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gameobject.anim.AnimationObjects; +import net.sf.gridarta.gameobject.match.GameObjectMatcher; +import net.sf.gridarta.gui.ErrorListView; +import net.sf.gridarta.gui.GSplitPane; +import net.sf.gridarta.gui.connectionview.ConnectionControl; +import net.sf.gridarta.gui.connectionview.LockedItemsControl; +import net.sf.gridarta.gui.connectionview.MonsterControl; +import net.sf.gridarta.gui.gameobjecttexteditor.GameObjectTextEditor; +import net.sf.gridarta.gui.map.MapView; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.objectchooser.ObjectChooser; +import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; +import net.sf.gridarta.gui.selectedsquare.SelectedSquareListener; +import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.map.MapModel; +import net.sf.gridarta.map.MapModelEvent; +import net.sf.gridarta.map.MapModelListener; +import net.sf.gridarta.map.MapSquare; +import net.sf.japi.swing.ActionFactory; +import net.sf.japi.swing.ActionMethod; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Common base class for the panel that allows users to edit a GameObject's + * attributes. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public abstract class GameObjectAttributesPanel<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> extends JPanel { + + // constants for the 'task' parameter in editScriptWanted() + public static final int SCRIPT_OPEN = 0; + + public static final int SCRIPT_EDIT_PATH = 1; + + public static final int SCRIPT_REMOVE = 2; + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); + + private final Action aScriptAddNew = ACTION_FACTORY.createAction(false, "scriptAddNew", this); + + private final Action aScriptEditData = ACTION_FACTORY.createAction(false, "scriptEditData", this); + + private final Action aScriptEdit = ACTION_FACTORY.createAction(false, "scriptEdit", this); + + private final Action aScriptRemove = ACTION_FACTORY.createAction(false, "scriptRemove", this); + + /** The label that displays the current animation name. */ + private final JLabel archAnimText = new JLabel(); + + /** The Panel that displays animation information. */ + private final JPanel animationPanel = createAnimationPanel(); + + /** The Panel that displays scripting information. */ + private final JPanel scriptPanel = createScriptPanel(); + + /** The MainControl to use, e.g. for accessing AnimationObjects. */ + private final MainControl<G, A, R, V> mainControl; + + /** + * The object chooser instance. + */ + @NotNull + private final ObjectChooser<G, A, R> objectChooser; + + /** The archetype type set. */ + @NotNull + private final ArchetypeTypeSet<G, A, R> archetypeTypeSet; + + /** The map manager. */ + private final MapManager<G, A, R, V> mapManager; + + /** The animtation objects instance to use. */ + @NotNull + private final AnimationObjects<?> animationObjects; + + /** + * The parent frame for dialog boxes. + */ + @NotNull + private final Frame parent; + + /** The tabs of this GameObjectAttributesPanel. */ + private final JTabbedPane panelDesktop = new JTabbedPane(SwingConstants.TOP); + + /** The selected game object. */ + private G selectedGameObject = null; + + /** Last known active map. This map has {@link #mapModelListener} attached. */ + @Nullable + private MapControl<G, A, R, V> currentMap; + + /** Arch text field. */ + private final JTextArea archTextArea = new JTextArea(4, 25); + + private JList eventList; + + /** Preferences. */ + private static final Preferences prefs = Preferences.userNodeForPackage(MainControl.class); + + private static final String MAPARCHPANEL_LOCATION_KEY = "MainWindowMapArchPanel.dividerLocation"; + + /** + * The buttons for the direction panel. + * @see #directionButtonGroup + */ + private final JToggleButton[] directionButtons = new JToggleButton[9]; + + /** + * The ButtonGroup for the direction buttons. + * @see #directionButtons + */ + private final ButtonGroup directionButtonGroup = new ButtonGroup(); + + private final GSplitPane splitPane; + + /** The {@link ErrorListView} holding the error information. */ + private final ErrorListView<G, A, R, V> errorListView; + + /** Arch name field. */ + private final JTextField archNameField = new JTextField(14); + + private final JLabel archMapPos = new JLabel(); + + private final JLabel archFaceText = new JLabel(); + + private final JLabel archTypeText = new JLabel(); + + private final JPanel mapArchPanel = new JPanel(); + + ... [truncated message content] |
From: <aki...@us...> - 2008-08-05 19:22:00
|
Revision: 4762 http://gridarta.svn.sourceforge.net/gridarta/?rev=4762&view=rev Author: akirschbaum Date: 2008-08-05 19:22:03 +0000 (Tue, 05 Aug 2008) Log Message: ----------- Remove empty packages. Removed Paths: ------------- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/ trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-08-05 19:37:29
|
Revision: 4763 http://gridarta.svn.sourceforge.net/gridarta/?rev=4763&view=rev Author: akirschbaum Date: 2008-08-05 19:37:23 +0000 (Tue, 05 Aug 2008) Log Message: ----------- Implement new view for archetype chooser: "Display icons only". Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/action.properties trunk/daimonin/ChangeLog trunk/daimonin/src/daieditor/action.properties trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserView.java trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeNameCellRenderer.java trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypePanel.java trunk/src/app/net/sf/gridarta/gui/archetypechooser/DisplayMode.java trunk/src/app/net/sf/gridarta/gui/archetypechooser/DisplayNameCellRenderer.java trunk/src/app/net/sf/gridarta/messages.properties trunk/src/app/net/sf/gridarta/messages_de.properties trunk/src/app/net/sf/gridarta/messages_fr.properties trunk/src/app/net/sf/gridarta/messages_sv.properties Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeIconCellRenderer.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-08-05 19:22:03 UTC (rev 4762) +++ trunk/crossfire/ChangeLog 2008-08-05 19:37:23 UTC (rev 4763) @@ -1,3 +1,7 @@ +2008-08-05 Andreas Kirschbaum + + * Implement new view for archetype chooser: "Display icons only". + 2008-07-24 Andreas Kirschbaum * Fix #1961165 (Fields too short). Modified: trunk/crossfire/src/cfeditor/action.properties =================================================================== --- trunk/crossfire/src/cfeditor/action.properties 2008-08-05 19:22:03 UTC (rev 4762) +++ trunk/crossfire/src/cfeditor/action.properties 2008-08-05 19:37:23 UTC (rev 4763) @@ -30,7 +30,7 @@ file.menu=createNew open recent close - save saveAs saveAll revert createImage - options - exit edit.menu=undo redo - clear cut copy paste - shift - replace fillAbove fillBelow randFillAbove randFillBelow floodfill - selectAll map.menu=autoJoin - enterExit enterNorthMap enterEastMap enterSouthMap enterWestMap tileShow - mapCreateView mapProperties shrinkMapSize -archetypes.menu=displayObjectNames findArchetypes +archetypes.menu=displayGameObjectNames displayArchetypeNames displayIconsOnly - findArchetypes #pickmaps.menu: See gridarta resources.menu=collectArches - viewTreasurelists tools.menu=newScript editScript - validateMap - zoom gc Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-08-05 19:22:03 UTC (rev 4762) +++ trunk/daimonin/ChangeLog 2008-08-05 19:37:23 UTC (rev 4763) @@ -1,3 +1,7 @@ +2008-08-05 Andreas Kirschbaum + + * Implement new view for archetype chooser: "Display icons only". + 2008-07-23 Andreas Kirschbaum * Fix map validator error messages: include actual parameter Modified: trunk/daimonin/src/daieditor/action.properties =================================================================== --- trunk/daimonin/src/daieditor/action.properties 2008-08-05 19:22:03 UTC (rev 4762) +++ trunk/daimonin/src/daieditor/action.properties 2008-08-05 19:37:23 UTC (rev 4763) @@ -30,7 +30,7 @@ file.menu=createNew open recent close - save saveAs saveAll revert createImage - options - exit edit.menu=undo redo - clear cut copy paste - shift - replace fillAbove fillBelow randFillAbove randFillBelow floodfill - selectAll map.menu=autoJoin - enterExit enterNorthMap enterEastMap enterSouthMap enterWestMap enterNorthEastMap enterSouthEastMap enterSouthWestMap enterNorthWestMap - mapCreateView mapProperties shrinkMapSize -archetypes.menu=displayObjectNames findArchetypes +archetypes.menu=displayGameObjectNames displayArchetypeNames displayIconsOnly - findArchetypes #pickmaps.menu: See gridarta resources.menu=collectArches collectSpells - reloadFaces - viewTreasurelists tools.menu=newScript editScript - controlServer controlClient - validateMap cleanCompletelyBlockedSquares - zoom gc Modified: trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserView.java 2008-08-05 19:22:03 UTC (rev 4762) +++ trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserView.java 2008-08-05 19:37:23 UTC (rev 4763) @@ -24,8 +24,10 @@ import java.util.List; import java.util.prefs.Preferences; import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; import javax.swing.JPanel; import javax.swing.JTabbedPane; +import javax.swing.JToggleButton; import javax.swing.SwingConstants; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -36,7 +38,6 @@ import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.ToggleAction; import org.jetbrains.annotations.NotNull; /** @@ -48,7 +49,7 @@ /** * The key for saving the display mode selection. */ - private static final String DISPLAY_OBJECT_NAMES = "archetypesDisplayObjectNames"; + private static final String DISPLAY_MODE_KEY = "archetypeChooserDisplayMode"; /** * The serial version UID. @@ -67,10 +68,18 @@ @NotNull private final List<ArchetypeChooserViewListener<G, A, R>> listeners = new ArrayList<ArchetypeChooserViewListener<G, A, R>>(); - /** Action for "display object names". */ + /** The button for "display game object names". */ @NotNull - private final ToggleAction aDisplayObjectNames = (ToggleAction) ACTION_FACTORY.createToggle(true, "displayObjectNames", this); + private final JToggleButton buttonDisplayGameObjectNames = new JToggleButton(ACTION_FACTORY.createAction(true, "displayGameObjectNames", this)); + /** The button for "display archetype names". */ + @NotNull + private final JToggleButton buttonDisplayArchetypeNames = new JToggleButton(ACTION_FACTORY.createAction(true, "displayArchetypeNames", this)); + + /** The button for "display icons only". */ + @NotNull + private final JToggleButton buttonDisplayIconsOnly = new JToggleButton(ACTION_FACTORY.createAction(true, "displayIconsOnly", this)); + /** * The main control. */ @@ -106,6 +115,12 @@ private final DisplayMode<R> displayModeArchetypeNames; /** + * The list cell renderer displaying archetype icons. + */ + @NotNull + private final DisplayMode<R> displayModeIconsOnly; + + /** * The change listener attached to {@link #tabDesktop}. */ private final ChangeListener changeListener = new ChangeListener() { @@ -130,7 +145,27 @@ this.archetypeChooserModel = archetypeChooserModel; displayModeGameObjectNames = new DisplayNameCellRenderer<R>(archetypeChooserModel.getArchetypeSet()); displayModeArchetypeNames = new ArchetypeNameCellRenderer<R>(archetypeChooserModel.getArchetypeSet()); - setDisplayObjectNames(prefs.getBoolean(DISPLAY_OBJECT_NAMES, false)); + displayModeIconsOnly = new ArchetypeIconCellRenderer<R>(archetypeChooserModel.getArchetypeSet()); + final ButtonGroup buttonGroup = new ButtonGroup(); + buttonGroup.add(buttonDisplayGameObjectNames); + buttonGroup.add(buttonDisplayArchetypeNames); + buttonGroup.add(buttonDisplayIconsOnly); + final int prefsDisplayMode = prefs.getInt(DISPLAY_MODE_KEY, 0); + switch (prefsDisplayMode) { + case 0: + default: + displayMode = displayModeGameObjectNames; + break; + + case 1: + displayMode = displayModeArchetypeNames; + break; + + case 2: + displayMode = displayModeIconsOnly; + break; + } + fireDisplayObjectNamesChangedEvent(); tabDesktop.setBorder(BorderFactory.createEmptyBorder(CommonConstants.SPACE_PICKARCH_TOP, 0, 0, 0)); add(tabDesktop); if (createDirectionPane) { @@ -196,6 +231,13 @@ * Notifies all listeners that the display mode has changed. */ private void fireDisplayObjectNamesChangedEvent() { + if (displayMode == displayModeGameObjectNames) { + prefs.putInt(DISPLAY_MODE_KEY, 0); + } else if (displayMode == displayModeArchetypeNames) { + prefs.putInt(DISPLAY_MODE_KEY, 1); + } if (displayMode == displayModeIconsOnly) { + prefs.putInt(DISPLAY_MODE_KEY, 2); + } updateActions(); for (final ArchetypeChooserViewListener<G, A, R> listener : listeners) { listener.displayModeChanged(displayMode); @@ -206,36 +248,46 @@ * Returns the current display mode. * @return the current display mode */ + @NotNull public DisplayMode<R> getDisplayMode() { return displayMode; } /** - * Action method for "display object names". - * @return <code>true</code> if object names are shown, or - * <code>false</code> if archetype names are shown. + * Updates the display mode. + * @param displayMode the new display mode */ - public boolean isDisplayObjectNames() { - return displayMode == displayModeGameObjectNames; + private void setDisplayMode(@NotNull final DisplayMode<R> displayMode) { + if (this.displayMode == displayMode) { + return; + } + + this.displayMode = displayMode; + fireDisplayObjectNamesChangedEvent(); } /** - * Sets whether object or archetype names are shown. - * @param displayObjectNames the new setting - * @see #getDisplayMode() + * Sets whether game object names are shown. */ - public void setDisplayObjectNames(final boolean displayObjectNames) { - final DisplayMode<R> newDisplayMode = displayObjectNames ? displayModeGameObjectNames : displayModeArchetypeNames; - if (displayMode == newDisplayMode) { - return; - } + public void displayGameObjectNames() { + setDisplayMode(displayModeGameObjectNames); + } - displayMode = newDisplayMode; - prefs.putBoolean(DISPLAY_OBJECT_NAMES, displayObjectNames); - fireDisplayObjectNamesChangedEvent(); + /** + * Sets whether archetype names are shown. + */ + public void displayArchetypeNames() { + setDisplayMode(displayModeArchetypeNames); } /** + * Sets whether icons are shown. + */ + public void displayIconsOnly() { + setDisplayMode(displayModeIconsOnly); + } + + /** * Adds a listener to be notified of events. * @param listener the listener to add */ @@ -255,7 +307,13 @@ * Update the actions' state. */ private void updateActions() { - aDisplayObjectNames.setSelected(displayMode == displayModeGameObjectNames); + if (displayMode == displayModeGameObjectNames) { + buttonDisplayGameObjectNames.setSelected(true); + } else if (displayMode == displayModeArchetypeNames) { + buttonDisplayArchetypeNames.setSelected(true); + } else if (displayMode == displayModeIconsOnly) { + buttonDisplayIconsOnly.setSelected(true); + } } } // class ArchetypeChooserView Added: trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeIconCellRenderer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeIconCellRenderer.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeIconCellRenderer.java 2008-08-05 19:37:23 UTC (rev 4763) @@ -0,0 +1,72 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.archetypechooser; + +import java.awt.Component; +import javax.swing.DefaultListCellRenderer; +import javax.swing.JList; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.ArchetypeSet; +import org.jetbrains.annotations.NotNull; + +/** + * A {@link DefaultListCellRenderer} showing archetypes as images only. + * @author Andreas Kirschbaum + */ +public final class ArchetypeIconCellRenderer<R extends Archetype<?, ?, R>> extends DisplayMode<R> { + + /** Serial Version UID. */ + private static final long serialVersionUID = 1L; + + /** The archetype set for looking up faces. */ + @NotNull + private final ArchetypeSet<?, ?, R> archetypeSet; + + /** + * Creates a new instance. + * @param archetypeSet the archetype set for looking up faces + */ + public ArchetypeIconCellRenderer(@NotNull final ArchetypeSet<?, ?, R> archetypeSet) { + this.archetypeSet = archetypeSet; + } + + /** {@inheritDoc} */ + @Override + public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + + final R archetype = (R) value; + setIcon(archetypeSet.getFace(archetype)); + setText(""); + return this; + } + + /** {@inheritDoc} */ + public int compare(final R o1, final R o2) { + return o1.getArchetypeName().compareToIgnoreCase(o2.getArchetypeName()); + } + + /** {@inheritDoc} */ + @Override + public int getLayoutOrientation() { + return JList.HORIZONTAL_WRAP; + } + +} // class ArchetypeIconCellRenderer Property changes on: trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeIconCellRenderer.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeNameCellRenderer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeNameCellRenderer.java 2008-08-05 19:22:03 UTC (rev 4762) +++ trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeNameCellRenderer.java 2008-08-05 19:37:23 UTC (rev 4763) @@ -64,4 +64,10 @@ return o1.getArchetypeName().compareToIgnoreCase(o2.getArchetypeName()); } + /** {@inheritDoc} */ + @Override + public int getLayoutOrientation() { + return JList.VERTICAL; + } + } // class ArchetypeNameCellRenderer Modified: trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypePanel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypePanel.java 2008-08-05 19:22:03 UTC (rev 4762) +++ trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypePanel.java 2008-08-05 19:37:23 UTC (rev 4763) @@ -152,6 +152,8 @@ private void updateCellRenderer(@NotNull final DisplayMode<R> displayMode) { this.displayMode = displayMode; archList.setCellRenderer(displayMode); + archList.setLayoutOrientation(displayMode.getLayoutOrientation()); + archList.setVisibleRowCount(-1); final Object selectedValue = archList.getSelectedValue(); showArchList(); if (selectedValue != null) { Modified: trunk/src/app/net/sf/gridarta/gui/archetypechooser/DisplayMode.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/archetypechooser/DisplayMode.java 2008-08-05 19:22:03 UTC (rev 4762) +++ trunk/src/app/net/sf/gridarta/gui/archetypechooser/DisplayMode.java 2008-08-05 19:37:23 UTC (rev 4763) @@ -42,4 +42,11 @@ protected DisplayMode() { } + /** + * Returns the layout orientation. See {@link + * javax.swing.JList#getLayoutOrientation}. + * @return the layout orientation + */ + public abstract int getLayoutOrientation(); + } // class DisplayMode Modified: trunk/src/app/net/sf/gridarta/gui/archetypechooser/DisplayNameCellRenderer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/archetypechooser/DisplayNameCellRenderer.java 2008-08-05 19:22:03 UTC (rev 4762) +++ trunk/src/app/net/sf/gridarta/gui/archetypechooser/DisplayNameCellRenderer.java 2008-08-05 19:37:23 UTC (rev 4763) @@ -69,4 +69,10 @@ return o1.getArchetypeName().compareToIgnoreCase(o2.getArchetypeName()); } + /** {@inheritDoc} */ + @Override + public int getLayoutOrientation() { + return JList.VERTICAL; + } + } // class DisplayNameCellRenderer Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2008-08-05 19:22:03 UTC (rev 4762) +++ trunk/src/app/net/sf/gridarta/messages.properties 2008-08-05 19:37:23 UTC (rev 4763) @@ -674,7 +674,7 @@ ################### # Preferences file prefs.archDirectory=Archetype directory. -prefs.archetypesDisplayObjectNames=Whether "display object names" is selected. +prefs.archetypeChooserDisplayMode=The display mode of the archetype chooser: 0=game object names, 1=archetype names, 2=icons only. prefs.autogenPreviews=If set, automatically generate map preview images. prefs.autojoin=Whether autojoining is enabled. prefs.autoValidate=Whether the map validator is run automatically after each change. @@ -925,7 +925,9 @@ ############ # Archetypes -displayObjectNames.text=Display object names +displayGameObjectNames.text=Display game object names +displayArchetypeNames.text=Display archetype names +displayIconsOnly.text=Display icons only findArchetypes.text=Find archetype findArchetypes.accel=ctrl alt pressed A Modified: trunk/src/app/net/sf/gridarta/messages_de.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_de.properties 2008-08-05 19:22:03 UTC (rev 4762) +++ trunk/src/app/net/sf/gridarta/messages_de.properties 2008-08-05 19:37:23 UTC (rev 4763) @@ -791,7 +791,9 @@ ############ # Archetypes -displayObjectNames.text=Objektnamen anzeigen +displayGameObjectNames.text=Objektnamen anzeigen +displayArchetypeNames.text=Archetypnamen anzeigen +displayIconsOnly.text=Bilder anzeigen findArchetypes.text=Archetypen finden Modified: trunk/src/app/net/sf/gridarta/messages_fr.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-08-05 19:22:03 UTC (rev 4762) +++ trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-08-05 19:37:23 UTC (rev 4763) @@ -790,7 +790,9 @@ ############ # Archetypes -#displayObjectNames.text= +#displayGameObjectNames.text= +#displayArchetypeNames.text= +#displayIconsOnly.text= #findArchetypes.text= Modified: trunk/src/app/net/sf/gridarta/messages_sv.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-08-05 19:22:03 UTC (rev 4762) +++ trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-08-05 19:37:23 UTC (rev 4763) @@ -794,7 +794,9 @@ ############ # Archetypes -#displayObjectNames.text= +#displayGameObjectNames.text= +#displayArchetypeNames.text= +#displayIconsOnly.text= #findArchetypes.text= This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-08-05 22:25:29
|
Revision: 4766 http://gridarta.svn.sourceforge.net/gridarta/?rev=4766&view=rev Author: akirschbaum Date: 2008-08-05 22:25:32 +0000 (Tue, 05 Aug 2008) Log Message: ----------- Split GameObjectAttributesPanel into separate classes for each tab. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesPanel.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Added Paths: ----------- trunk/crossfire/src/cfeditor/gui/ArchTab.java trunk/daimonin/src/daieditor/gui/ArchTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AbstractGameObjectAttributesTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AnimationTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ConnectionsTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesTabListener.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/LockedItemsTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MonstersTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MsgTextTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ScriptTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/WarningsTab.java Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-08-05 20:02:41 UTC (rev 4765) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-08-05 22:25:32 UTC (rev 4766) @@ -27,7 +27,7 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.scripts.AbstractScriptArchEditor; -import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesPanel; +import net.sf.gridarta.gui.gameobjectattributespanel.ScriptTab; import net.sf.gridarta.utils.StringUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -248,7 +248,7 @@ /** {@inheritDoc} */ @Override - public void modifyEventScript(final int eventType, final int task, @NotNull final JList eventList, @NotNull final GameObjectAttributesPanel<GameObject, MapArchObject, Archetype, ?> mapanel, @NotNull final MainControl<?, ?, ?, ?> mainControl, @NotNull final Frame parent) { + public void modifyEventScript(final int eventType, final int task, @NotNull final JList eventList, @NotNull final ScriptTab<GameObject, MapArchObject, Archetype> mapanel, @NotNull final MainControl<?, ?, ?, ?> mainControl, @NotNull final Frame parent) { scriptArchData.modifyEventScript(eventType, task, eventList, mainControl, parent); if (scriptArchData.isEmpty()) { @@ -258,7 +258,7 @@ /** {@inheritDoc} */ @Override - public void addEventScript(@NotNull final JList eventList, @NotNull final GameObjectAttributesPanel<GameObject, MapArchObject, Archetype, ?> mapanel, @NotNull final Frame parent) { + public void addEventScript(@NotNull final JList eventList, @NotNull final ScriptTab<GameObject, MapArchObject, Archetype> mapanel, @NotNull final Frame parent) { AbstractScriptArchEditor.addEventScript(this, scriptArchData, parent); if (!scriptArchData.isEmpty()) { Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-08-05 20:02:41 UTC (rev 4765) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-08-05 22:25:32 UTC (rev 4766) @@ -29,7 +29,7 @@ import javax.swing.JOptionPane; import net.sf.gridarta.MainControl; import net.sf.gridarta.gameobject.scripts.ScriptedEventEditor; -import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesPanel; +import net.sf.gridarta.gui.gameobjectattributespanel.ScriptTab; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -139,11 +139,11 @@ if (oldEvent != null) { final ScriptedEvent event = new ScriptedEvent(oldEvent); // now decide what to do: - if (task == GameObjectAttributesPanel.SCRIPT_OPEN) { + if (task == ScriptTab.SCRIPT_OPEN) { ScriptedEventEditor.openScript(mainControl, event.getScriptPath(), parent); - } else if (task == GameObjectAttributesPanel.SCRIPT_EDIT_PATH) { + } else if (task == ScriptTab.SCRIPT_EDIT_PATH) { ScriptedEventEditor.editParameters(event, parent); - } else if (task == GameObjectAttributesPanel.SCRIPT_REMOVE) { + } else if (task == ScriptTab.SCRIPT_REMOVE) { // first ask for confirmation if (JOptionPane.showConfirmDialog(panelList, "Are you sure you want to remove this \"" + ScriptArchUtils.typeName(event.getEventType()) + "\" event which is\n" + "linked to the script: '" + event.getScriptPath() + "'?\n" + "(The script file itself is not going to be deleted)", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { // remove this event from the GameObject Added: trunk/crossfire/src/cfeditor/gui/ArchTab.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ArchTab.java (rev 0) +++ trunk/crossfire/src/cfeditor/gui/ArchTab.java 2008-08-05 22:25:32 UTC (rev 4766) @@ -0,0 +1,50 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package cfeditor.gui; + +import cfeditor.gameobject.Archetype; +import cfeditor.gameobject.GameObject; +import cfeditor.map.MapArchObject; +import net.sf.gridarta.archtype.ArchetypeTypeSet; +import org.jetbrains.annotations.NotNull; + +public class ArchTab extends net.sf.gridarta.gui.gameobjectattributespanel.ArchTab<GameObject, MapArchObject, Archetype> { + + /** + * Creates a new instance. + * @param archetypeTypeSet the archetype type set + */ + public ArchTab(@NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet) { + super(archetypeTypeSet); + } + + /** {@inheritDoc} */ + @Override + protected void appendFaceSource(@NotNull final StringBuilder sb, @NotNull final GameObject gameObject) { + final String faceName = gameObject.getFaceName(); + if (faceName != null) { + sb.append(faceName.length() == 0 ? ">no face<" : faceName); + } else { + final String archFaceName = gameObject.getArchetype().getFaceName(); + sb.append(archFaceName == null ? ">no face<" : archFaceName); + } + } + +} // class ArchTab Property changes on: trunk/crossfire/src/cfeditor/gui/ArchTab.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-08-05 20:02:41 UTC (rev 4765) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-08-05 22:25:32 UTC (rev 4766) @@ -30,6 +30,13 @@ import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.connectionview.LockedItemsControl; +import net.sf.gridarta.gui.gameobjectattributespanel.AnimationTab; +import net.sf.gridarta.gui.gameobjectattributespanel.ConnectionsTab; +import net.sf.gridarta.gui.gameobjectattributespanel.LockedItemsTab; +import net.sf.gridarta.gui.gameobjectattributespanel.MonstersTab; +import net.sf.gridarta.gui.gameobjectattributespanel.MsgTextTab; +import net.sf.gridarta.gui.gameobjectattributespanel.ScriptTab; +import net.sf.gridarta.gui.gameobjectattributespanel.WarningsTab; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; @@ -49,19 +56,15 @@ /* Build Panel */ public GameObjectAttributesPanel(@NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final Frame parent) { - super(mainControl, objectChooser, archetypeTypeSet, mapManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, parent); + super(mainControl, objectChooser, mapManager, selectedSquareControl); + addTab(new ArchTab(archetypeTypeSet)); + addTab(new MsgTextTab<GameObject, MapArchObject, Archetype>()); + addTab(new ScriptTab<GameObject, MapArchObject, Archetype>(parent, mainControl)); + addTab(new AnimationTab<GameObject, MapArchObject, Archetype>(animationObjects)); + addTab(new ConnectionsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager)); + addTab(new LockedItemsTab<GameObject, MapArchObject, Archetype>(lockedItemsControl)); + addTab(new MonstersTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, monsterMatcher)); + addTab(new WarningsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, selectedSquareView)); } - /** {@inheritDoc} */ - @Override - protected void appendFaceSource(@NotNull final StringBuilder sb, @NotNull final GameObject gameObject) { - final String faceName = gameObject.getFaceName(); - if (faceName != null) { - sb.append(faceName.length() == 0 ? ">no face<" : faceName); - } else { - final String archFaceName = gameObject.getArchetype().getFaceName(); - sb.append(archFaceName == null ? ">no face<" : archFaceName); - } - } - } // class GameObjectAttributesPanel Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-08-05 20:02:41 UTC (rev 4765) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-08-05 22:25:32 UTC (rev 4766) @@ -28,7 +28,7 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.scripts.AbstractScriptArchEditor; -import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesPanel; +import net.sf.gridarta.gui.gameobjectattributespanel.ScriptTab; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -393,7 +393,7 @@ /** {@inheritDoc} */ @Override - public void modifyEventScript(final int eventType, final int task, @NotNull final JList eventList, @NotNull final GameObjectAttributesPanel<GameObject, MapArchObject, Archetype, ?> mapanel, @NotNull final MainControl<?, ?, ?, ?> mainControl, @NotNull final Frame parent) { + public void modifyEventScript(final int eventType, final int task, @NotNull final JList eventList, @NotNull final ScriptTab<GameObject, MapArchObject, Archetype> mapanel, @NotNull final MainControl<?, ?, ?, ?> mainControl, @NotNull final Frame parent) { scriptArchData.modifyEventScript(eventType, task, eventList, mainControl, parent); if (scriptArchData.isEmpty()) { @@ -403,7 +403,7 @@ /** {@inheritDoc} */ @Override - public void addEventScript(@NotNull final JList eventList, @NotNull final GameObjectAttributesPanel<GameObject, MapArchObject, Archetype, ?> mapanel, @NotNull final Frame parent) { + public void addEventScript(@NotNull final JList eventList, @NotNull final ScriptTab<GameObject, MapArchObject, Archetype> mapanel, @NotNull final Frame parent) { AbstractScriptArchEditor.addEventScript(this, scriptArchData, parent); if (!scriptArchData.isEmpty()) { Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-08-05 20:02:41 UTC (rev 4765) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-08-05 22:25:32 UTC (rev 4766) @@ -29,7 +29,7 @@ import javax.swing.JOptionPane; import net.sf.gridarta.MainControl; import net.sf.gridarta.gameobject.scripts.ScriptedEventEditor; -import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesPanel; +import net.sf.gridarta.gui.gameobjectattributespanel.ScriptTab; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -138,11 +138,11 @@ if (oldEvent != null) { final ScriptedEvent event = new ScriptedEvent(oldEvent); // now decide what to do: - if (task == GameObjectAttributesPanel.SCRIPT_OPEN) { + if (task == ScriptTab.SCRIPT_OPEN) { ScriptedEventEditor.openScript(mainControl, event.getScriptPath(), parent); - } else if (task == GameObjectAttributesPanel.SCRIPT_EDIT_PATH) { + } else if (task == ScriptTab.SCRIPT_EDIT_PATH) { ScriptedEventEditor.editParameters(event, parent); - } else if (task == GameObjectAttributesPanel.SCRIPT_REMOVE) { + } else if (task == ScriptTab.SCRIPT_REMOVE) { // first ask for confirmation if (JOptionPane.showConfirmDialog(panelList, "Are you sure you want to remove this \"" + ScriptArchUtils.typeName(event.getEventType()) + "\" event which is\n" + "linked to the script: '" + event.getScriptPath() + "'?\n" + "(The script file itself is not going to be deleted)", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { // remove this event from the GameObject Added: trunk/daimonin/src/daieditor/gui/ArchTab.java =================================================================== --- trunk/daimonin/src/daieditor/gui/ArchTab.java (rev 0) +++ trunk/daimonin/src/daieditor/gui/ArchTab.java 2008-08-05 22:25:32 UTC (rev 4766) @@ -0,0 +1,72 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package daieditor.gui; + +import daieditor.gameobject.Archetype; +import daieditor.gameobject.GameObject; +import daieditor.map.MapArchObject; +import net.sf.gridarta.archtype.ArchetypeTypeSet; +import org.jetbrains.annotations.NotNull; + +public class ArchTab extends net.sf.gridarta.gui.gameobjectattributespanel.ArchTab<GameObject, MapArchObject, Archetype> { + + /** + * Creates a new instance. + * @param archetypeTypeSet the archetype type set + */ + public ArchTab(@NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet) { + super(archetypeTypeSet); + } + + /** {@inheritDoc} */ + @Override + protected void appendFaceSource(@NotNull final StringBuilder sb, @NotNull final GameObject gameObject) { + final String faceName = gameObject.getFaceName(); + if (faceName != null) { + final GameObject.FaceSource desc = gameObject.getFaceObjSource(); + sb.append(faceName).append(" ("); + switch (desc) { + case FACE_NOT_FOUND: + sb.append("face not found"); + break; + + case FACE: + sb.append("face"); + break; + + case ARCHETYPE_FACE: + sb.append("archetype face"); + break; + + case ANIM: + sb.append("anim"); + break; + + case ARCHETYPE_ANIM: + sb.append("archetype anim"); + break; + } + sb.append(')'); + } else { + sb.append(">no face<"); + } + } + +} // class ArchTab Property changes on: trunk/daimonin/src/daieditor/gui/ArchTab.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-08-05 20:02:41 UTC (rev 4765) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-08-05 22:25:32 UTC (rev 4766) @@ -30,6 +30,13 @@ import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.connectionview.LockedItemsControl; +import net.sf.gridarta.gui.gameobjectattributespanel.AnimationTab; +import net.sf.gridarta.gui.gameobjectattributespanel.ConnectionsTab; +import net.sf.gridarta.gui.gameobjectattributespanel.LockedItemsTab; +import net.sf.gridarta.gui.gameobjectattributespanel.MonstersTab; +import net.sf.gridarta.gui.gameobjectattributespanel.MsgTextTab; +import net.sf.gridarta.gui.gameobjectattributespanel.ScriptTab; +import net.sf.gridarta.gui.gameobjectattributespanel.WarningsTab; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; @@ -49,41 +56,15 @@ /* Build Panel */ public GameObjectAttributesPanel(@NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final Frame parent) { - super(mainControl, objectChooser, archetypeTypeSet, mapManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, parent); + super(mainControl, objectChooser, mapManager, selectedSquareControl); + addTab(new ArchTab(archetypeTypeSet)); + addTab(new MsgTextTab<GameObject, MapArchObject, Archetype>()); + addTab(new ScriptTab<GameObject, MapArchObject, Archetype>(parent, mainControl)); + addTab(new AnimationTab<GameObject, MapArchObject, Archetype>(animationObjects)); + addTab(new ConnectionsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager)); + addTab(new LockedItemsTab<GameObject, MapArchObject, Archetype>(lockedItemsControl)); + addTab(new MonstersTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, monsterMatcher)); + addTab(new WarningsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, selectedSquareView)); } - /** {@inheritDoc} */ - @Override - protected void appendFaceSource(@NotNull final StringBuilder sb, @NotNull final GameObject gameObject) { - final String faceName = gameObject.getFaceName(); - if (faceName != null) { - final GameObject.FaceSource desc = gameObject.getFaceObjSource(); - sb.append(faceName).append(" ("); - switch (desc) { - case FACE_NOT_FOUND: - sb.append("face not found"); - break; - - case FACE: - sb.append("face"); - break; - - case ARCHETYPE_FACE: - sb.append("archetype face"); - break; - - case ANIM: - sb.append("anim"); - break; - - case ARCHETYPE_ANIM: - sb.append("archetype anim"); - break; - } - sb.append(')'); - } else { - sb.append(">no face<"); - } - } - } // class GameObjectAttributesPanel Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-08-05 20:02:41 UTC (rev 4765) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-08-05 22:25:32 UTC (rev 4766) @@ -29,7 +29,7 @@ import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.match.GameObjectMatchers; import net.sf.gridarta.gui.GUIConstants; -import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesPanel; +import net.sf.gridarta.gui.gameobjectattributespanel.ScriptTab; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapSquare; import net.sf.gridarta.utils.StringUtils; @@ -1383,7 +1383,7 @@ * @param parent the parent frame for dialog boxes * @xxx this method knows things it should never know, it is evil! */ - public abstract void modifyEventScript(final int eventType, final int task, @NotNull final JList eventList, @NotNull final GameObjectAttributesPanel<G, A, R, ?> mapanel, @NotNull final MainControl<?, ?, ?, ?> mainControl, @NotNull final Frame parent); + public abstract void modifyEventScript(final int eventType, final int task, @NotNull final JList eventList, @NotNull final ScriptTab<G, A, R> mapanel, @NotNull final MainControl<?, ?, ?, ?> mainControl, @NotNull final Frame parent); /** * A popup is opened and the user can create a new scripting event which @@ -1393,7 +1393,7 @@ * @param mapanel the MapArchPanel * @param parent the parent frame for the editor */ - public abstract void addEventScript(@NotNull final JList eventList, @NotNull final GameObjectAttributesPanel<G, A, R, ?> mapanel, @NotNull final Frame parent); + public abstract void addEventScript(@NotNull final JList eventList, @NotNull final ScriptTab<G, A, R> mapanel, @NotNull final Frame parent); /** {@inheritDoc} */ public int getDirection() { Added: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AbstractGameObjectAttributesTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AbstractGameObjectAttributesTab.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AbstractGameObjectAttributesTab.java 2008-08-05 22:25:32 UTC (rev 4766) @@ -0,0 +1,93 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.gameobjectattributespanel; + +import java.awt.Color; +import java.util.ArrayList; +import java.util.List; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.map.MapArchObject; +import org.jetbrains.annotations.NotNull; + +/** + * Base class for {@link GameObjectAttributesTab} implementations. + * @author Andreas Kirschbaum + */ +public abstract class AbstractGameObjectAttributesTab<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements GameObjectAttributesTab<G, A, R> { + + /** + * The tab color for "default values". + */ + protected static final Color TAB_COLOR_DEFAULT = Color.BLACK; + + /** + * The tab color for "custom values". + */ + protected static final Color TAB_COLOR_CUSTOM = Color.BLUE; + + /** + * The tab color for "error values". + */ + protected static final Color TAB_COLOR_ERROR = Color.RED; + + /** + * The registered listeners. + */ + private final List<GameObjectAttributesTabListener<G, A, R>> listeners = new ArrayList<GameObjectAttributesTabListener<G, A, R>>(); + + /** + * The tab color. + */ + @NotNull + private Color tabColor = TAB_COLOR_DEFAULT; + + /** + * Sets the tab color. + * @param tabColor the tab color + */ + protected void setTabColor(@NotNull final Color tabColor) { + if (this.tabColor.equals(tabColor)) { + return; + } + + this.tabColor = tabColor; + for (final GameObjectAttributesTabListener<G, A, R> listener : listeners) { + listener.tabColorChanged(this, tabColor); + } + } + + /** {@inheritDoc} */ + public void addGameObjectAttributesTabListener(@NotNull final GameObjectAttributesTabListener<G, A, R> listener) { + listeners.add(listener); + } + + /** {@inheritDoc} */ + public void removeGameObjectAttributesTabListener(@NotNull final GameObjectAttributesTabListener<G, A, R> listener) { + listeners.add(listener); + } + + /** {@inheritDoc} */ + @NotNull + public Color getTabColor() { + return tabColor; + } + +} // class AbstractGameObjectAttributesTab Property changes on: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AbstractGameObjectAttributesTab.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AnimationTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AnimationTab.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AnimationTab.java 2008-08-05 22:25:32 UTC (rev 4766) @@ -0,0 +1,107 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.gameobjectattributespanel; + +import java.awt.BorderLayout; +import javax.swing.JLabel; +import javax.swing.JPanel; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gameobject.anim.AnimationObjects; +import net.sf.gridarta.map.MapArchObject; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The "Animation" tab in the game object attributes panel. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @author Andreas Kirschbaum + */ +public class AnimationTab<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractGameObjectAttributesTab<G, A, R> { + + /** The animtation objects instance to use. */ + @NotNull + private final AnimationObjects<?> animationObjects; + + /** The label that displays the current animation name. */ + private final JLabel archAnimText = new JLabel(); + + /** + * Creates a new instance. + * @param animationObjects the animation objects + */ + public AnimationTab(@NotNull final AnimationObjects<?> animationObjects) { + this.animationObjects = animationObjects; + } + + /** {@inheritDoc} */ + @NotNull + public String getName() { + return "Animation"; + } + + /** {@inheritDoc} */ + @NotNull + public JPanel getPanel() { + final JPanel panel = new JPanel(new BorderLayout()); + archAnimText.setText("Animation: "); + panel.add(archAnimText); + return panel; + } + + /** {@inheritDoc} */ + public void refresh(@Nullable final G gameObject) { + if (gameObject == null) { + setTabColor(TAB_COLOR_DEFAULT); + setAnimationName(null); + } else { + String animName = gameObject.getAnimName(); + if (animName == null) { + animName = gameObject.getArchetype().getAnimName(); + } + if (animName != null) { + final StringBuilder animText = new StringBuilder(animName); + if (!animationObjects.containsKey(animName)) { + setTabColor(TAB_COLOR_ERROR); + animText.append(" (** unknown animation **)"); + } else { + setTabColor(TAB_COLOR_CUSTOM); + } + setAnimationName(animText.toString()); + } else { + setTabColor(TAB_COLOR_DEFAULT); + setAnimationName(null); + } + } + } + + /** {@inheritDoc} */ + public void apply() { + } + + /** + * Sets the animation name. + * @param animationName Animation name + */ + private void setAnimationName(@Nullable final String animationName) { + archAnimText.setText("Animation: " + (animationName != null ? animationName : "")); + } + +} // class AnimationTab Property changes on: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AnimationTab.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java 2008-08-05 22:25:32 UTC (rev 4766) @@ -0,0 +1,308 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.gameobjectattributespanel; + +import java.awt.Color; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import javax.swing.ButtonGroup; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.JToggleButton; +import net.sf.gridarta.archtype.ArchetypeType; +import net.sf.gridarta.archtype.ArchetypeTypeSet; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.utils.StringUtils; +import net.sf.japi.swing.ActionFactory; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The "Arch" tab in the archetype chooser. It display information about the + * currently selected object. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @author Andreas Kirschbaum + */ +public abstract class ArchTab<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractGameObjectAttributesTab<G, A, R> { + + /** The action factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); + + /** + * The archetype type set. + */ + @NotNull + private final ArchetypeTypeSet<G, A, R> archetypeTypeSet; + + /** Game object name field. */ + private final JTextField archNameField = new JTextField(14); + + private final JLabel archFaceText = new JLabel(); + + private final JLabel archTypeText = new JLabel(); + + private final JLabel archMapPos = new JLabel(); + + /** + * The ButtonGroup for the direction buttons. + * @see #directionButtons + */ + private final ButtonGroup directionButtonGroup = new ButtonGroup(); + + /** + * The buttons for the direction panel. + * @see #directionButtonGroup + */ + private final JToggleButton[] directionButtons = new JToggleButton[9]; + + /** + * The displayed game object. + */ + @Nullable + private G selectedGameObject = null; + + /** + * Creates a new instance. + * @param archetypeTypeSet the archetype type set + */ + protected ArchTab(@NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet) { + this.archetypeTypeSet = archetypeTypeSet; + } + + /** {@inheritDoc} */ + @NotNull + public String getName() { + return "Arch"; + } + + /** {@inheritDoc} */ + @NotNull + public JPanel getPanel() { + final JPanel panel = new JPanel(); + final GridBagLayout gridbag = new GridBagLayout(); + final GridBagConstraints gbc = new GridBagConstraints(); + + panel.setLayout(gridbag); + gbc.fill = GridBagConstraints.BOTH; + gbc.weightx = 1.0; + gbc.weighty = 0; + gbc.anchor = GridBagConstraints.NORTHWEST; + gbc.insets = new Insets(4, 4, 0, 0); + + archNameField.setText(""); + archNameField.setForeground(Color.blue); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.gridwidth = 1; + gbc.gridheight = 1; + gridbag.setConstraints(archNameField, gbc); + panel.add(archNameField); + + archFaceText.setText(""); + gbc.gridx = 0; + gbc.gridy = 1; + gbc.gridwidth = 1; + gbc.gridheight = 1; + gridbag.setConstraints(archFaceText, gbc); + panel.add(archFaceText); + + archTypeText.setText(""); + gbc.gridx = 0; + gbc.gridy = 2; + gbc.gridwidth = 1; + gbc.gridheight = 1; + gridbag.setConstraints(archTypeText, gbc); + panel.add(archTypeText); + + archMapPos.setText(""); + gbc.gridx = 0; + gbc.gridy = 3; + gbc.gridwidth = 1; + gbc.gridheight = 1; + gridbag.setConstraints(archMapPos, gbc); + panel.add(archMapPos); + + gbc.gridx = 1; + gbc.gridy = 0; + gbc.gridwidth = 1; + gbc.gridheight = 5; + gbc.weightx = 0.0; + panel.add(createDirPanel(), gbc); + + return panel; + } + + private JPanel createDirPanel() { + final JPanel dirPanel = new JPanel(new GridBagLayout()); + final GridBagConstraints gbc = new GridBagConstraints(); + gbc.fill = GridBagConstraints.BOTH; + gbc.anchor = GridBagConstraints.CENTER; + gbc.insets = new Insets(2, 2, 2, 2); + + createButton(7, dirPanel, gbc, 0, 0); + createButton(8, dirPanel, gbc, 1, 0); + createButton(1, dirPanel, gbc, 2, 0); + createButton(6, dirPanel, gbc, 0, 1); + createButton(0, dirPanel, gbc, 1, 1); + createButton(2, dirPanel, gbc, 2, 1); + createButton(5, dirPanel, gbc, 0, 2); + createButton(4, dirPanel, gbc, 1, 2); + createButton(3, dirPanel, gbc, 2, 2); + + return dirPanel; + } + + /** + * Create a direction button. + * @param direction Direction for button + * @param panel Panel to add button to + * @param gbc GridBagConstraints to modify + * @param x x position of button + * @param y y position of button + */ + private void createButton(final int direction, final JPanel panel, final GridBagConstraints gbc, final int x, final int y) { + final JToggleButton button = new JToggleButton(ACTION_FACTORY.createAction(true, "direction" + direction, this)); + directionButtonGroup.add(button); + button.setFocusable(false); + button.setEnabled(false); + gbc.gridx = x; + gbc.gridy = y; + panel.add(button, gbc); + directionButtons[direction] = button; + } + + /** {@inheritDoc} */ + public void apply() { + // We update all panels: name, face, msg and archText (more to come...) + // the obj name: + if (StringUtils.isNonwhitespaceText(archNameField.getText())) { // there is something in + // if this equal the default name... + final R archetype = selectedGameObject.getArchetype(); + if (archetype.getObjName() != null) { + if (archNameField.getText().compareTo(archetype.getObjName()) == 0) { + selectedGameObject.setObjName(null); // yes, we don't need it in map + } else { + selectedGameObject.setObjName(archNameField.getText()); // overrule in map selectedGameObject + } + } else + if (archNameField.getText().compareTo(selectedGameObject.getArchetypeName()) == 0) { + selectedGameObject.setObjName(null); + } else { // def is null, something is in panel, so we set it + selectedGameObject.setObjName(archNameField.getText()); // overrule in map selectedGameObject + } + } else { + selectedGameObject.setObjName(null); // nothing in, nothing in map selectedGameObject + // hm, there is no way yet to overrule a default selectedGameObject name with "nothing" + // like <name > ore <name "">..?? + } + } + + /** {@inheritDoc} */ + public void refresh(@Nullable final G gameObject) { + selectedGameObject = gameObject; + + setTabColor(gameObject == null ? Color.black : Color.blue); + + // archNameField + if (gameObject == null) { + archNameField.setForeground(Color.black); + archNameField.setText(""); + } else { + final String objName = gameObject.getObjName(); + if (objName != null) { + archNameField.setForeground(Color.blue); + archNameField.setText(objName); + } else { + archNameField.setForeground(Color.black); + final String archObjName = gameObject.getArchetype().getObjName(); + archNameField.setText(archObjName != null ? archObjName : gameObject.getArchetypeName()); + } + } + + // archFaceText + if (gameObject == null) { + archFaceText.setText("Image:"); + } else { + final StringBuilder faceText = new StringBuilder("Image: "); + appendFaceSource(faceText, gameObject); + archFaceText.setText(faceText.toString()); + } + + // archTypeText + if (gameObject == null) { + archTypeText.setText("Type:"); + } else { + final StringBuilder typeText = new StringBuilder("Type: "); + final ArchetypeType archetypeType = archetypeTypeSet.getArchetypeType(gameObject.getArchetype()); + typeText.append(archetypeType.getTypeName()); + typeText.append(" (").append(archetypeType.getTypeNo()).append(')'); + typeText.append(" [").append(gameObject.getArchetypeName()).append(']'); + if (gameObject.isMulti()) { + typeText.append(" [").append(gameObject.getSizeX()).append('x').append(gameObject.getSizeY()).append(']'); + } else { + typeText.append(" [single]"); + } + archTypeText.setText(typeText.toString()); + } + + // archMapPos + if (gameObject == null) { + archMapPos.setText("Status: "); + } else { + final StringBuilder specialText = new StringBuilder("Status:"); + if (!gameObject.isInContainer()) { + specialText.append(" (map: ").append(gameObject.getMapX()).append(", ").append(gameObject.getMapY()).append(')'); + } + if (gameObject.isScripted()) { + specialText.append(" (script)"); + } + if (gameObject.getMsgText() != null || gameObject.getArchetype().getMsgText() != null) { + specialText.append(" (msg)"); + } + final int invObjects = gameObject.countInvObjects(); + if (invObjects > 0) { + specialText.append(" (inv: ").append(invObjects).append(')'); + } + if (gameObject.isInContainer()) { + final G cont = (G) gameObject.getContainer(); + specialText.append(" (env: ").append(cont.getArchetypeName()).append(')'); + } + archMapPos.setText(specialText.toString()); + } + + // directions + for (final JToggleButton button : directionButtons) { + button.setBackground(null); + } + final boolean enableDirButtons = gameObject != null && gameObject.usesDirection(); + for (final JToggleButton button : directionButtons) { + button.setEnabled(enableDirButtons); + } + final int direction = enableDirButtons ? gameObject.getDirection() : 0; + directionButtons[direction < directionButtons.length ? direction : 0].setSelected(true); + } + + protected abstract void appendFaceSource(@NotNull final StringBuilder sb, @NotNull final G gameObject); + +} // class ArchTab Property changes on: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ConnectionsTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ConnectionsTab.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ConnectionsTab.java 2008-08-05 22:25:32 UTC (rev 4766) @@ -0,0 +1,55 @@ +package net.sf.gridarta.gui.gameobjectattributespanel; + +import javax.swing.JPanel; +import net.sf.gridarta.MapManager; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.connectionview.ConnectionControl; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.map.MapArchObject; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The "Connections" tab in the game object attributes panel. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @author Andreas Kirschbaum + */ +public class ConnectionsTab<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> extends AbstractGameObjectAttributesTab<G, A, R> { + + /** + * The map manager to use. + */ + @NotNull + private final MapManager<G, A, R, V> mapManager; + + /** + * Creates a new instance. + * @param mapManager the map manager to use + */ + public ConnectionsTab(@NotNull final MapManager<G, A, R, V> mapManager) { + this.mapManager = mapManager; + } + + /** {@inheritDoc} */ + @NotNull + public String getName() { + return "Connection"; + } + + /** {@inheritDoc} */ + @NotNull + public JPanel getPanel() { + final ConnectionControl<G, A, R, V> connectionControl = new ConnectionControl<G, A, R, V>(mapManager); + return connectionControl.getView(); + } + + /** {@inheritDoc} */ + public void refresh(@Nullable final G gameObject) { + } + + /** {@inheritDoc} */ + public void apply() { + } + +} // class ConnectionsTab Property changes on: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ConnectionsTab.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesPanel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesPanel.java 2008-08-05 20:02:41 UTC (rev 4765) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesPanel.java 2008-08-05 22:25:32 UTC (rev 4766) @@ -22,57 +22,37 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; import java.awt.GridLayout; -import java.awt.Insets; import java.awt.Toolkit; +import java.util.HashSet; +import java.util.IdentityHashMap; +import java.util.Map; +import java.util.Set; import java.util.prefs.Preferences; import javax.swing.Action; -import javax.swing.ButtonGroup; -import javax.swing.DefaultListModel; import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JList; import javax.swing.JPanel; -import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.JTabbedPane; -import javax.swing.JTextArea; -import javax.swing.JTextField; -import javax.swing.JToggleButton; -import javax.swing.ScrollPaneConstants; import javax.swing.SwingConstants; -import javax.swing.border.EtchedBorder; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; import net.sf.gridarta.MapManagerListener; -import net.sf.gridarta.archtype.ArchetypeType; -import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gameobject.anim.AnimationObjects; -import net.sf.gridarta.gameobject.match.GameObjectMatcher; -import net.sf.gridarta.gui.ErrorListView; import net.sf.gridarta.gui.GSplitPane; -import net.sf.gridarta.gui.connectionview.ConnectionControl; -import net.sf.gridarta.gui.connectionview.LockedItemsControl; -import net.sf.gridarta.gui.connectionview.MonsterControl; import net.sf.gridarta.gui.gameobjecttexteditor.GameObjectTextEditor; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.gridarta.gui.selectedsquare.SelectedSquareListener; -import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; import net.sf.gridarta.map.MapModel; import net.sf.gridarta.map.MapModelEvent; import net.sf.gridarta.map.MapModelListener; import net.sf.gridarta.map.MapSquare; -import net.sf.gridarta.utils.StringUtils; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; import org.jetbrains.annotations.NotNull; @@ -85,36 +65,12 @@ */ public abstract class GameObjectAttributesPanel<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> extends JPanel { - // constants for the 'task' parameter in editScriptWanted() - public static final int SCRIPT_OPEN = 0; - - public static final int SCRIPT_EDIT_PATH = 1; - - public static final int SCRIPT_REMOVE = 2; - /** The serial version UID. */ private static final long serialVersionUID = 1; /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); - private final Action aScriptAddNew = ACTION_FACTORY.createAction(false, "scriptAddNew", this); - - private final Action aScriptEditData = ACTION_FACTORY.createAction(false, "scriptEditData", this); - - private final Action aScriptEdit = ACTION_FACTORY.createAction(false, "scriptEdit", this); - - private final Action aScriptRemove = ACTION_FACTORY.createAction(false, "scriptRemove", this); - - /** The label that displays the current animation name. */ - private final JLabel archAnimText = new JLabel(); - - /** The Panel that displays animation information. */ - private final JPanel animationPanel = createAnimationPanel(); - - /** The Panel that displays scripting information. */ - private final JPanel scriptPanel = createScriptPanel(); - /** The MainControl to use, e.g. for accessing AnimationObjects. */ private final MainControl<G, A, R, V> mainControl; @@ -124,23 +80,6 @@ @NotNull private final ObjectChooser<G, A, R> objectChooser; - /** The archetype type set. */ - @NotNull - private final ArchetypeTypeSet<G, A, R> archetypeTypeSet; - - /** The map manager. */ - private final MapManager<G, A, R, V> mapManager; - - /** The animtation objects instance to use. */ - @NotNull - private final AnimationObjects<?> animationObjects; - - /** - * The parent frame for dialog boxes. - */ - @NotNull - private final Frame parent; - /** The tabs of this GameObjectAttributesPanel. */ private final JTabbedPane panelDesktop = new JTabbedPane(SwingConstants.TOP); @@ -151,42 +90,13 @@ @Nullable private MapControl<G, A, R, V> currentMap; - /** Arch text field. */ - private final JTextArea archTextArea = new JTextArea(4, 25); - - private JList eventList; - /** Preferences. */ private static final Preferences prefs = Preferences.userNodeForPackage(MainControl.class); private static final String MAPARCHPANEL_LOCATION_KEY = "MainWindowMapArchPanel.dividerLocation"; - /** - * The buttons for the direction panel. - * @see #directionButtonGroup - */ - private final JToggleButton[] directionButtons = new JToggleButton[9]; - - /** - * The ButtonGroup for the direction buttons. - * @see #directionButtons - */ - private final ButtonGroup directionButtonGroup = new ButtonGroup(); - private final GSplitPane splitPane; - /** The {@link ErrorListView} holding the error information. */ - private final ErrorListView<G, A, R, V> errorListView; - - /** Arch name field. */ - private final JTextField archNameField = new JTextField(14); - - private final JLabel archMapPos = new JLabel(); - - private final JLabel archFaceText = new JLabel(); - - private final JLabel archTypeText = new JLabel(); - private final JPanel mapArchPanel = new JPanel(); private final Action aMapArchApply = ACTION_FACTORY.createAction(false, "mapArchApply", this); @@ -197,6 +107,16 @@ private final GameObjectTextEditor gameObjectTextEditor; + /** + * All tabs. + */ + private final Set<GameObjectAttributesTab<G, A, R>> tabs = new HashSet<GameObjectAttributesTab<G, A, R>>(); + + /** + * Maps tab to index. + */ + private final Map<GameObjectAttributesTab<G, A, R>, Integer> tabIndex = new IdentityHashMap<GameObjectAttributesTab<G, A, R>, Integer>(); + /** The map manager listener which is attached to {@link #mainControl}. */ private final MapManagerListener<G, A, R, V> mapManagerListener = new MapManagerListener<G, A, R, V>() { @@ -278,7 +198,7 @@ /** {@inheritDoc} */ public void errorsChanged(@NotNull final MapModel<G, A, R> mapModel) { - setErrors(mapModel); + // ignore } }; @@ -294,24 +214,27 @@ }; /** + * The listener attached to all tabs. + */ + private final GameObjectAttributesTabListener<G, A, R> gameObjectAttributesTabListener = new GameObjectAttributesTabListener<G, A, R>() { + + /** {@inheritDoc} */ + public void tabColorChanged(@NotNull final GameObjectAttributesTab<G, A, R> tab, @NotNull final Color tabColor) { + setTabColor(tab, tabColor); + } + + }; + + /** * Create the GameObjectAttributesPanel. * @param mainControl MainControl to use, e.g. for accessing * AnimationObjects. * @param objectChooser the object chooser instance - * @param archetypeTypeSet the archetype type set - * @param monsterMatcher the <code>GameObjectMatcher</code> for matching - * monster objects - * @param parent the parent frame for dialog boxes */ - protected GameObjectAttributesPanel(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<G, A, R, V> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<G, A, R, V> selectedSquareControl, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull final Frame parent) { + protected GameObjectAttributesPanel(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final SelectedSquareControl<G, A, R, V> selectedSquareControl) { super(new BorderLayout()); this.mainControl = mainControl; this.objectChooser = objectChooser; - this.archetypeTypeSet = archetypeTypeSet; - this.mapManager = mapManager; - this.animationObjects = animationObjects; - this.parent = parent; - errorListView = new ErrorListView<G, A, R, V>(mapManager, selectedSquareView); gameObjectTextEditor = new GameObjectTextEditor(); @@ -327,15 +250,6 @@ mapArchPanel.add(buttonPanel, BorderLayout.WEST); mapArchPanel.add(panelDesktop, BorderLayout.CENTER); - panelDesktop.add(createArchPanel(), "Arch"); - panelDesktop.add(createTextPanel(), "Msg Text"); - panelDesktop.add(scriptPanel, "Scripts"); - panelDesktop.add(animationPanel, "Animation"); - panelDesktop.add(createConnectionPanel(), "Connection"); - panelDesktop.add(lockedItemsControl.getView(), "Locked Items"); - panelDesktop.add(createMonsterPanel(monsterMatcher), "Monster"); - panelDesktop.add(errorListView, "Warnings"); - selectedSquareControl.addSelectedSquareListener(selectedSquareListener); refreshDisplay(); @@ -344,26 +258,27 @@ currentMap.getMapModel().addMapModelListener(mapModelListener); } mapManager.addMapManagerListener(mapManagerListener); - archTextArea.setLineWrap(true); } /** - * Creates and returns the panel for displaying animation information. - * @return The newly created animation information panel. + * Adds a tab. + * @param tab the tab to add */ - private JPanel createAnimationPanel() { - final JPanel panel = new JPanel(new BorderLayout()); - archAnimText.setText("Animation: "); - panel.add(archAnimText); - return panel; + public void addTab(final GameObjectAttributesTab<G, A, R> tab) { + tabIndex.put(tab, tabs.size()); + tabs.add(tab); + panelDesktop.add(tab.getPanel(), tab.getName()); + tab.addGameObjectAttributesTabListener(gameObjectAttributesTabListener); + setTabColor(tab, tab.getTabColor()); } /** - * Sets the animation name. - * @param animationName Animation name + * Sets the tab color of a tab. + * @param tab the tab + * @param tabColor the tab color */ - protected void setAnimationName(@Nullable final String animationName) { - archAnimText.setText("Animation: " + (animationName != null ? animationName : "")); + private void setTabColor(final GameObjectAttributesTab<G, A, R> tab, final Color tabColor) { + panelDesktop.setForegroundAt(tabIndex.get(tab), tabColor); } /** @@ -395,273 +310,11 @@ aMapArchAttrib.setEnabled(gameObject != null); gameObjectTextEditor.refreshDisplay(gameObject); - refreshArchTab(gameObject); - refreshMsgTextTab(gameObject); - refreshScriptsTab(gameObject); - refreshAnimationTab(gameObject); - } - - /** - * Refresh the "Animation" tab in the Game Object Attributes Panel. - * @param gameObjec... [truncated message content] |
From: <aki...@us...> - 2008-08-06 10:33:05
|
Revision: 4769 http://gridarta.svn.sourceforge.net/gridarta/?rev=4769&view=rev Author: akirschbaum Date: 2008-08-06 10:33:08 +0000 (Wed, 06 Aug 2008) Log Message: ----------- Split off model class GameObjectAttributesModel from GameObjectAttributesPanel. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gui/ArchTab.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBox.java trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBoxEditor.java trunk/crossfire/src/cfeditor/gui/script/parameter/ArchParameterView.java trunk/crossfire/src/cfeditor/script/parameter/ArchParameter.java trunk/crossfire/src/cfeditor/script/parameter/PluginParameterFactory.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gui/ArchTab.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AbstractGameObjectAttributesTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AnimationTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ConnectionsTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesPanel.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/LockedItemsTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MonstersTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MsgTextTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ScriptTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/WarningsTab.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesModel.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesModelListener.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -83,6 +83,7 @@ import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import net.sf.gridarta.gui.map.MapCursorControl; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.tools.DeletionTool; @@ -325,8 +326,9 @@ // Initialize the main view final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, 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); - gameObjectAttributesPanel = new GameObjectAttributesPanel(this, objectChooser, archetypeTypeSet, mapManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); - PluginParameterFactory.init(archetypeSet, gameObjectAttributesPanel, objectChooser, mapManager); + final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel = new GameObjectAttributesModel<GameObject, MapArchObject, Archetype>(); + gameObjectAttributesPanel = new GameObjectAttributesPanel(gameObjectAttributesModel, this, objectChooser, archetypeTypeSet, mapManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); + PluginParameterFactory.init(archetypeSet, gameObjectAttributesModel, objectChooser, mapManager); final NamedFilterList defaultNamedFilterList = new NamedFilterList(gameObjectMatchers.getFilters()); final CFilterControl filterControl = new CFilterControl(null, mapManager, defaultNamedFilterList); ((CrossfireObjectsFactory) gridartaObjectsFactory).setFilterControl(filterControl); Modified: trunk/crossfire/src/cfeditor/gui/ArchTab.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ArchTab.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/crossfire/src/cfeditor/gui/ArchTab.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -23,6 +23,7 @@ import cfeditor.gameobject.GameObject; import cfeditor.map.MapArchObject; import net.sf.gridarta.archtype.ArchetypeTypeSet; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import org.jetbrains.annotations.NotNull; public class ArchTab extends net.sf.gridarta.gui.gameobjectattributespanel.ArchTab<GameObject, MapArchObject, Archetype> { @@ -30,9 +31,10 @@ /** * Creates a new instance. * @param archetypeTypeSet the archetype type set + * @param gameObjectAttributesModel the model to track */ - public ArchTab(@NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet) { - super(archetypeTypeSet); + public ArchTab(@NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel) { + super(archetypeTypeSet, gameObjectAttributesModel); } /** {@inheritDoc} */ Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -32,6 +32,7 @@ import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.gameobjectattributespanel.AnimationTab; import net.sf.gridarta.gui.gameobjectattributespanel.ConnectionsTab; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import net.sf.gridarta.gui.gameobjectattributespanel.LockedItemsTab; import net.sf.gridarta.gui.gameobjectattributespanel.MonstersTab; import net.sf.gridarta.gui.gameobjectattributespanel.MsgTextTab; @@ -55,16 +56,16 @@ private static final long serialVersionUID = 1L; /* Build Panel */ - public GameObjectAttributesPanel(@NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final Frame parent) { - super(mainControl, objectChooser, mapManager, selectedSquareControl); - addTab(new ArchTab(archetypeTypeSet)); - addTab(new MsgTextTab<GameObject, MapArchObject, Archetype>()); - addTab(new ScriptTab<GameObject, MapArchObject, Archetype>(parent, mainControl)); - addTab(new AnimationTab<GameObject, MapArchObject, Archetype>(animationObjects)); - addTab(new ConnectionsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager)); - addTab(new LockedItemsTab<GameObject, MapArchObject, Archetype>(lockedItemsControl)); - addTab(new MonstersTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, monsterMatcher)); - addTab(new WarningsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, selectedSquareView)); + public GameObjectAttributesPanel(final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final Frame parent) { + super(gameObjectAttributesModel, mainControl, objectChooser, mapManager, selectedSquareControl); + addTab(new ArchTab(archetypeTypeSet, gameObjectAttributesModel)); + addTab(new MsgTextTab<GameObject, MapArchObject, Archetype>(gameObjectAttributesModel)); + addTab(new ScriptTab<GameObject, MapArchObject, Archetype>(parent, mainControl, gameObjectAttributesModel)); + addTab(new AnimationTab<GameObject, MapArchObject, Archetype>(animationObjects, gameObjectAttributesModel)); + addTab(new ConnectionsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, gameObjectAttributesModel)); + addTab(new LockedItemsTab<GameObject, MapArchObject, Archetype>(lockedItemsControl, gameObjectAttributesModel)); + addTab(new MonstersTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, monsterMatcher, gameObjectAttributesModel)); + addTab(new WarningsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, selectedSquareView, gameObjectAttributesModel)); } } // class GameObjectAttributesPanel Modified: trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBox.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBox.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBox.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -22,11 +22,10 @@ import cfeditor.gameobject.Archetype; import cfeditor.gameobject.ArchetypeSet; import cfeditor.gameobject.GameObject; -import cfeditor.gui.map.CMapViewBasic; import cfeditor.map.MapArchObject; import java.awt.Dimension; import javax.swing.JComboBox; -import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesPanel; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; @@ -42,10 +41,10 @@ private final ArchComboBoxModel archComboBoxModel; - public ArchComboBox(@NotNull final GameObjectAttributesPanel<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesPanel, @NotNull final ArchetypeSet archetypeSet, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser) { + public ArchComboBox(@NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final ArchetypeSet archetypeSet, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser) { setMaximumRowCount(4); archComboBoxModel = new ArchComboBoxModel(archetypeSet); - archComboBoxEditor = new ArchComboBoxEditor(this, archComboBoxModel, objectChooser, gameObjectAttributesPanel, archetypeSet); + archComboBoxEditor = new ArchComboBoxEditor(this, archComboBoxModel, objectChooser, gameObjectAttributesModel, archetypeSet); final MyCellRenderer cellRenderer = new MyCellRenderer(archComboBoxEditor, archetypeSet); //setPrototypeDisplayValue(cellRenderer.sizeTester); setRenderer(cellRenderer); Modified: trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBoxEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBoxEditor.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBoxEditor.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -22,7 +22,6 @@ import cfeditor.gameobject.Archetype; import cfeditor.gameobject.ArchetypeSet; import cfeditor.gameobject.GameObject; -import cfeditor.gui.map.CMapViewBasic; import cfeditor.map.MapArchObject; import java.awt.Color; import java.awt.Component; @@ -44,7 +43,7 @@ import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import net.sf.gridarta.CommonConstants; -import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesPanel; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import org.jetbrains.annotations.Nullable; @@ -56,7 +55,7 @@ private final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser; - private final GameObjectAttributesPanel<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesPanel; + private final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel; private final ArchetypeSet archetypeSet; @@ -70,11 +69,11 @@ private boolean locked = false; - public ArchComboBoxEditor(final ArchComboBox archComboBox, final ArchComboBoxModel archComboBoxModel, final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, final GameObjectAttributesPanel<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesPanel, final ArchetypeSet archetypeSet) { + public ArchComboBoxEditor(final ArchComboBox archComboBox, final ArchComboBoxModel archComboBoxModel, final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, final ArchetypeSet archetypeSet) { this.archComboBox = archComboBox; this.archComboBoxModel = archComboBoxModel; this.objectChooser = objectChooser; - this.gameObjectAttributesPanel = gameObjectAttributesPanel; + this.gameObjectAttributesModel = gameObjectAttributesModel; this.archetypeSet = archetypeSet; } @@ -117,7 +116,7 @@ fromActive.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { try { - final Archetype ao = archComboBoxModel.getNearsetMatch(gameObjectAttributesPanel.getSelectedGameObject().getArchetypeName()); + final Archetype ao = archComboBoxModel.getNearsetMatch(gameObjectAttributesModel.getSelectedGameObject().getArchetypeName()); archComboBox.setSelectedItem(ao); setItem(ao); } catch (final Exception ex) {//null pointer exception Modified: trunk/crossfire/src/cfeditor/gui/script/parameter/ArchParameterView.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/script/parameter/ArchParameterView.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/crossfire/src/cfeditor/gui/script/parameter/ArchParameterView.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -22,7 +22,6 @@ import cfeditor.gameobject.Archetype; import cfeditor.gameobject.ArchetypeSet; import cfeditor.gameobject.GameObject; -import cfeditor.gui.map.CMapViewBasic; import cfeditor.map.MapArchObject; import cfeditor.script.parameter.ArchParameter; import cfeditor.script.parameter.PluginParameter; @@ -30,7 +29,7 @@ import java.awt.event.ItemListener; import javax.swing.JComponent; import javax.swing.JPanel; -import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesPanel; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import org.jetbrains.annotations.NotNull; @@ -50,8 +49,8 @@ return this.value; } - public ArchParameterView(final ArchParameter param, @NotNull final GameObjectAttributesPanel<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesPanel, @NotNull final ArchetypeSet archetypeSet, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser) { - value = new ArchComboBox(gameObjectAttributesPanel, archetypeSet, objectChooser); + public ArchParameterView(final ArchParameter param, @NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final ArchetypeSet archetypeSet, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser) { + value = new ArchComboBox(gameObjectAttributesModel, archetypeSet, objectChooser); parameter = param; value.setSelectedItem(param.getValue()); value.addItemListener(new ItemListener() { Modified: trunk/crossfire/src/cfeditor/script/parameter/ArchParameter.java =================================================================== --- trunk/crossfire/src/cfeditor/script/parameter/ArchParameter.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/crossfire/src/cfeditor/script/parameter/ArchParameter.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -22,11 +22,10 @@ import cfeditor.gameobject.Archetype; import cfeditor.gameobject.ArchetypeSet; import cfeditor.gameobject.GameObject; -import cfeditor.gui.map.CMapViewBasic; import cfeditor.gui.script.parameter.ArchParameterView; import cfeditor.gui.script.parameter.PluginParameterView; import cfeditor.map.MapArchObject; -import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesPanel; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import org.jdom.Element; import org.jetbrains.annotations.NotNull; @@ -39,7 +38,7 @@ private String valueString; @NotNull - private static GameObjectAttributesPanel<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesPanel; + private static GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel; @NotNull private static ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser; @@ -48,9 +47,9 @@ super(getParameterType()); } - public static void init(@NotNull final ArchetypeSet archetypeSet, @NotNull final GameObjectAttributesPanel<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesPanel, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser) { + public static void init(@NotNull final ArchetypeSet archetypeSet, @NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser) { ArchParameter.archetypeSet = archetypeSet; - ArchParameter.gameObjectAttributesPanel = gameObjectAttributesPanel; + ArchParameter.gameObjectAttributesModel = gameObjectAttributesModel; ArchParameter.objectChooser = objectChooser; } @@ -63,7 +62,7 @@ @Override public PluginParameterView getView() { - return new ArchParameterView(this, gameObjectAttributesPanel, archetypeSet, objectChooser); + return new ArchParameterView(this, gameObjectAttributesModel, archetypeSet, objectChooser); } @Override Modified: trunk/crossfire/src/cfeditor/script/parameter/PluginParameterFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/script/parameter/PluginParameterFactory.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/crossfire/src/cfeditor/script/parameter/PluginParameterFactory.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -27,7 +27,7 @@ import java.util.LinkedHashMap; import java.util.Map; import net.sf.gridarta.MapManager; -import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesPanel; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import org.apache.log4j.Logger; import org.jdom.Element; @@ -45,8 +45,8 @@ private static final Map<String, Class<? extends PluginParameter>> parameterTypes = new LinkedHashMap<String, Class<? extends PluginParameter>>(); - public static void init(@NotNull final ArchetypeSet archetypeSet, @NotNull final GameObjectAttributesPanel<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesPanel, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager) { - ArchParameter.init(archetypeSet, gameObjectAttributesPanel, objectChooser); + public static void init(@NotNull final ArchetypeSet archetypeSet, @NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager) { + ArchParameter.init(archetypeSet, gameObjectAttributesModel, objectChooser); MapParameter.init(mapManager); parameterTypes.put(StringParameter.getParameterType(), StringParameter.class); parameterTypes.put(IntegerParameter.getParameterType(), IntegerParameter.class); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -91,6 +91,7 @@ import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import net.sf.gridarta.gui.map.MapCursorControl; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.tools.DeletionTool; @@ -391,7 +392,8 @@ // Initialize the main view final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, 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); - gameObjectAttributesPanel = new GameObjectAttributesPanel(this, objectChooser, archetypeTypeSet, mapManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); + final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel = new GameObjectAttributesModel<GameObject, MapArchObject, Archetype>(); + gameObjectAttributesPanel = new GameObjectAttributesPanel(gameObjectAttributesModel, this, objectChooser, archetypeTypeSet, mapManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); final ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChoiceDisplay = new ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, CMapViewBasic>(replaceDialogManager, archetypeTypeSet, objectChooser, archetypeChooserModel, pickmapChooserControl); final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette = new ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic>(editTypes, selectedSquareView, objectChooser, pickmapChooserControl, copyBuffer); final LeftPanel leftPanel = new LeftPanel(objectChooser, toolPalette, objectChoiceDisplay); Modified: trunk/daimonin/src/daieditor/gui/ArchTab.java =================================================================== --- trunk/daimonin/src/daieditor/gui/ArchTab.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/daimonin/src/daieditor/gui/ArchTab.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -23,6 +23,7 @@ import daieditor.gameobject.GameObject; import daieditor.map.MapArchObject; import net.sf.gridarta.archtype.ArchetypeTypeSet; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import org.jetbrains.annotations.NotNull; public class ArchTab extends net.sf.gridarta.gui.gameobjectattributespanel.ArchTab<GameObject, MapArchObject, Archetype> { @@ -30,9 +31,10 @@ /** * Creates a new instance. * @param archetypeTypeSet the archetype type set + * @param gameObjectAttributesModel the model to track */ - public ArchTab(@NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet) { - super(archetypeTypeSet); + public ArchTab(@NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel) { + super(archetypeTypeSet, gameObjectAttributesModel); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -32,6 +32,7 @@ import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.gameobjectattributespanel.AnimationTab; import net.sf.gridarta.gui.gameobjectattributespanel.ConnectionsTab; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import net.sf.gridarta.gui.gameobjectattributespanel.LockedItemsTab; import net.sf.gridarta.gui.gameobjectattributespanel.MonstersTab; import net.sf.gridarta.gui.gameobjectattributespanel.MsgTextTab; @@ -55,16 +56,16 @@ private static final long serialVersionUID = 1L; /* Build Panel */ - public GameObjectAttributesPanel(@NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final Frame parent) { - super(mainControl, objectChooser, mapManager, selectedSquareControl); - addTab(new ArchTab(archetypeTypeSet)); - addTab(new MsgTextTab<GameObject, MapArchObject, Archetype>()); - addTab(new ScriptTab<GameObject, MapArchObject, Archetype>(parent, mainControl)); - addTab(new AnimationTab<GameObject, MapArchObject, Archetype>(animationObjects)); - addTab(new ConnectionsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager)); - addTab(new LockedItemsTab<GameObject, MapArchObject, Archetype>(lockedItemsControl)); - addTab(new MonstersTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, monsterMatcher)); - addTab(new WarningsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, selectedSquareView)); + public GameObjectAttributesPanel(@NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype>gameObjectAttributesModel, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final Frame parent) { + super(gameObjectAttributesModel, mainControl, objectChooser, mapManager, selectedSquareControl); + addTab(new ArchTab(archetypeTypeSet, gameObjectAttributesModel)); + addTab(new MsgTextTab<GameObject, MapArchObject, Archetype>(gameObjectAttributesModel)); + addTab(new ScriptTab<GameObject, MapArchObject, Archetype>(parent, mainControl, gameObjectAttributesModel)); + addTab(new AnimationTab<GameObject, MapArchObject, Archetype>(animationObjects, gameObjectAttributesModel)); + addTab(new ConnectionsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, gameObjectAttributesModel)); + addTab(new LockedItemsTab<GameObject, MapArchObject, Archetype>(lockedItemsControl, gameObjectAttributesModel)); + addTab(new MonstersTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, monsterMatcher, gameObjectAttributesModel)); + addTab(new WarningsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, selectedSquareView, gameObjectAttributesModel)); } } // class GameObjectAttributesPanel Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AbstractGameObjectAttributesTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AbstractGameObjectAttributesTab.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AbstractGameObjectAttributesTab.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -26,6 +26,7 @@ import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapArchObject; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Base class for {@link GameObjectAttributesTab} implementations. @@ -60,6 +61,33 @@ private Color tabColor = TAB_COLOR_DEFAULT; /** + * The currently selected game object. + */ + @Nullable + private G gameObject = null; + + /** + * The listener attached to the tracked model. + */ + private final GameObjectAttributesModelListener<G, A, R> gameObjectAttributesModelListener = new GameObjectAttributesModelListener<G, A, R>() { + + /** {@inheritDoc} */ + public void selectedGameObjectChanged(@Nullable final G selectedGameObject) { + AbstractGameObjectAttributesTab.this.gameObject = selectedGameObject; + refresh(selectedGameObject); + } + + }; + + /** + * Creates a new instance. + * @param gameObjectAttributesModel the model to track + */ + protected AbstractGameObjectAttributesTab(@NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel) { + gameObjectAttributesModel.addGameObjectAttributesModelListener(gameObjectAttributesModelListener); + } + + /** * Sets the tab color. * @param tabColor the tab color */ @@ -90,4 +118,21 @@ return tabColor; } + /** {@inheritDoc} */ + public final void apply() { + apply(gameObject); + } + + /** + * Refreshes the display. + * @param gameObject the game object to set the contents from + */ + protected abstract void refresh(@Nullable final G gameObject); + + /** + * Applies settings to the given game object. + * @param gameObject the game object to set the contents of + */ + protected abstract void apply(@Nullable final G gameObject); + } // class AbstractGameObjectAttributesTab Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AnimationTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AnimationTab.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AnimationTab.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -46,9 +46,12 @@ /** * Creates a new instance. * @param animationObjects the animation objects + * @param gameObjectAttributesModel the model to track */ - public AnimationTab(@NotNull final AnimationObjects<?> animationObjects) { + public AnimationTab(@NotNull final AnimationObjects<?> animationObjects, @NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel) { + super(gameObjectAttributesModel); this.animationObjects = animationObjects; + refresh(gameObjectAttributesModel.getSelectedGameObject()); } /** {@inheritDoc} */ @@ -67,7 +70,8 @@ } /** {@inheritDoc} */ - public void refresh(@Nullable final G gameObject) { + @Override + protected void refresh(@Nullable final G gameObject) { if (gameObject == null) { setTabColor(TAB_COLOR_DEFAULT); setAnimationName(null); @@ -93,7 +97,8 @@ } /** {@inheritDoc} */ - public void apply() { + @Override + protected void apply(@Nullable final G gameObject) { } /** Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -77,17 +77,19 @@ private final JToggleButton[] directionButtons = new JToggleButton[9]; /** - * The displayed game object. + * The panel consisting of the direction buttons. */ - @Nullable - private G selectedGameObject = null; + private final JPanel dirPanel = createDirPanel(); /** * Creates a new instance. * @param archetypeTypeSet the archetype type set + * @param gameObjectAttributesModel the model to track */ - protected ArchTab(@NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet) { + protected ArchTab(@NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel) { + super(gameObjectAttributesModel); this.archetypeTypeSet = archetypeTypeSet; + refresh(gameObjectAttributesModel.getSelectedGameObject()); } /** {@inheritDoc} */ @@ -148,29 +150,33 @@ gbc.gridwidth = 1; gbc.gridheight = 5; gbc.weightx = 0.0; - panel.add(createDirPanel(), gbc); + panel.add(dirPanel, gbc); return panel; } + /** + * Creates the panel consisting of the direction buttons. + * @return the panel + */ private JPanel createDirPanel() { - final JPanel dirPanel = new JPanel(new GridBagLayout()); + final JPanel panel = new JPanel(new GridBagLayout()); final GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(2, 2, 2, 2); - createButton(7, dirPanel, gbc, 0, 0); - createButton(8, dirPanel, gbc, 1, 0); - createButton(1, dirPanel, gbc, 2, 0); - createButton(6, dirPanel, gbc, 0, 1); - createButton(0, dirPanel, gbc, 1, 1); - createButton(2, dirPanel, gbc, 2, 1); - createButton(5, dirPanel, gbc, 0, 2); - createButton(4, dirPanel, gbc, 1, 2); - createButton(3, dirPanel, gbc, 2, 2); + createButton(7, panel, gbc, 0, 0); + createButton(8, panel, gbc, 1, 0); + createButton(1, panel, gbc, 2, 0); + createButton(6, panel, gbc, 0, 1); + createButton(0, panel, gbc, 1, 1); + createButton(2, panel, gbc, 2, 1); + createButton(5, panel, gbc, 0, 2); + createButton(4, panel, gbc, 1, 2); + createButton(3, panel, gbc, 2, 2); - return dirPanel; + return panel; } /** @@ -193,35 +199,35 @@ } /** {@inheritDoc} */ - public void apply() { + @Override + protected void apply(@Nullable final G gameObject) { // We update all panels: name, face, msg and archText (more to come...) // the obj name: if (StringUtils.isNonwhitespaceText(archNameField.getText())) { // there is something in // if this equal the default name... - final R archetype = selectedGameObject.getArchetype(); + final R archetype = gameObject.getArchetype(); if (archetype.getObjName() != null) { if (archNameField.getText().compareTo(archetype.getObjName()) == 0) { - selectedGameObject.setObjName(null); // yes, we don't need it in map + gameObject.setObjName(null); // yes, we don't need it in map } else { - selectedGameObject.setObjName(archNameField.getText()); // overrule in map selectedGameObject + gameObject.setObjName(archNameField.getText()); // overrule in map gameObject } } else - if (archNameField.getText().compareTo(selectedGameObject.getArchetypeName()) == 0) { - selectedGameObject.setObjName(null); + if (archNameField.getText().compareTo(gameObject.getArchetypeName()) == 0) { + gameObject.setObjName(null); } else { // def is null, something is in panel, so we set it - selectedGameObject.setObjName(archNameField.getText()); // overrule in map selectedGameObject + gameObject.setObjName(archNameField.getText()); // overrule in map gameObject } } else { - selectedGameObject.setObjName(null); // nothing in, nothing in map selectedGameObject - // hm, there is no way yet to overrule a default selectedGameObject name with "nothing" + gameObject.setObjName(null); // nothing in, nothing in map gameObject + // hm, there is no way yet to overrule a default gameObject name with "nothing" // like <name > ore <name "">..?? } } /** {@inheritDoc} */ - public void refresh(@Nullable final G gameObject) { - selectedGameObject = gameObject; - + @Override + protected void refresh(@Nullable final G gameObject) { setTabColor(gameObject == null ? Color.black : Color.blue); // archNameField Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ConnectionsTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ConnectionsTab.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ConnectionsTab.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -26,9 +26,12 @@ /** * Creates a new instance. * @param mapManager the map manager to use + * @param gameObjectAttributesModel the model to track */ - public ConnectionsTab(@NotNull final MapManager<G, A, R, V> mapManager) { + public ConnectionsTab(@NotNull final MapManager<G, A, R, V> mapManager, @NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel) { + super(gameObjectAttributesModel); this.mapManager = mapManager; + refresh(gameObjectAttributesModel.getSelectedGameObject()); } /** {@inheritDoc} */ @@ -45,11 +48,13 @@ } /** {@inheritDoc} */ - public void refresh(@Nullable final G gameObject) { + @Override + protected void refresh(@Nullable final G gameObject) { } /** {@inheritDoc} */ - public void apply() { + @Override + protected void apply(@Nullable final G gameObject) { } } // class ConnectionsTab Added: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesModel.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesModel.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -0,0 +1,88 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.gameobjectattributespanel; + +import java.util.ArrayList; +import java.util.List; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.map.MapArchObject; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The model of the game object attributes dialog. + * @author Andreas Kirschbaum + */ +public class GameObjectAttributesModel<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { + + /** + * The selected game object. + */ + @Nullable + private G selectedGameObject = null; + + /** + * The registered listeners. + */ + private final List<GameObjectAttributesModelListener<G, A, R>> listeners = new ArrayList<GameObjectAttributesModelListener<G, A, R>>(); + + /** + * If a game object is selected, the MapArchPanels (bottom right windows) + * get updated. + * @param selectedGameObject the selected game object + */ + public void setSelectedGameObject(@Nullable final G selectedGameObject) { + if (this.selectedGameObject == selectedGameObject) { + return; + } + + this.selectedGameObject = selectedGameObject; + for (final GameObjectAttributesModelListener<G, A, R> listener : listeners) { + listener.selectedGameObjectChanged(selectedGameObject); + } + } + + /** + * Returns the selected game object. + * @return the selected game object + */ + @Nullable + public G getSelectedGameObject() { + return selectedGameObject; + } + + /** + * Adds a listener to be notified. + * @param listener the listener + */ + public void addGameObjectAttributesModelListener(@NotNull final GameObjectAttributesModelListener<G, A, R> listener) { + listeners.add(listener); + } + + /** + * Removes a listener to be notified. + * @param listener the listener + */ + public void removeGameObjectAttributesModelListener(@NotNull final GameObjectAttributesModelListener<G, A, R> listener) { + listeners.add(listener); + } + +} // class GameObjectAttributesModel Property changes on: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesModel.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesModelListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesModelListener.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesModelListener.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -0,0 +1,39 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.gameobjectattributespanel; + +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.map.MapArchObject; +import org.jetbrains.annotations.Nullable; + +/** + * Listener for {@link GameObjectAttributesModel} related events. + * @author Andreas Kirschbaum + */ +public interface GameObjectAttributesModelListener<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { + + /** + * Called whenever the selected game object has changed. + * @param selectedGameObject the selected game object + */ + void selectedGameObjectChanged(@Nullable G selectedGameObject); + +} // interface GameObjectAttributesModelListener Property changes on: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesModelListener.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesPanel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesPanel.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesPanel.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -83,8 +83,10 @@ /** The tabs of this GameObjectAttributesPanel. */ private final JTabbedPane panelDesktop = new JTabbedPane(SwingConstants.TOP); - /** The selected game object. */ - private G selectedGameObject = null; + /** + * The model used by this controller. + */ + private final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel; /** Last known active map. This map has {@link #mapModelListener} attached. */ @Nullable @@ -173,6 +175,7 @@ /** {@inheritDoc} */ public void mapSquaresChanged(final MapModelEvent<G, A, R> e) { + final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); if (selectedGameObject == null) { return; } @@ -189,6 +192,7 @@ /** {@inheritDoc} */ public void mapObjectsChanged(final MapModelEvent<G, A, R> e) { + final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); for (final G gameObject : e.getGameObjects()) { if (selectedGameObject == gameObject) { refreshDisplay(); @@ -208,12 +212,24 @@ /** {@inheritDoc} */ public void selectedGameObjectChanged(@Nullable final G gameObject) { - setSelectedGameObject(gameObject); + gameObjectAttributesModel.setSelectedGameObject(gameObject); } }; /** + * The listener attached to {@link #gameObjectAttributesModel}. + */ + private final GameObjectAttributesModelListener<G, A, R> gameObjectAttributesModelListener = new GameObjectAttributesModelListener<G, A, R>() { + + /** {@inheritDoc} */ + public void selectedGameObjectChanged(@Nullable final G selectedGameObject) { + refreshDisplay(); + } + + }; + + /** * The listener attached to all tabs. */ private final GameObjectAttributesTabListener<G, A, R> gameObjectAttributesTabListener = new GameObjectAttributesTabListener<G, A, R>() { @@ -227,14 +243,16 @@ /** * Create the GameObjectAttributesPanel. + * @param gameObjectAttributesModel the model to use * @param mainControl MainControl to use, e.g. for accessing * AnimationObjects. * @param objectChooser the object chooser instance * @param mapManager the map manager instance * @param selectedSquareControl the selected square control instance */ - protected GameObjectAttributesPanel(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final SelectedSquareControl<G, A, R, V> selectedSquareControl) { + protected GameObjectAttributesPanel(@NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel, @NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final SelectedSquareControl<G, A, R, V> selectedSquareControl) { super(new BorderLayout()); + this.gameObjectAttributesModel = gameObjectAttributesModel; this.mainControl = mainControl; this.objectChooser = objectChooser; @@ -253,6 +271,7 @@ mapArchPanel.add(panelDesktop, BorderLayout.CENTER); selectedSquareControl.addSelectedSquareListener(selectedSquareListener); + gameObjectAttributesModel.addGameObjectAttributesModelListener(gameObjectAttributesModelListener); refreshDisplay(); currentMap = mapManager.getCurrentMap(); @@ -283,28 +302,9 @@ panelDesktop.setForegroundAt(tabIndex.get(tab), tabColor); } - /** - * Return the selected game object. - * @return the selected game object, or <code>null</code> if no game object - * is selected - */ - @Nullable - public G getSelectedGameObject() { - return selectedGameObject; - } - - /** - * If a game object is selected, the MapArchPanels (bottom right windows) - * get updated. - * @param selectedGameObject the selected game object - */ - private void setSelectedGameObject(@Nullable final G selectedGameObject) { - this.selectedGameObject = selectedGameObject; - refreshDisplay(); - } - - /** Update the displayed information for {@link #selectedGameObject}. */ + /** Update the displayed information for the selected game object. */ private void refreshDisplay() { + final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); final G gameObject = selectedGameObject == null ? null : selectedGameObject.getHead(); aMapArchApply.setEnabled(gameObject != null); @@ -312,14 +312,12 @@ aMapArchAttrib.setEnabled(gameObject != null); gameObjectTextEditor.refreshDisplay(gameObject); - for (final GameObjectAttributesTab<G, A, R> tab : tabs) { - tab.refresh(gameObject); - } } /** Action method for applying the changes made in the arch panel. */ @ActionMethod public void mapArchApply() { + final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); applyArchPanelChanges(selectedGameObject); } @@ -329,6 +327,7 @@ */ @ActionMethod public void mapArchAttrib() { + final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); mainControl.openAttrDialog(selectedGameObject); } @@ -343,6 +342,7 @@ return; } + final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); if (selectedGameObject == null) { return; } @@ -429,7 +429,7 @@ private void applyDirectionChanges(final G gameObject, final int dir) { gameObjectTextEditor.applyDirectionChanges(dir, gameObject.getArchetype().getDirection()); applyArchPanelChanges(gameObject); - setSelectedGameObject(gameObject); + gameObjectAttributesModel.setSelectedGameObject(gameObject); } /** @@ -437,6 +437,7 @@ * @param direction Direction number */ private void direction(final int direction) { + final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); applyDirectionChanges(selectedGameObject, direction); } Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesTab.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesTab.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -25,7 +25,6 @@ import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapArchObject; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; /** * A tab in the game object attributes panel. @@ -48,15 +47,8 @@ JPanel getPanel(); /** - * Refresh the "Arch" tab in the Game Object Attributes Panel. - * @param gameObject The game object to set the contents from. + * Applies the current settings. */ - void refresh(@Nullable G gameObject); - - /** - * Applies the current settings the game object previously set by {@link - * #refresh(GameObject)}. - */ void apply(); /** Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/LockedItemsTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/LockedItemsTab.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/LockedItemsTab.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -43,9 +43,12 @@ /** * Creates a new instance. * @param lockedItemsControl the locked items control to display + * @param gameObjectAttributesModel the model to track */ - public LockedItemsTab(@NotNull final LockedItemsControl<G, A, R, ?> lockedItemsControl) { + public LockedItemsTab(@NotNull final LockedItemsControl<G, A, R, ?> lockedItemsControl, @NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel) { + super(gameObjectAttributesModel); this.lockedItemsControl = lockedItemsControl; + refresh(gameObjectAttributesModel.getSelectedGameObject()); } /** {@inheritDoc} */ @@ -61,11 +64,13 @@ } /** {@inheritDoc} */ - public void refresh(@Nullable final G gameObject) { + @Override + protected void refresh(@Nullable final G gameObject) { } /** {@inheritDoc} */ - public void apply() { + @Override + protected void apply(@Nullable final G gameObject) { } } // class LockedItemsTab Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MonstersTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MonstersTab.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MonstersTab.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -53,10 +53,13 @@ * Creates a new instance. * @param mapManager the map manager to use * @param monsterMatcher the matcher for matching monsters + * @param gameObjectAttributesModel the model to track */ - public MonstersTab(@NotNull final MapManager<G, A, R, V> mapManager, @NotNull final GameObjectMatcher monsterMatcher) { + public MonstersTab(@NotNull final MapManager<G, A, R, V> mapManager, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel) { + super(gameObjectAttributesModel); this.mapManager = mapManager; this.monsterMatcher = monsterMatcher; + refresh(gameObjectAttributesModel.getSelectedGameObject()); } /** {@inheritDoc} */ @@ -73,11 +76,12 @@ } /** {@inheritDoc} */ - public void refresh(@Nullable final G gameObject) { + @Override + protected void refresh(@Nullable final G gameObject) { } /** {@inheritDoc} */ - public void apply() { + protected void apply(@Nullable final G gameObject) { } } // class MonstersTab Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MsgTextTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MsgTextTab.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MsgTextTab.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -46,16 +46,13 @@ private final JTextArea archTextArea = new JTextArea(4, 25); /** - * The displayed game object. - */ - @Nullable - private G selectedGameObject; - - /** * Creates a new instance. + * @param gameObjectAttributesModel the model to track */ - public MsgTextTab() { + public MsgTextTab(@NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel) { + super(gameObjectAttributesModel); archTextArea.setLineWrap(true); + refresh(gameObjectAttributesModel.getSelectedGameObject()); } /** {@inheritDoc} */ @@ -81,9 +78,8 @@ } /** {@inheritDoc} */ - public void refresh(@Nullable final G gameObject) { - selectedGameObject = gameObject; - + @Override + protected void refresh(@Nullable final G gameObject) { final boolean hasMessage; if (gameObject == null) { archTextArea.setForeground(Color.black); @@ -112,8 +108,9 @@ } /** {@inheritDoc} */ - public void apply() { - final R archetype = selectedGameObject.getArchetype(); + @Override + protected void apply(@Nullable final G gameObject) { + final R archetype = gameObject.getArchetype(); // the msg TEXT!! ("msg ... endmsg") // if there is an entry in the archTextArea (msg window), this // overrules the default text (if any) @@ -127,19 +124,19 @@ newMsgText = ""; } if (newMsgText.equals(archetype.getMsgText().trim())) { - selectedGameObject.deleteMsgText(); // yes, we don't need it in map + gameObject.deleteMsgText(); // yes, we don't need it in map ... [truncated message content] |
From: <aki...@us...> - 2008-08-06 17:55:07
|
Revision: 4770 http://gridarta.svn.sourceforge.net/gridarta/?rev=4770&view=rev Author: akirschbaum Date: 2008-08-06 17:55:09 +0000 (Wed, 06 Aug 2008) Log Message: ----------- Remove raw types. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBitmask.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java trunk/src/app/net/sf/gridarta/gui/MainView.java trunk/src/app/net/sf/gridarta/gui/findarchetypes/FindArchetypesDialog.java trunk/src/app/net/sf/gridarta/gui/findarchetypes/TableModel.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/HelpActionListener.java trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-06 10:33:08 UTC (rev 4769) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-06 17:55:09 UTC (rev 4770) @@ -314,7 +314,7 @@ ); final ArchetypeAttributeParser<GameObject, MapArchObject, Archetype> archetypeAttributeParser = new ArchetypeAttributeParser<GameObject, MapArchObject, Archetype>(Archetype.TYPE_EVENT_CONNECTOR, false, globalSettings, mapFileFilter, pythonFileFilter, faceObjects, animationObjects, numberSpells, gameObjectSpells, 0, archetypeTypeSet, treasureListTree); final ArchetypeTypeParser<GameObject, MapArchObject, Archetype> archetypeTypeParser = new ArchetypeTypeParser<GameObject, MapArchObject, Archetype>(archetypeAttributeParser); - final ArchetypeTypeSetParser<GameObject, MapArchObject, Archetype> archetypeTypeSetParser = new ArchetypeTypeSetParser(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath(), archetypeTypeSet, archetypeTypeParser); + final ArchetypeTypeSetParser<GameObject, MapArchObject, Archetype> archetypeTypeSetParser = new ArchetypeTypeSetParser<GameObject, MapArchObject, Archetype>(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath(), archetypeTypeSet, archetypeTypeParser); try { final String filename = IOUtils.getResourceURLAsString(getConfigurationDirectory(), CommonConstants.TYPEDEF_FILE); archetypeTypeSetParser.loadTypesFromXML(filename); Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-08-06 10:33:08 UTC (rev 4769) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-08-06 17:55:09 UTC (rev 4770) @@ -109,7 +109,7 @@ protected AbstractMainControl(@NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull final String key, @NotNull final GlobalSettings globalSettings) { this.globalSettings = globalSettings; final DefaultMapManager<G, A, R, V> tmpMapManager = new DefaultMapManager<G, A, R, V>(this, key, gridartaObjectsFactory); - editTypes = new EditTypes(tmpMapManager); + editTypes = new EditTypes<G, A, R, V>(tmpMapManager); tmpMapManager.setEditTypes(editTypes); mapManager = tmpMapManager; copyBuffer = new CopyBuffer<G, A, R, V>(this, editTypes, gridartaObjectsFactory); Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBitmask.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBitmask.java 2008-08-06 10:33:08 UTC (rev 4769) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBitmask.java 2008-08-06 17:55:09 UTC (rev 4770) @@ -58,7 +58,7 @@ // fetch the bitmask data, then build the attribute panel final CAttribBitmask bitmask = archetypeTypeSet.getBitmaskTable().get(getMisc()[0]); tmpAttr.setBitmask(bitmask); - cLabel = new JButton(new MaskChangeAL(getNameNew() + ":", tmpAttr)); + cLabel = new JButton(new MaskChangeAL<G, A, R>(getNameNew() + ":", tmpAttr)); input.setBackground(background); input.setEditable(false); input.setBorder(BorderFactory.createLineBorder(Color.gray)); Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java 2008-08-06 10:33:08 UTC (rev 4769) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java 2008-08-06 17:55:09 UTC (rev 4770) @@ -27,6 +27,7 @@ import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.spells.GameObjectSpell; import net.sf.gridarta.spells.NumberSpell; import net.sf.gridarta.spells.Spells; import net.sf.gridarta.treasurelist.CFTreasureListTree; @@ -112,7 +113,7 @@ * The game object spells. */ @NotNull - private final Spells<?> gameObjectSpells; + private final Spells<GameObjectSpell<G, A, R>> gameObjectSpells; /** * The index for no spell. @@ -146,7 +147,7 @@ * @param archetypeTypeSet the archetype types * @param treasureListTree the treasure lists */ - public ArchetypeAttributeParser(final int typeNoEventConnector, final boolean includeFaceText, @NotNull final GlobalSettings globalSettings, @NotNull final FileFilter mapFileFilter, @NotNull final FileFilter scriptFileFilter, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects<?> animationObjects, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<?> gameObjectSpells, final int undefinedSpellIndex, @NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final CFTreasureListTree<G, A, R> treasureListTree) { + public ArchetypeAttributeParser(final int typeNoEventConnector, final boolean includeFaceText, @NotNull final GlobalSettings globalSettings, @NotNull final FileFilter mapFileFilter, @NotNull final FileFilter scriptFileFilter, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects<?> animationObjects, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, final int undefinedSpellIndex, @NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final CFTreasureListTree<G, A, R> treasureListTree) { this.typeNoEventConnector = typeNoEventConnector; this.includeFaceText = includeFaceText; this.globalSettings = globalSettings; @@ -233,7 +234,7 @@ } else if (atype.equalsIgnoreCase("facename")) { return new ArchetypeAttributeFaceName(nameOld, null, nameNew, text, inputLength, null, typeNoEventConnector, faceObjects, includeFaceText); } else if (atype.equalsIgnoreCase("animname")) { - return new ArchetypeAttributeAnimName(nameOld, null, nameNew, text, inputLength, null, typeNoEventConnector, animationObjects, includeFaceText); + return new ArchetypeAttributeAnimName<G, A, R>(nameOld, null, nameNew, text, inputLength, null, typeNoEventConnector, animationObjects, includeFaceText); } else if (atype.equalsIgnoreCase("text")) { // for text data, the terminating string has to be read too final Attr archBeginAttr = root.getAttributeNode(XML_KEY_ARCH_BEGIN); @@ -265,15 +266,15 @@ return null; } nameNew = valueAttr.getValue().trim(); - return new ArchetypeAttributeFixed(nameOld, null, nameNew, text, inputLength, null); + return new ArchetypeAttributeFixed<G, A, R>(nameOld, null, nameNew, text, inputLength, null); } else if (atype.equalsIgnoreCase("spell")) { - return new ArchetypeAttributeSpell(nameOld, null, nameNew, text, inputLength, null, numberSpells, undefinedSpellIndex); + return new ArchetypeAttributeSpell<G, A, R>(nameOld, null, nameNew, text, inputLength, null, numberSpells, undefinedSpellIndex); } else if (atype.equalsIgnoreCase("nz_spell")) { - return new ArchetypeAttributeZSpell(nameOld, null, nameNew, text, inputLength, null, numberSpells, undefinedSpellIndex); + return new ArchetypeAttributeZSpell<G, A, R>(nameOld, null, nameNew, text, inputLength, null, numberSpells, undefinedSpellIndex); } else if (atype.equalsIgnoreCase("inv_spell")) { - return new ArchetypeAttributeInvSpell(nameOld, null, nameNew, text, inputLength, null, gameObjectSpells); + return new ArchetypeAttributeInvSpell<G, A, R>(nameOld, null, nameNew, text, inputLength, null, gameObjectSpells); } else if (atype.equalsIgnoreCase("inv_spell_optional")) { - return new ArchetypeAttributeInvSpellOptional(nameOld, null, nameNew, text, inputLength, null, gameObjectSpells); + return new ArchetypeAttributeInvSpellOptional<G, A, R>(nameOld, null, nameNew, text, inputLength, null, gameObjectSpells); } else if (atype.startsWith("bitmask")) { // got a bitmask attribute final String bitmaskName = atype.substring(8).trim(); @@ -283,7 +284,7 @@ } final String[] misc = new String[1]; misc[0] = bitmaskName; // store bitmask name in misc[0] - return new ArchetypeAttributeBitmask(nameOld, null, nameNew, text, inputLength, misc, archetypeTypeSet); + return new ArchetypeAttributeBitmask<G, A, R>(nameOld, null, nameNew, text, inputLength, misc, archetypeTypeSet); } else if (atype.startsWith("list_")) { // got a bitmask attribute final String listName = atype.substring(5).trim(); @@ -293,7 +294,7 @@ } final String[] misc = new String[1]; misc[0] = listName; // store list name in misc[0] - return new ArchetypeAttributeList(nameOld, null, nameNew, text, inputLength, misc, archetypeTypeSet); + return new ArchetypeAttributeList<G, A, R>(nameOld, null, nameNew, text, inputLength, misc, archetypeTypeSet); } else if (atype.startsWith("doublelist")) { // got a doublelist attribute final String listNames = atype.substring(11).trim(); @@ -313,9 +314,9 @@ final String[] misc = new String[2]; misc[0] = listName1; // store list name in misc[0] misc[1] = listName2; // store list name in misc[1] - return new ArchetypeAttributeDoubleList(nameOld, null, nameNew, text, inputLength, misc, archetypeTypeSet); + return new ArchetypeAttributeDoubleList<G, A, R>(nameOld, null, nameNew, text, inputLength, misc, archetypeTypeSet); } else if (atype.equalsIgnoreCase("treasurelist")) { - return new ArchetypeAttributeTreasure(nameOld, null, nameNew, text, inputLength, null, treasureListTree); + return new ArchetypeAttributeTreasure<G, A, R>(nameOld, null, nameNew, text, inputLength, null, treasureListTree); } else { // unknown type log.warn("In '" + CommonConstants.TYPEDEF_FILE + "': Type " + typeName + " has an attribute with unknown type: '" + atype + "'."); Modified: trunk/src/app/net/sf/gridarta/gui/MainView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-08-06 10:33:08 UTC (rev 4769) +++ trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-08-06 17:55:09 UTC (rev 4770) @@ -391,7 +391,7 @@ * @param objectChooser the object chooser * @param leftPanel the left panel instance */ - public void init(@NotNull final GameObjectAttributesPanel<G, A, R, V> gameObjectAttributesPanel, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, final ArchetypeTypeSet archetypeTypeSet, final boolean mapTileListBottom, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ArchetypeChooserControl<G, A, R, V> archetypeChooserControl, @NotNull final DefaultObjectChooser<G, A, R, V> objectChooser, @NotNull final LeftPanel leftPanel) { + public void init(@NotNull final GameObjectAttributesPanel<G, A, R, V> gameObjectAttributesPanel, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, final ArchetypeTypeSet<G, A, R> archetypeTypeSet, final boolean mapTileListBottom, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ArchetypeChooserControl<G, A, R, V> archetypeChooserControl, @NotNull final DefaultObjectChooser<G, A, R, V> objectChooser, @NotNull final LeftPanel leftPanel) { // calculate some default values in case there is no settings file final Rectangle screen = getGraphicsConfiguration().getBounds(); final int defwidth = (int) (0.9 * screen.getWidth()); Modified: trunk/src/app/net/sf/gridarta/gui/findarchetypes/FindArchetypesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/findarchetypes/FindArchetypesDialog.java 2008-08-06 10:33:08 UTC (rev 4769) +++ trunk/src/app/net/sf/gridarta/gui/findarchetypes/FindArchetypesDialog.java 2008-08-06 17:55:09 UTC (rev 4770) @@ -128,7 +128,7 @@ * search results.# * @param archetypeTypeSet the instance for looking up archetype types */ - public FindArchetypesDialog(final Component parent, final ArchetypeChooserControl<G, A, R, ?> archetypeChooserControl, final ObjectChooser<G, A, R> objectChooser, final ArchetypeTypeSet archetypeTypeSet) { + public FindArchetypesDialog(final Component parent, final ArchetypeChooserControl<G, A, R, ?> archetypeChooserControl, final ObjectChooser<G, A, R> objectChooser, final ArchetypeTypeSet<G, A, R> archetypeTypeSet) { this.archetypeChooserControl = archetypeChooserControl; this.objectChooser = objectChooser; Modified: trunk/src/app/net/sf/gridarta/gui/findarchetypes/TableModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/findarchetypes/TableModel.java 2008-08-06 10:33:08 UTC (rev 4769) +++ trunk/src/app/net/sf/gridarta/gui/findarchetypes/TableModel.java 2008-08-06 17:55:09 UTC (rev 4770) @@ -57,7 +57,7 @@ }; /** The instance for looking up archetype types. */ - private final ArchetypeTypeSet archetypeTypeSet; + private final ArchetypeTypeSet<G, A, R> archetypeTypeSet; /** The model's contents. */ private final List<R> archetypes = new ArrayList<R>(); @@ -97,7 +97,7 @@ * Creates a new instance. * @param archetypeTypeSet the instance for looking up archetype types */ - public TableModel(final ArchetypeTypeSet archetypeTypeSet) { + public TableModel(final ArchetypeTypeSet<G, A, R> archetypeTypeSet) { this.archetypeTypeSet = archetypeTypeSet; } Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-08-06 10:33:08 UTC (rev 4769) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-08-06 17:55:09 UTC (rev 4770) @@ -92,7 +92,7 @@ if (dialogs.containsKey(gameObject)) { dialogs.get(gameObject).toFront(); } else { - final GameObjectAttributesDialog<G, A, R> pane = new GameObjectAttributesDialog(this, archetypeTypeSet, gameObject, parent, archetypeSet, mapManager); + final GameObjectAttributesDialog<G, A, R> pane = new GameObjectAttributesDialog<G, A, R>(this, archetypeTypeSet, gameObject, parent, archetypeSet, mapManager); final JDialog dialog = pane.createDialog(parent, ACTION_FACTORY.getString("attribTitle")); dialog.getRootPane().setDefaultButton(pane.okButton); dialog.setResizable(true); Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/HelpActionListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/HelpActionListener.java 2008-08-06 10:33:08 UTC (rev 4769) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/HelpActionListener.java 2008-08-06 17:55:09 UTC (rev 4770) @@ -17,7 +17,7 @@ private static final Logger log = Logger.getLogger(HelpActionListener.class); /** CFArchAttrib which contains help information. */ - private final ArchetypeAttribute attrib; // attribute structure + private final ArchetypeAttribute<?, ?, ?> attrib; // attribute structure /** The component for help dialogs. */ private final Component parent; @@ -27,7 +27,7 @@ * @param a the gameObject attribute where this help button belongs to * @param parent the parent component for help dialogs */ - public HelpActionListener(final ArchetypeAttribute a, final Component parent) { + public HelpActionListener(final ArchetypeAttribute<?, ?, ?> a, final Component parent) { if (a == null) { throw new NullPointerException("HelpActionListener without context"); } Modified: trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java 2008-08-06 10:33:08 UTC (rev 4769) +++ trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java 2008-08-06 17:55:09 UTC (rev 4770) @@ -289,7 +289,7 @@ } if (archObject != null) { erroneousArchObjects.put(archObject, validationError); - final GameObject topContainer = archObject.getTopContainer(); + final G topContainer = archObject.getTopContainer(); mapGrid.setError(topContainer.getMapX(), topContainer.getMapY()); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-08-06 17:58:56
|
Revision: 4773 http://gridarta.svn.sourceforge.net/gridarta/?rev=4773&view=rev Author: akirschbaum Date: 2008-08-06 17:59:02 +0000 (Wed, 06 Aug 2008) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/daimonin/src/daieditor/gui/map/MapRenderer.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttribute.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeParser.java Modified: trunk/daimonin/src/daieditor/gui/map/MapRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/MapRenderer.java 2008-08-06 17:58:25 UTC (rev 4772) +++ trunk/daimonin/src/daieditor/gui/map/MapRenderer.java 2008-08-06 17:59:02 UTC (rev 4773) @@ -46,8 +46,6 @@ private final ImageIcon emptyTileIcon = SystemIcons.getEmptyTileIcon(); - private final CMainControl mainControl; - @NotNull private final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes; @@ -61,7 +59,6 @@ */ public MapRenderer(final CMainControl mainControl, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, final MapGrid mapGrid, @NotNull final FaceObjects faceObjects) { super(mainControl, mapControl, mapGrid, IGUIConstants.TILE_ISO_XLEN, 2 * IGUIConstants.TILE_ISO_YLEN, faceObjects); - this.mainControl = mainControl; this.editTypes = editTypes; } Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttribute.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttribute.java 2008-08-06 17:58:25 UTC (rev 4772) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttribute.java 2008-08-06 17:59:02 UTC (rev 4773) @@ -45,9 +45,6 @@ /** The width (columns) for input fields like textfields or JChooseBoxes. */ public static final int TEXTFIELD_COLUMNS = 18; - /** Next CFArchAttrib in linked list. */ - private ArchetypeAttribute<G, A, R> next; - /** Original attribute name (from the CF arches). */ @NotNull private final String nameOld; @@ -140,10 +137,6 @@ return inputLength; } - public void setNext(final ArchetypeAttribute<G, A, R> cfAttr) { - next = cfAttr; - } - public abstract GuiInfo<G, A, R> createGui(@NotNull final String nameOld, @NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType type, @NotNull final Color background, final Component parent); /** Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeParser.java 2008-08-06 17:58:25 UTC (rev 4772) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeParser.java 2008-08-06 17:59:02 UTC (rev 4773) @@ -358,16 +358,12 @@ * @param inSection true if this attribute belongs to a (custom-defined) * section * @param section name of the section (only relevant if 'inSection'==true) - * @param attrList linked list of attributes + * @param attrList list of attributes * @param tlist arch type list */ private void parseAttribute(final ArchetypeType archetypeType, final Element elem, final List<String> secNames, final boolean inSection, final String section, final List<ArchetypeAttribute<G, A, R>> attrList, final ArchetypeTypeSet<G, A, R> tlist) { final ArchetypeAttribute<G, A, R> attrib = archetypeAttributeParser.load(elem, tlist, archetypeType.typeName); if (attrib != null) { - // add this attribute to the list: - if (!attrList.isEmpty()) { - attrList.get(attrList.size() - 1).setNext(attrib); - } attrList.add(attrib); // parsing succeeded, now assign this attribute to a section This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-08-06 20:29:03
|
Revision: 4780 http://gridarta.svn.sourceforge.net/gridarta/?rev=4780&view=rev Author: akirschbaum Date: 2008-08-06 20:29:10 +0000 (Wed, 06 Aug 2008) Log Message: ----------- Rename GameObjectAttributesPanel to GameObjectAttributesControl. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java Added Paths: ----------- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java Removed Paths: ------------- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesPanel.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-06 20:18:17 UTC (rev 4779) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-06 20:29:10 UTC (rev 4780) @@ -29,7 +29,7 @@ import cfeditor.gameobject.scripts.ScriptArchEditor; import cfeditor.gameobject.scripts.ScriptArchUtils; import cfeditor.gameobject.scripts.ScriptedEvent; -import cfeditor.gui.GameObjectAttributesPanel; +import cfeditor.gui.GameObjectAttributesControl; import cfeditor.gui.map.CMapViewBasic; import cfeditor.gui.prefs.GUIPrefs; import cfeditor.gui.prefs.ResPrefs; @@ -216,7 +216,7 @@ private final GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory; @NotNull - private final GameObjectAttributesPanel gameObjectAttributesPanel; + private final GameObjectAttributesControl gameObjectAttributesPanel; /** * Constructs the main controller and its model and view. @@ -327,7 +327,7 @@ // Initialize the main view final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, 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); final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel = new GameObjectAttributesModel<GameObject, MapArchObject, Archetype>(); - gameObjectAttributesPanel = new GameObjectAttributesPanel(gameObjectAttributesModel, this, objectChooser, archetypeTypeSet, mapManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); + gameObjectAttributesPanel = new GameObjectAttributesControl(gameObjectAttributesModel, this, objectChooser, archetypeTypeSet, mapManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); PluginParameterFactory.init(archetypeSet, gameObjectAttributesModel, objectChooser, mapManager); final NamedFilterList defaultNamedFilterList = new NamedFilterList(gameObjectMatchers.getFilters()); final CFilterControl filterControl = new CFilterControl(null, mapManager, defaultNamedFilterList); Copied: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java (from rev 4777, trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java) =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java (rev 0) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java 2008-08-06 20:29:10 UTC (rev 4780) @@ -0,0 +1,71 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package cfeditor.gui; + +import cfeditor.gameobject.Archetype; +import cfeditor.gameobject.GameObject; +import cfeditor.gui.map.CMapViewBasic; +import cfeditor.map.MapArchObject; +import java.awt.Frame; +import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; +import net.sf.gridarta.archtype.ArchetypeTypeSet; +import net.sf.gridarta.gameobject.anim.AnimationObjects; +import net.sf.gridarta.gameobject.match.GameObjectMatcher; +import net.sf.gridarta.gui.connectionview.LockedItemsControl; +import net.sf.gridarta.gui.gameobjectattributespanel.AnimationTab; +import net.sf.gridarta.gui.gameobjectattributespanel.ConnectionsTab; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; +import net.sf.gridarta.gui.gameobjectattributespanel.LockedItemsTab; +import net.sf.gridarta.gui.gameobjectattributespanel.MonstersTab; +import net.sf.gridarta.gui.gameobjectattributespanel.MsgTextTab; +import net.sf.gridarta.gui.gameobjectattributespanel.ScriptTab; +import net.sf.gridarta.gui.gameobjectattributespanel.WarningsTab; +import net.sf.gridarta.gui.objectchooser.ObjectChooser; +import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; +import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; +import org.jetbrains.annotations.NotNull; + +/** + * <code>GameObjectAttributesPanel</code> implements the panel that holds + * information about the currently selected GameObject on the map. + * @author <a href="mailto:mic...@no...">Michael Toennies</a> + * @author <a href="mailto:and...@gm...">Andreas Vogl</a> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public final class GameObjectAttributesControl extends net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesControl<GameObject, MapArchObject, Archetype, CMapViewBasic> { + + /** Serial Version UID. */ + private static final long serialVersionUID = 1L; + + /* Build Panel */ + public GameObjectAttributesControl(final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final Frame parent) { + super(gameObjectAttributesModel, mainControl, objectChooser, mapManager, selectedSquareControl); + addTab(new ArchTab(archetypeTypeSet, gameObjectAttributesModel)); + addTab(new MsgTextTab<GameObject, MapArchObject, Archetype>(gameObjectAttributesModel)); + addTab(new ScriptTab<GameObject, MapArchObject, Archetype>(parent, mainControl, gameObjectAttributesModel)); + addTab(new AnimationTab<GameObject, MapArchObject, Archetype>(animationObjects, gameObjectAttributesModel)); + addTab(new ConnectionsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, gameObjectAttributesModel)); + addTab(new LockedItemsTab<GameObject, MapArchObject, Archetype>(lockedItemsControl, gameObjectAttributesModel)); + addTab(new MonstersTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, monsterMatcher, gameObjectAttributesModel)); + addTab(new WarningsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, selectedSquareView, gameObjectAttributesModel)); + } + +} // class GameObjectAttributesControl Property changes on: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:mergeinfo + Added: svn:eol-style + LF Deleted: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-08-06 20:18:17 UTC (rev 4779) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-08-06 20:29:10 UTC (rev 4780) @@ -1,71 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2007 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package cfeditor.gui; - -import cfeditor.gameobject.Archetype; -import cfeditor.gameobject.GameObject; -import cfeditor.gui.map.CMapViewBasic; -import cfeditor.map.MapArchObject; -import java.awt.Frame; -import net.sf.gridarta.MainControl; -import net.sf.gridarta.MapManager; -import net.sf.gridarta.archtype.ArchetypeTypeSet; -import net.sf.gridarta.gameobject.anim.AnimationObjects; -import net.sf.gridarta.gameobject.match.GameObjectMatcher; -import net.sf.gridarta.gui.connectionview.LockedItemsControl; -import net.sf.gridarta.gui.gameobjectattributespanel.AnimationTab; -import net.sf.gridarta.gui.gameobjectattributespanel.ConnectionsTab; -import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; -import net.sf.gridarta.gui.gameobjectattributespanel.LockedItemsTab; -import net.sf.gridarta.gui.gameobjectattributespanel.MonstersTab; -import net.sf.gridarta.gui.gameobjectattributespanel.MsgTextTab; -import net.sf.gridarta.gui.gameobjectattributespanel.ScriptTab; -import net.sf.gridarta.gui.gameobjectattributespanel.WarningsTab; -import net.sf.gridarta.gui.objectchooser.ObjectChooser; -import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; -import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; -import org.jetbrains.annotations.NotNull; - -/** - * <code>GameObjectAttributesPanel</code> implements the panel that holds - * information about the currently selected GameObject on the map. - * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public final class GameObjectAttributesPanel extends net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesPanel<GameObject, MapArchObject, Archetype, CMapViewBasic> { - - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - - /* Build Panel */ - public GameObjectAttributesPanel(final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final Frame parent) { - super(gameObjectAttributesModel, mainControl, objectChooser, mapManager, selectedSquareControl); - addTab(new ArchTab(archetypeTypeSet, gameObjectAttributesModel)); - addTab(new MsgTextTab<GameObject, MapArchObject, Archetype>(gameObjectAttributesModel)); - addTab(new ScriptTab<GameObject, MapArchObject, Archetype>(parent, mainControl, gameObjectAttributesModel)); - addTab(new AnimationTab<GameObject, MapArchObject, Archetype>(animationObjects, gameObjectAttributesModel)); - addTab(new ConnectionsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, gameObjectAttributesModel)); - addTab(new LockedItemsTab<GameObject, MapArchObject, Archetype>(lockedItemsControl, gameObjectAttributesModel)); - addTab(new MonstersTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, monsterMatcher, gameObjectAttributesModel)); - addTab(new WarningsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, selectedSquareView, gameObjectAttributesModel)); - } - -} // class GameObjectAttributesPanel Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-08-06 20:18:17 UTC (rev 4779) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-08-06 20:29:10 UTC (rev 4780) @@ -28,7 +28,7 @@ import daieditor.gameobject.scripts.ScriptArchEditor; import daieditor.gameobject.scripts.ScriptArchUtils; import daieditor.gameobject.scripts.ScriptedEvent; -import daieditor.gui.GameObjectAttributesPanel; +import daieditor.gui.GameObjectAttributesControl; import daieditor.gui.map.CMapViewBasic; import daieditor.gui.prefs.AppPrefs; import daieditor.gui.prefs.DevPrefs; @@ -276,7 +276,7 @@ private final GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory; @NotNull - private final GameObjectAttributesPanel gameObjectAttributesPanel; + private final GameObjectAttributesControl gameObjectAttributesPanel; /** * Constructs the main controller and its model and view. @@ -393,7 +393,7 @@ // Initialize the main view final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, 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); final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel = new GameObjectAttributesModel<GameObject, MapArchObject, Archetype>(); - gameObjectAttributesPanel = new GameObjectAttributesPanel(gameObjectAttributesModel, this, objectChooser, archetypeTypeSet, mapManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); + gameObjectAttributesPanel = new GameObjectAttributesControl(gameObjectAttributesModel, this, objectChooser, archetypeTypeSet, mapManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); final ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChoiceDisplay = new ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, CMapViewBasic>(replaceDialogManager, archetypeTypeSet, objectChooser, archetypeChooserModel, pickmapChooserControl); final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette = new ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic>(editTypes, selectedSquareView, objectChooser, pickmapChooserControl, copyBuffer); final LeftPanel leftPanel = new LeftPanel(objectChooser, toolPalette, objectChoiceDisplay); Copied: trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java (from rev 4777, trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java) =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java (rev 0) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java 2008-08-06 20:29:10 UTC (rev 4780) @@ -0,0 +1,71 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package daieditor.gui; + +import daieditor.gameobject.Archetype; +import daieditor.gameobject.GameObject; +import daieditor.gui.map.CMapViewBasic; +import daieditor.map.MapArchObject; +import java.awt.Frame; +import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; +import net.sf.gridarta.archtype.ArchetypeTypeSet; +import net.sf.gridarta.gameobject.anim.AnimationObjects; +import net.sf.gridarta.gameobject.match.GameObjectMatcher; +import net.sf.gridarta.gui.connectionview.LockedItemsControl; +import net.sf.gridarta.gui.gameobjectattributespanel.AnimationTab; +import net.sf.gridarta.gui.gameobjectattributespanel.ConnectionsTab; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; +import net.sf.gridarta.gui.gameobjectattributespanel.LockedItemsTab; +import net.sf.gridarta.gui.gameobjectattributespanel.MonstersTab; +import net.sf.gridarta.gui.gameobjectattributespanel.MsgTextTab; +import net.sf.gridarta.gui.gameobjectattributespanel.ScriptTab; +import net.sf.gridarta.gui.gameobjectattributespanel.WarningsTab; +import net.sf.gridarta.gui.objectchooser.ObjectChooser; +import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; +import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; +import org.jetbrains.annotations.NotNull; + +/** + * <code>GameObjectAttributesPanel</code> implements the panel that holds + * information about the currently selected GameObject on the map. + * @author <a href="mailto:mic...@no...">Michael Toennies</a> + * @author <a href="mailto:and...@gm...">Andreas Vogl</a> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public final class GameObjectAttributesControl extends net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesControl<GameObject, MapArchObject, Archetype, CMapViewBasic> { + + /** Serial Version UID. */ + private static final long serialVersionUID = 1L; + + /* Build Panel */ + public GameObjectAttributesControl(@NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype>gameObjectAttributesModel, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final Frame parent) { + super(gameObjectAttributesModel, mainControl, objectChooser, mapManager, selectedSquareControl); + addTab(new ArchTab(archetypeTypeSet, gameObjectAttributesModel)); + addTab(new MsgTextTab<GameObject, MapArchObject, Archetype>(gameObjectAttributesModel)); + addTab(new ScriptTab<GameObject, MapArchObject, Archetype>(parent, mainControl, gameObjectAttributesModel)); + addTab(new AnimationTab<GameObject, MapArchObject, Archetype>(animationObjects, gameObjectAttributesModel)); + addTab(new ConnectionsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, gameObjectAttributesModel)); + addTab(new LockedItemsTab<GameObject, MapArchObject, Archetype>(lockedItemsControl, gameObjectAttributesModel)); + addTab(new MonstersTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, monsterMatcher, gameObjectAttributesModel)); + addTab(new WarningsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, selectedSquareView, gameObjectAttributesModel)); + } + +} // class GameObjectAttributesControl Property changes on: trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:mergeinfo + Added: svn:eol-style + LF Deleted: trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-08-06 20:18:17 UTC (rev 4779) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-08-06 20:29:10 UTC (rev 4780) @@ -1,71 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2007 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package daieditor.gui; - -import daieditor.gameobject.Archetype; -import daieditor.gameobject.GameObject; -import daieditor.gui.map.CMapViewBasic; -import daieditor.map.MapArchObject; -import java.awt.Frame; -import net.sf.gridarta.MainControl; -import net.sf.gridarta.MapManager; -import net.sf.gridarta.archtype.ArchetypeTypeSet; -import net.sf.gridarta.gameobject.anim.AnimationObjects; -import net.sf.gridarta.gameobject.match.GameObjectMatcher; -import net.sf.gridarta.gui.connectionview.LockedItemsControl; -import net.sf.gridarta.gui.gameobjectattributespanel.AnimationTab; -import net.sf.gridarta.gui.gameobjectattributespanel.ConnectionsTab; -import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; -import net.sf.gridarta.gui.gameobjectattributespanel.LockedItemsTab; -import net.sf.gridarta.gui.gameobjectattributespanel.MonstersTab; -import net.sf.gridarta.gui.gameobjectattributespanel.MsgTextTab; -import net.sf.gridarta.gui.gameobjectattributespanel.ScriptTab; -import net.sf.gridarta.gui.gameobjectattributespanel.WarningsTab; -import net.sf.gridarta.gui.objectchooser.ObjectChooser; -import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; -import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; -import org.jetbrains.annotations.NotNull; - -/** - * <code>GameObjectAttributesPanel</code> implements the panel that holds - * information about the currently selected GameObject on the map. - * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public final class GameObjectAttributesPanel extends net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesPanel<GameObject, MapArchObject, Archetype, CMapViewBasic> { - - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - - /* Build Panel */ - public GameObjectAttributesPanel(@NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype>gameObjectAttributesModel, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final Frame parent) { - super(gameObjectAttributesModel, mainControl, objectChooser, mapManager, selectedSquareControl); - addTab(new ArchTab(archetypeTypeSet, gameObjectAttributesModel)); - addTab(new MsgTextTab<GameObject, MapArchObject, Archetype>(gameObjectAttributesModel)); - addTab(new ScriptTab<GameObject, MapArchObject, Archetype>(parent, mainControl, gameObjectAttributesModel)); - addTab(new AnimationTab<GameObject, MapArchObject, Archetype>(animationObjects, gameObjectAttributesModel)); - addTab(new ConnectionsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, gameObjectAttributesModel)); - addTab(new LockedItemsTab<GameObject, MapArchObject, Archetype>(lockedItemsControl, gameObjectAttributesModel)); - addTab(new MonstersTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, monsterMatcher, gameObjectAttributesModel)); - addTab(new WarningsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, selectedSquareView, gameObjectAttributesModel)); - } - -} // class GameObjectAttributesPanel Copied: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java (from rev 4777, trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesPanel.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2008-08-06 20:29:10 UTC (rev 4780) @@ -0,0 +1,520 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.gameobjectattributespanel; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.GridLayout; +import java.awt.Toolkit; +import java.util.HashSet; +import java.util.IdentityHashMap; +import java.util.Map; +import java.util.Set; +import java.util.prefs.Preferences; +import javax.swing.Action; +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.JSplitPane; +import javax.swing.JTabbedPane; +import javax.swing.SwingConstants; +import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; +import net.sf.gridarta.MapManagerListener; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.GSplitPane; +import net.sf.gridarta.gui.gameobjecttexteditor.GameObjectTextEditor; +import net.sf.gridarta.gui.map.MapView; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.objectchooser.ObjectChooser; +import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; +import net.sf.gridarta.gui.selectedsquare.SelectedSquareListener; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.map.MapModel; +import net.sf.gridarta.map.MapModelEvent; +import net.sf.gridarta.map.MapModelListener; +import net.sf.gridarta.map.MapSquare; +import net.sf.japi.swing.ActionFactory; +import net.sf.japi.swing.ActionMethod; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Common base class for the panel that allows users to edit a GameObject's + * attributes. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public abstract class GameObjectAttributesControl<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> extends JPanel { + + /** The serial version UID. */ + private static final long serialVersionUID = 1; + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); + + /** The MainControl to use, e.g. for accessing AnimationObjects. */ + private final MainControl<G, A, R, V> mainControl; + + /** + * The game object text editor. + */ + @NotNull + private final GameObjectTextEditor gameObjectTextEditor = new GameObjectTextEditor(); + + /** + * The object chooser instance. + */ + @NotNull + private final ObjectChooser<G, A, R> objectChooser; + + /** The tabs of this GameObjectAttributesPanel. */ + private final JTabbedPane panelDesktop = new JTabbedPane(SwingConstants.TOP); + + /** + * The model used by this controller. + */ + private final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel; + + /** Last known active map. This map has {@link #mapModelListener} attached. */ + @Nullable + private MapControl<G, A, R, V> currentMap; + + /** Preferences. */ + private static final Preferences prefs = Preferences.userNodeForPackage(MainControl.class); + + private static final String MAPARCHPANEL_LOCATION_KEY = "MainWindowMapArchPanel.dividerLocation"; + + private final GSplitPane splitPane; + + private final JPanel mapArchPanel = new JPanel(); + + private final Action aMapArchApply = ACTION_FACTORY.createAction(false, "mapArchApply", this); + + private final Action aMapArchAddInv = ACTION_FACTORY.createAction(false, "mapArchAddInv", this); + + private final Action aMapArchAttrib = ACTION_FACTORY.createAction(false, "mapArchAttrib", this); + + /** + * All active tabs. Tabs not currently visible are missing. The game object + * text editor tab is included. + */ + private final Set<GameObjectAttributesTab<G, A, R>> tabs = new HashSet<GameObjectAttributesTab<G, A, R>>(); + + /** + * Maps tab to index. Tabs not currently visible are missing. The game + * object text editor tab is not included. + */ + private final Map<GameObjectAttributesTab<G, A, R>, Integer> tabIndex = new IdentityHashMap<GameObjectAttributesTab<G, A, R>, Integer>(); + + /** The map manager listener which is attached to {@link #mainControl}. */ + private final MapManagerListener<G, A, R, V> mapManagerListener = new MapManagerListener<G, A, R, V>() { + + /** {@inheritDoc} */ + public void currentMapChanged(@Nullable final MapControl<G, A, R, V> mapControl) { + if (currentMap != null) { + currentMap.getMapModel().removeMapModelListener(mapModelListener); + } + currentMap = mapControl; + if (currentMap != null) { + currentMap.getMapModel().addMapModelListener(mapModelListener); + } + } + + /** {@inheritDoc} */ + public void currentMapViewChanged(@Nullable final MapView<G, A, R, V> mapView) { + // ignore + } + + /** {@inheritDoc} */ + public void mapCreated(@NotNull final MapControl<G, A, R, V> mapControl) { + // ignore + } + + /** {@inheritDoc} */ + public void mapViewCreated(@NotNull final MapView<G, A, R, V> mapView) { + // ignore + } + + /** {@inheritDoc} */ + public void mapClosing(@NotNull final MapControl<G, A, R, V> mapControl) { + // ignore + } + + /** {@inheritDoc} */ + public void mapViewClosing(@NotNull final MapView<G, A, R, V> mapView) { + // ignore + } + + }; + + /** The map model listener which is attached to {@link #currentMap}. */ + private final MapModelListener<G, A, R> mapModelListener = new MapModelListener<G, A, R>() { + + /** {@inheritDoc} */ + public void mapMetaChanged(@NotNull final A mapArchObject) { + // ignore + } + + /** {@inheritDoc} */ + public void mapSizeChanged(final MapModelEvent<G, A, R> e) { + // ignore + } + + /** {@inheritDoc} */ + public void mapSquaresChanged(final MapModelEvent<G, A, R> e) { + final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); + if (selectedGameObject == null) { + return; + } + + final G topGameObject = selectedGameObject.getTopContainer(); + for (final MapSquare<G, A, R> mapSquare : e.getSquares()) { + for (final G gameObject : mapSquare) { + if (gameObject == topGameObject) { + refreshDisplay(); + } + } + } + } + + /** {@inheritDoc} */ + public void mapObjectsChanged(final MapModelEvent<G, A, R> e) { + final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); + for (final G gameObject : e.getGameObjects()) { + if (selectedGameObject == gameObject) { + refreshDisplay(); + } + } + } + + /** {@inheritDoc} */ + public void errorsChanged(@NotNull final MapModel<G, A, R> mapModel) { + // ignore + } + + }; + + /** The listener to detect changes of the selected game object. */ + private final SelectedSquareListener<G, A, R> selectedSquareListener = new SelectedSquareListener<G, A, R>() { + + /** {@inheritDoc} */ + public void selectedGameObjectChanged(@Nullable final G gameObject) { + gameObjectAttributesModel.setSelectedGameObject(gameObject); + } + + }; + + /** + * The listener attached to {@link #gameObjectAttributesModel}. + */ + private final GameObjectAttributesModelListener<G, A, R> gameObjectAttributesModelListener = new GameObjectAttributesModelListener<G, A, R>() { + + /** {@inheritDoc} */ + public void selectedGameObjectChanged(@Nullable final G selectedGameObject) { + refreshDisplay(); + } + + }; + + /** + * The listener attached to all tabs. + */ + private final GameObjectAttributesTabListener<G, A, R> gameObjectAttributesTabListener = new GameObjectAttributesTabListener<G, A, R>() { + + /** {@inheritDoc} */ + public void tabColorChanged(@NotNull final GameObjectAttributesTab<G, A, R> tab, @NotNull final Color tabColor) { + setTabColor(tab, tabColor); + } + + }; + + /** + * Create the GameObjectAttributesPanel. + * @param gameObjectAttributesModel the model to use + * @param mainControl MainControl to use, e.g. for accessing + * AnimationObjects. + * @param objectChooser the object chooser instance + * @param mapManager the map manager instance + * @param selectedSquareControl the selected square control instance + */ + protected GameObjectAttributesControl(@NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel, @NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final SelectedSquareControl<G, A, R, V> selectedSquareControl) { + super(new BorderLayout()); + this.gameObjectAttributesModel = gameObjectAttributesModel; + this.mainControl = mainControl; + this.objectChooser = objectChooser; + + addTabInt(new TextEditorTab<G, A, R>(gameObjectAttributesModel, gameObjectTextEditor)); + + mapArchPanel.setLayout(new BorderLayout()); + splitPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, mapArchPanel, gameObjectTextEditor); + splitPane.setContinuousLayout(true); + splitPane.setResizeWeight(1); + splitPane.setDividerLocation(prefs.getInt(MAPARCHPANEL_LOCATION_KEY, getMapArchPanelLocation())); + add(splitPane, BorderLayout.CENTER); + + final JPanel buttonPanel = createButtonPanel(); + buttonPanel.setLayout(new GridLayout(0, 1)); + mapArchPanel.add(buttonPanel, BorderLayout.WEST); + mapArchPanel.add(panelDesktop, BorderLayout.CENTER); + + selectedSquareControl.addSelectedSquareListener(selectedSquareListener); + gameObjectAttributesModel.addGameObjectAttributesModelListener(gameObjectAttributesModelListener); + + refreshDisplay(); + currentMap = mapManager.getCurrentMap(); + if (currentMap != null) { + currentMap.getMapModel().addMapModelListener(mapModelListener); + } + mapManager.addMapManagerListener(mapManagerListener); + } + + /** + * Adds a tab. + * @param tab the tab to add + */ + public void addTab(final GameObjectAttributesTab<G, A, R> tab) { + tabIndex.put(tab, panelDesktop.getTabCount()); + addTabInt(tab); + panelDesktop.add(tab.getPanel(), tab.getName()); + setTabColor(tab, tab.getTabColor()); + } + + /** + * Adds a tab which is not shown in the tab panel. + * @param tab the tab to add + */ + private void addTabInt(final GameObjectAttributesTab<G, A, R> tab) { + tabs.add(tab); + tab.addGameObjectAttributesTabListener(gameObjectAttributesTabListener); + } + + /** + * Sets the tab color of a tab. + * @param tab the tab + * @param tabColor the tab color + */ + private void setTabColor(final GameObjectAttributesTab<G, A, R> tab, final Color tabColor) { + final Integer index = tabIndex.get(tab); + if (index != null) { + panelDesktop.setForegroundAt(index, tabColor); + } + } + + /** Update the displayed information for the selected game object. */ + private void refreshDisplay() { + final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); + final G gameObject = selectedGameObject == null ? null : selectedGameObject.getHead(); + + aMapArchApply.setEnabled(gameObject != null); + aMapArchAddInv.setEnabled(gameObject != null); + aMapArchAttrib.setEnabled(gameObject != null); + } + + /** Action method for applying the changes made in the arch panel. */ + @ActionMethod + public void mapArchApply() { + final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); + applyArchPanelChanges(selectedGameObject); + } + + /** + * Action method for displaying the attributes of the currently selected + * object. + */ + @ActionMethod + public void mapArchAttrib() { + final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); + mainControl.openAttrDialog(selectedGameObject); + } + + /** + * Action method for adding an object to the inventory of the currently + * selected object. + */ + @ActionMethod + public void mapArchAddInv() { + final G arch = objectChooser.getObjectChooserHighlight(); + if (arch == null) { // nothing selected? + return; + } + + final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); + if (selectedGameObject == null) { + return; + } + + final G inv = selectedGameObject.getHead(); + + final G invnew; + if (arch.isArchetype()) { + // create a new copy of a default arch + invnew = arch.createGameObject(); + } else { + // create clone from a pickmap + invnew = arch.createClone(0, 0); + } + + invnew.setDirection(invnew.getArchetype().getDirection()); + invnew.postParseGameObject(0); + final MapSquare<G, A, R> mapSquare = inv.getMapSquare(); + assert mapSquare != null; + final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); + mapModel.beginTransaction("Add to inventory"); + inv.addLast(invnew); + invnew.setObjectFace(); + mapModel.endTransaction(); + } + + /** + * When the "apply"-button on the ArchPanel (at the bottom of the window) is + * pressed, this function updates the active arch object. + * @param activeArch the currently selected arch + */ + public void applyArchPanelChanges(final G activeArch) { + if (activeArch == null) { + return; + } + + // If the active gameObject is part of a multi, the multi-head's stats + // are taken instead: + final G gameObject = activeArch.getHead(); + + final R archetype = gameObject.getArchetype(); + + final MapSquare<G, A, R> mapSquare = gameObject.getMapSquare(); + assert mapSquare != null; + mapSquare.getMapModel().beginTransaction("Change object attributes"); + + for (final GameObjectAttributesTab<G, A, R> tab : tabs) { + tab.apply(); + } + + /* check we have a face and set the real face obj for fast access */ + final String face = gameObject.getAttributeString("face", false); + // we have a new face name + gameObject.setRealFace(face); + if (gameObject.getAttributeString("animation", false).length() > 0) { + gameObject.setAnimName(gameObject.getAttributeString("animation", false)); + } else { + gameObject.setAnimName(archetype.getAnimName()); + } + + if (gameObject.getAttributeString("direction", false).length() > 0) { + final int dir = gameObject.getAttributeInt("direction", false); + if (archetype.getDirection() != dir) { + gameObject.setDirection(dir); + } + } else { + gameObject.setDirection(archetype.getDirection()); + } + gameObject.setObjectFace(); + + // we look for 'type' in the ArchText. In future maybe type should get + // a separate text field + if (gameObject.getAttributeString("type", false).length() > 0) { + gameObject.setArchTypNr(gameObject.getAttributeInt("type", false)); // specified type + } + + gameObject.updateEditType(gameObject.getMapSquare().getMapModel().getMapControl().getActiveEditType()); + + mapSquare.getMapModel().endTransaction(); + } + + private void applyDirectionChanges(final G gameObject, final int dir) { + gameObjectTextEditor.applyDirectionChanges(dir, gameObject.getArchetype().getDirection()); + applyArchPanelChanges(gameObject); + gameObjectAttributesModel.setSelectedGameObject(gameObject); + } + + /** + * Action proxy for direction. + * @param direction Direction number + */ + private void direction(final int direction) { + final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); + applyDirectionChanges(selectedGameObject, direction); + } + + /** Action method for direction. */ + public void direction0() { + direction(0); + } + + /** Action method for direction. */ + public void direction1() { + direction(1); + } + + /** Action method for direction. */ + public void direction2() { + direction(2); + } + + /** Action method for direction. */ + public void direction3() { + direction(3); + } + + /** Action method for direction. */ + public void direction4() { + direction(4); + } + + /** Action method for direction. */ + public void direction5() { + direction(5); + } + + /** Action method for direction. */ + public void direction6() { + direction(6); + } + + /** Action method for direction. */ + public void direction7() { + direction(7); + } + + /** Action method for direction. */ + public void direction8() { + direction(8); + } + + private JPanel createButtonPanel() { + final JPanel buttonPanel = new JPanel(); + buttonPanel.add(new JButton(aMapArchApply)); + buttonPanel.add(new JButton(aMapArchAddInv)); + buttonPanel.add(new JButton(aMapArchAttrib)); + return buttonPanel; + } + + public void appExitNotify() { + prefs.putInt(MAPARCHPANEL_LOCATION_KEY, splitPane.getDividerLocation()); + } + + // calculate default value in case there is no settings file + private static int getMapArchPanelLocation() { + final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); + return (int) (0.49 * screen.getWidth()); + } + +} // class GameObjectAttributesControl Deleted: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesPanel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesPanel.java 2008-08-06 20:18:17 UTC (rev 4779) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesPanel.java 2008-08-06 20:29:10 UTC (rev 4780) @@ -1,520 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2007 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package net.sf.gridarta.gui.gameobjectattributespanel; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.GridLayout; -import java.awt.Toolkit; -import java.util.HashSet; -import java.util.IdentityHashMap; -import java.util.Map; -import java.util.Set; -import java.util.prefs.Preferences; -import javax.swing.Action; -import javax.swing.JButton; -import javax.swing.JPanel; -import javax.swing.JSplitPane; -import javax.swing.JTabbedPane; -import javax.swing.SwingConstants; -import net.sf.gridarta.MainControl; -import net.sf.gridarta.MapManager; -import net.sf.gridarta.MapManagerListener; -import net.sf.gridarta.gameobject.Archetype; -import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gui.GSplitPane; -import net.sf.gridarta.gui.gameobjecttexteditor.GameObjectTextEditor; -import net.sf.gridarta.gui.map.MapView; -import net.sf.gridarta.gui.map.MapViewBasic; -import net.sf.gridarta.gui.objectchooser.ObjectChooser; -import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; -import net.sf.gridarta.gui.selectedsquare.SelectedSquareListener; -import net.sf.gridarta.map.MapArchObject; -import net.sf.gridarta.map.MapControl; -import net.sf.gridarta.map.MapModel; -import net.sf.gridarta.map.MapModelEvent; -import net.sf.gridarta.map.MapModelListener; -import net.sf.gridarta.map.MapSquare; -import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.ActionMethod; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Common base class for the panel that allows users to edit a GameObject's - * attributes. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public abstract class GameObjectAttributesPanel<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> extends JPanel { - - /** The serial version UID. */ - private static final long serialVersionUID = 1; - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); - - /** The MainControl to use, e.g. for accessing AnimationObjects. */ - private final MainControl<G, A, R, V> mainControl; - - /** - * The game object text editor. - */ - @NotNull - private final GameObjectTextEditor gameObjectTextEditor = new GameObjectTextEditor(); - - /** - * The object chooser instance. - */ - @NotNull - private final ObjectChooser<G, A, R> objectChooser; - - /** The tabs of this GameObjectAttributesPanel. */ - private final JTabbedPane panelDesktop = new JTabbedPane(SwingConstants.TOP); - - /** - * The model used by this controller. - */ - private final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel; - - /** Last known active map. This map has {@link #mapModelListener} attached. */ - @Nullable - private MapControl<G, A, R, V> currentMap; - - /** Preferences. */ - private static final Preferences prefs = Preferences.userNodeForPackage(MainControl.class); - - private static final String MAPARCHPANEL_LOCATION_KEY = "MainWindowMapArchPanel.dividerLocation"; - - private final GSplitPane splitPane; - - private final JPanel mapArchPanel = new JPanel(); - - private final Action aMapArchApply = ACTION_FACTORY.createAction(false, "mapArchApply", this); - - private final Action aMapArchAddInv = ACTION_FACTORY.createAction(false, "mapArchAddInv", this); - - private final Action aMapArchAttrib = ACTION_FACTORY.createAction(false, "mapArchAttrib", this); - - /** - * All active tabs. Tabs not currently visible are missing. The game object - * text editor tab is included. - */ - private final Set<GameObjectAttributesTab<G, A, R>> tabs = new HashSet<GameObjectAttributesTab<G, A, R>>(); - - /** - * Maps tab to index. Tabs not currently visible are missing. The game - * object text editor tab is not included. - */ - private final Map<GameObjectAttributesTab<G, A, R>, Integer> tabIndex = new IdentityHashMap<GameObjectAttributesTab<G, A, R>, Integer>(); - - /** The map manager listener which is attached to {@link #mainControl}. */ - private final MapManagerListener<G, A, R, V> mapManagerListener = new MapManagerListener<G, A, R, V>() { - - /** {@inheritDoc} */ - public void currentMapChanged(@Nullable final MapControl<G, A, R, V> mapControl) { - if (currentMap != null) { - currentMap.getMapModel().removeMapModelListener(mapModelListener); - } - currentMap = mapControl; - if (currentMap != null) { - currentMap.getMapModel().addMapModelListener(mapModelListener); - } - } - - /** {@inheritDoc} */ - public void currentMapViewChanged(@Nullable final MapView<G, A, R, V> mapView) { - // ignore - } - - /** {@inheritDoc} */ - public void mapCreated(@NotNull final MapControl<G, A, R, V> mapControl) { - // ignore - } - - /** {@inheritDoc} */ - public void mapViewCreated(@NotNull final MapView<G, A, R, V> mapView) { - // ignore - } - - /** {@inheritDoc} */ - public void mapClosing(@NotNull final MapControl<G, A, R, V> mapControl) { - // ignore - } - - /** {@inheritDoc} */ - public void mapViewClosing(@NotNull final MapView<G, A, R, V> mapView) { - // ignore - } - - }; - - /** The map model listener which is attached to {@link #currentMap}. */ - private final MapModelListener<G, A, R> mapModelListener = new MapModelListener<G, A, R>() { - - /** {@inheritDoc} */ - public void mapMetaChanged(@NotNull final A mapArchObject) { - // ignore - } - - /** {@inheritDoc} */ - public void mapSizeChanged(final MapModelEvent<G, A, R> e) { - // ignore - } - - /** {@inheritDoc} */ - public void mapSquaresChanged(final MapModelEvent<G, A, R> e) { - final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); - if (selectedGameObject == null) { - return; - } - - final G topGameObject = selectedGameObject.getTopContainer(); - for (final MapSquare<G, A, R> mapSquare : e.getSquares()) { - for (final G gameObject : mapSquare) { - if (gameObject == topGameObject) { - refreshDisplay(); - } - } - } - } - - /** {@inheritDoc} */ - public void mapObjectsChanged(final MapModelEvent<G, A, R> e) { - final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); - for (final G gameObject : e.getGameObjects()) { - if (selectedGameObject == gameObject) { - refreshDisplay(); - } - } - } - - /** {@inheritDoc} */ - public void errorsChanged(@NotNull final MapModel<G, A, R> mapModel) { - // ignore - } - - }; - - /** The listener to detect changes of the selected game object. */ - private final SelectedSquareListener<G, A, R> selectedSquareListener = new SelectedSquareListener<G, A, R>() { - - /** {@inheritDoc} */ - public void selectedGameObjectChanged(@Nullable final G gameObject) { - gameObjectAttributesModel.setSelectedGameObject(gameObject); - } - - }; - - /** - * The listener attached to {@link #gameObjectAttributesModel}. - */ - private final GameObjectAttributesModelListener<G, A, R> gameObjectAttributesModelListener = new GameObjectAttributesModelListener<G, A, R>() { - - /** {@inheritDoc} */ - public void selectedGameObjectChanged(@Nullable final G selectedGameObject) { - refreshDisplay(); - } - - }; - - /** - * The listener attached to all tabs. - */ - private final GameObjectAttributesTabListener<G, A, R> gameObjectAttributesTabListener = new GameObjectAttributesTabListener<G, A, R>() { - - /** {@inheritDoc} */ - public void tabColorChanged(@NotNull final GameObjectAttributesTab<G, A, R> tab, @NotNull final Color tabColor) { - setTabColor(tab, tabColor); - } - - }; - - /** - * Create the GameObjectAttributesPanel. - * @param gameObjectAttributesModel the model to use - * @param mainControl MainControl to use, e.g. for accessing - * AnimationObjects. - * @param objectChooser the object chooser instance - * @param mapManager the map manager instance - * @param selectedSquareControl the selected square control instance - */ - protected GameObjectAttributesPanel(@NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel, @NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final SelectedSquareControl<G, A, R, V> selectedSquareControl) { - super(new BorderLayout()); - this.gameObjectAttributesModel = gameObjectAttributesModel; - this.mainControl = mainControl; - this.objectChooser = objectChooser; - - addTabInt(new TextEditorTab<G, A, R>(gameObjectAttributesModel, gameObjectTextEditor)); - - mapArchPanel.setLayout(new BorderLayout()); - splitPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, mapArchPanel, gameObjectTextEditor); - splitPane.setContinuousLayout(true); - splitPane.setResizeWeight(1); - splitPane.setDividerLocation(prefs.getInt(MAPARCHPANEL_LOCATION_KEY, getMapArchPanelLocation())); - add(splitPane, BorderLayout.CENTER); - - final JPanel buttonPanel = createButtonPanel(); - buttonPanel.setLayout(new GridLayout(0, 1)); - mapArchPanel.add(buttonPanel, BorderLayout.WEST); - mapArchPanel.add(panelDesktop, BorderLayout.CENTER); - - selectedSquareControl.addSelectedSquareListener(selectedSquareListener); - gameObjectAttributesModel.addGameObjectAttributesModelListener(gameObjectAttributesModelListener); - - refreshDisplay(); - currentMap = mapManager.getCurrentMap(); - if (currentMap != null) { - currentMap.getMapModel().addMapModelListener(mapModelListener); - } - mapManager.addMapManagerListener(mapManagerListener); - } - - /** - * Adds a tab. - * @param tab the tab to add - */ - public void addTab(final GameObjectAttributesTab<G, A, R> tab) { - tabIndex.put(tab, panelDesktop.getTabCount()); - addTabInt(tab); - panelDesktop.add(tab.getPanel(), tab.getName()); - setTabColor(tab, tab.getTabColor()); - } - - /** - * Adds a tab which is not shown in the tab panel. - * @param tab the tab to add - */ - private void addTabInt(final GameObjectAttributesTab<G, A, R> tab) { - tabs.add(tab); - tab.addGameObjectAttributesTabListener(gameObjectAttributesTabListener); - } - - /** - * Sets the tab color of a tab. - * @param tab the tab - * @param tabColor the tab color - */ - private void setTabColor(final GameObjectAttributesTab<G, A, R> tab, final Color tabColor) { - final Integer index = tabIndex.get(tab); - if (index != null) { - panelDesktop.setForegroundAt(index, tabColor); - } - } - - /*... [truncated message content] |
From: <aki...@us...> - 2008-08-06 20:30:43
|
Revision: 4781 http://gridarta.svn.sourceforge.net/gridarta/?rev=4781&view=rev Author: akirschbaum Date: 2008-08-06 20:30:52 +0000 (Wed, 06 Aug 2008) Log Message: ----------- Rename field names. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-06 20:29:10 UTC (rev 4780) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-06 20:30:52 UTC (rev 4781) @@ -216,7 +216,7 @@ private final GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory; @NotNull - private final GameObjectAttributesControl gameObjectAttributesPanel; + private final GameObjectAttributesControl gameObjectAttributesControl; /** * Constructs the main controller and its model and view. @@ -327,7 +327,7 @@ // Initialize the main view final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, 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); final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel = new GameObjectAttributesModel<GameObject, MapArchObject, Archetype>(); - gameObjectAttributesPanel = new GameObjectAttributesControl(gameObjectAttributesModel, this, objectChooser, archetypeTypeSet, mapManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); + gameObjectAttributesControl = new GameObjectAttributesControl(gameObjectAttributesModel, this, objectChooser, archetypeTypeSet, mapManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); PluginParameterFactory.init(archetypeSet, gameObjectAttributesModel, objectChooser, mapManager); final NamedFilterList defaultNamedFilterList = new NamedFilterList(gameObjectMatchers.getFilters()); final CFilterControl filterControl = new CFilterControl(null, mapManager, defaultNamedFilterList); @@ -336,7 +336,7 @@ final ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChoiceDisplay = new ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, CMapViewBasic>(replaceDialogManager, archetypeTypeSet, objectChooser, archetypeChooserModel, pickmapChooserControl); final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette = new ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic>(editTypes, selectedSquareView, objectChooser, pickmapChooserControl, copyBuffer); final LeftPanel leftPanel = new LeftPanel(objectChooser, toolPalette, objectChoiceDisplay); - mainView.init(gameObjectAttributesPanel, selectedSquareView, archetypeTypeSet, mapTileListBottom, gameObjectMatchers, archetypeChooserControl, objectChooser, leftPanel); + mainView.init(gameObjectAttributesControl, selectedSquareView, archetypeTypeSet, mapTileListBottom, gameObjectMatchers, archetypeChooserControl, objectChooser, leftPanel); mapActions.updateMenuState(); scriptControl.getView().setMenu((JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "plugins")); final ArchetypeParser archetypeParser = new ArchetypeParser(gridartaObjectsFactory, archetypeChooserControl, animationObjects, archetypeSet); @@ -743,7 +743,7 @@ /** Notifies that the application is about to exit. */ void appExitNotify() { mainView.appExitNotify(); // notify main view - gameObjectAttributesPanel.appExitNotify(); + gameObjectAttributesControl.appExitNotify(); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-08-06 20:29:10 UTC (rev 4780) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-08-06 20:30:52 UTC (rev 4781) @@ -276,7 +276,7 @@ private final GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory; @NotNull - private final GameObjectAttributesControl gameObjectAttributesPanel; + private final GameObjectAttributesControl gameObjectAttributesControl; /** * Constructs the main controller and its model and view. @@ -393,11 +393,11 @@ // Initialize the main view final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, 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); final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel = new GameObjectAttributesModel<GameObject, MapArchObject, Archetype>(); - gameObjectAttributesPanel = new GameObjectAttributesControl(gameObjectAttributesModel, this, objectChooser, archetypeTypeSet, mapManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); + gameObjectAttributesControl = new GameObjectAttributesControl(gameObjectAttributesModel, this, objectChooser, archetypeTypeSet, mapManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); final ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChoiceDisplay = new ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, CMapViewBasic>(replaceDialogManager, archetypeTypeSet, objectChooser, archetypeChooserModel, pickmapChooserControl); final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette = new ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic>(editTypes, selectedSquareView, objectChooser, pickmapChooserControl, copyBuffer); final LeftPanel leftPanel = new LeftPanel(objectChooser, toolPalette, objectChoiceDisplay); - mainView.init(gameObjectAttributesPanel, selectedSquareView, archetypeTypeSet, mapTileListBottom, gameObjectMatchers, archetypeChooserControl, objectChooser, leftPanel); + mainView.init(gameObjectAttributesControl, selectedSquareView, archetypeTypeSet, mapTileListBottom, gameObjectMatchers, archetypeChooserControl, objectChooser, leftPanel); mapActions.updateMenuState(); final ArchetypeParser archetypeParser = new ArchetypeParser(archetypeChooserControl, animationObjects, archetypeSet); gridartaObjectsFactory.init(faceObjects, archetypeChooserModel, selectedSquareView, this, editTypes, mapImageCache, mapActions, archetypeParser, archetypeSet, autojoinLists, toolPalette); @@ -935,7 +935,7 @@ /** Notifies that the application is about to exit. */ void appExitNotify() { mainView.appExitNotify(); // notify main view - gameObjectAttributesPanel.appExitNotify(); + gameObjectAttributesControl.appExitNotify(); } /** {@inheritDoc} */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-08-06 21:10:59
|
Revision: 4782 http://gridarta.svn.sourceforge.net/gridarta/?rev=4782&view=rev Author: akirschbaum Date: 2008-08-06 21:11:04 +0000 (Wed, 06 Aug 2008) Log Message: ----------- Make the direction buttons work again. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/ArchTab.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java trunk/daimonin/src/daieditor/gui/ArchTab.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AbstractGameObjectAttributesTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesTabListener.java Modified: trunk/crossfire/src/cfeditor/gui/ArchTab.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ArchTab.java 2008-08-06 20:30:52 UTC (rev 4781) +++ trunk/crossfire/src/cfeditor/gui/ArchTab.java 2008-08-06 21:11:04 UTC (rev 4782) @@ -24,6 +24,7 @@ import cfeditor.map.MapArchObject; import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; +import net.sf.gridarta.gui.gameobjecttexteditor.GameObjectTextEditor; import org.jetbrains.annotations.NotNull; public class ArchTab extends net.sf.gridarta.gui.gameobjectattributespanel.ArchTab<GameObject, MapArchObject, Archetype> { @@ -32,9 +33,10 @@ * Creates a new instance. * @param archetypeTypeSet the archetype type set * @param gameObjectAttributesModel the model to track + * @param gameObjectTextEditor the game object text editor to modify */ - public ArchTab(@NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel) { - super(archetypeTypeSet, gameObjectAttributesModel); + public ArchTab(@NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final GameObjectTextEditor gameObjectTextEditor) { + super(archetypeTypeSet, gameObjectAttributesModel, gameObjectTextEditor); } /** {@inheritDoc} */ Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java 2008-08-06 20:30:52 UTC (rev 4781) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java 2008-08-06 21:11:04 UTC (rev 4782) @@ -58,7 +58,7 @@ /* Build Panel */ public GameObjectAttributesControl(final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final Frame parent) { super(gameObjectAttributesModel, mainControl, objectChooser, mapManager, selectedSquareControl); - addTab(new ArchTab(archetypeTypeSet, gameObjectAttributesModel)); + addTab(new ArchTab(archetypeTypeSet, gameObjectAttributesModel, gameObjectTextEditor)); addTab(new MsgTextTab<GameObject, MapArchObject, Archetype>(gameObjectAttributesModel)); addTab(new ScriptTab<GameObject, MapArchObject, Archetype>(parent, mainControl, gameObjectAttributesModel)); addTab(new AnimationTab<GameObject, MapArchObject, Archetype>(animationObjects, gameObjectAttributesModel)); Modified: trunk/daimonin/src/daieditor/gui/ArchTab.java =================================================================== --- trunk/daimonin/src/daieditor/gui/ArchTab.java 2008-08-06 20:30:52 UTC (rev 4781) +++ trunk/daimonin/src/daieditor/gui/ArchTab.java 2008-08-06 21:11:04 UTC (rev 4782) @@ -24,6 +24,7 @@ import daieditor.map.MapArchObject; import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; +import net.sf.gridarta.gui.gameobjecttexteditor.GameObjectTextEditor; import org.jetbrains.annotations.NotNull; public class ArchTab extends net.sf.gridarta.gui.gameobjectattributespanel.ArchTab<GameObject, MapArchObject, Archetype> { @@ -32,9 +33,10 @@ * Creates a new instance. * @param archetypeTypeSet the archetype type set * @param gameObjectAttributesModel the model to track + * @param gameObjectTextEditor the game object text editor to modify */ - public ArchTab(@NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel) { - super(archetypeTypeSet, gameObjectAttributesModel); + public ArchTab(@NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final GameObjectTextEditor gameObjectTextEditor) { + super(archetypeTypeSet, gameObjectAttributesModel, gameObjectTextEditor); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java 2008-08-06 20:30:52 UTC (rev 4781) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java 2008-08-06 21:11:04 UTC (rev 4782) @@ -58,7 +58,7 @@ /* Build Panel */ public GameObjectAttributesControl(@NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype>gameObjectAttributesModel, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final Frame parent) { super(gameObjectAttributesModel, mainControl, objectChooser, mapManager, selectedSquareControl); - addTab(new ArchTab(archetypeTypeSet, gameObjectAttributesModel)); + addTab(new ArchTab(archetypeTypeSet, gameObjectAttributesModel, gameObjectTextEditor)); addTab(new MsgTextTab<GameObject, MapArchObject, Archetype>(gameObjectAttributesModel)); addTab(new ScriptTab<GameObject, MapArchObject, Archetype>(parent, mainControl, gameObjectAttributesModel)); addTab(new AnimationTab<GameObject, MapArchObject, Archetype>(animationObjects, gameObjectAttributesModel)); Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AbstractGameObjectAttributesTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AbstractGameObjectAttributesTab.java 2008-08-06 20:30:52 UTC (rev 4781) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AbstractGameObjectAttributesTab.java 2008-08-06 21:11:04 UTC (rev 4782) @@ -135,4 +135,13 @@ */ protected abstract void apply(@Nullable final G gameObject); + /** + * Notify all listeners to apply the changes. + */ + protected void fireApply() { + for (final GameObjectAttributesTabListener<G, A, R> listener : listeners) { + listener.apply(); + } + } + } // class AbstractGameObjectAttributesTab Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java 2008-08-06 20:30:52 UTC (rev 4781) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java 2008-08-06 21:11:04 UTC (rev 4782) @@ -32,6 +32,7 @@ import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.gameobjecttexteditor.GameObjectTextEditor; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.utils.StringUtils; import net.sf.japi.swing.ActionFactory; @@ -55,6 +56,18 @@ @NotNull private final ArchetypeTypeSet<G, A, R> archetypeTypeSet; + /** + * The model to track. + */ + @NotNull + private final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel; + + /** + * The game object text editor to modify. + */ + @NotNull + private final GameObjectTextEditor gameObjectTextEditor; + /** Game object name field. */ private final JTextField archNameField = new JTextField(14); @@ -85,10 +98,13 @@ * Creates a new instance. * @param archetypeTypeSet the archetype type set * @param gameObjectAttributesModel the model to track + * @param gameObjectTextEditor the game object text editor to modify */ - protected ArchTab(@NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel) { + protected ArchTab(@NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel, @NotNull final GameObjectTextEditor gameObjectTextEditor) { super(gameObjectAttributesModel); this.archetypeTypeSet = archetypeTypeSet; + this.gameObjectAttributesModel = gameObjectAttributesModel; + this.gameObjectTextEditor = gameObjectTextEditor; refresh(gameObjectAttributesModel.getSelectedGameObject()); } @@ -311,4 +327,59 @@ protected abstract void appendFaceSource(@NotNull final StringBuilder sb, @NotNull final G gameObject); + /** Action method for direction. */ + public void direction0() { + direction(0); + } + + /** Action method for direction. */ + public void direction1() { + direction(1); + } + + /** Action method for direction. */ + public void direction2() { + direction(2); + } + + /** Action method for direction. */ + public void direction3() { + direction(3); + } + + /** Action method for direction. */ + public void direction4() { + direction(4); + } + + /** Action method for direction. */ + public void direction5() { + direction(5); + } + + /** Action method for direction. */ + public void direction6() { + direction(6); + } + + /** Action method for direction. */ + public void direction7() { + direction(7); + } + + /** Action method for direction. */ + public void direction8() { + direction(8); + } + + /** + * Action proxy for direction. + * @param direction Direction number + */ + private void direction(final int direction) { + final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); + gameObjectTextEditor.applyDirectionChanges(direction, selectedGameObject.getArchetype().getDirection()); + fireApply(); + } + } // class ArchTab Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2008-08-06 20:30:52 UTC (rev 4781) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2008-08-06 21:11:04 UTC (rev 4782) @@ -78,7 +78,7 @@ * The game object text editor. */ @NotNull - private final GameObjectTextEditor gameObjectTextEditor = new GameObjectTextEditor(); + protected final GameObjectTextEditor gameObjectTextEditor = new GameObjectTextEditor(); /** * The object chooser instance. @@ -245,6 +245,12 @@ setTabColor(tab, tabColor); } + /** {@inheritDoc} */ + public void apply() { + final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); + applyArchPanelChanges(selectedGameObject); + } + }; /** @@ -439,66 +445,6 @@ mapSquare.getMapModel().endTransaction(); } - private void applyDirectionChanges(final G gameObject, final int dir) { - gameObjectTextEditor.applyDirectionChanges(dir, gameObject.getArchetype().getDirection()); - applyArchPanelChanges(gameObject); - gameObjectAttributesModel.setSelectedGameObject(gameObject); - } - - /** - * Action proxy for direction. - * @param direction Direction number - */ - private void direction(final int direction) { - final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); - applyDirectionChanges(selectedGameObject, direction); - } - - /** Action method for direction. */ - public void direction0() { - direction(0); - } - - /** Action method for direction. */ - public void direction1() { - direction(1); - } - - /** Action method for direction. */ - public void direction2() { - direction(2); - } - - /** Action method for direction. */ - public void direction3() { - direction(3); - } - - /** Action method for direction. */ - public void direction4() { - direction(4); - } - - /** Action method for direction. */ - public void direction5() { - direction(5); - } - - /** Action method for direction. */ - public void direction6() { - direction(6); - } - - /** Action method for direction. */ - public void direction7() { - direction(7); - } - - /** Action method for direction. */ - public void direction8() { - direction(8); - } - private JPanel createButtonPanel() { final JPanel buttonPanel = new JPanel(); buttonPanel.add(new JButton(aMapArchApply)); Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesTabListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesTabListener.java 2008-08-06 20:30:52 UTC (rev 4781) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesTabListener.java 2008-08-06 21:11:04 UTC (rev 4782) @@ -38,4 +38,9 @@ */ void tabColorChanged(@NotNull GameObjectAttributesTab<G, A, R> tab, @NotNull final Color tabColor); + /** + * Makes the listener apply all tabs. + */ + void apply(); + } // interface GameObjectAttributesTabListener This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-08-07 18:14:43
|
Revision: 4783 http://gridarta.svn.sourceforge.net/gridarta/?rev=4783&view=rev Author: akirschbaum Date: 2008-08-07 18:14:47 +0000 (Thu, 07 Aug 2008) Log Message: ----------- Fix #1816940 ('Game object text editor' should warn of unapplied changes): changes are now automatically applied. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AbstractGameObjectAttributesTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MsgTextTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/TextEditorTab.java trunk/src/app/net/sf/gridarta/gui/gameobjecttexteditor/GameObjectTextEditor.java trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java trunk/src/app/net/sf/gridarta/map/MapTransactionListener.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-08-06 21:11:04 UTC (rev 4782) +++ trunk/crossfire/ChangeLog 2008-08-07 18:14:47 UTC (rev 4783) @@ -1,3 +1,8 @@ +2008-08-07 Andreas Kirschbaum + + * Fix #1816940 ('Game object text editor' should warn of unapplied + changes): changes are now automatically applied. + 2008-08-05 Andreas Kirschbaum * Implement new view for archetype chooser: "Display icons only". Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-08-06 21:11:04 UTC (rev 4782) +++ trunk/daimonin/ChangeLog 2008-08-07 18:14:47 UTC (rev 4783) @@ -1,3 +1,8 @@ +2008-08-07 Andreas Kirschbaum + + * Fix #1816940 ('Game object text editor' should warn of unapplied + changes): changes are now automatically applied. + 2008-08-05 Andreas Kirschbaum * Implement new view for archetype chooser: "Display icons only". Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AbstractGameObjectAttributesTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AbstractGameObjectAttributesTab.java 2008-08-06 21:11:04 UTC (rev 4782) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AbstractGameObjectAttributesTab.java 2008-08-07 18:14:47 UTC (rev 4783) @@ -20,6 +20,9 @@ package net.sf.gridarta.gui.gameobjectattributespanel; import java.awt.Color; +import java.awt.Component; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; import java.util.ArrayList; import java.util.List; import net.sf.gridarta.gameobject.Archetype; @@ -80,6 +83,24 @@ }; /** + * The focus listener to implement auto-applying. See {@link + * #addAutoApply(Component)}. + */ + private final FocusListener focusListener = new FocusListener() { + + /** {@inheritDoc} */ + public void focusGained(final FocusEvent e) { + // ignore + } + + /** {@inheritDoc} */ + public void focusLost(final FocusEvent e) { + fireApply(); + } + + }; + + /** * Creates a new instance. * @param gameObjectAttributesModel the model to track */ @@ -144,4 +165,12 @@ } } + /** + * Registers a component that auto-applies when the focus is lost. + * @param component the component + */ + protected void addAutoApply(@NotNull final Component component) { + component.addFocusListener(focusListener); + } + } // class AbstractGameObjectAttributesTab Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java 2008-08-06 21:11:04 UTC (rev 4782) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java 2008-08-07 18:14:47 UTC (rev 4783) @@ -105,6 +105,7 @@ this.archetypeTypeSet = archetypeTypeSet; this.gameObjectAttributesModel = gameObjectAttributesModel; this.gameObjectTextEditor = gameObjectTextEditor; + addAutoApply(archNameField); refresh(gameObjectAttributesModel.getSelectedGameObject()); } Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2008-08-06 21:11:04 UTC (rev 4782) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2008-08-07 18:14:47 UTC (rev 4783) @@ -53,6 +53,7 @@ import net.sf.gridarta.map.MapModelEvent; import net.sf.gridarta.map.MapModelListener; import net.sf.gridarta.map.MapSquare; +import net.sf.gridarta.map.MapTransactionListener; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; import org.jetbrains.annotations.NotNull; @@ -98,6 +99,11 @@ @Nullable private MapControl<G, A, R, V> currentMap; + /** + * Whether {@link #autoApplyArchPanelChanges()} is currently runnings. + */ + private boolean isInAutoApplyArchPanelChanges = false; + /** Preferences. */ private static final Preferences prefs = Preferences.userNodeForPackage(MainControl.class); @@ -125,6 +131,19 @@ */ private final Map<GameObjectAttributesTab<G, A, R>, Integer> tabIndex = new IdentityHashMap<GameObjectAttributesTab<G, A, R>, Integer>(); + /** + * The currently selected game object. + */ + @Nullable + private G selectedGameObject = null; + + /** + * Records whether a map transaction is active. This is used to prevent + * start recursive map transactions in {@link + * #autoApplyArchPanelChanges()}. + */ + private boolean isInMapTransaction = false; + /** The map manager listener which is attached to {@link #mainControl}. */ private final MapManagerListener<G, A, R, V> mapManagerListener = new MapManagerListener<G, A, R, V>() { @@ -132,10 +151,12 @@ public void currentMapChanged(@Nullable final MapControl<G, A, R, V> mapControl) { if (currentMap != null) { currentMap.getMapModel().removeMapModelListener(mapModelListener); + currentMap.getMapModel().removeMapTransactionListener(mapTransactionListener); } currentMap = mapControl; if (currentMap != null) { currentMap.getMapModel().addMapModelListener(mapModelListener); + currentMap.getMapModel().addMapTransactionListener(mapTransactionListener); } } @@ -181,7 +202,6 @@ /** {@inheritDoc} */ public void mapSquaresChanged(final MapModelEvent<G, A, R> e) { - final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); if (selectedGameObject == null) { return; } @@ -198,7 +218,6 @@ /** {@inheritDoc} */ public void mapObjectsChanged(final MapModelEvent<G, A, R> e) { - final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); for (final G gameObject : e.getGameObjects()) { if (selectedGameObject == gameObject) { refreshDisplay(); @@ -213,6 +232,35 @@ }; + /** + * The map transaction listener which is attached to {@link #currentMap}. + * It triggers auto-apply whenever a map transaction is about to start. + */ + private final MapTransactionListener<G, A, R> mapTransactionListener = new MapTransactionListener<G, A, R>() { + + /** {@inheritDoc} */ + public void preBeginTransaction(@NotNull final MapModel<G, A, R> mapModel) { + autoApplyArchPanelChanges(); + isInMapTransaction = true; + } + + /** {@inheritDoc} */ + public void beginTransaction(@NotNull final MapModel<G, A, R> mapModel, @NotNull final String name) { + // ignore + } + + /** {@inheritDoc} */ + public void endTransaction(@NotNull final MapModel<G, A, R> mapModel) { + // ignore + } + + /** {@inheritDoc} */ + public void postEndTransaction(@NotNull final MapModel<G, A, R> mapModel) { + isInMapTransaction = false; + } + + }; + /** The listener to detect changes of the selected game object. */ private final SelectedSquareListener<G, A, R> selectedSquareListener = new SelectedSquareListener<G, A, R>() { @@ -230,6 +278,8 @@ /** {@inheritDoc} */ public void selectedGameObjectChanged(@Nullable final G selectedGameObject) { + autoApplyArchPanelChanges(); + GameObjectAttributesControl.this.selectedGameObject = selectedGameObject; refreshDisplay(); } @@ -247,8 +297,7 @@ /** {@inheritDoc} */ public void apply() { - final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); - applyArchPanelChanges(selectedGameObject); + autoApplyArchPanelChanges(); } }; @@ -268,8 +317,6 @@ this.mainControl = mainControl; this.objectChooser = objectChooser; - addTabInt(new TextEditorTab<G, A, R>(gameObjectAttributesModel, gameObjectTextEditor)); - mapArchPanel.setLayout(new BorderLayout()); splitPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, mapArchPanel, gameObjectTextEditor); splitPane.setContinuousLayout(true); @@ -283,14 +330,18 @@ mapArchPanel.add(panelDesktop, BorderLayout.CENTER); selectedSquareControl.addSelectedSquareListener(selectedSquareListener); - gameObjectAttributesModel.addGameObjectAttributesModelListener(gameObjectAttributesModelListener); + gameObjectAttributesModel.addGameObjectAttributesModelListener(gameObjectAttributesModelListener); // this listener must be registered before any tab, including TextEditorTab + selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); refreshDisplay(); currentMap = mapManager.getCurrentMap(); if (currentMap != null) { currentMap.getMapModel().addMapModelListener(mapModelListener); + currentMap.getMapModel().addMapTransactionListener(mapTransactionListener); } mapManager.addMapManagerListener(mapManagerListener); + + addTabInt(new TextEditorTab<G, A, R>(gameObjectAttributesModel, gameObjectTextEditor)); } /** @@ -327,19 +378,15 @@ /** Update the displayed information for the selected game object. */ private void refreshDisplay() { - final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); - final G gameObject = selectedGameObject == null ? null : selectedGameObject.getHead(); - - aMapArchApply.setEnabled(gameObject != null); - aMapArchAddInv.setEnabled(gameObject != null); - aMapArchAttrib.setEnabled(gameObject != null); + aMapArchApply.setEnabled(selectedGameObject != null); + aMapArchAddInv.setEnabled(selectedGameObject != null); + aMapArchAttrib.setEnabled(selectedGameObject != null); } /** Action method for applying the changes made in the arch panel. */ @ActionMethod public void mapArchApply() { - final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); - applyArchPanelChanges(selectedGameObject); + applyArchPanelChanges(); } /** @@ -348,8 +395,9 @@ */ @ActionMethod public void mapArchAttrib() { - final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); - mainControl.openAttrDialog(selectedGameObject); + if (selectedGameObject != null) { + mainControl.openAttrDialog(selectedGameObject); + } } /** @@ -363,7 +411,6 @@ return; } - final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); if (selectedGameObject == null) { return; } @@ -391,23 +438,42 @@ } /** + * Same as {@link #applyArchPanelChanges()} but does protect against + * recursive calls. + */ + private void autoApplyArchPanelChanges() { + if (selectedGameObject == null || isInAutoApplyArchPanelChanges || isInMapTransaction) { + return; + } + + isInAutoApplyArchPanelChanges = true; + try { + applyArchPanelChanges(); + } finally { + isInAutoApplyArchPanelChanges = false; + } + } + + /** * When the "apply"-button on the ArchPanel (at the bottom of the window) is * pressed, this function updates the active arch object. - * @param activeArch the currently selected arch */ - public void applyArchPanelChanges(final G activeArch) { - if (activeArch == null) { + private void applyArchPanelChanges() { + if (selectedGameObject == null) { return; } // If the active gameObject is part of a multi, the multi-head's stats // are taken instead: - final G gameObject = activeArch.getHead(); + final G gameObject = selectedGameObject.getHead(); final R archetype = gameObject.getArchetype(); final MapSquare<G, A, R> mapSquare = gameObject.getMapSquare(); - assert mapSquare != null; + if (mapSquare == null) { + // auto-apply of deleted game object + return; + } mapSquare.getMapModel().beginTransaction("Change object attributes"); for (final GameObjectAttributesTab<G, A, R> tab : tabs) { Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MsgTextTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MsgTextTab.java 2008-08-06 21:11:04 UTC (rev 4782) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MsgTextTab.java 2008-08-07 18:14:47 UTC (rev 4783) @@ -52,6 +52,7 @@ public MsgTextTab(@NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel) { super(gameObjectAttributesModel); archTextArea.setLineWrap(true); + addAutoApply(archTextArea); refresh(gameObjectAttributesModel.getSelectedGameObject()); } Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/TextEditorTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/TextEditorTab.java 2008-08-06 21:11:04 UTC (rev 4782) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/TextEditorTab.java 2008-08-07 18:14:47 UTC (rev 4783) @@ -47,6 +47,7 @@ protected TextEditorTab(@NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel, @NotNull final GameObjectTextEditor gameObjectTextEditor) { super(gameObjectAttributesModel); this.gameObjectTextEditor = gameObjectTextEditor; + addAutoApply(gameObjectTextEditor.getTextPane()); } /** {@inheritDoc} */ @@ -72,7 +73,9 @@ /** {@inheritDoc} */ @Override protected void apply(@Nullable final G gameObject) { - gameObjectTextEditor.applyChanges(gameObject); + if (gameObject != null) { + gameObjectTextEditor.applyChanges(gameObject); + } } } // class TextEditorTab Modified: trunk/src/app/net/sf/gridarta/gui/gameobjecttexteditor/GameObjectTextEditor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjecttexteditor/GameObjectTextEditor.java 2008-08-06 21:11:04 UTC (rev 4782) +++ trunk/src/app/net/sf/gridarta/gui/gameobjecttexteditor/GameObjectTextEditor.java 2008-08-07 18:14:47 UTC (rev 4783) @@ -100,4 +100,12 @@ } } + /** + * Returns the text input pane. + * @return the text input pane + */ + public JTextPane getTextPane() { + return archEdit; + } + } // class GameObjectTextEditor Modified: trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java 2008-08-06 21:11:04 UTC (rev 4782) +++ trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java 2008-08-07 18:14:47 UTC (rev 4783) @@ -85,6 +85,11 @@ private UndoModel<G, A, R> undoModel = null; /** {@inheritDoc} */ + public void preBeginTransaction(@NotNull final MapModel<G, A, R> mapModel) { + // ignore + } + + /** {@inheritDoc} */ public void beginTransaction(@NotNull final MapModel<G, A, R> mapModel, @NotNull final String name) { undoModel = undoModels.get(mapModel); undoState = undoModel.isEnabled() ? new UndoState<G, A, R>(name, mapModel) : null; @@ -114,6 +119,11 @@ refreshMenus(); } + /** {@inheritDoc} */ + public void postEndTransaction(@NotNull final MapModel<G, A, R> mapModel) { + // ignore + } + }; /** Listener to be notified for created/deleted maps. */ Modified: trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-08-06 21:11:04 UTC (rev 4782) +++ trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-08-07 18:14:47 UTC (rev 4783) @@ -388,9 +388,10 @@ /** {@inheritDoc} */ public void beginTransaction(@NotNull final String name) { if (transactionDepth == 0) { + firePreBeginTransaction(); transactionName = name; transactionThread = Thread.currentThread(); - + transactionDepth++; fireBeginTransaction(name); } else { // == is okay for threads. @@ -398,8 +399,8 @@ if (transactionThread != Thread.currentThread()) { throw new IllegalStateException("A transaction must only be used by one thread."); } + transactionDepth++; } - transactionDepth++; } /** {@inheritDoc} */ @@ -451,6 +452,7 @@ transactionThread = null; fireEvents(); fireEndTransaction(); + firePostEndTransaction(); } /** {@inheritDoc} */ @@ -500,6 +502,15 @@ } /** + * Fire a pre-begin transaction event. + */ + private void firePreBeginTransaction() { + for (final MapTransactionListener<G, A, R> listener : listenerList.getListeners(MapTransactionListener.class)) { + listener.preBeginTransaction(this); + } + } + + /** * Fire a begin transaction event. * @param name the transaction name */ @@ -517,6 +528,15 @@ } /** + * Fire a post-end transaction event. + */ + private void firePostEndTransaction() { + for (final MapTransactionListener<G, A, R> listener : listenerList.getListeners(MapTransactionListener.class)) { + listener.postEndTransaction(this); + } + } + + /** * This method checks whether the map is rectangular. A map always MUST be * rectangular, this method can be used for assertions regarding this * assumption. The check for rectangularity is a check whether the array Modified: trunk/src/app/net/sf/gridarta/map/MapTransactionListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapTransactionListener.java 2008-08-06 21:11:04 UTC (rev 4782) +++ trunk/src/app/net/sf/gridarta/map/MapTransactionListener.java 2008-08-07 18:14:47 UTC (rev 4783) @@ -31,6 +31,12 @@ public interface MapTransactionListener<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends EventListener { /** + * A map transaction is about to start. + * @param mapModel the map model + */ + void preBeginTransaction(@NotNull final MapModel<G, A, R> mapModel); + + /** * A map transaction has started. * @param mapModel the map model * @param name the transaction name @@ -43,4 +49,10 @@ */ void endTransaction(@NotNull MapModel<G, A, R> mapModel); + /** + * A map transaction has been finished. + * @param mapModel the map model + */ + void postEndTransaction(@NotNull final MapModel<G, A, R> mapModel); + } // interface MapTransactionListener This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-08-08 18:50:21
|
Revision: 4803 http://gridarta.svn.sourceforge.net/gridarta/?rev=4803&view=rev Author: akirschbaum Date: 2008-08-08 18:50:21 +0000 (Fri, 08 Aug 2008) Log Message: ----------- Replace assert statement with @NotNull annotation. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/crossfire/src/cfeditor/gui/map/MapRenderer.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gameobject/GameObject.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-08 18:32:52 UTC (rev 4802) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-08 18:50:21 UTC (rev 4803) @@ -229,7 +229,6 @@ ScriptedEventEditor.setGlobalSettings(globalSettings); final AnimationObjects<AnimationObject> animationObjects = new cfeditor.gameobject.anim.AnimationObjects(); archetypeSet = new ArchetypeSet(this, globalSettings, editTypes, animationObjects, faceObjects, ((GlobalSettingsImpl) globalSettings).getImageSet(), gridartaObjectsFactory); - GameObject.setArchetypeSet(archetypeSet); ScriptedEvent.setArchetypeSet(archetypeSet); final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, MainView.MAP_TILE_LIST_BOTTOM_DEFAULT); ACTION_FACTORY.createActions(true, this, "createNew", "open", "options", "exit", "newScript", "editScript", "zoom", "gc", "onlineHelp", "tod", "about"); @@ -249,6 +248,7 @@ replaceDialogManager.setObjectChooser(objectChooser); mainActions = new MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(replaceDialogManager, this, editTypes, archetypeSet, copyBuffer, pickmapChooserControl, animationObjects, ACTION_FACTORY, faceObjects, objectChooser, mapManager); SystemIcons.init(); + GameObject.setArchetypeSet(archetypeSet, SystemIcons.getNofaceTileIcon()); createMapImageCache(CResourceLoader.getHomeFile("thumbnails"), SystemIcons.getDefaultIcon(), SystemIcons.getDefaultPreview(), new StatusBar<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, archetypeSet, faceObjects)); mainView = new MainView<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, editTypes, mapManager, ACTION_FACTORY, mapManagerActions.getCloseAllAction(), statusBar); new About("cfeditor", mainView); Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-08-08 18:32:52 UTC (rev 4802) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-08-08 18:50:21 UTC (rev 4803) @@ -64,13 +64,18 @@ private ScriptArchData scriptArchData = new ScriptArchData(this); /** The normal face. */ - private ImageIcon normalFace; + @NotNull + private ImageIcon normalFace = noFace; @Nullable private static ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet = null; - public static void setArchetypeSet(@Nullable final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { + @Nullable + private static ImageIcon noFace = null; + + public static void setArchetypeSet(@Nullable final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ImageIcon noFace) { GameObject.archetypeSet = archetypeSet; + GameObject.noFace = noFace; } /** {@inheritDoc} */ @@ -127,6 +132,7 @@ * Returns the normal face for this GameObject. * @return The normal face for this GameObject. */ + @NotNull public ImageIcon getNormalImage() { return normalFace; } Modified: trunk/crossfire/src/cfeditor/gui/map/MapRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapRenderer.java 2008-08-08 18:32:52 UTC (rev 4802) +++ trunk/crossfire/src/cfeditor/gui/map/MapRenderer.java 2008-08-08 18:50:21 UTC (rev 4803) @@ -189,7 +189,6 @@ continue; } final ImageIcon img = node.getNormalImage(); - assert img != null; if (!node.isMulti() || (img.getIconWidth() == 32 && img.getIconHeight() == 32)) { offset.x = 0; offset.y = 0; Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-08-08 18:32:52 UTC (rev 4802) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-08-08 18:50:21 UTC (rev 4803) @@ -288,7 +288,6 @@ ScriptArchEditor.setGlobalSettings(globalSettings, this); ScriptedEventEditor.setGlobalSettings(globalSettings); final AnimationObjects<AnimationObject> animationObjects = new daieditor.gameobject.anim.AnimationObjects(); - GameObject.setAnimationObjects(animationObjects); archetypeSet = new ArchetypeSet(this, globalSettings, editTypes, animationObjects, faceObjects, gridartaObjectsFactory); GameObject.setArchetypeSet(archetypeSet); ScriptedEvent.setArchetypeSet(archetypeSet); @@ -312,6 +311,7 @@ replaceDialogManager.setObjectChooser(objectChooser); mainActions = new MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(replaceDialogManager, this, editTypes, archetypeSet, copyBuffer, pickmapChooserControl, animationObjects, ACTION_FACTORY, faceObjects, objectChooser, mapManager); SystemIcons.init(); + GameObject.setAnimationObjects(animationObjects, SystemIcons.getNofaceTileIcon()); createMapImageCache(null, SystemIcons.getDefaultIcon(), SystemIcons.getDefaultPreview(), new StatusBar<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, archetypeSet, faceObjects)); mainView = new MainView<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, editTypes, mapManager, ACTION_FACTORY, mapManagerActions.getCloseAllAction(), statusBar); new About("daieditor", mainView); Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-08-08 18:32:52 UTC (rev 4802) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-08-08 18:50:21 UTC (rev 4803) @@ -88,13 +88,19 @@ private boolean noface; /** The normal face. */ - private ImageIcon normalFace; + @NotNull + private ImageIcon normalFace = noFace; /** The transparent face. */ - private ImageIcon transFace; + @NotNull + private ImageIcon transFace = noFace; - public static void setAnimationObjects(@Nullable final AnimationObjects<AnimationObject> animationObjects) { + @Nullable + private static ImageIcon noFace = null; + + public static void setAnimationObjects(@Nullable final AnimationObjects<AnimationObject> animationObjects, @NotNull final ImageIcon noFace) { GameObject.animationObjects = animationObjects; + GameObject.noFace = noFace; } @Nullable @@ -270,6 +276,7 @@ * Returns the normal face for this GameObject. * @return The normal face for this GameObject. */ + @NotNull public ImageIcon getNormalImage() { return normalFace; } @@ -278,6 +285,7 @@ * Returns a transparent variant of the face for this GameObject. * @return The transparent face for this GameObject. */ + @NotNull public ImageIcon getTransparentImage() { return transFace; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-08-08 19:12:37
|
Revision: 4804 http://gridarta.svn.sourceforge.net/gridarta/?rev=4804&view=rev Author: akirschbaum Date: 2008-08-08 19:12:37 +0000 (Fri, 08 Aug 2008) Log Message: ----------- Fix crash in CrossfireEditor when using undo/redo with multi-tile objects. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gameobject/GameObject.java Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-08-08 18:50:21 UTC (rev 4803) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-08-08 19:12:37 UTC (rev 4804) @@ -212,7 +212,7 @@ @Override public GameObject createMultiClone(final int posx, final int posy) { final GameObject newHead = createClone(posx, posy); - for (GameObject tmp = getArchetype().getMultiNext(); tmp != null; tmp = tmp.getMultiNext()) { + for (GameObject tmp = getMultiNext(); tmp != null; tmp = tmp.getMultiNext()) { newHead.addTailPart(tmp.createClone(posx + tmp.getMultiX(), posy + tmp.getMultiY())); } if (newHead.multi != null) { Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-08-08 18:50:21 UTC (rev 4803) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-08-08 19:12:37 UTC (rev 4804) @@ -362,7 +362,7 @@ @Override public GameObject createMultiClone(final int posx, final int posy) { final GameObject newHead = createClone(posx, posy); - for (GameObject tmp = getArchetype().getMultiNext(); tmp != null; tmp = tmp.getMultiNext()) { + for (GameObject tmp = getMultiNext(); tmp != null; tmp = tmp.getMultiNext()) { newHead.addTailPart(tmp.createClone(posx + tmp.getMultiX(), posy + tmp.getMultiY())); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-08-08 19:19:25
|
Revision: 4805 http://gridarta.svn.sourceforge.net/gridarta/?rev=4805&view=rev Author: akirschbaum Date: 2008-08-08 19:19:25 +0000 (Fri, 08 Aug 2008) Log Message: ----------- Move code to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-08 19:12:37 UTC (rev 4804) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-08 19:19:25 UTC (rev 4805) @@ -603,14 +603,7 @@ /** {@inheritDoc} */ public void openAttrDialog(final GameObject gameObject) { - if (archetypeTypeSet.isEmpty()) { - // types.xml is missing! - ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoTypes"); - } else if (gameObject != null && !gameObject.hasUndefinedArchetype()) { - gameObjectAttributesDialogFactory.showAttribDialog(gameObject); - } else { - ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoDefaultArch"); - } + gameObjectAttributesDialogFactory.showAttribDialog(gameObject); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-08-08 19:12:37 UTC (rev 4804) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-08-08 19:19:25 UTC (rev 4805) @@ -788,14 +788,7 @@ /** {@inheritDoc} */ public void openAttrDialog(final GameObject gameObject) { - if (archetypeTypeSet.isEmpty()) { - // types.xml is missing! - ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoTypes"); - } else if (gameObject != null && !gameObject.hasUndefinedArchetype()) { - gameObjectAttributesDialogFactory.showAttribDialog(gameObject); - } else { - ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoDefaultArch"); - } + gameObjectAttributesDialogFactory.showAttribDialog(gameObject); } /** {@inheritDoc} */ Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-08-08 19:12:37 UTC (rev 4804) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-08-08 19:19:25 UTC (rev 4805) @@ -88,6 +88,17 @@ * @param gameObject the GameObject to be displayed by this dialog */ public void showAttribDialog(@NotNull final G gameObject) { + if (archetypeTypeSet.isEmpty()) { + // types.xml is missing! + ACTION_FACTORY.showMessageDialog(parent, "openAttrDialogNoTypes"); + return; + } + + if (gameObject == null || gameObject.hasUndefinedArchetype()) { + ACTION_FACTORY.showMessageDialog(parent, "openAttrDialogNoDefaultArch"); + return; + } + synchronized (dialogs) { if (dialogs.containsKey(gameObject)) { dialogs.get(gameObject).toFront(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-08-08 20:03:15
|
Revision: 4806 http://gridarta.svn.sourceforge.net/gridarta/?rev=4806&view=rev Author: akirschbaum Date: 2008-08-08 20:03:10 +0000 (Fri, 08 Aug 2008) Log Message: ----------- Remove MainControl.openAttrDialog(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java trunk/src/app/net/sf/gridarta/MainControl.java trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserView.java trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypePanel.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java trunk/src/app/net/sf/gridarta/gui/map/MapCursorControl.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-08 19:19:25 UTC (rev 4805) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-08 20:03:10 UTC (rev 4806) @@ -235,22 +235,25 @@ final MapManagerActions<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager); PathManager.setGlobalSettings(globalSettings); final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel = new ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeSet); - final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl = new ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, false, archetypeChooserModel); + final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl = new ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeChooserModel); newMapDialogFactory = new NewMapDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, mapManager, gridartaObjectsFactory, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPSIZE, 0, false, false, IGUIConstants.DEF_PICKMAP_WIDTH, IGUIConstants.DEF_PICKMAP_HEIGHT); pickmapChooserControl = new PickmapChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(newMapDialogFactory, this, gridartaObjectsFactory, new File(globalSettings.getMapDir(), IGUIConstants.PICKMAP_DIR), mapManager); newMapDialogFactory.setPickmapChooserControl(pickmapChooserControl); archetypeTypeSet = new ArchetypeTypeSet<GameObject, MapArchObject, Archetype>(); final ReplaceDialogManager<GameObject, MapArchObject, Archetype, CMapViewBasic> replaceDialogManager = new ReplaceDialogManager<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, archetypeSet, copyBuffer); + gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeTypeSet, archetypeSet, mapManager); + archetypeChooserControl.init(false, gameObjectAttributesDialogFactory); objectChooser = new DefaultObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeChooserControl, pickmapChooserControl); - final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(ACTION_FACTORY, this, objectChooser, mapManager, editTypes, mapTileListBottom, null, archetypeSet); + final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(ACTION_FACTORY, gameObjectAttributesDialogFactory, objectChooser, mapManager, editTypes, mapTileListBottom, null, archetypeSet); final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView = selectedSquareControl.getSelectedSquareView(); - new MapCursorControl<GameObject, MapArchObject, Archetype, CMapViewBasic>("cfeditor", this, mapManager, selectedSquareControl, selectedSquareView); + new MapCursorControl<GameObject, MapArchObject, Archetype, CMapViewBasic>("cfeditor", this, gameObjectAttributesDialogFactory, mapManager, selectedSquareControl, selectedSquareView); replaceDialogManager.setObjectChooser(objectChooser); mainActions = new MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(replaceDialogManager, this, editTypes, archetypeSet, copyBuffer, pickmapChooserControl, animationObjects, ACTION_FACTORY, faceObjects, objectChooser, mapManager); SystemIcons.init(); GameObject.setArchetypeSet(archetypeSet, SystemIcons.getNofaceTileIcon()); createMapImageCache(CResourceLoader.getHomeFile("thumbnails"), SystemIcons.getDefaultIcon(), SystemIcons.getDefaultPreview(), new StatusBar<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, archetypeSet, faceObjects)); mainView = new MainView<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, editTypes, mapManager, ACTION_FACTORY, mapManagerActions.getCloseAllAction(), statusBar); + gameObjectAttributesDialogFactory.setParent(mainView); new About("cfeditor", mainView); new UndoControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager); updaterManager = new UpdaterManager("cfeditor", this, mapManager, mainView, "CrossfireEditor.jar"); @@ -327,7 +330,7 @@ // Initialize the main view final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, 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); final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel = new GameObjectAttributesModel<GameObject, MapArchObject, Archetype>(); - gameObjectAttributesControl = new GameObjectAttributesControl(gameObjectAttributesModel, this, objectChooser, archetypeTypeSet, mapManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); + gameObjectAttributesControl = new GameObjectAttributesControl(gameObjectAttributesModel, this, gameObjectAttributesDialogFactory, objectChooser, archetypeTypeSet, mapManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); PluginParameterFactory.init(archetypeSet, gameObjectAttributesModel, objectChooser, mapManager); final NamedFilterList defaultNamedFilterList = new NamedFilterList(gameObjectMatchers.getFilters()); final CFilterControl filterControl = new CFilterControl(null, mapManager, defaultNamedFilterList); @@ -383,7 +386,6 @@ recentManager.initRecent(); validators = createMapValidators(); new AutoValidator<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, mapManager, PREFS_VALIDATOR_AUTO_DEFAULT); - gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeTypeSet, mainView, archetypeSet, mapManager); } /** @@ -602,11 +604,6 @@ } /** {@inheritDoc} */ - public void openAttrDialog(final GameObject gameObject) { - gameObjectAttributesDialogFactory.showAttribDialog(gameObject); - } - - /** {@inheritDoc} */ public boolean saveLevelAsWanted(@NotNull final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl) { final JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle("Save Level File As"); Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java 2008-08-08 19:19:25 UTC (rev 4805) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java 2008-08-08 20:03:10 UTC (rev 4806) @@ -30,6 +30,7 @@ import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.connectionview.LockedItemsControl; +import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; import net.sf.gridarta.gui.gameobjectattributespanel.AnimationTab; import net.sf.gridarta.gui.gameobjectattributespanel.ConnectionsTab; import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; @@ -56,8 +57,8 @@ private static final long serialVersionUID = 1L; /* Build Panel */ - public GameObjectAttributesControl(final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final Frame parent) { - super(gameObjectAttributesModel, mainControl, objectChooser, mapManager, selectedSquareControl); + public GameObjectAttributesControl(final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final Frame parent) { + super(gameObjectAttributesModel, gameObjectAttributesDialogFactory, objectChooser, mapManager, selectedSquareControl); addTab(new ArchTab(archetypeTypeSet, gameObjectAttributesModel, gameObjectTextEditor)); addTab(new MsgTextTab<GameObject, MapArchObject, Archetype>(gameObjectAttributesModel)); addTab(new ScriptTab<GameObject, MapArchObject, Archetype>(parent, mainControl, gameObjectAttributesModel)); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-08-08 19:19:25 UTC (rev 4805) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-08-08 20:03:10 UTC (rev 4806) @@ -298,22 +298,25 @@ final MapManagerActions<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager); PathManager.setGlobalSettings(globalSettings); final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel = new ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeSet); - final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl = new ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, true, archetypeChooserModel); + final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl = new ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeChooserModel); newMapDialogFactory = new NewMapDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, mapManager, gridartaObjectsFactory, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPDIFFICULTY, true, true, IGUIConstants.DEF_PICKMAP_WIDTH, IGUIConstants.DEF_PICKMAP_HEIGHT); pickmapChooserControl = new PickmapChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(newMapDialogFactory, this, gridartaObjectsFactory, new File(globalSettings.getArchDefaultFolder(), IGUIConstants.PICKMAP_DIR), mapManager); newMapDialogFactory.setPickmapChooserControl(pickmapChooserControl); archetypeTypeSet = new ArchetypeTypeSet<GameObject, MapArchObject, Archetype>(); final ReplaceDialogManager<GameObject, MapArchObject, Archetype, CMapViewBasic> replaceDialogManager = new ReplaceDialogManager<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, archetypeSet, copyBuffer); + gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeTypeSet, archetypeSet, mapManager); + archetypeChooserControl.init(true, gameObjectAttributesDialogFactory); objectChooser = new DefaultObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeChooserControl, pickmapChooserControl); - final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(ACTION_FACTORY, this, objectChooser, mapManager, editTypes, mapTileListBottom, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), archetypeSet); + final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(ACTION_FACTORY, gameObjectAttributesDialogFactory, objectChooser, mapManager, editTypes, mapTileListBottom, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), archetypeSet); final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView = selectedSquareControl.getSelectedSquareView(); - new MapCursorControl<GameObject, MapArchObject, Archetype, CMapViewBasic>("daieditor", this, mapManager, selectedSquareControl, selectedSquareView); + new MapCursorControl<GameObject, MapArchObject, Archetype, CMapViewBasic>("daieditor", this, gameObjectAttributesDialogFactory, mapManager, selectedSquareControl, selectedSquareView); replaceDialogManager.setObjectChooser(objectChooser); mainActions = new MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(replaceDialogManager, this, editTypes, archetypeSet, copyBuffer, pickmapChooserControl, animationObjects, ACTION_FACTORY, faceObjects, objectChooser, mapManager); SystemIcons.init(); GameObject.setAnimationObjects(animationObjects, SystemIcons.getNofaceTileIcon()); createMapImageCache(null, SystemIcons.getDefaultIcon(), SystemIcons.getDefaultPreview(), new StatusBar<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, archetypeSet, faceObjects)); mainView = new MainView<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, editTypes, mapManager, ACTION_FACTORY, mapManagerActions.getCloseAllAction(), statusBar); + gameObjectAttributesDialogFactory.setParent(mainView); new About("daieditor", mainView); new UndoControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager); updaterManager = new UpdaterManager("daieditor", this, mapManager, mainView, "DaimoninEditor.jar"); @@ -393,7 +396,7 @@ // Initialize the main view final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, 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); final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel = new GameObjectAttributesModel<GameObject, MapArchObject, Archetype>(); - gameObjectAttributesControl = new GameObjectAttributesControl(gameObjectAttributesModel, this, objectChooser, archetypeTypeSet, mapManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); + gameObjectAttributesControl = new GameObjectAttributesControl(gameObjectAttributesModel, this, gameObjectAttributesDialogFactory, objectChooser, archetypeTypeSet, mapManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); final ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChoiceDisplay = new ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, CMapViewBasic>(replaceDialogManager, archetypeTypeSet, objectChooser, archetypeChooserModel, pickmapChooserControl); final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette = new ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic>(editTypes, selectedSquareView, objectChooser, pickmapChooserControl, copyBuffer); final LeftPanel leftPanel = new LeftPanel(objectChooser, toolPalette, objectChoiceDisplay); @@ -461,7 +464,6 @@ recentManager.initRecent(); validators = createMapValidators(); new AutoValidator<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, mapManager, PREFS_VALIDATOR_AUTO_DEFAULT); - gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeTypeSet, mainView, archetypeSet, mapManager); } /** @@ -787,11 +789,6 @@ } /** {@inheritDoc} */ - public void openAttrDialog(final GameObject gameObject) { - gameObjectAttributesDialogFactory.showAttribDialog(gameObject); - } - - /** {@inheritDoc} */ public boolean saveLevelAsWanted(@NotNull final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl) { final JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle("Save Map Or Script As"); Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java 2008-08-08 19:19:25 UTC (rev 4805) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java 2008-08-08 20:03:10 UTC (rev 4806) @@ -30,6 +30,7 @@ import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.connectionview.LockedItemsControl; +import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; import net.sf.gridarta.gui.gameobjectattributespanel.AnimationTab; import net.sf.gridarta.gui.gameobjectattributespanel.ConnectionsTab; import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; @@ -56,8 +57,8 @@ private static final long serialVersionUID = 1L; /* Build Panel */ - public GameObjectAttributesControl(@NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype>gameObjectAttributesModel, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final Frame parent) { - super(gameObjectAttributesModel, mainControl, objectChooser, mapManager, selectedSquareControl); + public GameObjectAttributesControl(@NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype>gameObjectAttributesModel, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final Frame parent) { + super(gameObjectAttributesModel, gameObjectAttributesDialogFactory, objectChooser, mapManager, selectedSquareControl); addTab(new ArchTab(archetypeTypeSet, gameObjectAttributesModel, gameObjectTextEditor)); addTab(new MsgTextTab<GameObject, MapArchObject, Archetype>(gameObjectAttributesModel)); addTab(new ScriptTab<GameObject, MapArchObject, Archetype>(parent, mainControl, gameObjectAttributesModel)); Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-08-08 19:19:25 UTC (rev 4805) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-08-08 20:03:10 UTC (rev 4806) @@ -101,12 +101,6 @@ void doExit(); /** - * Open an attribute dialog window for the specified gameObject. - * @param gameObject GameObject to open attribute dialog window for. - */ - void openAttrDialog(G gameObject); - - /** * Check a map. * @param map the map to check */ Modified: trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java 2008-08-08 19:19:25 UTC (rev 4805) +++ trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java 2008-08-08 20:03:10 UTC (rev 4806) @@ -26,9 +26,9 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import net.sf.gridarta.MainControl; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.InsertionMode; import net.sf.gridarta.map.MapArchObject; @@ -58,20 +58,27 @@ * The archetype chooser's view. */ @NotNull - private final ArchetypeChooserView<G, A, R, V> archetypeChooserView; + private ArchetypeChooserView<G, A, R, V> archetypeChooserView; /** * Creates a new instance. - * @param mainControl The main control. - * @param createDirectionPane Whether to create a "direction" panel. * @param archetypeChooserModel the archetype chooser model to use */ - public ArchetypeChooserControl(@NotNull final MainControl<G, A, R, V> mainControl, final boolean createDirectionPane, @NotNull final ArchetypeChooserModel<G, A, R, V> archetypeChooserModel) { + public ArchetypeChooserControl(@NotNull final ArchetypeChooserModel<G, A, R, V> archetypeChooserModel) { this.archetypeChooserModel = archetypeChooserModel; - archetypeChooserView = new ArchetypeChooserView<G, A, R, V>(createDirectionPane, mainControl, archetypeChooserModel); } /** + * Initializes the instance. + * @param createDirectionPane Whether to create a "direction" panel. + * @param gameObjectAttributesDialogFactory the faceoty for creating game + * object attributes dialog instances + */ + public void init(final boolean createDirectionPane, final GameObjectAttributesDialogFactory<G, A, R, V> gameObjectAttributesDialogFactory) { + archetypeChooserView = new ArchetypeChooserView<G, A, R, V>(createDirectionPane, gameObjectAttributesDialogFactory, archetypeChooserModel); + } + + /** * Returns the currently selected archetype. * @return the selected archetype, or <code>null</code> if none is selected */ Modified: trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserView.java 2008-08-08 19:19:25 UTC (rev 4805) +++ trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserView.java 2008-08-08 20:03:10 UTC (rev 4806) @@ -35,6 +35,7 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; import net.sf.japi.swing.ActionFactory; @@ -81,10 +82,10 @@ private final JToggleButton buttonDisplayIconsOnly = new JToggleButton(ACTION_FACTORY.createAction(true, "displayIconsOnly", this)); /** - * The main control. + * The factory for creating game object attributes dialog instances. */ @NotNull - private final MainControl<G, A, R, V> mainControl; + private final GameObjectAttributesDialogFactory<G, A, R, V> gameObjectAttributesDialogFactory; /** * The archetype chooser model. @@ -136,12 +137,13 @@ /** * Creates a new instance. * @param createDirectionPane whether the direction pane should be shown - * @param mainControl the main control + * @param gameObjectAttributesDialogFactory the factory for creating game + * object attributes dialog instances * @param archetypeChooserModel the model to use */ - public ArchetypeChooserView(final boolean createDirectionPane, @NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ArchetypeChooserModel<G, A, R, V> archetypeChooserModel) { + public ArchetypeChooserView(final boolean createDirectionPane, @NotNull final GameObjectAttributesDialogFactory<G, A, R, V> gameObjectAttributesDialogFactory, @NotNull final ArchetypeChooserModel<G, A, R, V> archetypeChooserModel) { super(new BorderLayout()); - this.mainControl = mainControl; + this.gameObjectAttributesDialogFactory = gameObjectAttributesDialogFactory; this.archetypeChooserModel = archetypeChooserModel; displayModeGameObjectNames = new DisplayNameCellRenderer<R>(archetypeChooserModel.getArchetypeSet()); displayModeArchetypeNames = new ArchetypeNameCellRenderer<R>(archetypeChooserModel.getArchetypeSet()); @@ -187,7 +189,7 @@ } } - final ArchetypePanel<G, A, R, V> newPanel = new ArchetypePanel<G, A, R, V>(this, archetypeChooserModel, mainControl); + final ArchetypePanel<G, A, R, V> newPanel = new ArchetypePanel<G, A, R, V>(this, archetypeChooserModel, gameObjectAttributesDialogFactory); // insert new panel in alphabetical order int i; Modified: trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypePanel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypePanel.java 2008-08-08 19:19:25 UTC (rev 4805) +++ trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypePanel.java 2008-08-08 20:03:10 UTC (rev 4806) @@ -38,9 +38,9 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import net.sf.gridarta.CommonConstants; -import net.sf.gridarta.MainControl; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; import net.sf.japi.swing.ActionFactory; @@ -98,7 +98,7 @@ * The main control. */ @NotNull - private final MainControl<G, A, R, V> mainControl; + private final GameObjectAttributesDialogFactory<G, A, R, V> gameObjectAttributesDialogFactory; /** * The comparator for sorting archetypes in the active panel. @@ -122,12 +122,13 @@ * Creates a new instance. * @param archetypeChooserView the associated archetype chooser view * @param archetypeChooserModel the associated archetype chooser model - * @param mainControl the main control + * @param gameObjectAttributesDialogFactory the factory for creating game + * object attributes dialog instances */ - protected ArchetypePanel(@NotNull final ArchetypeChooserView<G, A, R, V> archetypeChooserView, @NotNull final ArchetypeChooserModel<G, A, R, V> archetypeChooserModel, @NotNull final MainControl<G, A, R, V> mainControl) { + protected ArchetypePanel(@NotNull final ArchetypeChooserView<G, A, R, V> archetypeChooserView, @NotNull final ArchetypeChooserModel<G, A, R, V> archetypeChooserModel, @NotNull final GameObjectAttributesDialogFactory<G, A, R, V> gameObjectAttributesDialogFactory) { super(new BorderLayout()); this.archetypeChooserModel = archetypeChooserModel; - this.mainControl = mainControl; + this.gameObjectAttributesDialogFactory = gameObjectAttributesDialogFactory; comboBox = new JComboBox(); listModel = new DefaultListModel(); archList = new JList(listModel); @@ -265,7 +266,7 @@ /** Action method for the popup menu to edit a default arch. */ @ActionMethod public void editPopup() { - mainControl.openAttrDialog((/*XXX*/G) getSelectedArchetype()); + gameObjectAttributesDialogFactory.showAttribDialog((/*XXX*/G) getSelectedArchetype()); } /** Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-08-08 19:19:25 UTC (rev 4805) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-08-08 20:03:10 UTC (rev 4806) @@ -32,6 +32,7 @@ import net.sf.gridarta.map.MapArchObject; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public class GameObjectAttributesDialogFactory<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> { @@ -53,8 +54,8 @@ /** * The parent frame for showing dialog boxes. */ - @NotNull - private JFrame parent; + @Nullable + private JFrame parent = null; /** * The archetype set to use. @@ -71,18 +72,24 @@ /** * Creates a new instance. * @param archetypeTypeSet the list of CF type-data - * @param parent the parent frame for showing dialog boxes * @param archetypeSet the archetype set to use * @param mapManager the map manager */ - public GameObjectAttributesDialogFactory(@NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final JFrame parent, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final MapManager<G, A, R, V> mapManager) { + public GameObjectAttributesDialogFactory(@NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final MapManager<G, A, R, V> mapManager) { this.archetypeTypeSet = archetypeTypeSet; - this.parent = parent; this.archetypeSet = archetypeSet; this.mapManager = mapManager; } /** + * Sets the parent frame for dialog boxes. + * @param parent the parent frame for dialog boxes + */ + public void setParent(@NotNull final JFrame parent) { + this.parent = parent; + } + + /** * Shows the game object attributes dialog for a given {@link GameObject} * instance. * @param gameObject the GameObject to be displayed by this dialog Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2008-08-08 19:19:25 UTC (rev 4805) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2008-08-08 20:03:10 UTC (rev 4806) @@ -41,6 +41,7 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.GSplitPane; +import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; import net.sf.gridarta.gui.gameobjecttexteditor.GameObjectTextEditor; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; @@ -73,7 +74,7 @@ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); /** The MainControl to use, e.g. for accessing AnimationObjects. */ - private final MainControl<G, A, R, V> mainControl; + private final GameObjectAttributesDialogFactory<G, A, R, V> gameObjectAttributesDialogFactory; /** * The game object text editor. @@ -144,7 +145,7 @@ */ private boolean isInMapTransaction = false; - /** The map manager listener which is attached to {@link #mainControl}. */ + /** The map manager listener. */ private final MapManagerListener<G, A, R, V> mapManagerListener = new MapManagerListener<G, A, R, V>() { /** {@inheritDoc} */ @@ -305,16 +306,16 @@ /** * Create the GameObjectAttributesPanel. * @param gameObjectAttributesModel the model to use - * @param mainControl MainControl to use, e.g. for accessing - * AnimationObjects. + * @param gameObjectAttributesDialogFactory the factory for creating game + * object attributes dialog instances * @param objectChooser the object chooser instance * @param mapManager the map manager instance * @param selectedSquareControl the selected square control instance */ - protected GameObjectAttributesControl(@NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel, @NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final SelectedSquareControl<G, A, R, V> selectedSquareControl) { + protected GameObjectAttributesControl(@NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel, @NotNull final GameObjectAttributesDialogFactory<G, A, R, V> gameObjectAttributesDialogFactory, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final SelectedSquareControl<G, A, R, V> selectedSquareControl) { super(new BorderLayout()); this.gameObjectAttributesModel = gameObjectAttributesModel; - this.mainControl = mainControl; + this.gameObjectAttributesDialogFactory = gameObjectAttributesDialogFactory; this.objectChooser = objectChooser; mapArchPanel.setLayout(new BorderLayout()); @@ -396,7 +397,7 @@ @ActionMethod public void mapArchAttrib() { if (selectedGameObject != null) { - mainControl.openAttrDialog(selectedGameObject); + gameObjectAttributesDialogFactory.showAttribDialog(selectedGameObject); } } Modified: trunk/src/app/net/sf/gridarta/gui/map/MapCursorControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapCursorControl.java 2008-08-08 19:19:25 UTC (rev 4805) +++ trunk/src/app/net/sf/gridarta/gui/map/MapCursorControl.java 2008-08-08 20:03:10 UTC (rev 4806) @@ -24,6 +24,7 @@ import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.map.MapArchObject; @@ -38,8 +39,10 @@ */ public class MapCursorControl<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> { - /** The MainControl. */ - private final MainControl<G, A, R, V> mainControl; + /** + * The factory for creating game object attributes dialog instances. + */ + private final GameObjectAttributesDialogFactory<G, A, R, V> gameObjectAttributesDialogFactory; /** The selected square control. */ private final SelectedSquareControl<G, A, R, V> selectedSquareControl; @@ -59,14 +62,15 @@ /** * Create a MapCursorControl. * @param key The action factory key. - * @param mainControl MainControl to use (used for getting the current map - * etc.) + * @param mainControl the main control + * @param gameObjectAttributesDialogFactory the factory for creating game + * object attributes dialog instances * @param mapManager the map manager * @param selectedSquareControl the selected square control * @param selectedSquareView the selected square view */ - public MapCursorControl(final String key, final MainControl<G, A, R, V> mainControl, final MapManager<G, A, R, V> mapManager, @NotNull final SelectedSquareControl<G, A, R, V> selectedSquareControl, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView) { - this.mainControl = mainControl; + public MapCursorControl(final String key, @NotNull final MainControl<G, A, R, V> mainControl, @NotNull final GameObjectAttributesDialogFactory<G, A, R, V> gameObjectAttributesDialogFactory, final MapManager<G, A, R, V> mapManager, @NotNull final SelectedSquareControl<G, A, R, V> selectedSquareControl, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView) { + this.gameObjectAttributesDialogFactory = gameObjectAttributesDialogFactory; this.selectedSquareControl = selectedSquareControl; this.selectedSquareView = selectedSquareView; goLocationDialogManager = new GoLocationDialogManager<G, A, R, V>(mapManager); @@ -129,7 +133,7 @@ public void archAttributes() { final G arch = selectedSquareView.getSelectedGameObject(); if (arch != null) { - mainControl.openAttrDialog(arch); + gameObjectAttributesDialogFactory.showAttribDialog(arch); } } Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java 2008-08-08 19:19:25 UTC (rev 4805) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java 2008-08-08 20:03:10 UTC (rev 4806) @@ -27,11 +27,11 @@ import javax.swing.ImageIcon; import javax.swing.event.EventListenerList; import net.sf.gridarta.EditTypes; -import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.gui.objectchooser.ObjectChooser; @@ -54,8 +54,10 @@ */ public final class SelectedSquareControl<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> { - /** Controller of this subview. */ - private final MainControl<G, A, R, V> mainControl; + /** + * The factory for creating game object attributes dialog instances. + */ + private final GameObjectAttributesDialogFactory<G, A, R, V> gameObjectAttributesDialogFactory; /** * The object chooser. @@ -77,7 +79,7 @@ public void mousePressed(final MouseEvent e) { if (isSelect(e)) { if (e.getClickCount() > 1) { // LMB Double click - mainControl.openAttrDialog(view.getSelectedGameObject()); + gameObjectAttributesDialogFactory.showAttribDialog(view.getSelectedGameObject()); } } else if (isInsert(e)) { insertGameObjectFromObjectChooser(view.getListIndex(e)); @@ -91,7 +93,8 @@ /** * Create a SelectedSquareControl. * @param actionFactory the action factory - * @param mainControl MainControl, used for icons + * @param gameObjectAttributesDialogFactory the factory for creating game + * object attributes dialog instances * @param objectChooser the object chooser * @param mapManager the map manager to use * @param editTypes the edit types instance @@ -101,8 +104,8 @@ * of the list * @param archetypeSet the archetype set to use */ - public SelectedSquareControl(@NotNull final ActionFactory actionFactory, @NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final EditTypes<G, A, R, V> editTypes, final boolean mapTileListBottom, @Nullable final ImageIcon compassIcon, @NotNull final ArchetypeSet<G, A, R> archetypeSet) { - this.mainControl = mainControl; + public SelectedSquareControl(@NotNull final ActionFactory actionFactory, @NotNull final GameObjectAttributesDialogFactory<G, A, R, V> gameObjectAttributesDialogFactory, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final EditTypes<G, A, R, V> editTypes, final boolean mapTileListBottom, @Nullable final ImageIcon compassIcon, @NotNull final ArchetypeSet<G, A, R> archetypeSet) { + this.gameObjectAttributesDialogFactory = gameObjectAttributesDialogFactory; this.objectChooser = objectChooser; view = new SelectedSquareView<G, A, R, V>(actionFactory, this, mapManager, editTypes, mapTileListBottom, compassIcon, archetypeSet); Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-08-08 19:19:25 UTC (rev 4805) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-08-08 20:03:10 UTC (rev 4806) @@ -456,11 +456,6 @@ } /** {@inheritDoc} */ - public void openAttrDialog(final TestGameObject gameObject) { - throw new AssertionError(); - } - - /** {@inheritDoc} */ public void validateMap(final MapModel<TestGameObject, TestMapArchObject, TestArchetype> map) { throw new AssertionError(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-08-08 21:31:44
|
Revision: 4807 http://gridarta.svn.sourceforge.net/gridarta/?rev=4807&view=rev Author: akirschbaum Date: 2008-08-08 21:31:28 +0000 (Fri, 08 Aug 2008) Log Message: ----------- Add MapViewManagerListener; removes dependency MapViewManager -> MapManager. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CFJavaEditor.java trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/MapActions.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/MapActions.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java trunk/src/app/net/sf/gridarta/CurrentMapListener.java trunk/src/app/net/sf/gridarta/DefaultMapManager.java trunk/src/app/net/sf/gridarta/MainControl.java trunk/src/app/net/sf/gridarta/MapManager.java trunk/src/app/net/sf/gridarta/MapManagerListener.java trunk/src/app/net/sf/gridarta/gui/ErrorListView.java trunk/src/app/net/sf/gridarta/gui/MainActions.java trunk/src/app/net/sf/gridarta/gui/MainView.java trunk/src/app/net/sf/gridarta/gui/MapViewManager.java trunk/src/app/net/sf/gridarta/gui/StatusBar.java trunk/src/app/net/sf/gridarta/gui/connectionview/ConnectionControl.java trunk/src/app/net/sf/gridarta/gui/connectionview/ConnectionView.java trunk/src/app/net/sf/gridarta/gui/connectionview/LockedItemsControl.java trunk/src/app/net/sf/gridarta/gui/connectionview/LockedItemsView.java trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterControl.java trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterView.java trunk/src/app/net/sf/gridarta/gui/connectionview/View.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ConnectionsTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MonstersTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/WarningsTab.java trunk/src/app/net/sf/gridarta/gui/map/GoLocationDialogManager.java trunk/src/app/net/sf/gridarta/gui/map/MapCursorActions.java trunk/src/app/net/sf/gridarta/gui/map/MapCursorControl.java trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java trunk/src/app/net/sf/gridarta/gui/map/ShrinkMapSizeDialogManager.java trunk/src/app/net/sf/gridarta/gui/map/ViewActions.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/MapTileSelectionCache.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java trunk/src/app/net/sf/gridarta/map/AutoValidator.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/MapViewManagerListener.java Modified: trunk/crossfire/src/cfeditor/CFJavaEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/CFJavaEditor.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/crossfire/src/cfeditor/CFJavaEditor.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -20,7 +20,6 @@ package cfeditor; import java.awt.Component; -import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -148,8 +147,7 @@ } if (outfile != null) { - mainControl.openFiles(infiles); - mainControl.createImageWanted(mainControl.getCurrentMapView(), new File(outfile)); // create map image + mainControl.createImageFile(infiles, outfile); System.exit(0); // exit } Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -44,6 +44,7 @@ import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.MissingResourceException; import java.util.prefs.Preferences; @@ -75,6 +76,7 @@ import net.sf.gridarta.gui.MapFileFilter; import net.sf.gridarta.gui.MapManagerActions; import net.sf.gridarta.gui.MapPreview; +import net.sf.gridarta.gui.MapViewManager; import net.sf.gridarta.gui.RecentManager; import net.sf.gridarta.gui.ReplaceDialogManager; import net.sf.gridarta.gui.StatusBar; @@ -135,7 +137,6 @@ import net.sf.japi.util.filter.file.EndingFileFilter; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.w3c.dom.Document; import org.xml.sax.SAXException; @@ -219,6 +220,12 @@ private final GameObjectAttributesControl gameObjectAttributesControl; /** + * The map view manager instance. + */ + @NotNull + private final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager; + + /** * Constructs the main controller and its model and view. * @throws RuntimeException If the controller cannot be initialized. */ @@ -244,15 +251,16 @@ gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeTypeSet, archetypeSet, mapManager); archetypeChooserControl.init(false, gameObjectAttributesDialogFactory); objectChooser = new DefaultObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeChooserControl, pickmapChooserControl); - final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(ACTION_FACTORY, gameObjectAttributesDialogFactory, objectChooser, mapManager, editTypes, mapTileListBottom, null, archetypeSet); + mapViewManager = new MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic>(); + final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(ACTION_FACTORY, gameObjectAttributesDialogFactory, objectChooser, mapManager, mapViewManager, editTypes, mapTileListBottom, null, archetypeSet); final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView = selectedSquareControl.getSelectedSquareView(); - new MapCursorControl<GameObject, MapArchObject, Archetype, CMapViewBasic>("cfeditor", this, gameObjectAttributesDialogFactory, mapManager, selectedSquareControl, selectedSquareView); + new MapCursorControl<GameObject, MapArchObject, Archetype, CMapViewBasic>("cfeditor", this, gameObjectAttributesDialogFactory, mapManager, mapViewManager, selectedSquareControl, selectedSquareView); replaceDialogManager.setObjectChooser(objectChooser); - mainActions = new MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(replaceDialogManager, this, editTypes, archetypeSet, copyBuffer, pickmapChooserControl, animationObjects, ACTION_FACTORY, faceObjects, objectChooser, mapManager); + mainActions = new MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(replaceDialogManager, this, editTypes, archetypeSet, copyBuffer, pickmapChooserControl, animationObjects, ACTION_FACTORY, faceObjects, objectChooser, mapManager, mapViewManager); SystemIcons.init(); GameObject.setArchetypeSet(archetypeSet, SystemIcons.getNofaceTileIcon()); - createMapImageCache(CResourceLoader.getHomeFile("thumbnails"), SystemIcons.getDefaultIcon(), SystemIcons.getDefaultPreview(), new StatusBar<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, archetypeSet, faceObjects)); - mainView = new MainView<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, editTypes, mapManager, ACTION_FACTORY, mapManagerActions.getCloseAllAction(), statusBar); + createMapImageCache(CResourceLoader.getHomeFile("thumbnails"), SystemIcons.getDefaultIcon(), SystemIcons.getDefaultPreview(), new StatusBar<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, mapViewManager, archetypeSet, faceObjects)); + mainView = new MainView<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, editTypes, mapManager, mapViewManager, ACTION_FACTORY, mapManagerActions.getCloseAllAction(), statusBar); gameObjectAttributesDialogFactory.setParent(mainView); new About("cfeditor", mainView); new UndoControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager); @@ -299,7 +307,7 @@ log.fatal("GameObjectMatcher 'exit' does not exist"); throw new MissingResourceException("GameObjectMatcher 'exit' does not exist", null, null); } - final MapActions mapActions = new MapActions(mainView, this, gridartaObjectsFactory, globalSettings, mapManager, exitMatcher, mapFileFilter, selectedSquareView); + final MapActions mapActions = new MapActions(mainView, this, gridartaObjectsFactory, globalSettings, mapManager, mapViewManager, exitMatcher, mapFileFilter, selectedSquareView); archetypeTypeSet.getListTable().put("event", ScriptArchUtils.getEventTypes()); Map<String, TreasureTreeNode> specialTreasureLists; try { @@ -328,9 +336,9 @@ AbstractScriptArchEditor.initEventTypeBoxes(".py", "Python", ScriptArchUtils.createEventTypeBox(), pythonFileFilter, globalSettings, this); // Initialize the main view - final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, 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); + final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, mapViewManager, 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); final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel = new GameObjectAttributesModel<GameObject, MapArchObject, Archetype>(); - gameObjectAttributesControl = new GameObjectAttributesControl(gameObjectAttributesModel, this, gameObjectAttributesDialogFactory, objectChooser, archetypeTypeSet, mapManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); + gameObjectAttributesControl = new GameObjectAttributesControl(gameObjectAttributesModel, this, gameObjectAttributesDialogFactory, objectChooser, archetypeTypeSet, mapManager, mapViewManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); PluginParameterFactory.init(archetypeSet, gameObjectAttributesModel, objectChooser, mapManager); final NamedFilterList defaultNamedFilterList = new NamedFilterList(gameObjectMatchers.getFilters()); final CFilterControl filterControl = new CFilterControl(null, mapManager, defaultNamedFilterList); @@ -751,16 +759,6 @@ new MapPreview(gridartaObjectsFactory.newSimpleLevelRenderer(currentMap.getMapModel()).getFullImage()); } - /** - * Returns the current top map view we are working with. - * @return the current top map view we are working with, or - * <code>null</code> if no map is open - */ - @Nullable - public MapView<GameObject, MapArchObject, Archetype, CMapViewBasic> getCurrentMapView() { - return mainView == null ? null : mainView.getCurrentMapView(); - } - /** {@inheritDoc} */ @NotNull public String getConfigurationDirectory() { @@ -818,4 +816,9 @@ } } + public void createImageFile(final List<String> infiles, final String outfile) { + openFiles(infiles); + createImageWanted(mapViewManager.getCurrentMapView(), new File(outfile)); // create map image + } + } // class CMainControl Modified: trunk/crossfire/src/cfeditor/MapActions.java =================================================================== --- trunk/crossfire/src/cfeditor/MapActions.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/crossfire/src/cfeditor/MapActions.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -41,6 +41,7 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.match.GameObjectMatcher; +import net.sf.gridarta.gui.MapViewManager; import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.ShrinkMapSizeDialogManager; @@ -147,11 +148,12 @@ * @param gridartaObjectsFactory the gridarta objects factory instance * @param globalSettings the global settings instance * @param mapManager the map manager + * @param mapViewManager the map view manager * @param exitMatcher the game object matcher selecting exit objects * @param mapFileFilter the Swing file filter to use * @param selectedSquareView the selected square vuew to use */ - public MapActions(@NotNull final Component parent, final CMainControl mainControl, @NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final GlobalSettings globalSettings,final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, final GameObjectMatcher exitMatcher, final FileFilter mapFileFilter, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView) { + public MapActions(@NotNull final Component parent, @NotNull final CMainControl mainControl, @NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final GlobalSettings globalSettings, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager, final GameObjectMatcher exitMatcher, final FileFilter mapFileFilter, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView) { this.parent = parent; this.mainControl = mainControl; this.gridartaObjectsFactory = gridartaObjectsFactory; @@ -168,7 +170,7 @@ aDirections[i] = ACTION_FACTORY.createAction(true, directionsMap[i], this); } - currentMapListener = new CurrentMapListener<GameObject, MapArchObject, Archetype, CMapViewBasic>(mainControl, mapManager, null, false, false, true) { + currentMapListener = new CurrentMapListener<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, mapViewManager, null, false, false, true) { /** {@inheritDoc} */ @Override Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -29,6 +29,7 @@ import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.match.GameObjectMatcher; +import net.sf.gridarta.gui.MapViewManager; import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; import net.sf.gridarta.gui.gameobjectattributespanel.AnimationTab; @@ -57,15 +58,15 @@ private static final long serialVersionUID = 1L; /* Build Panel */ - public GameObjectAttributesControl(final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final Frame parent) { + public GameObjectAttributesControl(final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final Frame parent) { super(gameObjectAttributesModel, gameObjectAttributesDialogFactory, objectChooser, mapManager, selectedSquareControl); addTab(new ArchTab(archetypeTypeSet, gameObjectAttributesModel, gameObjectTextEditor)); addTab(new MsgTextTab<GameObject, MapArchObject, Archetype>(gameObjectAttributesModel)); addTab(new ScriptTab<GameObject, MapArchObject, Archetype>(parent, mainControl, gameObjectAttributesModel)); addTab(new AnimationTab<GameObject, MapArchObject, Archetype>(animationObjects, gameObjectAttributesModel)); - addTab(new ConnectionsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, gameObjectAttributesModel)); + addTab(new ConnectionsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, mapViewManager, gameObjectAttributesModel)); addTab(new LockedItemsTab<GameObject, MapArchObject, Archetype>(lockedItemsControl, gameObjectAttributesModel)); - addTab(new MonstersTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, monsterMatcher, gameObjectAttributesModel)); + addTab(new MonstersTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, mapViewManager, monsterMatcher, gameObjectAttributesModel)); addTab(new WarningsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, selectedSquareView, gameObjectAttributesModel)); } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -83,6 +83,7 @@ import net.sf.gridarta.gui.MapFileFilter; import net.sf.gridarta.gui.MapManagerActions; import net.sf.gridarta.gui.MapPreview; +import net.sf.gridarta.gui.MapViewManager; import net.sf.gridarta.gui.RecentManager; import net.sf.gridarta.gui.ReplaceDialogManager; import net.sf.gridarta.gui.StatusBar; @@ -156,7 +157,6 @@ import net.sf.japi.util.filter.file.GlobFileFilter; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.w3c.dom.Document; import org.xml.sax.SAXException; @@ -279,6 +279,12 @@ private final GameObjectAttributesControl gameObjectAttributesControl; /** + * The map view manager instance. + */ + @NotNull + private final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager; + + /** * Constructs the main controller and its model and view. * @throws RuntimeException If the controller cannot be initialized. */ @@ -307,15 +313,16 @@ gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeTypeSet, archetypeSet, mapManager); archetypeChooserControl.init(true, gameObjectAttributesDialogFactory); objectChooser = new DefaultObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeChooserControl, pickmapChooserControl); - final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(ACTION_FACTORY, gameObjectAttributesDialogFactory, objectChooser, mapManager, editTypes, mapTileListBottom, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), archetypeSet); + mapViewManager = new MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic>(); + final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(ACTION_FACTORY, gameObjectAttributesDialogFactory, objectChooser, mapManager, mapViewManager, editTypes, mapTileListBottom, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), archetypeSet); final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView = selectedSquareControl.getSelectedSquareView(); - new MapCursorControl<GameObject, MapArchObject, Archetype, CMapViewBasic>("daieditor", this, gameObjectAttributesDialogFactory, mapManager, selectedSquareControl, selectedSquareView); + new MapCursorControl<GameObject, MapArchObject, Archetype, CMapViewBasic>("daieditor", this, gameObjectAttributesDialogFactory, mapManager, mapViewManager, selectedSquareControl, selectedSquareView); replaceDialogManager.setObjectChooser(objectChooser); - mainActions = new MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(replaceDialogManager, this, editTypes, archetypeSet, copyBuffer, pickmapChooserControl, animationObjects, ACTION_FACTORY, faceObjects, objectChooser, mapManager); + mainActions = new MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(replaceDialogManager, this, editTypes, archetypeSet, copyBuffer, pickmapChooserControl, animationObjects, ACTION_FACTORY, faceObjects, objectChooser, mapManager, mapViewManager); SystemIcons.init(); GameObject.setAnimationObjects(animationObjects, SystemIcons.getNofaceTileIcon()); - createMapImageCache(null, SystemIcons.getDefaultIcon(), SystemIcons.getDefaultPreview(), new StatusBar<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, archetypeSet, faceObjects)); - mainView = new MainView<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, editTypes, mapManager, ACTION_FACTORY, mapManagerActions.getCloseAllAction(), statusBar); + createMapImageCache(null, SystemIcons.getDefaultIcon(), SystemIcons.getDefaultPreview(), new StatusBar<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, mapViewManager, archetypeSet, faceObjects)); + mainView = new MainView<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, editTypes, mapManager, mapViewManager, ACTION_FACTORY, mapManagerActions.getCloseAllAction(), statusBar); gameObjectAttributesDialogFactory.setParent(mainView); new About("daieditor", mainView); new UndoControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager); @@ -365,7 +372,7 @@ log.fatal("GameObjectMatcher 'exit' does not exist"); throw new MissingResourceException("GameObjectMatcher 'exit' does not exist", null, null); } - final MapActions mapActions = new MapActions(mainView, this, gridartaObjectsFactory, (GlobalSettingsImpl) globalSettings, mapManager, exitMatcher, mapFileFilter, selectedSquareView); + final MapActions mapActions = new MapActions(mainView, this, gridartaObjectsFactory, (GlobalSettingsImpl) globalSettings, mapManager, mapViewManager, exitMatcher, mapFileFilter, selectedSquareView); Map<String, TreasureTreeNode> specialTreasureLists; try { final Document specialTreasureListsDocument = xmlHelper.getDocumentBuilder().parse(IOUtils.getResourceURLAsString(getConfigurationDirectory(), "TreasureLists.xml")); @@ -394,9 +401,9 @@ AbstractScriptArchEditor.initEventTypeBoxes(".lua", "Lua", ScriptArchUtils.createEventTypeBox(), luaFileFilter, globalSettings, this); // Initialize the main view - final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, 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); + final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, mapViewManager, 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); final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel = new GameObjectAttributesModel<GameObject, MapArchObject, Archetype>(); - gameObjectAttributesControl = new GameObjectAttributesControl(gameObjectAttributesModel, this, gameObjectAttributesDialogFactory, objectChooser, archetypeTypeSet, mapManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); + gameObjectAttributesControl = new GameObjectAttributesControl(gameObjectAttributesModel, this, gameObjectAttributesDialogFactory, objectChooser, archetypeTypeSet, mapManager, mapViewManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); final ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChoiceDisplay = new ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, CMapViewBasic>(replaceDialogManager, archetypeTypeSet, objectChooser, archetypeChooserModel, pickmapChooserControl); final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette = new ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic>(editTypes, selectedSquareView, objectChooser, pickmapChooserControl, copyBuffer); final LeftPanel leftPanel = new LeftPanel(objectChooser, toolPalette, objectChoiceDisplay); @@ -943,16 +950,6 @@ new MapPreview(gridartaObjectsFactory.newSimpleLevelRenderer(currentMap.getMapModel()).getFullImage()); } - /** - * Returns the current top map view we are working with. - * @return the current top map view we are working with, or - * <code>null</code> if no map is open - */ - @Nullable - public MapView<GameObject, MapArchObject, Archetype, CMapViewBasic> getCurrentMapView() { - return mainView == null ? null : mainView.getCurrentMapView(); - } - /** {@inheritDoc} */ @NotNull public String getConfigurationDirectory() { Modified: trunk/daimonin/src/daieditor/MapActions.java =================================================================== --- trunk/daimonin/src/daieditor/MapActions.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/daimonin/src/daieditor/MapActions.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -40,6 +40,7 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.match.GameObjectMatcher; +import net.sf.gridarta.gui.MapViewManager; import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.ShrinkMapSizeDialogManager; @@ -142,11 +143,12 @@ * @param gridartaObjectsFactory the gridarta objects factory instance * @param globalSettings the global settings instance * @param mapManager the map manager + * @param mapViewManager the map view manager * @param exitMatcher the game object matcher selecting exit objects * @param mapFileFilter the Swing file filter to use * @param selectedSquareView the selected square vuew to use */ - public MapActions(@NotNull final Component parent, @NotNull final CMainControl mainControl, @NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final GlobalSettingsImpl globalSettings, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, final GameObjectMatcher exitMatcher, final FileFilter mapFileFilter, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView) { + public MapActions(@NotNull final Component parent, @NotNull final CMainControl mainControl, @NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final GlobalSettingsImpl globalSettings, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager, final GameObjectMatcher exitMatcher, final FileFilter mapFileFilter, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView) { this.parent = parent; this.mainControl = mainControl; this.gridartaObjectsFactory = gridartaObjectsFactory; @@ -163,7 +165,7 @@ aDirections[i] = ACTION_FACTORY.createAction(true, directionsMap[i], this); } - currentMapListener = new CurrentMapListener<GameObject, MapArchObject, Archetype, CMapViewBasic>(mainControl, mapManager, null, false, false, true) { + currentMapListener = new CurrentMapListener<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, mapViewManager, null, false, false, true) { /** {@inheritDoc} */ @Override Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -29,6 +29,7 @@ import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.match.GameObjectMatcher; +import net.sf.gridarta.gui.MapViewManager; import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; import net.sf.gridarta.gui.gameobjectattributespanel.AnimationTab; @@ -57,15 +58,15 @@ private static final long serialVersionUID = 1L; /* Build Panel */ - public GameObjectAttributesControl(@NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype>gameObjectAttributesModel, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final Frame parent) { + public GameObjectAttributesControl(@NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype>gameObjectAttributesModel, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final Frame parent) { super(gameObjectAttributesModel, gameObjectAttributesDialogFactory, objectChooser, mapManager, selectedSquareControl); addTab(new ArchTab(archetypeTypeSet, gameObjectAttributesModel, gameObjectTextEditor)); addTab(new MsgTextTab<GameObject, MapArchObject, Archetype>(gameObjectAttributesModel)); addTab(new ScriptTab<GameObject, MapArchObject, Archetype>(parent, mainControl, gameObjectAttributesModel)); addTab(new AnimationTab<GameObject, MapArchObject, Archetype>(animationObjects, gameObjectAttributesModel)); - addTab(new ConnectionsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, gameObjectAttributesModel)); + addTab(new ConnectionsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, mapViewManager, gameObjectAttributesModel)); addTab(new LockedItemsTab<GameObject, MapArchObject, Archetype>(lockedItemsControl, gameObjectAttributesModel)); - addTab(new MonstersTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, monsterMatcher, gameObjectAttributesModel)); + addTab(new MonstersTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, mapViewManager, monsterMatcher, gameObjectAttributesModel)); addTab(new WarningsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, selectedSquareView, gameObjectAttributesModel)); } Modified: trunk/src/app/net/sf/gridarta/CurrentMapListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/CurrentMapListener.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/src/app/net/sf/gridarta/CurrentMapListener.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -21,6 +21,8 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.MapViewManager; +import net.sf.gridarta.gui.MapViewManagerListener; import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapCursorListener; import net.sf.gridarta.gui.map.MapView; @@ -138,18 +140,6 @@ } /** {@inheritDoc} */ - public void currentMapViewChanged(@Nullable final MapView<G, A, R, V> mapView) { - if (trackMapCursor && currentMapView != null) { - currentMapView.getMapViewBasic().removeMapCursorListener(mapCursorListener); - } - currentMapView = mapView; - if (trackMapCursor && currentMapView != null) { - currentMapView.getMapViewBasic().addMapCursorListener(mapCursorListener); - } - mapViewHasChanged(); - } - - /** {@inheritDoc} */ public void mapCreated(@NotNull final MapControl<G, A, R, V> mapControl) { // ignore } @@ -172,9 +162,29 @@ }; /** + * The map view manager listener which is attached to the current map if + * the current map is tracked. Otherwise it is unused. + */ + private final MapViewManagerListener<G, A, R, V> mapViewManagerListener = new MapViewManagerListener<G, A, R, V>() { + + /** {@inheritDoc} */ + public void currentMapViewChanged(@Nullable final MapView<G, A, R, V> mapView) { + if (trackMapCursor && currentMapView != null) { + currentMapView.getMapViewBasic().removeMapCursorListener(mapCursorListener); + } + currentMapView = mapView; + if (trackMapCursor && currentMapView != null) { + currentMapView.getMapViewBasic().addMapCursorListener(mapCursorListener); + } + mapViewHasChanged(); + } + + }; + + /** * Create a new instance that tracks the map state. - * @param mainControl the main control to forward actions * @param mapManager the map manager + * @param mapViewManager the map view manager * @param mapControl the map control to check for changes, or * <code>null</code> to check <code>mainControl</code>'s current map * @param trackMapModified if set, notify about changes of the map modified @@ -184,7 +194,7 @@ * @param trackMapCursor if set, notify about map cursor changes of the * current map view */ - protected CurrentMapListener(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final MapManager<G, A, R, V> mapManager, @Nullable final MapControl<G, A, R, V> mapControl, final boolean trackMapModified, final boolean trackMapFileName, final boolean trackMapCursor) { + protected CurrentMapListener(@NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager, @Nullable final MapControl<G, A, R, V> mapControl, final boolean trackMapModified, final boolean trackMapFileName, final boolean trackMapCursor) { this.mapManager = mapManager; this.mapControl = mapControl; this.trackMapModified = trackMapModified; @@ -196,11 +206,12 @@ if (currentMap != null) { currentMap.addMapControlListener(mapControlListener); } - currentMapView = mainControl.getCurrentMapView(); + mapViewManager.addMapViewManagerListener(mapViewManagerListener); + currentMapView = mapViewManager.getCurrentMapView(); } else { currentMap = mapControl; currentMap.addMapControlListener(mapControlListener); - currentMapView = mainControl.getCurrentMapView(); + currentMapView = mapViewManager.getCurrentMapView(); if (currentMapView != null && currentMapView.getMapControl() != currentMap) { currentMapView = null; } Modified: trunk/src/app/net/sf/gridarta/DefaultMapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -430,13 +430,6 @@ } /** {@inheritDoc} */ - public void fireCurrentMapViewChangedEvent(@Nullable final MapView<G, A, R, V> currentMapView) { - for (final MapManagerListener<G, A, R, V> listener : listenerList.getListeners(MapManagerListener.class)) { - listener.currentMapViewChanged(currentMapView); - } - } - - /** {@inheritDoc} */ public void addMapManagerListener(@NotNull final MapManagerListener<G, A, R, V> listener) { listenerList.add(MapManagerListener.class, listener); } Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -31,7 +31,6 @@ import net.sf.gridarta.map.MapModel; import net.sf.japi.swing.ActionMethod; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; /** * This interface is only for unification. It should become obsolete after a @@ -50,13 +49,6 @@ MainView<G, A, R, V> getMainView(); /** - * Returns the current map view. - * @return The current map view - */ - @Nullable - MapView<G, A, R, V> getCurrentMapView(); - - /** * Invoked when user wants to save a map to certain file. * @param mapControl the map to be saved * @return <code>true</code> if the user confirmed saving the map and the Modified: trunk/src/app/net/sf/gridarta/MapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/MapManager.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/src/app/net/sf/gridarta/MapManager.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -172,12 +172,6 @@ void removeMapManagerListener(@NotNull MapManagerListener<G, A, R, V> listener); /** - * Notify all listeners about a changed current map view. - * @param currentMapView the current map view - */ - void fireCurrentMapViewChangedEvent(@Nullable MapView<G, A, R, V> currentMapView); - - /** * Notify all listeners about a map view to be closed. * @param mapView map view that's being closed */ Modified: trunk/src/app/net/sf/gridarta/MapManagerListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/MapManagerListener.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/src/app/net/sf/gridarta/MapManagerListener.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -35,8 +35,7 @@ * #mapCreated(MapControl)} - after a map has been created or opened <li>{@link * #currentMapChanged(MapControl)} - the newly created map now is the current * map <li>{@link #mapViewCreated(MapView)} - after a map view has been created - * <li>{@link #currentMapViewChanged(MapView)} - the new map view now is the - * current map view <li>{@link #mapViewClosing(MapView)} - the map view has been + * <li>{@link #mapViewClosing(MapView)} - the map view has been * closed <li>{@link #mapClosing(MapControl)} - the map has been closed </ul> * @author Andreas Kirschbaum */ @@ -50,13 +49,6 @@ void currentMapChanged(@Nullable MapControl<G, A, R, V> mapControl); /** - * This event handler is called when the current map view has changed. - * @param mapView the new map view, or <code>null</code> if no opened map - * view exists - */ - void currentMapViewChanged(@Nullable MapView<G, A, R, V> mapView); - - /** * This event handler is called when a map was created. * @param mapControl the created map control */ Modified: trunk/src/app/net/sf/gridarta/gui/ErrorListView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ErrorListView.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/src/app/net/sf/gridarta/gui/ErrorListView.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -109,11 +109,6 @@ } /** {@inheritDoc} */ - public void currentMapViewChanged(@Nullable final MapView<G, A, R, V> mapView) { - // ignore - } - - /** {@inheritDoc} */ public void mapCreated(@NotNull final MapControl<G, A, R, V> mapControl) { // ignore } Modified: trunk/src/app/net/sf/gridarta/gui/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -200,12 +200,6 @@ } /** {@inheritDoc} */ - public void currentMapViewChanged(@Nullable final MapView<G, A, R, V> mapView) { - currentMapView = mapView; - refreshMenus(); - } - - /** {@inheritDoc} */ public void mapCreated(@NotNull final MapControl<G, A, R, V> mapControl) { // ignore: a current map changed event will be generated } @@ -229,6 +223,17 @@ }; + /** The map manager listener to detect created and closed map views. */ + private final MapViewManagerListener<G, A, R, V> mapViewManagerListener = new MapViewManagerListener<G, A, R, V>() { + + /** {@inheritDoc} */ + public void currentMapViewChanged(@Nullable final MapView<G, A, R, V> mapView) { + currentMapView = mapView; + refreshMenus(); + } + + }; + /** The map grid listener used to detect map grid changes. */ private final MapGridListener mapGridListener = new MapGridListener() { @@ -312,8 +317,9 @@ * @param faceObjects the FaceObjects instance to use * @param objectChooser the animation objects instance to use * @param mapManager the map manager instance + * @param mapViewManager the map view manager instance */ - public MainActions(@NotNull final ReplaceDialogManager<G, A, R, V> replaceDialogManager, @NotNull final MainControl<G, A, R, V> mainControl, @NotNull final EditTypes<G, A, R, V> editTypes, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final CopyBuffer<G, A, R, V> copyBuffer, @NotNull final PickmapChooserControl<G, A, R, V> pickmapChooserControl, @NotNull final AnimationObjects<?> animationObjects, @NotNull final ActionFactory actionFactory, @NotNull final FaceObjects faceObjects, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapManager<G, A, R, V> mapManager) { + public MainActions(@NotNull final ReplaceDialogManager<G, A, R, V> replaceDialogManager, @NotNull final MainControl<G, A, R, V> mainControl, @NotNull final EditTypes<G, A, R, V> editTypes, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final CopyBuffer<G, A, R, V> copyBuffer, @NotNull final PickmapChooserControl<G, A, R, V> pickmapChooserControl, @NotNull final AnimationObjects<?> animationObjects, @NotNull final ActionFactory actionFactory, @NotNull final FaceObjects faceObjects, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager) { this.replaceDialogManager = replaceDialogManager; this.mainControl = mainControl; this.editTypes = editTypes; @@ -348,7 +354,8 @@ aValidateMap = actionFactory.createAction(true, "validateMap", this); mapManager.addMapManagerListener(mapManagerListener); currentMap = mapManager.getCurrentMap(); - currentMapView = mainControl.getCurrentMapView(); + mapViewManager.addMapViewManagerListener(mapViewManagerListener); + currentMapView = mapViewManager.getCurrentMapView(); } /** Must be called after object creation. */ Modified: trunk/src/app/net/sf/gridarta/gui/MainView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -44,7 +44,6 @@ import net.sf.gridarta.EditTypes; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; -import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; @@ -222,38 +221,13 @@ /** * The listener used to detect map view changes. */ - private final MapManagerListener<G, A, R, V> mapManagerListener = new MapManagerListener<G, A, R, V>() { + private final MapViewManagerListener<G, A, R, V> mapViewManagerListener = new MapViewManagerListener<G, A, R, V>() { /** {@inheritDoc} */ - public void currentMapChanged(@Nullable final MapControl<G, A, R, V> mapControl) { - // ignore - } - - /** {@inheritDoc} */ public void currentMapViewChanged(@Nullable final MapView<G, A, R, V> mapView) { rebuildWindowMenu(); } - /** {@inheritDoc} */ - public void mapCreated(@NotNull final MapControl<G, A, R, V> mapControl) { - // ignore - } - - /** {@inheritDoc} */ - public void mapViewCreated(@NotNull final MapView<G, A, R, V> mapView) { - // ignore - } - - /** {@inheritDoc} */ - public void mapClosing(@NotNull final MapControl<G, A, R, V> mapControl) { - // ignore - } - - /** {@inheritDoc} */ - public void mapViewClosing(@NotNull final MapView<G, A, R, V> mapView) { - // ignore - } - }; /** @@ -261,15 +235,16 @@ * @param mainControl MainControl to attach to. * @param editTypes the edit types instance * @param mapManager the map manager + * @param mapViewManager the map view manager * @param actionFactory the action factory to use * @param aCloseAll the action "close all map windows" * @param statusBar the status bar instance */ - public MainView(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final EditTypes<G, A, R, V> editTypes, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final ActionFactory actionFactory, @NotNull final Action aCloseAll, @NotNull final Component statusBar) { + public MainView(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final EditTypes<G, A, R, V> editTypes, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager, @NotNull final ActionFactory actionFactory, @NotNull final Action aCloseAll, @NotNull final Component statusBar) { super(actionFactory.format("mainWindow.title", AbstractMainControl.getBuildNumberAsString())); this.mapManager = mapManager; - mapViewManager = new MapViewManager<G, A, R, V>(mapManager); - mapFileAction = new MapFileActions<G, A, R, V>(mainControl, mapManager, null); + this.mapViewManager = mapViewManager; + mapFileAction = new MapFileActions<G, A, R, V>(mainControl, mapManager, mapViewManager, null); add(statusBar, BorderLayout.SOUTH); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @@ -285,7 +260,7 @@ aNextWindow = actionFactory.createAction(true, "nextWindow", this); actionFactory.createAction(true, "viewTreasurelists", mainControl); - viewActions = new ViewActions<G, A, R, V>(mainControl, editTypes, mapManager); + viewActions = new ViewActions<G, A, R, V>(editTypes, mapManager, mapViewManager); final ImageIcon icon = GUIUtils.getIcon(GUIConstants.APP_ICON); if (icon != null) { @@ -294,7 +269,7 @@ updateFocus(false); - mapManager.addMapManagerListener(mapManagerListener); + mapViewManager.addMapViewManagerListener(mapViewManagerListener); } /** Open the online help window. */ @@ -595,16 +570,6 @@ } /** - * Returns the current top map view we are working with. - * @return the current top map view we are working with, or - * <code>null</code> if no map is open - */ - @Nullable - public MapView<G, A, R, V> getCurrentMapView() { - return mapViewManager.getFirstMapView(); - } - - /** * Determine whether "prev window" should be enabled. * @return the map view to activate, or <code>null</code> if "prev window" * should be disabled Modified: trunk/src/app/net/sf/gridarta/gui/MapViewManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MapViewManager.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/src/app/net/sf/gridarta/gui/MapViewManager.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -23,7 +23,6 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; -import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapView; @@ -45,23 +44,21 @@ private final List<MapView<G, A, R, V>> mapViews = Collections.synchronizedList(new ArrayList<MapView<G, A, R, V>>()); /** - * The map manager to notify. - */ - @NotNull - private final MapManager<G, A, R, V> mapManager; - - /** * The current map view. */ @Nullable private MapView<G, A, R, V> currentMapView = null; /** + * The registered listeners. + */ + @NotNull + private final List<MapViewManagerListener<G, A, R, V>> listeners = new ArrayList<MapViewManagerListener<G, A, R, V>>(); + + /** * Creates a new instance. - * @param mapManager the map manager to notify */ - public MapViewManager(@NotNull final MapManager<G, A, R, V> mapManager) { - this.mapManager = mapManager; + public MapViewManager() { } public void setCurrentLevelView(final MapView<G, A, R, V> mapView) { @@ -146,13 +143,41 @@ * Updates the current map view and notifies all listeners of changes. */ private void updateCurrentMapView() { - final MapView<G, A, R, V> newCurrentMapView = getFirstMapView(); + final MapView<G, A, R, V> newCurrentMapView = getCurrentMapView(); if (currentMapView == newCurrentMapView) { return; } currentMapView = newCurrentMapView; - mapManager.fireCurrentMapViewChangedEvent(currentMapView); + for (final MapViewManagerListener<G, A, R, V> listener : listeners) { + listener.currentMapViewChanged(currentMapView); + } } + /** + * Adds a listener to be notified. + * @param listener the listener to add + */ + public void addMapViewManagerListener(@NotNull final MapViewManagerListener<G, A, R, V> listener) { + listeners.add(listener); + } + + /** + * Removes a listener to be notified. + * @param listener the listener to remove + */ + public void removeMapViewManagerListener(@NotNull final MapViewManagerListener<G, A, R, V> listener) { + listeners.remove(listener); + } + + /** + * Returns the current top map view we are working with. + * @return the current top map view we are working with or + * <code>null</code> if no map is open + */ + @Nullable + public MapView<G, A, R, V> getCurrentMapView() { + return getFirstMapView(); + } + } // class MapViewManager Added: trunk/src/app/net/sf/gridarta/gui/MapViewManagerListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MapViewManagerListener.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/MapViewManagerListener.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -0,0 +1,43 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui; + +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.map.MapView; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.map.MapArchObject; +import org.jetbrains.annotations.Nullable; + +/** + * Interface for listeners interested in events related to {@link + * MapViewManager} instances. + * @author Andreas Kirschbaum + */ +public interface MapViewManagerListener<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> { + + /** + * This event handler is called when the current map view has changed. + * @param mapView the new map view or <code>null</code> if no opened map + * view exists + */ + void currentMapViewChanged(@Nullable MapView<G, A, R, V> mapView); + +} // interface MapViewManagerListener Property changes on: trunk/src/app/net/sf/gridarta/gui/MapViewManagerListener.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gui/StatusBar.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/StatusBar.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/src/app/net/sf/gridarta/gui/StatusBar.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -124,11 +124,6 @@ } /** {@inheritDoc} */ - public void currentMapViewChanged(@Nullable final MapView<G, A, R, V> mapView) { - setCurrentMapView(mapView); - } - - /** {@inheritDoc} */ public void mapCreated(@NotNull final MapControl<G, A, R, V> mapControl) { setStatusText("Creating new map " + mapControl.getMapModel().getMapArchObject().getMapDisplayName() + "."); mapControl.addMapControlListener(mapControlListener); @@ -151,6 +146,16 @@ }; + /** The map view manager listener to detect current map changes. */ + private final MapViewManagerListener<G, A, R, V> mapViewManagerListener = new MapViewManagerListener<G, A, R, V>() { + + /** {@inheritDoc} */ + public void currentMapViewChanged(@Nullable final MapView<G, A, R, V> mapView) { + setCurrentMapView(mapView); + } + + }; + /** * The {@link MapControlListener} used to detect saved maps. */ @@ -202,10 +207,11 @@ * Constructs a statusbar that has the given main controller object set as * its controller. * @param mapManager the map manager + * @param mapViewManager the map view manager * @param archetypeSet the archetype set * @param faceObjects the FaceObjects instance to use */ - public StatusBar(@NotNull final MapManager<G, A, R, V> mapManager, @No... [truncated message content] |
From: <aki...@us...> - 2008-08-08 22:14:21
|
Revision: 4809 http://gridarta.svn.sourceforge.net/gridarta/?rev=4809&view=rev Author: akirschbaum Date: 2008-08-08 22:14:13 +0000 (Fri, 08 Aug 2008) Log Message: ----------- Move mapViewCreated() and mapViewClosing() from MapManagerListener to MapViewManagerListener. Modified Paths: -------------- trunk/crossfire/src/cfeditor/MapActions.java trunk/daimonin/src/daieditor/MapActions.java trunk/src/app/net/sf/gridarta/CurrentMapListener.java trunk/src/app/net/sf/gridarta/DefaultMapManager.java trunk/src/app/net/sf/gridarta/MapManager.java trunk/src/app/net/sf/gridarta/MapManagerListener.java trunk/src/app/net/sf/gridarta/gui/ErrorListView.java trunk/src/app/net/sf/gridarta/gui/MainActions.java trunk/src/app/net/sf/gridarta/gui/MainView.java trunk/src/app/net/sf/gridarta/gui/MapViewManager.java trunk/src/app/net/sf/gridarta/gui/MapViewManagerListener.java trunk/src/app/net/sf/gridarta/gui/StatusBar.java trunk/src/app/net/sf/gridarta/gui/connectionview/View.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/WarningsTab.java trunk/src/app/net/sf/gridarta/gui/map/GoLocationDialogManager.java trunk/src/app/net/sf/gridarta/gui/map/MapCursorActions.java trunk/src/app/net/sf/gridarta/gui/map/MapCursorControl.java trunk/src/app/net/sf/gridarta/gui/map/ShrinkMapSizeDialogManager.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/MapTileSelectionCache.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java trunk/src/app/net/sf/gridarta/map/AutoValidator.java Modified: trunk/crossfire/src/cfeditor/MapActions.java =================================================================== --- trunk/crossfire/src/cfeditor/MapActions.java 2008-08-08 21:43:09 UTC (rev 4808) +++ trunk/crossfire/src/cfeditor/MapActions.java 2008-08-08 22:14:13 UTC (rev 4809) @@ -162,7 +162,7 @@ this.exitMatcher = exitMatcher; this.mapFileFilter = mapFileFilter; this.selectedSquareView = selectedSquareView; - shrinkMapSizeDialogManager = new ShrinkMapSizeDialogManager<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager); + shrinkMapSizeDialogManager = new ShrinkMapSizeDialogManager<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapViewManager); autoJoin = prefs.getBoolean(AUTOJOIN_KEY, false); Modified: trunk/daimonin/src/daieditor/MapActions.java =================================================================== --- trunk/daimonin/src/daieditor/MapActions.java 2008-08-08 21:43:09 UTC (rev 4808) +++ trunk/daimonin/src/daieditor/MapActions.java 2008-08-08 22:14:13 UTC (rev 4809) @@ -157,7 +157,7 @@ this.exitMatcher = exitMatcher; this.mapFileFilter = mapFileFilter; this.selectedSquareView = selectedSquareView; - shrinkMapSizeDialogManager = new ShrinkMapSizeDialogManager<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager); + shrinkMapSizeDialogManager = new ShrinkMapSizeDialogManager<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapViewManager); autoJoin = prefs.getBoolean(AUTOJOIN_KEY, false); Modified: trunk/src/app/net/sf/gridarta/CurrentMapListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/CurrentMapListener.java 2008-08-08 21:43:09 UTC (rev 4808) +++ trunk/src/app/net/sf/gridarta/CurrentMapListener.java 2008-08-08 22:14:13 UTC (rev 4809) @@ -145,20 +145,10 @@ } /** {@inheritDoc} */ - public void mapViewCreated(@NotNull final MapView<G, A, R, V> mapView) { - // ignore - } - - /** {@inheritDoc} */ public void mapClosing(@NotNull final MapControl<G, A, R, V> mapControl) { // ignore } - /** {@inheritDoc} */ - public void mapViewClosing(@NotNull final MapView<G, A, R, V> mapView) { - // ignore - } - }; /** @@ -179,6 +169,16 @@ mapViewHasChanged(); } + /** {@inheritDoc} */ + public void mapViewCreated(@NotNull final MapView<G, A, R, V> mapView) { + // ignore + } + + /** {@inheritDoc} */ + public void mapViewClosing(@NotNull final MapView<G, A, R, V> mapView) { + // ignore + } + }; /** Modified: trunk/src/app/net/sf/gridarta/DefaultMapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-08-08 21:43:09 UTC (rev 4808) +++ trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-08-08 22:14:13 UTC (rev 4809) @@ -398,13 +398,6 @@ } } - /** {@inheritDoc} */ - public void fireMapViewCreatedEvent(@NotNull final MapView<G, A, R, V> mapView) { - for (final MapManagerListener<G, A, R, V> listener : listenerList.getListeners(MapManagerListener.class)) { - listener.mapViewCreated(mapView); - } - } - /** * Notify all listeners about a map to be closed. * @param mapControl MapControl that's being closed. @@ -415,13 +408,6 @@ } } - /** {@inheritDoc} */ - public void fireMapViewClosingEvent(@NotNull final MapView<G, A, R, V> mapView) { - for (final MapManagerListener<G, A, R, V> listener : listenerList.getListeners(MapManagerListener.class)) { - listener.mapViewClosing(mapView); - } - } - /** Notify all listeners about a changed current map. */ private void fireCurrentMapChangedEvent() { for (final MapManagerListener<G, A, R, V> listener : listenerList.getListeners(MapManagerListener.class)) { Modified: trunk/src/app/net/sf/gridarta/MapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/MapManager.java 2008-08-08 21:43:09 UTC (rev 4808) +++ trunk/src/app/net/sf/gridarta/MapManager.java 2008-08-08 22:14:13 UTC (rev 4809) @@ -172,18 +172,6 @@ void removeMapManagerListener(@NotNull MapManagerListener<G, A, R, V> listener); /** - * Notify all listeners about a map view to be closed. - * @param mapView map view that's being closed - */ - void fireMapViewClosingEvent(@NotNull MapView<G, A, R, V> mapView); - - /** - * Notify all listeners about a created map view. - * @param mapView the created map view - */ - void fireMapViewCreatedEvent(@NotNull MapView<G, A, R, V> mapView); - - /** * Refreshes all map view of the active map. Does nothing if no map is * opened. */ Modified: trunk/src/app/net/sf/gridarta/MapManagerListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/MapManagerListener.java 2008-08-08 21:43:09 UTC (rev 4808) +++ trunk/src/app/net/sf/gridarta/MapManagerListener.java 2008-08-08 22:14:13 UTC (rev 4809) @@ -22,7 +22,6 @@ import java.util.EventListener; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; @@ -34,9 +33,8 @@ * following events are created (in roughly the given order): <ul> <li>{@link * #mapCreated(MapControl)} - after a map has been created or opened <li>{@link * #currentMapChanged(MapControl)} - the newly created map now is the current - * map <li>{@link #mapViewCreated(MapView)} - after a map view has been created - * <li>{@link #mapViewClosing(MapView)} - the map view has been - * closed <li>{@link #mapClosing(MapControl)} - the map has been closed </ul> + * map + * <li>{@link #mapClosing(MapControl)} - the map has been closed </ul> * @author Andreas Kirschbaum */ public interface MapManagerListener<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> extends EventListener { @@ -55,21 +53,9 @@ void mapCreated(@NotNull MapControl<G, A, R, V> mapControl); /** - * This event handler is called when a map view was created. - * @param mapView the created map view - */ - void mapViewCreated(@NotNull MapView<G, A, R, V> mapView); - - /** * This event handler is called when a map is to be closed. * @param mapControl the map control that is to be closed */ void mapClosing(@NotNull MapControl<G, A, R, V> mapControl); - /** - * This event handler is called when a map view is to be closed. - * @param mapView the map view that is to be closed - */ - void mapViewClosing(@NotNull MapView<G, A, R, V> mapView); - } // interface MapManagerListener Modified: trunk/src/app/net/sf/gridarta/gui/ErrorListView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ErrorListView.java 2008-08-08 21:43:09 UTC (rev 4808) +++ trunk/src/app/net/sf/gridarta/gui/ErrorListView.java 2008-08-08 22:14:13 UTC (rev 4809) @@ -114,20 +114,10 @@ } /** {@inheritDoc} */ - public void mapViewCreated(@NotNull final MapView<G, A, R, V> mapView) { - // ignore - } - - /** {@inheritDoc} */ public void mapClosing(@NotNull final MapControl<G, A, R, V> mapControl) { errorsCache.remove(mapControl.getMapModel()); } - /** {@inheritDoc} */ - public void mapViewClosing(@NotNull final MapView<G, A, R, V> mapView) { - // ignore - } - }; /** Modified: trunk/src/app/net/sf/gridarta/gui/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-08-08 21:43:09 UTC (rev 4808) +++ trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-08-08 22:14:13 UTC (rev 4809) @@ -205,22 +205,10 @@ } /** {@inheritDoc} */ - public void mapViewCreated(@NotNull final MapView<G, A, R, V> mapView) { - mapView.getMapViewBasic().addMapGridListener(mapGridListener); - mapView.getMapViewBasic().addMapCursorListener(mapCursorListener); - } - - /** {@inheritDoc} */ public void mapClosing(@NotNull final MapControl<G, A, R, V> mapControl) { // ignore: a current map changed event will be generated } - /** {@inheritDoc} */ - public void mapViewClosing(@NotNull final MapView<G, A, R, V> mapView) { - mapView.getMapViewBasic().removeMapCursorListener(mapCursorListener); - mapView.getMapViewBasic().removeMapGridListener(mapGridListener); - } - }; /** The map manager listener to detect created and closed map views. */ @@ -232,6 +220,18 @@ refreshMenus(); } + /** {@inheritDoc} */ + public void mapViewCreated(@NotNull final MapView<G, A, R, V> mapView) { + mapView.getMapViewBasic().addMapGridListener(mapGridListener); + mapView.getMapViewBasic().addMapCursorListener(mapCursorListener); + } + + /** {@inheritDoc} */ + public void mapViewClosing(@NotNull final MapView<G, A, R, V> mapView) { + mapView.getMapViewBasic().removeMapCursorListener(mapCursorListener); + mapView.getMapViewBasic().removeMapGridListener(mapGridListener); + } + }; /** The map grid listener used to detect map grid changes. */ Modified: trunk/src/app/net/sf/gridarta/gui/MainView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-08-08 21:43:09 UTC (rev 4808) +++ trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-08-08 22:14:13 UTC (rev 4809) @@ -224,6 +224,16 @@ private final MapViewManagerListener<G, A, R, V> mapViewManagerListener = new MapViewManagerListener<G, A, R, V>() { /** {@inheritDoc} */ + public void mapViewCreated(@NotNull final MapView<G, A, R, V> mapView) { + // ignore + } + + /** {@inheritDoc} */ + public void mapViewClosing(@NotNull final MapView<G, A, R, V> mapView) { + // ignore + } + + /** {@inheritDoc} */ public void currentMapViewChanged(@Nullable final MapView<G, A, R, V> mapView) { rebuildWindowMenu(); } @@ -305,7 +315,6 @@ public void removeLevelView(final MapView<G, A, R, V> mapView) { mapView.removeInternalFrameListener(internalFrameListener); mapViewManager.removeLevelView(mapView); - mapManager.fireMapViewClosingEvent(mapView); mapDesktop.remove(mapView); // This is important: Removing a JInternalFrame from a JDesktopPane doesn't deselect it. // Thus it will still be referenced. To prevent a closed map from being referenced by Swing, @@ -325,10 +334,9 @@ * @param mapView the map view to add */ public void addLevelView(final MapView<G, A, R, V> mapView) { - mapViewManager.addLevelView(mapView); mapView.addInternalFrameListener(internalFrameListener); mapDesktop.add(mapView); - mapManager.fireMapViewCreatedEvent(mapView); + mapViewManager.addLevelView(mapView); setCurrentLevelView(mapView); mapView.setVisible(true); mapView.setBounds(0, 0, mapDesktop.getWidth(), mapDesktop.getHeight()); Modified: trunk/src/app/net/sf/gridarta/gui/MapViewManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MapViewManager.java 2008-08-08 21:43:09 UTC (rev 4808) +++ trunk/src/app/net/sf/gridarta/gui/MapViewManager.java 2008-08-08 22:14:13 UTC (rev 4809) @@ -23,6 +23,7 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; +import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapView; @@ -75,12 +76,19 @@ } mapViews.remove(mapView); + for (final MapViewManagerListener<G, A, R, V> listener : listeners) { + listener.mapViewClosing(mapView); + } updateCurrentMapView(); } public void addLevelView(final MapView<G, A, R, V> mapView) { assert !mapViews.contains(mapView); mapViews.add(0, mapView); + + for (final MapViewManagerListener<G, A, R, V> listener : listeners) { + listener.mapViewCreated(mapView); + } } public void levelViewFocusNotify(final MapView<G, A, R, V> mapView) { Modified: trunk/src/app/net/sf/gridarta/gui/MapViewManagerListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MapViewManagerListener.java 2008-08-08 21:43:09 UTC (rev 4808) +++ trunk/src/app/net/sf/gridarta/gui/MapViewManagerListener.java 2008-08-08 22:14:13 UTC (rev 4809) @@ -24,6 +24,7 @@ import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -40,4 +41,16 @@ */ void currentMapViewChanged(@Nullable MapView<G, A, R, V> mapView); + /** + * This event handler is called when a map view was created. + * @param mapView the created map view + */ + void mapViewCreated(@NotNull MapView<G, A, R, V> mapView); + + /** + * This event handler is called when a map view is to be closed. + * @param mapView the map view that is to be closed + */ + void mapViewClosing(@NotNull MapView<G, A, R, V> mapView); + } // interface MapViewManagerListener Modified: trunk/src/app/net/sf/gridarta/gui/StatusBar.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/StatusBar.java 2008-08-08 21:43:09 UTC (rev 4808) +++ trunk/src/app/net/sf/gridarta/gui/StatusBar.java 2008-08-08 22:14:13 UTC (rev 4809) @@ -130,20 +130,10 @@ } /** {@inheritDoc} */ - public void mapViewCreated(@NotNull final MapView<G, A, R, V> mapView) { - mapView.getMapViewBasic().getRenderer().addMouseMotionListener(StatusBar.this); - } - - /** {@inheritDoc} */ public void mapClosing(@NotNull final MapControl<G, A, R, V> mapControl) { mapControl.removeMapControlListener(mapControlListener); } - /** {@inheritDoc} */ - public void mapViewClosing(@NotNull final MapView<G, A, R, V> mapView) { - mapView.getMapViewBasic().getRenderer().removeMouseMotionListener(StatusBar.this); - } - }; /** The map view manager listener to detect current map changes. */ @@ -154,6 +144,16 @@ setCurrentMapView(mapView); } + /** {@inheritDoc} */ + public void mapViewCreated(@NotNull final MapView<G, A, R, V> mapView) { + mapView.getMapViewBasic().getRenderer().addMouseMotionListener(StatusBar.this); + } + + /** {@inheritDoc} */ + public void mapViewClosing(@NotNull final MapView<G, A, R, V> mapView) { + mapView.getMapViewBasic().getRenderer().removeMouseMotionListener(StatusBar.this); + } + }; /** Modified: trunk/src/app/net/sf/gridarta/gui/connectionview/View.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/connectionview/View.java 2008-08-08 21:43:09 UTC (rev 4808) +++ trunk/src/app/net/sf/gridarta/gui/connectionview/View.java 2008-08-08 22:14:13 UTC (rev 4809) @@ -82,20 +82,10 @@ } /** {@inheritDoc} */ - public void mapViewCreated(@NotNull final MapView<G, A, R, V> mapView) { - // ignore - } - - /** {@inheritDoc} */ public void mapClosing(@NotNull final MapControl<G, A, R, V> mapControl) { mapControl.getMapModel().removeMapModelListener(mapModelListener); } - /** {@inheritDoc} */ - public void mapViewClosing(@NotNull final MapView<G, A, R, V> mapView) { - // ignore - } - }; /** The map view istener to detect changed active maps. */ @@ -107,6 +97,16 @@ scanMapForConnections(); } + /** {@inheritDoc} */ + public void mapViewCreated(@NotNull final MapView<G, A, R, V> mapView) { + // ignore + } + + /** {@inheritDoc} */ + public void mapViewClosing(@NotNull final MapView<G, A, R, V> mapView) { + // ignore + } + }; /** The map model listener to detect map changes. */ Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2008-08-08 21:43:09 UTC (rev 4808) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2008-08-08 22:14:13 UTC (rev 4809) @@ -167,20 +167,10 @@ } /** {@inheritDoc} */ - public void mapViewCreated(@NotNull final MapView<G, A, R, V> mapView) { - // ignore - } - - /** {@inheritDoc} */ public void mapClosing(@NotNull final MapControl<G, A, R, V> mapControl) { // ignore } - /** {@inheritDoc} */ - public void mapViewClosing(@NotNull final MapView<G, A, R, V> mapView) { - // ignore - } - }; /** The map model listener which is attached to {@link #currentMap}. */ Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/WarningsTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/WarningsTab.java 2008-08-08 21:43:09 UTC (rev 4808) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/WarningsTab.java 2008-08-08 22:14:13 UTC (rev 4809) @@ -75,20 +75,10 @@ } /** {@inheritDoc} */ - public void mapViewCreated(@NotNull final MapView<G, A, R, V> mapView) { - // ignore - } - - /** {@inheritDoc} */ public void mapClosing(@NotNull final MapControl<G, A, R, V> mapControl) { // ignore } - /** {@inheritDoc} */ - public void mapViewClosing(@NotNull final MapView<G, A, R, V> mapView) { - // ignore - } - }; /** The map model listener which is attached to {@link #currentMap}. */ Modified: trunk/src/app/net/sf/gridarta/gui/map/GoLocationDialogManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/GoLocationDialogManager.java 2008-08-08 21:43:09 UTC (rev 4808) +++ trunk/src/app/net/sf/gridarta/gui/map/GoLocationDialogManager.java 2008-08-08 22:14:13 UTC (rev 4809) @@ -21,12 +21,11 @@ import java.util.HashMap; import java.util.Map; -import net.sf.gridarta.MapManager; -import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.MapViewManager; +import net.sf.gridarta.gui.MapViewManagerListener; import net.sf.gridarta.map.MapArchObject; -import net.sf.gridarta.map.MapControl; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -40,30 +39,20 @@ /** Dialog for each map view. */ private final Map<MapView<G, A, R, V>, GoLocationDialog<G, A, R, V>> dialogs = new HashMap<MapView<G, A, R, V>, GoLocationDialog<G, A, R, V>>(); - /** The map manager listener to detect closed map views. */ - private final MapManagerListener<G, A, R, V> mapManagerListener = new MapManagerListener<G, A, R, V>() { + /** The map view manager listener to detect closed map views. */ + private final MapViewManagerListener<G, A, R, V> mapViewManagerListener = new MapViewManagerListener<G, A, R, V>() { /** {@inheritDoc} */ - public void currentMapChanged(@Nullable final MapControl<G, A, R, V> mapControl) { + public void currentMapViewChanged(@Nullable final MapView<G, A, R, V> mapView) { // ignore } /** {@inheritDoc} */ - public void mapCreated(@NotNull final MapControl<G, A, R, V> mapControl) { - // ignore - } - - /** {@inheritDoc} */ public void mapViewCreated(@NotNull final MapView<G, A, R, V> mapView) { // ignore } /** {@inheritDoc} */ - public void mapClosing(@NotNull final MapControl<G, A, R, V> mapControl) { - // ignore - } - - /** {@inheritDoc} */ public void mapViewClosing(@NotNull final MapView<G, A, R, V> mapView) { disposeDialog(mapView); } @@ -71,11 +60,11 @@ }; /** - * Create a new instance. - * @param mapManager the map manager + * Creates a new instance. + * @param mapViewManager the view map manager */ - public GoLocationDialogManager(@NotNull final MapManager<G, A, R, V> mapManager) { - mapManager.addMapManagerListener(mapManagerListener); + public GoLocationDialogManager(@NotNull final MapViewManager<G, A, R, V> mapViewManager) { + mapViewManager.addMapViewManagerListener(mapViewManagerListener); } /** Modified: trunk/src/app/net/sf/gridarta/gui/map/MapCursorActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapCursorActions.java 2008-08-08 21:43:09 UTC (rev 4808) +++ trunk/src/app/net/sf/gridarta/gui/map/MapCursorActions.java 2008-08-08 22:14:13 UTC (rev 4809) @@ -101,20 +101,10 @@ } /** {@inheritDoc} */ - public void mapViewCreated(@NotNull final MapView<G, A, R, V> mapView) { - mapView.getMapViewBasic().addMapCursorListener(mapCursorListener); - } - - /** {@inheritDoc} */ public void mapClosing(@NotNull final MapControl<G, A, R, V> mapControl) { // ignore } - /** {@inheritDoc} */ - public void mapViewClosing(@NotNull final MapView<G, A, R, V> mapView) { - mapView.getMapViewBasic().removeMapCursorListener(mapCursorListener); - } - }; /** The map view manager listener used to detect changed current maps. */ @@ -126,6 +116,16 @@ refreshActions(); } + /** {@inheritDoc} */ + public void mapViewCreated(@NotNull final MapView<G, A, R, V> mapView) { + mapView.getMapViewBasic().addMapCursorListener(mapCursorListener); + } + + /** {@inheritDoc} */ + public void mapViewClosing(@NotNull final MapView<G, A, R, V> mapView) { + mapView.getMapViewBasic().removeMapCursorListener(mapCursorListener); + } + }; /** Modified: trunk/src/app/net/sf/gridarta/gui/map/MapCursorControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapCursorControl.java 2008-08-08 21:43:09 UTC (rev 4808) +++ trunk/src/app/net/sf/gridarta/gui/map/MapCursorControl.java 2008-08-08 22:14:13 UTC (rev 4809) @@ -75,7 +75,7 @@ this.gameObjectAttributesDialogFactory = gameObjectAttributesDialogFactory; this.selectedSquareControl = selectedSquareControl; this.selectedSquareView = selectedSquareView; - goLocationDialogManager = new GoLocationDialogManager<G, A, R, V>(mapManager); + goLocationDialogManager = new GoLocationDialogManager<G, A, R, V>(mapViewManager); actions = new MapCursorActions<G, A, R, V>(key, this, mainControl, mapManager, mapViewManager); } Modified: trunk/src/app/net/sf/gridarta/gui/map/ShrinkMapSizeDialogManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/ShrinkMapSizeDialogManager.java 2008-08-08 21:43:09 UTC (rev 4808) +++ trunk/src/app/net/sf/gridarta/gui/map/ShrinkMapSizeDialogManager.java 2008-08-08 22:14:13 UTC (rev 4809) @@ -21,12 +21,11 @@ import java.util.HashMap; import java.util.Map; -import net.sf.gridarta.MapManager; -import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.MapViewManager; +import net.sf.gridarta.gui.MapViewManagerListener; import net.sf.gridarta.map.MapArchObject; -import net.sf.gridarta.map.MapControl; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -40,30 +39,20 @@ /** Dialog for each map view. */ private final Map<MapView<G, A, R, V>, ShrinkMapSizeDialog<G, A, R, V>> dialogs = new HashMap<MapView<G, A, R, V>, ShrinkMapSizeDialog<G, A, R, V>>(); - /** The map manager listener to detect closed map views. */ - private final MapManagerListener<G, A, R, V> mapManagerListener = new MapManagerListener<G, A, R, V>() { + /** The map view manager listener to detect closed map views. */ + private final MapViewManagerListener<G, A, R, V> mapViewManagerListener = new MapViewManagerListener<G, A, R, V>() { /** {@inheritDoc} */ - public void currentMapChanged(@Nullable final MapControl<G, A, R, V> mapControl) { + public void currentMapViewChanged(@Nullable final MapView<G, A, R, V> mapView) { // ignore } /** {@inheritDoc} */ - public void mapCreated(@NotNull final MapControl<G, A, R, V> mapControl) { - // ignore - } - - /** {@inheritDoc} */ public void mapViewCreated(@NotNull final MapView<G, A, R, V> mapView) { // ignore } /** {@inheritDoc} */ - public void mapClosing(@NotNull final MapControl<G, A, R, V> mapControl) { - // ignore - } - - /** {@inheritDoc} */ public void mapViewClosing(@NotNull final MapView<G, A, R, V> mapView) { disposeDialog(mapView); } @@ -72,10 +61,10 @@ /** * Creates a new instance. - * @param mapManager the map manager + * @param mapViewManager the map view manager */ - public ShrinkMapSizeDialogManager(@NotNull final MapManager<G, A, R, V> mapManager) { - mapManager.addMapManagerListener(mapManagerListener); + public ShrinkMapSizeDialogManager(@NotNull final MapViewManager<G, A, R, V> mapViewManager) { + mapViewManager.addMapViewManagerListener(mapViewManagerListener); } /** Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2008-08-08 21:43:09 UTC (rev 4808) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2008-08-08 22:14:13 UTC (rev 4809) @@ -165,22 +165,12 @@ } /** {@inheritDoc} */ - public void mapViewCreated(@NotNull final MapView<G, A, R, V> mapView) { - // ignore - } - - /** {@inheritDoc} */ public void mapClosing(@NotNull final MapControl<G, A, R, V> mapControl) { if (!mapControl.isPickmap()) { mapControl.removeMapControlListener(mapControlListener); } } - /** {@inheritDoc} */ - public void mapViewClosing(@NotNull final MapView<G, A, R, V> mapView) { - // ignore - } - }; /** Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/MapTileSelectionCache.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/MapTileSelectionCache.java 2008-08-08 21:43:09 UTC (rev 4808) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/MapTileSelectionCache.java 2008-08-08 22:14:13 UTC (rev 4809) @@ -21,10 +21,10 @@ import java.util.IdentityHashMap; import java.util.Map; -import net.sf.gridarta.MapManager; -import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.MapViewManager; +import net.sf.gridarta.gui.MapViewManagerListener; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; @@ -48,25 +48,15 @@ private final Map<MapView<G, A, R, V>, MapTileSelection<G, A, R, V>> cache = new IdentityHashMap<MapView<G, A, R, V>, MapTileSelection<G, A, R, V>>(); /** The map control listener used to remove closed maps from {@link #cache}. */ - private final MapManagerListener<G, A, R, V> mapManagerListener = new MapManagerListener<G, A, R, V>() { + private final MapViewManagerListener<G, A, R, V> mapViewManagerListener = new MapViewManagerListener<G, A, R, V>() { /** {@inheritDoc} */ - public void currentMapChanged(@Nullable final MapControl<G, A, R, V> mapControl) { - // ignore - } - - /** {@inheritDoc} */ - public void mapCreated(@NotNull final MapControl<G, A, R, V> mapControl) { - // ignore - } - - /** {@inheritDoc} */ public void mapViewCreated(@NotNull final MapView<G, A, R, V> mapView) { // ignore } /** {@inheritDoc} */ - public void mapClosing(@NotNull final MapControl<G, A, R, V> mapControl) { + public void currentMapViewChanged(@Nullable final MapView<G, A, R, V> mapView) { // ignore } @@ -78,11 +68,11 @@ }; /** - * Create a new instance. - * @param mapManager the map manager + * Creates a new instance. + * @param mapViewManager the map view manager */ - public MapTileSelectionCache(@NotNull final MapManager<G, A, R, V> mapManager) { - mapManager.addMapManagerListener(mapManagerListener); + public MapTileSelectionCache(@NotNull final MapViewManager<G, A, R, V> mapViewManager) { + mapViewManager.addMapViewManagerListener(mapViewManagerListener); } /** Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java 2008-08-08 21:43:09 UTC (rev 4808) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java 2008-08-08 22:14:13 UTC (rev 4809) @@ -169,16 +169,28 @@ } /** {@inheritDoc} */ - public void mapViewCreated(@NotNull final MapView<G, A, R, V> mapView) { - mapView.getMapViewBasic().addMapCursorListener(SelectedSquareView.this); + public void mapClosing(@NotNull final MapControl<G, A, R, V> mapControl) { + mapControl.getMapModel().removeMapModelListener(mapModelListener); } + }; + + /** The map view manager listener. */ + private final MapViewManagerListener<G, A, R, V> mapViewManagerListener = new MapViewManagerListener<G, A, R, V>() { + /** {@inheritDoc} */ - public void mapClosing(@NotNull final MapControl<G, A, R, V> mapControl) { - mapControl.getMapModel().removeMapModelListener(mapModelListener); + public void currentMapViewChanged(@Nullable final MapView<G, A, R, V> mapView) { + if (setSelectedMapTile(mapTileSelectionCache.findOrCreate(mapView))) { + refresh(); + } } /** {@inheritDoc} */ + public void mapViewCreated(@NotNull final MapView<G, A, R, V> mapView) { + mapView.getMapViewBasic().addMapCursorListener(SelectedSquareView.this); + } + + /** {@inheritDoc} */ public void mapViewClosing(@NotNull final MapView<G, A, R, V> mapView) { mapView.getMapViewBasic().removeMapCursorListener(SelectedSquareView.this); @@ -192,18 +204,6 @@ }; - /** The map view manager listener. */ - private final MapViewManagerListener<G, A, R, V> mapViewManagerListener = new MapViewManagerListener<G, A, R, V>() { - - /** {@inheritDoc} */ - public void currentMapViewChanged(@Nullable final MapView<G, A, R, V> mapView) { - if (setSelectedMapTile(mapTileSelectionCache.findOrCreate(mapView))) { - refresh(); - } - } - - }; - /** * The listener attached to {@link #list} to be informed about selection * changes. @@ -233,7 +233,7 @@ public SelectedSquareView(@NotNull final ActionFactory actionFactory, @NotNull final SelectedSquareControl<G, A, R, V> control, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager, @NotNull final EditTypes<G, A, R, V> editTypes, final boolean mapTileListBottom, @Nullable final ImageIcon compassIcon, @NotNull final ArchetypeSet<G, A, R> archetypeSet) { this.editTypes = editTypes; this.control = control; - mapTileSelectionCache = new MapTileSelectionCache<G, A, R, V>(mapManager); + mapTileSelectionCache = new MapTileSelectionCache<G, A, R, V>(mapViewManager); setLayout(new BorderLayout()); Modified: trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java 2008-08-08 21:43:09 UTC (rev 4808) +++ trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java 2008-08-08 22:14:13 UTC (rev 4809) @@ -142,21 +142,11 @@ } /** {@inheritDoc} */ - public void mapViewCreated(@NotNull final MapView<G, A, R, V> mapView) { - // ignore - } - - /** {@inheritDoc} */ public void mapClosing(@NotNull final MapControl<G, A, R, V> mapControl) { undoModels.remove(mapControl.getMapModel()); mapControl.getMapModel().removeMapTransactionListener(mapTransactionListener); } - /** {@inheritDoc} */ - public void mapViewClosing(@NotNull final MapView<G, A, R, V> mapView) { - // ignore - } - }; /** Action for "undo" function. */ Modified: trunk/src/app/net/sf/gridarta/map/AutoValidator.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AutoValidator.java 2008-08-08 21:43:09 UTC (rev 4808) +++ trunk/src/app/net/sf/gridarta/map/AutoValidator.java 2008-08-08 22:14:13 UTC (rev 4809) @@ -72,11 +72,6 @@ } /** {@inheritDoc} */ - public void mapViewCreated(@NotNull final MapView<G, A, R, V> mapView) { - // ignore - } - - /** {@inheritDoc} */ public void mapClosing(@NotNull final MapControl<G, A, R, V> mapControl) { final MapModel<G, A, R> mapModel = mapControl.getMapModel(); autoValidatorProcessor.removeChangedMapModel(mapModel); @@ -84,11 +79,6 @@ mapModel.removeMapModelListener(mapModelListener); } - /** {@inheritDoc} */ - public void mapViewClosing(@NotNull final MapView<G, A, R, V> mapView) { - // ignore - } - }; /** The map control listener to track map changes. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-08-08 22:34:15
|
Revision: 4812 http://gridarta.svn.sourceforge.net/gridarta/?rev=4812&view=rev Author: akirschbaum Date: 2008-08-08 22:34:21 +0000 (Fri, 08 Aug 2008) Log Message: ----------- Move MainControl.revert() to MapManager.revert(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/src/app/net/sf/gridarta/DefaultMapManager.java trunk/src/app/net/sf/gridarta/MainControl.java trunk/src/app/net/sf/gridarta/MapManager.java trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-08 22:33:18 UTC (rev 4811) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-08 22:34:21 UTC (rev 4812) @@ -721,23 +721,6 @@ thread.start(); } - /** {@inheritDoc} */ - public void revert(@NotNull final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl) { - if (ACTION_FACTORY.showQuestionDialog(mainView, "confirmRevertMap", mapControl.getMapFileName())) { - final File mfile = mapControl.getMapFile(); - final Point[] viewPositions = mapControl.getViewPositions(); - mapManager.closeLevel(mapControl, true); - - final MapView<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapView = mapManager.openMapFileWithView(mfile, viewPositions[0]); - if (newMapView != null) { - final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControl = newMapView.getMapControl(); - for (int i = 1; i < viewPositions.length; i++) { - mapManager.mapCreateView(newMapControl, viewPositions[i]); - } - } - } - } - /** Notifies that the application is about to exit. */ void appExitNotify() { mainView.appExitNotify(); // notify main view Modified: trunk/src/app/net/sf/gridarta/DefaultMapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-08-08 22:33:18 UTC (rev 4811) +++ trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-08-08 22:34:21 UTC (rev 4812) @@ -447,4 +447,19 @@ this.recentManager = recentManager; } + /** {@inheritDoc} */ + public void revert(final MapControl<G, A, R, V> mapControl) { + final File mfile = mapControl.getMapFile(); + final Point[] viewPositions = mapControl.getViewPositions(); + closeLevel(mapControl, true); + + final MapView<G, A, R, V> newMapView = openMapFileWithView(mfile, viewPositions[0]); + if (newMapView != null) { + final MapControl<G, A, R, V> newMapControl = newMapView.getMapControl(); + for (int i = 1; i < viewPositions.length; i++) { + mapCreateView(newMapControl, viewPositions[i]); + } + } + } + } // class DefaultMapManager Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-08-08 22:33:18 UTC (rev 4811) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-08-08 22:34:21 UTC (rev 4812) @@ -64,12 +64,6 @@ */ void createImage(@NotNull MapView<G, A, R, V> mapView); - /** - * Invoked when user wants to revert a map to the previously saved state. - * @param mapControl the map to revert - */ - void revert(@NotNull MapControl<G, A, R, V> mapControl); - /** Action method for exiting the application. */ @ActionMethod void exit(); Modified: trunk/src/app/net/sf/gridarta/MapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/MapManager.java 2008-08-08 22:33:18 UTC (rev 4811) +++ trunk/src/app/net/sf/gridarta/MapManager.java 2008-08-08 22:34:21 UTC (rev 4812) @@ -187,4 +187,10 @@ void setRecentManager(@NotNull RecentManager recentManager); + /** + * Reverts one map. + * @param mapControl the map to revert + */ + void revert(MapControl<G, A, R, V> mapControl); + } // interface MapManager Modified: trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java 2008-08-08 22:33:18 UTC (rev 4811) +++ trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java 2008-08-08 22:34:21 UTC (rev 4812) @@ -205,9 +205,14 @@ */ public void revert() { final MapControl<G, A, R, V> mapControl = getRevertEnabled(); - if (mapControl != null) { - mainControl.revert(mapControl); + if (mapControl == null) { + return; } + if (!ACTION_FACTORY.showQuestionDialog(mainControl.getMainView(), "confirmRevertMap", mapControl.getMapFileName())) { + return; + } + + mapManager.revert(mapControl); } /** Invoked when the user wants to close the map. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-08-08 22:40:33
|
Revision: 4815 http://gridarta.svn.sourceforge.net/gridarta/?rev=4815&view=rev Author: akirschbaum Date: 2008-08-08 22:40:40 +0000 (Fri, 08 Aug 2008) Log Message: ----------- Replace if statement with guard. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-08 22:38:56 UTC (rev 4814) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-08 22:40:40 UTC (rev 4815) @@ -636,18 +636,18 @@ } final int returnVal = fileChooser.showSaveDialog(mainView); - if (returnVal == JFileChooser.APPROVE_OPTION) { - globalSettings.setChangedDir(true); // user has chosen an active dir - final File file = fileChooser.getSelectedFile(); - if (!file.exists() || ACTION_FACTORY.showConfirmDialog(mainView, JOptionPane.WARNING_MESSAGE, JOptionPane.OK_CANCEL_OPTION, "overwriteOtherFile", file.getName()) == JOptionPane.OK_OPTION) { - mapControl.saveAs(file); - - globalSettings.setCurrentDir(fileChooser.getCurrentDirectory()); - } - return true; - } else { + if (returnVal != JFileChooser.APPROVE_OPTION) { return false; } + + globalSettings.setChangedDir(true); // user has chosen an active dir + final File file = fileChooser.getSelectedFile(); + if (!file.exists() || ACTION_FACTORY.showConfirmDialog(mainView, JOptionPane.WARNING_MESSAGE, JOptionPane.OK_CANCEL_OPTION, "overwriteOtherFile", file.getName()) == JOptionPane.OK_OPTION) { + mapControl.saveAs(file); + + globalSettings.setCurrentDir(fileChooser.getCurrentDirectory()); + } + return true; } private PreferencesGroup prefsGroup; Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-08-08 22:38:56 UTC (rev 4814) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-08-08 22:40:40 UTC (rev 4815) @@ -821,18 +821,18 @@ } final int returnVal = fileChooser.showSaveDialog(mainView); - if (returnVal == JFileChooser.APPROVE_OPTION) { - globalSettings.setChangedDir(true); // user has chosen an active dir - final File file = fileChooser.getSelectedFile(); - if (!file.exists() || ACTION_FACTORY.showConfirmDialog(mainView, JOptionPane.WARNING_MESSAGE, JOptionPane.OK_CANCEL_OPTION, "overwriteOtherFile", file.getName()) == JOptionPane.OK_OPTION) { - mapControl.saveAs(file); - - globalSettings.setCurrentDir(fileChooser.getCurrentDirectory()); - } - return true; - } else { + if (returnVal != JFileChooser.APPROVE_OPTION) { return false; } + + globalSettings.setChangedDir(true); // user has chosen an active dir + final File file = fileChooser.getSelectedFile(); + if (!file.exists() || ACTION_FACTORY.showConfirmDialog(mainView, JOptionPane.WARNING_MESSAGE, JOptionPane.OK_CANCEL_OPTION, "overwriteOtherFile", file.getName()) == JOptionPane.OK_OPTION) { + mapControl.saveAs(file); + + globalSettings.setCurrentDir(fileChooser.getCurrentDirectory()); + } + return true; } private PreferencesGroup prefsGroup; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-08-09 08:11:48
|
Revision: 4816 http://gridarta.svn.sourceforge.net/gridarta/?rev=4816&view=rev Author: akirschbaum Date: 2008-08-09 08:11:56 +0000 (Sat, 09 Aug 2008) Log Message: ----------- Extract FileControl from CMainControl. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java Added Paths: ----------- trunk/crossfire/src/cfeditor/FileControl.java trunk/daimonin/src/daieditor/FileControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-08 22:40:40 UTC (rev 4815) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-09 08:11:56 UTC (rev 4816) @@ -47,7 +47,6 @@ import java.util.Map; import java.util.MissingResourceException; import java.util.prefs.Preferences; -import javax.swing.JFileChooser; import javax.swing.JMenu; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; @@ -200,9 +199,6 @@ /** Actions used by this instance. */ private final MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic> mainActions; - /** JFileChooser for opening a file. */ - private JFileChooser fileChooser; - /** The treasure lists. */ private final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree; @@ -225,6 +221,12 @@ private final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager; /** + * The file control instance. + */ + @NotNull + private final FileControl fileControl; + + /** * Constructs the main controller and its model and view. * @throws RuntimeException If the controller cannot be initialized. */ @@ -393,6 +395,7 @@ recentManager.initRecent(); validators = createMapValidators(); new AutoValidator<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, mapManager, PREFS_VALIDATOR_AUTO_DEFAULT); + fileControl = new FileControl(globalSettings, archetypeSet, mapPreviewAccessory, mapManager, mainView, mapFileFilter, pythonFileFilter, newMapDialogFactory); } /** @@ -478,7 +481,7 @@ /** Edit an existing script. */ @ActionMethod public void editScript() { - openFileWanted(false); + fileControl.openFileWanted(false); } public void onlineHelp() { @@ -514,78 +517,10 @@ /** Invoked when user wants to open a file. */ public void open() { - openFileWanted(true); + fileControl.openFileWanted(true); } - /** Create the JFileChooser for opening a file. */ - private void createFileChooser() { - fileChooser = new JFileChooser(); - fileChooser.setDialogTitle(ACTION_FACTORY.getString("fileDialog.title")); - fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - fileChooser.setMultiSelectionEnabled(true); - fileChooser.addChoosableFileFilter(pythonFileFilter); - fileChooser.addChoosableFileFilter(mapFileFilter); - if (globalSettings.getMapDir().exists()) { - fileChooser.setCurrentDirectory(globalSettings.getMapDir()); - } - mapPreviewAccessory.attachTo(fileChooser); - } - /** - * The user wants to open a file. The filefilters and preselected filefilter - * are set accordingly to <var>mapFilter</var>. - * @param mapFilter set to <code>true</code> if the user probably wants to - * open a map, <code>false</code> otherwise - */ - public void openFileWanted(final boolean mapFilter) { - if (fileChooser == null) { - createFileChooser(); - } - if (mapFilter) { - fileChooser.setFileFilter(mapFileFilter); - } else { - fileChooser.setFileFilter(pythonFileFilter); - } - final int returnVal = fileChooser.showOpenDialog(mainView); - if (returnVal == JFileChooser.APPROVE_OPTION) { - if (archetypeSet.getLoadStatus() == ArchetypeSet.LoadStatus.EMPTY) { - // ArchStack is empty -> abort! - ACTION_FACTORY.showMessageDialog(mainView, "openFileWantedNoArches"); - return; - } - - globalSettings.setChangedDir(true); // user has chosen an active dir - openFiles(fileChooser.getCurrentDirectory(), fileChooser.getSelectedFiles()); - } - } - - /** - * Load an array of files. - * @param dir directory to load files from - * @param files array of files to load - */ - private void openFiles(final File dir, final File... files) { - for (final File file : files) { - final boolean isScriptFile = file.getName().toLowerCase().endsWith(".py"); - if (file.isFile()) { - if (isScriptFile) { - ScriptEditControlInstance.getInstance().openScriptFile(file.getAbsolutePath()); - } else { - globalSettings.setCurrentDir(dir); - mapManager.openMapFileWithView(file, null); - } - } else if (!file.exists()) { - if (isScriptFile) { - // TODO: pass filename - ScriptEditControlInstance.getInstance().openScriptNew(); - } else { - newLevelWanted(file.getName()); - } - } // If neither branch matches, it's a directory - what to do with directories? - } - } - - /** * Load a list of map files. * @param filenames collection of filenames to load */ @@ -612,42 +547,7 @@ /** {@inheritDoc} */ public boolean saveLevelAsWanted(@NotNull final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl) { - final JFileChooser fileChooser = new JFileChooser(); - fileChooser.setDialogTitle("Save Map Or Script As"); - fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); - fileChooser.setMultiSelectionEnabled(false); - fileChooser.resetChoosableFileFilters(); - fileChooser.addChoosableFileFilter(pythonFileFilter); - fileChooser.setFileFilter(mapFileFilter); - - // default folder is the map-folder at first time, then the active folder - if (!globalSettings.hasChangedDir() && globalSettings.getMapDir().exists()) { - fileChooser.setCurrentDirectory(globalSettings.getMapDir()); - } else if (globalSettings.getCurrentDir().exists()) { - fileChooser.setCurrentDirectory(globalSettings.getCurrentDir()); - } - - // if file already exists, select it - final File mapFile = mapControl.getMapFile(); - if (mapFile != null && mapFile.exists()) { - fileChooser.setSelectedFile(mapFile); - } else { - fileChooser.setSelectedFile(new File(globalSettings.getMapDir(), mapControl.getMapFileName())); - } - - final int returnVal = fileChooser.showSaveDialog(mainView); - if (returnVal != JFileChooser.APPROVE_OPTION) { - return false; - } - - globalSettings.setChangedDir(true); // user has chosen an active dir - final File file = fileChooser.getSelectedFile(); - if (!file.exists() || ACTION_FACTORY.showConfirmDialog(mainView, JOptionPane.WARNING_MESSAGE, JOptionPane.OK_CANCEL_OPTION, "overwriteOtherFile", file.getName()) == JOptionPane.OK_OPTION) { - mapControl.saveAs(file); - - globalSettings.setCurrentDir(fileChooser.getCurrentDirectory()); - } - return true; + return fileControl.saveLevelAsWanted(mapControl); } private PreferencesGroup prefsGroup; Added: trunk/crossfire/src/cfeditor/FileControl.java =================================================================== --- trunk/crossfire/src/cfeditor/FileControl.java (rev 0) +++ trunk/crossfire/src/cfeditor/FileControl.java 2008-08-09 08:11:56 UTC (rev 4816) @@ -0,0 +1,232 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package cfeditor; + +import cfeditor.gameobject.Archetype; +import cfeditor.gameobject.ArchetypeSet; +import cfeditor.gameobject.GameObject; +import cfeditor.gui.map.CMapViewBasic; +import cfeditor.map.MapArchObject; +import java.awt.Component; +import java.io.File; +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.filechooser.FileFilter; +import net.sf.gridarta.GlobalSettings; +import net.sf.gridarta.MapManager; +import net.sf.gridarta.gui.map.MapPreviewAccessory; +import net.sf.gridarta.gui.newmap.NewMapDialogFactory; +import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.textedit.scripteditor.ScriptEditControlInstance; +import net.sf.japi.swing.ActionFactory; +import org.jetbrains.annotations.NotNull; + +public class FileControl { + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); + + /** + * The global settings instance. + */ + @NotNull + private final GlobalSettings globalSettings; + + /** + * The archetype set. + */ + @NotNull + private final ArchetypeSet archetypeSet; + + /** + * The map preview accessory. + */ + @NotNull + private final MapPreviewAccessory mapPreviewAccessory; + + /** + * The map manager. + */ + @NotNull + private final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager; + + /** + * The parent component for showing dialog boxes. + */ + @NotNull + private final Component parent; + + /** + * The map file filter. + */ + @NotNull + private final FileFilter mapFileFilter; + + /** + * The script file filter. + */ + @NotNull + private final FileFilter scriptFileFilter; + + /** + * The new map dialog factory. + */ + @NotNull + private final NewMapDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapDialogFactory; + + /** JFileChooser for opening a file. */ + private JFileChooser fileChooser; + + /** + * Creates a new instance. + * @param globalSettings the global settings instance + * @param archetypeSet the archetype set + * @param mapPreviewAccessory the map preview accessory + * @param mapManager the map manager + * @param parent the parent component for showing dialog boxes + * @param mapFileFilter the map file filter + * @param scriptFileFilter the script file filter + * @param newMapDialogFactory the new map dialog factory + */ + public FileControl(@NotNull final GlobalSettings globalSettings, @NotNull final ArchetypeSet archetypeSet, @NotNull final MapPreviewAccessory mapPreviewAccessory, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final Component parent, @NotNull final FileFilter mapFileFilter, @NotNull final FileFilter scriptFileFilter, @NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapDialogFactory) { + this.globalSettings = globalSettings; + this.archetypeSet = archetypeSet; + this.mapPreviewAccessory = mapPreviewAccessory; + this.mapManager = mapManager; + this.parent = parent; + this.mapFileFilter = mapFileFilter; + this.scriptFileFilter = scriptFileFilter; + this.newMapDialogFactory = newMapDialogFactory; + } + + /** Create the JFileChooser for opening a file. */ + private void createFileChooser() { + fileChooser = new JFileChooser(); + fileChooser.setDialogTitle(ACTION_FACTORY.getString("fileDialog.title")); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + fileChooser.setMultiSelectionEnabled(true); + fileChooser.addChoosableFileFilter(scriptFileFilter); + fileChooser.addChoosableFileFilter(mapFileFilter); + if (globalSettings.getMapDir().exists()) { + fileChooser.setCurrentDirectory(globalSettings.getMapDir()); + } + mapPreviewAccessory.attachTo(fileChooser); + } + + /** + * The user wants to open a file. The filefilters and preselected filefilter + * are set accordingly to <var>mapFilter</var>. + * @param mapFilter set to <code>true</code> if the user probably wants to + * open a map, <code>false</code> otherwise + */ + public void openFileWanted(final boolean mapFilter) { + if (fileChooser == null) { + createFileChooser(); + } + if (mapFilter) { + fileChooser.setFileFilter(mapFileFilter); + } else { + fileChooser.setFileFilter(scriptFileFilter); + } + final int returnVal = fileChooser.showOpenDialog(parent); + if (returnVal == JFileChooser.APPROVE_OPTION) { + if (archetypeSet.getLoadStatus() == ArchetypeSet.LoadStatus.EMPTY) { + // ArchStack is empty -> abort! + ACTION_FACTORY.showMessageDialog(parent, "openFileWantedNoArches"); + return; + } + + globalSettings.setChangedDir(true); // user has chosen an active dir + openFiles(fileChooser.getCurrentDirectory(), fileChooser.getSelectedFiles()); + } + } + + /** + * Invoked when user wants to save a map to certain file. + * @param mapControl the map to be saved + * @return <code>true</code> if the user confirmed saving the map and the + * map was saved successfully, otherwise <code>false</code> + */ + public boolean saveLevelAsWanted(@NotNull final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl) { + final JFileChooser fileChooser = new JFileChooser(); + fileChooser.setDialogTitle("Save Map Or Script As"); + fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); + fileChooser.setMultiSelectionEnabled(false); + fileChooser.resetChoosableFileFilters(); + fileChooser.addChoosableFileFilter(scriptFileFilter); + fileChooser.setFileFilter(mapFileFilter); + + // default folder is the map-folder at first time, then the active folder + if (!globalSettings.hasChangedDir() && globalSettings.getMapDir().exists()) { + fileChooser.setCurrentDirectory(globalSettings.getMapDir()); + } else if (globalSettings.getCurrentDir().exists()) { + fileChooser.setCurrentDirectory(globalSettings.getCurrentDir()); + } + + // if file already exists, select it + final File mapFile = mapControl.getMapFile(); + if (mapFile != null && mapFile.exists()) { + fileChooser.setSelectedFile(mapFile); + } else { + fileChooser.setSelectedFile(new File(globalSettings.getMapDir(), mapControl.getMapFileName())); + } + + final int returnVal = fileChooser.showSaveDialog(parent); + if (returnVal != JFileChooser.APPROVE_OPTION) { + return false; + } + + globalSettings.setChangedDir(true); // user has chosen an active dir + final File file = fileChooser.getSelectedFile(); + if (!file.exists() || ACTION_FACTORY.showConfirmDialog(parent, JOptionPane.WARNING_MESSAGE, JOptionPane.OK_CANCEL_OPTION, "overwriteOtherFile", file.getName()) == JOptionPane.OK_OPTION) { + mapControl.saveAs(file); + + globalSettings.setCurrentDir(fileChooser.getCurrentDirectory()); + } + return true; + } + + /** + * Load an array of files. + * @param dir directory to load files from + * @param files array of files to load + */ + private void openFiles(final File dir, final File... files) { + for (final File file : files) { + final boolean isScriptFile = file.getName().toLowerCase().endsWith(".py"); + if (file.isFile()) { + if (isScriptFile) { + ScriptEditControlInstance.getInstance().openScriptFile(file.getAbsolutePath()); + } else { + globalSettings.setCurrentDir(dir); + mapManager.openMapFileWithView(file, null); + } + } else if (!file.exists()) { + if (isScriptFile) { + // TODO: pass filename + ScriptEditControlInstance.getInstance().openScriptNew(); + } else { + newMapDialogFactory.showNewMapDialog(file.getName()); + } + } // If neither branch matches, it's a directory - what to do with directories? + } + } + +} // class FileControl Property changes on: trunk/crossfire/src/cfeditor/FileControl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-08-08 22:40:40 UTC (rev 4815) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-08-09 08:11:56 UTC (rev 4816) @@ -52,7 +52,6 @@ import java.util.Map; import java.util.MissingResourceException; import java.util.prefs.Preferences; -import javax.swing.JFileChooser; import javax.swing.JMenu; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; @@ -260,9 +259,6 @@ /** Actions used by this instance. */ private final MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic> mainActions; - /** JFileChooser for opening a file. */ - private JFileChooser fileChooser; - /** The treasure lists. */ private final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree; @@ -285,6 +281,12 @@ private final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager; /** + * The file control instance. + */ + @NotNull + private final FileControl fileControl; + + /** * Constructs the main controller and its model and view. * @throws RuntimeException If the controller cannot be initialized. */ @@ -471,6 +473,7 @@ recentManager.initRecent(); validators = createMapValidators(); new AutoValidator<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, mapManager, PREFS_VALIDATOR_AUTO_DEFAULT); + fileControl = new FileControl(globalSettings, archetypeSet, mapPreviewAccessory, mapManager, mainView, mapFileFilter, luaFileFilter, newMapDialogFactory); } /** @@ -621,7 +624,7 @@ /** Edit an existing script. */ @ActionMethod public void editScript() { - openFileWanted(false); + fileControl.openFileWanted(false); } /** @@ -699,78 +702,10 @@ /** Invoked when user wants to open a file. */ public void open() { - openFileWanted(true); + fileControl.openFileWanted(true); } - /** Create the JFileChooser for opening a file. */ - private void createFileChooser() { - fileChooser = new JFileChooser(); - fileChooser.setDialogTitle(ACTION_FACTORY.getString("fileDialog.title")); - fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - fileChooser.setMultiSelectionEnabled(true); - fileChooser.addChoosableFileFilter(luaFileFilter); - fileChooser.addChoosableFileFilter(mapFileFilter); - if (globalSettings.getMapDir().exists()) { - fileChooser.setCurrentDirectory(globalSettings.getMapDir()); - } - mapPreviewAccessory.attachTo(fileChooser); - } - /** - * The user wants to open a file. The filefilters and preselected filefilter - * are set accordingly to <var>mapFilter</var>. - * @param mapFilter set to <code>true</code> if the user probably wants to - * open a map, <code>false</code> otherwise - */ - public void openFileWanted(final boolean mapFilter) { - if (fileChooser == null) { - createFileChooser(); - } - if (mapFilter) { - fileChooser.setFileFilter(mapFileFilter); - } else { - fileChooser.setFileFilter(luaFileFilter); - } - final int returnVal = fileChooser.showOpenDialog(mainView); - if (returnVal == JFileChooser.APPROVE_OPTION) { - if (archetypeSet.getLoadStatus() == ArchetypeSet.LoadStatus.EMPTY) { - // ArchStack is empty -> abort! - ACTION_FACTORY.showMessageDialog(mainView, "openFileWantedNoArches"); - return; - } - - globalSettings.setChangedDir(true); // user has chosen an active dir - openFiles(fileChooser.getCurrentDirectory(), fileChooser.getSelectedFiles()); - } - } - - /** - * Load an array of files. - * @param dir directory to load files from - * @param files array of files to load - */ - private void openFiles(final File dir, final File... files) { - for (final File file : files) { - final boolean isScriptFile = file.getName().toLowerCase().endsWith(".lua"); - if (file.isFile()) { - if (isScriptFile) { - ScriptEditControlInstance.getInstance().openScriptFile(file.getAbsolutePath()); - } else { - globalSettings.setCurrentDir(dir); - mapManager.openMapFileWithView(file, null); - } - } else if (!file.exists()) { - if (isScriptFile) { - // TODO: pass filename - ScriptEditControlInstance.getInstance().openScriptNew(); - } else { - newLevelWanted(file.getName()); - } - } // If neither branch matches, it's a directory - what to do with directories? - } - } - - /** * Load a list of map files. * @param filenames collection of filenames to load */ @@ -797,42 +732,7 @@ /** {@inheritDoc} */ public boolean saveLevelAsWanted(@NotNull final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl) { - final JFileChooser fileChooser = new JFileChooser(); - fileChooser.setDialogTitle("Save Map Or Script As"); - fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); - fileChooser.setMultiSelectionEnabled(false); - fileChooser.resetChoosableFileFilters(); - fileChooser.addChoosableFileFilter(luaFileFilter); - fileChooser.setFileFilter(mapFileFilter); - - // default folder is the map-folder at first time, then the active folder - if (!globalSettings.hasChangedDir() && globalSettings.getMapDir().exists()) { - fileChooser.setCurrentDirectory(globalSettings.getMapDir()); - } else if (globalSettings.getCurrentDir().exists()) { - fileChooser.setCurrentDirectory(globalSettings.getCurrentDir()); - } - - // if file already exists, select it - final File mapFile = mapControl.getMapFile(); - if (mapFile != null && mapFile.exists()) { - fileChooser.setSelectedFile(mapFile); - } else { - fileChooser.setSelectedFile(new File(globalSettings.getMapDir(), mapControl.getMapFileName())); - } - - final int returnVal = fileChooser.showSaveDialog(mainView); - if (returnVal != JFileChooser.APPROVE_OPTION) { - return false; - } - - globalSettings.setChangedDir(true); // user has chosen an active dir - final File file = fileChooser.getSelectedFile(); - if (!file.exists() || ACTION_FACTORY.showConfirmDialog(mainView, JOptionPane.WARNING_MESSAGE, JOptionPane.OK_CANCEL_OPTION, "overwriteOtherFile", file.getName()) == JOptionPane.OK_OPTION) { - mapControl.saveAs(file); - - globalSettings.setCurrentDir(fileChooser.getCurrentDirectory()); - } - return true; + return fileControl.saveLevelAsWanted(mapControl); } private PreferencesGroup prefsGroup; Added: trunk/daimonin/src/daieditor/FileControl.java =================================================================== --- trunk/daimonin/src/daieditor/FileControl.java (rev 0) +++ trunk/daimonin/src/daieditor/FileControl.java 2008-08-09 08:11:56 UTC (rev 4816) @@ -0,0 +1,232 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package daieditor; + +import daieditor.gameobject.Archetype; +import daieditor.gameobject.ArchetypeSet; +import daieditor.gameobject.GameObject; +import daieditor.gui.map.CMapViewBasic; +import daieditor.map.MapArchObject; +import java.awt.Component; +import java.io.File; +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.filechooser.FileFilter; +import net.sf.gridarta.GlobalSettings; +import net.sf.gridarta.MapManager; +import net.sf.gridarta.gui.map.MapPreviewAccessory; +import net.sf.gridarta.gui.newmap.NewMapDialogFactory; +import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.textedit.scripteditor.ScriptEditControlInstance; +import net.sf.japi.swing.ActionFactory; +import org.jetbrains.annotations.NotNull; + +public class FileControl { + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); + + /** + * The global settings instance. + */ + @NotNull + private final GlobalSettings globalSettings; + + /** + * The archetype set. + */ + @NotNull + private final ArchetypeSet archetypeSet; + + /** + * The map preview accessory. + */ + @NotNull + private final MapPreviewAccessory mapPreviewAccessory; + + /** + * The map manager. + */ + @NotNull + private final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager; + + /** + * The parent component for showing dialog boxes. + */ + @NotNull + private final Component parent; + + /** + * The map file filter. + */ + @NotNull + private final FileFilter mapFileFilter; + + /** + * The script file filter. + */ + @NotNull + private final FileFilter scriptFileFilter; + + /** + * The new map dialog factory. + */ + @NotNull + private final NewMapDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapDialogFactory; + + /** JFileChooser for opening a file. */ + private JFileChooser fileChooser; + + /** + * Creates a new instance. + * @param globalSettings the global settings instance + * @param archetypeSet the archetype set + * @param mapPreviewAccessory the map preview accessory + * @param mapManager the map manager + * @param parent the parent component for showing dialog boxes + * @param mapFileFilter the map file filter + * @param scriptFileFilter the script file filter + * @param newMapDialogFactory the new map dialog factory + */ + public FileControl(@NotNull final GlobalSettings globalSettings, @NotNull final ArchetypeSet archetypeSet, @NotNull final MapPreviewAccessory mapPreviewAccessory, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final Component parent, @NotNull final FileFilter mapFileFilter, @NotNull final FileFilter scriptFileFilter, @NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapDialogFactory) { + this.globalSettings = globalSettings; + this.archetypeSet = archetypeSet; + this.mapPreviewAccessory = mapPreviewAccessory; + this.mapManager = mapManager; + this.parent = parent; + this.mapFileFilter = mapFileFilter; + this.scriptFileFilter = scriptFileFilter; + this.newMapDialogFactory = newMapDialogFactory; + } + + /** Create the JFileChooser for opening a file. */ + private void createFileChooser() { + fileChooser = new JFileChooser(); + fileChooser.setDialogTitle(ACTION_FACTORY.getString("fileDialog.title")); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + fileChooser.setMultiSelectionEnabled(true); + fileChooser.addChoosableFileFilter(scriptFileFilter); + fileChooser.addChoosableFileFilter(mapFileFilter); + if (globalSettings.getMapDir().exists()) { + fileChooser.setCurrentDirectory(globalSettings.getMapDir()); + } + mapPreviewAccessory.attachTo(fileChooser); + } + + /** + * The user wants to open a file. The filefilters and preselected filefilter + * are set accordingly to <var>mapFilter</var>. + * @param mapFilter set to <code>true</code> if the user probably wants to + * open a map, <code>false</code> otherwise + */ + public void openFileWanted(final boolean mapFilter) { + if (fileChooser == null) { + createFileChooser(); + } + if (mapFilter) { + fileChooser.setFileFilter(mapFileFilter); + } else { + fileChooser.setFileFilter(scriptFileFilter); + } + final int returnVal = fileChooser.showOpenDialog(parent); + if (returnVal == JFileChooser.APPROVE_OPTION) { + if (archetypeSet.getLoadStatus() == ArchetypeSet.LoadStatus.EMPTY) { + // ArchStack is empty -> abort! + ACTION_FACTORY.showMessageDialog(parent, "openFileWantedNoArches"); + return; + } + + globalSettings.setChangedDir(true); // user has chosen an active dir + openFiles(fileChooser.getCurrentDirectory(), fileChooser.getSelectedFiles()); + } + } + + /** + * Invoked when user wants to save a map to certain file. + * @param mapControl the map to be saved + * @return <code>true</code> if the user confirmed saving the map and the + * map was saved successfully, otherwise <code>false</code> + */ + public boolean saveLevelAsWanted(@NotNull final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl) { + final JFileChooser fileChooser = new JFileChooser(); + fileChooser.setDialogTitle("Save Map Or Script As"); + fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); + fileChooser.setMultiSelectionEnabled(false); + fileChooser.resetChoosableFileFilters(); + fileChooser.addChoosableFileFilter(scriptFileFilter); + fileChooser.setFileFilter(mapFileFilter); + + // default folder is the map-folder at first time, then the active folder + if (!globalSettings.hasChangedDir() && globalSettings.getMapDir().exists()) { + fileChooser.setCurrentDirectory(globalSettings.getMapDir()); + } else if (globalSettings.getCurrentDir().exists()) { + fileChooser.setCurrentDirectory(globalSettings.getCurrentDir()); + } + + // if file already exists, select it + final File mapFile = mapControl.getMapFile(); + if (mapFile != null && mapFile.exists()) { + fileChooser.setSelectedFile(mapFile); + } else { + fileChooser.setSelectedFile(new File(globalSettings.getMapDir(), mapControl.getMapFileName())); + } + + final int returnVal = fileChooser.showSaveDialog(parent); + if (returnVal != JFileChooser.APPROVE_OPTION) { + return false; + } + + globalSettings.setChangedDir(true); // user has chosen an active dir + final File file = fileChooser.getSelectedFile(); + if (!file.exists() || ACTION_FACTORY.showConfirmDialog(parent, JOptionPane.WARNING_MESSAGE, JOptionPane.OK_CANCEL_OPTION, "overwriteOtherFile", file.getName()) == JOptionPane.OK_OPTION) { + mapControl.saveAs(file); + + globalSettings.setCurrentDir(fileChooser.getCurrentDirectory()); + } + return true; + } + + /** + * Load an array of files. + * @param dir directory to load files from + * @param files array of files to load + */ + private void openFiles(final File dir, final File... files) { + for (final File file : files) { + final boolean isScriptFile = file.getName().toLowerCase().endsWith(".lua"); + if (file.isFile()) { + if (isScriptFile) { + ScriptEditControlInstance.getInstance().openScriptFile(file.getAbsolutePath()); + } else { + globalSettings.setCurrentDir(dir); + mapManager.openMapFileWithView(file, null); + } + } else if (!file.exists()) { + if (isScriptFile) { + // TODO: pass filename + ScriptEditControlInstance.getInstance().openScriptNew(); + } else { + newMapDialogFactory.showNewMapDialog(file.getName()); + } + } // If neither branch matches, it's a directory - what to do with directories? + } + } + +} // class FileControl Property changes on: trunk/daimonin/src/daieditor/FileControl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-08-09 09:09:56
|
Revision: 4818 http://gridarta.svn.sourceforge.net/gridarta/?rev=4818&view=rev Author: akirschbaum Date: 2008-08-09 09:10:03 +0000 (Sat, 09 Aug 2008) Log Message: ----------- Improve GameObject's setter methods for text messages: replace deleteTextMsg() and resetTextMsg() with setTextMsg(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MsgTextTab.java trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2008-08-09 08:14:33 UTC (rev 4817) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2008-08-09 09:10:03 UTC (rev 4818) @@ -162,7 +162,7 @@ if (thisLine.equals("endmsg")) { msgflag = false; } else { - archetype.addMsgText(thisLine2 + "\n"); // thisLine2 allows leading whitespaces + archetype.addMsgTextLine(thisLine2); // thisLine2 allows leading whitespaces } } else if (animflag) { if (thisLine.equals("mina")) { Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2008-08-09 08:14:33 UTC (rev 4817) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2008-08-09 09:10:03 UTC (rev 4818) @@ -160,7 +160,7 @@ if (thisLine.equals("endmsg")) { msgflag = false; } else { - archetype.addMsgText(thisLine2 + "\n"); // thisLine2 allows leading whitespaces + archetype.addMsgTextLine(thisLine2); // thisLine2 allows leading whitespaces } } else if (animflag) { if (thisLine.equals("mina")) { Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-08-09 08:14:33 UTC (rev 4817) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-08-09 09:10:03 UTC (rev 4818) @@ -834,58 +834,22 @@ gameObjectChanged(); } - /** Delete message text by nullification. */ - public void deleteMsgText() { - if (msgText == null) { - return; - } - - // FIXME, see addMsgText for information - msgText = null; - gameObjectChanged(); - } - - /** Delete message text by emptying. */ - public void resetMsgText() { - if (msgText == null || msgText.length() == 0) { - return; - } - - //noinspection ConstantConditions - msgText.delete(0, msgText.length()); - gameObjectChanged(); - } - /** * Add a line of message text. This is used when creating the GameObject - * from the ArchetypeParser. Special: invoking this method with - * <code>null</code> creates an empty string. + * from the ArchetypeParser. * @param text text to append to message text */ - public void addMsgText(@Nullable final String text) { - boolean isChanged = false; - + public void addMsgTextLine(@Nullable final String text) { // It's intentional that if text == null, msgText still is created if it's empty. // FIXME: Though it's intentional, it's not nice, search for users and fix this. // (Also look at deleteMsgText() and getMsgText() then) - StringBuilder myMsgText = msgText; - if (myMsgText == null) { - myMsgText = new StringBuilder(); - msgText = myMsgText; - isChanged = true; + if (msgText == null) { + msgText = new StringBuilder(); } - if (text != null) { - final String trimmedText = StringUtils.removeTrailingWhitespace(text); - if (trimmedText.length() > 0) { - myMsgText.append(trimmedText); - isChanged = true; - } - } - - if (isChanged) { - gameObjectChanged(); - } + msgText.append(StringUtils.removeTrailingWhitespace(text)); + msgText.append("\n"); + gameObjectChanged(); } /** @@ -898,6 +862,27 @@ } /** + * Sets the message text. + * @param msgText the message text + */ + public void setMsgText(@Nullable final String msgText) { + final String trimmedMsgText = msgText == null ? null : StringUtils.removeTrailingWhitespaceFromLines(msgText); + if (this.msgText == null ? trimmedMsgText == null : this.msgText.toString().equals(trimmedMsgText)) { + return; + } + + if (trimmedMsgText == null) { + this.msgText = null; + } else if (this.msgText == null) { + this.msgText = new StringBuilder(trimmedMsgText); + } else { + this.msgText.setLength(0); + this.msgText.append(trimmedMsgText); + } + gameObjectChanged(); + } + + /** * Get the X coordinate of this GameObject on its map. This method only * guarantees a reasonable value for GameObjects that are directly bound to * a map (i.e. {@link #getTopContainer()} returns <code>null</code>). Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-08-09 08:14:33 UTC (rev 4817) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-08-09 09:10:03 UTC (rev 4818) @@ -700,18 +700,16 @@ if (newMsg[0] != null) { // set new msg text only when it is not equal to Archetype if (!newMsg[0].trim().equals(archetype.getMsgText() == null ? "" : archetype.getMsgText().trim())) { - gameObject.deleteMsgText(); - gameObject.addMsgText(newMsg[0]); + gameObject.setMsgText(newMsg[0]); } else { - gameObject.deleteMsgText(); + gameObject.setMsgText(null); } } else if (archetype.getMsgText() != null && archetype.getMsgText().trim().length() > 0) { // we must override archetype msg by an empty msg - gameObject.deleteMsgText(); - gameObject.addMsgText(""); + gameObject.setMsgText(""); } else { - gameObject.deleteMsgText(); // all empty + gameObject.setMsgText(null); // all empty } if (newAnim[0] != null) { Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MsgTextTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MsgTextTab.java 2008-08-09 08:14:33 UTC (rev 4817) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MsgTextTab.java 2008-08-09 09:10:03 UTC (rev 4818) @@ -125,19 +125,18 @@ newMsgText = ""; } if (newMsgText.equals(archetype.getMsgText().trim())) { - gameObject.deleteMsgText(); // yes, we don't need it in map + gameObject.setMsgText(null); // yes, we don't need it in map } else { - gameObject.resetMsgText(); - gameObject.addMsgText(newMsgText); + gameObject.setMsgText(newMsgText); } } else { - gameObject.resetMsgText(); - gameObject.addMsgText(archTextArea.getText()); + gameObject.setMsgText(archTextArea.getText()); } } else { // there is nothing in the msg win - gameObject.deleteMsgText(); // always delete this... if (archetype.getMsgText() != null) { - gameObject.addMsgText(""); // but here we must overrule default with msg/endmsg (empty msg) + gameObject.setMsgText(""); // but here we must overrule default with msg/endmsg (empty msg) + } else { + gameObject.setMsgText(null); // always delete this... } } } Modified: trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java 2008-08-09 08:14:33 UTC (rev 4817) +++ trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java 2008-08-09 09:10:03 UTC (rev 4818) @@ -108,7 +108,7 @@ if (thisLine.startsWith("endmsg")) { msgflag = false; } else { - gameObject.addMsgText(thisLine2 + "\n"); // thisLine2 allows leading whitespaces + gameObject.addMsgTextLine(thisLine2); // thisLine2 allows leading whitespaces } } else if (thisLine.startsWith("arch ")) { // ok, we had a full arch... don't care here about map or object @@ -123,7 +123,7 @@ } return gameObject; } else if (thisLine.startsWith("msg")) { - gameObject.addMsgText(""); + gameObject.setMsgText(""); msgflag = true; } else if (parseLine(thisLine, gameObject)) { // ignore Modified: trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-08-09 08:14:33 UTC (rev 4817) +++ trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-08-09 09:10:03 UTC (rev 4818) @@ -814,8 +814,7 @@ if (newObject != null) { newObject.setObjectText(newarchHead.getObjectText()); newObject.setObjName(newarchHead.getObjName()); - newObject.resetMsgText(); - newObject.addMsgText(newarchHead.getMsgText()); + newObject.setMsgText(newarchHead.getMsgText()); } return newObject; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-08-11 18:17:45
|
Revision: 4820 http://gridarta.svn.sourceforge.net/gridarta/?rev=4820&view=rev Author: akirschbaum Date: 2008-08-11 18:17:27 +0000 (Mon, 11 Aug 2008) Log Message: ----------- Fix crash due to reverted pickmaps. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gui/pickmapchooser/CurrentPickmapActions.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-08-09 09:52:04 UTC (rev 4819) +++ trunk/crossfire/ChangeLog 2008-08-11 18:17:27 UTC (rev 4820) @@ -1,3 +1,7 @@ +2008-08-11 Andreas Kirschbaum + + * Fix crash due to reverted pickmaps. + 2008-08-07 Andreas Kirschbaum * Fix #1816940 ('Game object text editor' should warn of unapplied Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-08-09 09:52:04 UTC (rev 4819) +++ trunk/daimonin/ChangeLog 2008-08-11 18:17:27 UTC (rev 4820) @@ -1,3 +1,7 @@ +2008-08-11 Andreas Kirschbaum + + * Fix crash due to reverted pickmaps. + 2008-08-07 Andreas Kirschbaum * Fix #1816940 ('Game object text editor' should warn of unapplied Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/CurrentPickmapActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/CurrentPickmapActions.java 2008-08-09 09:52:04 UTC (rev 4819) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/CurrentPickmapActions.java 2008-08-11 18:17:27 UTC (rev 4820) @@ -125,6 +125,7 @@ /** {@inheritDoc} */ public void pickmapReverted(@NotNull final Pickmap<G, A, R, V> pickmap) { + setCurrentPickmap(pickmap); } }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-08-12 19:04:53
|
Revision: 4823 http://gridarta.svn.sourceforge.net/gridarta/?rev=4823&view=rev Author: akirschbaum Date: 2008-08-12 19:04:57 +0000 (Tue, 12 Aug 2008) Log Message: ----------- Remove dependency MapPropertiesDialog/MapActions -> CMainControl. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/MapActions.java trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/MapActions.java trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-11 18:38:23 UTC (rev 4822) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-12 19:04:57 UTC (rev 4823) @@ -308,7 +308,7 @@ log.fatal("GameObjectMatcher 'exit' does not exist"); throw new MissingResourceException("GameObjectMatcher 'exit' does not exist", null, null); } - final MapActions mapActions = new MapActions(mainView, this, gridartaObjectsFactory, globalSettings, mapManager, mapViewManager, exitMatcher, mapFileFilter, selectedSquareView); + final MapActions mapActions = new MapActions(mainView, mainView, gridartaObjectsFactory, globalSettings, mapManager, mapViewManager, exitMatcher, mapFileFilter, selectedSquareView); archetypeTypeSet.getListTable().put("event", ScriptArchUtils.getEventTypes()); Map<String, TreasureTreeNode> specialTreasureLists; try { Modified: trunk/crossfire/src/cfeditor/MapActions.java =================================================================== --- trunk/crossfire/src/cfeditor/MapActions.java 2008-08-11 18:38:23 UTC (rev 4822) +++ trunk/crossfire/src/cfeditor/MapActions.java 2008-08-12 19:04:57 UTC (rev 4823) @@ -32,6 +32,7 @@ import java.io.IOException; import java.util.prefs.Preferences; import javax.swing.Action; +import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.filechooser.FileFilter; import net.sf.gridarta.CommonConstants; @@ -110,8 +111,10 @@ @NotNull private final Component parent; - /** The main control to use. */ - private final CMainControl mainControl; + /** + * The parent frame for help windows. + */ + private final JFrame helpParent; /** * The gridarta objects factory instance. @@ -144,7 +147,7 @@ /** * Create a new instance. * @param parent the component for showing dialog boxes - * @param mainControl the main control to use + * @param helpParent the parent frame for help windows * @param gridartaObjectsFactory the gridarta objects factory instance * @param globalSettings the global settings instance * @param mapManager the map manager @@ -153,9 +156,9 @@ * @param mapFileFilter the Swing file filter to use * @param selectedSquareView the selected square vuew to use */ - public MapActions(@NotNull final Component parent, @NotNull final CMainControl mainControl, @NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final GlobalSettings globalSettings, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager, final GameObjectMatcher exitMatcher, final FileFilter mapFileFilter, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView) { + public MapActions(@NotNull final Component parent, @NotNull final JFrame helpParent, @NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final GlobalSettings globalSettings, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager, final GameObjectMatcher exitMatcher, final FileFilter mapFileFilter, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView) { this.parent = parent; - this.mainControl = mainControl; + this.helpParent = helpParent; this.gridartaObjectsFactory = gridartaObjectsFactory; this.globalSettings = globalSettings; this.mapManager = mapManager; @@ -253,7 +256,7 @@ public void mapProperties() { final MapView<GameObject, MapArchObject, Archetype, CMapViewBasic> mapView = getMapPropertiesEnabled(); if (mapView != null) { - MapPropertiesDialog.showDialog(mapView.getComponent(), mainControl, mapManager, gridartaObjectsFactory, globalSettings, mapView.getMapControl(), mapFileFilter); + MapPropertiesDialog.showDialog(mapView.getComponent(), helpParent, mapManager, gridartaObjectsFactory, globalSettings, mapView.getMapControl(), mapFileFilter); } } Modified: trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java 2008-08-11 18:38:23 UTC (rev 4822) +++ trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java 2008-08-12 19:04:57 UTC (rev 4823) @@ -19,7 +19,6 @@ package cfeditor.gui.map; -import cfeditor.CMainControl; import cfeditor.gameobject.Archetype; import cfeditor.gameobject.GameObject; import cfeditor.map.MapArchObject; @@ -32,6 +31,7 @@ import javax.swing.JCheckBox; import javax.swing.JDialog; import javax.swing.JFormattedTextField; +import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; @@ -65,7 +65,10 @@ /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); - private final CMainControl mainControl; + /** + * The parent frame for help windows. + */ + private final JFrame helpParent; private final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl; @@ -170,18 +173,18 @@ /** * Creates a map-options dialog. - * @param mainControl The controller of this dialog. + * @param helpParent the parent frame for help windows * @param mapManager the map manager to use * @param gridartaObjectsFactory the gridarta objects factory instance * @param globalSettings the global settings instance * @param mapControl The level whose properties are shown/edited. * @param mapFileFilter the Swing file filter to use */ - private MapPropertiesDialog(final CMainControl mainControl, @NotNull final MapManager<?, MapArchObject, ?, ?> mapManager, @NotNull final GridartaObjectsFactory<?, MapArchObject, ?, ?> gridartaObjectsFactory, @NotNull final GlobalSettings globalSettings, final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, final FileFilter mapFileFilter) { + private MapPropertiesDialog(final JFrame helpParent, @NotNull final MapManager<?, MapArchObject, ?, ?> mapManager, @NotNull final GridartaObjectsFactory<?, MapArchObject, ?, ?> gridartaObjectsFactory, @NotNull final GlobalSettings globalSettings, final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, final FileFilter mapFileFilter) { okButton.setDefaultCapable(true); setOptions(new Object[] {helpButton, okButton, restoreButton, cancelButton}); - this.mainControl = mainControl; + this.helpParent = helpParent; this.mapControl = mapControl; final MapArchObject map = mapControl.getMapModel().getMapArchObject(); @@ -348,7 +351,7 @@ /** Action method for help. */ public void mapHelp() { - new Help(mainControl.getMainView(), "tut_mapattr.html").setVisible(true); + new Help(helpParent, "tut_mapattr.html").setVisible(true); } /** Action method for okay. */ @@ -630,15 +633,15 @@ /** * Show a dialog querying the user for map properties. * @param parent the parent component to show dialog on - * @param mainControl CMainControl with information + * @param helpParent the parent frame for help windows * @param mapManager the map manager to use * @param gridartaObjectsFactory the gridarta objects factory instance * @param globalSettings the global settings instance * @param level map to show dialog about * @param mapFileFilter the Swing file filter to use */ - public static void showDialog(final Component parent, @NotNull final CMainControl mainControl, @NotNull final MapManager<?, MapArchObject, ?, ?> mapManager, @NotNull final GridartaObjectsFactory<?, MapArchObject, ?, ?> gridartaObjectsFactory, @NotNull final GlobalSettings globalSettings, final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> level, final FileFilter mapFileFilter) { - final MapPropertiesDialog pane = new MapPropertiesDialog(mainControl, mapManager, gridartaObjectsFactory, globalSettings, level, mapFileFilter); + public static void showDialog(final Component parent, @NotNull final JFrame helpParent, @NotNull final MapManager<?, MapArchObject, ?, ?> mapManager, @NotNull final GridartaObjectsFactory<?, MapArchObject, ?, ?> gridartaObjectsFactory, @NotNull final GlobalSettings globalSettings, final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> level, final FileFilter mapFileFilter) { + final MapPropertiesDialog pane = new MapPropertiesDialog(helpParent, mapManager, gridartaObjectsFactory, globalSettings, level, mapFileFilter); final JDialog dialog = pane.createDialog(parent, ACTION_FACTORY.format("mapTitle", level.getMapModel().getMapArchObject().getMapDisplayName(), level.getMapFileName())); pane.dialog = dialog; dialog.getRootPane().setDefaultButton(pane.okButton); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-08-11 18:38:23 UTC (rev 4822) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-08-12 19:04:57 UTC (rev 4823) @@ -374,7 +374,7 @@ log.fatal("GameObjectMatcher 'exit' does not exist"); throw new MissingResourceException("GameObjectMatcher 'exit' does not exist", null, null); } - final MapActions mapActions = new MapActions(mainView, this, gridartaObjectsFactory, (GlobalSettingsImpl) globalSettings, mapManager, mapViewManager, exitMatcher, mapFileFilter, selectedSquareView); + final MapActions mapActions = new MapActions(mainView, mainView, gridartaObjectsFactory, (GlobalSettingsImpl) globalSettings, mapManager, mapViewManager, exitMatcher, mapFileFilter, selectedSquareView); Map<String, TreasureTreeNode> specialTreasureLists; try { final Document specialTreasureListsDocument = xmlHelper.getDocumentBuilder().parse(IOUtils.getResourceURLAsString(getConfigurationDirectory(), "TreasureLists.xml")); Modified: trunk/daimonin/src/daieditor/MapActions.java =================================================================== --- trunk/daimonin/src/daieditor/MapActions.java 2008-08-11 18:38:23 UTC (rev 4822) +++ trunk/daimonin/src/daieditor/MapActions.java 2008-08-12 19:04:57 UTC (rev 4823) @@ -32,6 +32,7 @@ import java.io.IOException; import java.util.prefs.Preferences; import javax.swing.Action; +import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.filechooser.FileFilter; import net.sf.gridarta.CommonConstants; @@ -105,8 +106,10 @@ @NotNull private final Component parent; - /** The main control to use. */ - private final CMainControl mainControl; + /** + * The parent frame for help windows. + */ + private final JFrame helpParent; /** * The gridarta objects factory instance. @@ -139,7 +142,7 @@ /** * Create a new instance. * @param parent the component for showing dialog boxes - * @param mainControl the main control to use + * @param helpParent the parent frame for help windows * @param gridartaObjectsFactory the gridarta objects factory instance * @param globalSettings the global settings instance * @param mapManager the map manager @@ -148,9 +151,9 @@ * @param mapFileFilter the Swing file filter to use * @param selectedSquareView the selected square vuew to use */ - public MapActions(@NotNull final Component parent, @NotNull final CMainControl mainControl, @NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final GlobalSettingsImpl globalSettings, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager, final GameObjectMatcher exitMatcher, final FileFilter mapFileFilter, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView) { + public MapActions(@NotNull final Component parent, @NotNull final JFrame helpParent, @NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final GlobalSettingsImpl globalSettings, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager, final GameObjectMatcher exitMatcher, final FileFilter mapFileFilter, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView) { this.parent = parent; - this.mainControl = mainControl; + this.helpParent = helpParent; this.gridartaObjectsFactory = gridartaObjectsFactory; this.globalSettings = globalSettings; this.mapManager = mapManager; @@ -248,7 +251,7 @@ public void mapProperties() { final MapView<GameObject, MapArchObject, Archetype, CMapViewBasic> mapView = getMapPropertiesEnabled(); if (mapView != null) { - MapPropertiesDialog.showDialog(mapView.getComponent(), mainControl, mapManager, gridartaObjectsFactory, globalSettings, mapView.getMapControl(), mapFileFilter); + MapPropertiesDialog.showDialog(mapView.getComponent(), helpParent, mapManager, gridartaObjectsFactory, globalSettings, mapView.getMapControl(), mapFileFilter); } } Modified: trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java 2008-08-11 18:38:23 UTC (rev 4822) +++ trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java 2008-08-12 19:04:57 UTC (rev 4823) @@ -19,7 +19,6 @@ package daieditor.gui.map; -import daieditor.CMainControl; import daieditor.GlobalSettingsImpl; import daieditor.gameobject.Archetype; import daieditor.gameobject.GameObject; @@ -40,6 +39,7 @@ import javax.swing.JDialog; import javax.swing.JFileChooser; import javax.swing.JFormattedTextField; +import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; @@ -77,7 +77,10 @@ /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); - private final CMainControl mainControl; + /** + * The parent frame for help windows. + */ + private final JFrame helpParent; /** * The global settings instance. @@ -156,18 +159,18 @@ /** * Creates a map-options dialog. - * @param mainControl The controller of this dialog. + * @param helpParent the parent frame for help windows * @param mapManager the map manager to use * @param gridartaObjectsFactory the gridarta objects factory instance * @param globalSettings the global settings instance * @param mapControl The level whose properties are shown/edited. * @param mapFileFilter the Swing file filter to use */ - private MapPropertiesDialog(@NotNull final CMainControl mainControl, @NotNull final MapManager<?, MapArchObject, ?, ?> mapManager, @NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final GlobalSettingsImpl globalSettings, final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, final FileFilter mapFileFilter) { + private MapPropertiesDialog(@NotNull final JFrame helpParent, @NotNull final MapManager<?, MapArchObject, ?, ?> mapManager, @NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final GlobalSettingsImpl globalSettings, final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, final FileFilter mapFileFilter) { okButton.setDefaultCapable(true); setOptions(new Object[] {helpButton, okButton, restoreButton, cancelButton}); - this.mainControl = mainControl; + this.helpParent = helpParent; this.globalSettings = globalSettings; this.mapControl = mapControl; final MapArchObject map = mapControl.getMapModel().getMapArchObject(); @@ -345,7 +348,7 @@ /** Action method for help. */ public void mapHelp() { - new Help(mainControl.getMainView(), "tut_mapattr.html").setVisible(true); + new Help(helpParent, "tut_mapattr.html").setVisible(true); } /** Action method for okay. */ @@ -561,15 +564,15 @@ /** * Show a dialog querying the user for map properties. * @param parent the parent component to show dialog on - * @param mainControl CMainControl with information + * @param helpParent the parent frame for help windows * @param mapManager the map manager to use * @param gridartaObjectsFactory the gridarta objects factory instance * @param globalSettings the global settings instance * @param level map to show dialog about * @param mapFileFilter the Swing file filter to use */ - public static void showDialog(final Component parent, final CMainControl mainControl, @NotNull final MapManager<?, MapArchObject, ?, ?> mapManager, @NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final GlobalSettingsImpl globalSettings, final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> level, final FileFilter mapFileFilter) { - final MapPropertiesDialog pane = new MapPropertiesDialog(mainControl, mapManager, gridartaObjectsFactory, globalSettings, level, mapFileFilter); + public static void showDialog(final Component parent, final JFrame helpParent, @NotNull final MapManager<?, MapArchObject, ?, ?> mapManager, @NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final GlobalSettingsImpl globalSettings, final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> level, final FileFilter mapFileFilter) { + final MapPropertiesDialog pane = new MapPropertiesDialog(helpParent, mapManager, gridartaObjectsFactory, globalSettings, level, mapFileFilter); final JDialog dialog = pane.createDialog(parent, ACTION_FACTORY.format("mapTitle", level.getMapModel().getMapArchObject().getMapDisplayName(), level.getMapFileName())); pane.dialog = dialog; dialog.getRootPane().setDefaultButton(pane.okButton); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-08-12 19:32:32
|
Revision: 4824 http://gridarta.svn.sourceforge.net/gridarta/?rev=4824&view=rev Author: akirschbaum Date: 2008-08-12 19:32:40 +0000 (Tue, 12 Aug 2008) Log Message: ----------- Revert r4804 -- breaks pasting multi-tile objects. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gameobject/GameObject.java Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-08-12 19:04:57 UTC (rev 4823) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-08-12 19:32:40 UTC (rev 4824) @@ -212,7 +212,7 @@ @Override public GameObject createMultiClone(final int posx, final int posy) { final GameObject newHead = createClone(posx, posy); - for (GameObject tmp = getMultiNext(); tmp != null; tmp = tmp.getMultiNext()) { + for (GameObject tmp = getArchetype().getMultiNext(); tmp != null; tmp = tmp.getMultiNext()) { newHead.addTailPart(tmp.createClone(posx + tmp.getMultiX(), posy + tmp.getMultiY())); } if (newHead.multi != null) { Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-08-12 19:04:57 UTC (rev 4823) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-08-12 19:32:40 UTC (rev 4824) @@ -362,7 +362,7 @@ @Override public GameObject createMultiClone(final int posx, final int posy) { final GameObject newHead = createClone(posx, posy); - for (GameObject tmp = getMultiNext(); tmp != null; tmp = tmp.getMultiNext()) { + for (GameObject tmp = getArchetype().getMultiNext(); tmp != null; tmp = tmp.getMultiNext()) { newHead.addTailPart(tmp.createClone(posx + tmp.getMultiX(), posy + tmp.getMultiY())); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |