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