From: <aki...@us...> - 2008-03-28 08:11:36
|
Revision: 3753 http://gridarta.svn.sourceforge.net/gridarta/?rev=3753&view=rev Author: akirschbaum Date: 2008-03-28 01:11:43 -0700 (Fri, 28 Mar 2008) Log Message: ----------- Make map event generation work reliably; document the event ordering. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainView.java trunk/daimonin/src/daieditor/CMainView.java trunk/src/app/net/sf/gridarta/DefaultMapManager.java trunk/src/app/net/sf/gridarta/MapManager.java trunk/src/app/net/sf/gridarta/MapManagerListener.java Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-03-27 21:31:17 UTC (rev 3752) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-03-28 08:11:43 UTC (rev 3753) @@ -267,11 +267,11 @@ public void addLevelView(final MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapView) { assert !mapViews.contains(mapView); mapViews.add(0, mapView); - generateCurrentMapViewChangedEvent(); mapView.addInternalFrameListener(this); mapDesktop.add(mapView); + mapManager.fireMapViewCreatedEvent(mapView); + setCurrentLevelView(mapView); mapView.setVisible(true); - setCurrentLevelView(mapView); mapView.setBounds(0, 0, mapDesktop.getWidth(), mapDesktop.getHeight()); refreshMenus(); } @@ -286,6 +286,7 @@ mapView.removeInternalFrameListener(this); mapViews.remove(mapView); generateCurrentMapViewChangedEvent(); + mapManager.fireMapViewClosingEvent(mapView); mapDesktop.remove(mapView); // This is important: Removing a JInternalFrame from a JDesktopPane doesn't deselect it. // Thus it will still be referenced. To prevent a closed map from being referenced by Swing, Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-03-27 21:31:17 UTC (rev 3752) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-03-28 08:11:43 UTC (rev 3753) @@ -271,11 +271,11 @@ public void addLevelView(final MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapView) { assert !mapViews.contains(mapView); mapViews.add(0, mapView); - generateCurrentMapViewChangedEvent(); mapView.addInternalFrameListener(this); mapDesktop.add(mapView); + mapManager.fireMapViewCreatedEvent(mapView); + setCurrentLevelView(mapView); mapView.setVisible(true); - setCurrentLevelView(mapView); mapView.setBounds(0, 0, mapDesktop.getWidth(), mapDesktop.getHeight()); try { mapView.setMaximum(true); @@ -295,6 +295,7 @@ mapView.removeInternalFrameListener(this); mapViews.remove(mapView); generateCurrentMapViewChangedEvent(); + mapManager.fireMapViewClosingEvent(mapView); mapDesktop.remove(mapView); // This is important: Removing a JInternalFrame from a JDesktopPane doesn't deselect it. // Thus it will still be referenced. To prevent a closed map from being referenced by Swing, Modified: trunk/src/app/net/sf/gridarta/DefaultMapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-03-27 21:31:17 UTC (rev 3752) +++ trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-03-28 08:11:43 UTC (rev 3753) @@ -109,7 +109,6 @@ if (mapControl.nViews() <= 1) { closeLevel(mapControl); } else { - fireMapViewClosingEvent(mapView); mainControl.getMainView().removeLevelView(mapView); mapControl.closeView(mapView); } @@ -165,7 +164,6 @@ } else { while (mapControl.nViews() > 0) { final MapView<G, A, R, C, V> mapView = mapControl.getMapViewFrame(); - fireMapViewClosingEvent(mapView); mainControl.getMainView().removeLevelView(mapView); mapControl.closeView(mapView); } @@ -312,8 +310,6 @@ public MapView<G, A, R, C, V> mapCreateView(@NotNull final C mapControl, @Nullable final Point viewPosition) { final MapView<G, A, R, C, V> mapView = mapControl.createView(viewPosition); mainControl.getMainView().addLevelView(mapView); - fireMapViewCreatedEvent(mapView); - mainControl.getMainView().setCurrentLevelView(mapView); return mapView; } @@ -383,12 +379,8 @@ } } - /** - * Notify all listeners about a created map view. - * - * @param mapView the created map view - */ - private void fireMapViewCreatedEvent(@NotNull final MapView<G, A, R, C, V> mapView) { + /** {@inheritDoc} */ + public void fireMapViewCreatedEvent(@NotNull final MapView<G, A, R, C, V> mapView) { for (final MapManagerListener<G, A, R, C, V> listener : listenerList.getListeners(MapManagerListener.class)) { listener.mapViewCreated(mapView); } @@ -404,11 +396,8 @@ } } - /** - * Notify all listeners about a map view to be closed. - * @param mapView map view that's being closed - */ - private void fireMapViewClosingEvent(@NotNull final MapView<G, A, R, C, V> mapView) { + /** {@inheritDoc} */ + public void fireMapViewClosingEvent(@NotNull final MapView<G, A, R, C, V> mapView) { for (final MapManagerListener<G, A, R, C, V> listener : listenerList.getListeners(MapManagerListener.class)) { listener.mapViewClosing(mapView); } Modified: trunk/src/app/net/sf/gridarta/MapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/MapManager.java 2008-03-27 21:31:17 UTC (rev 3752) +++ trunk/src/app/net/sf/gridarta/MapManager.java 2008-03-28 08:11:43 UTC (rev 3753) @@ -187,6 +187,19 @@ void fireCurrentMapViewChangedEvent(@Nullable MapView<G, A, R, C, V> currentMapView); /** + * Notify all listeners about a map view to be closed. + * @param mapView map view that's being closed + */ + void fireMapViewClosingEvent(@NotNull MapView<G, A, R, C, V> mapView); + + /** + * Notify all listeners about a created map view. + * + * @param mapView the created map view + */ + void fireMapViewCreatedEvent(@NotNull MapView<G, A, R, C, V> mapView); + + /** * Refreshes all map view of the active map. Does nothing if no map is opened. */ void refreshCurrentMap(); Modified: trunk/src/app/net/sf/gridarta/MapManagerListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/MapManagerListener.java 2008-03-27 21:31:17 UTC (rev 3752) +++ trunk/src/app/net/sf/gridarta/MapManagerListener.java 2008-03-28 08:11:43 UTC (rev 3753) @@ -30,8 +30,18 @@ import org.jetbrains.annotations.Nullable; /** - * Interface for listeners listening to {@link MapManager} changes. - * + * Interface for listeners listening to {@link MapManager} changes. The + * following events are created (in roughly the given order): + * <ul> + * <li>{@link #mapCreated(MapControl)} - after a map has been created or opened + * <li>{@link #currentMapChanged(MapControl)} - the newly created map now is + * the current map + * <li>{@link #mapViewCreated(MapView)} - after a map view has been created + * <li>{@link #currentMapViewChanged(MapView)} - the new map view now is the + * current map view + * <li>{@link #mapViewClosing(MapView)} - the map view has been closed + * <li>{@link #mapClosing(MapControl)} - the map has been closed + * </ul> * @author Andreas Kirschbaum */ public interface MapManagerListener<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, C extends MapControl<G, A, R>, V extends MapViewBasic<G, A, R>> extends EventListener { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-28 22:29:12
|
Revision: 3758 http://gridarta.svn.sourceforge.net/gridarta/?rev=3758&view=rev Author: akirschbaum Date: 2008-03-28 15:28:10 -0700 (Fri, 28 Mar 2008) Log Message: ----------- Rename method name. Modified Paths: -------------- trunk/crossfire/src/cfeditor/MapActions.java trunk/daimonin/src/daieditor/MapActions.java trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java trunk/src/app/net/sf/gridarta/gui/map/MapCursorControl.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java Modified: trunk/crossfire/src/cfeditor/MapActions.java =================================================================== --- trunk/crossfire/src/cfeditor/MapActions.java 2008-03-28 22:20:58 UTC (rev 3757) +++ trunk/crossfire/src/cfeditor/MapActions.java 2008-03-28 22:28:10 UTC (rev 3758) @@ -430,7 +430,7 @@ return null; } - final GameObject selectedExit = mainControl.getMainView().getSelectedSquareControl().getSelectedSquareView().getMapTileSelection(); + final GameObject selectedExit = mainControl.getMainView().getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject(); if (selectedExit != null && CFArchTypeList.isExitType(selectedExit.getHead()) && selectedExit.getHead().getAttributeString("slaying").length() > 0) { return selectedExit.getHead(); } Modified: trunk/daimonin/src/daieditor/MapActions.java =================================================================== --- trunk/daimonin/src/daieditor/MapActions.java 2008-03-28 22:20:58 UTC (rev 3757) +++ trunk/daimonin/src/daieditor/MapActions.java 2008-03-28 22:28:10 UTC (rev 3758) @@ -419,7 +419,7 @@ return null; } - final GameObject selectedExit = mainControl.getMainView().getSelectedSquareControl().getSelectedSquareView().getMapTileSelection(); + final GameObject selectedExit = mainControl.getMainView().getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject(); if (selectedExit != null && CFArchTypeList.isExitType(selectedExit.getHead()) && selectedExit.getHead().getAttributeString("slaying").length() > 0) { return selectedExit.getHead(); } Modified: trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java 2008-03-28 22:20:58 UTC (rev 3757) +++ trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java 2008-03-28 22:28:10 UTC (rev 3758) @@ -589,7 +589,7 @@ /** This method is invoked when the user pressed the "new script" button. */ public void addNewScriptWanted() { - final G gameObject = mainControl.getMainView().getSelectedSquareControl().getSelectedSquareView().getMapTileSelection(); // get selected arch + final G gameObject = mainControl.getMainView().getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject(); // get selected arch if (gameObject != null) { final MapSquare<G, A, R> mapSquare = gameObject.getHead().getMapSquare(); assert mapSquare != null; @@ -607,7 +607,7 @@ * @param task Script type to edit (?). */ public void editScriptWanted(final int task) { - final G gameObject = mainControl.getMainView().getSelectedSquareControl().getSelectedSquareView().getMapTileSelection(); // get selected gameObject + final G gameObject = mainControl.getMainView().getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject(); // get selected gameObject if (gameObject == null) { return; } @@ -640,14 +640,14 @@ * Action method for applying the changes made in the arch panel. */ @ActionMethod public void mapArchApply() { - applyArchPanelChanges(mainView.getSelectedSquareControl().getSelectedSquareView().getMapTileSelection()); + applyArchPanelChanges(mainView.getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject()); } /** * Action method for displaying the attributes of the currently selected object. */ @ActionMethod public void mapArchAttrib() { - mainControl.openAttrDialog(mainView.getSelectedSquareControl().getSelectedSquareView().getMapTileSelection()); + mainControl.openAttrDialog(mainView.getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject()); } /** @@ -659,7 +659,7 @@ return; } - G inv = mainView.getSelectedSquareControl().getSelectedSquareView().getMapTileSelection(); + G inv = mainView.getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject(); if (inv == null) { return; } @@ -851,7 +851,7 @@ * @param direction Direction number */ private void direction(final int direction) { - applyDirectionChanges(mainView.getSelectedSquareControl().getSelectedSquareView().getMapTileSelection(), direction); + applyDirectionChanges(mainView.getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject(), direction); } /** Action method for direction. */ Modified: trunk/src/app/net/sf/gridarta/gui/map/MapCursorControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapCursorControl.java 2008-03-28 22:20:58 UTC (rev 3757) +++ trunk/src/app/net/sf/gridarta/gui/map/MapCursorControl.java 2008-03-28 22:28:10 UTC (rev 3758) @@ -135,7 +135,7 @@ assert mainView != null; final SelectedSquareControl<G, A, R, C, V> selectedSquareControl = mainView.getSelectedSquareControl(); assert selectedSquareControl != null; - final G arch = selectedSquareControl.getSelectedSquareView().getMapTileSelection(); + final G arch = selectedSquareControl.getSelectedSquareView().getSelectedGameObject(); if (arch != null) { mainControl.openAttrDialog(arch); } Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java 2008-03-28 22:20:58 UTC (rev 3757) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java 2008-03-28 22:28:10 UTC (rev 3758) @@ -68,7 +68,7 @@ @Override public void mousePressed(final MouseEvent e) { if (isSelect(e)) { if (e.getClickCount() > 1) { // LMB Double click - mainControl.openAttrDialog(view.getMapTileSelection()); + mainControl.openAttrDialog(view.getSelectedGameObject()); } } else if (isInsert(e)) { insertGameObjectFromObjectChooser(view.getListIndex(e)); @@ -104,7 +104,7 @@ * Action method for moving an arch topmost within its tile. */ @ActionMethod public void moveTileTop() { - final G arch = view.getMapTileSelection(); + final G arch = view.getSelectedGameObject(); if (arch != null) { final MapSquare<G, A, R> mapSquare = arch.getMapSquare(); assert mapSquare != null; @@ -118,7 +118,7 @@ * Action method for moving an arch up within its tile. */ @ActionMethod public void moveTileUp() { - final G arch = view.getMapTileSelection(); + final G arch = view.getSelectedGameObject(); if (arch != null) { final MapSquare<G, A, R> mapSquare = arch.getMapSquare(); assert mapSquare != null; @@ -132,7 +132,7 @@ * Action method for moving an arch down within its tile. */ @ActionMethod public void moveTileDown() { - final G arch = view.getMapTileSelection(); + final G arch = view.getSelectedGameObject(); if (arch != null) { final MapSquare<G, A, R> mapSquare = arch.getMapSquare(); assert mapSquare != null; @@ -146,7 +146,7 @@ * Action method for moving an arch topmost within its tile. */ @ActionMethod public void moveTileBottom() { - final G arch = view.getMapTileSelection(); + final G arch = view.getSelectedGameObject(); if (arch != null) { final MapSquare<G, A, R> mapSquare = arch.getMapSquare(); assert mapSquare != null; @@ -305,7 +305,7 @@ listener.selectedGameObjectChanged(gameObject); } if (mainView.getGameObjectAttributesPanel() != null) { - mainView.getGameObjectAttributesPanel().setSelectedGameObject(view.getMapTileSelection()); + mainView.getGameObjectAttributesPanel().setSelectedGameObject(view.getSelectedGameObject()); } } Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java 2008-03-28 22:20:58 UTC (rev 3757) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java 2008-03-28 22:28:10 UTC (rev 3758) @@ -323,7 +323,7 @@ * Return the currently selected GameObject within this list (currently selected MapSquare). * @return the currently selected GameObject */ - @Nullable public G getMapTileSelection() { + @Nullable public G getSelectedGameObject() { return selectedGameObject; } Modified: trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java 2008-03-28 22:20:58 UTC (rev 3757) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java 2008-03-28 22:28:10 UTC (rev 3758) @@ -303,7 +303,7 @@ // insertion is only allowed for valid *empty* squares if (currentMap != null && isPickmap() && mapModel.isPointValid(pos) && mapModel.getMapSquare(pos).isEmpty()) { // get the currently selected map arch - G newarch = mainControl.getMainView().getSelectedSquareControl().getSelectedSquareView().getMapTileSelection(); + G newarch = mainControl.getMainView().getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject(); if (newarch != null) { newarch = newarch.getHead(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-28 23:03:15
|
Revision: 3760 http://gridarta.svn.sourceforge.net/gridarta/?rev=3760&view=rev Author: akirschbaum Date: 2008-03-28 16:03:06 -0700 (Fri, 28 Mar 2008) Log Message: ----------- Move unrelated code out of try...catch block. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainView.java trunk/daimonin/src/daieditor/CMainView.java Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-03-28 22:38:50 UTC (rev 3759) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-03-28 23:03:06 UTC (rev 3760) @@ -322,30 +322,34 @@ if (!fCareAboutIconification) { try { mapView.setIcon(false); - mapManager.setCurrentLevel(mapView.getMapControl()); - mapView.setVisible(true); + } catch (final PropertyVetoException e) { + log.warn(ACTION_FACTORY.format("logUnexpectedException", e)); + } + mapManager.setCurrentLevel(mapView.getMapControl()); + mapView.setVisible(true); + try { mapView.setSelected(true); - mapView.moveToFront(); - mapDesktop.setSelectedFrame(mapView); - mapView.requestFocus(); - mapView.restoreSubcomponentFocus(); } catch (final PropertyVetoException e) { log.warn(ACTION_FACTORY.format("logUnexpectedException", e)); } + mapView.moveToFront(); + mapDesktop.setSelectedFrame(mapView); + mapView.requestFocus(); + mapView.restoreSubcomponentFocus(); return; } } else { + mapManager.setCurrentLevel(mapView.getMapControl()); + mapView.setVisible(true); try { - mapManager.setCurrentLevel(mapView.getMapControl()); - mapView.setVisible(true); mapView.setSelected(true); - mapView.moveToFront(); - mapDesktop.setSelectedFrame(mapView); - mapView.requestFocus(); - mapView.restoreSubcomponentFocus(); } catch (final PropertyVetoException e) { log.warn(ACTION_FACTORY.format("logUnexpectedException", e)); } + mapView.moveToFront(); + mapDesktop.setSelectedFrame(mapView); + mapView.requestFocus(); + mapView.restoreSubcomponentFocus(); return; } } Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-03-28 22:38:50 UTC (rev 3759) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-03-28 23:03:06 UTC (rev 3760) @@ -331,30 +331,34 @@ if (!fCareAboutIconification) { try { mapView.setIcon(false); - mapManager.setCurrentLevel(mapView.getMapControl()); - mapView.setVisible(true); + } catch (final PropertyVetoException e) { + log.warn(ACTION_FACTORY.format("logUnexpectedException", e)); + } + mapManager.setCurrentLevel(mapView.getMapControl()); + mapView.setVisible(true); + try { mapView.setSelected(true); - mapView.moveToFront(); - mapDesktop.setSelectedFrame(mapView); - mapView.requestFocus(); - mapView.restoreSubcomponentFocus(); } catch (final PropertyVetoException e) { log.warn(ACTION_FACTORY.format("logUnexpectedException", e)); } + mapView.moveToFront(); + mapDesktop.setSelectedFrame(mapView); + mapView.requestFocus(); + mapView.restoreSubcomponentFocus(); return; } } else { + mapManager.setCurrentLevel(mapView.getMapControl()); + mapView.setVisible(true); try { - mapManager.setCurrentLevel(mapView.getMapControl()); - mapView.setVisible(true); mapView.setSelected(true); - mapView.moveToFront(); - mapDesktop.setSelectedFrame(mapView); - mapView.requestFocus(); - mapView.restoreSubcomponentFocus(); } catch (final PropertyVetoException e) { log.warn(ACTION_FACTORY.format("logUnexpectedException", e)); } + mapView.moveToFront(); + mapDesktop.setSelectedFrame(mapView); + mapView.requestFocus(); + mapView.restoreSubcomponentFocus(); return; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-28 23:09:24
|
Revision: 3761 http://gridarta.svn.sourceforge.net/gridarta/?rev=3761&view=rev Author: akirschbaum Date: 2008-03-28 16:08:59 -0700 (Fri, 28 Mar 2008) Log Message: ----------- Move unrelated code out of try...catch block. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainView.java trunk/daimonin/src/daieditor/CMainView.java Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-03-28 23:03:06 UTC (rev 3760) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-03-28 23:08:59 UTC (rev 3761) @@ -397,13 +397,17 @@ if (mapView.isIcon()) { try { mapView.setIcon(false); + } catch (final PropertyVetoException e) { + log.warn(ACTION_FACTORY.format("logUnexpectedException", e)); + } + try { mapView.setSelected(true); - mapView.setVisible(true); - mapView.requestFocus(); - mapView.restoreSubcomponentFocus(); } catch (final PropertyVetoException e) { log.warn(ACTION_FACTORY.format("logUnexpectedException", e)); } + mapView.setVisible(true); + mapView.requestFocus(); + mapView.restoreSubcomponentFocus(); return; } updateFocus(true); Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-03-28 23:03:06 UTC (rev 3760) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-03-28 23:08:59 UTC (rev 3761) @@ -406,13 +406,17 @@ if (mapView.isIcon()) { try { mapView.setIcon(false); + } catch (final PropertyVetoException e) { + log.warn(ACTION_FACTORY.format("logUnexpectedException", e)); + } + try { mapView.setSelected(true); - mapView.setVisible(true); - mapView.requestFocus(); - mapView.restoreSubcomponentFocus(); } catch (final PropertyVetoException e) { log.warn(ACTION_FACTORY.format("logUnexpectedException", e)); } + mapView.setVisible(true); + mapView.requestFocus(); + mapView.restoreSubcomponentFocus(); return; } updateFocus(true); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-28 23:30:46
|
Revision: 3762 http://gridarta.svn.sourceforge.net/gridarta/?rev=3762&view=rev Author: akirschbaum Date: 2008-03-28 16:30:43 -0700 (Fri, 28 Mar 2008) Log Message: ----------- Merge duplicated code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainView.java trunk/daimonin/src/daieditor/CMainView.java trunk/src/app/net/sf/gridarta/gui/MainView.java Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-03-28 23:08:59 UTC (rev 3761) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-03-28 23:30:43 UTC (rev 3762) @@ -88,9 +88,6 @@ /** The controller of this view. */ private final CMainControl mainControl; - /** The map manager. */ - @NotNull private final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager; - /** The panel that contains the object chooser. */ private InsertionObjectChooser objectChooser; @@ -151,7 +148,6 @@ CMainView(@NotNull final CMainControl mainControl, @NotNull final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager, @NotNull final Action aCloseAll) { super(mainControl, mapManager, ACTION_FACTORY.format("mainWindow.title")); this.mainControl = mainControl; - this.mapManager = mapManager; aViewTreasurelists = ACTION_FACTORY.createAction(true, "viewTreasurelists", mainControl); this.aCloseAll = aCloseAll; @@ -325,31 +321,11 @@ } catch (final PropertyVetoException e) { log.warn(ACTION_FACTORY.format("logUnexpectedException", e)); } - mapManager.setCurrentLevel(mapView.getMapControl()); - mapView.setVisible(true); - try { - mapView.setSelected(true); - } catch (final PropertyVetoException e) { - log.warn(ACTION_FACTORY.format("logUnexpectedException", e)); - } - mapView.moveToFront(); - mapDesktop.setSelectedFrame(mapView); - mapView.requestFocus(); - mapView.restoreSubcomponentFocus(); + activateAndRaiseMapView(mapView); return; } } else { - mapManager.setCurrentLevel(mapView.getMapControl()); - mapView.setVisible(true); - try { - mapView.setSelected(true); - } catch (final PropertyVetoException e) { - log.warn(ACTION_FACTORY.format("logUnexpectedException", e)); - } - mapView.moveToFront(); - mapDesktop.setSelectedFrame(mapView); - mapView.requestFocus(); - mapView.restoreSubcomponentFocus(); + activateAndRaiseMapView(mapView); return; } } @@ -400,14 +376,7 @@ } catch (final PropertyVetoException e) { log.warn(ACTION_FACTORY.format("logUnexpectedException", e)); } - try { - mapView.setSelected(true); - } catch (final PropertyVetoException e) { - log.warn(ACTION_FACTORY.format("logUnexpectedException", e)); - } - mapView.setVisible(true); - mapView.requestFocus(); - mapView.restoreSubcomponentFocus(); + activateMapView(mapView); return; } updateFocus(true); Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-03-28 23:08:59 UTC (rev 3761) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-03-28 23:30:43 UTC (rev 3762) @@ -92,9 +92,6 @@ /** The controller of this view. */ private final CMainControl mainControl; - /** The map manager. */ - @NotNull private final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager; - /** The panel that contains the object chooser. */ private InsertionObjectChooser objectChooser; @@ -155,7 +152,6 @@ CMainView(@NotNull final CMainControl mainControl, @NotNull final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager, @NotNull final Action aCloseAll) { super(mainControl, mapManager, ACTION_FACTORY.format("mainWindow.title", CMainControl.getBuildNumberAsString())); this.mainControl = mainControl; - this.mapManager = mapManager; aCollectSpells = ACTION_FACTORY.createAction(true, "collectSpells", mainControl); aViewTreasurelists = ACTION_FACTORY.createAction(true, "viewTreasurelists", mainControl); this.aCloseAll = aCloseAll; @@ -334,31 +330,11 @@ } catch (final PropertyVetoException e) { log.warn(ACTION_FACTORY.format("logUnexpectedException", e)); } - mapManager.setCurrentLevel(mapView.getMapControl()); - mapView.setVisible(true); - try { - mapView.setSelected(true); - } catch (final PropertyVetoException e) { - log.warn(ACTION_FACTORY.format("logUnexpectedException", e)); - } - mapView.moveToFront(); - mapDesktop.setSelectedFrame(mapView); - mapView.requestFocus(); - mapView.restoreSubcomponentFocus(); + activateAndRaiseMapView(mapView); return; } } else { - mapManager.setCurrentLevel(mapView.getMapControl()); - mapView.setVisible(true); - try { - mapView.setSelected(true); - } catch (final PropertyVetoException e) { - log.warn(ACTION_FACTORY.format("logUnexpectedException", e)); - } - mapView.moveToFront(); - mapDesktop.setSelectedFrame(mapView); - mapView.requestFocus(); - mapView.restoreSubcomponentFocus(); + activateAndRaiseMapView(mapView); return; } } @@ -409,14 +385,7 @@ } catch (final PropertyVetoException e) { log.warn(ACTION_FACTORY.format("logUnexpectedException", e)); } - try { - mapView.setSelected(true); - } catch (final PropertyVetoException e) { - log.warn(ACTION_FACTORY.format("logUnexpectedException", e)); - } - mapView.setVisible(true); - mapView.requestFocus(); - mapView.restoreSubcomponentFocus(); + activateMapView(mapView); return; } updateFocus(true); Modified: trunk/src/app/net/sf/gridarta/gui/MainView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-03-28 23:08:59 UTC (rev 3761) +++ trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-03-28 23:30:43 UTC (rev 3762) @@ -22,6 +22,7 @@ import java.awt.BorderLayout; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.beans.PropertyVetoException; import javax.swing.JDesktopPane; import javax.swing.JFrame; import javax.swing.event.InternalFrameListener; @@ -36,6 +37,7 @@ import net.sf.gridarta.help.Help; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; +import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; /** @@ -46,6 +48,9 @@ */ public abstract class MainView<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, C extends MapControl<G, A, R>, V extends MapViewBasic<G, A, R>> extends JFrame implements InternalFrameListener { + /** The Logger for printing log messages. */ + private static final Logger log = Logger.getLogger(MainView.class); + /** The key used to store the main windows x-coordinate to INI file. */ protected static final String WINDOW_X = "MainWindow.x"; @@ -76,6 +81,9 @@ /** Default value for whether the main windows's toolbar is shown. */ public static final boolean SHOW_MAIN_TOOLBAR_DEFAULT = true; + /** The map manager. */ + @NotNull protected final MapManager<G, A, R, C, V> mapManager; + /** The main statusbar. */ private final StatusBar statusBar; @@ -102,6 +110,7 @@ */ protected MainView(@NotNull final MainControl<G, A, R, C, V> mainControl, @NotNull final MapManager<G, A, R, C, V> mapManager, @NotNull final String title) { super(title); + this.mapManager = mapManager; mapFileAction = new MapFileActions<G, A, R, C, V>(mainControl, mapManager, null); statusBar = new StatusBar(mainControl); add(statusBar, BorderLayout.SOUTH); @@ -186,4 +195,30 @@ */ public abstract boolean isAutoJoin(); + /** + * Activate the given map view. + * @param mapView the map view + */ + protected void activateMapView(@NotNull final MapView<G, A, R, C, V> mapView) { + try { + mapView.setSelected(true); + } catch (final PropertyVetoException e) { + log.warn("Unexpected exception", e); + } + mapView.setVisible(true); + mapView.requestFocus(); + mapView.restoreSubcomponentFocus(); + } + + /** + * Activate and raise the given map view. + * @param mapView the map view + */ + protected void activateAndRaiseMapView(@NotNull final MapView<G, A, R, C, V> mapView) { + mapManager.setCurrentLevel(mapView.getMapControl()); + activateMapView(mapView); + mapView.moveToFront(); + mapDesktop.setSelectedFrame(mapView); + } + } // class MainView This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-28 23:38:48
|
Revision: 3763 http://gridarta.svn.sourceforge.net/gridarta/?rev=3763&view=rev Author: akirschbaum Date: 2008-03-28 16:38:48 -0700 (Fri, 28 Mar 2008) Log Message: ----------- Move code to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainView.java trunk/daimonin/src/daieditor/CMainView.java trunk/src/app/net/sf/gridarta/gui/MainView.java Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-03-28 23:30:43 UTC (rev 3762) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-03-28 23:38:48 UTC (rev 3763) @@ -42,7 +42,6 @@ import javax.swing.JPanel; import javax.swing.JSplitPane; import javax.swing.JToolBar; -import javax.swing.event.InternalFrameEvent; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; import net.sf.gridarta.MenuHelper; @@ -384,12 +383,8 @@ mapView.restoreSubcomponentFocus(); } - /** - * Notifies that the level views focus is lost it is inserted - * as the second in line to the level view vector. - * @param mapView the level view who lost the focus - */ - private void levelViewFocusLostNotify(final MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapView) { + /** {@inheritDoc} */ + protected void levelViewFocusLostNotify(final MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapView) { assert mapViews.contains(mapView); if (mapViews.size() <= 1) { return; @@ -401,11 +396,8 @@ updateFocus(true); } - /** - * Notifies that the given level view is now set as the current one. - * @param mapView the new current level view - */ - private void levelViewFocusGainedNotify(final MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapView) { + /** {@inheritDoc} */ + protected void levelViewFocusGainedNotify(final MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapView) { assert mapViews.contains(mapView); mapViews.remove(mapView); mapViews.add(0, mapView); @@ -416,39 +408,6 @@ //statusBar.setLevelInfo(level); } - /** {@inheritDoc} */ - public void internalFrameOpened(final InternalFrameEvent e) { - } - - /** {@inheritDoc} */ - public void internalFrameClosing(final InternalFrameEvent e) { - mapManager.closeView((MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>) e.getInternalFrame()); - } - - /** {@inheritDoc} */ - public void internalFrameClosed(final InternalFrameEvent e) { - } - - /** {@inheritDoc} */ - public void internalFrameIconified(final InternalFrameEvent e) { - final MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapView = (MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>) e.getSource(); - levelViewFocusLostNotify(mapView); - } - - /** {@inheritDoc} */ - public void internalFrameDeiconified(final InternalFrameEvent e) { - } - - /** {@inheritDoc} */ - public void internalFrameActivated(final InternalFrameEvent e) { - final MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapView = (MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>) e.getSource(); - levelViewFocusGainedNotify(mapView); - } - - /** {@inheritDoc} */ - public void internalFrameDeactivated(final InternalFrameEvent e) { - } - /** * Rebuild the window menu. */ Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-03-28 23:30:43 UTC (rev 3762) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-03-28 23:38:48 UTC (rev 3763) @@ -42,7 +42,6 @@ import javax.swing.JPanel; import javax.swing.JSplitPane; import javax.swing.JToolBar; -import javax.swing.event.InternalFrameEvent; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; import net.sf.gridarta.MenuHelper; @@ -393,12 +392,8 @@ mapView.restoreSubcomponentFocus(); } - /** - * Notifies that the level views focus is lost it is inserted - * as the second in line to the level view vector. - * @param mapView the level view who lost the focus - */ - private void levelViewFocusLostNotify(final MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapView) { + /** {@inheritDoc} */ + protected void levelViewFocusLostNotify(final MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapView) { assert mapViews.contains(mapView); if (mapViews.size() <= 1) { return; @@ -410,11 +405,8 @@ updateFocus(true); } - /** - * Notifies that the given level view is now set as the current one. - * @param mapView the new current level view - */ - private void levelViewFocusGainedNotify(final MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapView) { + /** {@inheritDoc} */ + protected void levelViewFocusGainedNotify(final MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapView) { assert mapViews.contains(mapView); mapViews.remove(mapView); mapViews.add(0, mapView); @@ -425,39 +417,6 @@ //statusBar.setLevelInfo(level); } - /** {@inheritDoc} */ - public void internalFrameOpened(final InternalFrameEvent e) { - } - - /** {@inheritDoc} */ - public void internalFrameClosing(final InternalFrameEvent e) { - mapManager.closeView((MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>) e.getInternalFrame()); - } - - /** {@inheritDoc} */ - public void internalFrameClosed(final InternalFrameEvent e) { - } - - /** {@inheritDoc} */ - public void internalFrameIconified(final InternalFrameEvent e) { - final MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapView = (MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>) e.getSource(); - levelViewFocusLostNotify(mapView); - } - - /** {@inheritDoc} */ - public void internalFrameDeiconified(final InternalFrameEvent e) { - } - - /** {@inheritDoc} */ - public void internalFrameActivated(final InternalFrameEvent e) { - final MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapView = (MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>) e.getSource(); - levelViewFocusGainedNotify(mapView); - } - - /** {@inheritDoc} */ - public void internalFrameDeactivated(final InternalFrameEvent e) { - } - /** * Rebuild the window menu. */ Modified: trunk/src/app/net/sf/gridarta/gui/MainView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-03-28 23:30:43 UTC (rev 3762) +++ trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-03-28 23:38:48 UTC (rev 3763) @@ -25,6 +25,7 @@ import java.beans.PropertyVetoException; import javax.swing.JDesktopPane; import javax.swing.JFrame; +import javax.swing.event.InternalFrameEvent; import javax.swing.event.InternalFrameListener; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; @@ -221,4 +222,50 @@ mapDesktop.setSelectedFrame(mapView); } + /** {@inheritDoc} */ + public void internalFrameOpened(final InternalFrameEvent e) { + } + + /** {@inheritDoc} */ + public void internalFrameClosing(final InternalFrameEvent e) { + mapManager.closeView((MapView<G, A, R, C, V>) e.getInternalFrame()); + } + + /** {@inheritDoc} */ + public void internalFrameClosed(final InternalFrameEvent e) { + } + + /** {@inheritDoc} */ + public void internalFrameIconified(final InternalFrameEvent e) { + final MapView<G, A, R, C, V> mapView = (MapView<G, A, R, C, V>) e.getSource(); + levelViewFocusLostNotify(mapView); + } + + /** {@inheritDoc} */ + public void internalFrameDeiconified(final InternalFrameEvent e) { + } + + /** {@inheritDoc} */ + public void internalFrameActivated(final InternalFrameEvent e) { + final MapView<G, A, R, C, V> mapView = (MapView<G, A, R, C, V>) e.getSource(); + levelViewFocusGainedNotify(mapView); + } + + /** {@inheritDoc} */ + public void internalFrameDeactivated(final InternalFrameEvent e) { + } + + /** + * Notifies that the level views focus is lost it is inserted + * as the second in line to the level view vector. + * @param mapView the level view who lost the focus + */ + protected abstract void levelViewFocusLostNotify(final MapView<G, A, R, C, V> mapView); + + /** + * Notifies that the given level view is now set as the current one. + * @param mapView the new current level view + */ + protected abstract void levelViewFocusGainedNotify(final MapView<G, A, R, C, V> mapView); + } // class MainView This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-29 00:03:20
|
Revision: 3764 http://gridarta.svn.sourceforge.net/gridarta/?rev=3764&view=rev Author: akirschbaum Date: 2008-03-28 17:02:58 -0700 (Fri, 28 Mar 2008) Log Message: ----------- Move about dialog to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/About.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-28 23:38:48 UTC (rev 3763) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-29 00:02:58 UTC (rev 3764) @@ -60,6 +60,7 @@ import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.Collector; import net.sf.gridarta.gameobject.face.AbstractFaceObjects; +import net.sf.gridarta.gui.About; import net.sf.gridarta.gui.GUIUtils; import net.sf.gridarta.gui.HideFileFilterProxy; import net.sf.gridarta.gui.MainActions; @@ -262,6 +263,7 @@ ACTION_FACTORY.createActions(true, this, "createNew", "open", "options", "exit", "gc", "onlineHelp", "tod", "about"); mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager()); mainView = new CMainView(this, getMapManager(), mapManagerActions.getCloseAllAction()); + new About("cfeditor", mainView); undoControl = new UndoControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager()); readGlobalSettings(); Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-03-28 23:38:48 UTC (rev 3763) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-03-29 00:02:58 UTC (rev 3764) @@ -54,8 +54,6 @@ import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.ActionMethod; -import net.sf.japi.swing.about.AboutDialog; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -152,7 +150,6 @@ viewActions = new ViewActions(mainControl, mapManager); mapActions = new MapActions(mainControl, mapManager); - initActions(); final ImageIcon icon = GUIUtils.getIcon(IGUIConstants.APP_ICON); if (icon != null) { @@ -424,25 +421,12 @@ } } - /** The AboutDialog. */ - private final AboutDialog aboutDialog = new AboutDialog("cfeditor"); - - /** Action method for about. */ - @ActionMethod public void about() { - aboutDialog.showAboutDialog(this); - } - /** {@inheritDoc} */ @NotNull public GameObjectAttributesPanel getGameObjectAttributesPanel() { return gameObjectAttributesPanel; } /** {@inheritDoc} */ - @Override protected void initActions() { - ACTION_FACTORY.createActions(true, this, "about"); - } - - /** {@inheritDoc} */ @NotNull public SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> getSelectedSquareControl() { return selectedSquareControl; } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-03-28 23:38:48 UTC (rev 3763) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-03-29 00:02:58 UTC (rev 3764) @@ -68,6 +68,7 @@ import net.sf.gridarta.gameobject.face.AbstractFaceObjects; import net.sf.gridarta.gameobject.match.MutableOrGameObjectMatcher; import net.sf.gridarta.gameobject.match.ViewGameObjectMatcherManager; +import net.sf.gridarta.gui.About; import net.sf.gridarta.gui.GUIUtils; import net.sf.gridarta.gui.HideFileFilterProxy; import net.sf.gridarta.gui.MainActions; @@ -315,6 +316,7 @@ ACTION_FACTORY.createToggles(true, this, "drawDouble"); mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager()); mainView = new CMainView(this, getMapManager(), mapManagerActions.getCloseAllAction()); + new About("daieditor", mainView); undoControl = new UndoControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager()); updaterManager = new UpdaterManager("daieditor", this, mainView); updaterManager.startup(); Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-03-28 23:38:48 UTC (rev 3763) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-03-29 00:02:58 UTC (rev 3764) @@ -54,8 +54,6 @@ import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.ActionMethod; -import net.sf.japi.swing.about.AboutDialog; import net.sf.japi.util.ThrowableHandler; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; @@ -156,7 +154,6 @@ this.aCloseAll = aCloseAll; mapActions = new MapActions(mainControl, mapManager); - initActions(); final ImageIcon icon = GUIUtils.getIcon(IGUIConstants.APP_ICON); if (icon != null) { @@ -433,25 +430,12 @@ } } - /** The AboutDialog. */ - private final AboutDialog aboutDialog = new AboutDialog("daieditor"); - - /** Action method for about. */ - @ActionMethod public void about() { - aboutDialog.showAboutDialog(this); - } - /** {@inheritDoc} */ @NotNull public GameObjectAttributesPanel getGameObjectAttributesPanel() { return gameObjectAttributesPanel; } /** {@inheritDoc} */ - @Override protected void initActions() { - ACTION_FACTORY.createActions(true, this, "about"); - } - - /** {@inheritDoc} */ @NotNull public SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> getSelectedSquareControl() { return selectedSquareControl; } Added: trunk/src/app/net/sf/gridarta/gui/About.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/About.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/About.java 2008-03-29 00:02:58 UTC (rev 3764) @@ -0,0 +1,57 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui; + +import java.awt.Component; +import net.sf.japi.swing.ActionFactory; +import net.sf.japi.swing.ActionMethod; +import net.sf.japi.swing.about.AboutDialog; +import org.jetbrains.annotations.NotNull; + +/** + * The about dialog. + * @author Andreas Kirschbaum + */ +public class About { + + /** The AboutDialog. */ + private final AboutDialog aboutDialog; + + /** The parent component for the about dialog. */ + private final Component parent; + + /** + * Creates a new instance. + * @param key the action factory key + * @param parent the parent component for the about dialog + */ + public About(@NotNull final String key, @NotNull final Component parent) { + aboutDialog = new AboutDialog(key); + this.parent = parent; + final ActionFactory actionFactory = ActionFactory.getFactory(key); + actionFactory.createAction(true, "about", this); + } + + /** Action method for about. */ + @ActionMethod public void about() { + aboutDialog.showAboutDialog(parent); + } + +} // class About Property changes on: trunk/src/app/net/sf/gridarta/gui/About.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-03-29 10:47:51
|
Revision: 3766 http://gridarta.svn.sourceforge.net/gridarta/?rev=3766&view=rev Author: akirschbaum Date: 2008-03-29 03:47:56 -0700 (Sat, 29 Mar 2008) Log Message: ----------- Do not hard-code the name of the file being updated. Modified Paths: -------------- trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/messages.properties trunk/src/app/net/sf/gridarta/messages_de.properties trunk/src/app/net/sf/gridarta/messages_sv.properties trunk/src/app/net/sf/gridarta/updater/Updater.java trunk/src/app/net/sf/gridarta/updater/UpdaterManager.java Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-03-29 09:22:37 UTC (rev 3765) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-03-29 10:47:56 UTC (rev 3766) @@ -318,7 +318,7 @@ mainView = new CMainView(this, getMapManager(), mapManagerActions.getCloseAllAction()); new About("daieditor", mainView); undoControl = new UndoControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager()); - updaterManager = new UpdaterManager("daieditor", this, mainView); + updaterManager = new UpdaterManager("daieditor", this, mainView, "DaimoninEditor.jar"); updaterManager.startup(); readGlobalSettings(); Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2008-03-29 09:22:37 UTC (rev 3765) +++ trunk/src/app/net/sf/gridarta/messages.properties 2008-03-29 10:47:56 UTC (rev 3766) @@ -829,13 +829,13 @@ updateUnavailable.title=No update available updateUnavailable.message=<html><style type="text/css">.cell'{border-width:1px;border-style:solid;border-color:#000000;background-color:#FFFFFF;color:#000000;}'</style><table><tr><td></td><th class="cell">Installed</th><th class="cell">Available</th></tr><tr><th class="cell">Version</th><td class="cell">{0}</td><td class="cell">{1}</td></tr><tr><th class="cell">Developer</th><td class="cell">{2}</td><td class="cell">{3}</td></tr><tr><th class="cell">Timestamp</th><td class="cell">{4}</td><td class="cell">{5}</td></tr></table><p align="center">No newer version available.</p><p>Source: {6}<br>Download: {7}</p></html> updateAvailable.title=Update available! -updateAvailable.message=<html><style type="text/css">.cell'{border-width:1px;border-style:solid;border-color:#000000;background-color:#FFFFFF;color:#000000;}'</style><table><tr><td></td><th class="cell">Installed</th><th class="cell">Available</th></tr><tr><th class="cell">Version</th><td class="cell">{0}</td><td class="cell">{1}</td></tr><tr><th class="cell">Developer</th><td class="cell">{2}</td><td class="cell">{3}</td></tr><tr><th class="cell">Timestamp</th><td class="cell">{4}</td><td class="cell">{5}</td></tr></table><p align="center">A newer version is available. Install update?</p><p>Note: This will only update DaimoninEditor.jar. Your arches will not be updated.</p><p>(The editor will not be useable while the update is in progress)</p><p>Source: {6}<br>Download: {7}</p></html> +updateAvailable.message=<html><style type="text/css">.cell'{border-width:1px;border-style:solid;border-color:#000000;background-color:#FFFFFF;color:#000000;}'</style><table><tr><td></td><th class="cell">Installed</th><th class="cell">Available</th></tr><tr><th class="cell">Version</th><td class="cell">{1}</td><td class="cell">{2}</td></tr><tr><th class="cell">Developer</th><td class="cell">{3}</td><td class="cell">{4}</td></tr><tr><th class="cell">Timestamp</th><td class="cell">{5}</td><td class="cell">{6}</td></tr></table><p align="center">A newer version is available. Install update?</p><p>Note: This will only update {0}. Your arches will not be updated.</p><p>(The editor will not be useable while the update is in progress)</p><p>Source: {7}<br>Download: {8}</p></html> updateFailedNoBackup.title=Update failed -updateFailedNoBackup.message=<html>Could not create backup, update failed.<br>Please do the following steps manually after exiting the editor:<ol><li>rename DaimoninEditor.jar to DaimoninEditor.jar.bak<li>rename DaimoninEditor.jar.tmp to DaimoninEditor.jar</ol></html> +updateFailedNoBackup.message=<html>Could not create backup, update failed.<br>Please do the following steps manually after exiting the editor:<ol><li>rename {0} to {0}.bak<li>rename {0}.tmp to {0}</ol></html> updateFailedNoDownload.title=Update failed updateFailedNoDownload.message=Could not use download, update failed. updateRestart.title=Update successful -updateRestart.message=Update successful.\nI have stored a backup of the previous version under "DaimoninEditor.jar.bak".\n\nThe editor automatically exits after updating.\nYou have to restart it yourself in case you want to use it now. +updateRestart.message=Update successful.\nI have stored a backup of the previous version under "{0}.bak".\n\nThe editor automatically exits after updating.\nYou have to restart it yourself in case you want to use it now. updateAborted.title=Update aborted updateAborted.message=Update aborted on your request. updateProgress.title=Update Modified: trunk/src/app/net/sf/gridarta/messages_de.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_de.properties 2008-03-29 09:22:37 UTC (rev 3765) +++ trunk/src/app/net/sf/gridarta/messages_de.properties 2008-03-29 10:47:56 UTC (rev 3766) @@ -695,13 +695,13 @@ updateUnavailable.title=Kein Update verf\xFCgbar updateUnavailable.message=<html><style type="text/css">.cell'{border-width:1px;border-style:solid;border-color:#000000;background-color:#FFFFFF;color:#000000;}'</style><table><tr><td></td><th class="cell">Installiert</th><th class="cell">Verf\xFCgbar</th></tr><tr><th class="cell">Version</th><td class="cell">{0}</td><td class="cell">{1}</td></tr><tr><th class="cell">Entwickler</th><td class="cell">{2}</td><td class="cell">{3}</td></tr><tr><th class="cell">Datum</th><td class="cell">{4}</td><td class="cell">{5}</td></tr></table><p align="center">Keine neuere Version verf\xFCgbar.</p><p>Quelle: {6}<br>Download: {7}</p></html> updateAvailable.title=Update verf\xFCgbar! -updateAvailable.message=<html><style type="text/css">.cell'{border-width:1px;border-style:solid;border-color:#000000;background-color:#FFFFFF;color:#000000;}'</style><table><tr><td></td><th class="cell">Installiert</th><th class="cell">Verf\xFCgbar</th></tr><tr><th class="cell">Version</th><td class="cell">{1}</td><td class="cell">{2}</td></tr><tr><th class="cell">Entwickler</th><td class="cell">{3}</td><td class="cell">{4}</td></tr><tr><th class="cell">Datum</th><td class="cell">{5}</td><td class="cell">{6}</td></tr></table><p align="center">Eine neuere Version des Editors ist verf\xFCgbar. Update installieren?</p><p>Anmerkung: Es wird nur DaimoninEditor.jar aktualisiert. Die Archetypen werden nicht aktualisiert.</p><p>(Der Editor kann nicht benutzt werden, solange die Aktualisierung l\xE4uft)</p><p>Quelle: {7}<br>Download: {8}</p></html> +updateAvailable.message=<html><style type="text/css">.cell'{border-width:1px;border-style:solid;border-color:#000000;background-color:#FFFFFF;color:#000000;}'</style><table><tr><td></td><th class="cell">Installiert</th><th class="cell">Verf\xFCgbar</th></tr><tr><th class="cell">Version</th><td class="cell">{1}</td><td class="cell">{2}</td></tr><tr><th class="cell">Entwickler</th><td class="cell">{3}</td><td class="cell">{4}</td></tr><tr><th class="cell">Datum</th><td class="cell">{5}</td><td class="cell">{6}</td></tr></table><p align="center">Eine neuere Version des Editors ist verf\xFCgbar. Update installieren?</p><p>Anmerkung: Es wird nur {0} aktualisiert. Die Archetypen werden nicht aktualisiert.</p><p>(Der Editor kann nicht benutzt werden, solange die Aktualisierung l\xE4uft)</p><p>Quelle: {7}<br>Download: {8}</p></html> updateFailedNoBackup.title=Aktualisierung fehlgeschlagen -updateFailedNoBackup.message=<html>Konnte keine Backup-Datei anlegen, Aktualisierung fehlgeschlagen.<br>Bitte f\xFChren Sie folgende Schritte manuell aus, nachdem Sie den Editor geschlossen haben:<ol><li>Nennen Sie DaimoninEditor.jar in DaimoninEditor.jar.bak um<li>Nennen Sie DaimoninEditor.jar.tmp in DaimoninEditor.jar um</ol></html> +updateFailedNoBackup.message=<html>Konnte keine Backup-Datei anlegen, Aktualisierung fehlgeschlagen.<br>Bitte f\xFChren Sie folgende Schritte manuell aus, nachdem Sie den Editor geschlossen haben:<ol><li>Nennen Sie {0} in {0}.bak um<li>Nennen Sie {0}.tmp in {0} um</ol></html> updateFailedNoDownload.title=Aktualisierung fehlgeschlagen updateFailedNoDownload.message=Download fehlgeschlagen, Aktualisierung fehlgeschlagen. updateRestart.title=Aktualisierung erfolgreich -updateRestart.message=Aktualisierung erfolgreich.\nDie vorherige Version des Editors ist als "DaimoninEditor.jar.bak" verf\xFCgbar.\n\nDer Editor beendet sich jetzt automatisch.\nBitte starten Sie ihn erneut. +updateRestart.message=Aktualisierung erfolgreich.\nDie vorherige Version des Editors ist als "{0}.bak" verf\xFCgbar.\n\nDer Editor beendet sich jetzt automatisch.\nBitte starten Sie ihn erneut. updateAborted.title=Aktualisierung abgebrochen updateAborted.message=Sie haben die Aktualisierung abgebrochen. updateProgress.title=Aktualisierung Modified: trunk/src/app/net/sf/gridarta/messages_sv.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-03-29 09:22:37 UTC (rev 3765) +++ trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-03-29 10:47:56 UTC (rev 3766) @@ -693,13 +693,13 @@ updateUnavailable.title=Ingen ny uppdatering tillg\xE4nglig updateUnavailable.message=<html><style type="text/css">.cell'{border-width:1px;border-style:solid;border-color:#000000;background-color:#FFFFFF;color:#000000;}'</style><table><tr><td></td><th class="cell">Installerad</th><th class="cell">Tillg\xE4nglig</th></tr><tr><th class="cell">Version</th><td class="cell">{0}</td><td class="cell">{1}</td></tr><tr><th class="cell">Utvecklare</th><td class="cell">{2}</td><td class="cell">{3}</td></tr><tr><th class="cell">Datum</th><td class="cell">{4}</td><td class="cell">{5}</td></tr></table><p align="center">Ingen nyare version hittad.</p><p>K\xE4lla: {6}<br>Ladda ner: {7}</p></html> updateAvailable.title=Uppdatering tillg\xE4nglig! -updateAvailable.message=<html><style type="text/css">.cell'{border-width:1px;border-style:solid;border-color:#000000;background-color:#FFFFFF;color:#000000;}'</style><table><tr><td></td><th class="cell">Installerad</th><th class="cell">Tillg\xE4nglig</th></tr><tr><th class="cell">Version</th><td class="cell">{0}</td><td class="cell">{1}</td></tr><tr><th class="cell">Utvecklare</th><td class="cell">{2}</td><td class="cell">{3}</td></tr><tr><th class="cell">Datum</th><td class="cell">{4}</td><td class="cell">{5}</td></tr></table><p align="center">En nyare version \xE4r tillg\xE4nglig. Installera uppdatering?</p><p>OBS: Detta uppdaterar enbart DaimoninEditor.jar. Dina arketypfiler kommer inte att uppdateras.</p><p>(Editorn kan inte anv\xE4ndas medan uppdatering p\xE5g\xE5r)</p><p>K\xE4lla: {6}<br>Nerladdning: {7}</p></html> +updateAvailable.message=<html><style type="text/css">.cell'{border-width:1px;border-style:solid;border-color:#000000;background-color:#FFFFFF;color:#000000;}'</style><table><tr><td></td><th class="cell">Installerad</th><th class="cell">Tillg\xE4nglig</th></tr><tr><th class="cell">Version</th><td class="cell">{1}</td><td class="cell">{2}</td></tr><tr><th class="cell">Utvecklare</th><td class="cell">{3}</td><td class="cell">{4}</td></tr><tr><th class="cell">Datum</th><td class="cell">{5}</td><td class="cell">{6}</td></tr></table><p align="center">En nyare version \xE4r tillg\xE4nglig. Installera uppdatering?</p><p>OBS: Detta uppdaterar enbart {0}. Dina arketypfiler kommer inte att uppdateras.</p><p>(Editorn kan inte anv\xE4ndas medan uppdatering p\xE5g\xE5r)</p><p>K\xE4lla: {7}<br>Nerladdning: {8}</p></html> updateFailedNoBackup.title=Uppdatering misslyckades -updateFailedNoBackup.message=<html>Kunde inte skapa s\xE4kerhetskopia, updatering misslyckades.<br>Var v\xE4nlig utf\xF6r f\xF6ljande steg manuellt efter att avslutat editorn:<ol><li>d\xF6p om DaimoninEditor.jar till DaimoninEditor.jar.bak<li>d\xF6p om DaimoninEditor.jar.tmp till DaimoninEditor.jar</ol></html> +updateFailedNoBackup.message=<html>Kunde inte skapa s\xE4kerhetskopia, updatering misslyckades.<br>Var v\xE4nlig utf\xF6r f\xF6ljande steg manuellt efter att avslutat editorn:<ol><li>d\xF6p om {0} till {0}.bak<li>d\xF6p om {0}.tmp till {0}</ol></html> updateFailedNoDownload.title=Uppdatering misslyckades updateFailedNoDownload.message=Kunde inte anv\xE4nda den nerladdade filen. updateRestart.title=Uppdatering lyckades -updateRestart.message=Uppdatering lyckades.\nJag har lagrat en s\xE4kerhetskopia av den gamla versionen som "DaimoninEditor.jar.bak".\n\nEditorn kommer nu att avslutas automatiskt.\nDu m\xE5ste starta om den sj\xE4lv om du vill forts\xE4tta arbeta med den nya versionen. +updateRestart.message=Uppdatering lyckades.\nJag har lagrat en s\xE4kerhetskopia av den gamla versionen som "{0}.bak".\n\nEditorn kommer nu att avslutas automatiskt.\nDu m\xE5ste starta om den sj\xE4lv om du vill forts\xE4tta arbeta med den nya versionen. updateAborted.title=Uppdatering avbruten updateAborted.message=Uppdatering avbruten p\xE5 din beg\xE4ran. #updateProgress.title= Modified: trunk/src/app/net/sf/gridarta/updater/Updater.java =================================================================== --- trunk/src/app/net/sf/gridarta/updater/Updater.java 2008-03-29 09:22:37 UTC (rev 3765) +++ trunk/src/app/net/sf/gridarta/updater/Updater.java 2008-03-29 10:47:56 UTC (rev 3766) @@ -68,6 +68,9 @@ /** The main control. */ private final MainControl mainControl; + /** The file to update. */ + private final String updateFileName; + /** Buffer size. */ private static final int BUF_SIZE = 4096; @@ -76,11 +79,13 @@ * @param parentComponent Component to show dialogs on * @param mainControl The main control. * @param key the action factory key + * @param updateFileName the file to update */ - public Updater(final Component parentComponent, final MainControl mainControl, final String key) { + public Updater(final Component parentComponent, final MainControl mainControl, final String key, final String updateFileName) { ACTION_FACTORY = ActionFactory.getFactory(key); this.parentComponent = parentComponent; this.mainControl = mainControl; + this.updateFileName = updateFileName; if (parentComponent != null) { parentComponent.setEnabled(false); } @@ -135,6 +140,7 @@ private boolean askIfUserWantsUpdate(final VersionInfo active, final VersionInfo update, final String propUrl, final String downloadUrl) { return ACTION_FACTORY.showConfirmDialog(parentComponent, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, "updateAvailable", + updateFileName, active.version, update.version, active.developer, update.developer, active.tstamp, update.tstamp, @@ -163,9 +169,9 @@ * @param url URL to get update from */ private void downloadAndInstallUpdate(final String url) { - final File download = new File("DaimoninEditor.jar.tmp"); // TODO: print error message if file already exists - final File backup = new File("DaimoninEditor.jar.bak"); - final File orig = new File("DaimoninEditor.jar"); + final File download = new File(updateFileName + ".tmp"); // TODO: print error message if file already exists + final File backup = new File(updateFileName + ".bak"); + final File orig = new File(updateFileName); try { final InputStream in = openStream(url); try { @@ -177,12 +183,12 @@ } out.close(); if (/* !backup.delete() || */ !orig.renameTo(backup)) { - ACTION_FACTORY.showMessageDialog(parentComponent, "updateFailedNoBackup"); + ACTION_FACTORY.showMessageDialog(parentComponent, "updateFailedNoBackup", updateFileName); } else if (!download.renameTo(orig)) { backup.renameTo(orig); ACTION_FACTORY.showMessageDialog(parentComponent, "updateFailedNoDownload"); } else { - ACTION_FACTORY.showMessageDialog(parentComponent, "updateRestart"); + ACTION_FACTORY.showMessageDialog(parentComponent, "updateRestart", updateFileName); mainControl.doExit(); } } finally { Modified: trunk/src/app/net/sf/gridarta/updater/UpdaterManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/updater/UpdaterManager.java 2008-03-29 09:22:37 UTC (rev 3765) +++ trunk/src/app/net/sf/gridarta/updater/UpdaterManager.java 2008-03-29 10:47:56 UTC (rev 3766) @@ -68,15 +68,22 @@ private final Component parentComponent; /** + * The file to update. + */ + private final String updateFileName; + + /** * Creates a new instance. * @param key the action factory key * @param mainControl The main control. * @param parentComponent Component to show dialogs on + * @param updateFileName the file to update */ - public UpdaterManager(final String key, final MainControl mainControl, final Component parentComponent) { + public UpdaterManager(final String key, final MainControl mainControl, final Component parentComponent, final String updateFileName) { this.key = key; this.mainControl = mainControl; this.parentComponent = parentComponent; + this.updateFileName = updateFileName; } /** @@ -97,7 +104,7 @@ * Perform an update. */ public void update() { - new Thread(new Updater(parentComponent, mainControl, key)).start(); + new Thread(new Updater(parentComponent, mainControl, key, updateFileName)).start(); } } // class UpdaterManager This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-29 11:10:26
|
Revision: 3767 http://gridarta.svn.sourceforge.net/gridarta/?rev=3767&view=rev Author: akirschbaum Date: 2008-03-29 04:10:29 -0700 (Sat, 29 Mar 2008) Log Message: ----------- Move 'update' action to common code base. Modified Paths: -------------- trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/updater/UpdaterManager.java Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-03-29 10:47:56 UTC (rev 3766) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-03-29 11:10:29 UTC (rev 3767) @@ -312,7 +312,7 @@ instance = this; archetypeSet = new ArchetypeSet(this); mapCursorControl = new MapCursorControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>("daieditor", this, getMapManager()); - ACTION_FACTORY.createActions(true, this, "createNew", "open", "options", "exit", "newScript", "editScript", "controlServer", "controlClient", "cleanCompletelyBlockedSquares", "zoom", "gc", "onlineHelp", "tod", "about", "update"); + ACTION_FACTORY.createActions(true, this, "createNew", "open", "options", "exit", "newScript", "editScript", "controlServer", "controlClient", "cleanCompletelyBlockedSquares", "zoom", "gc", "onlineHelp", "tod", "about"); ACTION_FACTORY.createToggles(true, this, "drawDouble"); mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager()); mainView = new CMainView(this, getMapManager(), mapManagerActions.getCloseAllAction()); @@ -1148,15 +1148,6 @@ return mapDir; } - /** Update wanted. */ - public void update() { - if (getMapManager().hasOpenedMap()) { - ACTION_FACTORY.showMessageDialog(mainView, "updateCloseMaps"); - } else { - updaterManager.update(); - } - } - /** {@inheritDoc} */ public CFArchTypeList getTypeList() { return typeList; Modified: trunk/src/app/net/sf/gridarta/updater/UpdaterManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/updater/UpdaterManager.java 2008-03-29 10:47:56 UTC (rev 3766) +++ trunk/src/app/net/sf/gridarta/updater/UpdaterManager.java 2008-03-29 11:10:29 UTC (rev 3767) @@ -21,6 +21,8 @@ import java.awt.Component; import java.util.prefs.Preferences; +import javax.swing.Action; +import net.sf.japi.swing.ActionFactory; import net.sf.gridarta.MainControl; /** @@ -29,6 +31,9 @@ */ public final class UpdaterManager { + /** Action Factory. */ + private final ActionFactory ACTION_FACTORY; + /** Preferences. */ private static final Preferences PREFS = Preferences.userNodeForPackage(MainControl.class); @@ -72,6 +77,9 @@ */ private final String updateFileName; + /** Action for "update". */ + private final Action aUpdate; + /** * Creates a new instance. * @param key the action factory key @@ -80,10 +88,15 @@ * @param updateFileName the file to update */ public UpdaterManager(final String key, final MainControl mainControl, final Component parentComponent, final String updateFileName) { + ACTION_FACTORY = ActionFactory.getFactory(key); this.key = key; this.mainControl = mainControl; this.parentComponent = parentComponent; this.updateFileName = updateFileName; + aUpdate = ACTION_FACTORY.createAction(true, "update", this); + + final String propUrl = ACTION_FACTORY.getString("update.url"); + aUpdate.setEnabled(propUrl.length() > 0); } /** @@ -104,7 +117,11 @@ * Perform an update. */ public void update() { - new Thread(new Updater(parentComponent, mainControl, key, updateFileName)).start(); + if (mainControl.getMapManager().hasOpenedMap()) { + ACTION_FACTORY.showMessageDialog(parentComponent, "updateCloseMaps"); + } else { + new Thread(new Updater(parentComponent, mainControl, key, updateFileName)).start(); + } } } // class UpdaterManager This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-29 11:27:38
|
Revision: 3769 http://gridarta.svn.sourceforge.net/gridarta/?rev=3769&view=rev Author: akirschbaum Date: 2008-03-29 04:27:43 -0700 (Sat, 29 Mar 2008) Log Message: ----------- Move UpdatePrefs to common code base. Modified Paths: -------------- trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/action.properties trunk/daimonin/src/daieditor/messages.properties trunk/daimonin/src/daieditor/messages_de.properties trunk/daimonin/src/daieditor/messages_fr.properties trunk/daimonin/src/daieditor/messages_sv.properties trunk/src/app/net/sf/gridarta/action.properties trunk/src/app/net/sf/gridarta/messages.properties trunk/src/app/net/sf/gridarta/messages_de.properties trunk/src/app/net/sf/gridarta/messages_fr.properties trunk/src/app/net/sf/gridarta/messages_sv.properties Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/prefs/UpdatePrefs.java Removed Paths: ------------- trunk/daimonin/src/daieditor/gui/prefs/UpdatePrefs.java Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-03-29 11:13:34 UTC (rev 3768) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-03-29 11:27:43 UTC (rev 3769) @@ -31,7 +31,6 @@ import daieditor.gui.prefs.GUIPrefs; import daieditor.gui.prefs.NetPrefs; import daieditor.gui.prefs.ResPrefs; -import daieditor.gui.prefs.UpdatePrefs; import daieditor.map.MapArchObject; import daieditor.map.MapControl; import daieditor.map.validation.checks.ExitChecker; @@ -81,6 +80,7 @@ import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.prefs.MapValidatorPrefs; import net.sf.gridarta.gui.prefs.MiscPrefs; +import net.sf.gridarta.gui.prefs.UpdatePrefs; import net.sf.gridarta.gui.undo.UndoControl; import net.sf.gridarta.io.IOUtils; import net.sf.gridarta.map.AutoValidator; Modified: trunk/daimonin/src/daieditor/action.properties =================================================================== --- trunk/daimonin/src/daieditor/action.properties 2008-03-29 11:13:34 UTC (rev 3768) +++ trunk/daimonin/src/daieditor/action.properties 2008-03-29 11:27:43 UTC (rev 3769) @@ -159,7 +159,6 @@ prefsDev.icon=development/Server24 prefsRes.icon=general/Save24 prefsGUI.icon=development/Host24 -prefsUpdate.icon=general/Search24 ################ # Other Strings Deleted: trunk/daimonin/src/daieditor/gui/prefs/UpdatePrefs.java =================================================================== --- trunk/daimonin/src/daieditor/gui/prefs/UpdatePrefs.java 2008-03-29 11:13:34 UTC (rev 3768) +++ trunk/daimonin/src/daieditor/gui/prefs/UpdatePrefs.java 2008-03-29 11:27:43 UTC (rev 3769) @@ -1,150 +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.prefs; - -import java.awt.Component; -import java.util.prefs.Preferences; -import javax.swing.Box; -import javax.swing.JCheckBox; -import javax.swing.JComboBox; -import javax.swing.border.Border; -import javax.swing.border.CompoundBorder; -import javax.swing.border.TitledBorder; -import net.sf.gridarta.MainControl; -import net.sf.gridarta.gui.GUIConstants; -import net.sf.gridarta.updater.UpdaterManager; -import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.prefs.AbstractPrefs; - -/** - * Preferences Module for update preferences. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @serial exclude - */ -public final class UpdatePrefs extends AbstractPrefs { - - /** The serial version UID. */ - private static final long serialVersionUID = 1; - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); - - /** Preferences. */ - private static final Preferences PREFS = Preferences.userNodeForPackage(MainControl.class); - - /** Checkbox whether to automatically check for updates on startup. */ - private JCheckBox autoUpdate; - - /** ComboBox with selected interval. */ - private JComboBox interval; - - /** Create an UpdatePrefs pane. */ - public UpdatePrefs() { - setListLabelText(ACTION_FACTORY.getString("prefsUpdate.title")); - setListLabelIcon(ACTION_FACTORY.getIcon("prefsUpdate.icon")); - - add(createUpdatePanel()); - add(Box.createVerticalGlue()); - } - - /** - * Create a titled border. - * @param titleKey Action Key for border title - * @return titled border - */ - private static Border createTitledBorder(final String titleKey) { - return new CompoundBorder(new TitledBorder(ACTION_FACTORY.getString(titleKey)), GUIConstants.DIALOG_BORDER); - } - - /** {@inheritDoc} */ - public void apply() { - PREFS.putBoolean(UpdaterManager.AUTO_CHECK_KEY, autoUpdate.isSelected()); - PREFS.putInt(UpdaterManager.INTERVAL_KEY, interval.getSelectedIndex()); - } - - /** {@inheritDoc} */ - public void revert() { - autoUpdate.setSelected(PREFS.getBoolean(UpdaterManager.AUTO_CHECK_KEY, UpdaterManager.AUTO_CHECK_DEFAULT)); - interval.setSelectedIndex(PREFS.getInt(UpdaterManager.INTERVAL_KEY, UpdaterManager.INTERVAL_DEFAULT)); - } - - /** {@inheritDoc} */ - public void defaults() { - autoUpdate.setSelected(UpdaterManager.AUTO_CHECK_DEFAULT); - interval.setSelectedIndex(UpdaterManager.INTERVAL_DEFAULT); - } - - /** {@inheritDoc} */ - public boolean isChanged() { - return !( - autoUpdate.isSelected() == PREFS.getBoolean(UpdaterManager.AUTO_CHECK_KEY, UpdaterManager.AUTO_CHECK_DEFAULT) - && interval.getSelectedIndex() == PREFS.getInt(UpdaterManager.INTERVAL_KEY, UpdaterManager.INTERVAL_DEFAULT) - ); - } - - /** - * Creates the subpanel with the update settings. - * @return subpanel - */ - private Component createUpdatePanel() { - final Box updatePanel = Box.createVerticalBox(); - updatePanel.setBorder(createTitledBorder("optionsUpdate")); - autoUpdate = new JCheckBox(ACTION_FACTORY.createToggle(false, "autoUpdate", this)); - autoUpdate.setSelected(PREFS.getBoolean(UpdaterManager.AUTO_CHECK_KEY, UpdaterManager.AUTO_CHECK_DEFAULT)); - updatePanel.add(autoUpdate); - updatePanel.add(createComboBox()); - return updatePanel; - } - - /** - * Set AutoUpdate state. - * @param autoUpdate autoupdate state - */ - public void setAutoUpdate(final boolean autoUpdate) { - interval.setEnabled(autoUpdate); - } - - /** - * Get AutoUpdate state. - * @return autoupdate state - */ - public boolean isAutoUpdate() { - return interval.isEnabled(); - } - - /** - * Create the JComboBox with the update choices. - * @return JComboBox with update choices - */ - private JComboBox createComboBox() { - final String[] items = new String[]{ - ACTION_FACTORY.getString("prefsUpdateAuto0.text"), - ACTION_FACTORY.getString("prefsUpdateAuto1.text"), - ACTION_FACTORY.getString("prefsUpdateAuto2.text"), - ACTION_FACTORY.getString("prefsUpdateAuto3.text"), - }; - interval = new JComboBox(items); - interval.setEditable(false); - interval.setSelectedIndex(PREFS.getInt(UpdaterManager.INTERVAL_KEY, UpdaterManager.INTERVAL_DEFAULT)); - interval.setEnabled(PREFS.getBoolean(UpdaterManager.AUTO_CHECK_KEY, UpdaterManager.AUTO_CHECK_DEFAULT)); - return interval; - } - -} // class UpdatePrefs Modified: trunk/daimonin/src/daieditor/messages.properties =================================================================== --- trunk/daimonin/src/daieditor/messages.properties 2008-03-29 11:13:34 UTC (rev 3768) +++ trunk/daimonin/src/daieditor/messages.properties 2008-03-29 11:27:43 UTC (rev 3769) @@ -165,7 +165,6 @@ # Options optionsTitle=Options -optionsUpdate=Automatic Update optionsLoadArchColl.text=Load Arches from Collection optionsResMedia=Media optionsResMedia.shortdescription=<html>The media directory is for choosing background sounds for maps.<br>Please know that you cannot simply choose any media directory you want.<br>The background sound will only work if the files exist on the client as well.<br>Therefore, choosing a standard daimonin media directory is crucial.</html> @@ -528,15 +527,8 @@ prefsApp.title=External applications prefsDev.title=Developers -prefsUpdate.title=Update -autoUpdate.text=Automatically check for updates on startup? -prefsUpdateAuto0.text=Every startup -prefsUpdateAuto1.text=Once a day -prefsUpdateAuto2.text=Once a week -prefsUpdateAuto3.text=Once a month - ################# # Map Validation Modified: trunk/daimonin/src/daieditor/messages_de.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_de.properties 2008-03-29 11:13:34 UTC (rev 3768) +++ trunk/daimonin/src/daieditor/messages_de.properties 2008-03-29 11:27:43 UTC (rev 3769) @@ -162,7 +162,6 @@ # Options optionsTitle=Optionen -#optionsUpdate= optionsLoadArchColl.text=Vorbereitete Archetypen laden #optionsResMedia= #optionsResMedia.shortdescription= @@ -487,15 +486,8 @@ #prefsApp.title= #prefsDev.title= -#prefsUpdate.title= -#autoUpdate.text= -#prefsUpdateAuto0.text= -#prefsUpdateAuto1.text= -#prefsUpdateAuto2.text= -#prefsUpdateAuto3.text= - ################# # Map Validation Modified: trunk/daimonin/src/daieditor/messages_fr.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_fr.properties 2008-03-29 11:13:34 UTC (rev 3768) +++ trunk/daimonin/src/daieditor/messages_fr.properties 2008-03-29 11:27:43 UTC (rev 3769) @@ -484,15 +484,8 @@ #prefsApp.title= #prefsDev.title= -#prefsUpdate.title= -#autoUpdate.text= -#prefsUpdateAuto0.text= -#prefsUpdateAuto1.text= -#prefsUpdateAuto2.text= -#prefsUpdateAuto3.text= - ################# # Map Validation Modified: trunk/daimonin/src/daieditor/messages_sv.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_sv.properties 2008-03-29 11:13:34 UTC (rev 3768) +++ trunk/daimonin/src/daieditor/messages_sv.properties 2008-03-29 11:27:43 UTC (rev 3769) @@ -165,7 +165,6 @@ # Options optionsTitle=Inst\xE4llningar -optionsUpdate=Automatisk uppdatering optionsLoadArchColl.text=L\xE4s arketyper fr\xE5n samling optionsResMedia=Media optionsResMedia.shortdescription=<html>Mediakatalogen anv\xE4nds f\xF6r att v\xE4lja bakgrundsljud till kartor.<br>Observera att det inte g\xE5r att v\xE4lja vilka filer som helst.<br>Bakgrundsljud fungerar enbart om filen finns i klienten ocks\xE5.<br>D\xE4rf\xF6r \xE4r det viktigt att v\xE4lja en Daimonin standardkatalog f\xF6r media.</html> @@ -489,15 +488,8 @@ prefsApp.title=Externa applikationer prefsDev.title=Utvecklare -prefsUpdate.title=Uppdatering -autoUpdate.text=Automatiskt leta efter uppdateringar vid uppstart? -prefsUpdateAuto0.text=Varje uppstart -prefsUpdateAuto1.text=En g\xE5ng om dagen -prefsUpdateAuto2.text=En g\xE5ng i veckan -prefsUpdateAuto3.text=En g\xE5ng i m\xE5naden - ################# # Map Validation Modified: trunk/src/app/net/sf/gridarta/action.properties =================================================================== --- trunk/src/app/net/sf/gridarta/action.properties 2008-03-29 11:13:34 UTC (rev 3768) +++ trunk/src/app/net/sf/gridarta/action.properties 2008-03-29 11:27:43 UTC (rev 3769) @@ -69,6 +69,7 @@ prefsMisc.icon=general/Preferences24 prefsMapValidator.icon=general/Search24 +prefsUpdate.icon=general/Search24 mapTileRevert.icon=general/Undo16 mapTileClear.icon=general/Remove16 Copied: trunk/src/app/net/sf/gridarta/gui/prefs/UpdatePrefs.java (from rev 3764, trunk/daimonin/src/daieditor/gui/prefs/UpdatePrefs.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/prefs/UpdatePrefs.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/prefs/UpdatePrefs.java 2008-03-29 11:27:43 UTC (rev 3769) @@ -0,0 +1,150 @@ +/* + * 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.prefs; + +import java.awt.Component; +import java.util.prefs.Preferences; +import javax.swing.Box; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.border.Border; +import javax.swing.border.CompoundBorder; +import javax.swing.border.TitledBorder; +import net.sf.gridarta.MainControl; +import net.sf.gridarta.gui.GUIConstants; +import net.sf.gridarta.updater.UpdaterManager; +import net.sf.japi.swing.ActionFactory; +import net.sf.japi.swing.prefs.AbstractPrefs; + +/** + * Preferences Module for update preferences. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @serial exclude + */ +public final class UpdatePrefs extends AbstractPrefs { + + /** The serial version UID. */ + private static final long serialVersionUID = 1; + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); + + /** Preferences. */ + private static final Preferences PREFS = Preferences.userNodeForPackage(MainControl.class); + + /** Checkbox whether to automatically check for updates on startup. */ + private JCheckBox autoUpdate; + + /** ComboBox with selected interval. */ + private JComboBox interval; + + /** Create an UpdatePrefs pane. */ + public UpdatePrefs() { + setListLabelText(ACTION_FACTORY.getString("prefsUpdate.title")); + setListLabelIcon(ACTION_FACTORY.getIcon("prefsUpdate.icon")); + + add(createUpdatePanel()); + add(Box.createVerticalGlue()); + } + + /** + * Create a titled border. + * @param titleKey Action Key for border title + * @return titled border + */ + private static Border createTitledBorder(final String titleKey) { + return new CompoundBorder(new TitledBorder(ACTION_FACTORY.getString(titleKey)), GUIConstants.DIALOG_BORDER); + } + + /** {@inheritDoc} */ + public void apply() { + PREFS.putBoolean(UpdaterManager.AUTO_CHECK_KEY, autoUpdate.isSelected()); + PREFS.putInt(UpdaterManager.INTERVAL_KEY, interval.getSelectedIndex()); + } + + /** {@inheritDoc} */ + public void revert() { + autoUpdate.setSelected(PREFS.getBoolean(UpdaterManager.AUTO_CHECK_KEY, UpdaterManager.AUTO_CHECK_DEFAULT)); + interval.setSelectedIndex(PREFS.getInt(UpdaterManager.INTERVAL_KEY, UpdaterManager.INTERVAL_DEFAULT)); + } + + /** {@inheritDoc} */ + public void defaults() { + autoUpdate.setSelected(UpdaterManager.AUTO_CHECK_DEFAULT); + interval.setSelectedIndex(UpdaterManager.INTERVAL_DEFAULT); + } + + /** {@inheritDoc} */ + public boolean isChanged() { + return !( + autoUpdate.isSelected() == PREFS.getBoolean(UpdaterManager.AUTO_CHECK_KEY, UpdaterManager.AUTO_CHECK_DEFAULT) + && interval.getSelectedIndex() == PREFS.getInt(UpdaterManager.INTERVAL_KEY, UpdaterManager.INTERVAL_DEFAULT) + ); + } + + /** + * Creates the subpanel with the update settings. + * @return subpanel + */ + private Component createUpdatePanel() { + final Box updatePanel = Box.createVerticalBox(); + updatePanel.setBorder(createTitledBorder("optionsUpdate")); + autoUpdate = new JCheckBox(ACTION_FACTORY.createToggle(false, "autoUpdate", this)); + autoUpdate.setSelected(PREFS.getBoolean(UpdaterManager.AUTO_CHECK_KEY, UpdaterManager.AUTO_CHECK_DEFAULT)); + updatePanel.add(autoUpdate); + updatePanel.add(createComboBox()); + return updatePanel; + } + + /** + * Set AutoUpdate state. + * @param autoUpdate autoupdate state + */ + public void setAutoUpdate(final boolean autoUpdate) { + interval.setEnabled(autoUpdate); + } + + /** + * Get AutoUpdate state. + * @return autoupdate state + */ + public boolean isAutoUpdate() { + return interval.isEnabled(); + } + + /** + * Create the JComboBox with the update choices. + * @return JComboBox with update choices + */ + private JComboBox createComboBox() { + final String[] items = new String[]{ + ACTION_FACTORY.getString("prefsUpdateAuto0.text"), + ACTION_FACTORY.getString("prefsUpdateAuto1.text"), + ACTION_FACTORY.getString("prefsUpdateAuto2.text"), + ACTION_FACTORY.getString("prefsUpdateAuto3.text"), + }; + interval = new JComboBox(items); + interval.setEditable(false); + interval.setSelectedIndex(PREFS.getInt(UpdaterManager.INTERVAL_KEY, UpdaterManager.INTERVAL_DEFAULT)); + interval.setEnabled(PREFS.getBoolean(UpdaterManager.AUTO_CHECK_KEY, UpdaterManager.AUTO_CHECK_DEFAULT)); + return interval; + } + +} // class UpdatePrefs Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2008-03-29 11:13:34 UTC (rev 3768) +++ trunk/src/app/net/sf/gridarta/messages.properties 2008-03-29 11:27:43 UTC (rev 3769) @@ -516,7 +516,14 @@ prefsRes.title=Paths & resources prefsGUI.title=Appearance +prefsUpdate.title=Update +autoUpdate.text=Automatically check for updates on startup? +prefsUpdateAuto0.text=Every startup +prefsUpdateAuto1.text=Once a day +prefsUpdateAuto2.text=Once a week +prefsUpdateAuto3.text=Once a month + # Options optionsLanguage=Language @@ -776,6 +783,7 @@ prefsMapValidator.title=Map validation optionsMisc=Miscellaneous Options +optionsUpdate=Automatic Update optionsValidation=Validation settings autoValidate.text=Automatically run validation after each change optionsValidators=Validators Modified: trunk/src/app/net/sf/gridarta/messages_de.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_de.properties 2008-03-29 11:13:34 UTC (rev 3768) +++ trunk/src/app/net/sf/gridarta/messages_de.properties 2008-03-29 11:27:43 UTC (rev 3769) @@ -480,7 +480,14 @@ prefsRes.title=Pfade & Ressourcen prefsGUI.title=Aussehen +prefsUpdate.title=Update +autoUpdate.text=Beim Programmstart automatisch auf Updates pr\xFCfen? +prefsUpdateAuto0.text=Bei jedem Start +prefsUpdateAuto1.text=Einmal pro Tag +prefsUpdateAuto2.text=Einmal pro Woche +prefsUpdateAuto3.text=Einmal pro Monat + # Options optionsLanguage=Sprache @@ -646,6 +653,7 @@ prefsMapValidator.title=Kartenpr\xFCfung optionsMisc=Verschiedene Einstellungen +optionsUpdate=Automatisches Update optionsValidation=Einstellungen f\xFCr Kartenpr\xFCfung autoValidate.text=Automatische Kartenpr\xFCfung nach \xC4nderungen optionsValidators=Pr\xFCfungen Modified: trunk/src/app/net/sf/gridarta/messages_fr.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-03-29 11:13:34 UTC (rev 3768) +++ trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-03-29 11:27:43 UTC (rev 3769) @@ -479,7 +479,14 @@ #prefsRes.title= #prefsGUI.title= +#prefsUpdate.title= +#autoUpdate.text= +#prefsUpdateAuto0.text= +#prefsUpdateAuto1.text= +#prefsUpdateAuto2.text= +#prefsUpdateAuto3.text= + # Options #optionsLanguage= @@ -645,6 +652,7 @@ #prefsMapValidator.title= #optionsMisc= +#optionsUpdate= #optionsValidation= #autoValidate.text= #optionsValidators= Modified: trunk/src/app/net/sf/gridarta/messages_sv.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-03-29 11:13:34 UTC (rev 3768) +++ trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-03-29 11:27:43 UTC (rev 3769) @@ -478,7 +478,14 @@ prefsRes.title=S\xF6kv\xE4gar och resurser prefsGUI.title=Utseende +prefsUpdate.title=Uppdatering +autoUpdate.text=Automatiskt leta efter uppdateringar vid uppstart? +prefsUpdateAuto0.text=Varje uppstart +prefsUpdateAuto1.text=En g\xE5ng om dagen +prefsUpdateAuto2.text=En g\xE5ng i veckan +prefsUpdateAuto3.text=En g\xE5ng i m\xE5naden + # Options optionsLanguage=Spr\xE5k @@ -644,6 +651,7 @@ prefsMapValidator.title=Kartvalidering optionsMisc=Diverse +optionsUpdate=Automatisk uppdatering optionsValidation=Validering autoValidate.text=Validera automatiskt efter varje \xE4ndring optionsValidators=Validerare This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-29 11:39:07
|
Revision: 3770 http://gridarta.svn.sourceforge.net/gridarta/?rev=3770&view=rev Author: akirschbaum Date: 2008-03-29 04:39:13 -0700 (Sat, 29 Mar 2008) Log Message: ----------- Move update action icon specification to common code base. Modified Paths: -------------- trunk/daimonin/src/daieditor/action.properties trunk/src/app/net/sf/gridarta/action.properties Modified: trunk/daimonin/src/daieditor/action.properties =================================================================== --- trunk/daimonin/src/daieditor/action.properties 2008-03-29 11:27:43 UTC (rev 3769) +++ trunk/daimonin/src/daieditor/action.properties 2008-03-29 11:39:13 UTC (rev 3770) @@ -147,7 +147,6 @@ update.url=http://daimonin.sourceforge.net/editor/update.properties -update.icon=general/Search16 moveTileTop.icon=navigation/Top16 moveTileUp.icon=navigation/Up16 Modified: trunk/src/app/net/sf/gridarta/action.properties =================================================================== --- trunk/src/app/net/sf/gridarta/action.properties 2008-03-29 11:27:43 UTC (rev 3769) +++ trunk/src/app/net/sf/gridarta/action.properties 2008-03-29 11:39:13 UTC (rev 3770) @@ -74,3 +74,5 @@ mapTileRevert.icon=general/Undo16 mapTileClear.icon=general/Remove16 mapTileChoose.icon=general/Open16 + +update.icon=general/Search16 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-29 21:00:16
|
Revision: 3772 http://gridarta.svn.sourceforge.net/gridarta/?rev=3772&view=rev Author: akirschbaum Date: 2008-03-29 14:00:14 -0700 (Sat, 29 Mar 2008) Log Message: ----------- Improve selection markers: display only the border of the selected area; make the cursor more visible. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/resource/system/cursor.png trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/IGUIConstants.java trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java trunk/daimonin/ChangeLog trunk/daimonin/resource/system/icursor.png trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/IGUIConstants.java trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java trunk/src/app/net/sf/gridarta/gui/map/MapGrid.java Added Paths: ----------- trunk/crossfire/resource/system/seltile_e.png trunk/crossfire/resource/system/seltile_n.png trunk/crossfire/resource/system/seltile_s.png trunk/crossfire/resource/system/seltile_w.png trunk/daimonin/resource/system/iseltile_e.png trunk/daimonin/resource/system/iseltile_n.png trunk/daimonin/resource/system/iseltile_s.png trunk/daimonin/resource/system/iseltile_w.png trunk/src/test/net/sf/gridarta/gui/map/ trunk/src/test/net/sf/gridarta/gui/map/MapGridTest.java trunk/src/test/net/sf/gridarta/gui/map/package-info.java Removed Paths: ------------- trunk/daimonin/resource/system/iseltile.png Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-03-29 15:55:31 UTC (rev 3771) +++ trunk/crossfire/ChangeLog 2008-03-29 21:00:14 UTC (rev 3772) @@ -1,5 +1,8 @@ 2008-03-29 Andreas Kirschbaum + * Improve selection markers: display only the border of the + selected area; make the cursor more visible. + * Add updater module. 2008-03-23 Andreas Kirschbaum Modified: trunk/crossfire/resource/system/cursor.png =================================================================== (Binary files differ) Added: trunk/crossfire/resource/system/seltile_e.png =================================================================== (Binary files differ) Property changes on: trunk/crossfire/resource/system/seltile_e.png ___________________________________________________________________ Name: svn:mime-type + image/png Added: trunk/crossfire/resource/system/seltile_n.png =================================================================== (Binary files differ) Property changes on: trunk/crossfire/resource/system/seltile_n.png ___________________________________________________________________ Name: svn:mime-type + image/png Added: trunk/crossfire/resource/system/seltile_s.png =================================================================== (Binary files differ) Property changes on: trunk/crossfire/resource/system/seltile_s.png ___________________________________________________________________ Name: svn:mime-type + image/png Added: trunk/crossfire/resource/system/seltile_w.png =================================================================== (Binary files differ) Property changes on: trunk/crossfire/resource/system/seltile_w.png ___________________________________________________________________ Name: svn:mime-type + image/png Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-29 15:55:31 UTC (rev 3771) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-29 21:00:14 UTC (rev 3772) @@ -172,6 +172,14 @@ // icons for the map and arch pictures. private static ImageIcon mapSelIcon; + private static ImageIcon mapSelIconNorth; + + private static ImageIcon mapSelIconEast; + + private static ImageIcon mapSelIconSouth; + + private static ImageIcon mapSelIconWest; + private static ImageIcon mapCursorIcon; private static ImageIcon emptyTileIcon; @@ -950,12 +958,32 @@ return mapSelIcon; } + public static ImageIcon getMapSelIconNorth() { + return mapSelIconNorth; + } + + public static ImageIcon getMapSelIconEast() { + return mapSelIconEast; + } + + public static ImageIcon getMapSelIconSouth() { + return mapSelIconSouth; + } + + public static ImageIcon getMapSelIconWest() { + return mapSelIconWest; + } + /** * Load all system tile icons into temporary variables for more convenient * access. */ private static void loadDefTiles() { mapSelIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_SEL_TILE); + mapSelIconNorth = GUIUtils.getSysIcon(IGUIConstants.TILE_SEL_TILE_NORTH); + mapSelIconEast = GUIUtils.getSysIcon(IGUIConstants.TILE_SEL_TILE_EAST); + mapSelIconSouth = GUIUtils.getSysIcon(IGUIConstants.TILE_SEL_TILE_SOUTH); + mapSelIconWest = GUIUtils.getSysIcon(IGUIConstants.TILE_SEL_TILE_WEST); mapCursorIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_CURSOR); emptyTileIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_EMPTY); unknownTileIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_UNKNOWN); Modified: trunk/crossfire/src/cfeditor/IGUIConstants.java =================================================================== --- trunk/crossfire/src/cfeditor/IGUIConstants.java 2008-03-29 15:55:31 UTC (rev 3771) +++ trunk/crossfire/src/cfeditor/IGUIConstants.java 2008-03-29 21:00:14 UTC (rev 3772) @@ -75,6 +75,14 @@ String TILE_SEL_TILE = "seltile.png"; + String TILE_SEL_TILE_NORTH = "seltile_n.png"; + + String TILE_SEL_TILE_EAST = "seltile_e.png"; + + String TILE_SEL_TILE_SOUTH = "seltile_s.png"; + + String TILE_SEL_TILE_WEST = "seltile_w.png"; + String TILE_CURSOR = "cursor.png"; String TILE_EMPTY = "empty.png"; Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2008-03-29 15:55:31 UTC (rev 3771) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2008-03-29 21:00:14 UTC (rev 3772) @@ -287,9 +287,18 @@ if ((gridFlags & MapGrid.GRID_FLAG_SELECTING) != 0) { CMainControl.getMapSelIcon().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); } - if ((gridFlags & MapGrid.GRID_FLAG_SELECTION) != 0) { - CMainControl.getMapSelIcon().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); + if ((gridFlags & MapGrid.GRID_FLAG_SELECTION_NORTH) != 0) { + CMainControl.getMapSelIconNorth().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); } + if ((gridFlags & MapGrid.GRID_FLAG_SELECTION_EAST) != 0) { + CMainControl.getMapSelIconEast().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); + } + if ((gridFlags & MapGrid.GRID_FLAG_SELECTION_SOUTH) != 0) { + CMainControl.getMapSelIconSouth().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); + } + if ((gridFlags & MapGrid.GRID_FLAG_SELECTION_WEST) != 0) { + CMainControl.getMapSelIconWest().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); + } if ((gridFlags & MapGrid.GRID_FLAG_CURSOR) != 0) { CMainControl.getMapCursorIcon().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); } Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-03-29 15:55:31 UTC (rev 3771) +++ trunk/daimonin/ChangeLog 2008-03-29 21:00:14 UTC (rev 3772) @@ -1,3 +1,8 @@ +2008-03-29 Andreas Kirschbaum + + * Improve selection markers: display only the border of the + selected area; make the cursor more visible. + 2008-03-23 Andreas Kirschbaum * Do not cut off image parts in "create image". Modified: trunk/daimonin/resource/system/icursor.png =================================================================== (Binary files differ) Deleted: trunk/daimonin/resource/system/iseltile.png =================================================================== (Binary files differ) Added: trunk/daimonin/resource/system/iseltile_e.png =================================================================== (Binary files differ) Property changes on: trunk/daimonin/resource/system/iseltile_e.png ___________________________________________________________________ Name: svn:mime-type + image/png Added: trunk/daimonin/resource/system/iseltile_n.png =================================================================== (Binary files differ) Property changes on: trunk/daimonin/resource/system/iseltile_n.png ___________________________________________________________________ Name: svn:mime-type + image/png Added: trunk/daimonin/resource/system/iseltile_s.png =================================================================== (Binary files differ) Property changes on: trunk/daimonin/resource/system/iseltile_s.png ___________________________________________________________________ Name: svn:mime-type + image/png Added: trunk/daimonin/resource/system/iseltile_w.png =================================================================== (Binary files differ) Property changes on: trunk/daimonin/resource/system/iseltile_w.png ___________________________________________________________________ Name: svn:mime-type + image/png Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-03-29 15:55:31 UTC (rev 3771) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-03-29 21:00:14 UTC (rev 3772) @@ -207,8 +207,14 @@ private final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells = new Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>>(); // icons for the map and arch pictures. - private static ImageIcon mapSelIcon; + private static ImageIcon mapSelIconNorth; + private static ImageIcon mapSelIconEast; + + private static ImageIcon mapSelIconSouth; + + private static ImageIcon mapSelIconWest; + private static ImageIcon mapPreSelIcon; private static ImageIcon mapCursorIcon; @@ -1094,17 +1100,32 @@ return noarchTileIcon; } - public static ImageIcon getMapSelIcon() { - return mapSelIcon; + public static ImageIcon getMapSelIconNorth() { + return mapSelIconNorth; } + public static ImageIcon getMapSelIconEast() { + return mapSelIconEast; + } + + public static ImageIcon getMapSelIconSouth() { + return mapSelIconSouth; + } + + public static ImageIcon getMapSelIconWest() { + return mapSelIconWest; + } + /** * Load all system tile icons into temporary variables for more convenient * access. */ private static void loadDefTiles() { mapPreSelIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_IPRESEL_TILE); - mapSelIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_ISEL_TILE); + mapSelIconNorth = GUIUtils.getSysIcon(IGUIConstants.TILE_ISEL_TILE_NORTH); + mapSelIconEast = GUIUtils.getSysIcon(IGUIConstants.TILE_ISEL_TILE_EAST); + mapSelIconSouth = GUIUtils.getSysIcon(IGUIConstants.TILE_ISEL_TILE_SOUTH); + mapSelIconWest = GUIUtils.getSysIcon(IGUIConstants.TILE_ISEL_TILE_WEST); mapCursorIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_ICURSOR); emptyTileIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_IEMPTY); unknownTileIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_IUNKNOWN); Modified: trunk/daimonin/src/daieditor/IGUIConstants.java =================================================================== --- trunk/daimonin/src/daieditor/IGUIConstants.java 2008-03-29 15:55:31 UTC (rev 3771) +++ trunk/daimonin/src/daieditor/IGUIConstants.java 2008-03-29 21:00:14 UTC (rev 3772) @@ -88,8 +88,14 @@ /** Application icon definitions (icon-dir). */ String APP_ICON = "CFIcon.gif"; - String TILE_ISEL_TILE = "iseltile.png"; + String TILE_ISEL_TILE_NORTH = "iseltile_n.png"; + String TILE_ISEL_TILE_EAST = "iseltile_e.png"; + + String TILE_ISEL_TILE_SOUTH = "iseltile_s.png"; + + String TILE_ISEL_TILE_WEST = "iseltile_w.png"; + String TILE_IPRESEL_TILE = "ipreseltile.png"; String TILE_ICURSOR = "icursor.png"; Modified: trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2008-03-29 15:55:31 UTC (rev 3771) +++ trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2008-03-29 21:00:14 UTC (rev 3772) @@ -415,7 +415,10 @@ return; } final long start = System.currentTimeMillis(); - final Image selImg = CMainControl.getMapSelIcon().getImage(); + final Image selImgNorth = CMainControl.getMapSelIconNorth().getImage(); + final Image selImgEast = CMainControl.getMapSelIconEast().getImage(); + final Image selImgSouth = CMainControl.getMapSelIconSouth().getImage(); + final Image selImgWest = CMainControl.getMapSelIconWest().getImage(); final Image preSelImg = CMainControl.getMapPreSelIcon().getImage(); final Image cursorImg = CMainControl.getMapCursorIcon().getImage(); for (int y = 0; y < mapSize.getHeight(); y++) { @@ -424,9 +427,18 @@ for (int x = 0; x < mapSize.getWidth(); x++) { if (grfx.hitClip(xstart, ystart, IGUIConstants.TILE_ISO_XLEN, IGUIConstants.TILE_ISO_YLEN)) { final int gridFlags = mapGrid.getFlags(x, y); - if ((gridFlags & MapGrid.GRID_FLAG_SELECTION) != 0) { - grfx.drawImage(selImg, xstart, ystart, this); + if ((gridFlags & MapGrid.GRID_FLAG_SELECTION_NORTH) != 0) { + grfx.drawImage(selImgNorth, xstart, ystart, this); } + if ((gridFlags & MapGrid.GRID_FLAG_SELECTION_EAST) != 0) { + grfx.drawImage(selImgEast, xstart, ystart, this); + } + if ((gridFlags & MapGrid.GRID_FLAG_SELECTION_SOUTH) != 0) { + grfx.drawImage(selImgSouth, xstart, ystart, this); + } + if ((gridFlags & MapGrid.GRID_FLAG_SELECTION_WEST) != 0) { + grfx.drawImage(selImgWest, xstart, ystart, this); + } if ((gridFlags & MapGrid.GRID_FLAG_SELECTING) != 0) { grfx.drawImage(preSelImg, xstart, ystart, this); } Modified: trunk/src/app/net/sf/gridarta/gui/map/MapGrid.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapGrid.java 2008-03-29 15:55:31 UTC (rev 3771) +++ trunk/src/app/net/sf/gridarta/gui/map/MapGrid.java 2008-03-29 21:00:14 UTC (rev 3772) @@ -91,6 +91,18 @@ */ public static final int GRID_FLAG_CURSOR = 1 << 7; + /** Selection - is set for tiles at the north edge of the selected area. */ + public static final int GRID_FLAG_SELECTION_NORTH = 1 << 8; + + /** Selection - is set for tiles at the east edge of the selected area. */ + public static final int GRID_FLAG_SELECTION_EAST = 1 << 9; + + /** Selection - is set for tiles at the south edge of the selected area. */ + public static final int GRID_FLAG_SELECTION_SOUTH = 1 << 10; + + /** Selection - is set for tiles at the west edge of the selected area. */ + public static final int GRID_FLAG_SELECTION_WEST = 1 << 11; + /** The MapGridListeners to inform of changes. */ private final EventListenerList listenerList = new EventListenerList(); @@ -157,6 +169,12 @@ final int[][] newGridFlags = new int[newSize.getWidth()][newSize.getHeight()]; final Point pos = new Point(); final Size2D minSize = new Size2D(Math.min(newSize.getWidth(), gridSize.getWidth()), Math.min(newSize.getHeight(), gridSize.getHeight())); + if (newSize.getWidth() < gridSize.getWidth()) { + unsetFlags(newSize.getWidth(), 0, newSize.getWidth(), minSize.getHeight() - 1, GRID_FLAG_SELECTION); + } + if (newSize.getHeight() < gridSize.getHeight()) { + unsetFlags(0, newSize.getHeight(), minSize.getWidth() - 1, newSize.getHeight(), GRID_FLAG_SELECTION); + } for (pos.x = 0; pos.x < minSize.getWidth(); pos.x++) { for (pos.y = 0; pos.y < minSize.getHeight(); pos.y++) { newGridFlags[pos.x][pos.y] = gridFlags[pos.x][pos.y]; @@ -322,6 +340,7 @@ case FLIP: for (int x = cornerMin.x; x <= cornerMax.x; x++) { for (int y = cornerMin.y; y <= cornerMax.y; y++) { + updateSelectionFlag(x, y, (gridFlags[x][y] & GRID_FLAG_SELECTION) == 0); gridFlags[x][y] ^= GRID_FLAG_SELECTION; } } @@ -559,6 +578,9 @@ for (int x = minX; x <= maxX; x++) { for (int y = minY; y <= maxY; y++) { if ((gridFlags[x][y] & flags) != flags) { + if ((flags & GRID_FLAG_SELECTION) != 0 && (gridFlags[x][y] & GRID_FLAG_SELECTION) == 0) { + updateSelectionFlag(x, y, true); + } gridFlags[x][y] |= flags; updateRecChange(x, y); cachedSelectedRecValid = false; @@ -579,6 +601,9 @@ for (int x = minX; x <= maxX; x++) { for (int y = minY; y <= maxY; y++) { if ((gridFlags[x][y] & flags) != 0) { + if ((flags & GRID_FLAG_SELECTION) != 0 && (gridFlags[x][y] & GRID_FLAG_SELECTION) != 0) { + updateSelectionFlag(x, y, false); + } gridFlags[x][y] &= ~flags; updateRecChange(x, y); cachedSelectedRecValid = false; @@ -628,6 +653,52 @@ } } + /** + * Updates the border selection flags of a tile and its adjacent tiles. + * This function assumes the the tile's selection state has changed. + * @param x the x-coordinate of the tile + * @param y the y-coordinate of the tile + * @param newState the new tile's selection state + */ + private void updateSelectionFlag(final int x, final int y, final boolean newState) { + updateSelectionFlag(x, y, newState, x, y - 1, GRID_FLAG_SELECTION_NORTH, GRID_FLAG_SELECTION_SOUTH); + updateSelectionFlag(x, y, newState, x, y + 1, GRID_FLAG_SELECTION_SOUTH, GRID_FLAG_SELECTION_NORTH); + updateSelectionFlag(x, y, newState, x - 1, y, GRID_FLAG_SELECTION_WEST, GRID_FLAG_SELECTION_EAST); + updateSelectionFlag(x, y, newState, x + 1, y, GRID_FLAG_SELECTION_EAST, GRID_FLAG_SELECTION_WEST); + } + + /** + * Updates the border selection flags of a tile and one adjacent tile. This + * function assumes the the tile's selection state has changed. + * @param x the x-coordinate of the tile + * @param y the y-coordinate of the tile + * @param newState the new tile's selection state + * @param dx the x-coordinate of the adjacent tile + * @param dy the y-coordinate of the adjacent tile + * @param flag the border selection flag for the tile + * @param dFlag the border selection flag for the adjacent tile + */ + private void updateSelectionFlag(final int x, final int y, final boolean newState, final int dx, final int dy, final int flag, final int dFlag) { + final boolean dState = 0 <= dx && dx < gridSize.getWidth() && 0 <= dy && dy < gridSize.getHeight() && (gridFlags[dx][dy] & GRID_FLAG_SELECTION) != 0; + if (newState) { + if (dState) { + gridFlags[dx][dy] &= ~dFlag; + updateRecChange(dx, dy); + } else { + gridFlags[x][y] |= flag; + updateRecChange(x, y); + } + } else { + if (dState) { + gridFlags[dx][dy] |= dFlag; + updateRecChange(dx, dy); + } else { + gridFlags[x][y] &= ~flag; + updateRecChange(x, y); + } + } + } + /** Modes that describe how tiles get selected. */ public enum SelectionMode { Added: trunk/src/test/net/sf/gridarta/gui/map/MapGridTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/MapGridTest.java (rev 0) +++ trunk/src/test/net/sf/gridarta/gui/map/MapGridTest.java 2008-03-29 21:00:14 UTC (rev 3772) @@ -0,0 +1,100 @@ +/* + * 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 test.net.sf.gridarta.gui.map; + +import java.awt.Point; +import net.sf.gridarta.Size2D; +import net.sf.gridarta.gui.map.MapGrid; +import org.junit.Assert; +import org.junit.Test; + +/** + * Test for {@link MapGrid}. + * @author Andreas Kirschbaum + */ +public class MapGridTest { + + /** Test case for selection border updates. */ + @Test public void testSelectionBorderUpdates() { + final MapGrid mapGrid = new MapGrid(new Size2D(4, 3)); + checkSelectionBorder(mapGrid, "0000" + "0000" + "0000"); + + mapGrid.select(new Point(1, 1), new Point(1, 1), MapGrid.SelectionMode.ADD); + checkSelectionBorder(mapGrid, "0000" + "0f00" + "0000"); + + mapGrid.select(new Point(2, 1), new Point(2, 1), MapGrid.SelectionMode.ADD); + checkSelectionBorder(mapGrid, "0000" + "0d70" + "0000"); + + mapGrid.select(new Point(3, 1), new Point(3, 1), MapGrid.SelectionMode.ADD); + checkSelectionBorder(mapGrid, "0000" + "0d57" + "0000"); + + mapGrid.select(new Point(3, 1), new Point(3, 1), MapGrid.SelectionMode.SUB); + checkSelectionBorder(mapGrid, "0000" + "0d70" + "0000"); + + mapGrid.select(new Point(0, 0), new Point(3, 2), MapGrid.SelectionMode.FLIP); + checkSelectionBorder(mapGrid, "9553" + "a00a" + "c556"); + + mapGrid.select(new Point(1, 1), new Point(1, 1), MapGrid.SelectionMode.FLIP); + checkSelectionBorder(mapGrid, "9153" + "820a" + "c456"); + + mapGrid.select(new Point(1, 1), new Point(1, 1), MapGrid.SelectionMode.SUB); + checkSelectionBorder(mapGrid, "9553" + "a00a" + "c556"); + + mapGrid.select(new Point(0, 0), new Point(3, 2), MapGrid.SelectionMode.ADD); + checkSelectionBorder(mapGrid, "9113" + "8002" + "c446"); + + mapGrid.resize(new Size2D(2, 1)); + checkSelectionBorder(mapGrid, "d7"); + + mapGrid.resize(new Size2D(3, 4)); + checkSelectionBorder(mapGrid, "d700" + "0000" + "0000"); + + mapGrid.select(new Point(0, 0), new Point(2, 3), MapGrid.SelectionMode.ADD); + checkSelectionBorder(mapGrid, "913" + "802" + "802" + "c46"); + + mapGrid.resize(new Size2D(4, 3)); + checkSelectionBorder(mapGrid, "9130" + "8020" + "c460"); + } + + /** + * Checks that the map border selection flags of a {@link MapGrid} instance + * is as expected. The expected border selection is represented as + * <code>String</code>. Each tile is represented as one hex digit + * character; 1=north, 2=east, 4=south, 8=east border is set. + * @param mapGrid the map grid + * @param expectedBorder the expected border selection + */ + private static void checkSelectionBorder(final MapGrid mapGrid, final String expectedBorder) { + final StringBuilder sb = new StringBuilder(); + final Size2D size = mapGrid.getSize(); + for (int y = 0; y < size.getHeight(); y++) { + for (int x = 0; x < size.getWidth(); x++) { + final int flags = mapGrid.getFlags(x, y); + sb.append(Integer.toHexString( + ((flags & MapGrid.GRID_FLAG_SELECTION_NORTH) != 0 ? 1 : 0) + + ((flags & MapGrid.GRID_FLAG_SELECTION_EAST) != 0 ? 2 : 0) + + ((flags & MapGrid.GRID_FLAG_SELECTION_SOUTH) != 0 ? 4 : 0) + + ((flags & MapGrid.GRID_FLAG_SELECTION_WEST) != 0 ? 8 : 0))); + } + } + Assert.assertEquals(expectedBorder, sb.toString()); + } + +} // class MapGridTest Property changes on: trunk/src/test/net/sf/gridarta/gui/map/MapGridTest.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/src/test/net/sf/gridarta/gui/map/package-info.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/package-info.java (rev 0) +++ trunk/src/test/net/sf/gridarta/gui/map/package-info.java 2008-03-29 21:00:14 UTC (rev 3772) @@ -0,0 +1,24 @@ +/* + * 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. + */ + +/** + * Tests for {@link net.sf.gridarta.gui.map}. + * @author Andreas Kirschbaum + */ +package test.net.sf.gridarta.gui.map; Property changes on: trunk/src/test/net/sf/gridarta/gui/map/package-info.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-03-29 21:15:07
|
Revision: 3773 http://gridarta.svn.sourceforge.net/gridarta/?rev=3773&view=rev Author: akirschbaum Date: 2008-03-29 14:15:13 -0700 (Sat, 29 Mar 2008) Log Message: ----------- Change modifier keys for tile selection. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java trunk/daimonin/ChangeLog trunk/daimonin/src/daieditor/gui/map/tools/SelectionTool.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-03-29 21:00:14 UTC (rev 3772) +++ trunk/crossfire/ChangeLog 2008-03-29 21:15:13 UTC (rev 3773) @@ -1,5 +1,11 @@ 2008-03-29 Andreas Kirschbaum + * Change modifier keys for tile selection: + - no modifier => replace selection + - SHIFT => add to selection + - CTRL => remove from selection + - SHIFT+CTRL => toggle selection + * Improve selection markers: display only the border of the selected area; make the cursor more visible. Modified: trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java 2008-03-29 21:00:14 UTC (rev 3772) +++ trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java 2008-03-29 21:15:13 UTC (rev 3773) @@ -135,8 +135,8 @@ } } else if (isSelect(e)) { mapCursor.beginTransaction(); - // Throw away old selection if CTRL is not pressed - if (!e.isControlDown()) { + // Throw away old selection if neither SHIFT nor CTRL is not pressed + if (!e.isControlDown() && !e.isShiftDown()) { mapCursor.deactivate(); } mapCursor.setLocation(mapLoc); @@ -173,7 +173,11 @@ if (!mapCursor.isOnGrid(mapLoc)) { mapCursor.dragRelease(); } else if (e.isShiftDown()) { - mapCursor.dragSelect(MapGrid.SelectionMode.FLIP); + if (e.isControlDown()) { + mapCursor.dragSelect(MapGrid.SelectionMode.FLIP); + } else { + mapCursor.dragSelect(MapGrid.SelectionMode.ADD); + } } else if (e.isControlDown()) { mapCursor.dragSelect(MapGrid.SelectionMode.SUB); } else { Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-03-29 21:00:14 UTC (rev 3772) +++ trunk/daimonin/ChangeLog 2008-03-29 21:15:13 UTC (rev 3773) @@ -1,5 +1,11 @@ 2008-03-29 Andreas Kirschbaum + * Change modifier keys for tile selection: + - no modifier => replace selection + - SHIFT => add to selection + - CTRL => remove from selection + - SHIFT+CTRL => toggle selection + * Improve selection markers: display only the border of the selected area; make the cursor more visible. Modified: trunk/daimonin/src/daieditor/gui/map/tools/SelectionTool.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/SelectionTool.java 2008-03-29 21:00:14 UTC (rev 3772) +++ trunk/daimonin/src/daieditor/gui/map/tools/SelectionTool.java 2008-03-29 21:15:13 UTC (rev 3773) @@ -47,8 +47,8 @@ final MapCursor mapCursor = e.getMapCursor(); final MapControl mapControl = e.getMapControl(); // left mouse button: select tiles - // Throw away old selection if CTRL is not pressed - if ((mod & InputEvent.CTRL_DOWN_MASK) == 0) { + // 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(); @@ -72,14 +72,16 @@ final MapCursor mapCursor = e.getMapCursor(); final int modifiers = e.getModifiers(); if (mapCursor.isOnGrid(e.getMapLocation())) { - if ((modifiers & InputEvent.SHIFT_DOWN_MASK) == 0) { - mapCursor.dragSelect(MapGrid.SelectionMode.FLIP); - } else { - if ((modifiers & InputEvent.CTRL_DOWN_MASK) == 0) { - mapCursor.dragSelect(MapGrid.SelectionMode.SUB); + 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(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-30 17:03:26
|
Revision: 3776 http://gridarta.svn.sourceforge.net/gridarta/?rev=3776&view=rev Author: akirschbaum Date: 2008-03-30 10:03:30 -0700 (Sun, 30 Mar 2008) Log Message: ----------- Make map selection more visible. Modified Paths: -------------- trunk/crossfire/resource/system/seltile.png trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/IGUIConstants.java trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/IGUIConstants.java trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java Added Paths: ----------- trunk/crossfire/resource/system/preseltile.png trunk/daimonin/resource/system/iseltile.png Added: trunk/crossfire/resource/system/preseltile.png =================================================================== (Binary files differ) Property changes on: trunk/crossfire/resource/system/preseltile.png ___________________________________________________________________ Name: svn:mime-type + image/png Modified: trunk/crossfire/resource/system/seltile.png =================================================================== (Binary files differ) Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-30 16:46:47 UTC (rev 3775) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-30 17:03:30 UTC (rev 3776) @@ -180,6 +180,8 @@ private static ImageIcon mapSelIconWest; + private static ImageIcon mapPreSelIcon; + private static ImageIcon mapCursorIcon; private static ImageIcon emptyTileIcon; @@ -974,6 +976,10 @@ return mapSelIconWest; } + public static ImageIcon getMapPreSelIcon() { + return mapPreSelIcon; + } + /** * Load all system tile icons into temporary variables for more convenient * access. @@ -984,6 +990,7 @@ mapSelIconEast = GUIUtils.getSysIcon(IGUIConstants.TILE_SEL_TILE_EAST); mapSelIconSouth = GUIUtils.getSysIcon(IGUIConstants.TILE_SEL_TILE_SOUTH); mapSelIconWest = GUIUtils.getSysIcon(IGUIConstants.TILE_SEL_TILE_WEST); + mapPreSelIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_PRESEL_TILE); mapCursorIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_CURSOR); emptyTileIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_EMPTY); unknownTileIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_UNKNOWN); Modified: trunk/crossfire/src/cfeditor/IGUIConstants.java =================================================================== --- trunk/crossfire/src/cfeditor/IGUIConstants.java 2008-03-30 16:46:47 UTC (rev 3775) +++ trunk/crossfire/src/cfeditor/IGUIConstants.java 2008-03-30 17:03:30 UTC (rev 3776) @@ -83,6 +83,8 @@ String TILE_SEL_TILE_WEST = "seltile_w.png"; + String TILE_PRESEL_TILE = "preseltile.png"; + String TILE_CURSOR = "cursor.png"; String TILE_EMPTY = "empty.png"; Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2008-03-30 16:46:47 UTC (rev 3775) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2008-03-30 17:03:30 UTC (rev 3776) @@ -284,7 +284,7 @@ */ protected void paintTileSelection(final Graphics grfx, final Point point) { final int gridFlags = mapGrid.getFlags(point.x, point.y); - if ((gridFlags & MapGrid.GRID_FLAG_SELECTING) != 0) { + if ((gridFlags & MapGrid.GRID_FLAG_SELECTION) != 0) { CMainControl.getMapSelIcon().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); } if ((gridFlags & MapGrid.GRID_FLAG_SELECTION_NORTH) != 0) { @@ -299,6 +299,9 @@ if ((gridFlags & MapGrid.GRID_FLAG_SELECTION_WEST) != 0) { CMainControl.getMapSelIconWest().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); } + if ((gridFlags & MapGrid.GRID_FLAG_SELECTING) != 0) { + CMainControl.getMapPreSelIcon().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); + } if ((gridFlags & MapGrid.GRID_FLAG_CURSOR) != 0) { CMainControl.getMapCursorIcon().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); } Added: trunk/daimonin/resource/system/iseltile.png =================================================================== (Binary files differ) Property changes on: trunk/daimonin/resource/system/iseltile.png ___________________________________________________________________ Name: svn:mime-type + image/png Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-03-30 16:46:47 UTC (rev 3775) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-03-30 17:03:30 UTC (rev 3776) @@ -207,6 +207,8 @@ private final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells = new Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>>(); // icons for the map and arch pictures. + private static ImageIcon mapSelIcon; + private static ImageIcon mapSelIconNorth; private static ImageIcon mapSelIconEast; @@ -1101,6 +1103,10 @@ return noarchTileIcon; } + public static ImageIcon getMapSelIcon() { + return mapSelIcon; + } + public static ImageIcon getMapSelIconNorth() { return mapSelIconNorth; } @@ -1123,6 +1129,7 @@ */ private static void loadDefTiles() { mapPreSelIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_IPRESEL_TILE); + mapSelIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_ISEL_TILE); mapSelIconNorth = GUIUtils.getSysIcon(IGUIConstants.TILE_ISEL_TILE_NORTH); mapSelIconEast = GUIUtils.getSysIcon(IGUIConstants.TILE_ISEL_TILE_EAST); mapSelIconSouth = GUIUtils.getSysIcon(IGUIConstants.TILE_ISEL_TILE_SOUTH); Modified: trunk/daimonin/src/daieditor/IGUIConstants.java =================================================================== --- trunk/daimonin/src/daieditor/IGUIConstants.java 2008-03-30 16:46:47 UTC (rev 3775) +++ trunk/daimonin/src/daieditor/IGUIConstants.java 2008-03-30 17:03:30 UTC (rev 3776) @@ -88,6 +88,8 @@ /** Application icon definitions (icon-dir). */ String APP_ICON = "CFIcon.gif"; + String TILE_ISEL_TILE = "iseltile.png"; + String TILE_ISEL_TILE_NORTH = "iseltile_n.png"; String TILE_ISEL_TILE_EAST = "iseltile_e.png"; Modified: trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2008-03-30 16:46:47 UTC (rev 3775) +++ trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2008-03-30 17:03:30 UTC (rev 3776) @@ -415,6 +415,7 @@ return; } final long start = System.currentTimeMillis(); + final Image selImg = CMainControl.getMapSelIcon().getImage(); final Image selImgNorth = CMainControl.getMapSelIconNorth().getImage(); final Image selImgEast = CMainControl.getMapSelIconEast().getImage(); final Image selImgSouth = CMainControl.getMapSelIconSouth().getImage(); @@ -427,6 +428,9 @@ for (int x = 0; x < mapSize.getWidth(); x++) { if (grfx.hitClip(xstart, ystart, IGUIConstants.TILE_ISO_XLEN, IGUIConstants.TILE_ISO_YLEN)) { final int gridFlags = mapGrid.getFlags(x, y); + if ((gridFlags & MapGrid.GRID_FLAG_SELECTION) != 0) { + grfx.drawImage(selImg, xstart, ystart, this); + } if ((gridFlags & MapGrid.GRID_FLAG_SELECTION_NORTH) != 0) { grfx.drawImage(selImgNorth, xstart, ystart, this); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-30 17:17:19
|
Revision: 3777 http://gridarta.svn.sourceforge.net/gridarta/?rev=3777&view=rev Author: akirschbaum Date: 2008-03-30 10:17:24 -0700 (Sun, 30 Mar 2008) Log Message: ----------- Make variable more local. 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-03-30 17:03:30 UTC (rev 3776) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-30 17:17:24 UTC (rev 3777) @@ -374,9 +374,8 @@ if (archetypeSet.getLoadStatus() != ArchetypeSet.LoadStatus.EMPTY) { mainView.getObjectChooser().getPickmapChooserControl().loadPickmaps(true); } - final Document specialTreasureListsDocument; try { - specialTreasureListsDocument = xmlHelper.getDocumentBuilder().parse(IOUtils.getResourceURLAsString(getConfigurationDirectory(), "TreasureLists.xml")); + final Document specialTreasureListsDocument = xmlHelper.getDocumentBuilder().parse(IOUtils.getResourceURLAsString(getConfigurationDirectory(), "TreasureLists.xml")); treasureListTree = new CFTreasureListTree<GameObject, MapArchObject, Archetype>(archetypeSet, specialTreasureListsDocument, new TreasureLocation(getConfigurationDirectory(), IGUIConstants.TREASURES_FILE) ); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-03-30 17:03:30 UTC (rev 3776) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-03-30 17:17:24 UTC (rev 3777) @@ -438,10 +438,9 @@ if (archetypeSet.getLoadStatus() != ArchetypeSet.LoadStatus.EMPTY) { mainView.getObjectChooser().getPickmapChooserControl().loadPickmaps(true); } - final Document specialTreasureListsDocument; CFTreasureListTree treasureListTree = null; try { - specialTreasureListsDocument = xmlHelper.getDocumentBuilder().parse(IOUtils.getResourceURLAsString(getConfigurationDirectory(), "TreasureLists.xml")); + final Document specialTreasureListsDocument = xmlHelper.getDocumentBuilder().parse(IOUtils.getResourceURLAsString(getConfigurationDirectory(), "TreasureLists.xml")); treasureListTree = new CFTreasureListTree<GameObject, MapArchObject, Archetype>(archetypeSet, specialTreasureListsDocument, new TreasureLocation(getArchDefaultFolder(), IGUIConstants.TREASURES_FILE), new TreasureLocation(getMapDefaultFolder(), null) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-31 20:26:55
|
Revision: 3782 http://gridarta.svn.sourceforge.net/gridarta/?rev=3782&view=rev Author: akirschbaum Date: 2008-03-31 13:26:49 -0700 (Mon, 31 Mar 2008) Log Message: ----------- Move parsing of TreasureLists.xml file out of CFTreasureListTree. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/treasurelist/CFTreasureListTree.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-31 20:22:18 UTC (rev 3781) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-31 20:26:49 UTC (rev 3782) @@ -44,6 +44,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.MissingResourceException; import java.util.prefs.Preferences; import javax.swing.ImageIcon; @@ -95,7 +96,9 @@ import net.sf.gridarta.spells.Spells; import net.sf.gridarta.textedit.scripteditor.ScriptEditControl; import net.sf.gridarta.treasurelist.CFTreasureListTree; +import net.sf.gridarta.treasurelist.TreasureListsParser; import net.sf.gridarta.treasurelist.TreasureLocation; +import net.sf.gridarta.treasurelist.TreasureTreeNode; import net.sf.gridarta.updater.UpdaterManager; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; @@ -376,7 +379,8 @@ } try { final Document specialTreasureListsDocument = xmlHelper.getDocumentBuilder().parse(IOUtils.getResourceURLAsString(getConfigurationDirectory(), "TreasureLists.xml")); - treasureListTree = new CFTreasureListTree<GameObject, MapArchObject, Archetype>(archetypeSet, specialTreasureListsDocument, + final Map<String, TreasureTreeNode> specialTreasureLists = TreasureListsParser.parseTreasureLists(specialTreasureListsDocument); + treasureListTree = new CFTreasureListTree<GameObject, MapArchObject, Archetype>(archetypeSet, specialTreasureLists, new TreasureLocation(getConfigurationDirectory(), IGUIConstants.TREASURES_FILE) ); } catch (final IOException ex) { Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-03-31 20:22:18 UTC (rev 3781) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-03-31 20:26:49 UTC (rev 3782) @@ -48,6 +48,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Map; import java.util.MissingResourceException; import java.util.ResourceBundle; import java.util.prefs.Preferences; @@ -111,7 +112,9 @@ import net.sf.gridarta.spells.XMLSpellLoader; import net.sf.gridarta.textedit.scripteditor.ScriptEditControl; import net.sf.gridarta.treasurelist.CFTreasureListTree; +import net.sf.gridarta.treasurelist.TreasureListsParser; import net.sf.gridarta.treasurelist.TreasureLocation; +import net.sf.gridarta.treasurelist.TreasureTreeNode; import net.sf.gridarta.updater.UpdaterManager; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; @@ -441,7 +444,8 @@ CFTreasureListTree treasureListTree = null; try { final Document specialTreasureListsDocument = xmlHelper.getDocumentBuilder().parse(IOUtils.getResourceURLAsString(getConfigurationDirectory(), "TreasureLists.xml")); - treasureListTree = new CFTreasureListTree<GameObject, MapArchObject, Archetype>(archetypeSet, specialTreasureListsDocument, + final Map<String, TreasureTreeNode> specialTreasureLists = TreasureListsParser.parseTreasureLists(specialTreasureListsDocument); + treasureListTree = new CFTreasureListTree<GameObject, MapArchObject, Archetype>(archetypeSet, specialTreasureLists, new TreasureLocation(getArchDefaultFolder(), IGUIConstants.TREASURES_FILE), new TreasureLocation(getMapDefaultFolder(), null) ); Modified: trunk/src/app/net/sf/gridarta/treasurelist/CFTreasureListTree.java =================================================================== --- trunk/src/app/net/sf/gridarta/treasurelist/CFTreasureListTree.java 2008-03-31 20:22:18 UTC (rev 3781) +++ trunk/src/app/net/sf/gridarta/treasurelist/CFTreasureListTree.java 2008-03-31 20:26:49 UTC (rev 3782) @@ -47,7 +47,6 @@ import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.w3c.dom.Document; /** * The CFTreasureListTree class fully manages treasurelists. @@ -88,16 +87,15 @@ /** * Create a new instance. * @param archetypeSet ArchetypeSet to get treasures from. - * @param specialTreasureListsDocument the special treasure lists definitions + * @param specialTreasureLists the special treasure lists * @param treasures The treasures to load. */ - public CFTreasureListTree(@NotNull final ArchetypeSet<G, A, R> archetypeSet, final Document specialTreasureListsDocument, final TreasureLocation... treasures) { + public CFTreasureListTree(@NotNull final ArchetypeSet<G, A, R> archetypeSet, final Map<String, TreasureTreeNode> specialTreasureLists, final TreasureLocation... treasures) { super(root); putClientProperty("JTree.lineStyle", "Angled"); setCellRenderer(new TreasureCellRenderer(archetypeSet, root)); - final Map<String, TreasureTreeNode> specialTreasureLists = TreasureListsParser.parseTreasureLists(specialTreasureListsDocument); for (final TreasureTreeNode folder : new HashSet<TreasureTreeNode>(specialTreasureLists.values())) { root.add(folder); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-31 20:37:14
|
Revision: 3783 http://gridarta.svn.sourceforge.net/gridarta/?rev=3783&view=rev Author: akirschbaum Date: 2008-03-31 13:36:57 -0700 (Mon, 31 Mar 2008) Log Message: ----------- Do not crash/ignore missing TreasureLists.xml file. 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-03-31 20:26:49 UTC (rev 3782) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-31 20:36:57 UTC (rev 3783) @@ -43,6 +43,7 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.MissingResourceException; @@ -377,19 +378,20 @@ if (archetypeSet.getLoadStatus() != ArchetypeSet.LoadStatus.EMPTY) { mainView.getObjectChooser().getPickmapChooserControl().loadPickmaps(true); } + Map<String, TreasureTreeNode> specialTreasureLists; try { final Document specialTreasureListsDocument = xmlHelper.getDocumentBuilder().parse(IOUtils.getResourceURLAsString(getConfigurationDirectory(), "TreasureLists.xml")); - final Map<String, TreasureTreeNode> specialTreasureLists = TreasureListsParser.parseTreasureLists(specialTreasureListsDocument); - treasureListTree = new CFTreasureListTree<GameObject, MapArchObject, Archetype>(archetypeSet, specialTreasureLists, - new TreasureLocation(getConfigurationDirectory(), IGUIConstants.TREASURES_FILE) - ); + specialTreasureLists = TreasureListsParser.parseTreasureLists(specialTreasureListsDocument); } catch (final IOException ex) { log.fatal("Cannot read TreasureLists.xml: " + ex.getMessage()); - throw new MissingResourceException("Cannot read TreasureLists.xml: " + ex.getMessage(), null, "TreasureLists.xml"); + specialTreasureLists = Collections.emptyMap(); } catch (final SAXException ex) { log.fatal("Cannot read TreasureLists.xml: " + ex.getMessage()); - throw new MissingResourceException("Cannot read TreasureLists.xml: " + ex.getMessage(), null, "TreasureLists.xml"); + specialTreasureLists = Collections.emptyMap(); } + treasureListTree = new CFTreasureListTree<GameObject, MapArchObject, Archetype>(archetypeSet, specialTreasureLists, + new TreasureLocation(getConfigurationDirectory(), IGUIConstants.TREASURES_FILE) + ); recentManager.initRecent(); validators = createMapValidators(); autoValidator = new AutoValidator<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, PREFS_VALIDATOR_AUTO_DEFAULT); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-03-31 20:26:49 UTC (rev 3782) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-03-31 20:36:57 UTC (rev 3783) @@ -47,6 +47,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.MissingResourceException; @@ -441,21 +442,21 @@ if (archetypeSet.getLoadStatus() != ArchetypeSet.LoadStatus.EMPTY) { mainView.getObjectChooser().getPickmapChooserControl().loadPickmaps(true); } - CFTreasureListTree treasureListTree = null; + Map<String, TreasureTreeNode> specialTreasureLists; try { final Document specialTreasureListsDocument = xmlHelper.getDocumentBuilder().parse(IOUtils.getResourceURLAsString(getConfigurationDirectory(), "TreasureLists.xml")); - final Map<String, TreasureTreeNode> specialTreasureLists = TreasureListsParser.parseTreasureLists(specialTreasureListsDocument); - treasureListTree = new CFTreasureListTree<GameObject, MapArchObject, Archetype>(archetypeSet, specialTreasureLists, - new TreasureLocation(getArchDefaultFolder(), IGUIConstants.TREASURES_FILE), - new TreasureLocation(getMapDefaultFolder(), null) - ); + specialTreasureLists = TreasureListsParser.parseTreasureLists(specialTreasureListsDocument); } catch (final IOException ex) { log.fatal("Cannot read TreasureLists.xml: " + ex.getMessage()); + specialTreasureLists = Collections.emptyMap(); } catch (final SAXException ex) { log.fatal("Cannot read TreasureLists.xml: " + ex.getMessage()); - } finally { - this.treasureListTree = treasureListTree; + specialTreasureLists = Collections.emptyMap(); } + treasureListTree = new CFTreasureListTree<GameObject, MapArchObject, Archetype>(archetypeSet, specialTreasureLists, + new TreasureLocation(getArchDefaultFolder(), IGUIConstants.TREASURES_FILE), + new TreasureLocation(getMapDefaultFolder(), null) + ); recentManager.initRecent(); validators = createMapValidators(); autoValidator = new AutoValidator<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, PREFS_VALIDATOR_AUTO_DEFAULT); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-31 20:45:07
|
Revision: 3784 http://gridarta.svn.sourceforge.net/gridarta/?rev=3784&view=rev Author: akirschbaum Date: 2008-03-31 13:44:12 -0700 (Mon, 31 Mar 2008) Log Message: ----------- Make CMainView.updateFocus() private. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-31 20:36:57 UTC (rev 3783) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-31 20:44:12 UTC (rev 3784) @@ -337,8 +337,6 @@ getCopyBuffer().init(getGridartaObjectsFactory().newMapArchObject()); mainActions.init(); - mainView.updateFocus(false); - recentManager = new RecentManager(this, (JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "recent")); final long timeStart = System.currentTimeMillis(); Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-03-31 20:36:57 UTC (rev 3783) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-03-31 20:44:12 UTC (rev 3784) @@ -155,6 +155,8 @@ if (icon != null) { setIconImage(icon.getImage()); } + + updateFocus(false); } /** @@ -307,7 +309,7 @@ * @param fCareAboutIconification True if the focus update should ignore * all windows iconified by the user. */ - void updateFocus(final boolean fCareAboutIconification) { + private void updateFocus(final boolean fCareAboutIconification) { // Show the next level (if such exists) for (final MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapView : mapViews) { if (mapView.isIcon()) { Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-03-31 20:36:57 UTC (rev 3783) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-03-31 20:44:12 UTC (rev 3784) @@ -387,8 +387,6 @@ getCopyBuffer().init(getGridartaObjectsFactory().newMapArchObject()); mainActions.init(); - mainView.updateFocus(false); - // Delete libraries. final File libs = new File(System.getProperty("user.dir"), "lib"); final String libsString = ACTION_FACTORY.getString("oldLibs.okayLibs"); Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-03-31 20:36:57 UTC (rev 3783) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-03-31 20:44:12 UTC (rev 3784) @@ -159,6 +159,8 @@ if (icon != null) { setIconImage(icon.getImage()); } + + updateFocus(false); } /** @@ -316,7 +318,7 @@ * @param fCareAboutIconification True if the focus update should ignore * all windows iconified by the user. */ - void updateFocus(final boolean fCareAboutIconification) { + private void updateFocus(final boolean fCareAboutIconification) { // Show the next level (if such exists) for (final MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapView : mapViews) { if (mapView.isIcon()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-31 21:29:51
|
Revision: 3788 http://gridarta.svn.sourceforge.net/gridarta/?rev=3788&view=rev Author: akirschbaum Date: 2008-03-31 14:29:51 -0700 (Mon, 31 Mar 2008) Log Message: ----------- Change logging message for missing TreasureLists.xml file from fatal to warning since it is not fatal anymore. 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-03-31 21:13:33 UTC (rev 3787) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-31 21:29:51 UTC (rev 3788) @@ -381,10 +381,10 @@ final Document specialTreasureListsDocument = xmlHelper.getDocumentBuilder().parse(IOUtils.getResourceURLAsString(getConfigurationDirectory(), "TreasureLists.xml")); specialTreasureLists = TreasureListsParser.parseTreasureLists(specialTreasureListsDocument); } catch (final IOException ex) { - log.fatal("Cannot read TreasureLists.xml: " + ex.getMessage()); + log.warn("Cannot read TreasureLists.xml: " + ex.getMessage()); specialTreasureLists = Collections.emptyMap(); } catch (final SAXException ex) { - log.fatal("Cannot read TreasureLists.xml: " + ex.getMessage()); + log.warn("Cannot read TreasureLists.xml: " + ex.getMessage()); specialTreasureLists = Collections.emptyMap(); } treasureListTree = new CFTreasureListTree<GameObject, MapArchObject, Archetype>(archetypeSet, specialTreasureLists, Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-03-31 21:13:33 UTC (rev 3787) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-03-31 21:29:51 UTC (rev 3788) @@ -445,10 +445,10 @@ final Document specialTreasureListsDocument = xmlHelper.getDocumentBuilder().parse(IOUtils.getResourceURLAsString(getConfigurationDirectory(), "TreasureLists.xml")); specialTreasureLists = TreasureListsParser.parseTreasureLists(specialTreasureListsDocument); } catch (final IOException ex) { - log.fatal("Cannot read TreasureLists.xml: " + ex.getMessage()); + log.warn("Cannot read TreasureLists.xml: " + ex.getMessage()); specialTreasureLists = Collections.emptyMap(); } catch (final SAXException ex) { - log.fatal("Cannot read TreasureLists.xml: " + ex.getMessage()); + log.warn("Cannot read TreasureLists.xml: " + ex.getMessage()); specialTreasureLists = Collections.emptyMap(); } treasureListTree = new CFTreasureListTree<GameObject, MapArchObject, Archetype>(archetypeSet, specialTreasureLists, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-31 21:46:10
|
Revision: 3789 http://gridarta.svn.sourceforge.net/gridarta/?rev=3789&view=rev Author: akirschbaum Date: 2008-03-31 14:38:47 -0700 (Mon, 31 Mar 2008) Log Message: ----------- Move constants to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/IGUIConstants.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/IGUIConstants.java trunk/src/app/net/sf/gridarta/gui/GUIConstants.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-31 21:29:51 UTC (rev 3788) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-31 21:38:47 UTC (rev 3789) @@ -63,6 +63,7 @@ import net.sf.gridarta.gameobject.Collector; import net.sf.gridarta.gameobject.face.AbstractFaceObjects; import net.sf.gridarta.gui.About; +import net.sf.gridarta.gui.GUIConstants; import net.sf.gridarta.gui.GUIUtils; import net.sf.gridarta.gui.HideFileFilterProxy; import net.sf.gridarta.gui.MainActions; @@ -988,25 +989,25 @@ * access. */ private static void loadDefTiles() { - mapSelIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_SEL_TILE); - mapSelIconNorth = GUIUtils.getSysIcon(IGUIConstants.TILE_SEL_TILE_NORTH); - mapSelIconEast = GUIUtils.getSysIcon(IGUIConstants.TILE_SEL_TILE_EAST); - mapSelIconSouth = GUIUtils.getSysIcon(IGUIConstants.TILE_SEL_TILE_SOUTH); - mapSelIconWest = GUIUtils.getSysIcon(IGUIConstants.TILE_SEL_TILE_WEST); - mapPreSelIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_PRESEL_TILE); - mapCursorIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_CURSOR); - emptyTileIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_EMPTY); - unknownTileIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_UNKNOWN); + mapSelIcon = GUIUtils.getSysIcon(GUIConstants.TILE_SEL_TILE); + mapSelIconNorth = GUIUtils.getSysIcon(GUIConstants.TILE_SEL_TILE_NORTH); + mapSelIconEast = GUIUtils.getSysIcon(GUIConstants.TILE_SEL_TILE_EAST); + mapSelIconSouth = GUIUtils.getSysIcon(GUIConstants.TILE_SEL_TILE_SOUTH); + mapSelIconWest = GUIUtils.getSysIcon(GUIConstants.TILE_SEL_TILE_WEST); + mapPreSelIcon = GUIUtils.getSysIcon(GUIConstants.TILE_PRESEL_TILE); + mapCursorIcon = GUIUtils.getSysIcon(GUIConstants.TILE_CURSOR); + emptyTileIcon = GUIUtils.getSysIcon(GUIConstants.TILE_EMPTY); + unknownTileIcon = GUIUtils.getSysIcon(GUIConstants.TILE_UNKNOWN); warningSquareIcon = createWarningSquareIcon(); - nofaceTileIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_NOFACE); - noarchTileIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_NOARCH); - defaultIcon = GUIUtils.getSysIcon(IGUIConstants.DEFAULT_ICON); - defaultPreview = GUIUtils.getSysIcon(IGUIConstants.DEFAULT_PREVIEW); + nofaceTileIcon = GUIUtils.getSysIcon(GUIConstants.TILE_NOFACE); + noarchTileIcon = GUIUtils.getSysIcon(GUIConstants.TILE_NOARCH); + defaultIcon = GUIUtils.getSysIcon(GUIConstants.DEFAULT_ICON); + defaultPreview = GUIUtils.getSysIcon(GUIConstants.DEFAULT_PREVIEW); } private static ImageIcon createWarningSquareIcon() { final ImageFilter alphaFilter = AbstractFaceObjects.ALPHA_FILTER; - final ImageIcon sysIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_WARNING); + final ImageIcon sysIcon = GUIUtils.getSysIcon(GUIConstants.TILE_WARNING); final Image image = sysIcon.getImage(); final ImageProducer source = image.getSource(); final FilteredImageSource producer = new FilteredImageSource(source, alphaFilter); Modified: trunk/crossfire/src/cfeditor/IGUIConstants.java =================================================================== --- trunk/crossfire/src/cfeditor/IGUIConstants.java 2008-03-31 21:29:51 UTC (rev 3788) +++ trunk/crossfire/src/cfeditor/IGUIConstants.java 2008-03-31 21:38:47 UTC (rev 3789) @@ -73,30 +73,4 @@ String RUN_PLUGIN_SMALLICON = "RunPluginSmallIcon.gif"; - String TILE_SEL_TILE = "seltile.png"; - - String TILE_SEL_TILE_NORTH = "seltile_n.png"; - - String TILE_SEL_TILE_EAST = "seltile_e.png"; - - String TILE_SEL_TILE_SOUTH = "seltile_s.png"; - - String TILE_SEL_TILE_WEST = "seltile_w.png"; - - String TILE_PRESEL_TILE = "preseltile.png"; - - String TILE_CURSOR = "cursor.png"; - - String TILE_EMPTY = "empty.png"; - - String TILE_UNKNOWN = "unknown.png"; - - String TILE_WARNING = "warning.png"; - - /** The default map icon to use if no icon can be created. */ - String DEFAULT_ICON = "default_icon.png"; - - /** The default map preview to use if no icon can be created. */ - String DEFAULT_PREVIEW = "default_preview.png"; - } // interface IGUIConstants Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-03-31 21:29:51 UTC (rev 3788) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-03-31 21:38:47 UTC (rev 3789) @@ -70,6 +70,7 @@ import net.sf.gridarta.gameobject.match.MutableOrGameObjectMatcher; import net.sf.gridarta.gameobject.match.ViewGameObjectMatcherManager; import net.sf.gridarta.gui.About; +import net.sf.gridarta.gui.GUIConstants; import net.sf.gridarta.gui.GUIUtils; import net.sf.gridarta.gui.HideFileFilterProxy; import net.sf.gridarta.gui.MainActions; @@ -1130,25 +1131,25 @@ * access. */ private static void loadDefTiles() { - mapSelIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_SEL_TILE); - mapSelIconNorth = GUIUtils.getSysIcon(IGUIConstants.TILE_SEL_TILE_NORTH); - mapSelIconEast = GUIUtils.getSysIcon(IGUIConstants.TILE_SEL_TILE_EAST); - mapSelIconSouth = GUIUtils.getSysIcon(IGUIConstants.TILE_SEL_TILE_SOUTH); - mapSelIconWest = GUIUtils.getSysIcon(IGUIConstants.TILE_SEL_TILE_WEST); - mapPreSelIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_PRESEL_TILE); - mapCursorIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_CURSOR); - emptyTileIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_EMPTY); - unknownTileIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_UNKNOWN); + mapSelIcon = GUIUtils.getSysIcon(GUIConstants.TILE_SEL_TILE); + mapSelIconNorth = GUIUtils.getSysIcon(GUIConstants.TILE_SEL_TILE_NORTH); + mapSelIconEast = GUIUtils.getSysIcon(GUIConstants.TILE_SEL_TILE_EAST); + mapSelIconSouth = GUIUtils.getSysIcon(GUIConstants.TILE_SEL_TILE_SOUTH); + mapSelIconWest = GUIUtils.getSysIcon(GUIConstants.TILE_SEL_TILE_WEST); + mapPreSelIcon = GUIUtils.getSysIcon(GUIConstants.TILE_PRESEL_TILE); + mapCursorIcon = GUIUtils.getSysIcon(GUIConstants.TILE_CURSOR); + emptyTileIcon = GUIUtils.getSysIcon(GUIConstants.TILE_EMPTY); + unknownTileIcon = GUIUtils.getSysIcon(GUIConstants.TILE_UNKNOWN); warningSquareIcon = createWarningSquareIcon(); - nofaceTileIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_NOFACE); - noarchTileIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_NOARCH); - defaultIcon = GUIUtils.getSysIcon(IGUIConstants.DEFAULT_ICON); - defaultPreview = GUIUtils.getSysIcon(IGUIConstants.DEFAULT_PREVIEW); + nofaceTileIcon = GUIUtils.getSysIcon(GUIConstants.TILE_NOFACE); + noarchTileIcon = GUIUtils.getSysIcon(GUIConstants.TILE_NOARCH); + defaultIcon = GUIUtils.getSysIcon(GUIConstants.DEFAULT_ICON); + defaultPreview = GUIUtils.getSysIcon(GUIConstants.DEFAULT_PREVIEW); } private static ImageIcon createWarningSquareIcon() { final ImageFilter alphaFilter = AbstractFaceObjects.ALPHA_FILTER; - final ImageIcon sysIcon = GUIUtils.getSysIcon(IGUIConstants.TILE_WARNING); + final ImageIcon sysIcon = GUIUtils.getSysIcon(GUIConstants.TILE_WARNING); final Image image = sysIcon.getImage(); final ImageProducer source = image.getSource(); final FilteredImageSource producer = new FilteredImageSource(source, alphaFilter); Modified: trunk/daimonin/src/daieditor/IGUIConstants.java =================================================================== --- trunk/daimonin/src/daieditor/IGUIConstants.java 2008-03-31 21:29:51 UTC (rev 3788) +++ trunk/daimonin/src/daieditor/IGUIConstants.java 2008-03-31 21:38:47 UTC (rev 3789) @@ -88,32 +88,6 @@ /** Application icon definitions (icon-dir). */ String APP_ICON = "CFIcon.gif"; - String TILE_SEL_TILE = "seltile.png"; - - String TILE_SEL_TILE_NORTH = "seltile_n.png"; - - String TILE_SEL_TILE_EAST = "seltile_e.png"; - - String TILE_SEL_TILE_SOUTH = "seltile_s.png"; - - String TILE_SEL_TILE_WEST = "seltile_w.png"; - - String TILE_PRESEL_TILE = "preseltile.png"; - - String TILE_CURSOR = "cursor.png"; - - String TILE_EMPTY = "empty.png"; - - String TILE_UNKNOWN = "unknown.png"; - - String TILE_WARNING = "warning.png"; - String TILE_NORTH = "north.png"; - /** The default map icon to use if no icon can be created. */ - String DEFAULT_ICON = "default_icon.png"; - - /** The default map preview to use if no icon can be created. */ - String DEFAULT_PREVIEW = "default_preview.png"; - } // interface IGUIConstants Modified: trunk/src/app/net/sf/gridarta/gui/GUIConstants.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/GUIConstants.java 2008-03-31 21:29:51 UTC (rev 3788) +++ trunk/src/app/net/sf/gridarta/gui/GUIConstants.java 2008-03-31 21:38:47 UTC (rev 3789) @@ -59,6 +59,26 @@ int EDIT_TYPE_NONE = 0xffff + 1; // special case + String TILE_SEL_TILE = "seltile.png"; + + String TILE_SEL_TILE_NORTH = "seltile_n.png"; + + String TILE_SEL_TILE_EAST = "seltile_e.png"; + + String TILE_SEL_TILE_SOUTH = "seltile_s.png"; + + String TILE_SEL_TILE_WEST = "seltile_w.png"; + + String TILE_PRESEL_TILE = "preseltile.png"; + + String TILE_CURSOR = "cursor.png"; + + String TILE_EMPTY = "empty.png"; + + String TILE_UNKNOWN = "unknown.png"; + + String TILE_WARNING = "warning.png"; + String TILE_NOFACE = "noface.png"; String TILE_NOARCH = "noarch.png"; @@ -71,4 +91,10 @@ String TILE_TR_NO = "treasure_no.png"; + /** The default map icon to use if no icon can be created. */ + String DEFAULT_ICON = "default_icon.png"; + + /** The default map preview to use if no icon can be created. */ + String DEFAULT_PREVIEW = "default_preview.png"; + } // interface GUIConstants This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-31 22:01:43
|
Revision: 3790 http://gridarta.svn.sourceforge.net/gridarta/?rev=3790&view=rev Author: akirschbaum Date: 2008-03-31 15:01:41 -0700 (Mon, 31 Mar 2008) Log Message: ----------- Extract code for loading system icons into SystemIcons. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.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/CMainControl.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.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/AbstractMainControl.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/CellRenderer.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/SystemIcons.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-31 21:38:47 UTC (rev 3789) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-31 22:01:41 UTC (rev 3790) @@ -33,12 +33,7 @@ import cfeditor.map.MapArchObject; import cfeditor.map.MapControl; import cfeditor.script.ScriptController; -import java.awt.Image; import java.awt.Point; -import java.awt.Toolkit; -import java.awt.image.FilteredImageSource; -import java.awt.image.ImageFilter; -import java.awt.image.ImageProducer; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; @@ -48,7 +43,6 @@ import java.util.Map; import java.util.MissingResourceException; import java.util.prefs.Preferences; -import javax.swing.ImageIcon; import javax.swing.JFileChooser; import javax.swing.JMenu; import javax.swing.JOptionPane; @@ -61,7 +55,6 @@ import net.sf.gridarta.XmlHelper; import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.Collector; -import net.sf.gridarta.gameobject.face.AbstractFaceObjects; import net.sf.gridarta.gui.About; import net.sf.gridarta.gui.GUIConstants; import net.sf.gridarta.gui.GUIUtils; @@ -72,6 +65,7 @@ import net.sf.gridarta.gui.MapManagerActions; import net.sf.gridarta.gui.NewMapDialogFactory; import net.sf.gridarta.gui.RecentManager; +import net.sf.gridarta.gui.SystemIcons; import net.sf.gridarta.gui.map.MapCursorControl; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.prefs.MapValidatorPrefs; @@ -174,35 +168,6 @@ /** The Spells. */ private final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells = new Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>>(); - // icons for the map and arch pictures. - private static ImageIcon mapSelIcon; - - private static ImageIcon mapSelIconNorth; - - private static ImageIcon mapSelIconEast; - - private static ImageIcon mapSelIconSouth; - - private static ImageIcon mapSelIconWest; - - private static ImageIcon mapPreSelIcon; - - private static ImageIcon mapCursorIcon; - - private static ImageIcon emptyTileIcon; - - private static ImageIcon warningSquareIcon; - - private static ImageIcon nofaceTileIcon; - - private static ImageIcon noarchTileIcon; - - /** The default image for map icon. */ - private static ImageIcon defaultIcon; - - /** The default image for map previews. */ - private static ImageIcon defaultPreview; - /** * The ArchetypeSet, which is a registry of all Archetypes. */ @@ -287,8 +252,8 @@ readGlobalSettings(); - loadDefTiles(); - createMapImageCache(CResourceLoader.getHomeFile("thumbnails"), defaultIcon, defaultPreview); + SystemIcons.init(); + createMapImageCache(CResourceLoader.getHomeFile("thumbnails"), SystemIcons.getDefaultIcon(), SystemIcons.getDefaultPreview()); // initialize the script-editor pad ScriptEditControl.init(strMapDir, this); @@ -940,81 +905,6 @@ mainView.appExitNotify(); // notify main view } - public static ImageIcon getMapCursorIcon() { - return mapCursorIcon; - } - - public static ImageIcon getEmptyTileIcon() { - return emptyTileIcon; - } - - public static ImageIcon getWarningSquareIcon() { - return warningSquareIcon; - } - - public static ImageIcon getNofaceTileIcon() { - return nofaceTileIcon; - } - - public static ImageIcon getNoarchTileIcon() { - return noarchTileIcon; - } - - public static ImageIcon getMapSelIcon() { - return mapSelIcon; - } - - public static ImageIcon getMapSelIconNorth() { - return mapSelIconNorth; - } - - public static ImageIcon getMapSelIconEast() { - return mapSelIconEast; - } - - public static ImageIcon getMapSelIconSouth() { - return mapSelIconSouth; - } - - public static ImageIcon getMapSelIconWest() { - return mapSelIconWest; - } - - public static ImageIcon getMapPreSelIcon() { - return mapPreSelIcon; - } - - /** - * Load all system tile icons into temporary variables for more convenient - * access. - */ - private static void loadDefTiles() { - mapSelIcon = GUIUtils.getSysIcon(GUIConstants.TILE_SEL_TILE); - mapSelIconNorth = GUIUtils.getSysIcon(GUIConstants.TILE_SEL_TILE_NORTH); - mapSelIconEast = GUIUtils.getSysIcon(GUIConstants.TILE_SEL_TILE_EAST); - mapSelIconSouth = GUIUtils.getSysIcon(GUIConstants.TILE_SEL_TILE_SOUTH); - mapSelIconWest = GUIUtils.getSysIcon(GUIConstants.TILE_SEL_TILE_WEST); - mapPreSelIcon = GUIUtils.getSysIcon(GUIConstants.TILE_PRESEL_TILE); - mapCursorIcon = GUIUtils.getSysIcon(GUIConstants.TILE_CURSOR); - emptyTileIcon = GUIUtils.getSysIcon(GUIConstants.TILE_EMPTY); - unknownTileIcon = GUIUtils.getSysIcon(GUIConstants.TILE_UNKNOWN); - warningSquareIcon = createWarningSquareIcon(); - nofaceTileIcon = GUIUtils.getSysIcon(GUIConstants.TILE_NOFACE); - noarchTileIcon = GUIUtils.getSysIcon(GUIConstants.TILE_NOARCH); - defaultIcon = GUIUtils.getSysIcon(GUIConstants.DEFAULT_ICON); - defaultPreview = GUIUtils.getSysIcon(GUIConstants.DEFAULT_PREVIEW); - } - - private static ImageIcon createWarningSquareIcon() { - final ImageFilter alphaFilter = AbstractFaceObjects.ALPHA_FILTER; - final ImageIcon sysIcon = GUIUtils.getSysIcon(GUIConstants.TILE_WARNING); - final Image image = sysIcon.getImage(); - final ImageProducer source = image.getSource(); - final FilteredImageSource producer = new FilteredImageSource(source, alphaFilter); - final Image image2 = Toolkit.getDefaultToolkit().createImage(producer); - return new ImageIcon(image2); - } - /** {@inheritDoc} */ public void handleThrowable(final Throwable t) { mainView.handleThrowable(t); Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-03-31 21:38:47 UTC (rev 3789) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-03-31 22:01:41 UTC (rev 3790) @@ -38,10 +38,10 @@ import java.util.Arrays; import java.util.List; import javax.swing.ImageIcon; -import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.gameobject.AbstractArchetypeParser; import net.sf.gridarta.gameobject.AbstractArchetypeSet; import net.sf.gridarta.gameobject.face.DuplicateFaceException; +import net.sf.gridarta.gui.SystemIcons; import net.sf.gridarta.io.IOUtils; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.misc.Progress; @@ -93,21 +93,21 @@ */ @NotNull private ImageIcon getFace(@NotNull final String faceName, final boolean hasUndefinedArchetype) { if (hasUndefinedArchetype) { - return CMainControl.getNoarchTileIcon(); + return SystemIcons.getNoarchTileIcon(); } if (faceName == null) { - return CMainControl.getNofaceTileIcon(); + return SystemIcons.getNofaceTileIcon(); } final FaceObject faceObject = mainControl.getFaceObjects().get(faceName); if (faceObject == null) { - return AbstractMainControl.getUnknownTileIcon(); + return SystemIcons.getUnknownTileIcon(); } final ImageIcon face = faceObject.getFace(); if (face == null) { - return AbstractMainControl.getUnknownTileIcon(); + return SystemIcons.getUnknownTileIcon(); } return face; Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2008-03-31 21:38:47 UTC (rev 3789) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2008-03-31 22:01:41 UTC (rev 3790) @@ -19,7 +19,6 @@ package cfeditor.gui.map; -import cfeditor.CMainControl; import cfeditor.gameobject.Archetype; import cfeditor.gameobject.GameObject; import cfeditor.map.MapArchObject; @@ -37,6 +36,7 @@ import javax.imageio.ImageIO; import javax.swing.JComponent; import net.sf.gridarta.Size2D; +import net.sf.gridarta.gui.SystemIcons; import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapGrid; import net.sf.gridarta.gui.map.MapGridEvent; @@ -285,28 +285,28 @@ protected void paintTileSelection(final Graphics grfx, final Point point) { final int gridFlags = mapGrid.getFlags(point.x, point.y); if ((gridFlags & MapGrid.GRID_FLAG_SELECTION) != 0) { - CMainControl.getMapSelIcon().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); + SystemIcons.getMapSelIcon().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); } if ((gridFlags & MapGrid.GRID_FLAG_SELECTION_NORTH) != 0) { - CMainControl.getMapSelIconNorth().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); + SystemIcons.getMapSelIconNorth().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); } if ((gridFlags & MapGrid.GRID_FLAG_SELECTION_EAST) != 0) { - CMainControl.getMapSelIconEast().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); + SystemIcons.getMapSelIconEast().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); } if ((gridFlags & MapGrid.GRID_FLAG_SELECTION_SOUTH) != 0) { - CMainControl.getMapSelIconSouth().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); + SystemIcons.getMapSelIconSouth().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); } if ((gridFlags & MapGrid.GRID_FLAG_SELECTION_WEST) != 0) { - CMainControl.getMapSelIconWest().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); + SystemIcons.getMapSelIconWest().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); } if ((gridFlags & MapGrid.GRID_FLAG_SELECTING) != 0) { - CMainControl.getMapPreSelIcon().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); + SystemIcons.getMapPreSelIcon().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); } if ((gridFlags & MapGrid.GRID_FLAG_CURSOR) != 0) { - CMainControl.getMapCursorIcon().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); + SystemIcons.getMapCursorIcon().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); } if ((gridFlags & MapGrid.GRID_FLAG_ERROR) != 0) { - CMainControl.getWarningSquareIcon().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); + SystemIcons.getWarningSquareIcon().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); } } Modified: trunk/crossfire/src/cfeditor/gui/map/MapRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapRenderer.java 2008-03-31 21:38:47 UTC (rev 3789) +++ trunk/crossfire/src/cfeditor/gui/map/MapRenderer.java 2008-03-31 22:01:41 UTC (rev 3790) @@ -32,6 +32,7 @@ import java.awt.image.BufferedImage; import java.lang.ref.SoftReference; import javax.swing.ImageIcon; +import net.sf.gridarta.gui.SystemIcons; import net.sf.gridarta.gui.map.MapGrid; import org.apache.log4j.Logger; import org.jetbrains.annotations.Nullable; @@ -181,7 +182,7 @@ filter.newSquare(); setColor(grfx); if (mapModel.getMapSquare(point).isEmpty()) { - CMainControl.getEmptyTileIcon().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); + SystemIcons.getEmptyTileIcon().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); } else { grfx.fillRect(borderOffset.x + point.x * 32, borderOffset.y + point.y * 32, 32, 32); for (final GameObject node : mapModel.getMapSquare(point)) { Modified: trunk/crossfire/src/cfeditor/gui/map/SimpleLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/SimpleLevelRenderer.java 2008-03-31 21:38:47 UTC (rev 3789) +++ trunk/crossfire/src/cfeditor/gui/map/SimpleLevelRenderer.java 2008-03-31 22:01:41 UTC (rev 3790) @@ -19,7 +19,6 @@ package cfeditor.gui.map; -import cfeditor.CMainControl; import cfeditor.gameobject.Archetype; import cfeditor.gameobject.ArchetypeSet; import cfeditor.gameobject.GameObject; @@ -31,6 +30,7 @@ import javax.swing.ImageIcon; import javax.swing.JComponent; import net.sf.gridarta.Size2D; +import net.sf.gridarta.gui.SystemIcons; import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.map.MapModel; import org.jetbrains.annotations.NotNull; @@ -111,7 +111,7 @@ */ private void paintTile(@NotNull final Graphics grfx, @NotNull final Point point) { if (mapModel.getMapSquare(point).isEmpty()) { - CMainControl.getEmptyTileIcon().paintIcon(this, grfx, point.x * 32, point.y * 32); + SystemIcons.getEmptyTileIcon().paintIcon(this, grfx, point.x * 32, point.y * 32); return; } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-03-31 21:38:47 UTC (rev 3789) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-03-31 22:01:41 UTC (rev 3790) @@ -36,12 +36,7 @@ import daieditor.map.validation.checks.ExitChecker; import daieditor.map.validation.checks.SlayingChecker; import daieditor.map.validation.checks.TilePathsChecker; -import java.awt.Image; import java.awt.Point; -import java.awt.Toolkit; -import java.awt.image.FilteredImageSource; -import java.awt.image.ImageFilter; -import java.awt.image.ImageProducer; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; @@ -53,7 +48,6 @@ import java.util.MissingResourceException; import java.util.ResourceBundle; import java.util.prefs.Preferences; -import javax.swing.ImageIcon; import javax.swing.JFileChooser; import javax.swing.JMenu; import javax.swing.JOptionPane; @@ -66,7 +60,6 @@ import net.sf.gridarta.XmlHelper; import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.Collector; -import net.sf.gridarta.gameobject.face.AbstractFaceObjects; import net.sf.gridarta.gameobject.match.MutableOrGameObjectMatcher; import net.sf.gridarta.gameobject.match.ViewGameObjectMatcherManager; import net.sf.gridarta.gui.About; @@ -79,6 +72,7 @@ import net.sf.gridarta.gui.MapManagerActions; import net.sf.gridarta.gui.NewMapDialogFactory; import net.sf.gridarta.gui.RecentManager; +import net.sf.gridarta.gui.SystemIcons; import net.sf.gridarta.gui.map.MapCursorControl; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.prefs.MapValidatorPrefs; @@ -211,35 +205,6 @@ /** The Spells. */ private final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells = new Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>>(); - // icons for the map and arch pictures. - private static ImageIcon mapSelIcon; - - private static ImageIcon mapSelIconNorth; - - private static ImageIcon mapSelIconEast; - - private static ImageIcon mapSelIconSouth; - - private static ImageIcon mapSelIconWest; - - private static ImageIcon mapPreSelIcon; - - private static ImageIcon mapCursorIcon; - - private static ImageIcon emptyTileIcon; - - private static ImageIcon warningSquareIcon; - - private static ImageIcon nofaceTileIcon; - - private static ImageIcon noarchTileIcon; - - /** The default image for map icon. */ - private static ImageIcon defaultIcon; - - /** The default image for map previews. */ - private static ImageIcon defaultPreview; - /** * The ArchetypeSet, which is a registry of all Archetypes. */ @@ -336,8 +301,8 @@ readGlobalSettings(); - loadDefTiles(); - createMapImageCache(null, defaultIcon, defaultPreview); + SystemIcons.init(); + createMapImageCache(null, SystemIcons.getDefaultIcon(), SystemIcons.getDefaultPreview()); // initialize & load MultiPositionData.init(); @@ -1082,81 +1047,6 @@ mainView.appExitNotify(); // notify main view } - public static ImageIcon getMapCursorIcon() { - return mapCursorIcon; - } - - public static ImageIcon getEmptyTileIcon() { - return emptyTileIcon; - } - - public static ImageIcon getWarningSquareIcon() { - return warningSquareIcon; - } - - public static ImageIcon getNofaceTileIcon() { - return nofaceTileIcon; - } - - public static ImageIcon getNoarchTileIcon() { - return noarchTileIcon; - } - - public static ImageIcon getMapSelIcon() { - return mapSelIcon; - } - - public static ImageIcon getMapSelIconNorth() { - return mapSelIconNorth; - } - - public static ImageIcon getMapSelIconEast() { - return mapSelIconEast; - } - - public static ImageIcon getMapSelIconSouth() { - return mapSelIconSouth; - } - - public static ImageIcon getMapSelIconWest() { - return mapSelIconWest; - } - - public static ImageIcon getMapPreSelIcon() { - return mapPreSelIcon; - } - - /** - * Load all system tile icons into temporary variables for more convenient - * access. - */ - private static void loadDefTiles() { - mapSelIcon = GUIUtils.getSysIcon(GUIConstants.TILE_SEL_TILE); - mapSelIconNorth = GUIUtils.getSysIcon(GUIConstants.TILE_SEL_TILE_NORTH); - mapSelIconEast = GUIUtils.getSysIcon(GUIConstants.TILE_SEL_TILE_EAST); - mapSelIconSouth = GUIUtils.getSysIcon(GUIConstants.TILE_SEL_TILE_SOUTH); - mapSelIconWest = GUIUtils.getSysIcon(GUIConstants.TILE_SEL_TILE_WEST); - mapPreSelIcon = GUIUtils.getSysIcon(GUIConstants.TILE_PRESEL_TILE); - mapCursorIcon = GUIUtils.getSysIcon(GUIConstants.TILE_CURSOR); - emptyTileIcon = GUIUtils.getSysIcon(GUIConstants.TILE_EMPTY); - unknownTileIcon = GUIUtils.getSysIcon(GUIConstants.TILE_UNKNOWN); - warningSquareIcon = createWarningSquareIcon(); - nofaceTileIcon = GUIUtils.getSysIcon(GUIConstants.TILE_NOFACE); - noarchTileIcon = GUIUtils.getSysIcon(GUIConstants.TILE_NOARCH); - defaultIcon = GUIUtils.getSysIcon(GUIConstants.DEFAULT_ICON); - defaultPreview = GUIUtils.getSysIcon(GUIConstants.DEFAULT_PREVIEW); - } - - private static ImageIcon createWarningSquareIcon() { - final ImageFilter alphaFilter = AbstractFaceObjects.ALPHA_FILTER; - final ImageIcon sysIcon = GUIUtils.getSysIcon(GUIConstants.TILE_WARNING); - final Image image = sysIcon.getImage(); - final ImageProducer source = image.getSource(); - final FilteredImageSource producer = new FilteredImageSource(source, alphaFilter); - final Image image2 = Toolkit.getDefaultToolkit().createImage(producer); - return new ImageIcon(image2); - } - /** {@inheritDoc} */ public void handleThrowable(final Throwable t) { mainView.handleThrowable(t); Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-03-31 21:38:47 UTC (rev 3789) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-03-31 22:01:41 UTC (rev 3790) @@ -39,12 +39,12 @@ import java.util.Arrays; import java.util.List; import javax.swing.ImageIcon; -import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.gameobject.AbstractArchetypeParser; import net.sf.gridarta.gameobject.AbstractArchetypeSet; import net.sf.gridarta.gameobject.anim.AnimationParseException; import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; import net.sf.gridarta.gameobject.face.DuplicateFaceException; +import net.sf.gridarta.gui.SystemIcons; import net.sf.gridarta.io.IOUtils; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.misc.Progress; @@ -91,16 +91,16 @@ */ @NotNull private ImageIcon getFace(final String faceName, final boolean hasUndefinedArchetype) { if (hasUndefinedArchetype) { - return CMainControl.getNoarchTileIcon(); + return SystemIcons.getNoarchTileIcon(); } if (faceName == null) { - return CMainControl.getNofaceTileIcon(); + return SystemIcons.getNofaceTileIcon(); } final ImageIcon face = FaceObjects.normal.getImageIconForFacename(faceName); if (face == null) { - return AbstractMainControl.getUnknownTileIcon(); + return SystemIcons.getUnknownTileIcon(); } return face; @@ -130,16 +130,16 @@ */ @NotNull private ImageIcon getTrans(final String faceName, final boolean hasUndefinedArchetype) { if (hasUndefinedArchetype) { - return CMainControl.getNoarchTileIcon(); + return SystemIcons.getNoarchTileIcon(); } if (faceName == null) { - return CMainControl.getNofaceTileIcon(); + return SystemIcons.getNofaceTileIcon(); } final ImageIcon face = FaceObjects.ALPHA.getImageIconForFacename(faceName); if (face == null) { - return AbstractMainControl.getUnknownTileIcon(); + return SystemIcons.getUnknownTileIcon(); } return face; Modified: trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2008-03-31 21:38:47 UTC (rev 3789) +++ trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2008-03-31 22:01:41 UTC (rev 3790) @@ -42,8 +42,8 @@ import javax.imageio.ImageIO; import javax.swing.ImageIcon; import javax.swing.JComponent; -import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.Size2D; +import net.sf.gridarta.gui.SystemIcons; import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapGrid; import net.sf.gridarta.gui.map.MapGridEvent; @@ -92,8 +92,8 @@ /** Whether to check for double arches. */ private transient boolean drawDoubleFaces; - private final ImageIcon unknownTileIcon = AbstractMainControl.getUnknownTileIcon(); - private final ImageIcon warningSquareIcon = CMainControl.getWarningSquareIcon(); + private final ImageIcon unknownTileIcon = SystemIcons.getUnknownTileIcon(); + private final ImageIcon warningSquareIcon = SystemIcons.getWarningSquareIcon(); /** The MapSquares that are known to contain errors. */ private Map<MapSquare<GameObject, MapArchObject, Archetype>, ValidationError<GameObject, MapArchObject, Archetype>> erroneousMapSquares; @@ -415,13 +415,13 @@ return; } final long start = System.currentTimeMillis(); - final Image selImg = CMainControl.getMapSelIcon().getImage(); - final Image selImgNorth = CMainControl.getMapSelIconNorth().getImage(); - final Image selImgEast = CMainControl.getMapSelIconEast().getImage(); - final Image selImgSouth = CMainControl.getMapSelIconSouth().getImage(); - final Image selImgWest = CMainControl.getMapSelIconWest().getImage(); - final Image preSelImg = CMainControl.getMapPreSelIcon().getImage(); - final Image cursorImg = CMainControl.getMapCursorIcon().getImage(); + final Image selImg = SystemIcons.getMapSelIcon().getImage(); + final Image selImgNorth = SystemIcons.getMapSelIconNorth().getImage(); + final Image selImgEast = SystemIcons.getMapSelIconEast().getImage(); + final Image selImgSouth = SystemIcons.getMapSelIconSouth().getImage(); + final Image selImgWest = SystemIcons.getMapSelIconWest().getImage(); + final Image preSelImg = SystemIcons.getMapPreSelIcon().getImage(); + final Image cursorImg = SystemIcons.getMapCursorIcon().getImage(); for (int y = 0; y < mapSize.getHeight(); y++) { int xstart = origin.x - (y + 1) * IGUIConstants.TILE_ISO_XLEN2; int ystart = origin.y + y * IGUIConstants.TILE_ISO_YLEN2; Modified: trunk/daimonin/src/daieditor/gui/map/MapRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/MapRenderer.java 2008-03-31 21:38:47 UTC (rev 3789) +++ trunk/daimonin/src/daieditor/gui/map/MapRenderer.java 2008-03-31 22:01:41 UTC (rev 3790) @@ -27,6 +27,7 @@ import daieditor.map.MapControl; import java.awt.Graphics2D; import javax.swing.ImageIcon; +import net.sf.gridarta.gui.SystemIcons; import net.sf.gridarta.gui.map.MapGrid; import net.sf.gridarta.map.MapSquare; import org.jetbrains.annotations.NotNull; @@ -41,7 +42,7 @@ /** Serial Version UID. */ private static final long serialVersionUID = 1L; - private final ImageIcon emptyTileIcon = CMainControl.getEmptyTileIcon(); + private final ImageIcon emptyTileIcon = SystemIcons.getEmptyTileIcon(); private final CMainControl mainControl; Modified: trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java 2008-03-31 21:38:47 UTC (rev 3789) +++ trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java 2008-03-31 22:01:41 UTC (rev 3790) @@ -32,8 +32,8 @@ import java.awt.image.BufferedImage; import javax.swing.ImageIcon; import javax.swing.JComponent; -import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.Size2D; +import net.sf.gridarta.gui.SystemIcons; import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.map.MapModel; import net.sf.gridarta.map.MapSquare; @@ -57,7 +57,7 @@ */ @NotNull private final MapModel<GameObject, MapArchObject, Archetype> mapModel; - private final ImageIcon unknownTileIcon = AbstractMainControl.getUnknownTileIcon(); + private final ImageIcon unknownTileIcon = SystemIcons.getUnknownTileIcon(); /** * Create a SimpleLevelRenderer. Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-03-31 21:38:47 UTC (rev 3789) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-03-31 22:01:41 UTC (rev 3790) @@ -83,8 +83,6 @@ */ protected boolean hasChangedDir = false; - protected static ImageIcon unknownTileIcon; - /** The autojoin lists. */ private final AutojoinLists<G, A, R> autojoinLists = new AutojoinLists<G, A, R>(); @@ -200,10 +198,6 @@ mapPreviewAccessory.attachTo(fileChooser); } - public static ImageIcon getUnknownTileIcon() { - return unknownTileIcon; - } - /** {@inheritDoc} */ public AutojoinLists<G, A, R> getAutojoinLists() { return autojoinLists; Added: trunk/src/app/net/sf/gridarta/gui/SystemIcons.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/SystemIcons.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/SystemIcons.java 2008-03-31 22:01:41 UTC (rev 3790) @@ -0,0 +1,167 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui; + +import java.awt.Image; +import java.awt.Toolkit; +import java.awt.image.FilteredImageSource; +import java.awt.image.ImageFilter; +import java.awt.image.ImageProducer; +import javax.swing.ImageIcon; +import net.sf.gridarta.gameobject.face.AbstractFaceObjects; + +/** + * Utility class for system icons. + * @author Andreas Kirschbaum + */ +public class SystemIcons { + + private static ImageIcon mapSelIcon; + + private static ImageIcon mapSelIconNorth; + + private static ImageIcon mapSelIconEast; + + private static ImageIcon mapSelIconSouth; + + private static ImageIcon mapSelIconWest; + + private static ImageIcon mapPreSelIcon; + + private static ImageIcon mapCursorIcon; + + private static ImageIcon emptyTileIcon; + + private static ImageIcon unknownTileIcon; + + private static ImageIcon warningSquareIcon; + + private static ImageIcon nofaceTileIcon; + + private static ImageIcon noarchTileIcon; + + /** The default image for map previews. */ + private static ImageIcon defaultIcon; + + /** The default image for map icon. */ + private static ImageIcon defaultPreview; + + /** + * Private constructor to prevent instantiation. + */ + private SystemIcons() { + } + + /** + * Loads all system tile icons into temporary variables for more convenient + * access. + */ + public static void init() { + mapSelIcon = GUIUtils.getSysIcon(GUIConstants.TILE_SEL_TILE); + mapSelIconNorth = GUIUtils.getSysIcon(GUIConstants.TILE_SEL_TILE_NORTH); + mapSelIconEast = GUIUtils.getSysIcon(GUIConstants.TILE_SEL_TILE_EAST); + mapSelIconSouth = GUIUtils.getSysIcon(GUIConstants.TILE_SEL_TILE_SOUTH); + mapSelIconWest = GUIUtils.getSysIcon(GUIConstants.TILE_SEL_TILE_WEST); + mapPreSelIcon = GUIUtils.getSysIcon(GUIConstants.TILE_PRESEL_TILE); + mapCursorIcon = GUIUtils.getSysIcon(GUIConstants.TILE_CURSOR); + emptyTileIcon = GUIUtils.getSysIcon(GUIConstants.TILE_EMPTY); + unknownTileIcon = GUIUtils.getSysIcon(GUIConstants.TILE_UNKNOWN); + warningSquareIcon = createWarningSquareIcon(); + nofaceTileIcon = GUIUtils.getSysIcon(GUIConstants.TILE_NOFACE); + noarchTileIcon = GUIUtils.getSysIcon(GUIConstants.TILE_NOARCH); + defaultIcon = GUIUtils.getSysIcon(GUIConstants.DEFAULT_ICON); + defaultPreview = GUIUtils.getSysIcon(GUIConstants.DEFAULT_PREVIEW); + } + + private static ImageIcon createWarningSquareIcon() { + final ImageFilter alphaFilter = AbstractFaceObjects.ALPHA_FILTER; + final ImageIcon sysIcon = GUIUtils.getSysIcon(GUIConstants.TILE_WARNING); + final Image image = sysIcon.getImage(); + final ImageProducer source = image.getSource(); + final FilteredImageSource producer = new FilteredImageSource(source, alphaFilter); + final Image image2 = Toolkit.getDefaultToolkit().createImage(producer); + return new ImageIcon(image2); + } + + public static ImageIcon getMapCursorIcon() { + return mapCursorIcon; + } + + public static ImageIcon getEmptyTileIcon() { + return emptyTileIcon; + } + + public static ImageIcon getUnknownTileIcon() { + return unknownTileIcon; + } + + public static ImageIcon getWarningSquareIcon() { + return warningSquareIcon; + } + + public static ImageIcon getNofaceTileIcon() { + return nofaceTileIcon; + } + + public static ImageIcon getNoarchTileIcon() { + return noarchTileIcon; + } + + public static ImageIcon getMapSelIcon() { + return mapSelIcon; + } + + public static ImageIcon getMapSelIconNorth() { + return mapSelIconNorth; + } + + public static ImageIcon getMapSelIconEast() { + return mapSelIconEast; + } + + public static ImageIcon getMapSelIconSouth() { + return mapSelIconSouth; + } + + public static ImageIcon getMapSelIconWest() { + return mapSelIconWest; + } + + public static ImageIcon getMapPreSelIcon() { + return mapPreSelIcon; + } + + /** + * Returns the default image for map previews. + * @return the image + */ + public static ImageIcon getDefaultIcon() { + return defaultIcon; + } + + /** + * Retruns the default image for map icon. + * @return the image + */ + public static ImageIcon getDefaultPreview() { + return defaultPreview; + } + +} // class SystemIcons Property changes on: trunk/src/app/net/sf/gridarta/gui/SystemIcons.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/CellRenderer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/CellRenderer.java 2008-03-31 21:38:47 UTC (rev 3789) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/CellRenderer.java 2008-03-31 22:01:41 UTC (rev 3790) @@ -23,11 +23,11 @@ import javax.swing.BorderFactory; import javax.swing.DefaultListCellRenderer; import javax.swing.JList; -import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gameobject.GameObjectContainer; +import net.sf.gridarta.gui.SystemIcons; import net.sf.gridarta.map.MapArchObject; import org.jetbrains.annotations.NotNull; @@ -79,7 +79,7 @@ } } } else { - setIcon(AbstractMainControl.getUnknownTileIcon()); + setIcon(SystemIcons.getUnknownTileIcon()); setText("?"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-31 23:32:58
|
Revision: 3793 http://gridarta.svn.sourceforge.net/gridarta/?rev=3793&view=rev Author: akirschbaum Date: 2008-03-31 16:33:03 -0700 (Mon, 31 Mar 2008) Log Message: ----------- Remove CMainView.setMapTileListBottom(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-31 22:14:10 UTC (rev 3792) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-31 23:33:03 UTC (rev 3793) @@ -523,8 +523,6 @@ loadFromArchive = prefs.getBoolean(LOAD_ARCH_COLL, true); - mainView.setMapTileListBottom(prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT)); - // docu version if (IGUIConstants.DOCU_VERSION > prefs.getInt(DOCU_VERSION_KEY, 0)) { // remember to open docu Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-03-31 22:14:10 UTC (rev 3792) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-03-31 23:33:03 UTC (rev 3793) @@ -100,9 +100,6 @@ /** Attributes panel (bottom). */ private GameObjectAttributesPanel gameObjectAttributesPanel; - /** <code>true</code> when the object chooser is merged into the bottom panel. */ - private boolean mapTileListBottom = true; - private final Action aViewTreasurelists; /** The action for "close all map windows". */ @@ -207,6 +204,7 @@ final int divLocation = prefs.getInt(DIVIDER_LOCATION_KEY, (int) (defwidth * 0.17)); objectChooser = new InsertionObjectChooser(newMapDialogFactory, mainControl); + final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT); selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>("cfeditor", mainControl, this, mapTileListBottom, null); final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mapManager, Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER); gameObjectAttributesPanel = new GameObjectAttributesPanel(mainControl, mapManager, this, lockedItemsControl); @@ -232,15 +230,6 @@ return centerPanel; } - /** - * Sets <code>true</code> when the object chooser is merged into the bottom panel. - * @param mapTileListBottom <code>true</code> when the object chooser is merged into - * the bottom panel - */ - public void setMapTileListBottom(final boolean mapTileListBottom) { - this.mapTileListBottom = mapTileListBottom; - } - /** Notifies that the application is about to exit. */ void appExitNotify() { // Store the location and size Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-03-31 22:14:10 UTC (rev 3792) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-03-31 23:33:03 UTC (rev 3793) @@ -665,8 +665,6 @@ loadFromArchive = prefs.getBoolean(LOAD_ARCH_COLL, true); - mainView.setMapTileListBottom(prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT)); - // docu version if (IGUIConstants.DOCU_VERSION > prefs.getInt(DOCU_VERSION_KEY, 0)) { // remember to open docu Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-03-31 22:14:10 UTC (rev 3792) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-03-31 23:33:03 UTC (rev 3793) @@ -104,9 +104,6 @@ /** Attributes panel (bottom). */ private GameObjectAttributesPanel gameObjectAttributesPanel; - /** <code>true</code> when the object chooser is merged into the bottom panel. */ - private boolean mapTileListBottom = true; - private final Action aCollectSpells; private final Action aViewTreasurelists; @@ -211,6 +208,7 @@ final int divLocation = prefs.getInt(DIVIDER_LOCATION_KEY, (int) (defwidth * 0.17)); objectChooser = new InsertionObjectChooser(newMapDialogFactory, mainControl); + final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT); selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>("daieditor", mainControl, this, mapTileListBottom, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH)); final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mapManager, Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER); gameObjectAttributesPanel = new GameObjectAttributesPanel(mainControl, mapManager, this, lockedItemsControl); @@ -236,15 +234,6 @@ return centerPanel; } - /** - * Sets <code>true</code> when the object chooser is merged into the bottom panel. - * @param mapTileListBottom <code>true</code> when the object chooser is merged into - * the bottom panel - */ - public void setMapTileListBottom(final boolean mapTileListBottom) { - this.mapTileListBottom = mapTileListBottom; - } - /** Notifies that the application is about to exit. */ void appExitNotify() { // Store the location and size This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-31 23:45:10
|
Revision: 3794 http://gridarta.svn.sourceforge.net/gridarta/?rev=3794&view=rev Author: akirschbaum Date: 2008-03-31 16:45:15 -0700 (Mon, 31 Mar 2008) Log Message: ----------- Move code to create the main toolbar into a separate function. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainView.java trunk/daimonin/src/daieditor/CMainView.java Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-03-31 23:33:03 UTC (rev 3793) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-03-31 23:45:15 UTC (rev 3794) @@ -169,10 +169,8 @@ final int defwidth = (int) (0.9 * screen.getWidth()); final int defheight = (int) (0.9 * screen.getHeight()); - mainToolbar = ACTION_FACTORY.createToolBar("main"); + mainToolbar = createMainToolbar(); toolbarPanel.add(mainToolbar, BorderLayout.NORTH); - prefs.addPreferenceChangeListener(preferenceChangeListener); - mainToolbar.setVisible(prefs.getBoolean(SHOW_MAIN_TOOLBAR_KEY, SHOW_MAIN_TOOLBAR_DEFAULT)); toolbarPanel.add(createCenterPanel(defwidth, defheight, newMapDialogFactory), BorderLayout.CENTER); archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser); setJMenuBar(ACTION_FACTORY.createMenuBar(true, "main")); @@ -190,6 +188,17 @@ } /** + * Creates the toolbar. + * @return the toolbar + */ + private JToolBar createMainToolbar() { + final JToolBar toolbar = ACTION_FACTORY.createToolBar("main"); + prefs.addPreferenceChangeListener(preferenceChangeListener); + toolbar.setVisible(prefs.getBoolean(SHOW_MAIN_TOOLBAR_KEY, SHOW_MAIN_TOOLBAR_DEFAULT)); + return toolbar; + } + + /** * Create the center panel. * @param defwidth default width * @param defheight default height Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-03-31 23:33:03 UTC (rev 3793) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-03-31 23:45:15 UTC (rev 3794) @@ -173,10 +173,8 @@ final int defwidth = (int) (0.9 * screen.getWidth()); final int defheight = (int) (0.9 * screen.getHeight()); - mainToolbar = ACTION_FACTORY.createToolBar("main"); + mainToolbar = createMainToolbar(); toolbarPanel.add(mainToolbar, BorderLayout.NORTH); - prefs.addPreferenceChangeListener(preferenceChangeListener); - mainToolbar.setVisible(prefs.getBoolean(SHOW_MAIN_TOOLBAR_KEY, SHOW_MAIN_TOOLBAR_DEFAULT)); toolbarPanel.add(createCenterPanel(defwidth, defheight, newMapDialogFactory), BorderLayout.CENTER); archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser); setJMenuBar(ACTION_FACTORY.createMenuBar(true, "main")); @@ -194,6 +192,17 @@ } /** + * Creates the toolbar. + * @return the toolbar + */ + private JToolBar createMainToolbar() { + final JToolBar toolbar = ACTION_FACTORY.createToolBar("main"); + prefs.addPreferenceChangeListener(preferenceChangeListener); + toolbar.setVisible(prefs.getBoolean(SHOW_MAIN_TOOLBAR_KEY, SHOW_MAIN_TOOLBAR_DEFAULT)); + return toolbar; + } + + /** * Create the center panel. * @param defwidth default width * @param defheight default height This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-31 23:50:07
|
Revision: 3795 http://gridarta.svn.sourceforge.net/gridarta/?rev=3795&view=rev Author: akirschbaum Date: 2008-03-31 16:50:05 -0700 (Mon, 31 Mar 2008) Log Message: ----------- Reorder statements. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainView.java trunk/daimonin/src/daieditor/CMainView.java Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-03-31 23:45:15 UTC (rev 3794) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-03-31 23:50:05 UTC (rev 3795) @@ -161,17 +161,18 @@ * @param newMapDialogFactory the factory for creating new pickmaps */ void init(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory) { - final JPanel toolbarPanel = new JPanel(new BorderLayout()); - add(toolbarPanel, BorderLayout.CENTER); - // calculate some default values in case there is no settings file final Rectangle screen = getGraphicsConfiguration().getBounds(); final int defwidth = (int) (0.9 * screen.getWidth()); final int defheight = (int) (0.9 * screen.getHeight()); mainToolbar = createMainToolbar(); + + final JPanel toolbarPanel = new JPanel(new BorderLayout()); toolbarPanel.add(mainToolbar, BorderLayout.NORTH); toolbarPanel.add(createCenterPanel(defwidth, defheight, newMapDialogFactory), BorderLayout.CENTER); + add(toolbarPanel, BorderLayout.CENTER); + archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser); setJMenuBar(ACTION_FACTORY.createMenuBar(true, "main")); Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-03-31 23:45:15 UTC (rev 3794) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-03-31 23:50:05 UTC (rev 3795) @@ -165,17 +165,18 @@ * @param newMapDialogFactory the factory for creating new pickmaps */ void init(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory) { - final JPanel toolbarPanel = new JPanel(new BorderLayout()); - add(toolbarPanel, BorderLayout.CENTER); - // calculate some default values in case there is no settings file final Rectangle screen = getGraphicsConfiguration().getBounds(); final int defwidth = (int) (0.9 * screen.getWidth()); final int defheight = (int) (0.9 * screen.getHeight()); mainToolbar = createMainToolbar(); + + final JPanel toolbarPanel = new JPanel(new BorderLayout()); toolbarPanel.add(mainToolbar, BorderLayout.NORTH); toolbarPanel.add(createCenterPanel(defwidth, defheight, newMapDialogFactory), BorderLayout.CENTER); + add(toolbarPanel, BorderLayout.CENTER); + archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser); setJMenuBar(ACTION_FACTORY.createMenuBar(true, "main")); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-01 00:03:40
|
Revision: 3796 http://gridarta.svn.sourceforge.net/gridarta/?rev=3796&view=rev Author: akirschbaum Date: 2008-03-31 17:03:43 -0700 (Mon, 31 Mar 2008) Log Message: ----------- Move ViewActions to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/messages.properties trunk/crossfire/src/cfeditor/messages_de.properties trunk/crossfire/src/cfeditor/messages_fr.properties trunk/crossfire/src/cfeditor/messages_sv.properties trunk/src/app/net/sf/gridarta/messages.properties trunk/src/app/net/sf/gridarta/messages_de.properties trunk/src/app/net/sf/gridarta/messages_fr.properties trunk/src/app/net/sf/gridarta/messages_sv.properties Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/map/ViewActions.java Removed Paths: ------------- trunk/crossfire/src/cfeditor/ViewActions.java Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-03-31 23:50:05 UTC (rev 3795) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-04-01 00:03:43 UTC (rev 3796) @@ -52,6 +52,7 @@ import net.sf.gridarta.gui.NewMapDialogFactory; import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.map.MapView; +import net.sf.gridarta.gui.map.ViewActions; import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; @@ -111,7 +112,7 @@ /** Action for "next window". */ private final Action aNextWindow = ACTION_FACTORY.createAction(true, "nextWindow", this); - private final ViewActions viewActions; + private final ViewActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> viewActions; private final MapActions mapActions; @@ -145,7 +146,7 @@ aViewTreasurelists = ACTION_FACTORY.createAction(true, "viewTreasurelists", mainControl); this.aCloseAll = aCloseAll; - viewActions = new ViewActions(mainControl, mapManager); + viewActions = new ViewActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, mapManager); mapActions = new MapActions(mainControl, mapManager); final ImageIcon icon = GUIUtils.getIcon(IGUIConstants.APP_ICON); Deleted: trunk/crossfire/src/cfeditor/ViewActions.java =================================================================== --- trunk/crossfire/src/cfeditor/ViewActions.java 2008-03-31 23:50:05 UTC (rev 3795) +++ trunk/crossfire/src/cfeditor/ViewActions.java 2008-04-01 00:03:43 UTC (rev 3796) @@ -1,259 +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; - -import cfeditor.gameobject.Archetype; -import cfeditor.gameobject.GameObject; -import cfeditor.map.MapArchObject; -import cfeditor.map.MapControl; -import net.sf.gridarta.CurrentMapListener; -import net.sf.gridarta.MapManager; -import net.sf.gridarta.gui.GUIConstants; -import net.sf.gridarta.gui.map.MapCursorEvent; -import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.ToggleAction; -import org.jetbrains.annotations.NotNull; - -/** - * Manages edit type actions in "view" menu. - * @author Andreas Kirschbaum - */ -public class ViewActions { - - /** Action Factory to create Actions. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); - - /** The main control to use. */ - @NotNull private final CMainControl mainControl; - - /** The listener to check for current map changes. */ - private final CurrentMapListener<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> currentMapListener; - - /** Action for "show monster". */ - private final ToggleAction aShowMonster = (ToggleAction) ACTION_FACTORY.createToggle(true, "showMonster", this); - - /** Action for "show exit". */ - private final ToggleAction aShowExit = (ToggleAction) ACTION_FACTORY.createToggle(true, "showExit", this); - - /** Action for "show background". */ - private final ToggleAction aShowBackground = (ToggleAction) ACTION_FACTORY.createToggle(true, "showBackground", this); - - /** Action for "show door". */ - private final ToggleAction aShowDoor = (ToggleAction) ACTION_FACTORY.createToggle(true, "showDoor", this); - - /** Action for "show wall". */ - private final ToggleAction aShowWall = (ToggleAction) ACTION_FACTORY.createToggle(true, "showWall", this); - - /** Action for "show equipment". */ - private final ToggleAction aShowEquipment = (ToggleAction) ACTION_FACTORY.createToggle(true, "showEquipment", this); - - /** Action for "show treasure". */ - private final ToggleAction aShowTreasure = (ToggleAction) ACTION_FACTORY.createToggle(true, "showTreasure", this); - - /** Action for "show connected". */ - private final ToggleAction aShowConnected = (ToggleAction) ACTION_FACTORY.createToggle(true, "showConnected", this); - - /** - * Create a new instance. - * - * @param mainControl the main control to use - * - * @param mapManager the map manager - */ - public ViewActions(@NotNull final CMainControl mainControl, @NotNull final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager) { - this.mainControl = mainControl; - ACTION_FACTORY.createActions(true, this, "resetView"); - - currentMapListener = new CurrentMapListener<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, mapManager, null, false, false, false) { - - /** {@inheritDoc} */ - @Override protected void mapHasChanged() { - updateActions(); - } - - /** {@inheritDoc} */ - @Override protected void mapViewHasChanged() { - // ignore - } - - /** {@inheritDoc} */ - @Override protected void mapCursorChangedPos(@NotNull final MapCursorEvent e) { - updateActions(); - } - - /** {@inheritDoc} */ - @Override protected void mapCursorChangedMode(@NotNull final MapCursorEvent e) { - // ignore - } - - }; - updateActions(); - } - - /** - * Unregister all registered listeners. Must be called when this instance - * is freed. - */ - public void closeNotify() { - currentMapListener.closeNotify(); - } - - /** Action method for "reset view". */ - public void resetView() { - // set edit type to zero (-> show all) - mainControl.unsetEditType(~0); - updateActions(); - } - - /** - * Update the actions' state to the current edit mode. - */ - private void updateActions() { - aShowMonster.setSelected(isShowMonster()); - aShowExit.setSelected(isShowExit()); - aShowBackground.setSelected(isShowBackground()); - aShowDoor.setSelected(isShowDoor()); - aShowWall.setSelected(isShowWall()); - aShowEquipment.setSelected(isShowEquipment()); - aShowTreasure.setSelected(isShowTreasure()); - aShowConnected.setSelected(isShowConnected()); - } - - /** Action method for "show monster". - * @return <code>true</code> if showMonster is active, otherwise <code>false</code>. - */ - public boolean isShowMonster() { - return mainControl.isEditType(GUIConstants.EDIT_TYPE_MONSTER); - } - - /** Action method for "show monster". - * @param showMonster <code>true</code> if showMonster should be activated, otherwise <code>false</code>. - */ - public void setShowMonster(final boolean showMonster) { - setShow(showMonster, GUIConstants.EDIT_TYPE_MONSTER); - } - - /** Action method for "show exit". - * @return <code>true</code> if showExit is active, otherwise <code>false</code>. - */ - public boolean isShowExit() { - return mainControl.isEditType(GUIConstants.EDIT_TYPE_EXIT); - } - - /** Action method for "show exit". - * @param showExit <code>true</code> if showExit should be activated, otherwise <code>false</code>. - */ - public void setShowExit(final boolean showExit) { - setShow(showExit, GUIConstants.EDIT_TYPE_EXIT); - } - - /** Action method for "show background". - * @return <code>true</code> if showBackground is active, otherwise <code>false</code>. - */ - public boolean isShowBackground() { - return mainControl.isEditType(GUIConstants.EDIT_TYPE_BACKGROUND); - } - - /** Action method for "show background". - * @param showBackground <code>true</code> if showBackground should be activated, otherwise <code>false</code>. - */ - public void setShowBackground(final boolean showBackground) { - setShow(showBackground, GUIConstants.EDIT_TYPE_BACKGROUND); - } - - /** Action method for "show door". - * @return <code>true</code> if showDoor is active, otherwise <code>false</code>. - */ - public boolean isShowDoor() { - return mainControl.isEditType(GUIConstants.EDIT_TYPE_DOOR); - } - - /** Action method for "show door". - * @param showDoor <code>true</code> if showDoor should be activated, otherwise <code>false</code>. - */ - public void setShowDoor(final boolean showDoor) { - setShow(showDoor, GUIConstants.EDIT_TYPE_DOOR); - } - - /** Action method for "show wall". - * @return <code>true</code> if showWall is active, otherwise <code>false</code>. - */ - public boolean isShowWall() { - return mainControl.isEditType(GUIConstants.EDIT_TYPE_WALL); - } - - /** Action method for "show wall". - * @param showWall <code>true</code> if showWall should be activated, otherwise <code>false</code>. - */ - public void setShowWall(final boolean showWall) { - setShow(showWall, GUIConstants.EDIT_TYPE_WALL); - } - - /** Action method for "show equipment". - * @return <code>true</code> if showEquipment is active, otherwise <code>false</code>. - */ - public boolean isShowEquipment() { - return mainControl.isEditType(GUIConstants.EDIT_TYPE_EQUIP); - } - - /** Action method for "show equipment". - * @param showEquipment <code>true</code> if showEquipment should be activated, otherwise <code>false</code>. - */ - public void setShowEquipment(final boolean showEquipment) { - setShow(showEquipment, GUIConstants.EDIT_TYPE_EQUIP); - } - - /** Action method for "show treasure". - * @return <code>true</code> if showTreasure is active, otherwise <code>false</code>. - */ - public boolean isShowTreasure() { - return mainControl.isEditType(GUIConstants.EDIT_TYPE_TREASURE); - } - - /** Action method for "show treasure". - * @param showTreasure <code>true</code> if showTreasure should be activated, otherwise <code>false</code>. - */ - public void setShowTreasure(final boolean showTreasure) { - setShow(showTreasure, GUIConstants.EDIT_TYPE_TREASURE); - } - - /** Action method for "show connected". - * @return <code>true</code> if showConnected is active, otherwise <code>false</code>. - */ - public boolean isShowConnected() { - return mainControl.isEditType(GUIConstants.EDIT_TYPE_CONNECTED); - } - - /** Action method for "show connected". - * @param showConnected <code>true</code> if showConnected should be activated, otherwise <code>false</code>. - */ - public void setShowConnected(final boolean showConnected) { - setShow(showConnected, GUIConstants.EDIT_TYPE_CONNECTED); - } - - private void setShow(final boolean show, final int editType) { - if (show) { - mainControl.setEditType(editType); - } else { - mainControl.unsetEditType(editType); - } - } - -} // class ViewActions Modified: trunk/crossfire/src/cfeditor/messages.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages.properties 2008-03-31 23:50:05 UTC (rev 3795) +++ trunk/crossfire/src/cfeditor/messages.properties 2008-04-01 00:03:43 UTC (rev 3796) @@ -267,34 +267,7 @@ view.text=View view.mnemonic=V -showMonster.text=Show monsters -showMonster.mnemonic=M -showExit.text=Show exits -showExit.mnemonic=X - -showBackground.text=Show background -showBackground.mnemonic=B - -showDoor.text=Show doors & keys -showDoor.mnemonic=D - -showWall.text=Show walls -showWall.mnemonic=W - -showEquipment.text=Show equipment -showEquipment.mnemonic=E - -showTreasure.text=Show treasure -showTreasure.mnemonic=T - -showConnected.text=Show connected -showConnected.mnemonic=C - -resetView.text=Reset view -resetView.mnemonic=R - - ######### # Plugins Modified: trunk/crossfire/src/cfeditor/messages_de.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_de.properties 2008-03-31 23:50:05 UTC (rev 3795) +++ trunk/crossfire/src/cfeditor/messages_de.properties 2008-04-01 00:03:43 UTC (rev 3796) @@ -244,34 +244,7 @@ view.text=Ansicht view.mnemonic=A -showMonster.text=Monster anzeigen -showMonster.mnemonic=M -showExit.text=Ausg\xE4nge anzeigen -showExit.mnemonic=A - -showBackground.text=Hintergrund anzeigen -showBackground.mnemonic=H - -showDoor.text=T\xFCren und Schl\xFCssel anzeigen -showDoor.mnemonic=T - -showWall.text=W\xE4nde anzeigen -showWall.mnemonic=W - -showEquipment.text=Ausr\xFCstung anzeigen -showEquipment.mnemonic=U - -showTreasure.text=Sch\xE4tze anzeigen -showTreasure.mnemonic=S - -showConnected.text=Verbindungen anzeigen -showConnected.mnemonic=V - -resetView.text=Ansicht zur\xFCcksetzen -resetView.mnemonic=Z - - ######### # Plugins Modified: trunk/crossfire/src/cfeditor/messages_fr.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_fr.properties 2008-03-31 23:50:05 UTC (rev 3795) +++ trunk/crossfire/src/cfeditor/messages_fr.properties 2008-04-01 00:03:43 UTC (rev 3796) @@ -245,34 +245,7 @@ view.text=Affichage view.mnemonic=A -showMonster.text=Afficher monstres -showMonster.mnemonic=M -showExit.text=Afficher sorties -showExit.mnemonic=S - -showBackground.text=Afficher fond -showBackground.mnemonic=F - -showDoor.text=Afficher portes et cl\xE9s -showDoor.mnemonic=P - -showWall.text=Afficher murs -showWall.mnemonic=U - -showEquipment.text=Afficher \xE9quipement -showEquipment.mnemonic=E - -showTreasure.text=Afficher tr\xE9sors -showTreasure.mnemonic=T - -showConnected.text=Afficher objets connect\xE9s -showConnected.mnemonic=C - -resetView.text=Vue normale -resetView.mnemonic=N - - ######### # Plugins Modified: trunk/crossfire/src/cfeditor/messages_sv.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_sv.properties 2008-03-31 23:50:05 UTC (rev 3795) +++ trunk/crossfire/src/cfeditor/messages_sv.properties 2008-04-01 00:03:43 UTC (rev 3796) @@ -243,34 +243,7 @@ view.text=Visning view.mnemonic=V -showMonster.text=Monster -showMonster.mnemonic=M -showExit.text=Utg\xE5ngar -showExit.mnemonic=U - -showBackground.text=Bakgrund -showBackground.mnemonic=B - -showDoor.text=D\xF6rrar och nycklar -showDoor.mnemonic=D - -showWall.text=V\xE4ggar -showWall.mnemonic=V - -showEquipment.text=Utrustning -showEquipment.mnemonic=R - -showTreasure.text=Skatter -showTreasure.mnemonic=S - -showConnected.text=Anslutna -showConnected.mnemonic=A - -resetView.text=\xC5terst\xE4ll visning -resetView.mnemonic=V - - ######### # Plugins Copied: trunk/src/app/net/sf/gridarta/gui/map/ViewActions.java (from rev 3792, trunk/crossfire/src/cfeditor/ViewActions.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/ViewActions.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/map/ViewActions.java 2008-04-01 00:03:43 UTC (rev 3796) @@ -0,0 +1,260 @@ +/* + * 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; + +import net.sf.gridarta.CurrentMapListener; +import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.GUIConstants; +import net.sf.gridarta.gui.map.MapCursorEvent; +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; + +/** + * Manages edit type actions in "view" menu. + * @author Andreas Kirschbaum + */ +public class ViewActions<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, C extends MapControl<G, A, R>, V extends MapViewBasic<G, A, R>> { + + /** Action Factory to create Actions. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); + + /** The main control to use. */ + @NotNull private final MainControl<G, A, R, C, V> mainControl; + + /** The listener to check for current map changes. */ + private final CurrentMapListener<G, A, R, C, V> currentMapListener; + + /** Action for "show monster". */ + private final ToggleAction aShowMonster = (ToggleAction) ACTION_FACTORY.createToggle(true, "showMonster", this); + + /** Action for "show exit". */ + private final ToggleAction aShowExit = (ToggleAction) ACTION_FACTORY.createToggle(true, "showExit", this); + + /** Action for "show background". */ + private final ToggleAction aShowBackground = (ToggleAction) ACTION_FACTORY.createToggle(true, "showBackground", this); + + /** Action for "show door". */ + private final ToggleAction aShowDoor = (ToggleAction) ACTION_FACTORY.createToggle(true, "showDoor", this); + + /** Action for "show wall". */ + private final ToggleAction aShowWall = (ToggleAction) ACTION_FACTORY.createToggle(true, "showWall", this); + + /** Action for "show equipment". */ + private final ToggleAction aShowEquipment = (ToggleAction) ACTION_FACTORY.createToggle(true, "showEquipment", this); + + /** Action for "show treasure". */ + private final ToggleAction aShowTreasure = (ToggleAction) ACTION_FACTORY.createToggle(true, "showTreasure", this); + + /** Action for "show connected". */ + private final ToggleAction aShowConnected = (ToggleAction) ACTION_FACTORY.createToggle(true, "showConnected", this); + + /** + * Create a new instance. + * + * @param mainControl the main control to use + * + * @param mapManager the map manager + */ + public ViewActions(@NotNull final MainControl<G, A, R, C, V> mainControl, @NotNull final MapManager<G, A, R, C, V> mapManager) { + this.mainControl = mainControl; + ACTION_FACTORY.createActions(true, this, "resetView"); + + currentMapListener = new CurrentMapListener<G, A, R, C, V>(mainControl, mapManager, null, false, false, false) { + + /** {@inheritDoc} */ + @Override protected void mapHasChanged() { + updateActions(); + } + + /** {@inheritDoc} */ + @Override protected void mapViewHasChanged() { + // ignore + } + + /** {@inheritDoc} */ + @Override protected void mapCursorChangedPos(@NotNull final MapCursorEvent e) { + updateActions(); + } + + /** {@inheritDoc} */ + @Override protected void mapCursorChangedMode(@NotNull final MapCursorEvent e) { + // ignore + } + + }; + updateActions(); + } + + /** + * Unregister all registered listeners. Must be called when this instance + * is freed. + */ + public void closeNotify() { + currentMapListener.closeNotify(); + } + + /** Action method for "reset view". */ + public void resetView() { + // set edit type to zero (-> show all) + mainControl.unsetEditType(~0); + updateActions(); + } + + /** + * Update the actions' state to the current edit mode. + */ + private void updateActions() { + aShowMonster.setSelected(isShowMonster()); + aShowExit.setSelected(isShowExit()); + aShowBackground.setSelected(isShowBackground()); + aShowDoor.setSelected(isShowDoor()); + aShowWall.setSelected(isShowWall()); + aShowEquipment.setSelected(isShowEquipment()); + aShowTreasure.setSelected(isShowTreasure()); + aShowConnected.setSelected(isShowConnected()); + } + + /** Action method for "show monster". + * @return <code>true</code> if showMonster is active, otherwise <code>false</code>. + */ + public boolean isShowMonster() { + return mainControl.isEditType(GUIConstants.EDIT_TYPE_MONSTER); + } + + /** Action method for "show monster". + * @param showMonster <code>true</code> if showMonster should be activated, otherwise <code>false</code>. + */ + public void setShowMonster(final boolean showMonster) { + setShow(showMonster, GUIConstants.EDIT_TYPE_MONSTER); + } + + /** Action method for "show exit". + * @return <code>true</code> if showExit is active, otherwise <code>false</code>. + */ + public boolean isShowExit() { + return mainControl.isEditType(GUIConstants.EDIT_TYPE_EXIT); + } + + /** Action method for "show exit". + * @param showExit <code>true</code> if showExit should be activated, otherwise <code>false</code>. + */ + public void setShowExit(final boolean showExit) { + setShow(showExit, GUIConstants.EDIT_TYPE_EXIT); + } + + /** Action method for "show background". + * @return <code>true</code> if showBackground is active, otherwise <code>false</code>. + */ + public boolean isShowBackground() { + return mainControl.isEditType(GUIConstants.EDIT_TYPE_BACKGROUND); + } + + /** Action method for "show background". + * @param showBackground <code>true</code> if showBackground should be activated, otherwise <code>false</code>. + */ + public void setShowBackground(final boolean showBackground) { + setShow(showBackground, GUIConstants.EDIT_TYPE_BACKGROUND); + } + + /** Action method for "show door". + * @return <code>true</code> if showDoor is active, otherwise <code>false</code>. + */ + public boolean isShowDoor() { + return mainControl.isEditType(GUIConstants.EDIT_TYPE_DOOR); + } + + /** Action method for "show door". + * @param showDoor <code>true</code> if showDoor should be activated, otherwise <code>false</code>. + */ + public void setShowDoor(final boolean showDoor) { + setShow(showDoor, GUIConstants.EDIT_TYPE_DOOR); + } + + /** Action method for "show wall". + * @return <code>true</code> if showWall is active, otherwise <code>false</code>. + */ + public boolean isShowWall() { + return mainControl.isEditType(GUIConstants.EDIT_TYPE_WALL); + } + + /** Action method for "show wall". + * @param showWall <code>true</code> if showWall should be activated, otherwise <code>false</code>. + */ + public void setShowWall(final boolean showWall) { + setShow(showWall, GUIConstants.EDIT_TYPE_WALL); + } + + /** Action method for "show equipment". + * @return <code>true</code> if showEquipment is active, otherwise <code>false</code>. + */ + public boolean isShowEquipment() { + return mainControl.isEditType(GUIConstants.EDIT_TYPE_EQUIP); + } + + /** Action method for "show equipment". + * @param showEquipment <code>true</code> if showEquipment should be activated, otherwise <code>false</code>. + */ + public void setShowEquipment(final boolean showEquipment) { + setShow(showEquipment, GUIConstants.EDIT_TYPE_EQUIP); + } + + /** Action method for "show treasure". + * @return <code>true</code> if showTreasure is active, otherwise <code>false</code>. + */ + public boolean isShowTreasure() { + return mainControl.isEditType(GUIConstants.EDIT_TYPE_TREASURE); + } + + /** Action method for "show treasure". + * @param showTreasure <code>true</code> if showTreasure should be activated, otherwise <code>false</code>. + */ + public void setShowTreasure(final boolean showTreasure) { + setShow(showTreasure, GUIConstants.EDIT_TYPE_TREASURE); + } + + /** Action method for "show connected". + * @return <code>true</code> if showConnected is active, otherwise <code>false</code>. + */ + public boolean isShowConnected() { + return mainControl.isEditType(GUIConstants.EDIT_TYPE_CONNECTED); + } + + /** Action method for "show connected". + * @param showConnected <code>true</code> if showConnected should be activated, otherwise <code>false</code>. + */ + public void setShowConnected(final boolean showConnected) { + setShow(showConnected, GUIConstants.EDIT_TYPE_CONNECTED); + } + + private void setShow(final boolean show, final int editType) { + if (show) { + mainControl.setEditType(editType); + } else { + mainControl.unsetEditType(editType); + } + } + +} // class ViewActions Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2008-03-31 23:50:05 UTC (rev 3795) +++ trunk/src/app/net/sf/gridarta/messages.properties 2008-04-01 00:03:43 UTC (rev 3796) @@ -511,6 +511,37 @@ revertPickmap.mnemonic=R +###### +# View + +showMonster.text=Show monsters +showMonster.mnemonic=M + +showExit.text=Show exits +showExit.mnemonic=X + +showBackground.text=Show background +showBackground.mnemonic=B + +showDoor.text=Show doors & keys +showDoor.mnemonic=D + +showWall.text=Show walls +showWall.mnemonic=W + +showEquipment.text=Show equipment +showEquipment.mnemonic=E + +showTreasure.text=Show treasure +showTreasure.mnemonic=T + +showConnected.text=Show connected +showConnected.mnemonic=C + +resetView.text=Reset view +resetView.mnemonic=R + + ##################### # Preference Modules Modified: trunk/src/app/net/sf/gridarta/messages_de.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_de.properties 2008-03-31 23:50:05 UTC (rev 3795) +++ trunk/src/app/net/sf/gridarta/messages_de.properties 2008-04-01 00:03:43 UTC (rev 3796) @@ -475,6 +475,37 @@ revertPickmap.mnemonic=Z +###### +# View + +showMonster.text=Monster anzeigen +showMonster.mnemonic=M + +showExit.text=Ausg\xE4nge anzeigen +showExit.mnemonic=A + +showBackground.text=Hintergrund anzeigen +showBackground.mnemonic=H + +showDoor.text=T\xFCren und Schl\xFCssel anzeigen +showDoor.mnemonic=T + +showWall.text=W\xE4nde anzeigen +showWall.mnemonic=W + +showEquipment.text=Ausr\xFCstung anzeigen +showEquipment.mnemonic=U + +showTreasure.text=Sch\xE4tze anzeigen +showTreasure.mnemonic=S + +showConnected.text=Verbindungen anzeigen +showConnected.mnemonic=V + +resetView.text=Ansicht zur\xFCcksetzen +resetView.mnemonic=Z + + ##################### # Preference Modules Modified: trunk/src/app/net/sf/gridarta/messages_fr.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-03-31 23:50:05 UTC (rev 3795) +++ trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-04-01 00:03:43 UTC (rev 3796) @@ -474,6 +474,37 @@ revertPickmap.mnemonic=R +###### +# View + +showMonster.text=Afficher monstres +showMonster.mnemonic=M + +showExit.text=Afficher sorties +showExit.mnemonic=S + +showBackground.text=Afficher fond +showBackground.mnemonic=F + +showDoor.text=Afficher portes et cl\xE9s +showDoor.mnemonic=P + +showWall.text=Afficher murs +showWall.mnemonic=U + +showEquipment.text=Afficher \xE9quipement +showEquipment.mnemonic=E + +showTreasure.text=Afficher tr\xE9sors +showTreasure.mnemonic=T + +showConnected.text=Afficher objets connect\xE9s +showConnected.mnemonic=C + +resetView.text=Vue normale +resetView.mnemonic=N + + ##################### # Preference Modules Modified: trunk/src/app/net/sf/gridarta/messages_sv.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-03-31 23:50:05 UTC (rev 3795) +++ trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-04-01 00:03:43 UTC (rev 3796) @@ -473,6 +473,37 @@ revertPickmap.mnemonic=R +###### +# View + +showMonster.text=Monster +showMonster.mnemonic=M + +showExit.text=Utg\xE5ngar +showExit.mnemonic=U + +showBackground.text=Bakgrund +showBackground.mnemonic=B + +showDoor.text=D\xF6rrar och nycklar +showDoor.mnemonic=D + +showWall.text=V\xE4ggar +showWall.mnemonic=V + +showEquipment.text=Utrustning +showEquipment.mnemonic=R + +showTreasure.text=Skatter +showTreasure.mnemonic=S + +showConnected.text=Anslutna +showConnected.mnemonic=A + +resetView.text=\xC5terst\xE4ll visning +resetView.mnemonic=V + + #################### # Preference Module This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |