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] |