From: <aki...@us...> - 2008-07-08 18:48:23
|
Revision: 4255 http://gridarta.svn.sourceforge.net/gridarta/?rev=4255&view=rev Author: akirschbaum Date: 2008-07-08 11:47:32 -0700 (Tue, 08 Jul 2008) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java trunk/src/app/net/sf/gridarta/CurrentMapListener.java trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java trunk/src/app/net/sf/gridarta/gui/MainView.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java trunk/src/app/net/sf/gridarta/treasurelist/TreasureCellRenderer.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-08 18:29:46 UTC (rev 4254) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-08 18:47:32 UTC (rev 4255) @@ -285,7 +285,7 @@ AbstractScriptArchEditor.initEventTypeBoxes(".py", "Python", ScriptArchUtils.createEventTypeBox()); final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, MainView.MAP_TILE_LIST_BOTTOM_DEFAULT); - selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(ACTION_FACTORY, this, mainView, mapTileListBottom, null); + selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(ACTION_FACTORY, this, mapTileListBottom, null); // Initialize the main view final GameObjectMatcher monsterMatcher = gameObjectMatchers.getMatcher("monster"); if (monsterMatcher == null) { @@ -293,7 +293,7 @@ throw new MissingResourceException("GameObjectMatcher 'monster' does not exist", null, null); } final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(getMapManager(), 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 GameObjectAttributesPanel gameObjectAttributesPanel = new GameObjectAttributesPanel(this, getMapManager(), mainView, lockedItemsControl, monsterMatcher); + final GameObjectAttributesPanel gameObjectAttributesPanel = new GameObjectAttributesPanel(this, getMapManager(), lockedItemsControl, monsterMatcher); mainView.init(gameObjectAttributesPanel, selectedSquareControl.getSelectedSquareView(), typeList, mapTileListBottom, gameObjectMatchers); mapActions.updateMenuState(); scriptControl.getView().setMenu((JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "plugins")); Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-07-08 18:29:46 UTC (rev 4254) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-07-08 18:47:32 UTC (rev 4255) @@ -26,7 +26,6 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.match.GameObjectMatcher; -import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.connectionview.LockedItemsControl; import org.jetbrains.annotations.NotNull; @@ -43,8 +42,8 @@ private static final long serialVersionUID = 1L; /* Build Panel */ - public GameObjectAttributesPanel(final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> view, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher) { - super(mainControl, mapManager, view, lockedItemsControl, monsterMatcher); + public GameObjectAttributesPanel(final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher) { + super(mainControl, mapManager, lockedItemsControl, monsterMatcher); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-07-08 18:29:46 UTC (rev 4254) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-07-08 18:47:32 UTC (rev 4255) @@ -341,7 +341,7 @@ AbstractScriptArchEditor.initEventTypeBoxes(".lua", "Lua", ScriptArchUtils.createEventTypeBox()); final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, MainView.MAP_TILE_LIST_BOTTOM_DEFAULT); - selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(ACTION_FACTORY, this, mainView, mapTileListBottom, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH)); + selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(ACTION_FACTORY, this, mapTileListBottom, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH)); // Initialize the main view final GameObjectMatcher monsterMatcher = gameObjectMatchers.getMatcher("monster"); if (monsterMatcher == null) { @@ -349,7 +349,7 @@ throw new MissingResourceException("GameObjectMatcher 'monster' does not exist", null, null); } final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(getMapManager(), 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 GameObjectAttributesPanel gameObjectAttributesPanel = new GameObjectAttributesPanel(this, getMapManager(), mainView, lockedItemsControl, monsterMatcher); + final GameObjectAttributesPanel gameObjectAttributesPanel = new GameObjectAttributesPanel(this, getMapManager(), lockedItemsControl, monsterMatcher); mainView.init(gameObjectAttributesPanel, selectedSquareControl.getSelectedSquareView(), typeList, mapTileListBottom, gameObjectMatchers); mapActions.updateMenuState(); archetypeParser = new ArchetypeParser(this, objectChooser.getArchetypeChooserControl(), animationObjects); Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-07-08 18:29:46 UTC (rev 4254) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-07-08 18:47:32 UTC (rev 4255) @@ -26,7 +26,6 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.match.GameObjectMatcher; -import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.connectionview.LockedItemsControl; import org.jetbrains.annotations.NotNull; @@ -43,8 +42,8 @@ private static final long serialVersionUID = 1L; /* Build Panel */ - public GameObjectAttributesPanel(final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> view, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher) { - super(mainControl, mapManager, view, lockedItemsControl, monsterMatcher); + public GameObjectAttributesPanel(final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher) { + super(mainControl, mapManager, lockedItemsControl, monsterMatcher); } /** {@inheritDoc} */ Modified: trunk/src/app/net/sf/gridarta/CurrentMapListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/CurrentMapListener.java 2008-07-08 18:29:46 UTC (rev 4254) +++ trunk/src/app/net/sf/gridarta/CurrentMapListener.java 2008-07-08 18:47:32 UTC (rev 4255) @@ -37,17 +37,13 @@ */ public abstract class CurrentMapListener<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R>> { - /** The main control. */ - @NotNull - private final MainControl<G, A, R, V> mainControl; - /** The map manager. */ @NotNull private final MapManager<G, A, R, V> mapManager; /** - * The map control to track, or <code>null</code> if {@link #mainControl}'s - * current map is tracked. + * The map control to track, or <code>null</code> if the current map is + * tracked. */ @Nullable private final MapControl<G, A, R, V> mapControl; @@ -118,7 +114,7 @@ }; /** - * The map manager listener which is attached to {@link #mainControl} if the + * The map manager listener which is attached to the current map if the * current map is tracked. Otherwise it is unused. */ private final MapManagerListener<G, A, R, V> mapManagerListener = new MapManagerListener<G, A, R, V>() { @@ -183,7 +179,6 @@ * current map view */ protected CurrentMapListener(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final MapManager<G, A, R, V> mapManager, @Nullable final MapControl<G, A, R, V> mapControl, final boolean trackMapModified, final boolean trackMapFileName, final boolean trackMapCursor) { - this.mainControl = mainControl; this.mapManager = mapManager; this.mapControl = mapControl; this.trackMapModified = trackMapModified; Modified: trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java 2008-07-08 18:29:46 UTC (rev 4254) +++ trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java 2008-07-08 18:47:32 UTC (rev 4255) @@ -129,8 +129,6 @@ private static final String MAPARCHPANEL_LOCATION_KEY = "MainWindowMapArchPanel.dividerLocation"; - private final MainView<G, A, R, V> mainView; - /** * The buttons for the direction panel. * @see #directionButtonGroup @@ -266,12 +264,11 @@ * @param monsterMatcher the <code>GameObjectMatcher</code> for matching * monster objects */ - protected GameObjectAttributesPanel(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final MapManager<G, A, R, V> mapManager, final MainView<G, A, R, V> mainView, final LockedItemsControl<G, A, R, V> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher) { + protected GameObjectAttributesPanel(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final MapManager<G, A, R, V> mapManager, final LockedItemsControl<G, A, R, V> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher) { super(new BorderLayout()); this.mainControl = mainControl; this.mapManager = mapManager; errorListView = new ErrorListView<G, A, R, V>(mapManager, mainControl.getSelectedSquareControl().getSelectedSquareView()); - this.mainView = mainView; gameObjectTextEditor = new GameObjectTextEditor(); Modified: trunk/src/app/net/sf/gridarta/gui/MainView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-07-08 18:29:46 UTC (rev 4254) +++ trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-07-08 18:47:32 UTC (rev 4255) @@ -151,9 +151,6 @@ /** Action Factory to create Actions. */ private final ActionFactory actionFactory; - /** The controller of this view. */ - private final MainControl<G, A, R, V> mainControl; - /** The panel that contains the object chooser. */ private final AbstractObjectChooser<G, A, R, V> objectChooser; @@ -255,7 +252,6 @@ } }); - this.mainControl = mainControl; this.objectChooser = objectChooser; this.actionFactory = actionFactory; this.aCloseAll = aCloseAll; Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java 2008-07-08 18:29:46 UTC (rev 4254) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java 2008-07-08 18:47:32 UTC (rev 4255) @@ -29,7 +29,6 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; @@ -54,8 +53,6 @@ /** Controller of this subview. */ private final MainControl<G, A, R, V> mainControl; - private final MainView<G, A, R, V> mainView; - /** The view for this controller. */ private final SelectedSquareView<G, A, R, V> view; @@ -84,15 +81,13 @@ * Create a SelectedSquareControl. * @param actionFactory the action factory * @param mainControl MainControl, used for icons - * @param mainView MainView, used for updating UI * @param mapTileListBottom set if the map tile list should be at the bottom * or on the top of the main view * @param compassIcon If non-<code>null</code>, display this icon on the top * of the list */ - public SelectedSquareControl(@NotNull final ActionFactory actionFactory, final MainControl<G, A, R, V> mainControl, final MainView<G, A, R, V> mainView, final boolean mapTileListBottom, @Nullable final ImageIcon compassIcon) { + public SelectedSquareControl(@NotNull final ActionFactory actionFactory, final MainControl<G, A, R, V> mainControl, final boolean mapTileListBottom, @Nullable final ImageIcon compassIcon) { this.mainControl = mainControl; - this.mainView = mainView; view = new SelectedSquareView<G, A, R, V>(actionFactory, this, mainControl, mapTileListBottom, compassIcon); } Modified: trunk/src/app/net/sf/gridarta/treasurelist/TreasureCellRenderer.java =================================================================== --- trunk/src/app/net/sf/gridarta/treasurelist/TreasureCellRenderer.java 2008-07-08 18:29:46 UTC (rev 4254) +++ trunk/src/app/net/sf/gridarta/treasurelist/TreasureCellRenderer.java 2008-07-08 18:47:32 UTC (rev 4255) @@ -58,8 +58,6 @@ private final ImageIcon noIcon; // icon for "NO" objects - private final ImageIcon noface; // icon for faceless arches - private final ImageIcon noarch; // icon for unknown arches /** @@ -74,7 +72,6 @@ tlistOneIcon = GUIUtils.getSysIcon(GUIConstants.TILE_TREASUREONE); yesIcon = GUIUtils.getSysIcon(GUIConstants.TILE_TR_YES); noIcon = GUIUtils.getSysIcon(GUIConstants.TILE_TR_NO); - noface = GUIUtils.getSysIcon(GUIConstants.TILE_NOFACE); noarch = GUIUtils.getSysIcon(GUIConstants.TILE_NOARCH); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-08 20:52:45
|
Revision: 4256 http://gridarta.svn.sourceforge.net/gridarta/?rev=4256&view=rev Author: akirschbaum Date: 2008-07-08 13:50:51 -0700 (Tue, 08 Jul 2008) Log Message: ----------- Remove call to MainControl.getAnimationObjects(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-08 18:47:32 UTC (rev 4255) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-08 20:50:51 UTC (rev 4256) @@ -293,7 +293,7 @@ throw new MissingResourceException("GameObjectMatcher 'monster' does not exist", null, null); } final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(getMapManager(), 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 GameObjectAttributesPanel gameObjectAttributesPanel = new GameObjectAttributesPanel(this, getMapManager(), lockedItemsControl, monsterMatcher); + final GameObjectAttributesPanel gameObjectAttributesPanel = new GameObjectAttributesPanel(this, getMapManager(), animationObjects, lockedItemsControl, monsterMatcher); mainView.init(gameObjectAttributesPanel, selectedSquareControl.getSelectedSquareView(), typeList, mapTileListBottom, gameObjectMatchers); mapActions.updateMenuState(); scriptControl.getView().setMenu((JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "plugins")); Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-07-08 18:47:32 UTC (rev 4255) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-07-08 20:50:51 UTC (rev 4256) @@ -25,6 +25,7 @@ import cfeditor.map.MapArchObject; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; +import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.connectionview.LockedItemsControl; import org.jetbrains.annotations.NotNull; @@ -42,8 +43,8 @@ private static final long serialVersionUID = 1L; /* Build Panel */ - public GameObjectAttributesPanel(final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher) { - super(mainControl, mapManager, lockedItemsControl, monsterMatcher); + public GameObjectAttributesPanel(final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher) { + super(mainControl, mapManager, animationObjects, lockedItemsControl, monsterMatcher); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-07-08 18:47:32 UTC (rev 4255) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-07-08 20:50:51 UTC (rev 4256) @@ -49,7 +49,6 @@ import java.util.Map; import java.util.MissingResourceException; import java.util.prefs.Preferences; -import javax.swing.Action; import javax.swing.JFileChooser; import javax.swing.JMenu; import javax.swing.JOptionPane; @@ -349,7 +348,7 @@ throw new MissingResourceException("GameObjectMatcher 'monster' does not exist", null, null); } final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(getMapManager(), 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 GameObjectAttributesPanel gameObjectAttributesPanel = new GameObjectAttributesPanel(this, getMapManager(), lockedItemsControl, monsterMatcher); + final GameObjectAttributesPanel gameObjectAttributesPanel = new GameObjectAttributesPanel(this, getMapManager(), animationObjects, lockedItemsControl, monsterMatcher); mainView.init(gameObjectAttributesPanel, selectedSquareControl.getSelectedSquareView(), typeList, mapTileListBottom, gameObjectMatchers); mapActions.updateMenuState(); archetypeParser = new ArchetypeParser(this, objectChooser.getArchetypeChooserControl(), animationObjects); Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-07-08 18:47:32 UTC (rev 4255) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-07-08 20:50:51 UTC (rev 4256) @@ -25,6 +25,7 @@ import daieditor.map.MapArchObject; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; +import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.connectionview.LockedItemsControl; import org.jetbrains.annotations.NotNull; @@ -42,8 +43,8 @@ private static final long serialVersionUID = 1L; /* Build Panel */ - public GameObjectAttributesPanel(final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher) { - super(mainControl, mapManager, lockedItemsControl, monsterMatcher); + public GameObjectAttributesPanel(final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher) { + super(mainControl, mapManager, animationObjects, lockedItemsControl, monsterMatcher); } /** {@inheritDoc} */ Modified: trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java 2008-07-08 18:47:32 UTC (rev 4255) +++ trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java 2008-07-08 20:50:51 UTC (rev 4256) @@ -50,6 +50,7 @@ import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.connectionview.ConnectionControl; import net.sf.gridarta.gui.connectionview.LockedItemsControl; @@ -109,6 +110,10 @@ /** The map manager. */ private final MapManager<G, A, R, V> mapManager; + /** The animtation objects instance to use. */ + @NotNull + private final AnimationObjects<?> animationObjects; + /** The tabs of this GameObjectAttributesPanel. */ protected final JTabbedPane panelDesktop = new JTabbedPane(SwingConstants.TOP); @@ -264,10 +269,11 @@ * @param monsterMatcher the <code>GameObjectMatcher</code> for matching * monster objects */ - protected GameObjectAttributesPanel(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final MapManager<G, A, R, V> mapManager, final LockedItemsControl<G, A, R, V> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher) { + protected GameObjectAttributesPanel(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<G, A, R, V> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher) { super(new BorderLayout()); this.mainControl = mainControl; this.mapManager = mapManager; + this.animationObjects = animationObjects; errorListView = new ErrorListView<G, A, R, V>(mapManager, mainControl.getSelectedSquareControl().getSelectedSquareView()); gameObjectTextEditor = new GameObjectTextEditor(); @@ -380,7 +386,7 @@ } if (animName != null) { final StringBuilder animText = new StringBuilder(animName); - if (!mainControl.getAnimationObjects().containsKey(animName)) { + if (!animationObjects.containsKey(animName)) { panelDesktop.setForegroundAt(3, Color.red); animText.append(" (** unknown animation **)"); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-08 21:00:54
|
Revision: 4257 http://gridarta.svn.sourceforge.net/gridarta/?rev=4257&view=rev Author: akirschbaum Date: 2008-07-08 13:59:57 -0700 (Tue, 08 Jul 2008) Log Message: ----------- Remove call to MainControl.getAnimationObjects(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/gui/MainActions.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-08 20:50:51 UTC (rev 4256) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-08 20:59:57 UTC (rev 4257) @@ -234,7 +234,7 @@ globalSettings.readGlobalSettings(); PathManager.setGlobalSettings(globalSettings); objectChooser = new ObjectChooser(newMapDialogFactory, this, new File(globalSettings.getMapDir(), IGUIConstants.PICKMAP_DIR)); - mainActions = new MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, ACTION_FACTORY, faceObjects, objectChooser); + mainActions = new MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, animationObjects, ACTION_FACTORY, faceObjects, objectChooser); getGridartaObjectsFactory().init(faceObjects, objectChooser, objectChooser.getArchetypeChooserControl()); mainView = new MainView<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, objectChooser, getMapManager(), ACTION_FACTORY, mapManagerActions.getCloseAllAction(), faceObjects); new About("cfeditor", mainView); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-07-08 20:50:51 UTC (rev 4256) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-07-08 20:59:57 UTC (rev 4257) @@ -287,7 +287,7 @@ globalSettings.readGlobalSettings(); PathManager.setGlobalSettings(globalSettings); objectChooser = new ObjectChooser(newMapDialogFactory, this, new File(globalSettings.getArchDefaultFolder(), IGUIConstants.PICKMAP_DIR)); - mainActions = new MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, ACTION_FACTORY, faceObjects, objectChooser); + mainActions = new MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, animationObjects, ACTION_FACTORY, faceObjects, objectChooser); getGridartaObjectsFactory().init(faceObjects, objectChooser, objectChooser.getArchetypeChooserControl()); mainView = new MainView<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, objectChooser, getMapManager(), ACTION_FACTORY, mapManagerActions.getCloseAllAction(), faceObjects); new About("daieditor", mainView); Modified: trunk/src/app/net/sf/gridarta/gui/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-07-08 20:50:51 UTC (rev 4256) +++ trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-07-08 20:59:57 UTC (rev 4257) @@ -33,6 +33,7 @@ import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.Collector; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapCursorListener; @@ -62,6 +63,10 @@ /** The MainControl. */ private final MainControl<G, A, R, V> mainControl; + /** The animation objects instance to use. */ + @NotNull + private final AnimationObjects<?> animationObjects; + /** The ActionFactory. */ @NotNull private final ActionFactory actionFactory; @@ -272,9 +277,11 @@ * @param mainControl the MainControl * @param actionFactory The action factory to create actions. * @param faceObjects the FaceObjects instance to use + * @param objectChooser the animation objects instance to use */ - public MainActions(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ActionFactory actionFactory, @NotNull final FaceObjects faceObjects, @NotNull final ObjectChooser<G, A, R, V> objectChooser) { + public MainActions(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final AnimationObjects<?> animationObjects, @NotNull final ActionFactory actionFactory, @NotNull final FaceObjects faceObjects, @NotNull final ObjectChooser<G, A, R, V> objectChooser) { this.mainControl = mainControl; + this.animationObjects = animationObjects; this.actionFactory = actionFactory; this.faceObjects = faceObjects; this.objectChooser = objectChooser; @@ -581,7 +588,7 @@ final List<Collectable> collectables = new ArrayList<Collectable>(); collector = new Collector(collectArches); collectables.add(mainControl.getArchetypeSet()); - collectables.add(mainControl.getAnimationObjects()); + collectables.add(animationObjects); collectables.add(faceObjects); collector.setCollectables(collectables); collector.setDestDir(new File(mainControl.getCollectedDirectory())); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-08 21:09:16
|
Revision: 4258 http://gridarta.svn.sourceforge.net/gridarta/?rev=4258&view=rev Author: akirschbaum Date: 2008-07-08 14:08:41 -0700 (Tue, 08 Jul 2008) Log Message: ----------- Remove call to MainControl.getAnimationObjects(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-08 20:59:57 UTC (rev 4257) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-08 21:08:41 UTC (rev 4258) @@ -624,7 +624,7 @@ // types.xml is missing! ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoTypes"); } else if (gameObject != null && !gameObject.hasUndefinedArchetype()) { - GameObjectAttributesDialog.showAttribDialog(typeList, gameObject, this, getMapManager(), treasureListTree, faceObjects); + GameObjectAttributesDialog.showAttribDialog(typeList, gameObject, this, animationObjects, getMapManager(), treasureListTree, faceObjects); } else { ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoDefaultArch"); } Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2008-07-08 20:59:57 UTC (rev 4257) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2008-07-08 21:08:41 UTC (rev 4258) @@ -37,6 +37,7 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.ArchAttribType; +import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialog; import net.sf.gridarta.gui.gameobjectattributesdialog.BitmaskAttrib; @@ -76,16 +77,17 @@ * @param archTypeList the list of CF type-data * @param gameObject the GameObject to be displayed by this dialog * @param mainControl main control + * @param animationObjects the animation objects instance to use * @param mapManager the map manager * @param treasureListTree the treasure list tree instance to use * @param faceObjects the FaceObjects instance to use */ - public static void showAttribDialog(final CFArchTypeList archTypeList, final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects) { + public static void showAttribDialog(final CFArchTypeList archTypeList, final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final AnimationObjects<?> animationObjects, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects) { synchronized (dialogs) { if (dialogs.containsKey(gameObject)) { dialogs.get(gameObject).toFront(); } else { - final GameObjectAttributesDialog pane = new GameObjectAttributesDialog(archTypeList, gameObject, mainControl, mapManager, treasureListTree, faceObjects); + final GameObjectAttributesDialog pane = new GameObjectAttributesDialog(archTypeList, gameObject, mainControl, animationObjects, mapManager, treasureListTree, faceObjects); final JDialog dialog = pane.createDialog(mainControl.getMainView(), ACTION_FACTORY.getString("attribTitle")); dialog.getRootPane().setDefaultButton(pane.okButton); dialog.setResizable(true); @@ -101,12 +103,13 @@ * @param archTypeList the list of CF type-data * @param gameObject the GameObject to be displayed by this dialog * @param mainControl main control + * @param animationObjects the animation objects instance to use * @param mapManager the map manager * @param treasureListTree the treasure list tree * @param faceObjects the FaceObjects instance to use */ - private GameObjectAttributesDialog(final CFArchTypeList archTypeList, @NotNull final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects) { - super(archTypeList, gameObject, mainControl, treasureListTree, faceObjects); + private GameObjectAttributesDialog(final CFArchTypeList archTypeList, @NotNull final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final AnimationObjects<?> animationObjects, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects) { + super(archTypeList, gameObject, mainControl, animationObjects, treasureListTree, faceObjects); this.mapManager = mapManager; } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-07-08 20:59:57 UTC (rev 4257) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-07-08 21:08:41 UTC (rev 4258) @@ -805,7 +805,7 @@ // types.xml is missing! ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoTypes"); } else if (gameObject != null && !gameObject.hasUndefinedArchetype()) { - GameObjectAttributesDialog.showAttribDialog(typeList, gameObject, this, getMapManager(), treasureListTree, faceObjects); + GameObjectAttributesDialog.showAttribDialog(typeList, gameObject, this, animationObjects, getMapManager(), treasureListTree, faceObjects); } else { ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoDefaultArch"); } Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java 2008-07-08 20:59:57 UTC (rev 4257) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java 2008-07-08 21:08:41 UTC (rev 4258) @@ -37,6 +37,7 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.ArchAttribType; +import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialog; import net.sf.gridarta.gui.gameobjectattributesdialog.BitmaskAttrib; @@ -75,16 +76,17 @@ * @param archTypeList the list of CF type-data * @param gameObject the GameObject to be displayed by this dialog * @param mainControl main control + * @param animationObjects the animation objects instance to use * @param mapManager the map manager * @param treasureListTree the treasure list tree instance to use * @param faceObjects the FaceObjects instance to use */ - public static void showAttribDialog(final CFArchTypeList archTypeList, final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects) { + public static void showAttribDialog(final CFArchTypeList archTypeList, final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final AnimationObjects<?> animationObjects, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects) { synchronized (dialogs) { if (dialogs.containsKey(gameObject)) { dialogs.get(gameObject).toFront(); } else { - final GameObjectAttributesDialog pane = new GameObjectAttributesDialog(archTypeList, gameObject, mainControl, mapManager, treasureListTree, faceObjects); + final GameObjectAttributesDialog pane = new GameObjectAttributesDialog(archTypeList, gameObject, mainControl, animationObjects, mapManager, treasureListTree, faceObjects); final JDialog dialog = pane.createDialog(mainControl.getMainView(), ACTION_FACTORY.getString("attribTitle")); dialog.getRootPane().setDefaultButton(pane.okButton); dialog.setResizable(true); @@ -100,12 +102,13 @@ * @param archTypeList the list of CF type-data * @param gameObject the GameObject to be displayed by this dialog * @param mainControl main control + * @param animationObjects the animation objects instance to use * @param mapManager the map manager * @param treasureListTree the treasure list tree * @param faceObjects the FaceObjects instance to use */ - private GameObjectAttributesDialog(final CFArchTypeList archTypeList, @NotNull final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects) { - super(archTypeList, gameObject, mainControl, treasureListTree, faceObjects); + private GameObjectAttributesDialog(final CFArchTypeList archTypeList, @NotNull final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final AnimationObjects<?> animationObjects, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects) { + super(archTypeList, gameObject, mainControl, animationObjects, treasureListTree, faceObjects); this.mapManager = mapManager; } Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java 2008-07-08 20:59:57 UTC (rev 4257) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java 2008-07-08 21:08:41 UTC (rev 4258) @@ -83,6 +83,7 @@ import net.sf.gridarta.gameobject.ArchAttribType; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gui.map.TilePanel; import net.sf.gridarta.help.Help; @@ -121,7 +122,11 @@ /** Reference to MainControl. */ protected final MainControl<G, A, R, ?> mainControl; + /** The animation objects to use. */ @NotNull + private final AnimationObjects<?> animationObjects; + + @NotNull private final CFTreasureListTree<G, A, R> treasureListTree; /** The FaceObjects instance to use. */ @@ -183,13 +188,15 @@ * @param archTypeList Reference to the list of CFArchTypes. * @param gameObject GameObject to show dialog for. * @param mainControl MainControl, for retrieving AnimationObjects etc. + * @param animationObjects the animation objects instance to use * @param treasureListTree the treasure list tree * @param faceObjects the face objects instance to use */ - protected AbstractGameObjectAttributesDialog(final CFArchTypeList archTypeList, @NotNull final G gameObject, @NotNull final MainControl<G, A, R, ?> mainControl, @NotNull final CFTreasureListTree<G, A, R> treasureListTree, @NotNull final FaceObjects faceObjects) { + protected AbstractGameObjectAttributesDialog(final CFArchTypeList archTypeList, @NotNull final G gameObject, @NotNull final MainControl<G, A, R, ?> mainControl, @NotNull final AnimationObjects<?> animationObjects, @NotNull final CFTreasureListTree<G, A, R> treasureListTree, @NotNull final FaceObjects faceObjects) { this.archTypeList = archTypeList; this.gameObject = gameObject.getHead(); this.mainControl = mainControl; + this.animationObjects = animationObjects; this.treasureListTree = treasureListTree; this.faceObjects = faceObjects; archetype = this.gameObject.getArchetype(); @@ -686,7 +693,7 @@ cLabel = new JButton(new TreeChooseAction(attrib.getNameNew() + ": ", input, faceObjects)); break; case ANIMNAME: - cLabel = new JButton(new TreeChooseAction(attrib.getNameNew() + ": ", input, mainControl.getAnimationObjects())); + cLabel = new JButton(new TreeChooseAction(attrib.getNameNew() + ": ", input, animationObjects)); break; default: throw new AssertionError(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-08 21:18:04
|
Revision: 4259 http://gridarta.svn.sourceforge.net/gridarta/?rev=4259&view=rev Author: akirschbaum Date: 2008-07-08 14:17:51 -0700 (Tue, 08 Jul 2008) Log Message: ----------- Remove call to MainControl.getArchetypeSet(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-08 21:08:41 UTC (rev 4258) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-08 21:17:51 UTC (rev 4259) @@ -297,7 +297,7 @@ mainView.init(gameObjectAttributesPanel, selectedSquareControl.getSelectedSquareView(), typeList, mapTileListBottom, gameObjectMatchers); mapActions.updateMenuState(); scriptControl.getView().setMenu((JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "plugins")); - archetypeParser = new ArchetypeParser(this, objectChooser.getArchetypeChooserControl(), animationObjects); + archetypeParser = new ArchetypeParser(this, objectChooser.getArchetypeChooserControl(), animationObjects, archetypeSet); archetypeSet.loadArchetypes(archetypeParser); if (globalSettings.isAutoPopupDocu()) { Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2008-07-08 21:08:41 UTC (rev 4258) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2008-07-08 21:17:51 UTC (rev 4259) @@ -58,6 +58,10 @@ private final AnimationObjects<?> animationObjects; + /** The archetype set. */ + @NotNull + private final ArchetypeSet archetypeSet; + /** The archetype chooser to add parsed archetypes to. */ private final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl; @@ -73,11 +77,13 @@ * @param archetypeChooserControl an archetype chooser to add parsed * archetypes to * @param animationObjects the animation objects instance to use + * @param archetypeSet the archetype set */ - public ArchetypeParser(final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final AnimationObjects<?> animationObjects) { + public ArchetypeParser(final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final AnimationObjects<?> animationObjects, @NotNull final ArchetypeSet archetypeSet) { this.mainControl = mainControl; this.archetypeChooserControl = archetypeChooserControl; this.animationObjects = animationObjects; + this.archetypeSet = archetypeSet; } /** {@inheritDoc} */ @@ -93,7 +99,7 @@ final boolean isInternPath; // path is needed when we don't read from collection because there is no editor_folder in arc files @Nullable final String path; - if (!mainControl.getArchetypeSet().isLoadedFromArchive() && archName == null) { + if (!archetypeSet.isLoadedFromArchive() && archName == null) { String tmpPath = (new File(PathManager.getArchPath(fname))).getParent(); if (tmpPath == null) { tmpPath = "/"; @@ -211,7 +217,7 @@ if (!isInternPath && !(editorFolder != null && editorFolder.contains("intern")) && !archetype.getArchetypeName().equals(STARTARCH_NAME)) { final String panel; final String folder; - if (!mainControl.getArchetypeSet().isLoadedFromArchive() || archName != null) { + if (!archetypeSet.isLoadedFromArchive() || archName != null) { panel = panelName; folder = folderName; } else { @@ -230,7 +236,7 @@ } archetype.postParseArchetype(); archetype.setIsArchetype(); - mainControl.getArchetypeSet().addArchetype(archetype); + archetypeSet.addArchetype(archetype); archmore = false; // we assume this is last... but perhaps.. Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-07-08 21:08:41 UTC (rev 4258) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-07-08 21:17:51 UTC (rev 4259) @@ -351,7 +351,7 @@ final GameObjectAttributesPanel gameObjectAttributesPanel = new GameObjectAttributesPanel(this, getMapManager(), animationObjects, lockedItemsControl, monsterMatcher); mainView.init(gameObjectAttributesPanel, selectedSquareControl.getSelectedSquareView(), typeList, mapTileListBottom, gameObjectMatchers); mapActions.updateMenuState(); - archetypeParser = new ArchetypeParser(this, objectChooser.getArchetypeChooserControl(), animationObjects); + archetypeParser = new ArchetypeParser(this, objectChooser.getArchetypeChooserControl(), animationObjects, archetypeSet); archetypeSet.loadArchetypes(archetypeParser); if (globalSettings.isAutoPopupDocu()) { Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2008-07-08 21:08:41 UTC (rev 4258) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2008-07-08 21:17:51 UTC (rev 4259) @@ -59,6 +59,10 @@ private final AnimationObjects<?> animationObjects; + /** The archetype set. */ + @NotNull + private final ArchetypeSet archetypeSet; + /** The archetype chooser to add parsed archetypes to. */ private final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl; @@ -74,11 +78,13 @@ * @param archetypeChooserControl an archetype chooser to add parsed * archetypes to * @param animationObjects the animation objects instance to use + * @param archetypeSet the archetype set */ - public ArchetypeParser(final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final AnimationObjects<?> animationObjects) { + public ArchetypeParser(final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final AnimationObjects<?> animationObjects, @NotNull final ArchetypeSet archetypeSet) { this.mainControl = mainControl; this.archetypeChooserControl = archetypeChooserControl; this.animationObjects = animationObjects; + this.archetypeSet = archetypeSet; } /** {@inheritDoc} */ @@ -95,7 +101,7 @@ final boolean isInternPath; // path is needed when we don't read from collection because there is no editor_folder in arc files @Nullable final String path; - if (!mainControl.getArchetypeSet().isLoadedFromArchive() && archName == null) { + if (!archetypeSet.isLoadedFromArchive() && archName == null) { String tmpPath = (new File(PathManager.getArchPath(fname))).getParent(); if (tmpPath == null) { tmpPath = "/"; @@ -211,7 +217,7 @@ if (!isInternPath && !(editorFolder != null && editorFolder.contains("intern"))) { final String panel; final String folder; - if (!mainControl.getArchetypeSet().isLoadedFromArchive() || archName != null) { + if (!archetypeSet.isLoadedFromArchive() || archName != null) { panel = panelName; folder = folderName; } else { @@ -230,7 +236,7 @@ } archetype.postParseArchetype(); archetype.setIsArchetype(); - mainControl.getArchetypeSet().addArchetype(archetype); + archetypeSet.addArchetype(archetype); if (archmore) { calcLowestMulti(archetype); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-08 21:40:06
|
Revision: 4260 http://gridarta.svn.sourceforge.net/gridarta/?rev=4260&view=rev Author: akirschbaum Date: 2008-07-08 14:39:52 -0700 (Tue, 08 Jul 2008) Log Message: ----------- Extract GameObjectAttributesDialogFactory from GameObjectAttributesDialog. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java Added Paths: ----------- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialogFactory.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialogFactory.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialogFactory.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-08 21:17:51 UTC (rev 4259) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-08 21:39:52 UTC (rev 4260) @@ -27,7 +27,7 @@ import cfeditor.gameobject.anim.AnimationObject; import cfeditor.gameobject.face.FaceObjects; import cfeditor.gameobject.scripts.ScriptArchUtils; -import cfeditor.gui.GameObjectAttributesDialog; +import cfeditor.gui.GameObjectAttributesDialogFactory; import cfeditor.gui.GameObjectAttributesPanel; import cfeditor.gui.ObjectChooser; import cfeditor.gui.map.CMapViewBasic; @@ -624,7 +624,7 @@ // types.xml is missing! ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoTypes"); } else if (gameObject != null && !gameObject.hasUndefinedArchetype()) { - GameObjectAttributesDialog.showAttribDialog(typeList, gameObject, this, animationObjects, getMapManager(), treasureListTree, faceObjects); + GameObjectAttributesDialogFactory.showAttribDialog(typeList, gameObject, this, animationObjects, getMapManager(), treasureListTree, faceObjects); } else { ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoDefaultArch"); } Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2008-07-08 21:17:51 UTC (rev 4259) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2008-07-08 21:39:52 UTC (rev 4260) @@ -27,7 +27,6 @@ import java.util.Vector; import javax.swing.JCheckBox; import javax.swing.JComboBox; -import javax.swing.JDialog; import javax.swing.JFormattedTextField; import javax.swing.JTextField; import javax.swing.text.JTextComponent; @@ -50,7 +49,6 @@ import net.sf.gridarta.spells.Spells; import net.sf.gridarta.textedit.textarea.JEditTextArea; import net.sf.gridarta.treasurelist.CFTreasureListTree; -import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; /** @@ -64,41 +62,10 @@ /** Serial Version UID. */ private static final long serialVersionUID = 1L; - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); - /** The map manager. */ private final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager; /** - * Wrapper method for the constructor. This method only creates a - * GameObjectAttributesDialog if there's no dialog for the same gameObject - * already. - * @param archTypeList the list of CF type-data - * @param gameObject the GameObject to be displayed by this dialog - * @param mainControl main control - * @param animationObjects the animation objects instance to use - * @param mapManager the map manager - * @param treasureListTree the treasure list tree instance to use - * @param faceObjects the FaceObjects instance to use - */ - public static void showAttribDialog(final CFArchTypeList archTypeList, final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final AnimationObjects<?> animationObjects, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects) { - synchronized (dialogs) { - if (dialogs.containsKey(gameObject)) { - dialogs.get(gameObject).toFront(); - } else { - final GameObjectAttributesDialog pane = new GameObjectAttributesDialog(archTypeList, gameObject, mainControl, animationObjects, mapManager, treasureListTree, faceObjects); - final JDialog dialog = pane.createDialog(mainControl.getMainView(), ACTION_FACTORY.getString("attribTitle")); - dialog.getRootPane().setDefaultButton(pane.okButton); - dialog.setResizable(true); - dialog.setModal(false); - dialog.setVisible(true); - dialogs.put(pane.gameObject, dialog); - } - } - } - - /** * Constructor, creates the GUI layout. * @param archTypeList the list of CF type-data * @param gameObject the GameObject to be displayed by this dialog @@ -108,7 +75,7 @@ * @param treasureListTree the treasure list tree * @param faceObjects the FaceObjects instance to use */ - private GameObjectAttributesDialog(final CFArchTypeList archTypeList, @NotNull final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final AnimationObjects<?> animationObjects, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects) { + public GameObjectAttributesDialog(final CFArchTypeList archTypeList, @NotNull final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final AnimationObjects<?> animationObjects, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects) { super(archTypeList, gameObject, mainControl, animationObjects, treasureListTree, faceObjects); this.mapManager = mapManager; } Added: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialogFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialogFactory.java (rev 0) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialogFactory.java 2008-07-08 21:39:52 UTC (rev 4260) @@ -0,0 +1,50 @@ +package cfeditor.gui; + +import cfeditor.gameobject.Archetype; +import cfeditor.gameobject.GameObject; +import cfeditor.gui.map.CMapViewBasic; +import cfeditor.map.MapArchObject; +import javax.swing.JDialog; +import net.sf.gridarta.CFArchTypeList; +import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; +import net.sf.gridarta.gameobject.anim.AnimationObjects; +import net.sf.gridarta.gameobject.face.FaceObjects; +import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialogFactory; +import net.sf.gridarta.treasurelist.CFTreasureListTree; +import net.sf.japi.swing.ActionFactory; +import org.jetbrains.annotations.NotNull; + +public class GameObjectAttributesDialogFactory extends AbstractGameObjectAttributesDialogFactory { + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); + + /** + * Wrapper method for the constructor. This method only creates a + * GameObjectAttributesDialog if there's no dialog for the same gameObject + * already. + * @param archTypeList the list of CF type-data + * @param gameObject the GameObject to be displayed by this dialog + * @param mainControl main control + * @param animationObjects the animation objects instance to use + * @param mapManager the map manager + * @param treasureListTree the treasure list tree instance to use + * @param faceObjects the FaceObjects instance to use + */ + public static void showAttribDialog(final CFArchTypeList archTypeList, final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final AnimationObjects<?> animationObjects, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects) { + synchronized (dialogs) { + if (AbstractGameObjectAttributesDialogFactory.dialogs.containsKey(gameObject)) { + AbstractGameObjectAttributesDialogFactory.dialogs.get(gameObject).toFront(); + } else { + final GameObjectAttributesDialog pane = new GameObjectAttributesDialog(archTypeList, gameObject, mainControl, animationObjects, mapManager, treasureListTree, faceObjects); + final JDialog dialog = pane.createDialog(mainControl.getMainView(), ACTION_FACTORY.getString("attribTitle")); + dialog.getRootPane().setDefaultButton(pane.okButton); + dialog.setResizable(true); + dialog.setModal(false); + dialog.setVisible(true); + dialogs.put(pane.gameObject, dialog); + } + } + } +} Property changes on: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialogFactory.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-07-08 21:17:51 UTC (rev 4259) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-07-08 21:39:52 UTC (rev 4260) @@ -26,7 +26,7 @@ import daieditor.gameobject.anim.AnimationObject; import daieditor.gameobject.face.FaceObjects; import daieditor.gameobject.scripts.ScriptArchUtils; -import daieditor.gui.GameObjectAttributesDialog; +import daieditor.gui.GameObjectAttributesDialogFactory; import daieditor.gui.GameObjectAttributesPanel; import daieditor.gui.ObjectChooser; import daieditor.gui.map.CMapViewBasic; @@ -805,7 +805,7 @@ // types.xml is missing! ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoTypes"); } else if (gameObject != null && !gameObject.hasUndefinedArchetype()) { - GameObjectAttributesDialog.showAttribDialog(typeList, gameObject, this, animationObjects, getMapManager(), treasureListTree, faceObjects); + GameObjectAttributesDialogFactory.showAttribDialog(typeList, gameObject, this, animationObjects, getMapManager(), treasureListTree, faceObjects); } else { ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoDefaultArch"); } Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java 2008-07-08 21:17:51 UTC (rev 4259) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java 2008-07-08 21:39:52 UTC (rev 4260) @@ -27,7 +27,6 @@ import java.util.Vector; import javax.swing.JCheckBox; import javax.swing.JComboBox; -import javax.swing.JDialog; import javax.swing.JFormattedTextField; import javax.swing.JTextField; import javax.swing.text.JTextComponent; @@ -49,7 +48,6 @@ import net.sf.gridarta.spells.Spells; import net.sf.gridarta.textedit.textarea.JEditTextArea; import net.sf.gridarta.treasurelist.CFTreasureListTree; -import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; /** @@ -63,41 +61,10 @@ /** Serial Version UID. */ private static final long serialVersionUID = 1L; - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); - /** The map manager. */ private final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager; /** - * Wrapper method for the constructor. This method only creates a - * GameObjectAttributesDialog if there's no dialog for the same gameObject - * already. - * @param archTypeList the list of CF type-data - * @param gameObject the GameObject to be displayed by this dialog - * @param mainControl main control - * @param animationObjects the animation objects instance to use - * @param mapManager the map manager - * @param treasureListTree the treasure list tree instance to use - * @param faceObjects the FaceObjects instance to use - */ - public static void showAttribDialog(final CFArchTypeList archTypeList, final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final AnimationObjects<?> animationObjects, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects) { - synchronized (dialogs) { - if (dialogs.containsKey(gameObject)) { - dialogs.get(gameObject).toFront(); - } else { - final GameObjectAttributesDialog pane = new GameObjectAttributesDialog(archTypeList, gameObject, mainControl, animationObjects, mapManager, treasureListTree, faceObjects); - final JDialog dialog = pane.createDialog(mainControl.getMainView(), ACTION_FACTORY.getString("attribTitle")); - dialog.getRootPane().setDefaultButton(pane.okButton); - dialog.setResizable(true); - dialog.setModal(false); - dialog.setVisible(true); - dialogs.put(pane.gameObject, dialog); - } - } - } - - /** * Constructor, creates the GUI layout. * @param archTypeList the list of CF type-data * @param gameObject the GameObject to be displayed by this dialog @@ -107,7 +74,7 @@ * @param treasureListTree the treasure list tree * @param faceObjects the FaceObjects instance to use */ - private GameObjectAttributesDialog(final CFArchTypeList archTypeList, @NotNull final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final AnimationObjects<?> animationObjects, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects) { + public GameObjectAttributesDialog(final CFArchTypeList archTypeList, @NotNull final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final AnimationObjects<?> animationObjects, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects) { super(archTypeList, gameObject, mainControl, animationObjects, treasureListTree, faceObjects); this.mapManager = mapManager; } Added: trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialogFactory.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialogFactory.java (rev 0) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialogFactory.java 2008-07-08 21:39:52 UTC (rev 4260) @@ -0,0 +1,50 @@ +package daieditor.gui; + +import daieditor.gameobject.Archetype; +import daieditor.gameobject.GameObject; +import daieditor.gui.map.CMapViewBasic; +import daieditor.map.MapArchObject; +import javax.swing.JDialog; +import net.sf.gridarta.CFArchTypeList; +import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; +import net.sf.gridarta.gameobject.anim.AnimationObjects; +import net.sf.gridarta.gameobject.face.FaceObjects; +import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialogFactory; +import net.sf.gridarta.treasurelist.CFTreasureListTree; +import net.sf.japi.swing.ActionFactory; +import org.jetbrains.annotations.NotNull; + +public class GameObjectAttributesDialogFactory extends AbstractGameObjectAttributesDialogFactory { + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); + + /** + * Wrapper method for the constructor. This method only creates a + * GameObjectAttributesDialog if there's no dialog for the same gameObject + * already. + * @param archTypeList the list of CF type-data + * @param gameObject the GameObject to be displayed by this dialog + * @param mainControl main control + * @param animationObjects the animation objects instance to use + * @param mapManager the map manager + * @param treasureListTree the treasure list tree instance to use + * @param faceObjects the FaceObjects instance to use + */ + public static void showAttribDialog(final CFArchTypeList archTypeList, final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final AnimationObjects<?> animationObjects, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects) { + synchronized (dialogs) { + if (dialogs.containsKey(gameObject)) { + dialogs.get(gameObject).toFront(); + } else { + final GameObjectAttributesDialog pane = new GameObjectAttributesDialog(archTypeList, gameObject, mainControl, animationObjects, mapManager, treasureListTree, faceObjects); + final JDialog dialog = pane.createDialog(mainControl.getMainView(), ACTION_FACTORY.getString("attribTitle")); + dialog.getRootPane().setDefaultButton(pane.okButton); + dialog.setResizable(true); + dialog.setModal(false); + dialog.setVisible(true); + dialogs.put(pane.gameObject, dialog); + } + } + } +} Property changes on: trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialogFactory.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java 2008-07-08 21:17:51 UTC (rev 4259) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java 2008-07-08 21:39:52 UTC (rev 4260) @@ -37,9 +37,7 @@ import java.io.File; import java.text.NumberFormat; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.Vector; import javax.swing.Action; import javax.swing.BorderFactory; @@ -141,7 +139,7 @@ /** The game object being modified. */ @NotNull - protected final G gameObject; + public final G gameObject; protected final Archetype<G, A, R> archetype; @@ -166,7 +164,7 @@ private JButton cancelButton; /** The Button for ok. */ - protected JButton okButton; + public JButton okButton; /** Central tabbed pane (the place where all the attribute tabs are). */ private JTabbedPane tabbedPane; @@ -178,12 +176,6 @@ private final JTextPane summaryTP; /** - * The gameObject objects that already are shown, to avoid opening a dialog - * twice. - */ - protected static final Map<GameObject<?, ?, ?>, JDialog> dialogs = new HashMap<GameObject<?, ?, ?>, JDialog>(); - - /** * Create an AbstractGameObjectAttributesDialog. * @param archTypeList Reference to the list of CFArchTypes. * @param gameObject GameObject to show dialog for. @@ -244,7 +236,7 @@ public void setValue(final Object newValue) { super.setValue(newValue); if (newValue != UNINITIALIZED_VALUE) { - dialogs.remove(gameObject).dispose(); + AbstractGameObjectAttributesDialogFactory.dialogs.remove(gameObject).dispose(); } } Added: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialogFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialogFactory.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialogFactory.java 2008-07-08 21:39:52 UTC (rev 4260) @@ -0,0 +1,15 @@ +package net.sf.gridarta.gui.gameobjectattributesdialog; + +import java.util.HashMap; +import java.util.Map; +import javax.swing.JDialog; +import net.sf.gridarta.gameobject.GameObject; + +public class AbstractGameObjectAttributesDialogFactory { + + /** + * The gameObject objects that already are shown, to avoid opening a dialog + * twice. + */ + protected static final Map<GameObject<?, ?, ?>, JDialog> dialogs = new HashMap<GameObject<?, ?, ?>, JDialog>(); +} Property changes on: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialogFactory.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-08 21:43:06
|
Revision: 4261 http://gridarta.svn.sourceforge.net/gridarta/?rev=4261&view=rev Author: akirschbaum Date: 2008-07-08 14:42:58 -0700 (Tue, 08 Jul 2008) Log Message: ----------- Unify package names between common code base and non-merged code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java Added Paths: ----------- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/ trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/ trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java Removed Paths: ------------- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialogFactory.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialogFactory.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-08 21:39:52 UTC (rev 4260) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-08 21:42:58 UTC (rev 4261) @@ -27,9 +27,9 @@ import cfeditor.gameobject.anim.AnimationObject; import cfeditor.gameobject.face.FaceObjects; import cfeditor.gameobject.scripts.ScriptArchUtils; -import cfeditor.gui.GameObjectAttributesDialogFactory; import cfeditor.gui.GameObjectAttributesPanel; import cfeditor.gui.ObjectChooser; +import cfeditor.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; import cfeditor.gui.map.CMapViewBasic; import cfeditor.gui.prefs.GUIPrefs; import cfeditor.gui.prefs.ResPrefs; Deleted: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2008-07-08 21:39:52 UTC (rev 4260) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2008-07-08 21:42:58 UTC (rev 4261) @@ -1,509 +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.util.List; -import java.util.Vector; -import javax.swing.JCheckBox; -import javax.swing.JComboBox; -import javax.swing.JFormattedTextField; -import javax.swing.JTextField; -import javax.swing.text.JTextComponent; -import net.sf.gridarta.CFArchAttrib; -import net.sf.gridarta.CFArchType; -import net.sf.gridarta.CFArchTypeList; -import net.sf.gridarta.MainControl; -import net.sf.gridarta.MapManager; -import net.sf.gridarta.gameobject.ArchAttribType; -import net.sf.gridarta.gameobject.anim.AnimationObjects; -import net.sf.gridarta.gameobject.face.FaceObjects; -import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialog; -import net.sf.gridarta.gui.gameobjectattributesdialog.BitmaskAttrib; -import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttrib; -import net.sf.gridarta.gui.gameobjectattributesdialog.StringKeyManager; -import net.sf.gridarta.gui.map.TilePanel; -import net.sf.gridarta.spells.GameObjectSpell; -import net.sf.gridarta.spells.NumberSpell; -import net.sf.gridarta.spells.Spell; -import net.sf.gridarta.spells.Spells; -import net.sf.gridarta.textedit.textarea.JEditTextArea; -import net.sf.gridarta.treasurelist.CFTreasureListTree; -import org.jetbrains.annotations.NotNull; - -/** - * GameObjectAttributesDialog poses the GUI for Crossfire object attributes. - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @fixme I suck - */ -public final class GameObjectAttributesDialog extends AbstractGameObjectAttributesDialog<GameObject, MapArchObject, Archetype> { - - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - - /** The map manager. */ - private final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager; - - /** - * Constructor, creates the GUI layout. - * @param archTypeList the list of CF type-data - * @param gameObject the GameObject to be displayed by this dialog - * @param mainControl main control - * @param animationObjects the animation objects instance to use - * @param mapManager the map manager - * @param treasureListTree the treasure list tree - * @param faceObjects the FaceObjects instance to use - */ - public GameObjectAttributesDialog(final CFArchTypeList archTypeList, @NotNull final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final AnimationObjects<?> animationObjects, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects) { - super(archTypeList, gameObject, mainControl, animationObjects, treasureListTree, faceObjects); - this.mapManager = mapManager; - } - - /** {@inheritDoc} */ - @Override - protected JComboBox buildSpellBox(final CFArchAttrib attr) { - // first parse the spell-number value from gameObject - int spnum = gameObject.getAttributeInt(attr.getNameOld()); // spell number - - if (spnum < 0 || spnum >= mainControl.getNumberSpells().size()) { - spnum = 0; // undefined spellnumbers be 0 - } - - // do we have "none" spell? - final int selectedIndex; - if (spnum == 0 && attr.getDataType() == ArchAttribType.ZSPELL) { - selectedIndex = 0; - } else { - // now look up the spell-number in the array of spells - selectedIndex = 1 + findSpellIndex(spnum); - } - - final Vector<String> content = new Vector<String>(); - content.add("<none>"); - for (final Spell spell : mainControl.getNumberSpells()) { - content.add(spell.getName()); - } - final JComboBox comboBox = new JComboBox(content); - comboBox.setSelectedIndex(selectedIndex); - comboBox.setMaximumRowCount(10); - comboBox.setKeySelectionManager(new StringKeyManager(comboBox)); - comboBox.setName(attr.getNameNew()); - return comboBox; - } - - /** - * Return the spell index for a spell number. - * @param number The spell number. - * @return The spell object. - */ - private int findSpellIndex(final int number) { - final Spells<NumberSpell> spells = mainControl.getNumberSpells(); - for (int i = 0; i < spells.size(); i++) { - if (spells.getSpell(i).getNumber() == number) { - return i; - } - } - return -1; - } - - /** - * This method is called when the "apply"-button has been pressed. All the - * settings from the dialog get written into the GameObject. - * @return true if the settings were applied, false if error occurred - */ - @Override - protected boolean applySettings2() { - final CFArchType typeStruct = archTypeList.getTypeOfArch(gameObject); // the type structure for this gameObject - - final StringBuilder newArchText = new StringBuilder(); - String newName = null; - String newFace = null; - String newMsg = null; - for (final DialogAttrib<?> attr : dialogAttribs) { - final ArchAttribType dType = attr.ref.getDataType(); - - switch (dType) { - case BOOL: { - // a boolean attribute (flag) - if (((DialogAttrib<JCheckBox>) attr).getInput().isSelected() != (archetype.getAttributeInt(attr.ref.getNameOld()) == 1)) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(((DialogAttrib<JCheckBox>) attr).getInput().isSelected() ? 1 : 0).append("\n"); - } - } - break; - case BOOL_SPEC: { - // a boolean attribute with customized true/false values - final String valString; // value-string to apply - if (((DialogAttrib<JCheckBox>) attr).getInput().isSelected()) { - valString = attr.ref.getMisc()[0]; // true string - } else { - valString = attr.ref.getMisc()[1]; // false string - } - // now see if we need to write it into the archtext or not - if ((valString.equals("0") && !(archetype.getAttributeString(attr.ref.getNameOld()).length() == 0)) || (!valString.equals("0") && !archetype.getAttributeString(attr.ref.getNameOld()).equals(valString))) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(valString).append("\n"); - } - } - break; - case INT: - case LONG: - case FLOAT: { - // an int attribute - if (dType == ArchAttribType.INT && ((DialogAttrib<JFormattedTextField>) attr).getInput().getText().trim().length() == 0) { - if (archetype.getAttributeInt(attr.ref.getNameOld()) != 0) { - newArchText.append(attr.ref.getNameOld()).append(" 0\n"); - } - } else - if (dType == ArchAttribType.LONG && ((DialogAttrib<JFormattedTextField>) attr).getInput().getText().trim().length() == 0) { - if (archetype.getAttributeLong(attr.ref.getNameOld()) != 0) { - newArchText.append(attr.ref.getNameOld()).append(" 0\n"); - } - } else - if (dType == ArchAttribType.FLOAT && ((DialogAttrib<JFormattedTextField>) attr).getInput().getText().trim().length() == 0) { - if (archetype.getAttributeString(attr.ref.getNameOld()).length() > 0) { - newArchText.append(attr.ref.getNameOld()).append(" 0.0\n"); - } - } else { - try { - switch (dType) { - case INT: { - final int value = ((Number) ((DialogAttrib<JFormattedTextField>) attr).getInput().getValue()).intValue(); - if (archetype.getAttributeInt(attr.ref.getNameOld()) != value) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(value).append("\n"); - } - } - break; - case LONG: { - final long value = ((Number) ((DialogAttrib<JFormattedTextField>) attr).getInput().getValue()).longValue(); - if (archetype.getAttributeLong(attr.ref.getNameOld()) != value) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(value).append("\n"); - } - } - break; - case FLOAT: { - final double value = ((Number) ((DialogAttrib<JFormattedTextField>) attr).getInput().getValue()).doubleValue(); - // The following floating point equality comparison is okay and known not to cause problems. - //noinspection FloatingPointEquality - if (archetype.getAttributeDouble(attr.ref.getNameOld()) != value) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(value).append("\n"); - } - } - break; - default: - assert false; - break; - } - } catch (final NumberFormatException e) { - // parsing failed: wrong entry!! - showMessageDialog(this, "Attribute '" + attr.ref.getNameNew() + "' must be a number!", "Input Error", ERROR_MESSAGE); - return false; - } - } - } - break; - case STRING: - case FACENAME: - case ANIMNAME: { - // a String attribute - final String inline = ((DialogAttrib<JTextField>) attr).getInput().getText().trim(); - - if (inline != null) { - if (attr.ref.getNameOld().equalsIgnoreCase("name")) { - // special case #1: "name"-textfield - if (typeStruct.getTypeNr() == Archetype.TYPE_EVENT_CONNECTOR) { - // events are special: they do not inherit the - // archetype name for empty names - newName = inline; - } else - if (archetype.getObjName() != null && archetype.getObjName().length() > 0) { - if (!inline.equals(archetype.getObjName())) { - newName = inline; - } else { - newName = ""; - } - } else - if (!inline.equals(archetype.getArchetypeName())) { - newName = inline; - } else { - newName = ""; - } - } else - if (attr.ref.getNameOld().equalsIgnoreCase("animation")) { - if (inline.length() > 0 && !inline.equals(archetype.getAttributeString(attr.ref.getNameOld()))) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(inline).append("\n"); - gameObject.setAnimName(inline); - } else { - gameObject.setAnimName(archetype.getAnimName()); - } - } else if (attr.ref.getNameOld().equalsIgnoreCase("face")) { - // special case #2: "face"-textfield - final String archFaceName = archetype.getFaceName(); - if (archFaceName == null || archFaceName.length() == 0 || !inline.equals(archFaceName)) { - newFace = inline; - } else { - newFace = ""; - } - } else { - if (!inline.equals(archetype.getAttributeString(attr.ref.getNameOld()))) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(inline).append("\n"); - } - } - } - } - break; - case MAP_PATH: - case SCRIPT_FILE: { - final String newString = ((DialogAttrib<TilePanel>) attr).getInput().getText().trim(); - if (!archetype.getAttributeString(attr.ref.getNameOld()).equals(newString)) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(newString).append("\n"); - } - } - break; - case TEXT: { - // a String attribute - if (attr.ref.getNameOld().equalsIgnoreCase("msg") && ((DialogAttrib<JEditTextArea>) attr).getInput().getText().trim().length() > 0) { - newMsg = ((DialogAttrib<JEditTextArea>) attr).getInput().getText().trim(); - } - } - break; - case SPELL: - case ZSPELL: - case LIST: { - // get attribute value that should go into the gameObject - final int attrVal; // attribute value - switch (dType) { - case SPELL: - case ZSPELL: - final int index = ((DialogAttrib<JComboBox>) attr).getInput().getSelectedIndex(); - attrVal = index == 0 ? 0 : mainControl.getNumberSpells().getSpell(index - 1).getNumber(); - break; - case LIST: - // get selected index of ComboBox - final int attrValTmp = ((JComboBox) attr.getInput()).getSelectedIndex(); - // fetch value according to this list entry: - attrVal = ((List<Integer>) archTypeList.getListTable().get(attr.ref.getMisc()[0])).get(2 * attrValTmp); - break; - default: - assert false; - attrVal = 0; - break; - } - - if (archetype.getAttributeInt(attr.ref.getNameOld()) != attrVal) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(attrVal).append("\n"); - } - } - break; - case INV_SPELL: - case INV_SPELL_OPTIONAL: { - final JComboBox comboBox = ((DialogAttrib<JComboBox>) attr).getInput(); - final int index = comboBox.getSelectedIndex(); - final boolean isOptionalSpell = dType == ArchAttribType.INV_SPELL_OPTIONAL; - if (index < mainControl.getGameObjectSpells().size() + (isOptionalSpell ? 1 : 0)) { - final boolean isModified; - switch (gameObject.countInvObjects()) { - case 0: - // game object has no inventory ==> isModified if - // anything other than <none> is selected - isModified = index != mainControl.getGameObjectSpells().size(); - break; - - default: - // game object has multiple inventories ==> always isModified - isModified = true; - break; - - case 1: - if (index >= mainControl.getGameObjectSpells().size()) { - // game object has one inventory, <none> is - // selected ==> isModified - isModified = true; - } else { - // game object has one inventory, a spell is - // selected ==> isModified if a different spell is - // selected - final GameObject invObject = gameObject.iterator().next(); - if (!invObject.isDefaultGameObject()) { - isModified = true; - } else { - final String invObjectArchetypeName = invObject.getArchetype().getArchetypeName(); - final GameObjectSpell<GameObject, MapArchObject, Archetype> spellObject = mainControl.getGameObjectSpells().getSpell(index); - isModified = !invObjectArchetypeName.equals(spellObject.getArchetypeName()); - } - } - break; - } - if (isModified) { - gameObject.removeAll(); - if (index < mainControl.getGameObjectSpells().size()) { - final GameObject spellObject = mainControl.getGameObjectSpells().getSpell(index).createGameObject(); - spellObject.postParseGameObject(0); - gameObject.addLast(spellObject); - } - - // remove the entry for a customized spell - final int modelSize = comboBox.getModel().getSize(); - if (modelSize > mainControl.getGameObjectSpells().size() + (isOptionalSpell ? 1 : 0)) { - comboBox.removeItemAt(modelSize - 1); - } - } - } - } - break; - case DBLLIST: { - final int val1 = ((List<Integer>) archTypeList.getListTable().get(attr.ref.getMisc()[0])).get(2 * ((JComboBox[]) attr.getInput())[0].getSelectedIndex()); - final int val2 = ((List<Integer>) archTypeList.getListTable().get(attr.ref.getMisc()[1])).get(2 * ((JComboBox[]) attr.getInput())[1].getSelectedIndex()); - final int combinedVal = val1 + val2; - - if (archetype.getAttributeInt(attr.ref.getNameOld()) != combinedVal) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(combinedVal).append("\n"); - } - } - break; - case BITMASK: { - // a bitmask attribute (similar to integer, but easier because no parsing needed) - final String value = ((BitmaskAttrib) attr).getEncodedValue(); // get bitmask value - String oldValue = archetype.getAttributeString(attr.ref.getNameOld()); - if (oldValue.length() == 0) { - oldValue = "0"; - } - - if (!oldValue.equals(value)) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(value).append("\n"); - } - } - break; - case TREASURE: { - // a treasurelist attribute - final String inline = ((JTextComponent) attr.getInput()).getText().trim(); // input string - - if (inline != null) { - final boolean isNone = inline.equals(CFTreasureListTree.NONE_SYM) || inline.length() == 0; - - if (!isNone && !CFTreasureListTree.containsTreasureList(inline) && !inline.equalsIgnoreCase(archetype.getAttributeString(attr.ref.getNameOld()))) { - // The user has specified a WRONG treasurelist name, and it does not come - // from the default gameObject. -> Error and out. - showMessageDialog(this, "In attribute '" + attr.ref.getNameNew() + "':\n" + "'" + inline + "' is not a known treasurelist name!", "Input Error", ERROR_MESSAGE); - return false; - } - - if (!inline.equalsIgnoreCase(archetype.getAttributeString(attr.ref.getNameOld())) && !(isNone && archetype.getAttributeString(attr.ref.getNameOld()).length() == 0)) { - if (isNone) { - newArchText.append(attr.ref.getNameOld()).append(" none\n"); - } else { - newArchText.append(attr.ref.getNameOld()).append(" ").append(inline).append("\n"); - } - } - } - } - break; - } - } - - // Also write all the 'fixed' attributes into the archtext - for (int i = 0; type.getAttr().length > i; i++) { - // ### TODO: for changed types, copy fixed attributes over default arches ### - if (type.getAttr()[i].getDataType() == ArchAttribType.FIXED) { - final String defaultValue = archetype.getAttributeString(type.getAttr()[i].getNameOld()); - if (defaultValue.length() == 0 || (gameObject.getArchTypNr() != archetype.getArchTypNr() && !defaultValue.equalsIgnoreCase(type.getAttr()[i].getNameNew()))) { - // usually, fixed attributes are only applied when *not* defined in the archetype. - // the reason behind this is: if the default gameObject violates our fixed attribute, - // we assume the default gameObject is "right" and we are "wrong". The typedefs aren't that trustworthy. - // BUT - if the gameObject has a changed type, the archetype has lost it's credibility. - // So, in this special case, the fixed attribute applies always. - newArchText.append(type.getAttr()[i].getNameOld()).append(" ").append(type.getAttr()[i].getNameNew()).append("\n"); - } - } - } - - /* we have excluded direction hard coded from the attribut panel - * because we have a better interface in the gameObject panel. - * But we need to add when needed the gameObject text - we do it here. - */ - if (gameObject.getDirection() != archetype.getDirection()) { - newArchText.append("direction ").append(gameObject.getDirection()).append("\n"); - } - // before we modify the archtext, we look for errors and save them. - // later the user must confirm whether to keep or dump those errors - final String errors = gameObject.getSyntaxErrors(typeStruct); - - // --- parsing succeeded, now we write it into the gameObject/map --- - gameObject.setObjectText(newArchText.toString()); - //gameObject.setArchTypNr(); - if (newName != null) { - if (newName.length() == 0) { - gameObject.setObjName(null); - } else { - gameObject.setObjName(newName); - } - } - - if (newFace != null) { - gameObject.setFaceName(newFace.length() == 0 ? null : newFace); - } - - // now lets assign the visible face - perhaps we have still a anim - gameObject.setObjectFace(); - imagePanel.setIcon(mainControl.getArchetypeSet().getFace(gameObject)); - - if (newMsg != null) { - // set new msg text only when it is not equal to Archetype - if (!newMsg.trim().equals(archetype.getMsgText() == null ? "" : archetype.getMsgText().trim())) { - gameObject.deleteMsgText(); - gameObject.addMsgText(newMsg); - } else { - gameObject.deleteMsgText(); - } - } else - if (archetype.getMsgText() != null && archetype.getMsgText().trim().length() > 0) { - // we must override archetype msg by an empty msg - gameObject.deleteMsgText(); - gameObject.addMsgText(""); - } else { - gameObject.deleteMsgText(); // all empty - } - - // deal with syntax errors now - if (errors != null) { - if (typeStruct == archTypeList.getArchType(1)) { - // for generic (misc) type, all errors are automatically kept. - // "misc" is no real type - it is more a default mask for unknown types - gameObject.addObjectText(errors.trim()); - } else { - // open a popup dialog and ask user to decide what to do with his errors - askConfirmErrors(errors); - } - } - - gameObject.updateEditType(mapManager.getCurrentMap().getActiveEditType()); - - return true; // apply succeeded - } - - /** {@inheritDoc} */ - @Override - protected boolean isSpecialNameHandling() { - return type.getTypeNr() != Archetype.TYPE_EVENT_CONNECTOR; - } - -} // class GameObjectAttributesDialog Deleted: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialogFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialogFactory.java 2008-07-08 21:39:52 UTC (rev 4260) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialogFactory.java 2008-07-08 21:42:58 UTC (rev 4261) @@ -1,50 +0,0 @@ -package cfeditor.gui; - -import cfeditor.gameobject.Archetype; -import cfeditor.gameobject.GameObject; -import cfeditor.gui.map.CMapViewBasic; -import cfeditor.map.MapArchObject; -import javax.swing.JDialog; -import net.sf.gridarta.CFArchTypeList; -import net.sf.gridarta.MainControl; -import net.sf.gridarta.MapManager; -import net.sf.gridarta.gameobject.anim.AnimationObjects; -import net.sf.gridarta.gameobject.face.FaceObjects; -import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialogFactory; -import net.sf.gridarta.treasurelist.CFTreasureListTree; -import net.sf.japi.swing.ActionFactory; -import org.jetbrains.annotations.NotNull; - -public class GameObjectAttributesDialogFactory extends AbstractGameObjectAttributesDialogFactory { - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); - - /** - * Wrapper method for the constructor. This method only creates a - * GameObjectAttributesDialog if there's no dialog for the same gameObject - * already. - * @param archTypeList the list of CF type-data - * @param gameObject the GameObject to be displayed by this dialog - * @param mainControl main control - * @param animationObjects the animation objects instance to use - * @param mapManager the map manager - * @param treasureListTree the treasure list tree instance to use - * @param faceObjects the FaceObjects instance to use - */ - public static void showAttribDialog(final CFArchTypeList archTypeList, final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final AnimationObjects<?> animationObjects, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects) { - synchronized (dialogs) { - if (AbstractGameObjectAttributesDialogFactory.dialogs.containsKey(gameObject)) { - AbstractGameObjectAttributesDialogFactory.dialogs.get(gameObject).toFront(); - } else { - final GameObjectAttributesDialog pane = new GameObjectAttributesDialog(archTypeList, gameObject, mainControl, animationObjects, mapManager, treasureListTree, faceObjects); - final JDialog dialog = pane.createDialog(mainControl.getMainView(), ACTION_FACTORY.getString("attribTitle")); - dialog.getRootPane().setDefaultButton(pane.okButton); - dialog.setResizable(true); - dialog.setModal(false); - dialog.setVisible(true); - dialogs.put(pane.gameObject, dialog); - } - } - } -} Copied: trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java (from rev 4260, trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java) =================================================================== --- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java (rev 0) +++ trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-08 21:42:58 UTC (rev 4261) @@ -0,0 +1,509 @@ +/* + * 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.gameobjectattributesdialog; + +import cfeditor.gameobject.Archetype; +import cfeditor.gameobject.GameObject; +import cfeditor.gui.map.CMapViewBasic; +import cfeditor.map.MapArchObject; +import java.util.List; +import java.util.Vector; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JFormattedTextField; +import javax.swing.JTextField; +import javax.swing.text.JTextComponent; +import net.sf.gridarta.CFArchAttrib; +import net.sf.gridarta.CFArchType; +import net.sf.gridarta.CFArchTypeList; +import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; +import net.sf.gridarta.gameobject.ArchAttribType; +import net.sf.gridarta.gameobject.anim.AnimationObjects; +import net.sf.gridarta.gameobject.face.FaceObjects; +import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialog; +import net.sf.gridarta.gui.gameobjectattributesdialog.BitmaskAttrib; +import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttrib; +import net.sf.gridarta.gui.gameobjectattributesdialog.StringKeyManager; +import net.sf.gridarta.gui.map.TilePanel; +import net.sf.gridarta.spells.GameObjectSpell; +import net.sf.gridarta.spells.NumberSpell; +import net.sf.gridarta.spells.Spell; +import net.sf.gridarta.spells.Spells; +import net.sf.gridarta.textedit.textarea.JEditTextArea; +import net.sf.gridarta.treasurelist.CFTreasureListTree; +import org.jetbrains.annotations.NotNull; + +/** + * GameObjectAttributesDialog poses the GUI for Crossfire object attributes. + * @author <a href="mailto:and...@gm...">Andreas Vogl</a> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @fixme I suck + */ +public final class GameObjectAttributesDialog extends AbstractGameObjectAttributesDialog<GameObject, MapArchObject, Archetype> { + + /** Serial Version UID. */ + private static final long serialVersionUID = 1L; + + /** The map manager. */ + private final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager; + + /** + * Constructor, creates the GUI layout. + * @param archTypeList the list of CF type-data + * @param gameObject the GameObject to be displayed by this dialog + * @param mainControl main control + * @param animationObjects the animation objects instance to use + * @param mapManager the map manager + * @param treasureListTree the treasure list tree + * @param faceObjects the FaceObjects instance to use + */ + public GameObjectAttributesDialog(final CFArchTypeList archTypeList, @NotNull final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final AnimationObjects<?> animationObjects, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects) { + super(archTypeList, gameObject, mainControl, animationObjects, treasureListTree, faceObjects); + this.mapManager = mapManager; + } + + /** {@inheritDoc} */ + @Override + protected JComboBox buildSpellBox(final CFArchAttrib attr) { + // first parse the spell-number value from gameObject + int spnum = gameObject.getAttributeInt(attr.getNameOld()); // spell number + + if (spnum < 0 || spnum >= mainControl.getNumberSpells().size()) { + spnum = 0; // undefined spellnumbers be 0 + } + + // do we have "none" spell? + final int selectedIndex; + if (spnum == 0 && attr.getDataType() == ArchAttribType.ZSPELL) { + selectedIndex = 0; + } else { + // now look up the spell-number in the array of spells + selectedIndex = 1 + findSpellIndex(spnum); + } + + final Vector<String> content = new Vector<String>(); + content.add("<none>"); + for (final Spell spell : mainControl.getNumberSpells()) { + content.add(spell.getName()); + } + final JComboBox comboBox = new JComboBox(content); + comboBox.setSelectedIndex(selectedIndex); + comboBox.setMaximumRowCount(10); + comboBox.setKeySelectionManager(new StringKeyManager(comboBox)); + comboBox.setName(attr.getNameNew()); + return comboBox; + } + + /** + * Return the spell index for a spell number. + * @param number The spell number. + * @return The spell object. + */ + private int findSpellIndex(final int number) { + final Spells<NumberSpell> spells = mainControl.getNumberSpells(); + for (int i = 0; i < spells.size(); i++) { + if (spells.getSpell(i).getNumber() == number) { + return i; + } + } + return -1; + } + + /** + * This method is called when the "apply"-button has been pressed. All the + * settings from the dialog get written into the GameObject. + * @return true if the settings were applied, false if error occurred + */ + @Override + protected boolean applySettings2() { + final CFArchType typeStruct = archTypeList.getTypeOfArch(gameObject); // the type structure for this gameObject + + final StringBuilder newArchText = new StringBuilder(); + String newName = null; + String newFace = null; + String newMsg = null; + for (final DialogAttrib<?> attr : dialogAttribs) { + final ArchAttribType dType = attr.ref.getDataType(); + + switch (dType) { + case BOOL: { + // a boolean attribute (flag) + if (((DialogAttrib<JCheckBox>) attr).getInput().isSelected() != (archetype.getAttributeInt(attr.ref.getNameOld()) == 1)) { + newArchText.append(attr.ref.getNameOld()).append(" ").append(((DialogAttrib<JCheckBox>) attr).getInput().isSelected() ? 1 : 0).append("\n"); + } + } + break; + case BOOL_SPEC: { + // a boolean attribute with customized true/false values + final String valString; // value-string to apply + if (((DialogAttrib<JCheckBox>) attr).getInput().isSelected()) { + valString = attr.ref.getMisc()[0]; // true string + } else { + valString = attr.ref.getMisc()[1]; // false string + } + // now see if we need to write it into the archtext or not + if ((valString.equals("0") && !(archetype.getAttributeString(attr.ref.getNameOld()).length() == 0)) || (!valString.equals("0") && !archetype.getAttributeString(attr.ref.getNameOld()).equals(valString))) { + newArchText.append(attr.ref.getNameOld()).append(" ").append(valString).append("\n"); + } + } + break; + case INT: + case LONG: + case FLOAT: { + // an int attribute + if (dType == ArchAttribType.INT && ((DialogAttrib<JFormattedTextField>) attr).getInput().getText().trim().length() == 0) { + if (archetype.getAttributeInt(attr.ref.getNameOld()) != 0) { + newArchText.append(attr.ref.getNameOld()).append(" 0\n"); + } + } else + if (dType == ArchAttribType.LONG && ((DialogAttrib<JFormattedTextField>) attr).getInput().getText().trim().length() == 0) { + if (archetype.getAttributeLong(attr.ref.getNameOld()) != 0) { + newArchText.append(attr.ref.getNameOld()).append(" 0\n"); + } + } else + if (dType == ArchAttribType.FLOAT && ((DialogAttrib<JFormattedTextField>) attr).getInput().getText().trim().length() == 0) { + if (archetype.getAttributeString(attr.ref.getNameOld()).length() > 0) { + newArchText.append(attr.ref.getNameOld()).append(" 0.0\n"); + } + } else { + try { + switch (dType) { + case INT: { + final int value = ((Number) ((DialogAttrib<JFormattedTextField>) attr).getInput().getValue()).intValue(); + if (archetype.getAttributeInt(attr.ref.getNameOld()) != value) { + newArchText.append(attr.ref.getNameOld()).append(" ").append(value).append("\n"); + } + } + break; + case LONG: { + final long value = ((Number) ((DialogAttrib<JFormattedTextField>) attr).getInput().getValue()).longValue(); + if (archetype.getAttributeLong(attr.ref.getNameOld()) != value) { + newArchText.append(attr.ref.getNameOld()).append(" ").append(value).append("\n"); + } + } + break; + case FLOAT: { + final double value = ((Number) ((DialogAttrib<JFormattedTextField>) attr).getInput().getValue()).doubleValue(); + // The following floating point equality comparison is okay and known not to cause problems. + //noinspection FloatingPointEquality + if (archetype.getAttributeDouble(attr.ref.getNameOld()) != value) { + newArchText.append(attr.ref.getNameOld()).append(" ").append(value).append("\n"); + } + } + break; + default: + assert false; + break; + } + } catch (final NumberFormatException e) { + // parsing failed: wrong entry!! + showMessageDialog(this, "Attribute '" + attr.ref.getNameNew() + "' must be a number!", "Input Error", ERROR_MESSAGE); + return false; + } + } + } + break; + case STRING: + case FACENAME: + case ANIMNAME: { + // a String attribute + final String inline = ((DialogAttrib<JTextField>) attr).getInput().getText().trim(); + + if (inline != null) { + if (attr.ref.getNameOld().equalsIgnoreCase("name")) { + // special case #1: "name"-textfield + if (typeStruct.getTypeNr() == Archetype.TYPE_EVENT_CONNECTOR) { + // events are special: they do not inherit the + // archetype name for empty names + newName = inline; + } else + if (archetype.getObjName() != null && archetype.getObjName().length() > 0) { + if (!inline.equals(archetype.getObjName())) { + newName = inline; + } else { + newName = ""; + } + } else + if (!inline.equals(archetype.getArchetypeName())) { + newName = inline; + } else { + newName = ""; + } + } else + if (attr.ref.getNameOld().equalsIgnoreCase("animation")) { + if (inline.length() > 0 && !inline.equals(archetype.getAttributeString(attr.ref.getNameOld()))) { + newArchText.append(attr.ref.getNameOld()).append(" ").append(inline).append("\n"); + gameObject.setAnimName(inline); + } else { + gameObject.setAnimName(archetype.getAnimName()); + } + } else if (attr.ref.getNameOld().equalsIgnoreCase("face")) { + // special case #2: "face"-textfield + final String archFaceName = archetype.getFaceName(); + if (archFaceName == null || archFaceName.length() == 0 || !inline.equals(archFaceName)) { + newFace = inline; + } else { + newFace = ""; + } + } else { + if (!inline.equals(archetype.getAttributeString(attr.ref.getNameOld()))) { + newArchText.append(attr.ref.getNameOld()).append(" ").append(inline).append("\n"); + } + } + } + } + break; + case MAP_PATH: + case SCRIPT_FILE: { + final String newString = ((DialogAttrib<TilePanel>) attr).getInput().getText().trim(); + if (!archetype.getAttributeString(attr.ref.getNameOld()).equals(newString)) { + newArchText.append(attr.ref.getNameOld()).append(" ").append(newString).append("\n"); + } + } + break; + case TEXT: { + // a String attribute + if (attr.ref.getNameOld().equalsIgnoreCase("msg") && ((DialogAttrib<JEditTextArea>) attr).getInput().getText().trim().length() > 0) { + newMsg = ((DialogAttrib<JEditTextArea>) attr).getInput().getText().trim(); + } + } + break; + case SPELL: + case ZSPELL: + case LIST: { + // get attribute value that should go into the gameObject + final int attrVal; // attribute value + switch (dType) { + case SPELL: + case ZSPELL: + final int index = ((DialogAttrib<JComboBox>) attr).getInput().getSelectedIndex(); + attrVal = index == 0 ? 0 : mainControl.getNumberSpells().getSpell(index - 1).getNumber(); + break; + case LIST: + // get selected index of ComboBox + final int attrValTmp = ((JComboBox) attr.getInput()).getSelectedIndex(); + // fetch value according to this list entry: + attrVal = ((List<Integer>) archTypeList.getListTable().get(attr.ref.getMisc()[0])).get(2 * attrValTmp); + break; + default: + assert false; + attrVal = 0; + break; + } + + if (archetype.getAttributeInt(attr.ref.getNameOld()) != attrVal) { + newArchText.append(attr.ref.getNameOld()).append(" ").append(attrVal).append("\n"); + } + } + break; + case INV_SPELL: + case INV_SPELL_OPTIONAL: { + final JComboBox comboBox = ((DialogAttrib<JComboBox>) attr).getInput(); + final int index = comboBox.getSelectedIndex(); + final boolean isOptionalSpell = dType == ArchAttribType.INV_SPELL_OPTIONAL; + if (index < mainControl.getGameObjectSpells().size() + (isOptionalSpell ? 1 : 0)) { + final boolean isModified; + switch (gameObject.countInvObjects()) { + case 0: + // game object has no inventory ==> isModified if + // anything other than <none> is selected + isModified = index != mainControl.getGameObjectSpells().size(); + break; + + default: + // game object has multiple inventories ==> always isModified + isModified = true; + break; + + case 1: + if (index >= mainControl.getGameObjectSpells().size()) { + // game object has one inventory, <none> is + // selected ==> isModified + isModified = true; + } else { + // game object has one inventory, a spell is + // selected ==> isModified if a different spell is + // selected + final GameObject invObject = gameObject.iterator().next(); + if (!invObject.isDefaultGameObject()) { + isModified = true; + } else { + final String invObjectArchetypeName = invObject.getArchetype().getArchetypeName(); + final GameObjectSpell<GameObject, MapArchObject, Archetype> spellObject = mainControl.getGameObjectSpells().getSpell(index); + isModified = !invObjectArchetypeName.equals(spellObject.getArchetypeName()); + } + } + break; + } + if (isModified) { + gameObject.removeAll(); + if (index < mainControl.getGameObjectSpells().size()) { + final GameObject spellObject = mainControl.getGameObjectSpells().getSpell(index).createGameObject(); + spellObject.postParseGameObject(0); + gameObject.addLast(spellObject); + } + + // remove the entry for a customized spell + final int modelSize = comboBox.getModel().getSize(); + if (modelSize > mainControl.getGameObjectSpells().size() + (isOptionalSpell ? 1 : 0)) { + comboBox.removeItemAt(modelSize - 1); + } + } + } + } + break; + case DBLLIST: { + final int val1 = ((List<Integer>) archTypeList.getListTable().get(attr.ref.getMisc()[0])).get(2 * ((JComboBox[]) attr.getInput())[0].getSelectedIndex()); + final int val2 = ((List<Integer>) archTypeList.getListTable().get(attr.ref.getMisc()[1])).get(2 * ((JComboBox[]) attr.getInput())[1].getSelectedIndex()); + final int combinedVal = val1 + val2; + + if (archetype.getAttributeInt(attr.ref.getNameOld()) != combinedVal) { + newArchText.append(attr.ref.getNameOld()).append(" ").append(combinedVal).append("\n"); + } + } + break; + case BITMASK: { + // a bitmask attribute (similar to integer, but easier because no parsing needed) + final String value = ((BitmaskAttrib) attr).getEncodedValue(); // get bitmask value + String oldValue = archetype.getAttributeString(attr.ref.getNameOld()); + if (oldValue.length() == 0) { + oldValue = "0"; + } + + if (!oldValue.equals(value)) { + newArchText.append(attr.ref.getNameOld()).append(" ").append(value).append("\n"); + } + } + break; + case TREASURE: { + // a treasurelist attribute + final String inline = ((JTextComponent) attr.getInput()).getText().trim(); // input string + + if (inline != null) { + final boolean isNone = inline.equals(CFTreasureListTree.NONE_SYM) || inline.length() == 0; + + if (!isNone && !CFTreasureListTree.containsTreasureList(inline) && !inline.equalsIgnoreCase(archetype.getAttributeString(attr.ref.getNameOld()))) { + // The user has specified a WRONG treasurelist name, and it does not come + // from the default gameObject. -> Error and out. + showMessageDialog(this, "In attribute '" + attr.ref.getNameNew() + "':\n" + "'" + inline + "' is not a known treasurelist name!", "Input Error", ERROR_MESSAGE); + return false; + } + + if (!inline.equalsIgnoreCase(archetype.getAttributeString(attr.ref.getNameOld())) && !(isNone && archetype.getAttributeString(attr.ref.getNameOld()).length() == 0)) { + if (isNone) { + newArchText.append(attr.ref.getNameOld()).append(" none\n"); + } else { + newArchText.append(attr.ref.getNameOld()).append(" ").append(inline).append("\n"); + } + } + } + } + break; + } + } + + // Also write all the 'fixed' attributes into the archtext + for (int i = 0; type.getAttr().length > i; i++) { + // ### TODO: for changed types, copy fixed attributes over default arches ### + if (type.getAttr()[i].getDataType() == ArchAttribType.FIXED) { + final String defaultValue = archetype.getAttributeString(type.getAttr()[i].getNameOld()); + if (defaultValue.length() == 0 || (gameObject.getArchTypNr() != archetype.getArchTypNr() && !defaultValue.equalsIgnoreCase(type.getAttr()[i].getNameNew()))) { + // usually, fixed attributes are only applied when *not* defined in the archetype. + // the reason behind this is: if the default gameObject violates our fixed attribute, + // we assume the default gameObject is "right" and we are "wrong". The typedefs aren't that trustworthy. + // BUT - if the gameObject has a changed type, the archetype has lost it's credibility. + // So, in this special case, the fixed attribute applies always. + newArchText.append(type.getAttr()[i].getNameOld()).append(" ").append(type.getAttr()[i].getNameNew()).append("\n"); + } + } + } + + /* we have excluded direction hard coded from the attribut panel + * because we have a better interface in the gameObject panel. + * But we need to add when needed the gameObject text - we do it here. + */ + if (gameObject.getDirection() != archetype.getDirection()) { + newArchText.append("direction ").append(gameObject.getDirection()).append("\n"); + } + // before we modify the archtext, we look for errors and save them. + // later the user must confirm whether to keep or dump those errors + final String errors = gameObject.getSyntaxErrors(typeStruct); + + // --- parsing succeeded, now we write it into the gameObject/map --- + gameObject.setObjectText(newArchText.toString()); + //gameObject.setArchTypNr(); + if (newName != null) { + if (newName.length() == 0) { + gameObject.setObjName(null); + } else { + gameObject.setObjName(newName); + } + } + + if (newFace != null) { + gameObject.setFaceName(newFace.length() == 0 ? null : newFace); + } + + // now lets assign the visible face - perhaps we have still a anim + gameObject.setObjectFace(); + imagePanel.setIcon(mainControl.getArchetypeSet().getFace(gameObject)); + + if (newMsg != null) { + // set new msg text only when it is not equal to Archetype + if (!newMsg.trim().equals(archetype.getMsgText() == null ? "" : archetype.getMsgText().trim())) { + gameObject.deleteMsgText(); + gameObject.addMsgText(newMsg); + } else { + gameObject.deleteMsgText(); + } + } else + if (archetype.getMsgText() != null && archetype.getMsgText().trim().length() > 0) { + // we must override archetype msg by an empty msg + gameObject.deleteMsgText(); + gameObject.addMsgText(""); + } else { + gameObject.deleteMsgText(); // all empty + } + + // deal with syntax errors now + if (errors != null) { + if (typeStruct == archTypeList.getArchType(1)) { + // for generic (misc) type, all errors are automatically kept. + // "misc" is no real type - it is more a default mask for unknown types + gameObject.addObjectText(errors.trim()); + } else { + // open a popup dialog and ask user to decide what to do with his errors + askConfirmErrors(errors); + } + } + + gameObject.updateEditType(mapManager.getCurrentMap().getActiveEditType()); + + return true; // apply succeeded + } + + /** {@inheritDoc} */ + @Override + protected boolean isSpecialNameHandling() { + return type.getTypeNr() != Archetype.TYPE_EVENT_CONNECTOR; + } + +} // class GameObjectAttributesDialog Property changes on: trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Copied: trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java (from rev 4260, trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialogFactory.java) =================================================================== --- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java (rev 0) +++ trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-08 21:42:58 UTC (rev 4261) @@ -0,0 +1,50 @@ +package cfeditor.gui.gameobjectattributesdialog; + +import cfeditor.gameobject.Archetype; +import cfeditor.gameobject.GameObject; +import cfeditor.gui.map.CMapViewBasic; +import cfeditor.map.MapArchObject; +import javax.swing.JDialog; +import net.sf.gridarta.CFArchTypeList; +import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; +import net.sf.gridarta.gameobject.anim.AnimationObjects; +import net.sf.gridarta.gameobject.face.FaceObjects; +import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialogFactory; +import net.sf.gridarta.treasurelist.CFTreasureListTree; +import net.sf.japi.swing.ActionFactory; +import org.jetbrains.annotations.NotNull; + +public class GameObjectAttributesDialogFactory extends AbstractGameObjectAttributesDialogFactory { + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); + + /** + * Wrapper method for the constructor. This method only creates a + * GameObjectAttributesDialog if there's no dialog for the same gameObject + * already. + * @param archTypeList the list of CF type-data + * @param gameObject the GameObject to be displayed by this dialog + * @param mainControl main control + * @param animationObjects the animation objects instance to use + * @param mapManager the map manage... [truncated message content] |
From: <aki...@us...> - 2008-07-09 09:03:13
|
Revision: 4263 http://gridarta.svn.sourceforge.net/gridarta/?rev=4263&view=rev Author: akirschbaum Date: 2008-07-09 02:03:16 -0700 (Wed, 09 Jul 2008) Log Message: ----------- Replace DefaultLevelRenderer with AbstractLevelRenderer. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java trunk/crossfire/src/cfeditor/gui/map/MapRenderer.java trunk/crossfire/src/cfeditor/gui/map/SimpleLevelRenderer.java trunk/daimonin/src/daieditor/gui/map/CMapViewBasic.java trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java trunk/daimonin/src/daieditor/gui/map/MapRenderer.java trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java trunk/src/app/net/sf/gridarta/gui/map/AbstractLevelRenderer.java Modified: trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java 2008-07-08 21:48:41 UTC (rev 4262) +++ trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java 2008-07-09 09:03:16 UTC (rev 4263) @@ -30,6 +30,7 @@ import javax.swing.JViewport; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gui.ObjectChooser; +import net.sf.gridarta.gui.map.AbstractLevelRenderer; import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapCursor; import net.sf.gridarta.gui.map.MapCursorEvent; @@ -75,7 +76,7 @@ private final CMainControl mainControl; /** The tile palette renderer. */ - private final DefaultLevelRenderer renderer; + private final AbstractLevelRenderer<GameObject, MapArchObject, Archetype> renderer; /** The MapSquares that are known to contain errors. */ private final Map<MapSquare<GameObject, MapArchObject, Archetype>, ValidationError<GameObject, MapArchObject, Archetype>> erroneousMapSquares = new HashMap<MapSquare<GameObject, MapArchObject, Archetype>, ValidationError<GameObject, MapArchObject, Archetype>>(); Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2008-07-08 21:48:41 UTC (rev 4262) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2008-07-09 09:03:16 UTC (rev 4263) @@ -54,7 +54,7 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>. * @author Andreas Kirschbaum */ -public abstract class DefaultLevelRenderer extends AbstractLevelRenderer { +public abstract class DefaultLevelRenderer extends AbstractLevelRenderer<GameObject, MapArchObject, Archetype> { /** Serial Version UID. */ private static final long serialVersionUID = 1L; @@ -183,7 +183,8 @@ mapGrid.addMapGridListener(mapGridListener); } - /** Must be called when this renderer is not used anymore. */ + /** {@inheritDoc} */ + @Override public void closeNotify() { mapModel.removeMapModelListener(mapModelListener); mapGrid.removeMapGridListener(mapGridListener); @@ -240,11 +241,8 @@ private final Rectangle tmpRec = new Rectangle(); - /** - * Get coordinates, length and width of map tile. - * @param p Map coordinates - * @return Boundary rectangle of tile - */ + /** {@inheritDoc} */ + @Override public Rectangle getTileBounds(final Point p) { tmpRec.x = borderOffset.x + p.x * 32; tmpRec.y = borderOffset.y + p.y * 32; @@ -467,20 +465,14 @@ /** Callback function that is called when any tile may have changed. */ protected abstract void updateAll(); - /** - * Sets the ArchObjects that are known to contain errors. - * @param erroneousArchObjects the ArchObjects that are known to contain - * errors - */ + /** {@inheritDoc} */ + @Override public void setErroneousArchObjects(final Map<GameObject, ValidationError<GameObject, MapArchObject, Archetype>> erroneousArchObjects) { //XXX: save erroneousArchObjects } - /** - * Sets the MapSquares that are known to contain errors. - * @param erroneousMapSquares the MapSquares that are known to contain - * errors - */ + /** {@inheritDoc} */ + @Override public void setErroneousMapSquares(final Map<MapSquare<GameObject, MapArchObject, Archetype>, ValidationError<GameObject, MapArchObject, Archetype>> erroneousMapSquares) { this.erroneousMapSquares = erroneousMapSquares; } Modified: trunk/crossfire/src/cfeditor/gui/map/MapRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapRenderer.java 2008-07-08 21:48:41 UTC (rev 4262) +++ trunk/crossfire/src/cfeditor/gui/map/MapRenderer.java 2008-07-09 09:03:16 UTC (rev 4263) @@ -92,6 +92,7 @@ } /** {@inheritDoc} */ + @Override public void closeNotify() { removeMouseMotionListener(mainControl.getMainView().getStatusBar()); super.closeNotify(); Modified: trunk/crossfire/src/cfeditor/gui/map/SimpleLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/SimpleLevelRenderer.java 2008-07-08 21:48:41 UTC (rev 4262) +++ trunk/crossfire/src/cfeditor/gui/map/SimpleLevelRenderer.java 2008-07-09 09:03:16 UTC (rev 4263) @@ -25,13 +25,17 @@ import java.awt.Color; import java.awt.Graphics; import java.awt.Point; +import java.awt.Rectangle; import java.awt.image.BufferedImage; +import java.util.Map; import javax.swing.ImageIcon; import net.sf.gridarta.Size2D; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gui.SystemIcons; import net.sf.gridarta.gui.map.AbstractLevelRenderer; import net.sf.gridarta.map.MapModel; +import net.sf.gridarta.map.MapSquare; +import net.sf.gridarta.map.validation.ValidationError; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -39,7 +43,7 @@ * The SimpleLevelRenderer renders maps without MapGrid. * @author Andreas Kirschbaum */ -public final class SimpleLevelRenderer extends AbstractLevelRenderer { +public final class SimpleLevelRenderer extends AbstractLevelRenderer<GameObject, MapArchObject, Archetype> { /** The serial version UID. */ private static final long serialVersionUID = 1; @@ -135,4 +139,25 @@ public void setGridVisible(final boolean gridVisible) { } + /** {@inheritDoc} */ + @Override + public void setErroneousArchObjects(final Map<GameObject, ValidationError<GameObject, MapArchObject, Archetype>> erroneousArchObjects) { + } + + /** {@inheritDoc} */ + @Override + public void setErroneousMapSquares(final Map<MapSquare<GameObject, MapArchObject, Archetype>, ValidationError<GameObject, MapArchObject, Archetype>> erroneousMapSquares) { + } + + /** @inheritDoc} */ + @Override + public void closeNotify() { + } + + /** {@inheritDoc} */ + @Override + public Rectangle getTileBounds(final Point p) { + throw new IllegalStateException(); + } + } // class SimpleLevelRenderer Modified: trunk/daimonin/src/daieditor/gui/map/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/CMapViewBasic.java 2008-07-08 21:48:41 UTC (rev 4262) +++ trunk/daimonin/src/daieditor/gui/map/CMapViewBasic.java 2008-07-09 09:03:16 UTC (rev 4263) @@ -30,6 +30,7 @@ import java.util.Map; import javax.swing.JViewport; import net.sf.gridarta.gameobject.face.FaceObjects; +import net.sf.gridarta.gui.map.AbstractLevelRenderer; import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapCursor; import net.sf.gridarta.gui.map.MapCursorEvent; @@ -75,7 +76,7 @@ private final CMainControl mainControl; /** The tile palette renderer. */ - private final DefaultLevelRenderer renderer; + private final AbstractLevelRenderer<GameObject, MapArchObject, Archetype> renderer; /** The MapSquares that are known to contain errors. */ private final Map<MapSquare<GameObject, MapArchObject, Archetype>, ValidationError<GameObject, MapArchObject, Archetype>> erroneousMapSquares = new HashMap<MapSquare<GameObject, MapArchObject, Archetype>, ValidationError<GameObject, MapArchObject, Archetype>>(); Modified: trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2008-07-08 21:48:41 UTC (rev 4262) +++ trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2008-07-09 09:03:16 UTC (rev 4263) @@ -58,7 +58,7 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>. * @author Andreas Kirschbaum */ -public abstract class DefaultLevelRenderer extends AbstractLevelRenderer { +public abstract class DefaultLevelRenderer extends AbstractLevelRenderer<GameObject, MapArchObject, Archetype> { /** Serial Version UID. */ private static final long serialVersionUID = 1L; @@ -159,7 +159,8 @@ mapGrid.addMapGridListener(mapGridListener); } - /** Must be called when this renderer is not used anymore. */ + /** @inheritDoc} */ + @Override public void closeNotify() { mapGrid.removeMapGridListener(mapGridListener); } @@ -269,11 +270,8 @@ private final Rectangle tmpRec = new Rectangle(); - /** - * Get coordinates, length and width of map tile. - * @param p Map coordinates - * @return Boundary rectangle of tile - */ + /** {@inheritDoc} */ + @Override public Rectangle getTileBounds(final Point p) { tmpRec.x = origin.x - (p.y + 1) * IGUIConstants.TILE_ISO_XLEN2 + p.x * IGUIConstants.TILE_ISO_XLEN2; tmpRec.y = origin.y + p.y * IGUIConstants.TILE_ISO_YLEN2 + p.x * IGUIConstants.TILE_ISO_YLEN2; @@ -518,20 +516,12 @@ return new Point(xm, ym); } - /** - * Sets the ArchObjects that are known to contain errors. - * @param erroneousArchObjects the ArchObjects that are known to contain - * errors - */ + /** {@inheritDoc} */ public void setErroneousArchObjects(final Map<GameObject, ValidationError<GameObject, MapArchObject, Archetype>> erroneousArchObjects) { //XXX: save erroneousArchObjects } - /** - * Sets the MapSquares that are known to contain errors. - * @param erroneousMapSquares the MapSquares that are known to contain - * errors - */ + /** {@inheritDoc} */ public void setErroneousMapSquares(final Map<MapSquare<GameObject, MapArchObject, Archetype>, ValidationError<GameObject, MapArchObject, Archetype>> erroneousMapSquares) { this.erroneousMapSquares = erroneousMapSquares; } Modified: trunk/daimonin/src/daieditor/gui/map/MapRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/MapRenderer.java 2008-07-08 21:48:41 UTC (rev 4262) +++ trunk/daimonin/src/daieditor/gui/map/MapRenderer.java 2008-07-09 09:03:16 UTC (rev 4263) @@ -60,6 +60,7 @@ } /** {@inheritDoc} */ + @Override public void closeNotify() { removeMouseMotionListener(mainControl.getMainView().getStatusBar()); super.closeNotify(); Modified: trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java 2008-07-08 21:48:41 UTC (rev 4262) +++ trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java 2008-07-09 09:03:16 UTC (rev 4263) @@ -30,12 +30,14 @@ import java.awt.Point; import java.awt.Rectangle; import java.awt.image.BufferedImage; +import java.util.Map; import javax.swing.ImageIcon; import net.sf.gridarta.Size2D; import net.sf.gridarta.gui.SystemIcons; import net.sf.gridarta.gui.map.AbstractLevelRenderer; import net.sf.gridarta.map.MapModel; import net.sf.gridarta.map.MapSquare; +import net.sf.gridarta.map.validation.ValidationError; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -43,7 +45,7 @@ * The SimpleLevelRenderer renders maps without MapGrid or validation errors. * @author <a href="mailto:dlv...@gm...">Daniel Viegas</a> */ -public final class SimpleLevelRenderer extends AbstractLevelRenderer { +public final class SimpleLevelRenderer extends AbstractLevelRenderer<GameObject, MapArchObject, Archetype> { /** The serial version UID. */ private static final long serialVersionUID = 1; @@ -204,4 +206,24 @@ public void setGridVisible(final boolean gridVisible) { } + /** {@inheritDoc} */ + @Override + public void setErroneousArchObjects(final Map<GameObject, ValidationError<GameObject, MapArchObject, Archetype>> erroneousArchObjects) { + } + + /** {@inheritDoc} */ + @Override + public void setErroneousMapSquares(final Map<MapSquare<GameObject, MapArchObject, Archetype>, ValidationError<GameObject, MapArchObject, Archetype>> erroneousMapSquares) { + } + + /** @inheritDoc} */ + @Override + public void closeNotify() { + } + + /** @inheritDoc} */ + @Override + public Rectangle getTileBounds(final Point p) { + throw new IllegalStateException(); + } } // class SimpleLevelRenderer Modified: trunk/src/app/net/sf/gridarta/gui/map/AbstractLevelRenderer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/AbstractLevelRenderer.java 2008-07-08 21:48:41 UTC (rev 4262) +++ trunk/src/app/net/sf/gridarta/gui/map/AbstractLevelRenderer.java 2008-07-09 09:03:16 UTC (rev 4263) @@ -19,17 +19,49 @@ package net.sf.gridarta.gui.map; +import java.awt.Point; +import java.awt.Rectangle; import java.io.File; import java.io.IOException; +import java.util.Map; import javax.imageio.ImageIO; import javax.swing.JComponent; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapSquare; +import net.sf.gridarta.map.validation.ValidationError; /** Abstract base class for classes implementing {@link LevelRenderer}. */ -public abstract class AbstractLevelRenderer extends JComponent implements LevelRenderer { +public abstract class AbstractLevelRenderer<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends JComponent implements LevelRenderer { /** {@inheritDoc} */ public void printFullImage(final File file) throws IOException { ImageIO.write(getFullImage(), "png", file); } + /** + * Sets the ArchObjects that are known to contain errors. + * @param erroneousArchObjects the ArchObjects that are known to contain + * errors + */ + public abstract void setErroneousArchObjects(final Map<G, ValidationError<G, A, R>> erroneousArchObjects); + + /** + * Sets the MapSquares that are known to contain errors. + * @param erroneousMapSquares the MapSquares that are known to contain + * errors + */ + public abstract void setErroneousMapSquares(final Map<MapSquare<G, A, R>, ValidationError<G, A, R>> erroneousMapSquares); + + /** Must be called when this renderer is not used anymore. */ + public abstract void closeNotify(); + + /** + * Get coordinates, length and width of map tile. + * @param p Map coordinates + * @return Boundary rectangle of tile + */ + public abstract Rectangle getTileBounds(final Point p); + } // class AbstractLevelRenderer This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-09 17:33:54
|
Revision: 4265 http://gridarta.svn.sourceforge.net/gridarta/?rev=4265&view=rev Author: akirschbaum Date: 2008-07-09 10:33:34 -0700 (Wed, 09 Jul 2008) Log Message: ----------- Remove MainControl.getMapFileFilter(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/MapActions.java trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java trunk/crossfire/src/cfeditor/gui/map/MapTilePane.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/MapActions.java trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java trunk/daimonin/src/daieditor/gui/map/MapTilePane.java trunk/src/app/net/sf/gridarta/MainControl.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/gui/map/AbstractMapTilePane.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-09 17:30:05 UTC (rev 4264) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-09 17:33:34 UTC (rev 4265) @@ -273,7 +273,7 @@ log.fatal("GameObjectMatcher 'exit' does not exist"); throw new MissingResourceException("GameObjectMatcher 'exit' does not exist", null, null); } - mapActions = new MapActions(this, getMapManager(), exitMatcher); + mapActions = new MapActions(this, getMapManager(), exitMatcher, mapFileFilter); typeList.getListTable().put("event", getEventTypes()); try { final String filename = IOUtils.getResourceURLAsString(getConfigurationDirectory(), CommonConstants.TYPEDEF_FILE); @@ -471,11 +471,6 @@ /** Swing FileFilter for map files. */ private static final FileFilter mapFileFilter = new HideFileFilterProxy(MapFileFilter.getInstance()); - /** {@inheritDoc} */ - public FileFilter getMapFileFilter() { - return mapFileFilter; - } - /** Swing FileFilter for Python scripts. */ public static final FileFilter pythonFileFilter = new HideFileFilterProxy(new EndingFileFilter(true, ACTION_FACTORY.getString("fileDialog.filter.python"), ".py")); @@ -624,7 +619,7 @@ // types.xml is missing! ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoTypes"); } else if (gameObject != null && !gameObject.hasUndefinedArchetype()) { - GameObjectAttributesDialogFactory.showAttribDialog(typeList, gameObject, this, animationObjects, getMapManager(), treasureListTree, faceObjects); + GameObjectAttributesDialogFactory.showAttribDialog(typeList, gameObject, this, animationObjects, getMapManager(), treasureListTree, faceObjects, mapFileFilter); } else { ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoDefaultArch"); } Modified: trunk/crossfire/src/cfeditor/MapActions.java =================================================================== --- trunk/crossfire/src/cfeditor/MapActions.java 2008-07-09 17:30:05 UTC (rev 4264) +++ trunk/crossfire/src/cfeditor/MapActions.java 2008-07-09 17:33:34 UTC (rev 4265) @@ -32,6 +32,7 @@ import java.util.prefs.Preferences; import javax.swing.Action; import javax.swing.JOptionPane; +import javax.swing.filechooser.FileFilter; import net.sf.gridarta.CommonConstants; import net.sf.gridarta.CurrentMapListener; import net.sf.gridarta.MainControl; @@ -107,6 +108,9 @@ /** The matcher for selecting exit objects. */ private final GameObjectMatcher exitMatcher; + /** The Swing file filter to use. */ + private final FileFilter mapFileFilter; + /** The current map listener used to detect current map/map view changes. */ private final CurrentMapListener<GameObject, MapArchObject, Archetype, CMapViewBasic> currentMapListener; @@ -118,11 +122,13 @@ * @param mainControl the main control to use * @param mapManager the map manager * @param exitMatcher the game object matcher selecting exit objects + * @param mapFileFilter the Swing file filter to use */ - public MapActions(final CMainControl mainControl, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, final GameObjectMatcher exitMatcher) { + public MapActions(final CMainControl mainControl, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, final GameObjectMatcher exitMatcher, final FileFilter mapFileFilter) { this.mainControl = mainControl; this.mapManager = mapManager; this.exitMatcher = exitMatcher; + this.mapFileFilter = mapFileFilter; shrinkMapSizeDialogManager = new ShrinkMapSizeDialogManager<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager); autoJoin = prefs.getBoolean(AUTOJOIN_KEY, false); @@ -214,7 +220,7 @@ public void mapProperties() { final MapView<GameObject, MapArchObject, Archetype, CMapViewBasic> mapView = getMapPropertiesEnabled(); if (mapView != null) { - MapPropertiesDialog.showDialog(mapView.getComponent(), mainControl, mapView.getMapControl()); + MapPropertiesDialog.showDialog(mapView.getComponent(), mainControl, mapView.getMapControl(), mapFileFilter); } } Modified: trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-09 17:30:05 UTC (rev 4264) +++ trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-09 17:33:34 UTC (rev 4265) @@ -29,6 +29,7 @@ import javax.swing.JComboBox; import javax.swing.JFormattedTextField; import javax.swing.JTextField; +import javax.swing.filechooser.FileFilter; import javax.swing.text.JTextComponent; import net.sf.gridarta.CFArchAttrib; import net.sf.gridarta.CFArchType; @@ -74,9 +75,10 @@ * @param mapManager the map manager * @param treasureListTree the treasure list tree * @param faceObjects the FaceObjects instance to use + * @param mapFileFilter the Swing file filter to use */ - public GameObjectAttributesDialog(final CFArchTypeList archTypeList, @NotNull final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final AnimationObjects<?> animationObjects, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects) { - super(archTypeList, gameObject, mainControl, animationObjects, treasureListTree, faceObjects); + public GameObjectAttributesDialog(final CFArchTypeList archTypeList, @NotNull final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final AnimationObjects<?> animationObjects, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, final FileFilter mapFileFilter) { + super(archTypeList, gameObject, mainControl, animationObjects, treasureListTree, faceObjects, mapFileFilter); this.mapManager = mapManager; } Modified: trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-09 17:30:05 UTC (rev 4264) +++ trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-09 17:33:34 UTC (rev 4265) @@ -5,6 +5,7 @@ import cfeditor.gui.map.CMapViewBasic; import cfeditor.map.MapArchObject; import javax.swing.JDialog; +import javax.swing.filechooser.FileFilter; import net.sf.gridarta.CFArchTypeList; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; @@ -31,13 +32,14 @@ * @param mapManager the map manager * @param treasureListTree the treasure list tree instance to use * @param faceObjects the FaceObjects instance to use + * @param mapFileFilter the Swing file filter to use */ - public static void showAttribDialog(final CFArchTypeList archTypeList, final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final AnimationObjects<?> animationObjects, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects) { + public static void showAttribDialog(final CFArchTypeList archTypeList, final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final AnimationObjects<?> animationObjects, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, final FileFilter mapFileFilter) { synchronized (dialogs) { if (AbstractGameObjectAttributesDialogFactory.dialogs.containsKey(gameObject)) { AbstractGameObjectAttributesDialogFactory.dialogs.get(gameObject).toFront(); } else { - final GameObjectAttributesDialog pane = new GameObjectAttributesDialog(archTypeList, gameObject, mainControl, animationObjects, mapManager, treasureListTree, faceObjects); + final GameObjectAttributesDialog pane = new GameObjectAttributesDialog(archTypeList, gameObject, mainControl, animationObjects, mapManager, treasureListTree, faceObjects, mapFileFilter); final JDialog dialog = pane.createDialog(mainControl.getMainView(), ACTION_FACTORY.getString("attribTitle")); dialog.getRootPane().setDefaultButton(pane.okButton); dialog.setResizable(true); Modified: trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java 2008-07-09 17:30:05 UTC (rev 4264) +++ trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java 2008-07-09 17:33:34 UTC (rev 4265) @@ -39,6 +39,7 @@ import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.border.EmptyBorder; +import javax.swing.filechooser.FileFilter; import net.sf.gridarta.Size2D; import net.sf.gridarta.help.Help; import net.sf.gridarta.map.MapControl; @@ -145,8 +146,9 @@ * Creates a map-options dialog. * @param mainControl The controller of this dialog. * @param mapControl The level whose properties are shown/edited. + * @param mapFileFilter the Swing file filter to use */ - private MapPropertiesDialog(final CMainControl mainControl, final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl) { + private MapPropertiesDialog(final CMainControl mainControl, final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, final FileFilter mapFileFilter) { okButton.setDefaultCapable(true); setOptions(new Object[] {helpButton, okButton, restoreButton, cancelButton}); @@ -175,7 +177,7 @@ final JPanel weatherPanel = createWeatherPanel(map); tabs.add(ACTION_FACTORY.getString("mapWeatherTabTitle"), weatherPanel); - mapTilePane = new MapTilePane(mainControl, mapControl); + mapTilePane = new MapTilePane(mainControl, mapControl, mapFileFilter); final JPanel tilePanel = createTilePathPanel(mapTilePane); tabs.add(ACTION_FACTORY.getString("mapTilesTabTitle"), tilePanel); @@ -587,9 +589,10 @@ * @param parent the parent component to show dialog on * @param mainControl CMainControl with information * @param level map to show dialog about + * @param mapFileFilter the Swing file filter to use */ - public static void showDialog(final Component parent, final CMainControl mainControl, final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> level) { - final MapPropertiesDialog pane = new MapPropertiesDialog(mainControl, level); + public static void showDialog(final Component parent, final CMainControl mainControl, final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> level, final FileFilter mapFileFilter) { + final MapPropertiesDialog pane = new MapPropertiesDialog(mainControl, level, mapFileFilter); final JDialog dialog = pane.createDialog(parent, ACTION_FACTORY.format("mapTitle", level.getMapModel().getMapArchObject().getMapDisplayName(), level.getMapFileName())); pane.dialog = dialog; dialog.getRootPane().setDefaultButton(pane.okButton); Modified: trunk/crossfire/src/cfeditor/gui/map/MapTilePane.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapTilePane.java 2008-07-09 17:30:05 UTC (rev 4264) +++ trunk/crossfire/src/cfeditor/gui/map/MapTilePane.java 2008-07-09 17:33:34 UTC (rev 4265) @@ -23,6 +23,7 @@ import cfeditor.gameobject.Archetype; import cfeditor.gameobject.GameObject; import cfeditor.map.MapArchObject; +import javax.swing.filechooser.FileFilter; import net.sf.gridarta.gui.DirectionLayout; import net.sf.gridarta.gui.map.AbstractMapTilePane; import net.sf.gridarta.map.MapControl; @@ -57,9 +58,10 @@ * paths etc.. * @param mapControl MapControl of the map that's tiles are to be viewed / * controlled + * @param mapFileFilter the Swing file filter to use */ - public MapTilePane(final CMainControl mainControl, final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl) { - super(mainControl, mapControl, tileLink, directionMapping, nextFocus); + public MapTilePane(final CMainControl mainControl, final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, final FileFilter mapFileFilter) { + super(mainControl, mapControl, tileLink, directionMapping, nextFocus, mapFileFilter); } } // class MapTilePane Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-07-09 17:30:05 UTC (rev 4264) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-07-09 17:33:34 UTC (rev 4265) @@ -329,7 +329,7 @@ log.fatal("GameObjectMatcher 'exit' does not exist"); throw new MissingResourceException("GameObjectMatcher 'exit' does not exist", null, null); } - mapActions = new MapActions(this, getMapManager(), exitMatcher); + mapActions = new MapActions(this, getMapManager(), exitMatcher, mapFileFilter); try { final String filename = IOUtils.getResourceURLAsString(getConfigurationDirectory(), CommonConstants.TYPEDEF_FILE); typeList.loadTypesFromXML(filename); @@ -643,11 +643,6 @@ /** Swing FileFilter for map files. */ private static final FileFilter mapFileFilter = new HideFileFilterProxy(MapFileFilter.getInstance()); - /** {@inheritDoc} */ - public FileFilter getMapFileFilter() { - return mapFileFilter; - } - /** Swing FileFilter for Lua scripts. */ public static final FileFilter luaFileFilter = new HideFileFilterProxy(new EndingFileFilter(true, ACTION_FACTORY.getString("fileDialog.filter.lua"), ".lua")); @@ -805,7 +800,7 @@ // types.xml is missing! ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoTypes"); } else if (gameObject != null && !gameObject.hasUndefinedArchetype()) { - GameObjectAttributesDialogFactory.showAttribDialog(typeList, gameObject, this, animationObjects, getMapManager(), treasureListTree, faceObjects); + GameObjectAttributesDialogFactory.showAttribDialog(typeList, gameObject, this, animationObjects, getMapManager(), treasureListTree, faceObjects, mapFileFilter); } else { ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoDefaultArch"); } Modified: trunk/daimonin/src/daieditor/MapActions.java =================================================================== --- trunk/daimonin/src/daieditor/MapActions.java 2008-07-09 17:30:05 UTC (rev 4264) +++ trunk/daimonin/src/daieditor/MapActions.java 2008-07-09 17:33:34 UTC (rev 4265) @@ -32,6 +32,7 @@ import java.util.prefs.Preferences; import javax.swing.Action; import javax.swing.JOptionPane; +import javax.swing.filechooser.FileFilter; import net.sf.gridarta.CommonConstants; import net.sf.gridarta.CurrentMapListener; import net.sf.gridarta.MainControl; @@ -103,6 +104,9 @@ /** The matcher for selecting exit objects. */ private final GameObjectMatcher exitMatcher; + /** The Swing file filter to use. */ + private final FileFilter mapFileFilter; + /** The current map listener used to detect current map/map view changes. */ private final CurrentMapListener<GameObject, MapArchObject, Archetype, CMapViewBasic> currentMapListener; @@ -114,11 +118,13 @@ * @param mainControl the main control to use * @param mapManager the map manager * @param exitMatcher the game object matcher selecting exit objects + * @param mapFileFilter the Swing file filter to use */ - public MapActions(final CMainControl mainControl, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, final GameObjectMatcher exitMatcher) { + public MapActions(final CMainControl mainControl, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, final GameObjectMatcher exitMatcher, final FileFilter mapFileFilter) { this.mainControl = mainControl; this.mapManager = mapManager; this.exitMatcher = exitMatcher; + this.mapFileFilter = mapFileFilter; shrinkMapSizeDialogManager = new ShrinkMapSizeDialogManager<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager); autoJoin = prefs.getBoolean(AUTOJOIN_KEY, false); @@ -210,7 +216,7 @@ public void mapProperties() { final MapView<GameObject, MapArchObject, Archetype, CMapViewBasic> mapView = getMapPropertiesEnabled(); if (mapView != null) { - MapPropertiesDialog.showDialog(mapView.getComponent(), mainControl, mapView.getMapControl()); + MapPropertiesDialog.showDialog(mapView.getComponent(), mainControl, mapView.getMapControl(), mapFileFilter); } } Modified: trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-09 17:30:05 UTC (rev 4264) +++ trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-09 17:33:34 UTC (rev 4265) @@ -29,6 +29,7 @@ import javax.swing.JComboBox; import javax.swing.JFormattedTextField; import javax.swing.JTextField; +import javax.swing.filechooser.FileFilter; import javax.swing.text.JTextComponent; import net.sf.gridarta.CFArchAttrib; import net.sf.gridarta.CFArchType; @@ -73,9 +74,10 @@ * @param mapManager the map manager * @param treasureListTree the treasure list tree * @param faceObjects the FaceObjects instance to use + * @param mapFileFilter the Swing file filter to use */ - public GameObjectAttributesDialog(final CFArchTypeList archTypeList, @NotNull final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final AnimationObjects<?> animationObjects, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects) { - super(archTypeList, gameObject, mainControl, animationObjects, treasureListTree, faceObjects); + public GameObjectAttributesDialog(final CFArchTypeList archTypeList, @NotNull final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final AnimationObjects<?> animationObjects, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, final FileFilter mapFileFilter) { + super(archTypeList, gameObject, mainControl, animationObjects, treasureListTree, faceObjects, mapFileFilter); this.mapManager = mapManager; } Modified: trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java =================================================================== --- trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-09 17:30:05 UTC (rev 4264) +++ trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-09 17:33:34 UTC (rev 4265) @@ -5,6 +5,7 @@ import daieditor.gui.map.CMapViewBasic; import daieditor.map.MapArchObject; import javax.swing.JDialog; +import javax.swing.filechooser.FileFilter; import net.sf.gridarta.CFArchTypeList; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; @@ -31,13 +32,14 @@ * @param mapManager the map manager * @param treasureListTree the treasure list tree instance to use * @param faceObjects the FaceObjects instance to use + * @param mapFileFilter the Swing file filter to use */ - public static void showAttribDialog(final CFArchTypeList archTypeList, final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final AnimationObjects<?> animationObjects, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects) { + public static void showAttribDialog(final CFArchTypeList archTypeList, final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final AnimationObjects<?> animationObjects, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, final FileFilter mapFileFilter) { synchronized (dialogs) { if (dialogs.containsKey(gameObject)) { dialogs.get(gameObject).toFront(); } else { - final GameObjectAttributesDialog pane = new GameObjectAttributesDialog(archTypeList, gameObject, mainControl, animationObjects, mapManager, treasureListTree, faceObjects); + final GameObjectAttributesDialog pane = new GameObjectAttributesDialog(archTypeList, gameObject, mainControl, animationObjects, mapManager, treasureListTree, faceObjects, mapFileFilter); final JDialog dialog = pane.createDialog(mainControl.getMainView(), ACTION_FACTORY.getString("attribTitle")); dialog.getRootPane().setDefaultButton(pane.okButton); dialog.setResizable(true); Modified: trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java 2008-07-09 17:30:05 UTC (rev 4264) +++ trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java 2008-07-09 17:33:34 UTC (rev 4265) @@ -49,6 +49,7 @@ import javax.swing.ScrollPaneConstants; import javax.swing.border.Border; import javax.swing.border.EmptyBorder; +import javax.swing.filechooser.FileFilter; import net.sf.gridarta.Size2D; import net.sf.gridarta.gui.GUIConstants; import net.sf.gridarta.help.Help; @@ -147,8 +148,9 @@ * Creates a map-options dialog. * @param mainControl The controller of this dialog. * @param mapControl The level whose properties are shown/edited. + * @param mapFileFilter the Swing file filter to use */ - private MapPropertiesDialog(final CMainControl mainControl, final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl) { + private MapPropertiesDialog(final CMainControl mainControl, final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, final FileFilter mapFileFilter) { okButton.setDefaultCapable(true); setOptions(new Object[] {helpButton, okButton, restoreButton, cancelButton}); @@ -162,7 +164,7 @@ final JPanel mainPanel = createMainPanel(map); tabs.add(ACTION_FACTORY.getString("mapMapTabTitle"), mainPanel); - mapTilePane = new MapTilePane(mainControl, mapControl); + mapTilePane = new MapTilePane(mainControl, mapControl, mapFileFilter); final JPanel tilePanel = createTilePathPanel(mapTilePane); tabs.add(ACTION_FACTORY.getString("mapTilesTabTitle"), tilePanel); @@ -547,9 +549,10 @@ * @param parent the parent component to show dialog on * @param mainControl CMainControl with information * @param level map to show dialog about + * @param mapFileFilter the Swing file filter to use */ - public static void showDialog(final Component parent, final CMainControl mainControl, final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> level) { - final MapPropertiesDialog pane = new MapPropertiesDialog(mainControl, level); + public static void showDialog(final Component parent, final CMainControl mainControl, final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> level, final FileFilter mapFileFilter) { + final MapPropertiesDialog pane = new MapPropertiesDialog(mainControl, level, mapFileFilter); final JDialog dialog = pane.createDialog(parent, ACTION_FACTORY.format("mapTitle", level.getMapModel().getMapArchObject().getMapDisplayName(), level.getMapFileName())); pane.dialog = dialog; dialog.getRootPane().setDefaultButton(pane.okButton); Modified: trunk/daimonin/src/daieditor/gui/map/MapTilePane.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/MapTilePane.java 2008-07-09 17:30:05 UTC (rev 4264) +++ trunk/daimonin/src/daieditor/gui/map/MapTilePane.java 2008-07-09 17:33:34 UTC (rev 4265) @@ -23,6 +23,7 @@ import daieditor.gameobject.Archetype; import daieditor.gameobject.GameObject; import daieditor.map.MapArchObject; +import javax.swing.filechooser.FileFilter; import net.sf.gridarta.CommonConstants; import net.sf.gridarta.gui.DirectionLayout; import net.sf.gridarta.gui.map.AbstractMapTilePane; @@ -105,9 +106,10 @@ * paths etc.. * @param mapControl MapControl of the map that's tiles are to be viewed / * controlled + * @param mapFileFilter the Swing file filter to use */ - public MapTilePane(final CMainControl mainControl, final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl) { - super(mainControl, mapControl, tileLink, directionMapping, nextFocus); + public MapTilePane(final CMainControl mainControl, final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, final FileFilter mapFileFilter) { + super(mainControl, mapControl, tileLink, directionMapping, nextFocus, mapFileFilter); } } // class MapTilePane Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-07-09 17:30:05 UTC (rev 4264) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-07-09 17:33:34 UTC (rev 4265) @@ -80,12 +80,6 @@ FileFilter getScriptFileFilter(); /** - * Get the FileFilter that matches map files. - * @return FileFilter that matches map files. - */ - FileFilter getMapFileFilter(); - - /** * Get the suffix for script files of this implementation's server side * scripting language. The returned suffix includes the infix character * ".". Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java 2008-07-09 17:30:05 UTC (rev 4264) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java 2008-07-09 17:33:34 UTC (rev 4265) @@ -64,6 +64,7 @@ import javax.swing.ScrollPaneConstants; import javax.swing.SwingConstants; import javax.swing.WindowConstants; +import javax.swing.filechooser.FileFilter; import javax.swing.text.BadLocationException; import javax.swing.text.DefaultFormatterFactory; import javax.swing.text.Document; @@ -131,6 +132,9 @@ @NotNull private final FaceObjects faceObjects; + /** Swing FileFilter for map files. */ + private final FileFilter mapFileFilter; + protected final List<DialogAttrib<?>> dialogAttribs = new ArrayList<DialogAttrib<?>>(); private JComboBox typesel; // selection box for type @@ -183,14 +187,16 @@ * @param animationObjects the animation objects instance to use * @param treasureListTree the treasure list tree * @param faceObjects the face objects instance to use + * @param mapFileFilter the Swing FileFilter for map files */ - protected AbstractGameObjectAttributesDialog(final CFArchTypeList archTypeList, @NotNull final G gameObject, @NotNull final MainControl<G, A, R, ?> mainControl, @NotNull final AnimationObjects<?> animationObjects, @NotNull final CFTreasureListTree<G, A, R> treasureListTree, @NotNull final FaceObjects faceObjects) { + protected AbstractGameObjectAttributesDialog(final CFArchTypeList archTypeList, @NotNull final G gameObject, @NotNull final MainControl<G, A, R, ?> mainControl, @NotNull final AnimationObjects<?> animationObjects, @NotNull final CFTreasureListTree<G, A, R> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter) { this.archTypeList = archTypeList; this.gameObject = gameObject.getHead(); this.mainControl = mainControl; this.animationObjects = animationObjects; this.treasureListTree = treasureListTree; this.faceObjects = faceObjects; + this.mapFileFilter = mapFileFilter; archetype = this.gameObject.getArchetype(); type = archTypeList.getType(gameObject); @@ -702,7 +708,7 @@ case MAP_PATH: case SCRIPT_FILE: { cLabel = new JLabel(attrib.getNameNew() + ": "); - final TilePanel tilePanel = new TilePanel(dType == ArchAttribType.MAP_PATH ? mainControl.getMapFileFilter() : mainControl.getScriptFileFilter()); + final TilePanel tilePanel = new TilePanel(dType == ArchAttribType.MAP_PATH ? mapFileFilter : mainControl.getScriptFileFilter()); tilePanel.setAbsoluteReference(dType == ArchAttribType.MAP_PATH ? mainControl.getGlobalSettings().getMapDir() : mainControl.getGlobalSettings().getMapDir()); tilePanel.setOriginal(gameObject.getAttributeString(nameOld)); File relativeReference; Modified: trunk/src/app/net/sf/gridarta/gui/map/AbstractMapTilePane.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/AbstractMapTilePane.java 2008-07-09 17:30:05 UTC (rev 4264) +++ trunk/src/app/net/sf/gridarta/gui/map/AbstractMapTilePane.java 2008-07-09 17:33:34 UTC (rev 4265) @@ -107,6 +107,9 @@ /** Indices of next focus. */ private final int[] nextFocus; + /** Swing FileFilter for map files. */ + private final FileFilter mapFileFilter; + /** The JTextFields with the tile paths. */ private final TilePanel[] tilePaths; @@ -115,11 +118,12 @@ * @param mainControl MainControl to use for displaying dialogs, getting * paths etc.. */ - private AbstractMapTilePane(final MainControl<?, A, ?, ?> mainControl, final int[][][] tileLink, final DirectionLayout.Direction[] directionMapping, final int[] nextFocus) { + private AbstractMapTilePane(final MainControl<?, A, ?, ?> mainControl, final int[][][] tileLink, final DirectionLayout.Direction[] directionMapping, final int[] nextFocus, final FileFilter mapFileFilter) { this.mainControl = mainControl; this.tileLink = tileLink; this.directionMapping = directionMapping; this.nextFocus = nextFocus; + this.mapFileFilter = mapFileFilter; tilePaths = new TilePanel[directionMapping.length]; buildComponents(); } @@ -131,8 +135,8 @@ * @param mapControl MapControl of the map that's tiles are to be viewed / * controlled */ - protected AbstractMapTilePane(final MainControl<?, A, ?, ?> mainControl, final MapControl<?, A, ?, ?> mapControl, final int[][][] tileLink, final DirectionLayout.Direction[] directionMapping, final int[] nextFocus) { - this(mainControl, tileLink, directionMapping, nextFocus); + protected AbstractMapTilePane(final MainControl<?, A, ?, ?> mainControl, final MapControl<?, A, ?, ?> mapControl, final int[][][] tileLink, final DirectionLayout.Direction[] directionMapping, final int[] nextFocus, final FileFilter mapFileFilter) { + this(mainControl, tileLink, directionMapping, nextFocus, mapFileFilter); setMapControl(mapControl); } @@ -174,7 +178,7 @@ tilePanels.setBorder(new CompoundBorder(BorderFactory.createTitledBorder(ACTION_FACTORY.getString("mapTiles")), GUIConstants.DIALOG_BORDER)); for (int index = 0; index < tilePaths.length; index++) { - final JPanel tilePanel = tilePaths[index] = new MapTilePanel(index, nextFocus, mainControl.getMapFileFilter()); + final JPanel tilePanel = tilePaths[index] = new MapTilePanel(index, nextFocus, mapFileFilter); tilePanels.add(tilePanel, directionMapping[index]); } return tilePanels; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-09 18:22:36
|
Revision: 4267 http://gridarta.svn.sourceforge.net/gridarta/?rev=4267&view=rev Author: akirschbaum Date: 2008-07-09 11:22:14 -0700 (Wed, 09 Jul 2008) Log Message: ----------- Move MouseOpEvent to common code base. Modified Paths: -------------- trunk/daimonin/src/daieditor/gui/map/MapUserListener.java trunk/daimonin/src/daieditor/gui/map/event/MouseOpAdapter.java trunk/daimonin/src/daieditor/gui/map/event/MouseOpListener.java trunk/daimonin/src/daieditor/gui/map/tools/DeletionTool.java trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java trunk/daimonin/src/daieditor/gui/map/tools/SelectionTool.java trunk/daimonin/src/daieditor/gui/map/tools/ToolPalette.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/map/event/ trunk/src/app/net/sf/gridarta/gui/map/event/MouseOpEvent.java Removed Paths: ------------- trunk/daimonin/src/daieditor/gui/map/event/MouseOpEvent.java Modified: trunk/daimonin/src/daieditor/gui/map/MapUserListener.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/MapUserListener.java 2008-07-09 18:11:33 UTC (rev 4266) +++ trunk/daimonin/src/daieditor/gui/map/MapUserListener.java 2008-07-09 18:22:14 UTC (rev 4267) @@ -22,7 +22,6 @@ import daieditor.CMainControl; import daieditor.gameobject.Archetype; import daieditor.gameobject.GameObject; -import daieditor.gui.map.event.MouseOpEvent; import daieditor.gui.map.event.MouseOpListener; import daieditor.gui.map.tools.ToolPalette; import daieditor.map.MapArchObject; @@ -33,6 +32,7 @@ import java.awt.event.MouseMotionListener; import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapCursor; +import net.sf.gridarta.gui.map.event.MouseOpEvent; import net.sf.gridarta.map.MapControl; import org.jetbrains.annotations.Nullable; @@ -55,7 +55,7 @@ private final Point tmpPoint = new Point(); - private final MouseOpEvent mouseOpEvent = new MouseOpEvent(); + private final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> mouseOpEvent = new MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic>(); public MapUserListener(final CMainControl mainControl, final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, final CMapViewBasic mapView) { this.mainControl = mainControl; Modified: trunk/daimonin/src/daieditor/gui/map/event/MouseOpAdapter.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/event/MouseOpAdapter.java 2008-07-09 18:11:33 UTC (rev 4266) +++ trunk/daimonin/src/daieditor/gui/map/event/MouseOpAdapter.java 2008-07-09 18:22:14 UTC (rev 4267) @@ -19,6 +19,12 @@ package daieditor.gui.map.event; +import daieditor.gameobject.Archetype; +import daieditor.gameobject.GameObject; +import daieditor.gui.map.CMapViewBasic; +import daieditor.map.MapArchObject; +import net.sf.gridarta.gui.map.event.MouseOpEvent; + /** * Event Listener Adapater for {@link MouseOpListener}. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> @@ -27,27 +33,27 @@ public abstract class MouseOpAdapter implements MouseOpListener { /** {@inheritDoc} */ - public void clicked(final MouseOpEvent e) { + public void clicked(final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e) { /* empty base implementation. */ } /** {@inheritDoc} */ - public void dragged(final MouseOpEvent e) { + public void dragged(final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e) { /* empty base implementation. */ } /** {@inheritDoc} */ - public void moved(final MouseOpEvent e) { + public void moved(final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e) { /* empty base implementation. */ } /** {@inheritDoc} */ - public void pressed(final MouseOpEvent e) { + public void pressed(final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e) { /* empty base implementation. */ } /** {@inheritDoc} */ - public void released(final MouseOpEvent e) { + public void released(final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e) { } } // class MouseOpAdapter Deleted: trunk/daimonin/src/daieditor/gui/map/event/MouseOpEvent.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/event/MouseOpEvent.java 2008-07-09 18:11:33 UTC (rev 4266) +++ trunk/daimonin/src/daieditor/gui/map/event/MouseOpEvent.java 2008-07-09 18:22:14 UTC (rev 4267) @@ -1,183 +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.map.event; - -import daieditor.gameobject.Archetype; -import daieditor.gameobject.GameObject; -import daieditor.gui.map.CMapViewBasic; -import daieditor.map.MapArchObject; -import java.awt.Point; -import java.util.EventObject; -import net.sf.gridarta.gui.map.MapCursor; -import net.sf.gridarta.map.MapControl; -import net.sf.gridarta.map.MapModel; - -/** - * A MouseOpEvent is an event triggered for a MouseOpListener. Note that - * MouseOpEvent objects may be reused. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public class MouseOpEvent extends EventObject { - - /** The serial version UID. */ - private static final long serialVersionUID = 1; - - /** The cursor to use for this event. */ - private MapCursor mapCursor; - - /** The map control for this event. */ - private MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl; - - /** The location of the point on the map model. */ - private Point mapLocation; - - /** - * The pressed mouse button. - * @see java.awt.event.MouseEvent#getButton() - */ - private int button; - - /** - * The type of event. - * @see java.awt.AWTEvent#getID() - */ - @SuppressWarnings({"InstanceVariableNamingConvention"}) - private int id; - - /** - * The modifiers during this event. - * @see java.awt.event.MouseEvent#getModifiers() - */ - private int modifiers; - - /** The number of consecutive mouse clicks (only valid for click events). */ - private int clickCount; - - /** Create an empty MouseOpEvent. */ - public MouseOpEvent() { - super(""); - } - - /** - * Create a MouseOpEvent. - * @param source The object on which the Event initially occurred - * @param mapCursor The map cursor to control cursor and selection - * @param mapLocation The location of the point on the map model - * @param modifiers The event modifiers (keys like shift or ctrl being - * pressed while this event was triggered) - * @param clickCount The number of consecutive mouse clicks (only valid for - * click events) - * @see java.awt.event.MouseEvent#getModifiers() - */ - public MouseOpEvent(final MapModel<?, ?, ?> source, final MapCursor mapCursor, final Point mapLocation, final int modifiers, final int clickCount) { - super(source); - this.mapCursor = mapCursor; - this.mapLocation = mapLocation; - this.modifiers = modifiers; - this.clickCount = clickCount; - } - - /** - * Create a MouseOpEvent. - * @param source The object on which the Event initially occurred - * @param mapCursor The map cursor to control cursor and selection - * @param mapLocation The location of the point on the map model - * @param modifiers The event modifiers (keys like shift or ctrl being - * pressed while this event was triggered) - * @see java.awt.event.MouseEvent#getModifiersEx() - */ - public MouseOpEvent(final MapModel<?, ?, ?> source, final MapCursor mapCursor, final Point mapLocation, final int modifiers) { - this(source, mapCursor, mapLocation, modifiers, 0); - } - - public Point getMapLocation() { - return mapLocation; - } - - public int getModifiers() { - return modifiers; - } - - public MapCursor getMapCursor() { - return mapCursor; - } - - public int getClickCount() { - return clickCount; - } - - /** - * Get mouse button that changed. - * @return Changed mouse button - */ - public int getButton() { - return button; - } - - /** - * Set mouse button that changed. - * @param button Mouse button that changed. - */ - public void setButton(final int button) { - this.button = button; - } - - public void setMapCursor(final MapCursor mapCursor) { - this.mapCursor = mapCursor; - } - - public void setMapLocation(final Point mapLocation) { - this.mapLocation = mapLocation; - } - - public void setModifiers(final int modifiers) { - this.modifiers = modifiers; - } - - public void setClickCount(final int clickCount) { - this.clickCount = clickCount; - } - - public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> getMapControl() { - return mapControl; - } - - public void setMapControl(final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl) { - this.mapControl = mapControl; - } - - /** - * Get event type. - * @return Return event type - * @see java.awt.AWTEvent#getID() - */ - public int getId() { - return id; - } - - /** - * Set event type. - * @param id Set event type to <code>id</code> - */ - public void setId(final int id) { - this.id = id; - } - -} // class MouseOpEvent Modified: trunk/daimonin/src/daieditor/gui/map/event/MouseOpListener.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/event/MouseOpListener.java 2008-07-09 18:11:33 UTC (rev 4266) +++ trunk/daimonin/src/daieditor/gui/map/event/MouseOpListener.java 2008-07-09 18:22:14 UTC (rev 4267) @@ -19,6 +19,12 @@ package daieditor.gui.map.event; +import daieditor.gameobject.Archetype; +import daieditor.gameobject.GameObject; +import daieditor.gui.map.CMapViewBasic; +import daieditor.map.MapArchObject; +import net.sf.gridarta.gui.map.event.MouseOpEvent; + /** * Interface for Mouse Operations. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> @@ -29,30 +35,30 @@ * Mouse was clicked. * @param e Event */ - void clicked(MouseOpEvent e); + void clicked(MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e); /** * Mouse was dragged. * @param e Event */ - void dragged(MouseOpEvent e); + void dragged(MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e); /** * Mouse was moved. * @param e Event */ - void moved(MouseOpEvent e); + void moved(MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e); /** * Mouse was pressed. * @param e Event */ - void pressed(MouseOpEvent e); + void pressed(MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e); /** * Mouse was released. * @param e Event */ - void released(MouseOpEvent e); + void released(MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e); } // interface MouseOpListener Modified: trunk/daimonin/src/daieditor/gui/map/tools/DeletionTool.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/DeletionTool.java 2008-07-09 18:11:33 UTC (rev 4266) +++ trunk/daimonin/src/daieditor/gui/map/tools/DeletionTool.java 2008-07-09 18:22:14 UTC (rev 4267) @@ -22,13 +22,13 @@ import daieditor.gameobject.Archetype; import daieditor.gameobject.GameObject; import daieditor.gui.map.CMapViewBasic; -import daieditor.gui.map.event.MouseOpEvent; import daieditor.map.MapArchObject; import java.awt.Component; import java.awt.Point; import javax.swing.JPanel; import net.sf.gridarta.MainControl; import net.sf.gridarta.gui.map.MapCursor; +import net.sf.gridarta.gui.map.event.MouseOpEvent; import net.sf.gridarta.map.MapControl; import net.sf.gridarta.map.MapSquare; import net.sf.japi.swing.ActionFactory; @@ -67,7 +67,7 @@ /** {@inheritDoc} */ @Override - public void pressed(final MouseOpEvent e) { + public void pressed(final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e) { final Point mapLoc = e.getMapLocation(); final MapCursor mapCursor = e.getMapCursor(); final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = e.getMapControl(); @@ -80,7 +80,7 @@ /** {@inheritDoc} */ @Override - public void dragged(final MouseOpEvent e) { + public void dragged(final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e) { final Point mapLoc = e.getMapLocation(); final MapCursor mapCursor = e.getMapCursor(); final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = e.getMapControl(); Modified: trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java 2008-07-09 18:11:33 UTC (rev 4266) +++ trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java 2008-07-09 18:22:14 UTC (rev 4267) @@ -22,7 +22,6 @@ import daieditor.gameobject.Archetype; import daieditor.gameobject.GameObject; import daieditor.gui.map.CMapViewBasic; -import daieditor.gui.map.event.MouseOpEvent; import daieditor.map.MapArchObject; import java.awt.Component; import java.awt.Point; @@ -30,6 +29,7 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.map.MapCursor; +import net.sf.gridarta.gui.map.event.MouseOpEvent; import net.sf.gridarta.map.MapControl; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ToggleAction; @@ -75,7 +75,7 @@ /** {@inheritDoc} */ @Override - public void pressed(final MouseOpEvent e) { + public void pressed(final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e) { final Point p = e.getMapLocation(); final MapCursor mapCursor = e.getMapCursor(); final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = e.getMapControl(); @@ -92,7 +92,7 @@ /** {@inheritDoc} */ @Override - public void dragged(final MouseOpEvent e) { + public void dragged(final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e) { final Point p = e.getMapLocation(); final MapCursor mapCursor = e.getMapCursor(); final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = e.getMapControl(); Modified: trunk/daimonin/src/daieditor/gui/map/tools/SelectionTool.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/SelectionTool.java 2008-07-09 18:11:33 UTC (rev 4266) +++ trunk/daimonin/src/daieditor/gui/map/tools/SelectionTool.java 2008-07-09 18:22:14 UTC (rev 4267) @@ -22,13 +22,13 @@ import daieditor.gameobject.Archetype; import daieditor.gameobject.GameObject; import daieditor.gui.map.CMapViewBasic; -import daieditor.gui.map.event.MouseOpEvent; import daieditor.map.MapArchObject; import java.awt.Point; import java.awt.event.InputEvent; import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.map.MapCursor; import net.sf.gridarta.gui.map.MapGrid; +import net.sf.gridarta.gui.map.event.MouseOpEvent; import net.sf.gridarta.map.MapControl; import org.jetbrains.annotations.NotNull; @@ -53,7 +53,7 @@ /** {@inheritDoc} */ @Override - public void pressed(final MouseOpEvent e) { + public void pressed(final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e) { final Point mapLoc = e.getMapLocation(); final int mod = e.getModifiers(); final MapCursor mapCursor = e.getMapCursor(); @@ -76,13 +76,13 @@ /** {@inheritDoc} */ @Override - public void dragged(final MouseOpEvent e) { + public void dragged(final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e) { e.getMapCursor().dragTo(e.getMapLocation()); } /** {@inheritDoc} */ @Override - public void released(final MouseOpEvent e) { + public void released(final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e) { final MapCursor mapCursor = e.getMapCursor(); final int modifiers = e.getModifiers(); if (mapCursor.isOnGrid(e.getMapLocation())) { Modified: trunk/daimonin/src/daieditor/gui/map/tools/ToolPalette.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/ToolPalette.java 2008-07-09 18:11:33 UTC (rev 4266) +++ trunk/daimonin/src/daieditor/gui/map/tools/ToolPalette.java 2008-07-09 18:22:14 UTC (rev 4267) @@ -22,7 +22,6 @@ import daieditor.gameobject.Archetype; import daieditor.gameobject.GameObject; import daieditor.gui.map.CMapViewBasic; -import daieditor.gui.map.event.MouseOpEvent; import daieditor.map.MapArchObject; import java.awt.BorderLayout; import java.awt.event.InputEvent; @@ -32,6 +31,7 @@ import javax.swing.JTabbedPane; import net.sf.gridarta.MainControl; import net.sf.gridarta.gui.ObjectChooser; +import net.sf.gridarta.gui.map.event.MouseOpEvent; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -87,7 +87,7 @@ * mouse button is not bound to a tool. */ @Nullable - public Tool getTool(final MouseOpEvent event) { + public Tool getTool(final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> event) { final int button = event.getButton(); final ToolSelector toolSelector; switch (button) { Copied: trunk/src/app/net/sf/gridarta/gui/map/event/MouseOpEvent.java (from rev 4265, trunk/daimonin/src/daieditor/gui/map/event/MouseOpEvent.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/event/MouseOpEvent.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/map/event/MouseOpEvent.java 2008-07-09 18:22:14 UTC (rev 4267) @@ -0,0 +1,183 @@ +/* + * 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.map.event; + +import java.awt.Point; +import java.util.EventObject; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.map.MapCursor; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.map.MapModel; + +/** + * A MouseOpEvent is an event triggered for a MouseOpListener. Note that + * MouseOpEvent objects may be reused. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class MouseOpEvent<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R>> extends EventObject { + + /** The serial version UID. */ + private static final long serialVersionUID = 1; + + /** The cursor to use for this event. */ + private MapCursor mapCursor; + + /** The map control for this event. */ + private MapControl<G, A, R, V> mapControl; + + /** The location of the point on the map model. */ + private Point mapLocation; + + /** + * The pressed mouse button. + * @see java.awt.event.MouseEvent#getButton() + */ + private int button; + + /** + * The type of event. + * @see java.awt.AWTEvent#getID() + */ + @SuppressWarnings({"InstanceVariableNamingConvention"}) + private int id; + + /** + * The modifiers during this event. + * @see java.awt.event.MouseEvent#getModifiers() + */ + private int modifiers; + + /** The number of consecutive mouse clicks (only valid for click events). */ + private int clickCount; + + /** Create an empty MouseOpEvent. */ + public MouseOpEvent() { + super(""); + } + + /** + * Create a MouseOpEvent. + * @param source The object on which the Event initially occurred + * @param mapCursor The map cursor to control cursor and selection + * @param mapLocation The location of the point on the map model + * @param modifiers The event modifiers (keys like shift or ctrl being + * pressed while this event was triggered) + * @param clickCount The number of consecutive mouse clicks (only valid for + * click events) + * @see java.awt.event.MouseEvent#getModifiers() + */ + public MouseOpEvent(final MapModel<G, A, R> source, final MapCursor mapCursor, final Point mapLocation, final int modifiers, final int clickCount) { + super(source); + this.mapCursor = mapCursor; + this.mapLocation = mapLocation; + this.modifiers = modifiers; + this.clickCount = clickCount; + } + + /** + * Create a MouseOpEvent. + * @param source The object on which the Event initially occurred + * @param mapCursor The map cursor to control cursor and selection + * @param mapLocation The location of the point on the map model + * @param modifiers The event modifiers (keys like shift or ctrl being + * pressed while this event was triggered) + * @see java.awt.event.MouseEvent#getModifiersEx() + */ + public MouseOpEvent(final MapModel<G, A, R> source, final MapCursor mapCursor, final Point mapLocation, final int modifiers) { + this(source, mapCursor, mapLocation, modifiers, 0); + } + + public Point getMapLocation() { + return mapLocation; + } + + public int getModifiers() { + return modifiers; + } + + public MapCursor getMapCursor() { + return mapCursor; + } + + public int getClickCount() { + return clickCount; + } + + /** + * Get mouse button that changed. + * @return Changed mouse button + */ + public int getButton() { + return button; + } + + /** + * Set mouse button that changed. + * @param button Mouse button that changed. + */ + public void setButton(final int button) { + this.button = button; + } + + public void setMapCursor(final MapCursor mapCursor) { + this.mapCursor = mapCursor; + } + + public void setMapLocation(final Point mapLocation) { + this.mapLocation = mapLocation; + } + + public void setModifiers(final int modifiers) { + this.modifiers = modifiers; + } + + public void setClickCount(final int clickCount) { + this.clickCount = clickCount; + } + + public MapControl<G, A, R, V> getMapControl() { + return mapControl; + } + + public void setMapControl(final MapControl<G, A, R, V> mapControl) { + this.mapControl = mapControl; + } + + /** + * Get event type. + * @return Return event type + * @see java.awt.AWTEvent#getID() + */ + public int getId() { + return id; + } + + /** + * Set event type. + * @param id Set event type to <code>id</code> + */ + public void setId(final int id) { + this.id = id; + } + +} // class MouseOpEvent Property changes on: trunk/src/app/net/sf/gridarta/gui/map/event/MouseOpEvent.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-09 18:38:21
|
Revision: 4268 http://gridarta.svn.sourceforge.net/gridarta/?rev=4268&view=rev Author: akirschbaum Date: 2008-07-09 11:38:18 -0700 (Wed, 09 Jul 2008) Log Message: ----------- Move MouseOpListener to common code base. Modified Paths: -------------- trunk/daimonin/src/daieditor/gui/map/MapUserListener.java trunk/daimonin/src/daieditor/gui/map/event/MouseOpAdapter.java trunk/daimonin/src/daieditor/gui/map/tools/Tool.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/map/event/MouseOpListener.java Removed Paths: ------------- trunk/daimonin/src/daieditor/gui/map/event/MouseOpListener.java Modified: trunk/daimonin/src/daieditor/gui/map/MapUserListener.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/MapUserListener.java 2008-07-09 18:22:14 UTC (rev 4267) +++ trunk/daimonin/src/daieditor/gui/map/MapUserListener.java 2008-07-09 18:38:18 UTC (rev 4268) @@ -22,7 +22,6 @@ import daieditor.CMainControl; import daieditor.gameobject.Archetype; import daieditor.gameobject.GameObject; -import daieditor.gui.map.event.MouseOpListener; import daieditor.gui.map.tools.ToolPalette; import daieditor.map.MapArchObject; import java.awt.Point; @@ -33,6 +32,7 @@ import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapCursor; import net.sf.gridarta.gui.map.event.MouseOpEvent; +import net.sf.gridarta.gui.map.event.MouseOpListener; import net.sf.gridarta.map.MapControl; import org.jetbrains.annotations.Nullable; @@ -67,7 +67,7 @@ /** {@inheritDoc} */ public void mouseClicked(final MouseEvent e) { - final MouseOpListener mouseOpListener = getMouseOperation(e); + final MouseOpListener<GameObject, MapArchObject, Archetype, CMapViewBasic> mouseOpListener = getMouseOperation(e); if (mouseOpListener != null) { mouseOpListener.clicked(mouseOpEvent); } @@ -96,7 +96,7 @@ /** {@inheritDoc} */ public void mouseDragged(final MouseEvent e) { - final MouseOpListener mouseOpListener = getMouseOperation(e); + final MouseOpListener<GameObject, MapArchObject, Archetype, CMapViewBasic> mouseOpListener = getMouseOperation(e); if (mouseOpListener != null) { mouseOpListener.dragged(mouseOpEvent); } @@ -104,7 +104,7 @@ /** {@inheritDoc} */ public void mouseMoved(final MouseEvent e) { - final MouseOpListener mouseOpListener = getMouseOperation(e); + final MouseOpListener<GameObject, MapArchObject, Archetype, CMapViewBasic> mouseOpListener = getMouseOperation(e); if (mouseOpListener != null) { mouseOpListener.moved(mouseOpEvent); } @@ -118,7 +118,7 @@ if (mapControl.isPickmap() && mainControl.getObjectChooser().getPickmapChooserControl().isLockAllPickmaps() && !(e.getModifiers() == InputEvent.BUTTON1_MASK && !e.isShiftDown() && !e.isControlDown())) { return; } - final MouseOpListener mouseOpListener = getMouseOperation(e); + final MouseOpListener<GameObject, MapArchObject, Archetype, CMapViewBasic> mouseOpListener = getMouseOperation(e); if (mouseOpListener != null) { mouseOpListener.pressed(mouseOpEvent); } @@ -126,7 +126,7 @@ /** {@inheritDoc} */ public void mouseReleased(final MouseEvent e) { - final MouseOpListener mouseOpListener = getMouseOperation(e); + final MouseOpListener<GameObject, MapArchObject, Archetype, CMapViewBasic> mouseOpListener = getMouseOperation(e); if (mouseOpListener != null) { mouseOpListener.released(mouseOpEvent); } @@ -138,7 +138,7 @@ * @return mouse operation for <var>event</var> */ @Nullable - private MouseOpListener getMouseOperation(final MouseEvent event) { + private MouseOpListener<GameObject, MapArchObject, Archetype, CMapViewBasic> getMouseOperation(final MouseEvent event) { initEvent(event); return toolPalette.getTool(mouseOpEvent); } Modified: trunk/daimonin/src/daieditor/gui/map/event/MouseOpAdapter.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/event/MouseOpAdapter.java 2008-07-09 18:22:14 UTC (rev 4267) +++ trunk/daimonin/src/daieditor/gui/map/event/MouseOpAdapter.java 2008-07-09 18:38:18 UTC (rev 4268) @@ -24,13 +24,14 @@ import daieditor.gui.map.CMapViewBasic; import daieditor.map.MapArchObject; import net.sf.gridarta.gui.map.event.MouseOpEvent; +import net.sf.gridarta.gui.map.event.MouseOpListener; /** - * Event Listener Adapater for {@link MouseOpListener}. + * Event Listener Adapater for {@link net.sf.gridarta.gui.map.event.MouseOpListener}. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ @SuppressWarnings({"NoopMethodInAbstractClass"}) -public abstract class MouseOpAdapter implements MouseOpListener { +public abstract class MouseOpAdapter implements MouseOpListener<GameObject, MapArchObject, Archetype, CMapViewBasic> { /** {@inheritDoc} */ public void clicked(final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e) { Deleted: trunk/daimonin/src/daieditor/gui/map/event/MouseOpListener.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/event/MouseOpListener.java 2008-07-09 18:22:14 UTC (rev 4267) +++ trunk/daimonin/src/daieditor/gui/map/event/MouseOpListener.java 2008-07-09 18:38:18 UTC (rev 4268) @@ -1,64 +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.map.event; - -import daieditor.gameobject.Archetype; -import daieditor.gameobject.GameObject; -import daieditor.gui.map.CMapViewBasic; -import daieditor.map.MapArchObject; -import net.sf.gridarta.gui.map.event.MouseOpEvent; - -/** - * Interface for Mouse Operations. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public interface MouseOpListener { - - /** - * Mouse was clicked. - * @param e Event - */ - void clicked(MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e); - - /** - * Mouse was dragged. - * @param e Event - */ - void dragged(MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e); - - /** - * Mouse was moved. - * @param e Event - */ - void moved(MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e); - - /** - * Mouse was pressed. - * @param e Event - */ - void pressed(MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e); - - /** - * Mouse was released. - * @param e Event - */ - void released(MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e); - -} // interface MouseOpListener Modified: trunk/daimonin/src/daieditor/gui/map/tools/Tool.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/Tool.java 2008-07-09 18:22:14 UTC (rev 4267) +++ trunk/daimonin/src/daieditor/gui/map/tools/Tool.java 2008-07-09 18:38:18 UTC (rev 4268) @@ -19,15 +19,19 @@ package daieditor.gui.map.tools; -import daieditor.gui.map.event.MouseOpListener; +import daieditor.gameobject.Archetype; +import daieditor.gameobject.GameObject; +import daieditor.gui.map.CMapViewBasic; +import daieditor.map.MapArchObject; import java.awt.Component; +import net.sf.gridarta.gui.map.event.MouseOpListener; import org.jetbrains.annotations.Nullable; /** * Interface for tools that are used to manipulate maps. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public interface Tool extends MouseOpListener { +public interface Tool extends MouseOpListener<GameObject, MapArchObject, Archetype, CMapViewBasic> { /** * Create a view for changing the options of this tool. Copied: trunk/src/app/net/sf/gridarta/gui/map/event/MouseOpListener.java (from rev 4267, trunk/daimonin/src/daieditor/gui/map/event/MouseOpListener.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/event/MouseOpListener.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/map/event/MouseOpListener.java 2008-07-09 18:38:18 UTC (rev 4268) @@ -0,0 +1,63 @@ +/* + * 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.map.event; + +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.map.MapArchObject; + +/** + * Interface for Mouse Operations. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public interface MouseOpListener<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R>> { + + /** + * Mouse was clicked. + * @param e Event + */ + void clicked(MouseOpEvent<G, A, R, V> e); + + /** + * Mouse was dragged. + * @param e Event + */ + void dragged(MouseOpEvent<G, A, R, V> e); + + /** + * Mouse was moved. + * @param e Event + */ + void moved(MouseOpEvent<G, A, R, V> e); + + /** + * Mouse was pressed. + * @param e Event + */ + void pressed(MouseOpEvent<G, A, R, V> e); + + /** + * Mouse was released. + * @param e Event + */ + void released(MouseOpEvent<G, A, R, V> e); + +} // interface MouseOpListener Property changes on: trunk/src/app/net/sf/gridarta/gui/map/event/MouseOpListener.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-09 19:26:46
|
Revision: 4269 http://gridarta.svn.sourceforge.net/gridarta/?rev=4269&view=rev Author: akirschbaum Date: 2008-07-09 12:25:29 -0700 (Wed, 09 Jul 2008) Log Message: ----------- Move MouseOpAdapter to common code base. Modified Paths: -------------- trunk/daimonin/src/daieditor/gui/map/tools/AbstractTool.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/map/event/MouseOpAdapter.java Removed Paths: ------------- trunk/daimonin/src/daieditor/gui/map/event/MouseOpAdapter.java Deleted: trunk/daimonin/src/daieditor/gui/map/event/MouseOpAdapter.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/event/MouseOpAdapter.java 2008-07-09 18:38:18 UTC (rev 4268) +++ trunk/daimonin/src/daieditor/gui/map/event/MouseOpAdapter.java 2008-07-09 19:25:29 UTC (rev 4269) @@ -1,60 +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.map.event; - -import daieditor.gameobject.Archetype; -import daieditor.gameobject.GameObject; -import daieditor.gui.map.CMapViewBasic; -import daieditor.map.MapArchObject; -import net.sf.gridarta.gui.map.event.MouseOpEvent; -import net.sf.gridarta.gui.map.event.MouseOpListener; - -/** - * Event Listener Adapater for {@link net.sf.gridarta.gui.map.event.MouseOpListener}. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -@SuppressWarnings({"NoopMethodInAbstractClass"}) -public abstract class MouseOpAdapter implements MouseOpListener<GameObject, MapArchObject, Archetype, CMapViewBasic> { - - /** {@inheritDoc} */ - public void clicked(final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e) { - /* empty base implementation. */ - } - - /** {@inheritDoc} */ - public void dragged(final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e) { - /* empty base implementation. */ - } - - /** {@inheritDoc} */ - public void moved(final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e) { - /* empty base implementation. */ - } - - /** {@inheritDoc} */ - public void pressed(final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e) { - /* empty base implementation. */ - } - - /** {@inheritDoc} */ - public void released(final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e) { - } - -} // class MouseOpAdapter Modified: trunk/daimonin/src/daieditor/gui/map/tools/AbstractTool.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/AbstractTool.java 2008-07-09 18:38:18 UTC (rev 4268) +++ trunk/daimonin/src/daieditor/gui/map/tools/AbstractTool.java 2008-07-09 19:25:29 UTC (rev 4269) @@ -19,14 +19,18 @@ package daieditor.gui.map.tools; -import daieditor.gui.map.event.MouseOpAdapter; +import daieditor.gameobject.Archetype; +import daieditor.gameobject.GameObject; +import daieditor.gui.map.CMapViewBasic; +import daieditor.map.MapArchObject; +import net.sf.gridarta.gui.map.event.MouseOpAdapter; /** * Base class for tools. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ @SuppressWarnings({"AbstractClassWithOnlyOneDirectInheritor"}) -public abstract class AbstractTool extends MouseOpAdapter implements Tool { +public abstract class AbstractTool extends MouseOpAdapter<GameObject, MapArchObject, Archetype, CMapViewBasic> implements Tool { /** Create an AbstractTool. */ protected AbstractTool() { Copied: trunk/src/app/net/sf/gridarta/gui/map/event/MouseOpAdapter.java (from rev 4268, trunk/daimonin/src/daieditor/gui/map/event/MouseOpAdapter.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/event/MouseOpAdapter.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/map/event/MouseOpAdapter.java 2008-07-09 19:25:29 UTC (rev 4269) @@ -0,0 +1,58 @@ +/* + * 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.map.event; + +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.map.MapArchObject; + +/** + * Event Listener Adapater for {@link net.sf.gridarta.gui.map.event.MouseOpListener}. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +@SuppressWarnings({"NoopMethodInAbstractClass"}) +public abstract class MouseOpAdapter<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R>> implements MouseOpListener<G, A, R, V> { + + /** {@inheritDoc} */ + public void clicked(final MouseOpEvent<G, A, R, V> e) { + /* empty base implementation. */ + } + + /** {@inheritDoc} */ + public void dragged(final MouseOpEvent<G, A, R, V> e) { + /* empty base implementation. */ + } + + /** {@inheritDoc} */ + public void moved(final MouseOpEvent<G, A, R, V> e) { + /* empty base implementation. */ + } + + /** {@inheritDoc} */ + public void pressed(final MouseOpEvent<G, A, R, V> e) { + /* empty base implementation. */ + } + + /** {@inheritDoc} */ + public void released(final MouseOpEvent<G, A, R, V> e) { + } + +} // class MouseOpAdapter Property changes on: trunk/src/app/net/sf/gridarta/gui/map/event/MouseOpAdapter.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-09 19:42:09
|
Revision: 4270 http://gridarta.svn.sourceforge.net/gridarta/?rev=4270&view=rev Author: akirschbaum Date: 2008-07-09 12:41:07 -0700 (Wed, 09 Jul 2008) Log Message: ----------- Move Tool and AbstractTool to common code base. Modified Paths: -------------- trunk/daimonin/src/daieditor/gui/map/tools/BasicAbstractTool.java trunk/daimonin/src/daieditor/gui/map/tools/ToolPalette.java trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/map/tools/ trunk/src/app/net/sf/gridarta/gui/map/tools/AbstractTool.java trunk/src/app/net/sf/gridarta/gui/map/tools/Tool.java trunk/src/app/net/sf/gridarta/gui/map/tools/package-info.java Removed Paths: ------------- trunk/daimonin/src/daieditor/gui/map/tools/AbstractTool.java trunk/daimonin/src/daieditor/gui/map/tools/Tool.java trunk/daimonin/src/daieditor/gui/map/tools/package-info.java Deleted: trunk/daimonin/src/daieditor/gui/map/tools/AbstractTool.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/AbstractTool.java 2008-07-09 19:25:29 UTC (rev 4269) +++ trunk/daimonin/src/daieditor/gui/map/tools/AbstractTool.java 2008-07-09 19:41:07 UTC (rev 4270) @@ -1,39 +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.map.tools; - -import daieditor.gameobject.Archetype; -import daieditor.gameobject.GameObject; -import daieditor.gui.map.CMapViewBasic; -import daieditor.map.MapArchObject; -import net.sf.gridarta.gui.map.event.MouseOpAdapter; - -/** - * Base class for tools. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -@SuppressWarnings({"AbstractClassWithOnlyOneDirectInheritor"}) -public abstract class AbstractTool extends MouseOpAdapter<GameObject, MapArchObject, Archetype, CMapViewBasic> implements Tool { - - /** Create an AbstractTool. */ - protected AbstractTool() { - } - -} // class AbstractTool Modified: trunk/daimonin/src/daieditor/gui/map/tools/BasicAbstractTool.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/BasicAbstractTool.java 2008-07-09 19:25:29 UTC (rev 4269) +++ trunk/daimonin/src/daieditor/gui/map/tools/BasicAbstractTool.java 2008-07-09 19:41:07 UTC (rev 4270) @@ -19,7 +19,12 @@ package daieditor.gui.map.tools; +import daieditor.gameobject.Archetype; +import daieditor.gameobject.GameObject; +import daieditor.gui.map.CMapViewBasic; +import daieditor.map.MapArchObject; import java.awt.Component; +import net.sf.gridarta.gui.map.tools.AbstractTool; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; @@ -27,7 +32,7 @@ * Base class for the default provided tools. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -class BasicAbstractTool extends AbstractTool { +class BasicAbstractTool extends AbstractTool<GameObject, MapArchObject, Archetype, CMapViewBasic> { /** The ID of this tool. */ @SuppressWarnings({"InstanceVariableNamingConvention"}) Deleted: trunk/daimonin/src/daieditor/gui/map/tools/Tool.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/Tool.java 2008-07-09 19:25:29 UTC (rev 4269) +++ trunk/daimonin/src/daieditor/gui/map/tools/Tool.java 2008-07-09 19:41:07 UTC (rev 4270) @@ -1,51 +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.map.tools; - -import daieditor.gameobject.Archetype; -import daieditor.gameobject.GameObject; -import daieditor.gui.map.CMapViewBasic; -import daieditor.map.MapArchObject; -import java.awt.Component; -import net.sf.gridarta.gui.map.event.MouseOpListener; -import org.jetbrains.annotations.Nullable; - -/** - * Interface for tools that are used to manipulate maps. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public interface Tool extends MouseOpListener<GameObject, MapArchObject, Archetype, CMapViewBasic> { - - /** - * Create a view for changing the options of this tool. - * @return view for changing the options of this tool or <code>null</code> - * if this tool hasn't any options - */ - @Nullable - Component createOptionsView(); - - /** - * Get the id of this tool. Each tool needs a unique id which distinguishes - * this tool from other tools. - * @return id of this tool - */ - String getId(); - -} // interface Tool Modified: trunk/daimonin/src/daieditor/gui/map/tools/ToolPalette.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/ToolPalette.java 2008-07-09 19:25:29 UTC (rev 4269) +++ trunk/daimonin/src/daieditor/gui/map/tools/ToolPalette.java 2008-07-09 19:41:07 UTC (rev 4270) @@ -32,6 +32,7 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.map.event.MouseOpEvent; +import net.sf.gridarta.gui.map.tools.Tool; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -87,7 +88,7 @@ * mouse button is not bound to a tool. */ @Nullable - public Tool getTool(final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> event) { + public Tool<GameObject, MapArchObject, Archetype, CMapViewBasic> getTool(final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> event) { final int button = event.getButton(); final ToolSelector toolSelector; switch (button) { Modified: trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java 2008-07-09 19:25:29 UTC (rev 4269) +++ trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java 2008-07-09 19:41:07 UTC (rev 4270) @@ -38,6 +38,7 @@ import javax.swing.JToggleButton; import net.sf.gridarta.MainControl; import net.sf.gridarta.gui.ObjectChooser; +import net.sf.gridarta.gui.map.tools.Tool; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -73,11 +74,11 @@ /** The currently selected tool. */ @NotNull - private Tool selectedTool; + private Tool<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedTool; /** The tools. */ @NotNull - private final Map<String, Tool> tools = new HashMap<String, Tool>(); + private final Map<String, Tool<GameObject, MapArchObject, Archetype, CMapViewBasic>> tools = new HashMap<String, Tool<GameObject, MapArchObject, Archetype, CMapViewBasic>>(); /** Empty margin. */ private static final Insets EMPTY_MARGIN = new Insets(0, 0, 0, 0); @@ -91,7 +92,7 @@ */ public ToolSelector(@NotNull final String defaultTool, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChooser) { createUI(); - for (final Tool toolToAdd : new Tool[] {new VoidTool(), new SelectionTool(objectChooser), new DeletionTool(mainControl), new InsertionTool(mainControl, objectChooser)}) { + for (final Tool<GameObject, MapArchObject, Archetype, CMapViewBasic> toolToAdd : new Tool[] {new VoidTool(), new SelectionTool(objectChooser), new DeletionTool(mainControl), new InsertionTool(mainControl, objectChooser)}) { add(toolToAdd, toolToAdd.getId().equals(defaultTool)); } } @@ -108,7 +109,7 @@ * @param tool Tool to add */ @SuppressWarnings({"MethodOverloadsMethodOfSuperclass"}) - public void add(@NotNull final Tool tool) { + public void add(@NotNull final Tool<GameObject, MapArchObject, Archetype, CMapViewBasic> tool) { add(tool, false); } @@ -118,7 +119,7 @@ * @param selected <code>true</code> if the tool should be made the selected * tool, otherwise <code>false</code> */ - private void add(@NotNull final Tool tool, final boolean selected) { + private void add(@NotNull final Tool<GameObject, MapArchObject, Archetype, CMapViewBasic> tool, final boolean selected) { @NotNull final Action selectionAction = new SelectionAction(tool); @NotNull final JToggleButton toggleButton = new JToggleButton(selectionAction); toggleButton.setMargin(EMPTY_MARGIN); @@ -143,7 +144,7 @@ * tool doesn't provide an options view) */ @NotNull - private static Component createOptionsView(@NotNull final Tool tool) { + private static Component createOptionsView(@NotNull final Tool<GameObject, MapArchObject, Archetype, CMapViewBasic> tool) { @Nullable final Component optionsView = tool.createOptionsView(); return optionsView != null ? optionsView : new JPanel(); } @@ -154,7 +155,7 @@ * @pre the tool must be controlled by this toolselector. * @see #setSelectedTool(String) */ - public void setSelectedTool(@NotNull final Tool tool) { + public void setSelectedTool(@NotNull final Tool<GameObject, MapArchObject, Archetype, CMapViewBasic> tool) { selectedTool = tool; optionCards.show(optionsPane, tool.getId()); } @@ -177,7 +178,7 @@ * @return the currently selected tool. */ @NotNull - public Tool getSelectedTool() { + public Tool<GameObject, MapArchObject, Archetype, CMapViewBasic> getSelectedTool() { return selectedTool; } @@ -189,13 +190,13 @@ /** The tool to select with this action. */ @NotNull - private final Tool tool; + private final Tool<GameObject, MapArchObject, Archetype, CMapViewBasic> tool; /** * Create a SelectionAction. * @param tool Tool to select with this action */ - SelectionAction(@NotNull final Tool tool) { + SelectionAction(@NotNull final Tool<GameObject, MapArchObject, Archetype, CMapViewBasic> tool) { this.tool = tool; ACTION_FACTORY.initAction(false, this, tool.getId()); } Deleted: trunk/daimonin/src/daieditor/gui/map/tools/package-info.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/package-info.java 2008-07-09 19:25:29 UTC (rev 4269) +++ trunk/daimonin/src/daieditor/gui/map/tools/package-info.java 2008-07-09 19:41:07 UTC (rev 4270) @@ -1,25 +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. - */ - -/** - * The package <code>daieditor.gui.map.tools</code> handles tools for manipulating maps. - * Examples for such tools are Selection, Deletion and Insertion. - */ - -package daieditor.gui.map.tools; Copied: trunk/src/app/net/sf/gridarta/gui/map/tools/AbstractTool.java (from rev 4269, trunk/daimonin/src/daieditor/gui/map/tools/AbstractTool.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/AbstractTool.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/AbstractTool.java 2008-07-09 19:41:07 UTC (rev 4270) @@ -0,0 +1,39 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.map.tools; + +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.map.event.MouseOpAdapter; +import net.sf.gridarta.map.MapArchObject; + +/** + * Base class for tools. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +@SuppressWarnings({"AbstractClassWithOnlyOneDirectInheritor"}) +public abstract class AbstractTool<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R>> extends MouseOpAdapter<G, A, R, V> implements Tool<G, A, R, V> { + + /** Create an AbstractTool. */ + protected AbstractTool() { + } + +} // class AbstractTool Property changes on: trunk/src/app/net/sf/gridarta/gui/map/tools/AbstractTool.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Copied: trunk/src/app/net/sf/gridarta/gui/map/tools/Tool.java (from rev 4269, trunk/daimonin/src/daieditor/gui/map/tools/Tool.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/Tool.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/Tool.java 2008-07-09 19:41:07 UTC (rev 4270) @@ -0,0 +1,51 @@ +/* + * 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.map.tools; + +import java.awt.Component; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.map.event.MouseOpListener; +import net.sf.gridarta.map.MapArchObject; +import org.jetbrains.annotations.Nullable; + +/** + * Interface for tools that are used to manipulate maps. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public interface Tool<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R>> extends MouseOpListener<G, A, R, V> { + + /** + * Create a view for changing the options of this tool. + * @return view for changing the options of this tool or <code>null</code> + * if this tool hasn't any options + */ + @Nullable + Component createOptionsView(); + + /** + * Get the id of this tool. Each tool needs a unique id which distinguishes + * this tool from other tools. + * @return id of this tool + */ + String getId(); + +} // interface Tool Property changes on: trunk/src/app/net/sf/gridarta/gui/map/tools/Tool.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Copied: trunk/src/app/net/sf/gridarta/gui/map/tools/package-info.java (from rev 4269, trunk/daimonin/src/daieditor/gui/map/tools/package-info.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/package-info.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/package-info.java 2008-07-09 19:41:07 UTC (rev 4270) @@ -0,0 +1,25 @@ +/* + * 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. + */ + +/** + * This package handles tools for manipulating maps. Examples for such tools + * are Selection, Deletion and Insertion. + */ + +package net.sf.gridarta.gui.map.tools; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-09 19:57:10
|
Revision: 4271 http://gridarta.svn.sourceforge.net/gridarta/?rev=4271&view=rev Author: akirschbaum Date: 2008-07-09 12:56:06 -0700 (Wed, 09 Jul 2008) Log Message: ----------- Move BasicAbstractTool to common code base. Modified Paths: -------------- trunk/daimonin/src/daieditor/gui/map/tools/DeletionTool.java trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java trunk/daimonin/src/daieditor/gui/map/tools/SelectionTool.java trunk/daimonin/src/daieditor/gui/map/tools/VoidTool.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/map/tools/BasicAbstractTool.java Removed Paths: ------------- trunk/daimonin/src/daieditor/gui/map/tools/BasicAbstractTool.java Deleted: trunk/daimonin/src/daieditor/gui/map/tools/BasicAbstractTool.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/BasicAbstractTool.java 2008-07-09 19:41:07 UTC (rev 4270) +++ trunk/daimonin/src/daieditor/gui/map/tools/BasicAbstractTool.java 2008-07-09 19:56:06 UTC (rev 4271) @@ -1,62 +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.map.tools; - -import daieditor.gameobject.Archetype; -import daieditor.gameobject.GameObject; -import daieditor.gui.map.CMapViewBasic; -import daieditor.map.MapArchObject; -import java.awt.Component; -import net.sf.gridarta.gui.map.tools.AbstractTool; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.Nullable; - -/** - * Base class for the default provided tools. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -class BasicAbstractTool extends AbstractTool<GameObject, MapArchObject, Archetype, CMapViewBasic> { - - /** The ID of this tool. */ - @SuppressWarnings({"InstanceVariableNamingConvention"}) - @NonNls - private final String id; - - /** - * Create a BasicAbstractTool. - * @param id ID (used for {@link #getId()} as well as for the - * ActionFactory) - */ - protected BasicAbstractTool(final String id) { - this.id = id; - } - - /** {@inheritDoc} */ - @Nullable - public Component createOptionsView() { - return null; - } - - /** {@inheritDoc} */ - public String getId() { - return id; - } - -} // class BasicAbstractTool Modified: trunk/daimonin/src/daieditor/gui/map/tools/DeletionTool.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/DeletionTool.java 2008-07-09 19:41:07 UTC (rev 4270) +++ trunk/daimonin/src/daieditor/gui/map/tools/DeletionTool.java 2008-07-09 19:56:06 UTC (rev 4271) @@ -29,6 +29,7 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.gui.map.MapCursor; import net.sf.gridarta.gui.map.event.MouseOpEvent; +import net.sf.gridarta.gui.map.tools.BasicAbstractTool; import net.sf.gridarta.map.MapControl; import net.sf.gridarta.map.MapSquare; import net.sf.japi.swing.ActionFactory; @@ -40,7 +41,7 @@ * Tool for Deletion. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public class DeletionTool extends BasicAbstractTool { +public class DeletionTool extends BasicAbstractTool<GameObject, MapArchObject, Archetype, CMapViewBasic> { /** Action Factory. */ @NotNull Modified: trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java 2008-07-09 19:41:07 UTC (rev 4270) +++ trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java 2008-07-09 19:56:06 UTC (rev 4271) @@ -30,6 +30,7 @@ import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.map.MapCursor; import net.sf.gridarta.gui.map.event.MouseOpEvent; +import net.sf.gridarta.gui.map.tools.BasicAbstractTool; import net.sf.gridarta.map.MapControl; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ToggleAction; @@ -41,7 +42,7 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @todo implement insert below */ -public class InsertionTool extends BasicAbstractTool { +public class InsertionTool extends BasicAbstractTool<GameObject, MapArchObject, Archetype, CMapViewBasic> { /** Action Factory. */ @NotNull Modified: trunk/daimonin/src/daieditor/gui/map/tools/SelectionTool.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/SelectionTool.java 2008-07-09 19:41:07 UTC (rev 4270) +++ trunk/daimonin/src/daieditor/gui/map/tools/SelectionTool.java 2008-07-09 19:56:06 UTC (rev 4271) @@ -29,6 +29,7 @@ import net.sf.gridarta.gui.map.MapCursor; import net.sf.gridarta.gui.map.MapGrid; import net.sf.gridarta.gui.map.event.MouseOpEvent; +import net.sf.gridarta.gui.map.tools.BasicAbstractTool; import net.sf.gridarta.map.MapControl; import org.jetbrains.annotations.NotNull; @@ -36,7 +37,7 @@ * Tool for Selection. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public class SelectionTool extends BasicAbstractTool { +public class SelectionTool extends BasicAbstractTool<GameObject, MapArchObject, Archetype, CMapViewBasic> { /** The object chooser to update. */ @NotNull Modified: trunk/daimonin/src/daieditor/gui/map/tools/VoidTool.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/VoidTool.java 2008-07-09 19:41:07 UTC (rev 4270) +++ trunk/daimonin/src/daieditor/gui/map/tools/VoidTool.java 2008-07-09 19:56:06 UTC (rev 4271) @@ -19,12 +19,18 @@ package daieditor.gui.map.tools; +import daieditor.gameobject.Archetype; +import daieditor.gameobject.GameObject; +import daieditor.gui.map.CMapViewBasic; +import daieditor.map.MapArchObject; +import net.sf.gridarta.gui.map.tools.BasicAbstractTool; + /** * The VoidTool is a tool that does nothing. It's used as a fallback dummy tool * in case no other tool is active. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public class VoidTool extends BasicAbstractTool { +public class VoidTool extends BasicAbstractTool<GameObject, MapArchObject, Archetype, CMapViewBasic> { /** Create a VoidTool. */ public VoidTool() { Copied: trunk/src/app/net/sf/gridarta/gui/map/tools/BasicAbstractTool.java (from rev 4270, trunk/daimonin/src/daieditor/gui/map/tools/BasicAbstractTool.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/BasicAbstractTool.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/BasicAbstractTool.java 2008-07-09 19:56:06 UTC (rev 4271) @@ -0,0 +1,61 @@ +/* + * 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.map.tools; + +import java.awt.Component; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.map.MapArchObject; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.Nullable; + +/** + * Base class for the default provided tools. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class BasicAbstractTool<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R>> extends AbstractTool<G, A, R, V> { + + /** The ID of this tool. */ + @SuppressWarnings({"InstanceVariableNamingConvention"}) + @NonNls + private final String id; + + /** + * Create a BasicAbstractTool. + * @param id ID (used for {@link #getId()} as well as for the + * ActionFactory) + */ + protected BasicAbstractTool(final String id) { + this.id = id; + } + + /** {@inheritDoc} */ + @Nullable + public Component createOptionsView() { + return null; + } + + /** {@inheritDoc} */ + public String getId() { + return id; + } + +} // class BasicAbstractTool Property changes on: trunk/src/app/net/sf/gridarta/gui/map/tools/BasicAbstractTool.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-09 20:05:48
|
Revision: 4272 http://gridarta.svn.sourceforge.net/gridarta/?rev=4272&view=rev Author: akirschbaum Date: 2008-07-09 13:03:47 -0700 (Wed, 09 Jul 2008) Log Message: ----------- Move VoidTool to common code base. Modified Paths: -------------- trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/map/tools/VoidTool.java Removed Paths: ------------- trunk/daimonin/src/daieditor/gui/map/tools/VoidTool.java Modified: trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java 2008-07-09 19:56:06 UTC (rev 4271) +++ trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java 2008-07-09 20:03:47 UTC (rev 4272) @@ -39,6 +39,7 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.map.tools.Tool; +import net.sf.gridarta.gui.map.tools.VoidTool; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -92,7 +93,7 @@ */ public ToolSelector(@NotNull final String defaultTool, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChooser) { createUI(); - for (final Tool<GameObject, MapArchObject, Archetype, CMapViewBasic> toolToAdd : new Tool[] {new VoidTool(), new SelectionTool(objectChooser), new DeletionTool(mainControl), new InsertionTool(mainControl, objectChooser)}) { + for (final Tool<GameObject, MapArchObject, Archetype, CMapViewBasic> toolToAdd : new Tool[] {new VoidTool<GameObject, MapArchObject, Archetype, CMapViewBasic>(), new SelectionTool(objectChooser), new DeletionTool(mainControl), new InsertionTool(mainControl, objectChooser)}) { add(toolToAdd, toolToAdd.getId().equals(defaultTool)); } } Deleted: trunk/daimonin/src/daieditor/gui/map/tools/VoidTool.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/VoidTool.java 2008-07-09 19:56:06 UTC (rev 4271) +++ trunk/daimonin/src/daieditor/gui/map/tools/VoidTool.java 2008-07-09 20:03:47 UTC (rev 4272) @@ -1,40 +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.map.tools; - -import daieditor.gameobject.Archetype; -import daieditor.gameobject.GameObject; -import daieditor.gui.map.CMapViewBasic; -import daieditor.map.MapArchObject; -import net.sf.gridarta.gui.map.tools.BasicAbstractTool; - -/** - * The VoidTool is a tool that does nothing. It's used as a fallback dummy tool - * in case no other tool is active. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public class VoidTool extends BasicAbstractTool<GameObject, MapArchObject, Archetype, CMapViewBasic> { - - /** Create a VoidTool. */ - public VoidTool() { - super("void"); - } - -} // class VoidTool Copied: trunk/src/app/net/sf/gridarta/gui/map/tools/VoidTool.java (from rev 4271, trunk/daimonin/src/daieditor/gui/map/tools/VoidTool.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/VoidTool.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/VoidTool.java 2008-07-09 20:03:47 UTC (rev 4272) @@ -0,0 +1,39 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.map.tools; + +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.map.MapArchObject; + +/** + * The VoidTool is a tool that does nothing. It's used as a fallback dummy tool + * in case no other tool is active. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class VoidTool<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R>> extends BasicAbstractTool<G, A, R, V> { + + /** Create a VoidTool. */ + public VoidTool() { + super("void"); + } + +} // class VoidTool Property changes on: trunk/src/app/net/sf/gridarta/gui/map/tools/VoidTool.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-09 20:17:40
|
Revision: 4273 http://gridarta.svn.sourceforge.net/gridarta/?rev=4273&view=rev Author: akirschbaum Date: 2008-07-09 13:15:39 -0700 (Wed, 09 Jul 2008) Log Message: ----------- Move DeletionTool to common code base. Modified Paths: -------------- trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java Removed Paths: ------------- trunk/daimonin/src/daieditor/gui/map/tools/DeletionTool.java Deleted: trunk/daimonin/src/daieditor/gui/map/tools/DeletionTool.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/DeletionTool.java 2008-07-09 20:03:47 UTC (rev 4272) +++ trunk/daimonin/src/daieditor/gui/map/tools/DeletionTool.java 2008-07-09 20:15:39 UTC (rev 4273) @@ -1,140 +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.map.tools; - -import daieditor.gameobject.Archetype; -import daieditor.gameobject.GameObject; -import daieditor.gui.map.CMapViewBasic; -import daieditor.map.MapArchObject; -import java.awt.Component; -import java.awt.Point; -import javax.swing.JPanel; -import net.sf.gridarta.MainControl; -import net.sf.gridarta.gui.map.MapCursor; -import net.sf.gridarta.gui.map.event.MouseOpEvent; -import net.sf.gridarta.gui.map.tools.BasicAbstractTool; -import net.sf.gridarta.map.MapControl; -import net.sf.gridarta.map.MapSquare; -import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.ToggleAction; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Tool for Deletion. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public class DeletionTool extends BasicAbstractTool<GameObject, MapArchObject, Archetype, CMapViewBasic> { - - /** Action Factory. */ - @NotNull - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor.gui.map.tools"); - - /** The main control. */ - @NotNull - private final MainControl<GameObject, ?, ?, ?> mainControl; - - /** The ToggleAction for toggling the deleteBelow status. */ - private final ToggleAction deleteBelowAction = (ToggleAction) ACTION_FACTORY.createToggle(true, "deleteBelow", this); - - /** The position for deletion. */ - private boolean deleteBelow; - - /** - * Create a DeletionTool. - * @param mainControl the main control - */ - public DeletionTool(@NotNull final MainControl<GameObject, ?, ?, ?> mainControl) { - super("deletion"); - this.mainControl = mainControl; - } - - /** {@inheritDoc} */ - @Override - public void pressed(final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e) { - final Point mapLoc = e.getMapLocation(); - final MapCursor mapCursor = e.getMapCursor(); - final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = e.getMapControl(); - mapCursor.setLocationSafe(mapLoc); - if (mapLoc != null && mapCursor.isActive()) { - // delete the topmost arch (matching the view settings) on that square and redraw the map - deleteArch(mapLoc, mapControl); - } - } - - /** {@inheritDoc} */ - @Override - public void dragged(final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e) { - final Point mapLoc = e.getMapLocation(); - final MapCursor mapCursor = e.getMapCursor(); - final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = e.getMapControl(); - if (mapCursor.setLocationSafe(mapLoc)) { - // delete the topmost arch (matching the view settings) on that square and redraw the map - deleteArch(mapLoc, mapControl); - } - } - - /** - * Delete an arch. - * @param mapLoc position to delete topmost arch at - * @param mapControl map control of map to delete arch from - */ - private void deleteArch(final Point mapLoc, final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl) { - GameObject delArch = null; - final MapSquare<GameObject, MapArchObject, Archetype> mapSquare = mapControl.getMapModel().getMapSquare(mapLoc); - for (final GameObject searchArch : deleteBelow ? mapSquare : mapSquare.reverse()) { - if (mainControl.isEditType(searchArch)) { - delArch = searchArch.getHead(); - break; - } - } - if (delArch != null) { - mapSquare.getModel().beginTransaction("Delete Object"); - mapSquare.getModel().deleteMapArch(delArch, true); - mapSquare.getModel().endTransaction(); - } - } - - /** {@inheritDoc} */ - @Override - @Nullable - public Component createOptionsView() { - final JPanel optionsPanel = new JPanel(); - optionsPanel.add(deleteBelowAction.createCheckBox()); - return optionsPanel; - } - - /** - * Returns the position for deletion. - * @return the position for deletion. - */ - public boolean isDeleteBelow() { - return deleteBelow; - } - - /** - * Sets the position for deletion. - * @param deleteBelow the position for deletion. - */ - public void setDeleteBelow(final boolean deleteBelow) { - this.deleteBelow = deleteBelow; - } - -} // class DeletionTool Modified: trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java 2008-07-09 20:03:47 UTC (rev 4272) +++ trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java 2008-07-09 20:15:39 UTC (rev 4273) @@ -38,6 +38,7 @@ import javax.swing.JToggleButton; import net.sf.gridarta.MainControl; import net.sf.gridarta.gui.ObjectChooser; +import net.sf.gridarta.gui.map.tools.DeletionTool; import net.sf.gridarta.gui.map.tools.Tool; import net.sf.gridarta.gui.map.tools.VoidTool; import net.sf.japi.swing.ActionFactory; @@ -93,7 +94,7 @@ */ public ToolSelector(@NotNull final String defaultTool, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChooser) { createUI(); - for (final Tool<GameObject, MapArchObject, Archetype, CMapViewBasic> toolToAdd : new Tool[] {new VoidTool<GameObject, MapArchObject, Archetype, CMapViewBasic>(), new SelectionTool(objectChooser), new DeletionTool(mainControl), new InsertionTool(mainControl, objectChooser)}) { + for (final Tool<GameObject, MapArchObject, Archetype, CMapViewBasic> toolToAdd : new Tool[] {new VoidTool<GameObject, MapArchObject, Archetype, CMapViewBasic>(), new SelectionTool(objectChooser), new DeletionTool<GameObject, MapArchObject, Archetype, CMapViewBasic>(mainControl), new InsertionTool(mainControl, objectChooser)}) { add(toolToAdd, toolToAdd.getId().equals(defaultTool)); } } Copied: trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java (from rev 4271, trunk/daimonin/src/daieditor/gui/map/tools/DeletionTool.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java 2008-07-09 20:15:39 UTC (rev 4273) @@ -0,0 +1,139 @@ +/* + * 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.map.tools; + +import java.awt.Component; +import java.awt.Point; +import javax.swing.JPanel; +import net.sf.gridarta.MainControl; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.map.MapCursor; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.map.event.MouseOpEvent; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.map.MapSquare; +import net.sf.japi.swing.ActionFactory; +import net.sf.japi.swing.ToggleAction; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Tool for Deletion. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class DeletionTool<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R>> extends BasicAbstractTool<G, A, R, V> { + + /** Action Factory. */ + @NotNull + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor.gui.map.tools"); + + /** The main control. */ + @NotNull + private final MainControl<G, ?, ?, ?> mainControl; + + /** The ToggleAction for toggling the deleteBelow status. */ + private final ToggleAction deleteBelowAction = (ToggleAction) ACTION_FACTORY.createToggle(true, "deleteBelow", this); + + /** The position for deletion. */ + private boolean deleteBelow; + + /** + * Create a DeletionTool. + * @param mainControl the main control + */ + public DeletionTool(@NotNull final MainControl<G, ?, ?, ?> mainControl) { + super("deletion"); + this.mainControl = mainControl; + } + + /** {@inheritDoc} */ + @Override + public void pressed(final MouseOpEvent<G, A, R, V> e) { + final Point mapLoc = e.getMapLocation(); + final MapCursor mapCursor = e.getMapCursor(); + final MapControl<G, A, R, V> mapControl = e.getMapControl(); + mapCursor.setLocationSafe(mapLoc); + if (mapLoc != null && mapCursor.isActive()) { + // delete the topmost arch (matching the view settings) on that square and redraw the map + deleteArch(mapLoc, mapControl); + } + } + + /** {@inheritDoc} */ + @Override + public void dragged(final MouseOpEvent<G, A, R, V> e) { + final Point mapLoc = e.getMapLocation(); + final MapCursor mapCursor = e.getMapCursor(); + final MapControl<G, A, R, V> mapControl = e.getMapControl(); + if (mapCursor.setLocationSafe(mapLoc)) { + // delete the topmost arch (matching the view settings) on that square and redraw the map + deleteArch(mapLoc, mapControl); + } + } + + /** + * Delete an arch. + * @param mapLoc position to delete topmost arch at + * @param mapControl map control of map to delete arch from + */ + private void deleteArch(final Point mapLoc, final MapControl<G, A, R, V> mapControl) { + G delArch = null; + final MapSquare<G, A, R> mapSquare = mapControl.getMapModel().getMapSquare(mapLoc); + for (final G searchArch : deleteBelow ? mapSquare : mapSquare.reverse()) { + if (mainControl.isEditType(searchArch)) { + delArch = searchArch.getHead(); + break; + } + } + if (delArch != null) { + mapSquare.getModel().beginTransaction("Delete Object"); + mapSquare.getModel().deleteMapArch(delArch, true); + mapSquare.getModel().endTransaction(); + } + } + + /** {@inheritDoc} */ + @Override + @Nullable + public Component createOptionsView() { + final JPanel optionsPanel = new JPanel(); + optionsPanel.add(deleteBelowAction.createCheckBox()); + return optionsPanel; + } + + /** + * Returns the position for deletion. + * @return the position for deletion. + */ + public boolean isDeleteBelow() { + return deleteBelow; + } + + /** + * Sets the position for deletion. + * @param deleteBelow the position for deletion. + */ + public void setDeleteBelow(final boolean deleteBelow) { + this.deleteBelow = deleteBelow; + } + +} // class DeletionTool Property changes on: trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-09 20:26:32
|
Revision: 4274 http://gridarta.svn.sourceforge.net/gridarta/?rev=4274&view=rev Author: akirschbaum Date: 2008-07-09 13:25:50 -0700 (Wed, 09 Jul 2008) Log Message: ----------- Move SelectionTool to common code base. Modified Paths: -------------- trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java Removed Paths: ------------- trunk/daimonin/src/daieditor/gui/map/tools/SelectionTool.java Deleted: trunk/daimonin/src/daieditor/gui/map/tools/SelectionTool.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/SelectionTool.java 2008-07-09 20:15:39 UTC (rev 4273) +++ trunk/daimonin/src/daieditor/gui/map/tools/SelectionTool.java 2008-07-09 20:25:50 UTC (rev 4274) @@ -1,106 +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.map.tools; - -import daieditor.gameobject.Archetype; -import daieditor.gameobject.GameObject; -import daieditor.gui.map.CMapViewBasic; -import daieditor.map.MapArchObject; -import java.awt.Point; -import java.awt.event.InputEvent; -import net.sf.gridarta.gui.ObjectChooser; -import net.sf.gridarta.gui.map.MapCursor; -import net.sf.gridarta.gui.map.MapGrid; -import net.sf.gridarta.gui.map.event.MouseOpEvent; -import net.sf.gridarta.gui.map.tools.BasicAbstractTool; -import net.sf.gridarta.map.MapControl; -import org.jetbrains.annotations.NotNull; - -/** - * Tool for Selection. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public class SelectionTool extends BasicAbstractTool<GameObject, MapArchObject, Archetype, CMapViewBasic> { - - /** The object chooser to update. */ - @NotNull - private final ObjectChooser<GameObject, ?, ?, ?> objectChooser; - - /** - * Create a BasicAbstractTool. - * @param objectChooser the object chooser to update - */ - public SelectionTool(@NotNull final ObjectChooser<GameObject, ?, ?, ?> objectChooser) { - super("selection"); - this.objectChooser = objectChooser; - } - - /** {@inheritDoc} */ - @Override - public void pressed(final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e) { - final Point mapLoc = e.getMapLocation(); - final int mod = e.getModifiers(); - final MapCursor mapCursor = e.getMapCursor(); - final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = e.getMapControl(); - // left mouse button: select tiles - // Throw away old selection if neither SHIFT nor CTRL is not pressed - if ((mod & (InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)) == 0) { - mapCursor.deactivate(); - } - mapCursor.beginTransaction(); - mapCursor.setLocation(mapLoc); - mapCursor.dragStart(); - if (mapCursor.isActive() && mapControl.isPickmap()) { - // an arch of a pickmap was selected - objectChooser.showObjectChooserQuickObject(mapControl.getMapModel().getMapSquare(mapLoc).getFirst()); - } - mapCursor.endTransaction(); - // Change edit menu if there was a selection before and has gone or the other way around - } - - /** {@inheritDoc} */ - @Override - public void dragged(final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e) { - e.getMapCursor().dragTo(e.getMapLocation()); - } - - /** {@inheritDoc} */ - @Override - public void released(final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e) { - final MapCursor mapCursor = e.getMapCursor(); - final int modifiers = e.getModifiers(); - if (mapCursor.isOnGrid(e.getMapLocation())) { - if ((modifiers & InputEvent.SHIFT_DOWN_MASK) != 0) { - if ((modifiers & InputEvent.CTRL_DOWN_MASK) != 0) { - mapCursor.dragSelect(MapGrid.SelectionMode.FLIP); - } else { - mapCursor.dragSelect(MapGrid.SelectionMode.ADD); - } - } else if ((modifiers & InputEvent.CTRL_DOWN_MASK) != 0) { - mapCursor.dragSelect(MapGrid.SelectionMode.SUB); - } else { - mapCursor.dragSelect(MapGrid.SelectionMode.ADD); - } - } else { - mapCursor.dragRelease(); - } - } - -} // class SelectionTool Modified: trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java 2008-07-09 20:15:39 UTC (rev 4273) +++ trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java 2008-07-09 20:25:50 UTC (rev 4274) @@ -39,6 +39,7 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.map.tools.DeletionTool; +import net.sf.gridarta.gui.map.tools.SelectionTool; import net.sf.gridarta.gui.map.tools.Tool; import net.sf.gridarta.gui.map.tools.VoidTool; import net.sf.japi.swing.ActionFactory; @@ -94,7 +95,7 @@ */ public ToolSelector(@NotNull final String defaultTool, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChooser) { createUI(); - for (final Tool<GameObject, MapArchObject, Archetype, CMapViewBasic> toolToAdd : new Tool[] {new VoidTool<GameObject, MapArchObject, Archetype, CMapViewBasic>(), new SelectionTool(objectChooser), new DeletionTool<GameObject, MapArchObject, Archetype, CMapViewBasic>(mainControl), new InsertionTool(mainControl, objectChooser)}) { + for (final Tool<GameObject, MapArchObject, Archetype, CMapViewBasic> toolToAdd : new Tool[] {new VoidTool<GameObject, MapArchObject, Archetype, CMapViewBasic>(), new SelectionTool<GameObject, MapArchObject, Archetype, CMapViewBasic>(objectChooser), new DeletionTool<GameObject, MapArchObject, Archetype, CMapViewBasic>(mainControl), new InsertionTool(mainControl, objectChooser)}) { add(toolToAdd, toolToAdd.getId().equals(defaultTool)); } } Copied: trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java (from rev 4273, trunk/daimonin/src/daieditor/gui/map/tools/SelectionTool.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java 2008-07-09 20:25:50 UTC (rev 4274) @@ -0,0 +1,105 @@ +/* + * 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.map.tools; + +import java.awt.Point; +import java.awt.event.InputEvent; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.ObjectChooser; +import net.sf.gridarta.gui.map.MapCursor; +import net.sf.gridarta.gui.map.MapGrid; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.map.event.MouseOpEvent; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapControl; +import org.jetbrains.annotations.NotNull; + +/** + * Tool for Selection. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class SelectionTool<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R>> extends BasicAbstractTool<G, A, R, V> { + + /** The object chooser to update. */ + @NotNull + private final ObjectChooser<G, ?, ?, ?> objectChooser; + + /** + * Create a BasicAbstractTool. + * @param objectChooser the object chooser to update + */ + public SelectionTool(@NotNull final ObjectChooser<G, ?, ?, ?> objectChooser) { + super("selection"); + this.objectChooser = objectChooser; + } + + /** {@inheritDoc} */ + @Override + public void pressed(final MouseOpEvent<G, A, R, V> e) { + final Point mapLoc = e.getMapLocation(); + final int mod = e.getModifiers(); + final MapCursor mapCursor = e.getMapCursor(); + final MapControl<G, A, R, V> mapControl = e.getMapControl(); + // left mouse button: select tiles + // Throw away old selection if neither SHIFT nor CTRL is not pressed + if ((mod & (InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)) == 0) { + mapCursor.deactivate(); + } + mapCursor.beginTransaction(); + mapCursor.setLocation(mapLoc); + mapCursor.dragStart(); + if (mapCursor.isActive() && mapControl.isPickmap()) { + // an arch of a pickmap was selected + objectChooser.showObjectChooserQuickObject(mapControl.getMapModel().getMapSquare(mapLoc).getFirst()); + } + mapCursor.endTransaction(); + // Change edit menu if there was a selection before and has gone or the other way around + } + + /** {@inheritDoc} */ + @Override + public void dragged(final MouseOpEvent<G, A, R, V> e) { + e.getMapCursor().dragTo(e.getMapLocation()); + } + + /** {@inheritDoc} */ + @Override + public void released(final MouseOpEvent<G, A, R, V> e) { + final MapCursor mapCursor = e.getMapCursor(); + final int modifiers = e.getModifiers(); + if (mapCursor.isOnGrid(e.getMapLocation())) { + if ((modifiers & InputEvent.SHIFT_DOWN_MASK) != 0) { + if ((modifiers & InputEvent.CTRL_DOWN_MASK) != 0) { + mapCursor.dragSelect(MapGrid.SelectionMode.FLIP); + } else { + mapCursor.dragSelect(MapGrid.SelectionMode.ADD); + } + } else if ((modifiers & InputEvent.CTRL_DOWN_MASK) != 0) { + mapCursor.dragSelect(MapGrid.SelectionMode.SUB); + } else { + mapCursor.dragSelect(MapGrid.SelectionMode.ADD); + } + } else { + mapCursor.dragRelease(); + } + } + +} // class SelectionTool Property changes on: trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-09 20:35:35
|
Revision: 4275 http://gridarta.svn.sourceforge.net/gridarta/?rev=4275&view=rev Author: akirschbaum Date: 2008-07-09 13:34:18 -0700 (Wed, 09 Jul 2008) Log Message: ----------- Move InsertionTool to common code base. Modified Paths: -------------- trunk/daimonin/src/daieditor/gui/map/tools/ToolPalette.java trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java Removed Paths: ------------- trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java Deleted: trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java 2008-07-09 20:25:50 UTC (rev 4274) +++ trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java 2008-07-09 20:34:18 UTC (rev 4275) @@ -1,134 +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.map.tools; - -import daieditor.gameobject.Archetype; -import daieditor.gameobject.GameObject; -import daieditor.gui.map.CMapViewBasic; -import daieditor.map.MapArchObject; -import java.awt.Component; -import java.awt.Point; -import javax.swing.JPanel; -import net.sf.gridarta.MainControl; -import net.sf.gridarta.gui.ObjectChooser; -import net.sf.gridarta.gui.map.MapCursor; -import net.sf.gridarta.gui.map.event.MouseOpEvent; -import net.sf.gridarta.gui.map.tools.BasicAbstractTool; -import net.sf.gridarta.map.MapControl; -import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.ToggleAction; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * MouseOpListener for insertion. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @todo implement insert below - */ -public class InsertionTool extends BasicAbstractTool<GameObject, MapArchObject, Archetype, CMapViewBasic> { - - /** Action Factory. */ - @NotNull - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor.gui.map.tools"); - - /** The ToggleAction for toggling the insertBelow status. */ - @SuppressWarnings({"UnusedDeclaration"}) - private final ToggleAction insertBelowAction = (ToggleAction) ACTION_FACTORY.createToggle(true, "insertBelow", this); - - /** The main control. */ - @NotNull - private final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl; - - /** The ObjectChooser to use. */ - @NotNull - private final ObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChooser; - - /** The position for insertion. */ - private boolean insertBelow; - - /** - * Create a BasicAbstractTool. - * @param mainControl The main control. - * @param objectChooser the ObjectChooser to use - */ - public InsertionTool(@NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChooser) { - super("insertion"); - this.mainControl = mainControl; - this.objectChooser = objectChooser; - } - - /** {@inheritDoc} */ - @Override - public void pressed(final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e) { - final Point p = e.getMapLocation(); - final MapCursor mapCursor = e.getMapCursor(); - final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = e.getMapControl(); - if (p != null) { - mapControl.getMapModel().beginTransaction("Insert Object"); - final GameObject insertedObject = objectChooser.insertSelectedObject(mapControl, p, true); - if (!mapControl.isPickmap()) { - mapCursor.setLocation(p); - } - mapControl.getMapModel().endTransaction(); - mainControl.getSelectedSquareControl().getSelectedSquareView().setSelectedGameObject(insertedObject); - } - } - - /** {@inheritDoc} */ - @Override - public void dragged(final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> e) { - final Point p = e.getMapLocation(); - final MapCursor mapCursor = e.getMapCursor(); - final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = e.getMapControl(); - if (!mapControl.isPickmap() && mapCursor.setLocationSafe(p)) { - mapControl.getMapModel().beginTransaction("Insert Object"); - final GameObject insertedObject = objectChooser.insertSelectedObject(mapControl, p, false); - mapControl.getMapModel().endTransaction(); - mainControl.getSelectedSquareControl().getSelectedSquareView().setSelectedGameObject(insertedObject); - } - } - - /** {@inheritDoc} */ - @Override - @Nullable - public Component createOptionsView() { - final JPanel optionsPanel = new JPanel(); - // commented to hide it because currently inserting below doesn't work. - //optionsPanel.add(insertBelowAction.createCheckBox()); - return optionsPanel; - } - - /** - * Returns the position for insertion. - * @return the position for insertion. - */ - public boolean isInsertBelow() { - return insertBelow; - } - - /** - * Sets the position for insertion. - * @param insertBelow the position for insertion. - */ - public void setInsertBelow(final boolean insertBelow) { - this.insertBelow = insertBelow; - } - -} // class InsertMouseOperation Modified: trunk/daimonin/src/daieditor/gui/map/tools/ToolPalette.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/ToolPalette.java 2008-07-09 20:25:50 UTC (rev 4274) +++ trunk/daimonin/src/daieditor/gui/map/tools/ToolPalette.java 2008-07-09 20:34:18 UTC (rev 4275) @@ -65,7 +65,7 @@ /** * Create a ToolPalette. * @param mainControl MainControl to use (required for {@link - * InsertionTool}). + * net.sf.gridarta.gui.map.tools.InsertionTool}). * @param objectChooser the object chooser to use */ public ToolPalette(@NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChooser) { Modified: trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java 2008-07-09 20:25:50 UTC (rev 4274) +++ trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java 2008-07-09 20:34:18 UTC (rev 4275) @@ -39,6 +39,7 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.map.tools.DeletionTool; +import net.sf.gridarta.gui.map.tools.InsertionTool; import net.sf.gridarta.gui.map.tools.SelectionTool; import net.sf.gridarta.gui.map.tools.Tool; import net.sf.gridarta.gui.map.tools.VoidTool; @@ -95,7 +96,7 @@ */ public ToolSelector(@NotNull final String defaultTool, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChooser) { createUI(); - for (final Tool<GameObject, MapArchObject, Archetype, CMapViewBasic> toolToAdd : new Tool[] {new VoidTool<GameObject, MapArchObject, Archetype, CMapViewBasic>(), new SelectionTool<GameObject, MapArchObject, Archetype, CMapViewBasic>(objectChooser), new DeletionTool<GameObject, MapArchObject, Archetype, CMapViewBasic>(mainControl), new InsertionTool(mainControl, objectChooser)}) { + for (final Tool<GameObject, MapArchObject, Archetype, CMapViewBasic> toolToAdd : new Tool[] {new VoidTool<GameObject, MapArchObject, Archetype, CMapViewBasic>(), new SelectionTool<GameObject, MapArchObject, Archetype, CMapViewBasic>(objectChooser), new DeletionTool<GameObject, MapArchObject, Archetype, CMapViewBasic>(mainControl), new InsertionTool<GameObject, MapArchObject, Archetype, CMapViewBasic>(mainControl, objectChooser)}) { add(toolToAdd, toolToAdd.getId().equals(defaultTool)); } } Copied: trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java (from rev 4274, trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java 2008-07-09 20:34:18 UTC (rev 4275) @@ -0,0 +1,133 @@ +/* + * 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.map.tools; + +import java.awt.Component; +import java.awt.Point; +import javax.swing.JPanel; +import net.sf.gridarta.MainControl; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.ObjectChooser; +import net.sf.gridarta.gui.map.MapCursor; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.map.event.MouseOpEvent; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapControl; +import net.sf.japi.swing.ActionFactory; +import net.sf.japi.swing.ToggleAction; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * MouseOpListener for insertion. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @todo implement insert below + */ +public class InsertionTool<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R>> extends BasicAbstractTool<G, A, R, V> { + + /** Action Factory. */ + @NotNull + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor.gui.map.tools"); + + /** The ToggleAction for toggling the insertBelow status. */ + @SuppressWarnings({"UnusedDeclaration"}) + private final ToggleAction insertBelowAction = (ToggleAction) ACTION_FACTORY.createToggle(true, "insertBelow", this); + + /** The main control. */ + @NotNull + private final MainControl<G, A, R, V> mainControl; + + /** The ObjectChooser to use. */ + @NotNull + private final ObjectChooser<G, A, R, V> objectChooser; + + /** The position for insertion. */ + private boolean insertBelow; + + /** + * Create a BasicAbstractTool. + * @param mainControl The main control. + * @param objectChooser the ObjectChooser to use + */ + public InsertionTool(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ObjectChooser<G, A, R, V> objectChooser) { + super("insertion"); + this.mainControl = mainControl; + this.objectChooser = objectChooser; + } + + /** {@inheritDoc} */ + @Override + public void pressed(final MouseOpEvent<G, A, R, V> e) { + final Point p = e.getMapLocation(); + final MapCursor mapCursor = e.getMapCursor(); + final MapControl<G, A, R, V> mapControl = e.getMapControl(); + if (p != null) { + mapControl.getMapModel().beginTransaction("Insert Object"); + final G insertedObject = objectChooser.insertSelectedObject(mapControl, p, true); + if (!mapControl.isPickmap()) { + mapCursor.setLocation(p); + } + mapControl.getMapModel().endTransaction(); + mainControl.getSelectedSquareControl().getSelectedSquareView().setSelectedGameObject(insertedObject); + } + } + + /** {@inheritDoc} */ + @Override + public void dragged(final MouseOpEvent<G, A, R, V> e) { + final Point p = e.getMapLocation(); + final MapCursor mapCursor = e.getMapCursor(); + final MapControl<G, A, R, V> mapControl = e.getMapControl(); + if (!mapControl.isPickmap() && mapCursor.setLocationSafe(p)) { + mapControl.getMapModel().beginTransaction("Insert Object"); + final G insertedObject = objectChooser.insertSelectedObject(mapControl, p, false); + mapControl.getMapModel().endTransaction(); + mainControl.getSelectedSquareControl().getSelectedSquareView().setSelectedGameObject(insertedObject); + } + } + + /** {@inheritDoc} */ + @Override + @Nullable + public Component createOptionsView() { + final JPanel optionsPanel = new JPanel(); + // commented to hide it because currently inserting below doesn't work. + //optionsPanel.add(insertBelowAction.createCheckBox()); + return optionsPanel; + } + + /** + * Returns the position for insertion. + * @return the position for insertion. + */ + public boolean isInsertBelow() { + return insertBelow; + } + + /** + * Sets the position for insertion. + * @param insertBelow the position for insertion. + */ + public void setInsertBelow(final boolean insertBelow) { + this.insertBelow = insertBelow; + } + +} // class InsertMouseOperation Property changes on: trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-09 20:45:00
|
Revision: 4276 http://gridarta.svn.sourceforge.net/gridarta/?rev=4276&view=rev Author: akirschbaum Date: 2008-07-09 13:43:42 -0700 (Wed, 09 Jul 2008) Log Message: ----------- Move ToolSelector to common code base. Modified Paths: -------------- trunk/daimonin/src/daieditor/gui/map/tools/ToolPalette.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/map/tools/ToolSelector.java Removed Paths: ------------- trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java Modified: trunk/daimonin/src/daieditor/gui/map/tools/ToolPalette.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/ToolPalette.java 2008-07-09 20:34:18 UTC (rev 4275) +++ trunk/daimonin/src/daieditor/gui/map/tools/ToolPalette.java 2008-07-09 20:43:42 UTC (rev 4276) @@ -33,6 +33,7 @@ import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.map.event.MouseOpEvent; import net.sf.gridarta.gui.map.tools.Tool; +import net.sf.gridarta.gui.map.tools.ToolSelector; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -54,13 +55,13 @@ private final JTabbedPane mouseTabs = new JTabbedPane(); /** The ToolSelector for lmb. */ - private final ToolSelector lmbSelector; + private final ToolSelector<GameObject, MapArchObject, Archetype, CMapViewBasic> lmbSelector; /** The ToolSelector for mmb. */ - private final ToolSelector mmbSelector; + private final ToolSelector<GameObject, MapArchObject, Archetype, CMapViewBasic> mmbSelector; /** The ToolSelector for rmb. */ - private final ToolSelector rmbSelector; + private final ToolSelector<GameObject, MapArchObject, Archetype, CMapViewBasic> rmbSelector; /** * Create a ToolPalette. @@ -70,9 +71,9 @@ */ public ToolPalette(@NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChooser) { super(new BorderLayout()); - lmbSelector = new ToolSelector("selection", mainControl, objectChooser); - mmbSelector = new ToolSelector("deletion", mainControl, objectChooser); - rmbSelector = new ToolSelector("insertion", mainControl, objectChooser); + lmbSelector = new ToolSelector<GameObject, MapArchObject, Archetype, CMapViewBasic>("selection", mainControl, objectChooser); + mmbSelector = new ToolSelector<GameObject, MapArchObject, Archetype, CMapViewBasic>("deletion", mainControl, objectChooser); + rmbSelector = new ToolSelector<GameObject, MapArchObject, Archetype, CMapViewBasic>("insertion", mainControl, objectChooser); add(new JLabel(ACTION_FACTORY.getString("mouse")), BorderLayout.NORTH); mouseTabs.add(ACTION_FACTORY.getString("left"), lmbSelector); mouseTabs.add(ACTION_FACTORY.getString("middle"), mmbSelector); @@ -90,7 +91,7 @@ @Nullable public Tool<GameObject, MapArchObject, Archetype, CMapViewBasic> getTool(final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> event) { final int button = event.getButton(); - final ToolSelector toolSelector; + final ToolSelector<GameObject, MapArchObject, Archetype, CMapViewBasic> toolSelector; switch (button) { case MouseEvent.BUTTON1: toolSelector = lmbSelector; Deleted: trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java 2008-07-09 20:34:18 UTC (rev 4275) +++ trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java 2008-07-09 20:43:42 UTC (rev 4276) @@ -1,215 +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.map.tools; - -import daieditor.gameobject.Archetype; -import daieditor.gameobject.GameObject; -import daieditor.gui.map.CMapViewBasic; -import daieditor.map.MapArchObject; -import java.awt.BorderLayout; -import java.awt.CardLayout; -import java.awt.Component; -import java.awt.FlowLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.util.HashMap; -import java.util.Map; -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.ButtonGroup; -import javax.swing.JPanel; -import javax.swing.JToggleButton; -import net.sf.gridarta.MainControl; -import net.sf.gridarta.gui.ObjectChooser; -import net.sf.gridarta.gui.map.tools.DeletionTool; -import net.sf.gridarta.gui.map.tools.InsertionTool; -import net.sf.gridarta.gui.map.tools.SelectionTool; -import net.sf.gridarta.gui.map.tools.Tool; -import net.sf.gridarta.gui.map.tools.VoidTool; -import net.sf.japi.swing.ActionFactory; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * User interface for selecting a tool and displaying its options. Note: A - * ToolSelector automatically has always at least one Tool, the VoidTool. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public final class ToolSelector extends JPanel { - - /** The serial version UID. */ - private static final long serialVersionUID = 1; - - /** The Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor.gui.map.tools"); - - /** The pane with the selections. */ - @NotNull - private final JPanel selectionPane = new JPanel(new FlowLayout()); - - /** The CardLayout for the pane that shows a tool's options. */ - @NotNull - private final CardLayout optionCards = new CardLayout(); - - /** The ButtonGroup for the toggle buttons. */ - @NotNull - private final ButtonGroup selectionButtonGroup = new ButtonGroup(); - - /** The pane with the options of a tool. */ - @NotNull - private final JPanel optionsPane = new JPanel(optionCards); - - /** The currently selected tool. */ - @NotNull - private Tool<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedTool; - - /** The tools. */ - @NotNull - private final Map<String, Tool<GameObject, MapArchObject, Archetype, CMapViewBasic>> tools = new HashMap<String, Tool<GameObject, MapArchObject, Archetype, CMapViewBasic>>(); - - /** Empty margin. */ - private static final Insets EMPTY_MARGIN = new Insets(0, 0, 0, 0); - - /** - * Create a ToolSelector component. - * @param defaultTool name of the tool that should be selected by default - * @param mainControl MainControl to use (required for {@link - * InsertionTool}). - * @param objectChooser the object chooser to use - */ - public ToolSelector(@NotNull final String defaultTool, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChooser) { - createUI(); - for (final Tool<GameObject, MapArchObject, Archetype, CMapViewBasic> toolToAdd : new Tool[] {new VoidTool<GameObject, MapArchObject, Archetype, CMapViewBasic>(), new SelectionTool<GameObject, MapArchObject, Archetype, CMapViewBasic>(objectChooser), new DeletionTool<GameObject, MapArchObject, Archetype, CMapViewBasic>(mainControl), new InsertionTool<GameObject, MapArchObject, Archetype, CMapViewBasic>(mainControl, objectChooser)}) { - add(toolToAdd, toolToAdd.getId().equals(defaultTool)); - } - } - - /** Create the user interface elements of the ToolSelector. */ - private void createUI() { - setLayout(new BorderLayout()); - add(selectionPane, BorderLayout.NORTH); - add(optionsPane, BorderLayout.CENTER); - } - - /** - * Add a tool to this tool selector. - * @param tool Tool to add - */ - @SuppressWarnings({"MethodOverloadsMethodOfSuperclass"}) - public void add(@NotNull final Tool<GameObject, MapArchObject, Archetype, CMapViewBasic> tool) { - add(tool, false); - } - - /** - * Add a tool to this tool selector. - * @param tool Tool to add - * @param selected <code>true</code> if the tool should be made the selected - * tool, otherwise <code>false</code> - */ - private void add(@NotNull final Tool<GameObject, MapArchObject, Archetype, CMapViewBasic> tool, final boolean selected) { - @NotNull final Action selectionAction = new SelectionAction(tool); - @NotNull final JToggleButton toggleButton = new JToggleButton(selectionAction); - toggleButton.setMargin(EMPTY_MARGIN); - @NotNull final Component optionsView = createOptionsView(tool); - selectionButtonGroup.add(toggleButton); - selectionPane.add(toggleButton); - optionsPane.add(optionsView, tool.getId()); - toggleButton.setSelected(selected); - tools.put(tool.getId(), tool); - if (selected) { - selectedTool = tool; - optionCards.show(optionsPane, tool.getId()); - } - } - - /** - * Create the options view for a tool. This method is a delegate to {@link - * Tool#createOptionsView()} but will provide a fallback if the tool doesn't - * provide tweaking its options. - * @param tool Tool to create options view for - * @return options view (the tool's options view or a dummy fallback if the - * tool doesn't provide an options view) - */ - @NotNull - private static Component createOptionsView(@NotNull final Tool<GameObject, MapArchObject, Archetype, CMapViewBasic> tool) { - @Nullable final Component optionsView = tool.createOptionsView(); - return optionsView != null ? optionsView : new JPanel(); - } - - /** - * Make a tool the currently selected tool to edit its options. - * @param tool Tool to select - * @pre the tool must be controlled by this toolselector. - * @see #setSelectedTool(String) - */ - public void setSelectedTool(@NotNull final Tool<GameObject, MapArchObject, Archetype, CMapViewBasic> tool) { - selectedTool = tool; - optionCards.show(optionsPane, tool.getId()); - } - - /** - * Make a tool the currently selected tool to edit its options. This method - * exists to allow programs to store the currently selected tool in - * preferences and restore it after startup. - * @param id ID of tool to select - * @pre the tool must be controlled by this toolselector. - * @see #setSelectedTool(Tool) - * @see Tool#getId() - */ - public void setSelectedTool(@NotNull final String id) { - setSelectedTool(tools.get(id)); - } - - /** - * Get the tool that is currently selected. - * @return the currently selected tool. - */ - @NotNull - public Tool<GameObject, MapArchObject, Archetype, CMapViewBasic> getSelectedTool() { - return selectedTool; - } - - /** Action for selecting a tool. */ - private final class SelectionAction extends AbstractAction { - - /** The serial version UID. */ - private static final long serialVersionUID = 1; - - /** The tool to select with this action. */ - @NotNull - private final Tool<GameObject, MapArchObject, Archetype, CMapViewBasic> tool; - - /** - * Create a SelectionAction. - * @param tool Tool to select with this action - */ - SelectionAction(@NotNull final Tool<GameObject, MapArchObject, Archetype, CMapViewBasic> tool) { - this.tool = tool; - ACTION_FACTORY.initAction(false, this, tool.getId()); - } - - /** {@inheritDoc} */ - public void actionPerformed(@NotNull final ActionEvent e) { - setSelectedTool(tool); - } - - } // class SelectionAction - -} // class ToolSelector Copied: trunk/src/app/net/sf/gridarta/gui/map/tools/ToolSelector.java (from rev 4275, trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/ToolSelector.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/ToolSelector.java 2008-07-09 20:43:42 UTC (rev 4276) @@ -0,0 +1,210 @@ +/* + * 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.map.tools; + +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Component; +import java.awt.FlowLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.util.HashMap; +import java.util.Map; +import javax.swing.AbstractAction; +import javax.swing.Action; +import javax.swing.ButtonGroup; +import javax.swing.JPanel; +import javax.swing.JToggleButton; +import net.sf.gridarta.MainControl; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.ObjectChooser; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.map.MapArchObject; +import net.sf.japi.swing.ActionFactory; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * User interface for selecting a tool and displaying its options. Note: A + * ToolSelector automatically has always at least one Tool, the VoidTool. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public final class ToolSelector<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R>> extends JPanel { + + /** The serial version UID. */ + private static final long serialVersionUID = 1; + + /** The Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor.gui.map.tools"); + + /** The pane with the selections. */ + @NotNull + private final JPanel selectionPane = new JPanel(new FlowLayout()); + + /** The CardLayout for the pane that shows a tool's options. */ + @NotNull + private final CardLayout optionCards = new CardLayout(); + + /** The ButtonGroup for the toggle buttons. */ + @NotNull + private final ButtonGroup selectionButtonGroup = new ButtonGroup(); + + /** The pane with the options of a tool. */ + @NotNull + private final JPanel optionsPane = new JPanel(optionCards); + + /** The currently selected tool. */ + @NotNull + private Tool<G, A, R, V> selectedTool; + + /** The tools. */ + @NotNull + private final Map<String, Tool<G, A, R, V>> tools = new HashMap<String, Tool<G, A, R, V>>(); + + /** Empty margin. */ + private static final Insets EMPTY_MARGIN = new Insets(0, 0, 0, 0); + + /** + * Create a ToolSelector component. + * @param defaultTool name of the tool that should be selected by default + * @param mainControl MainControl to use (required for {@link + * InsertionTool}). + * @param objectChooser the object chooser to use + */ + public ToolSelector(@NotNull final String defaultTool, @NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ObjectChooser<G, A, R, V> objectChooser) { + createUI(); + for (final Tool<G, A, R, V> toolToAdd : new Tool[] {new VoidTool<G, A, R, V>(), new SelectionTool<G, A, R, V>(objectChooser), new DeletionTool<G, A, R, V>(mainControl), new InsertionTool<G, A, R, V>(mainControl, objectChooser)}) { + add(toolToAdd, toolToAdd.getId().equals(defaultTool)); + } + } + + /** Create the user interface elements of the ToolSelector. */ + private void createUI() { + setLayout(new BorderLayout()); + add(selectionPane, BorderLayout.NORTH); + add(optionsPane, BorderLayout.CENTER); + } + + /** + * Add a tool to this tool selector. + * @param tool Tool to add + */ + @SuppressWarnings({"MethodOverloadsMethodOfSuperclass"}) + public void add(@NotNull final Tool<G, A, R, V> tool) { + add(tool, false); + } + + /** + * Add a tool to this tool selector. + * @param tool Tool to add + * @param selected <code>true</code> if the tool should be made the selected + * tool, otherwise <code>false</code> + */ + private void add(@NotNull final Tool<G, A, R, V> tool, final boolean selected) { + @NotNull final Action selectionAction = new SelectionAction(tool); + @NotNull final JToggleButton toggleButton = new JToggleButton(selectionAction); + toggleButton.setMargin(EMPTY_MARGIN); + @NotNull final Component optionsView = createOptionsView(tool); + selectionButtonGroup.add(toggleButton); + selectionPane.add(toggleButton); + optionsPane.add(optionsView, tool.getId()); + toggleButton.setSelected(selected); + tools.put(tool.getId(), tool); + if (selected) { + selectedTool = tool; + optionCards.show(optionsPane, tool.getId()); + } + } + + /** + * Create the options view for a tool. This method is a delegate to {@link + * Tool#createOptionsView()} but will provide a fallback if the tool doesn't + * provide tweaking its options. + * @param tool Tool to create options view for + * @return options view (the tool's options view or a dummy fallback if the + * tool doesn't provide an options view) + */ + @NotNull + private static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R>> Component createOptionsView(@NotNull final Tool<G, A, R, V> tool) { + @Nullable final Component optionsView = tool.createOptionsView(); + return optionsView != null ? optionsView : new JPanel(); + } + + /** + * Make a tool the currently selected tool to edit its options. + * @param tool Tool to select + * @pre the tool must be controlled by this toolselector. + * @see #setSelectedTool(String) + */ + public void setSelectedTool(@NotNull final Tool<G, A, R, V> tool) { + selectedTool = tool; + optionCards.show(optionsPane, tool.getId()); + } + + /** + * Make a tool the currently selected tool to edit its options. This method + * exists to allow programs to store the currently selected tool in + * preferences and restore it after startup. + * @param id ID of tool to select + * @pre the tool must be controlled by this toolselector. + * @see #setSelectedTool(Tool) + * @see Tool#getId() + */ + public void setSelectedTool(@NotNull final String id) { + setSelectedTool(tools.get(id)); + } + + /** + * Get the tool that is currently selected. + * @return the currently selected tool. + */ + @NotNull + public Tool<G, A, R, V> getSelectedTool() { + return selectedTool; + } + + /** Action for selecting a tool. */ + private final class SelectionAction extends AbstractAction { + + /** The serial version UID. */ + private static final long serialVersionUID = 1; + + /** The tool to select with this action. */ + @NotNull + private final Tool<G, A, R, V> tool; + + /** + * Create a SelectionAction. + * @param tool Tool to select with this action + */ + SelectionAction(@NotNull final Tool<G, A, R, V> tool) { + this.tool = tool; + ACTION_FACTORY.initAction(false, this, tool.getId()); + } + + /** {@inheritDoc} */ + public void actionPerformed(@NotNull final ActionEvent e) { + setSelectedTool(tool); + } + + } // class SelectionAction + +} // class ToolSelector Property changes on: trunk/src/app/net/sf/gridarta/gui/map/tools/ToolSelector.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-09 20:50:57
|
Revision: 4277 http://gridarta.svn.sourceforge.net/gridarta/?rev=4277&view=rev Author: akirschbaum Date: 2008-07-09 13:50:02 -0700 (Wed, 09 Jul 2008) Log Message: ----------- Move ToolPalette to common code base. Modified Paths: -------------- trunk/daimonin/src/daieditor/gui/ObjectChooser.java trunk/daimonin/src/daieditor/gui/map/MapUserListener.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/map/tools/ToolPalette.java Removed Paths: ------------- trunk/daimonin/src/daieditor/gui/map/tools/ToolPalette.java Modified: trunk/daimonin/src/daieditor/gui/ObjectChooser.java =================================================================== --- trunk/daimonin/src/daieditor/gui/ObjectChooser.java 2008-07-09 20:43:42 UTC (rev 4276) +++ trunk/daimonin/src/daieditor/gui/ObjectChooser.java 2008-07-09 20:50:02 UTC (rev 4277) @@ -23,7 +23,6 @@ import daieditor.gameobject.Archetype; import daieditor.gameobject.GameObject; import daieditor.gui.map.CMapViewBasic; -import daieditor.gui.map.tools.ToolPalette; import daieditor.map.MapArchObject; import java.awt.BorderLayout; import java.io.File; @@ -36,6 +35,7 @@ import net.sf.gridarta.gui.ObjectChoiceDisplay; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserListener; +import net.sf.gridarta.gui.map.tools.ToolPalette; import net.sf.gridarta.gui.newmap.NewMapDialogFactory; import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; import net.sf.japi.swing.ActionFactory; @@ -58,7 +58,7 @@ private static final long serialVersionUID = 1L; /** ToolSelector of this subview. */ - private final ToolPalette toolPalette; + private final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette; /** Panel holding both archlist and pickmaps. */ private final JTabbedPane archAndPickPane = new JTabbedPane(SwingConstants.TOP); @@ -92,7 +92,7 @@ // ignore } }); - toolPalette = new ToolPalette(mainControl, this); + toolPalette = new ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic>(mainControl, this); objectChoiceDisplay = new ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, CMapViewBasic>(mainControl, this); @@ -167,7 +167,7 @@ * Returns the tool selector pane. * @return The tool selector pane. */ - public ToolPalette getToolSelectorPane() { + public ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> getToolSelectorPane() { return toolPalette; } Modified: trunk/daimonin/src/daieditor/gui/map/MapUserListener.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/MapUserListener.java 2008-07-09 20:43:42 UTC (rev 4276) +++ trunk/daimonin/src/daieditor/gui/map/MapUserListener.java 2008-07-09 20:50:02 UTC (rev 4277) @@ -22,7 +22,6 @@ import daieditor.CMainControl; import daieditor.gameobject.Archetype; import daieditor.gameobject.GameObject; -import daieditor.gui.map.tools.ToolPalette; import daieditor.map.MapArchObject; import java.awt.Point; import java.awt.event.InputEvent; @@ -33,6 +32,7 @@ import net.sf.gridarta.gui.map.MapCursor; import net.sf.gridarta.gui.map.event.MouseOpEvent; import net.sf.gridarta.gui.map.event.MouseOpListener; +import net.sf.gridarta.gui.map.tools.ToolPalette; import net.sf.gridarta.map.MapControl; import org.jetbrains.annotations.Nullable; @@ -43,7 +43,7 @@ public final class MapUserListener implements MouseListener, MouseMotionListener { /** ToolSelector of ArchPanel. */ - private final ToolPalette toolPalette; + private final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette; private final MapCursor mapCursor; Deleted: trunk/daimonin/src/daieditor/gui/map/tools/ToolPalette.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/ToolPalette.java 2008-07-09 20:43:42 UTC (rev 4276) +++ trunk/daimonin/src/daieditor/gui/map/tools/ToolPalette.java 2008-07-09 20:50:02 UTC (rev 4277) @@ -1,123 +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.map.tools; - -import daieditor.gameobject.Archetype; -import daieditor.gameobject.GameObject; -import daieditor.gui.map.CMapViewBasic; -import daieditor.map.MapArchObject; -import java.awt.BorderLayout; -import java.awt.event.InputEvent; -import java.awt.event.MouseEvent; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JTabbedPane; -import net.sf.gridarta.MainControl; -import net.sf.gridarta.gui.ObjectChooser; -import net.sf.gridarta.gui.map.event.MouseOpEvent; -import net.sf.gridarta.gui.map.tools.Tool; -import net.sf.gridarta.gui.map.tools.ToolSelector; -import net.sf.japi.swing.ActionFactory; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Pane for controlling which mouse to select and configure tools for. Also - * serves as a proxy for querying which tool is bound to which mouse button. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public class ToolPalette extends JPanel { - - /** The serial version UID. */ - private static final long serialVersionUID = 1; - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor.gui.map.tools"); - - /** The JTabbedPane for the three tabs, one for each mousebutton. */ - private final JTabbedPane mouseTabs = new JTabbedPane(); - - /** The ToolSelector for lmb. */ - private final ToolSelector<GameObject, MapArchObject, Archetype, CMapViewBasic> lmbSelector; - - /** The ToolSelector for mmb. */ - private final ToolSelector<GameObject, MapArchObject, Archetype, CMapViewBasic> mmbSelector; - - /** The ToolSelector for rmb. */ - private final ToolSelector<GameObject, MapArchObject, Archetype, CMapViewBasic> rmbSelector; - - /** - * Create a ToolPalette. - * @param mainControl MainControl to use (required for {@link - * net.sf.gridarta.gui.map.tools.InsertionTool}). - * @param objectChooser the object chooser to use - */ - public ToolPalette(@NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChooser) { - super(new BorderLayout()); - lmbSelector = new ToolSelector<GameObject, MapArchObject, Archetype, CMapViewBasic>("selection", mainControl, objectChooser); - mmbSelector = new ToolSelector<GameObject, MapArchObject, Archetype, CMapViewBasic>("deletion", mainControl, objectChooser); - rmbSelector = new ToolSelector<GameObject, MapArchObject, Archetype, CMapViewBasic>("insertion", mainControl, objectChooser); - add(new JLabel(ACTION_FACTORY.getString("mouse")), BorderLayout.NORTH); - mouseTabs.add(ACTION_FACTORY.getString("left"), lmbSelector); - mouseTabs.add(ACTION_FACTORY.getString("middle"), mmbSelector); - mouseTabs.add(ACTION_FACTORY.getString("right"), rmbSelector); - add(mouseTabs); - } - - /** - * Returns <code>MouseOpListener</code> depending on the <code>event</code> - * and the default settings. - * @param event This event's button and modifiers are needed - * @return Default <code>MouseOpListener</code> or <code>null</code> if - * mouse button is not bound to a tool. - */ - @Nullable - public Tool<GameObject, MapArchObject, Archetype, CMapViewBasic> getTool(final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> event) { - final int button = event.getButton(); - final ToolSelector<GameObject, MapArchObject, Archetype, CMapViewBasic> toolSelector; - switch (button) { - case MouseEvent.BUTTON1: - toolSelector = lmbSelector; - break; - case MouseEvent.BUTTON2: - toolSelector = mmbSelector; - break; - case MouseEvent.BUTTON3: - toolSelector = rmbSelector; - break; - default: - final int mask = event.getModifiers(); - if ((mask & InputEvent.BUTTON1_DOWN_MASK) == InputEvent.BUTTON1_DOWN_MASK) { - toolSelector = lmbSelector; - } else - if ((mask & InputEvent.BUTTON2_DOWN_MASK) == InputEvent.BUTTON2_DOWN_MASK) { - toolSelector = mmbSelector; - } else - if ((mask & InputEvent.BUTTON3_DOWN_MASK) == InputEvent.BUTTON3_DOWN_MASK) { - toolSelector = rmbSelector; - } else { - return null; - } - break; - } - return toolSelector.getSelectedTool(); - } - -} // class ToolPalette Copied: trunk/src/app/net/sf/gridarta/gui/map/tools/ToolPalette.java (from rev 4276, trunk/daimonin/src/daieditor/gui/map/tools/ToolPalette.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/ToolPalette.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/ToolPalette.java 2008-07-09 20:50:02 UTC (rev 4277) @@ -0,0 +1,121 @@ +/* + * 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.map.tools; + +import java.awt.BorderLayout; +import java.awt.event.InputEvent; +import java.awt.event.MouseEvent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTabbedPane; +import net.sf.gridarta.MainControl; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.ObjectChooser; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.map.event.MouseOpEvent; +import net.sf.gridarta.map.MapArchObject; +import net.sf.japi.swing.ActionFactory; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Pane for controlling which mouse to select and configure tools for. Also + * serves as a proxy for querying which tool is bound to which mouse button. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class ToolPalette<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R>> extends JPanel { + + /** The serial version UID. */ + private static final long serialVersionUID = 1; + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor.gui.map.tools"); + + /** The JTabbedPane for the three tabs, one for each mousebutton. */ + private final JTabbedPane mouseTabs = new JTabbedPane(); + + /** The ToolSelector for lmb. */ + private final ToolSelector<G, A, R, V> lmbSelector; + + /** The ToolSelector for mmb. */ + private final ToolSelector<G, A, R, V> mmbSelector; + + /** The ToolSelector for rmb. */ + private final ToolSelector<G, A, R, V> rmbSelector; + + /** + * Create a ToolPalette. + * @param mainControl MainControl to use (required for {@link + * net.sf.gridarta.gui.map.tools.InsertionTool}). + * @param objectChooser the object chooser to use + */ + public ToolPalette(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ObjectChooser<G, A, R, V> objectChooser) { + super(new BorderLayout()); + lmbSelector = new ToolSelector<G, A, R, V>("selection", mainControl, objectChooser); + mmbSelector = new ToolSelector<G, A, R, V>("deletion", mainControl, objectChooser); + rmbSelector = new ToolSelector<G, A, R, V>("insertion", mainControl, objectChooser); + add(new JLabel(ACTION_FACTORY.getString("mouse")), BorderLayout.NORTH); + mouseTabs.add(ACTION_FACTORY.getString("left"), lmbSelector); + mouseTabs.add(ACTION_FACTORY.getString("middle"), mmbSelector); + mouseTabs.add(ACTION_FACTORY.getString("right"), rmbSelector); + add(mouseTabs); + } + + /** + * Returns <code>MouseOpListener</code> depending on the <code>event</code> + * and the default settings. + * @param event This event's button and modifiers are needed + * @return Default <code>MouseOpListener</code> or <code>null</code> if + * mouse button is not bound to a tool. + */ + @Nullable + public Tool<G, A, R, V> getTool(final MouseOpEvent<G, A, R, V> event) { + final int button = event.getButton(); + final ToolSelector<G, A, R, V> toolSelector; + switch (button) { + case MouseEvent.BUTTON1: + toolSelector = lmbSelector; + break; + case MouseEvent.BUTTON2: + toolSelector = mmbSelector; + break; + case MouseEvent.BUTTON3: + toolSelector = rmbSelector; + break; + default: + final int mask = event.getModifiers(); + if ((mask & InputEvent.BUTTON1_DOWN_MASK) == InputEvent.BUTTON1_DOWN_MASK) { + toolSelector = lmbSelector; + } else + if ((mask & InputEvent.BUTTON2_DOWN_MASK) == InputEvent.BUTTON2_DOWN_MASK) { + toolSelector = mmbSelector; + } else + if ((mask & InputEvent.BUTTON3_DOWN_MASK) == InputEvent.BUTTON3_DOWN_MASK) { + toolSelector = rmbSelector; + } else { + return null; + } + break; + } + return toolSelector.getSelectedTool(); + } + +} // class ToolPalette Property changes on: trunk/src/app/net/sf/gridarta/gui/map/tools/ToolPalette.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-10 05:18:00
|
Revision: 4278 http://gridarta.svn.sourceforge.net/gridarta/?rev=4278&view=rev Author: akirschbaum Date: 2008-07-09 22:18:06 -0700 (Wed, 09 Jul 2008) Log Message: ----------- Move tool related action.properties to common code base. Modified Paths: -------------- trunk/daimonin/build.xml trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java trunk/src/app/net/sf/gridarta/gui/map/tools/ToolPalette.java trunk/src/app/net/sf/gridarta/gui/map/tools/ToolSelector.java Added Paths: ----------- trunk/resource/toolbarButtonGraphics/ trunk/src/app/net/sf/gridarta/gui/map/tools/action.properties Removed Paths: ------------- trunk/daimonin/resource/toolbarButtonGraphics/ trunk/daimonin/src/daieditor/gui/map/tools/action.properties Modified: trunk/daimonin/build.xml =================================================================== --- trunk/daimonin/build.xml 2008-07-09 20:50:02 UTC (rev 4277) +++ trunk/daimonin/build.xml 2008-07-10 05:18:06 UTC (rev 4278) @@ -113,7 +113,6 @@ <copy todir="${build.dir.production}"> <fileset dir="${resource.dir}"> <include name="icons/**/*.*"/> - <include name="toolbarButtonGraphics/**/*.*"/> <include name="system/**/*.*"/> <include name="log4j.properties"/> <exclude name="**/.xvpics/**"/> @@ -126,7 +125,10 @@ <fileset dir="${src.dir}" includes="**/*.properties" /> </copy> <copy todir="${build.dir.production}"> - <fileset dir="../resource" includes="system/**/*.*" /> + <fileset dir="../resource"> + <include name="system/**/*.*"/> + <include name="toolbarButtonGraphics/**/*.*"/> + </fileset> </copy> <!--copy file="${arch.dir}/archetypes" todir="${build.dir.production}" /--> <!--copy file="${arch.dir}/daimonin.0" todir="${build.dir.production}" /--> Deleted: trunk/daimonin/src/daieditor/gui/map/tools/action.properties =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/action.properties 2008-07-09 20:50:02 UTC (rev 4277) +++ trunk/daimonin/src/daieditor/gui/map/tools/action.properties 2008-07-10 05:18:06 UTC (rev 4278) @@ -1,33 +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. -# - -selection.icon=misc/Select16 -selection.shortdescription=Select regions of the map. -deletion.icon=misc/Delete16 -deletion.shortdescription=Delete topmost or bottommost objects. -insertion.icon=misc/Insert16 -insertion.shortdescription=Insert topmost objects. -void.icon=misc/Void16 -void.shortdescription=Do nothing (makes selected mouse button inactive). -deleteBelow.text=Delete below -insertBelow.text=Insert below -left=left -middle=middle -right=right -mouse=Mousebutton \ No newline at end of file Copied: trunk/resource/toolbarButtonGraphics (from rev 4277, trunk/daimonin/resource/toolbarButtonGraphics) Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java 2008-07-09 20:50:02 UTC (rev 4277) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java 2008-07-10 05:18:06 UTC (rev 4278) @@ -44,7 +44,7 @@ /** Action Factory. */ @NotNull - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor.gui.map.tools"); + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta.gui.map.tools"); /** The main control. */ @NotNull Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java 2008-07-09 20:50:02 UTC (rev 4277) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java 2008-07-10 05:18:06 UTC (rev 4278) @@ -45,7 +45,7 @@ /** Action Factory. */ @NotNull - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor.gui.map.tools"); + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta.gui.map.tools"); /** The ToggleAction for toggling the insertBelow status. */ @SuppressWarnings({"UnusedDeclaration"}) Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/ToolPalette.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/ToolPalette.java 2008-07-09 20:50:02 UTC (rev 4277) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/ToolPalette.java 2008-07-10 05:18:06 UTC (rev 4278) @@ -47,7 +47,7 @@ private static final long serialVersionUID = 1; /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor.gui.map.tools"); + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta.gui.map.tools"); /** The JTabbedPane for the three tabs, one for each mousebutton. */ private final JTabbedPane mouseTabs = new JTabbedPane(); Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/ToolSelector.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/ToolSelector.java 2008-07-09 20:50:02 UTC (rev 4277) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/ToolSelector.java 2008-07-10 05:18:06 UTC (rev 4278) @@ -53,7 +53,7 @@ private static final long serialVersionUID = 1; /** The Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor.gui.map.tools"); + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta.gui.map.tools"); /** The pane with the selections. */ @NotNull Copied: trunk/src/app/net/sf/gridarta/gui/map/tools/action.properties (from rev 4277, trunk/daimonin/src/daieditor/gui/map/tools/action.properties) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/action.properties (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/action.properties 2008-07-10 05:18:06 UTC (rev 4278) @@ -0,0 +1,33 @@ +# +# 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. +# + +selection.icon=misc/Select16 +selection.shortdescription=Select regions of the map. +deletion.icon=misc/Delete16 +deletion.shortdescription=Delete topmost or bottommost objects. +insertion.icon=misc/Insert16 +insertion.shortdescription=Insert topmost objects. +void.icon=misc/Void16 +void.shortdescription=Do nothing (makes selected mouse button inactive). +deleteBelow.text=Delete below +insertBelow.text=Insert below +left=left +middle=middle +right=right +mouse=Mousebutton \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-10 17:08:55
|
Revision: 4280 http://gridarta.svn.sourceforge.net/gridarta/?rev=4280&view=rev Author: akirschbaum Date: 2008-07-10 10:09:02 -0700 (Thu, 10 Jul 2008) Log Message: ----------- Remove ObjectChooser.getArchetypeChooserControl(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gui/ObjectChooser.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gui/ObjectChooser.java trunk/src/app/net/sf/gridarta/gui/AbstractObjectChooser.java trunk/src/app/net/sf/gridarta/gui/MainView.java trunk/src/app/net/sf/gridarta/gui/ObjectChooser.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-10 06:44:41 UTC (rev 4279) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-10 17:09:02 UTC (rev 4280) @@ -71,6 +71,7 @@ import net.sf.gridarta.gui.MapPreview; import net.sf.gridarta.gui.RecentManager; import net.sf.gridarta.gui.SystemIcons; +import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.map.MapCursorControl; import net.sf.gridarta.gui.map.MapView; @@ -233,9 +234,10 @@ mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(getMapManager()); globalSettings.readGlobalSettings(); PathManager.setGlobalSettings(globalSettings); - objectChooser = new ObjectChooser(newMapDialogFactory, this, new File(globalSettings.getMapDir(), IGUIConstants.PICKMAP_DIR)); + final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl = new ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, false); + objectChooser = new ObjectChooser(newMapDialogFactory, this, new File(globalSettings.getMapDir(), IGUIConstants.PICKMAP_DIR), archetypeChooserControl); mainActions = new MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, animationObjects, ACTION_FACTORY, faceObjects, objectChooser); - getGridartaObjectsFactory().init(faceObjects, objectChooser, objectChooser.getArchetypeChooserControl()); + getGridartaObjectsFactory().init(faceObjects, objectChooser, archetypeChooserControl); mainView = new MainView<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, objectChooser, getMapManager(), ACTION_FACTORY, mapManagerActions.getCloseAllAction(), faceObjects); new About("cfeditor", mainView); undoControl = new UndoControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(getMapManager()); @@ -294,10 +296,10 @@ } final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(getMapManager(), 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 GameObjectAttributesPanel gameObjectAttributesPanel = new GameObjectAttributesPanel(this, getMapManager(), animationObjects, lockedItemsControl, monsterMatcher); - mainView.init(gameObjectAttributesPanel, selectedSquareControl.getSelectedSquareView(), typeList, mapTileListBottom, gameObjectMatchers); + mainView.init(gameObjectAttributesPanel, selectedSquareControl.getSelectedSquareView(), typeList, mapTileListBottom, gameObjectMatchers, archetypeChooserControl); mapActions.updateMenuState(); scriptControl.getView().setMenu((JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "plugins")); - archetypeParser = new ArchetypeParser(this, objectChooser.getArchetypeChooserControl(), animationObjects, archetypeSet); + archetypeParser = new ArchetypeParser(this, archetypeChooserControl, animationObjects, archetypeSet); archetypeSet.loadArchetypes(archetypeParser); if (globalSettings.isAutoPopupDocu()) { @@ -333,7 +335,7 @@ scriptControl.loadScripts(new File(globalSettings.getMapDir(), IGUIConstants.SCRIPTS_DIR)); mainView.getStatusBar().setStatusText("Sorting..."); - objectChooser.getArchetypeChooserControl().finishBuildProcess(); + archetypeChooserControl.finishBuildProcess(); // load the autojoin lists mainView.getStatusBar().setStatusText("Loading Autojoin Tables..."); Modified: trunk/crossfire/src/cfeditor/gui/ObjectChooser.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ObjectChooser.java 2008-07-10 06:44:41 UTC (rev 4279) +++ trunk/crossfire/src/cfeditor/gui/ObjectChooser.java 2008-07-10 17:09:02 UTC (rev 4280) @@ -77,18 +77,15 @@ /** The pickmap chooser control. */ private final PickmapChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> pickmapChooserControl; - /** The archetype chooser control. */ - private final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl; - /** * Build Panel. * @param newMapDialogFactory the factory for creating new pickmaps * @param mainControl CMainControl * @param pickmapDir the pickmaps directory */ - public ObjectChooser(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapDialogFactory, final CMainControl mainControl, @NotNull final File pickmapDir) { + public ObjectChooser(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapDialogFactory, final CMainControl mainControl, @NotNull final File pickmapDir, @NotNull final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl) { + super(archetypeChooserControl); pickmapChooserControl = new PickmapChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(newMapDialogFactory, mainControl, this, pickmapDir); - archetypeChooserControl = new ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mainControl, false); archetypeChooserControl.addArchetypeChooserListener(new ArchetypeChooserListener<GameObject, MapArchObject, Archetype>() { /** {@inheritDoc} */ public void selectedArchetypeChanged(@NotNull final GameObject archetype) { @@ -163,12 +160,6 @@ } /** {@inheritDoc} */ - @NotNull - public ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> getArchetypeChooserControl() { - return archetypeChooserControl; - } - - /** {@inheritDoc} */ public void setPickmapActive(final boolean pickmapActive) { super.setPickmapActive(pickmapActive); pickmapChooserControl.setActive(pickmapActive); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-07-10 06:44:41 UTC (rev 4279) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-07-10 17:09:02 UTC (rev 4280) @@ -78,6 +78,7 @@ import net.sf.gridarta.gui.MapPreview; import net.sf.gridarta.gui.RecentManager; import net.sf.gridarta.gui.SystemIcons; +import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.map.MapCursorControl; import net.sf.gridarta.gui.map.MapView; @@ -286,9 +287,10 @@ mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(getMapManager()); globalSettings.readGlobalSettings(); PathManager.setGlobalSettings(globalSettings); - objectChooser = new ObjectChooser(newMapDialogFactory, this, new File(globalSettings.getArchDefaultFolder(), IGUIConstants.PICKMAP_DIR)); + final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl = new ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, true); + objectChooser = new ObjectChooser(newMapDialogFactory, this, new File(globalSettings.getArchDefaultFolder(), IGUIConstants.PICKMAP_DIR), archetypeChooserControl); mainActions = new MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, animationObjects, ACTION_FACTORY, faceObjects, objectChooser); - getGridartaObjectsFactory().init(faceObjects, objectChooser, objectChooser.getArchetypeChooserControl()); + getGridartaObjectsFactory().init(faceObjects, objectChooser, archetypeChooserControl); mainView = new MainView<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, objectChooser, getMapManager(), ACTION_FACTORY, mapManagerActions.getCloseAllAction(), faceObjects); new About("daieditor", mainView); undoControl = new UndoControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(getMapManager()); @@ -349,9 +351,9 @@ } final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(getMapManager(), 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 GameObjectAttributesPanel gameObjectAttributesPanel = new GameObjectAttributesPanel(this, getMapManager(), animationObjects, lockedItemsControl, monsterMatcher); - mainView.init(gameObjectAttributesPanel, selectedSquareControl.getSelectedSquareView(), typeList, mapTileListBottom, gameObjectMatchers); + mainView.init(gameObjectAttributesPanel, selectedSquareControl.getSelectedSquareView(), typeList, mapTileListBottom, gameObjectMatchers, archetypeChooserControl); mapActions.updateMenuState(); - archetypeParser = new ArchetypeParser(this, objectChooser.getArchetypeChooserControl(), animationObjects, archetypeSet); + archetypeParser = new ArchetypeParser(this, archetypeChooserControl, animationObjects, archetypeSet); archetypeSet.loadArchetypes(archetypeParser); if (globalSettings.isAutoPopupDocu()) { @@ -403,7 +405,7 @@ // load object from a arch file you found mainView.getStatusBar().setStatusText("Sorting..."); - objectChooser.getArchetypeChooserControl().finishBuildProcess(); + archetypeChooserControl.finishBuildProcess(); // load the autojoin lists mainView.getStatusBar().setStatusText("Loading Autojoin Tables..."); Modified: trunk/daimonin/src/daieditor/gui/ObjectChooser.java =================================================================== --- trunk/daimonin/src/daieditor/gui/ObjectChooser.java 2008-07-10 06:44:41 UTC (rev 4279) +++ trunk/daimonin/src/daieditor/gui/ObjectChooser.java 2008-07-10 17:09:02 UTC (rev 4280) @@ -69,18 +69,16 @@ /** The pickmap chooser control. */ private final PickmapChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> pickmapChooserControl; - /** The archetype chooser control. */ - private final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl; - /** * Build Panel. * @param newMapDialogFactory the factory for creating new pickmaps * @param mainControl CMainControl * @param pickmapDir the pickmaps directory + * @param archetypeChooserControl the archetype chooser control */ - public ObjectChooser(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapDialogFactory, final CMainControl mainControl, @NotNull final File pickmapDir) { + public ObjectChooser(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapDialogFactory, final CMainControl mainControl, @NotNull final File pickmapDir, @NotNull final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl) { + super(archetypeChooserControl); pickmapChooserControl = new PickmapChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(newMapDialogFactory, mainControl, this, pickmapDir); - archetypeChooserControl = new ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mainControl, true); archetypeChooserControl.addArchetypeChooserListener(new ArchetypeChooserListener<GameObject, MapArchObject, Archetype>() { /** {@inheritDoc} */ public void selectedArchetypeChanged(@NotNull final GameObject archetype) { @@ -152,12 +150,6 @@ } /** {@inheritDoc} */ - @NotNull - public ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> getArchetypeChooserControl() { - return archetypeChooserControl; - } - - /** {@inheritDoc} */ public void setPickmapActive(final boolean pickmapActive) { super.setPickmapActive(pickmapActive); pickmapChooserControl.setActive(pickmapActive); Modified: trunk/src/app/net/sf/gridarta/gui/AbstractObjectChooser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/AbstractObjectChooser.java 2008-07-10 06:44:41 UTC (rev 4279) +++ trunk/src/app/net/sf/gridarta/gui/AbstractObjectChooser.java 2008-07-10 17:09:02 UTC (rev 4280) @@ -25,6 +25,7 @@ import javax.swing.JPanel; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; @@ -37,15 +38,22 @@ */ public abstract class AbstractObjectChooser<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R>> extends JPanel implements ObjectChooser<G, A, R, V> { + /** The archetype chooser control. */ + protected final ArchetypeChooserControl<G, A, R, V> archetypeChooserControl; + /** * <code>true</code> if the PickmapChooser is active, <code>false</code> if * the Archetype Chooser is active. */ private boolean pickmapActive = false; - /** Create a new instance. */ - protected AbstractObjectChooser() { + /** + * Creates a new instance. + * @param archetypeChooserControl the archetype chooser control + */ + protected AbstractObjectChooser(@NotNull final ArchetypeChooserControl<G, A, R, V> archetypeChooserControl) { super(new BorderLayout()); + this.archetypeChooserControl = archetypeChooserControl; } /** {@inheritDoc} */ @@ -82,7 +90,7 @@ // insert default arch from archlist: mapControl.getMapModel().beginTransaction("Insert"); // TODO: I18N/L10N - final G newObject = mapControl.getMapModel().addArchToMap(getArchetypeChooserControl().getSelectedArch(), pos, allowMany, true, false); + final G newObject = mapControl.getMapModel().addArchToMap(archetypeChooserControl.getSelectedArch(), pos, allowMany, true, false); mapControl.getMapModel().endTransaction(); return newObject; } Modified: trunk/src/app/net/sf/gridarta/gui/MainView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-07-10 06:44:41 UTC (rev 4279) +++ trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-07-10 17:09:02 UTC (rev 4280) @@ -50,6 +50,7 @@ import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gameobject.match.GameObjectMatchers; +import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.gui.map.MapFileActions; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; @@ -432,8 +433,9 @@ * @param mapTileListBottom whether the map tile view should be on the * bottom monster objects * @param gameObjectMatchers the game object matchers + * @param archetypeChooserControl the archetype chooser control */ - public void init(@NotNull final GameObjectAttributesPanel<G, A, R, V> gameObjectAttributesPanel, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, final CFArchTypeList archTypeList, final boolean mapTileListBottom, @NotNull final GameObjectMatchers gameObjectMatchers) { + public void init(@NotNull final GameObjectAttributesPanel<G, A, R, V> gameObjectAttributesPanel, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, final CFArchTypeList archTypeList, final boolean mapTileListBottom, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ArchetypeChooserControl<G, A, R, V> archetypeChooserControl) { this.gameObjectAttributesPanel = gameObjectAttributesPanel; // calculate some default values in case there is no settings file @@ -448,7 +450,7 @@ toolbarPanel.add(createCenterPanel(defwidth, defheight, selectedSquareView, mapTileListBottom), BorderLayout.CENTER); add(toolbarPanel, BorderLayout.CENTER); - archetypesActions = new ArchetypesActions<G, A, R, V>(this, objectChooser.getArchetypeChooserControl(), objectChooser, archTypeList); + archetypesActions = new ArchetypesActions<G, A, R, V>(this, archetypeChooserControl, objectChooser, archTypeList); setJMenuBar(actionFactory.createMenuBar(true, "main")); objectChooser.setPickmapFoldersMenu((JMenu) actionFactory.find(getJMenuBar(), "pickmapFolders")); viewActions.init(gameObjectMatchers); Modified: trunk/src/app/net/sf/gridarta/gui/ObjectChooser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ObjectChooser.java 2008-07-10 06:44:41 UTC (rev 4279) +++ trunk/src/app/net/sf/gridarta/gui/ObjectChooser.java 2008-07-10 17:09:02 UTC (rev 4280) @@ -24,7 +24,6 @@ import javax.swing.JMenu; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; import net.sf.gridarta.map.MapArchObject; @@ -100,13 +99,6 @@ void selectArchetype(R archetype); /** - * Return the archetype chooser control. - * @return the archetype chooser control - */ - @NotNull - ArchetypeChooserControl<G, A, R, V> getArchetypeChooserControl(); - - /** * Add the selected game object to the map. * @param mapControl the map control to add to * @param pos The location to add to. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-10 17:11:11
|
Revision: 4281 http://gridarta.svn.sourceforge.net/gridarta/?rev=4281&view=rev Author: akirschbaum Date: 2008-07-10 10:11:13 -0700 (Thu, 10 Jul 2008) Log Message: ----------- Make fields final. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-10 17:09:02 UTC (rev 4280) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-10 17:11:13 UTC (rev 4281) @@ -178,7 +178,7 @@ private final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells = new Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>>(); /** List of objects on map (right side). */ - private SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl; + private final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl; /** The ArchetypeSet, which is a registry of all Archetypes. */ private final ArchetypeSet archetypeSet; Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-07-10 17:09:02 UTC (rev 4280) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-07-10 17:11:13 UTC (rev 4281) @@ -217,7 +217,7 @@ private final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells = new Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>>(); /** List of objects on map (right side). */ - private SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl; + private final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl; /** The ArchetypeSet, which is a registry of all Archetypes. */ private final ArchetypeSet archetypeSet; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-10 17:50:25
|
Revision: 4282 http://gridarta.svn.sourceforge.net/gridarta/?rev=4282&view=rev Author: akirschbaum Date: 2008-07-10 10:50:34 -0700 (Thu, 10 Jul 2008) Log Message: ----------- Remove call from PickmapChooserControl to ObjectChooser. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-10 17:11:13 UTC (rev 4281) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-10 17:50:34 UTC (rev 4282) @@ -350,7 +350,10 @@ log.info("Arch loading took " + (System.currentTimeMillis() - timeStart) / 1000.0 + " Seconds"); } - objectChooser.getPickmapChooserControl().loadPickmaps(true); + objectChooser.getPickmapChooserControl().loadPickmaps(); + if (!objectChooser.getPickmapChooserControl().isEmpty()) { + objectChooser.movePickmapChooserToFront(); + } } Map<String, TreasureTreeNode> specialTreasureLists; try { Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-07-10 17:11:13 UTC (rev 4281) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-07-10 17:50:34 UTC (rev 4282) @@ -420,7 +420,10 @@ log.info("Arch loading took " + (System.currentTimeMillis() - timeStart) / 1000.0 + " Seconds"); } - objectChooser.getPickmapChooserControl().loadPickmaps(true); + objectChooser.getPickmapChooserControl().loadPickmaps(); + if (!objectChooser.getPickmapChooserControl().isEmpty()) { + objectChooser.movePickmapChooserToFront(); + } } Map<String, TreasureTreeNode> specialTreasureLists; try { Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2008-07-10 17:11:13 UTC (rev 4281) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2008-07-10 17:50:34 UTC (rev 4282) @@ -113,15 +113,9 @@ /** * Load all pickmaps and build the pickmap-panel. - * @param movePickmapChooserToFront If set, move activate the pickmap - * chooser if at least one pickmap was loaded. */ - public void loadPickmaps(final boolean movePickmapChooserToFront) { + public void loadPickmaps() { new Loader<G, A, R, V>(model, mainControl.getGridartaObjectsFactory()).load(); - - if (movePickmapChooserToFront && !view.isEmpty()) { - objectChooser.movePickmapChooserToFront(); - } } /** @@ -309,4 +303,12 @@ return true; } + /** + * Returns whether no pickmaps exist. + * @return whether no pickmaps exist + */ + public boolean isEmpty() { + return view.isEmpty(); + } + } // class PickmapChooserControl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-10 18:11:10
|
Revision: 4283 http://gridarta.svn.sourceforge.net/gridarta/?rev=4283&view=rev Author: akirschbaum Date: 2008-07-10 11:11:10 -0700 (Thu, 10 Jul 2008) Log Message: ----------- Remove PickmapChooserControl.addArchNPickChangeListener(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/ObjectChooser.java trunk/daimonin/src/daieditor/gui/ObjectChooser.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java Modified: trunk/crossfire/src/cfeditor/gui/ObjectChooser.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ObjectChooser.java 2008-07-10 17:50:34 UTC (rev 4282) +++ trunk/crossfire/src/cfeditor/gui/ObjectChooser.java 2008-07-10 18:11:10 UTC (rev 4283) @@ -40,6 +40,7 @@ import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserListener; import net.sf.gridarta.gui.newmap.NewMapDialogFactory; +import net.sf.gridarta.gui.pickmapchooser.ArchNPickChangeListener; import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; @@ -104,7 +105,7 @@ archAndPickPane.addTab(ACTION_FACTORY.getString("objectChooser.archetypesTabTitle"), archetypeChooserControl.getArchetypePanel()); archAndPickPane.addTab(ACTION_FACTORY.getString("objectChooser.pickmapsTabTitle"), pickmapChooserControl.getPickmapPanel()); // this listener informs the mainview which panel is active: archlist or pickmaps? - pickmapChooserControl.addArchNPickChangeListener(archAndPickPane); + archAndPickPane.addChangeListener(new ArchNPickChangeListener(this, archAndPickPane)); // calculate default value in case there is no settings file final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); Modified: trunk/daimonin/src/daieditor/gui/ObjectChooser.java =================================================================== --- trunk/daimonin/src/daieditor/gui/ObjectChooser.java 2008-07-10 17:50:34 UTC (rev 4282) +++ trunk/daimonin/src/daieditor/gui/ObjectChooser.java 2008-07-10 18:11:10 UTC (rev 4283) @@ -37,6 +37,7 @@ import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserListener; import net.sf.gridarta.gui.map.tools.ToolPalette; import net.sf.gridarta.gui.newmap.NewMapDialogFactory; +import net.sf.gridarta.gui.pickmapchooser.ArchNPickChangeListener; import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; @@ -98,7 +99,7 @@ archAndPickPane.addTab(ACTION_FACTORY.getString("objectChooser.archetypesTabTitle"), archetypeChooserControl.getArchetypePanel()); archAndPickPane.addTab(ACTION_FACTORY.getString("objectChooser.pickmapsTabTitle"), pickmapChooserControl.getPickmapPanel()); // this listener informs the mainview which panel is active: archlist or pickmaps? - pickmapChooserControl.addArchNPickChangeListener(archAndPickPane); + archAndPickPane.addChangeListener(new ArchNPickChangeListener(this, archAndPickPane)); // calculate default value in case there is no settings file Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2008-07-10 17:50:34 UTC (rev 4282) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2008-07-10 18:11:10 UTC (rev 4283) @@ -185,16 +185,6 @@ } /** - * Add the ArchNPickChangeListener to the panel containing both archlist and - * pickmaps. - * @param pane the left-side panel - * @todo this method's name is a Bad Thing - */ - public void addArchNPickChangeListener(@NotNull final JTabbedPane pane) { - pane.addChangeListener(new ArchNPickChangeListener(objectChooser, pane)); - } - - /** * Callback function: set the pickmap panel state. * @param active <code>true</code> if the pickmap panel is active */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |