From: <aki...@us...> - 2008-06-12 18:46:12
|
Revision: 4180 http://gridarta.svn.sourceforge.net/gridarta/?rev=4180&view=rev Author: akirschbaum Date: 2008-06-12 11:46:13 -0700 (Thu, 12 Jun 2008) Log Message: ----------- Remove calls to MainControl.getObjectChooser(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java trunk/src/app/net/sf/gridarta/gui/AbstractObjectChooser.java trunk/src/app/net/sf/gridarta/gui/ObjectChooser.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-06-12 09:22:43 UTC (rev 4179) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-06-12 18:46:13 UTC (rev 4180) @@ -227,7 +227,6 @@ */ public CMainControl() { super(new CrossfireObjectsFactory(), "cfeditor"); - getGridartaObjectsFactory().setFaceObjects(faceObjects); instance = this; animationObjects = new AnimationObjects(); archetypeSet = new ArchetypeSet(this, animationObjects, faceObjects); @@ -238,6 +237,7 @@ globalSettings.readGlobalSettings(); PathManager.setGlobalSettings(globalSettings); objectChooser = new ObjectChooser(newMapDialogFactory, this, new File(globalSettings.getMapDir(), IGUIConstants.PICKMAP_DIR)); + getGridartaObjectsFactory().init(faceObjects, objectChooser); mainView = new MainView<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, objectChooser, getMapManager(), ACTION_FACTORY, mapManagerActions.getCloseAllAction(), faceObjects); new About("cfeditor", mainView); undoControl = new UndoControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(getMapManager()); Modified: trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-06-12 09:22:43 UTC (rev 4179) +++ trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-06-12 18:46:13 UTC (rev 4180) @@ -38,6 +38,7 @@ import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gameobject.match.GameObjectMatchers; +import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.io.DefaultMapReader; @@ -65,6 +66,9 @@ /** The {@link FaceObjects} instance to use. */ private FaceObjects faceObjects = null; + /** The {@link ObjectChooser} instance to use. */ + private ObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChooser = null; + /** {@inheritDoc} */ @NotNull public GameObject newGameObject() { return new GameObject(); @@ -116,12 +120,13 @@ /** {@inheritDoc} */ @NotNull public MapView<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapView(@NotNull final MapControl mapControl, @Nullable final Point viewPosition, final int viewCounter) { - return new MapView<GameObject, MapArchObject, Archetype, CMapViewBasic>(AbstractMainControl.getInstance(), mapControl, viewCounter, new CMapViewBasic(CMainControl.getInstance(), mapControl, viewPosition, faceObjects), ACTION_FACTORY); + return new MapView<GameObject, MapArchObject, Archetype, CMapViewBasic>(AbstractMainControl.getInstance(), mapControl, viewCounter, new CMapViewBasic(CMainControl.getInstance(), mapControl, viewPosition, faceObjects, objectChooser), ACTION_FACTORY); } /** {@inheritDoc} */ - public void setFaceObjects(final FaceObjects faceObjects) { + public void init(@NotNull final FaceObjects faceObjects, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChooser) { this.faceObjects = faceObjects; + this.objectChooser = objectChooser; } } // class CrossfireObjectsFactory Modified: trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java 2008-06-12 09:22:43 UTC (rev 4179) +++ trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java 2008-06-12 18:46:13 UTC (rev 4180) @@ -29,6 +29,7 @@ import java.util.Map; import javax.swing.JViewport; import net.sf.gridarta.gameobject.face.FaceObjects; +import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapCursor; import net.sf.gridarta.gui.map.MapCursorEvent; @@ -96,8 +97,9 @@ * @param initial the initial view position to show; null=show top left * corner * @param faceObjects the FaceObjects instance to use + * @param objectChooser the ObjectChooser instance to use */ - public CMapViewBasic(@NotNull final CMainControl mainControl, @NotNull final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, @Nullable final Point initial, @NotNull final FaceObjects faceObjects) { + public CMapViewBasic(@NotNull final CMainControl mainControl, @NotNull final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, @Nullable final Point initial, @NotNull final FaceObjects faceObjects, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChooser) { super(mapControl); this.mapControl = mapControl; mapModel = mapControl.getMapModel(); @@ -121,7 +123,7 @@ getViewport().setViewPosition(initial); } - mapUserListener = new MapUserListener(mainControl, mapControl, this, mainControl.getObjectChooser(), mainControl.getSelectedSquareControl().getSelectedSquareView(), mainControl.getObjectChooser().getPickmapChooserControl()); + mapUserListener = new MapUserListener(mainControl, mapControl, this, objectChooser, mainControl.getSelectedSquareControl().getSelectedSquareView(), objectChooser.getPickmapChooserControl()); renderer.addMouseListener(mapUserListener); renderer.addMouseMotionListener(mapUserListener); renderer.setErroneousMapSquares(erroneousMapSquares); Modified: trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java 2008-06-12 09:22:43 UTC (rev 4179) +++ trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java 2008-06-12 18:46:13 UTC (rev 4180) @@ -97,7 +97,7 @@ } else if (isInsert(e)) { if (mapCursor.setLocation(temp) && temp != null) { mapControl.getMapModel().beginTransaction("Insert Object"); - final GameObject insertedObject = mainControl.getObjectChooser().insertSelectedObject(mapControl, temp, false); + final GameObject insertedObject = objectChooser.insertSelectedObject(mapControl, temp, false); mapControl.getMapModel().endTransaction(); selectedSquareView.setSelectedGameObject(insertedObject); } @@ -172,7 +172,7 @@ private void insertObject(final Point mapLoc) { if (mapLoc.x != -1 && mapLoc.y != -1) { mapControl.getMapModel().beginTransaction("Insert Object"); - final GameObject insertedObject = mainControl.getObjectChooser().insertSelectedObject(mapControl, mapLoc, true); + final GameObject insertedObject = objectChooser.insertSelectedObject(mapControl, mapLoc, true); mapControl.getMapModel().endTransaction(); selectedSquareView.setSelectedGameObject(insertedObject); } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-06-12 09:22:43 UTC (rev 4179) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-06-12 18:46:13 UTC (rev 4180) @@ -281,7 +281,6 @@ */ public CMainControl() { super(new DaimoninObjectsFactory(), "daieditor"); - getGridartaObjectsFactory().setFaceObjects(faceObjects); instance = this; animationObjects = new AnimationObjects(); archetypeSet = new ArchetypeSet(this, animationObjects, faceObjects); @@ -293,6 +292,7 @@ globalSettings.readGlobalSettings(); PathManager.setGlobalSettings(globalSettings); objectChooser = new ObjectChooser(newMapDialogFactory, this, new File(globalSettings.getArchDefaultFolder(), IGUIConstants.PICKMAP_DIR)); + getGridartaObjectsFactory().init(faceObjects, objectChooser); mainView = new MainView<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, objectChooser, getMapManager(), ACTION_FACTORY, mapManagerActions.getCloseAllAction(), faceObjects); new About("daieditor", mainView); undoControl = new UndoControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(getMapManager()); Modified: trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java =================================================================== --- trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java 2008-06-12 09:22:43 UTC (rev 4179) +++ trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java 2008-06-12 18:46:13 UTC (rev 4180) @@ -38,6 +38,7 @@ import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gameobject.match.GameObjectMatchers; +import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.io.DefaultMapReader; @@ -65,6 +66,9 @@ /** The {@link FaceObjects} instance to use. */ private FaceObjects faceObjects = null; + /** The {@link ObjectChooser} instance to use. */ + private ObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChooser = null; + /** {@inheritDoc} */ @NotNull public GameObject newGameObject() { return new GameObject(); @@ -120,8 +124,9 @@ } /** {@inheritDoc} */ - public void setFaceObjects(final FaceObjects faceObjects) { + public void init(@NotNull final FaceObjects faceObjects, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChooser) { this.faceObjects = faceObjects; + this.objectChooser = objectChooser; } } // class DaimoninObjectsFactory Modified: trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java 2008-06-12 09:22:43 UTC (rev 4179) +++ trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java 2008-06-12 18:46:13 UTC (rev 4180) @@ -24,6 +24,7 @@ import daieditor.gameobject.GameObject; import daieditor.gui.map.CMapViewBasic; import daieditor.gui.map.event.MouseOpEvent; +import daieditor.gui.ObjectChooser; import daieditor.map.MapArchObject; import java.awt.Component; import java.awt.Point; @@ -52,16 +53,21 @@ /** The main control. */ @NotNull private final CMainControl mainControl; + /** The ObjectChooser to use. */ + @NotNull private final ObjectChooser objectChooser; + /** The position for insertion. */ private boolean insertBelow; /** * Create a BasicAbstractTool. * @param mainControl The main control. + * @param objectChooser the ObjectChooser to use */ - public InsertionTool(@NotNull final CMainControl mainControl) { + public InsertionTool(@NotNull final CMainControl mainControl, @NotNull final ObjectChooser objectChooser) { super("insertion"); this.mainControl = mainControl; + this.objectChooser = objectChooser; } /** {@inheritDoc} */ @@ -71,7 +77,7 @@ final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = e.getMapControl(); if (p != null) { mapControl.getMapModel().beginTransaction("Insert Object"); - final GameObject insertedObject = mainControl.getObjectChooser().insertSelectedObject(mapControl, p, true); + final GameObject insertedObject = objectChooser.insertSelectedObject(mapControl, p, true); if (!mapControl.isPickmap()) { mapCursor.setLocation(p); } @@ -87,7 +93,7 @@ final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = e.getMapControl(); if (!mapControl.isPickmap() && mapCursor.setLocationSafe(p)) { mapControl.getMapModel().beginTransaction("Insert Object"); - final GameObject insertedObject = mainControl.getObjectChooser().insertSelectedObject(mapControl, p, false); + final GameObject insertedObject = objectChooser.insertSelectedObject(mapControl, p, false); mapControl.getMapModel().endTransaction(); mainControl.getSelectedSquareControl().getSelectedSquareView().setSelectedGameObject(insertedObject); } Modified: trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java 2008-06-12 09:22:43 UTC (rev 4179) +++ trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java 2008-06-12 18:46:13 UTC (rev 4180) @@ -80,7 +80,7 @@ */ public ToolSelector(@NotNull final String defaultTool, @NotNull final CMainControl mainControl, @NotNull final ObjectChooser objectChooser) { createUI(); - for (final Tool toolToAdd : new Tool[] { new VoidTool(), new SelectionTool(objectChooser), new DeletionTool(mainControl), new InsertionTool(mainControl) }) { + for (final Tool toolToAdd : new Tool[] { new VoidTool(), new SelectionTool(objectChooser), new DeletionTool(mainControl), new InsertionTool(mainControl, objectChooser) }) { add(toolToAdd, toolToAdd.getId().equals(defaultTool)); } } Modified: trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java 2008-06-12 09:22:43 UTC (rev 4179) +++ trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java 2008-06-12 18:46:13 UTC (rev 4180) @@ -27,6 +27,7 @@ import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gameobject.face.FaceObjects; +import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; @@ -136,9 +137,10 @@ @NotNull MapView<G, A, R, V> newMapView(@NotNull MapControl<G, A, R, V> mapControl, @Nullable Point viewPosition, int viewCounter); /** - * Sets the {@link FaceObjects} instance to use. + * Initializes the instance. * @param faceObjects the FaceObjects instance + * @param objectChooser the ObjectChooser instance */ - void setFaceObjects(final FaceObjects faceObjects); + void init(@NotNull final FaceObjects faceObjects, @NotNull final ObjectChooser<G, A, R, V> objectChooser); } // interface GridartaObjectsFactory Modified: trunk/src/app/net/sf/gridarta/gui/AbstractObjectChooser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/AbstractObjectChooser.java 2008-06-12 09:22:43 UTC (rev 4179) +++ trunk/src/app/net/sf/gridarta/gui/AbstractObjectChooser.java 2008-06-12 18:46:13 UTC (rev 4180) @@ -61,10 +61,7 @@ return pickmapActive; } - /** - * Sets the pickmap folders menu to manage. - * @param folderMenu the pickmap folders menu - */ + /** {@inheritDoc} */ public void setPickmapFoldersMenu(@Nullable final JMenu folderMenu) { getPickmapChooserControl().setPickmapFoldersMenu(folderMenu); } Modified: trunk/src/app/net/sf/gridarta/gui/ObjectChooser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ObjectChooser.java 2008-06-12 09:22:43 UTC (rev 4179) +++ trunk/src/app/net/sf/gridarta/gui/ObjectChooser.java 2008-06-12 18:46:13 UTC (rev 4180) @@ -21,6 +21,7 @@ import java.awt.Point; import java.util.List; +import javax.swing.JMenu; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; @@ -128,4 +129,10 @@ */ @Nullable G insertSelectedObject(@NotNull final MapControl<G, A, R, V> mapControl, @NotNull Point pos, boolean allowMany); + /** + * Sets the pickmap folders menu to manage. + * @param folderMenu the pickmap folders menu + */ + void setPickmapFoldersMenu(@Nullable JMenu folderMenu); + } // interface ObjectChooser This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-06-12 18:58:25
|
Revision: 4181 http://gridarta.svn.sourceforge.net/gridarta/?rev=4181&view=rev Author: akirschbaum Date: 2008-06-12 11:58:22 -0700 (Thu, 12 Jun 2008) Log Message: ----------- Remove calls to MainControl.getObjectChooser(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gui/ObjectChooser.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gui/ObjectChooser.java trunk/src/app/net/sf/gridarta/gui/MainActions.java trunk/src/app/net/sf/gridarta/gui/ObjectChoiceDisplay.java trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-06-12 18:46:13 UTC (rev 4180) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-06-12 18:58:22 UTC (rev 4181) @@ -203,7 +203,7 @@ private final MapCursorControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapCursorControl; /** Actions used by this instance. */ - private final MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic> mainActions = new MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, ACTION_FACTORY, faceObjects); + private final MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic> mainActions; /** JFileChooser for opening a file. */ private JFileChooser fileChooser; @@ -237,6 +237,7 @@ globalSettings.readGlobalSettings(); PathManager.setGlobalSettings(globalSettings); objectChooser = new ObjectChooser(newMapDialogFactory, this, new File(globalSettings.getMapDir(), IGUIConstants.PICKMAP_DIR)); + mainActions = new MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, ACTION_FACTORY, faceObjects, objectChooser); getGridartaObjectsFactory().init(faceObjects, objectChooser); mainView = new MainView<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, objectChooser, getMapManager(), ACTION_FACTORY, mapManagerActions.getCloseAllAction(), faceObjects); new About("cfeditor", mainView); Modified: trunk/crossfire/src/cfeditor/gui/ObjectChooser.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ObjectChooser.java 2008-06-12 18:46:13 UTC (rev 4180) +++ trunk/crossfire/src/cfeditor/gui/ObjectChooser.java 2008-06-12 18:58:22 UTC (rev 4181) @@ -101,7 +101,7 @@ } }); - objectChoiceDisplay = new ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, CMapViewBasic>(mainControl); + objectChoiceDisplay = new ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, CMapViewBasic>(mainControl, this); // archAndPickPane is the panel containing both archpanel and pickmaps archAndPickPane.addTab(ACTION_FACTORY.getString("objectChooser.archetypesTabTitle"), archetypeChooserControl.getArchetypePanel()); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-06-12 18:46:13 UTC (rev 4180) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-06-12 18:58:22 UTC (rev 4181) @@ -260,7 +260,7 @@ private final MapCursorControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapCursorControl; /** Actions used by this instance. */ - private final MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic> mainActions = new MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, ACTION_FACTORY, faceObjects); + private final MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic> mainActions; /** JFileChooser for opening a file. */ private JFileChooser fileChooser; @@ -292,6 +292,7 @@ globalSettings.readGlobalSettings(); PathManager.setGlobalSettings(globalSettings); objectChooser = new ObjectChooser(newMapDialogFactory, this, new File(globalSettings.getArchDefaultFolder(), IGUIConstants.PICKMAP_DIR)); + mainActions = new MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, ACTION_FACTORY, faceObjects, objectChooser); getGridartaObjectsFactory().init(faceObjects, objectChooser); mainView = new MainView<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, objectChooser, getMapManager(), ACTION_FACTORY, mapManagerActions.getCloseAllAction(), faceObjects); new About("daieditor", mainView); Modified: trunk/daimonin/src/daieditor/gui/ObjectChooser.java =================================================================== --- trunk/daimonin/src/daieditor/gui/ObjectChooser.java 2008-06-12 18:46:13 UTC (rev 4180) +++ trunk/daimonin/src/daieditor/gui/ObjectChooser.java 2008-06-12 18:58:22 UTC (rev 4181) @@ -94,7 +94,7 @@ }); toolPalette = new ToolPalette(mainControl, this); - objectChoiceDisplay = new ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, CMapViewBasic>(mainControl); + objectChoiceDisplay = new ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, CMapViewBasic>(mainControl, this); // archAndPickPane is the panel containing both archpanel and pickmaps archAndPickPane.addTab(ACTION_FACTORY.getString("objectChooser.archetypesTabTitle"), archetypeChooserControl.getArchetypePanel()); Modified: trunk/src/app/net/sf/gridarta/gui/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-06-12 18:46:13 UTC (rev 4180) +++ trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-06-12 18:58:22 UTC (rev 4181) @@ -68,6 +68,9 @@ /** The FaceObjects instance to use. */ @NotNull private final FaceObjects faceObjects; + /** The ObjectChooser instance to use. */ + @NotNull private final ObjectChooser<G, A, R, V> objectChooser; + /** Action called for "clear". */ private final Action aClear; @@ -279,10 +282,11 @@ * * @param faceObjects the FaceObjects instance to use */ - public MainActions(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ActionFactory actionFactory, @NotNull final FaceObjects faceObjects) { + public MainActions(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ActionFactory actionFactory, @NotNull final FaceObjects faceObjects, @NotNull final ObjectChooser<G, A, R, V> objectChooser) { this.mainControl = mainControl; this.actionFactory = actionFactory; this.faceObjects = faceObjects; + this.objectChooser = objectChooser; aClear = actionFactory.createAction(true, "clear", this); aCut = actionFactory.createAction(true, "cut", this); aCopy = actionFactory.createAction(true, "copy", this); @@ -435,7 +439,7 @@ public void replace() { final MapView<G, A, R, V> mapView = getReplaceEnabled(); if (mapView != null) { - ReplaceDialog.getInstance(mainControl).display(mapView); + ReplaceDialog.getInstance(mainControl, objectChooser).display(mapView); } } Modified: trunk/src/app/net/sf/gridarta/gui/ObjectChoiceDisplay.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ObjectChoiceDisplay.java 2008-06-12 18:46:13 UTC (rev 4180) +++ trunk/src/app/net/sf/gridarta/gui/ObjectChoiceDisplay.java 2008-06-12 18:58:22 UTC (rev 4181) @@ -31,6 +31,7 @@ import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; /** * The ObjectChoiceDisplay shows quick information about the chose object from the Object Chooser. @@ -44,6 +45,9 @@ /** Controller of this subview. */ private final MainControl<G, A, R, V> mainControl; + /** The ObjectChooser to use. */ + @NotNull private final ObjectChooser<G, A, R, V> objectChooser; + private final JLabel archObjNameLabel = new JLabel("Name:"); private final JLabel archArchNameLabel = new JLabel("Arch:"); @@ -60,8 +64,9 @@ private final JLabel archTileText = new JLabel(); - public ObjectChoiceDisplay(final MainControl<G, A, R, V> mainControl) { + public ObjectChoiceDisplay(final MainControl<G, A, R, V> mainControl, @NotNull final ObjectChooser<G, A, R, V> objectChooser) { this.mainControl = mainControl; + this.objectChooser = objectChooser; setLayout(new GridBagLayout()); final GridBagConstraints gcl = new GridBagConstraints(); @@ -144,8 +149,8 @@ } // notify ReplaceDialog - if (ReplaceDialog.isBuilt() && ReplaceDialog.getInstance(mainControl).isShowing()) { - ReplaceDialog.getInstance(mainControl).updateArchSelection(headObject, false); + if (ReplaceDialog.isBuilt() && ReplaceDialog.getInstance(mainControl, objectChooser).isShowing()) { + ReplaceDialog.getInstance(mainControl, objectChooser).updateArchSelection(headObject, false); } } } Modified: trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java 2008-06-12 18:46:13 UTC (rev 4180) +++ trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java 2008-06-12 18:58:22 UTC (rev 4181) @@ -75,6 +75,8 @@ private final MainControl<G, A, R, V> mainControl; + @NotNull private final ObjectChooser<G, A, R, V> objectChooser; + private boolean isBuilt = false; private MapView<G, A, R, V> mapView; @@ -110,11 +112,12 @@ * Construct instance. * @param mainControl MainControl */ - private ReplaceDialog(@NotNull final MainControl<G, A, R, V> mainControl) { + private ReplaceDialog(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ObjectChooser<G, A, R, V> objectChooser) { dialog = createDialog(mainControl.getMainView(), ACTION_FACTORY.getString("replaceTitle")); dialog.setModal(false); dialog.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); this.mainControl = mainControl; + this.objectChooser = objectChooser; } /** @@ -125,9 +128,9 @@ return instance != null && instance.isBuilt; } - public static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R>> ReplaceDialog<G, A, R, V> getInstance(@NotNull final MainControl<G, A, R, V> mainControl) { + public static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R>> ReplaceDialog<G, A, R, V> getInstance(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ObjectChooser objectChooser) { if (instance == null) { - instance = new ReplaceDialog<G, A, R, V>(mainControl); + instance = new ReplaceDialog<G, A, R, V>(mainControl, objectChooser); } return instance; } @@ -137,8 +140,8 @@ * @param mapView map view of the active map where the action was invoked */ public void display(final MapView<G, A, R, V> mapView) { - replaceArch = mainControl.getObjectChooser().getObjectChooserHighlight(); // highlighted arch - replacePickmap = mainControl.getObjectChooser().getObjectChooserSelection(); // selected arches + replaceArch = objectChooser.getObjectChooserHighlight(); // highlighted arch + replacePickmap = objectChooser.getObjectChooserSelection(); // selected arches replaceCopyBuffer = mainControl.getCopyBuffer().getCopyMapCtrl().getAllGameObjects(); if (!isBuilt) { @@ -403,7 +406,7 @@ switch (selectedIndex) { case 0: // replace with arch - replaceArch = mainControl.getObjectChooser().getObjectChooserHighlight(); // selected arch + replaceArch = objectChooser.getObjectChooserHighlight(); // selected arch updateArchSelection(replaceArch, true); break; @@ -419,7 +422,7 @@ case 2: // replace with pickmap - replacePickmap = mainControl.getObjectChooser().getObjectChooserSelection(); // selected arches + replacePickmap = objectChooser.getObjectChooserSelection(); // selected arches iconLabel.setIcon(null); size = replacePickmap.size(); rfArchName.setText(String.valueOf(size)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-06-12 19:43:44
|
Revision: 4186 http://gridarta.svn.sourceforge.net/gridarta/?rev=4186&view=rev Author: akirschbaum Date: 2008-06-12 12:42:39 -0700 (Thu, 12 Jun 2008) Log Message: ----------- Remove calls to MainControl.getObjectChooser(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-06-12 19:15:32 UTC (rev 4185) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-06-12 19:42:39 UTC (rev 4186) @@ -238,7 +238,7 @@ PathManager.setGlobalSettings(globalSettings); objectChooser = new ObjectChooser(newMapDialogFactory, this, new File(globalSettings.getMapDir(), IGUIConstants.PICKMAP_DIR)); mainActions = new MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, ACTION_FACTORY, faceObjects, objectChooser); - getGridartaObjectsFactory().init(faceObjects, objectChooser); + getGridartaObjectsFactory().init(faceObjects, objectChooser, objectChooser.getArchetypeChooserControl()); mainView = new MainView<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, objectChooser, getMapManager(), ACTION_FACTORY, mapManagerActions.getCloseAllAction(), faceObjects); new About("cfeditor", mainView); undoControl = new UndoControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(getMapManager()); Modified: trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-06-12 19:15:32 UTC (rev 4185) +++ trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-06-12 19:42:39 UTC (rev 4186) @@ -39,6 +39,7 @@ import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gameobject.match.GameObjectMatchers; import net.sf.gridarta.gui.ObjectChooser; +import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.io.DefaultMapReader; @@ -69,6 +70,9 @@ /** The {@link ObjectChooser} instance to use. */ private ObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChooser = null; + /** The {@link ArchetypeChooserControl} instance to use. */ + @NotNull private ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl = null; + /** {@inheritDoc} */ @NotNull public GameObject newGameObject() { return new GameObject(); @@ -105,12 +109,12 @@ /** {@inheritDoc} */ @NotNull public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject) { - return new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, CMainControl.getInstance(), objects, mapArchObject, false, GameObjectMatchers.getMatcher("exit")); + return new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, CMainControl.getInstance(), objects, mapArchObject, false, GameObjectMatchers.getMatcher("exit"), archetypeChooserControl); } /** {@inheritDoc} */ @NotNull public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newPickmapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject) { - return new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, CMainControl.getInstance(), objects, mapArchObject, true, GameObjectMatchers.getMatcher("exit")); + return new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, CMainControl.getInstance(), objects, mapArchObject, true, GameObjectMatchers.getMatcher("exit"), archetypeChooserControl); } /** {@inheritDoc} */ @@ -124,9 +128,10 @@ } /** {@inheritDoc} */ - public void init(@NotNull final FaceObjects faceObjects, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChooser) { + public void init(@NotNull final FaceObjects faceObjects, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChooser, @NotNull final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl) { this.faceObjects = faceObjects; this.objectChooser = objectChooser; + this.archetypeChooserControl = archetypeChooserControl; } } // class CrossfireObjectsFactory Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-06-12 19:15:32 UTC (rev 4185) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-06-12 19:42:39 UTC (rev 4186) @@ -293,7 +293,7 @@ PathManager.setGlobalSettings(globalSettings); objectChooser = new ObjectChooser(newMapDialogFactory, this, new File(globalSettings.getArchDefaultFolder(), IGUIConstants.PICKMAP_DIR)); mainActions = new MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, ACTION_FACTORY, faceObjects, objectChooser); - getGridartaObjectsFactory().init(faceObjects, objectChooser); + getGridartaObjectsFactory().init(faceObjects, objectChooser, objectChooser.getArchetypeChooserControl()); mainView = new MainView<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, objectChooser, getMapManager(), ACTION_FACTORY, mapManagerActions.getCloseAllAction(), faceObjects); new About("daieditor", mainView); undoControl = new UndoControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(getMapManager()); Modified: trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java =================================================================== --- trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java 2008-06-12 19:15:32 UTC (rev 4185) +++ trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java 2008-06-12 19:42:39 UTC (rev 4186) @@ -39,6 +39,7 @@ import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gameobject.match.GameObjectMatchers; import net.sf.gridarta.gui.ObjectChooser; +import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.io.DefaultMapReader; @@ -69,6 +70,9 @@ /** The {@link ObjectChooser} instance to use. */ private ObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChooser = null; + /** The {@link net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl} instance to use. */ + @NotNull private ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl = null; + /** {@inheritDoc} */ @NotNull public GameObject newGameObject() { return new GameObject(); @@ -105,12 +109,12 @@ /** {@inheritDoc} */ @NotNull public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject) { - return new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, CMainControl.getInstance(), objects, mapArchObject, false, GameObjectMatchers.getMatcher("exit")); + return new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, CMainControl.getInstance(), objects, mapArchObject, false, GameObjectMatchers.getMatcher("exit"), archetypeChooserControl); } /** {@inheritDoc} */ @NotNull public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newPickmapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject) { - return new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, CMainControl.getInstance(), objects, mapArchObject, true, GameObjectMatchers.getMatcher("exit")); + return new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, CMainControl.getInstance(), objects, mapArchObject, true, GameObjectMatchers.getMatcher("exit"), archetypeChooserControl); } /** {@inheritDoc} */ @@ -124,9 +128,10 @@ } /** {@inheritDoc} */ - public void init(@NotNull final FaceObjects faceObjects, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChooser) { + public void init(@NotNull final FaceObjects faceObjects, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChooser, @NotNull final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl) { this.faceObjects = faceObjects; this.objectChooser = objectChooser; + this.archetypeChooserControl = archetypeChooserControl; } } // class DaimoninObjectsFactory Modified: trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java 2008-06-12 19:15:32 UTC (rev 4185) +++ trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java 2008-06-12 19:42:39 UTC (rev 4186) @@ -28,6 +28,7 @@ import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gui.ObjectChooser; +import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; @@ -140,7 +141,8 @@ * Initializes the instance. * @param faceObjects the FaceObjects instance * @param objectChooser the ObjectChooser instance + * @param archetypeChooserControl the ArchetypeChooserControl instance */ - void init(@NotNull final FaceObjects faceObjects, @NotNull final ObjectChooser<G, A, R, V> objectChooser); + void init(@NotNull FaceObjects faceObjects, @NotNull ObjectChooser<G, A, R, V> objectChooser, @NotNull ArchetypeChooserControl<G, A, R, V> archetypeChooserControl); } // interface GridartaObjectsFactory Modified: trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java 2008-06-12 19:15:32 UTC (rev 4185) +++ trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java 2008-06-12 19:42:39 UTC (rev 4186) @@ -35,6 +35,7 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gameobject.match.GameObjectMatcher; +import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; @@ -164,12 +165,12 @@ * @param isPickmap true if this is a pickmap * @param exitTypeGameObjectMatcher the matcher to select exit objects */ - public DefaultMapControl(@NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull final MainControl<G, A, R, V> mainControl, final List<G> objects, final A mapArchObject, final boolean isPickmap, @Nullable final GameObjectMatcher exitTypeGameObjectMatcher) { + public DefaultMapControl(@NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull final MainControl<G, A, R, V> mainControl, final List<G> objects, final A mapArchObject, final boolean isPickmap, @Nullable final GameObjectMatcher exitTypeGameObjectMatcher, @NotNull final ArchetypeChooserControl<G, A, R, V> archetypeChooserControl) { this.gridartaObjectsFactory = gridartaObjectsFactory; this.mainControl = mainControl; this.isPickmap = isPickmap; // we create model (= data) - mapModel = new DefaultMapModel<G, A, R>(mainControl, this, objects, mapArchObject, exitTypeGameObjectMatcher); + mapModel = new DefaultMapModel<G, A, R>(mainControl, this, objects, mapArchObject, exitTypeGameObjectMatcher, archetypeChooserControl); mapModel.addMapModelListener(mapModelListener); } Modified: trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-06-12 19:15:32 UTC (rev 4185) +++ trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-06-12 19:42:39 UTC (rev 4186) @@ -32,6 +32,7 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gameobject.match.GameObjectMatcher; +import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.map.validation.DefaultErrorCollector; import net.sf.gridarta.map.validation.ErrorCollector; import net.sf.japi.swing.ActionFactory; @@ -78,6 +79,8 @@ */ @Deprecated private final transient MainControl<G, A, R, ?> mainControl; + @NotNull private final ArchetypeChooserControl<G, A, R, ?> archetypeChooserControl; + /** * The {@link GameObjectMatcher} for selecting exit objects. */ @@ -133,11 +136,13 @@ * @param objects the <code>GameObject</code> list of this map or <code>null</code> for an empty map * @param mapArchObject The MapArchObject to associate with this model. * @param exitTypeGameObjectMatcher the matcher for selecting exit objects + * @param archetypeChooserControl the archetype chooser control */ - public DefaultMapModel(final MainControl<G, A, R, ?> mainControl, final MapControl<G, A, R, ?> mapControl, final List<G> objects, final A mapArchObject, @Nullable final GameObjectMatcher exitTypeGameObjectMatcher) { + public DefaultMapModel(final MainControl<G, A, R, ?> mainControl, final MapControl<G, A, R, ?> mapControl, final List<G> objects, final A mapArchObject, @Nullable final GameObjectMatcher exitTypeGameObjectMatcher, @NotNull final ArchetypeChooserControl<G, A, R, ?> archetypeChooserControl) { this.mapControl = mapControl; this.mapArchObject = mapArchObject; this.mainControl = mainControl; + this.archetypeChooserControl = archetypeChooserControl; this.exitTypeGameObjectMatcher = exitTypeGameObjectMatcher; mapSize = mapArchObject.getMapSize(); mapGrid = new MapSquare[mapSize.getWidth()][mapSize.getHeight()]; @@ -709,7 +714,7 @@ mapGrid[mapx][mapy].addLast(part); } - final Integer direction = mainControl.getObjectChooser().getArchetypeChooserControl().getCurrentDirection(); + final Integer direction = archetypeChooserControl.getCurrentDirection(); if (direction != null) { part.setDirection(direction); part.setAttributeString("direction", Integer.toString(direction)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-06-15 12:37:03
|
Revision: 4190 http://gridarta.svn.sourceforge.net/gridarta/?rev=4190&view=rev Author: akirschbaum Date: 2008-06-15 05:37:09 -0700 (Sun, 15 Jun 2008) Log Message: ----------- Unify code. 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-06-15 12:20:52 UTC (rev 4189) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-06-15 12:37:09 UTC (rev 4190) @@ -262,6 +262,8 @@ typeList = new CFArchTypeList(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath()); gameObjectMatchers = new GameObjectMatchers(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath()); new ArchetypeSetSpellLoader<GameObject, MapArchObject, Archetype>().load(archetypeSet, Archetype.TYPE_SPELL, gameObjectSpells); + gameObjectSpells.sort(); + numberSpells.sort(); try { final String filename = IOUtils.getResourceURLAsString(getConfigurationDirectory(), "GameObjectMatchers.xml"); gameObjectMatchers.readGameObjectMatchers(filename); @@ -281,7 +283,6 @@ } catch (final FileNotFoundException ex) { log.error("Cannot read " + CommonConstants.TYPEDEF_FILE + ": " + ex.getMessage()); } - gameObjectSpells.sort(); ScriptArchEditor.initEventTypeBoxes(".py", "Python"); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-06-15 12:20:52 UTC (rev 4189) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-06-15 12:37:09 UTC (rev 4190) @@ -319,7 +319,9 @@ } typeList = new CFArchTypeList(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath()); gameObjectMatchers = new GameObjectMatchers(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath()); + gameObjectSpells.sort(); new XMLSpellLoader().load(getConfigurationDirectory(), CommonConstants.SPELL_FILE, xmlHelper.getDocumentBuilder(), numberSpells); + numberSpells.sort(); try { final String filename = IOUtils.getResourceURLAsString(getConfigurationDirectory(), "GameObjectMatchers.xml"); gameObjectMatchers.readGameObjectMatchers(filename); @@ -338,7 +340,6 @@ } catch (final FileNotFoundException ex) { log.error("Cannot read " + CommonConstants.TYPEDEF_FILE + ": " + ex.getMessage()); } - numberSpells.sort(); ScriptArchEditor.initEventTypeBoxes(".lua", "Lua"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-06-15 13:31:21
|
Revision: 4191 http://gridarta.svn.sourceforge.net/gridarta/?rev=4191&view=rev Author: akirschbaum Date: 2008-06-15 06:31:11 -0700 (Sun, 15 Jun 2008) Log Message: ----------- Remove static functions from GameObjectMatchers. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchers.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchersInstance.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-06-15 12:37:09 UTC (rev 4190) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-06-15 13:31:11 UTC (rev 4191) @@ -60,6 +60,7 @@ import net.sf.gridarta.XmlHelper; import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gameobject.match.GameObjectMatchers; +import net.sf.gridarta.gameobject.match.GameObjectMatchersInstance; import net.sf.gridarta.gui.About; import net.sf.gridarta.gui.HideFileFilterProxy; import net.sf.gridarta.gui.MainActions; @@ -270,7 +271,8 @@ } catch (final FileNotFoundException ex) { log.error("Cannot read GameObjectMatchers.xml: " + ex.getMessage()); } - final GameObjectMatcher exitMatcher = GameObjectMatchers.getMatcher("exit"); + GameObjectMatchersInstance.setInstance(gameObjectMatchers); + final GameObjectMatcher exitMatcher = gameObjectMatchers.getMatcher("exit"); if (exitMatcher == null) { log.fatal("GameObjectMatcher 'exit' does not exist"); throw new MissingResourceException("GameObjectMatcher 'exit' does not exist", null, null); @@ -289,7 +291,7 @@ final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, MainView.MAP_TILE_LIST_BOTTOM_DEFAULT); selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(ACTION_FACTORY, this, mainView, mapTileListBottom, null); // Initialize the main view - final GameObjectMatcher monsterMatcher = GameObjectMatchers.getMatcher("monster"); + final GameObjectMatcher monsterMatcher = gameObjectMatchers.getMatcher("monster"); if (monsterMatcher == null) { log.fatal("GameObjectMatcher 'monster' does not exist"); throw new MissingResourceException("GameObjectMatcher 'monster' does not exist", null, null); @@ -309,7 +311,7 @@ globalSettings.setAutoPopupDocu(false); } - net.sf.gridarta.gameobject.GameObject.setTypeList(typeList); // set reference in GameObject + net.sf.gridarta.gameobject.GameObject.initialize(typeList, gameObjectMatchers); getCopyBuffer().init(getGridartaObjectsFactory().newMapArchObject(false)); mainActions.init(); Modified: trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-06-15 12:37:09 UTC (rev 4190) +++ trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-06-15 13:31:11 UTC (rev 4191) @@ -37,7 +37,7 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.face.FaceObjects; -import net.sf.gridarta.gameobject.match.GameObjectMatchers; +import net.sf.gridarta.gameobject.match.GameObjectMatchersInstance; import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.gui.map.LevelRenderer; @@ -109,12 +109,12 @@ /** {@inheritDoc} */ @NotNull public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject) { - return new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, CMainControl.getInstance(), objects, mapArchObject, false, GameObjectMatchers.getMatcher("exit"), archetypeChooserControl); + return new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, CMainControl.getInstance(), objects, mapArchObject, false, GameObjectMatchersInstance.getInstance().getMatcher("exit"), archetypeChooserControl); } /** {@inheritDoc} */ @NotNull public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newPickmapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject) { - return new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, CMainControl.getInstance(), objects, mapArchObject, true, GameObjectMatchers.getMatcher("exit"), archetypeChooserControl); + return new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, CMainControl.getInstance(), objects, mapArchObject, true, GameObjectMatchersInstance.getInstance().getMatcher("exit"), archetypeChooserControl); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-06-15 12:37:09 UTC (rev 4190) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-06-15 13:31:11 UTC (rev 4191) @@ -64,6 +64,7 @@ import net.sf.gridarta.gameobject.face.FaceObjectProviders; import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gameobject.match.GameObjectMatchers; +import net.sf.gridarta.gameobject.match.GameObjectMatchersInstance; import net.sf.gridarta.gameobject.match.MutableOrGameObjectMatcher; import net.sf.gridarta.gameobject.match.ViewGameObjectMatcherManager; import net.sf.gridarta.gui.About; @@ -230,9 +231,6 @@ /** The list of archtype-data (loaded from "types.xml"). */ private CFArchTypeList typeList = null; - /** The game object matchers. */ - private final GameObjectMatchers gameObjectMatchers; - /** Client Control Component. */ private ProcessRunner controlClient; @@ -318,7 +316,7 @@ throw new MissingResourceException("Cannot create XML parser: " + ex.getMessage(), null, null); } typeList = new CFArchTypeList(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath()); - gameObjectMatchers = new GameObjectMatchers(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath()); + final GameObjectMatchers gameObjectMatchers = new GameObjectMatchers(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath()); gameObjectSpells.sort(); new XMLSpellLoader().load(getConfigurationDirectory(), CommonConstants.SPELL_FILE, xmlHelper.getDocumentBuilder(), numberSpells); numberSpells.sort(); @@ -328,6 +326,7 @@ } catch (final FileNotFoundException ex) { log.error("Cannot read GameObjectMatchers.xml: " + ex.getMessage()); } + GameObjectMatchersInstance.setInstance(gameObjectMatchers); final GameObjectMatcher exitMatcher = gameObjectMatchers.getMatcher("exit"); if (exitMatcher == null) { log.fatal("GameObjectMatcher 'exit' does not exist"); @@ -365,7 +364,7 @@ globalSettings.setAutoPopupDocu(false); } - net.sf.gridarta.gameobject.GameObject.setTypeList(typeList); // set reference in GameObject + net.sf.gridarta.gameobject.GameObject.initialize(typeList, gameObjectMatchers); getCopyBuffer().init(getGridartaObjectsFactory().newMapArchObject(false)); mainActions.init(); Modified: trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java =================================================================== --- trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java 2008-06-15 12:37:09 UTC (rev 4190) +++ trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java 2008-06-15 13:31:11 UTC (rev 4191) @@ -37,7 +37,7 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.face.FaceObjects; -import net.sf.gridarta.gameobject.match.GameObjectMatchers; +import net.sf.gridarta.gameobject.match.GameObjectMatchersInstance; import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.gui.map.LevelRenderer; @@ -109,12 +109,12 @@ /** {@inheritDoc} */ @NotNull public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject) { - return new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, CMainControl.getInstance(), objects, mapArchObject, false, GameObjectMatchers.getMatcher("exit"), archetypeChooserControl); + return new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, CMainControl.getInstance(), objects, mapArchObject, false, GameObjectMatchersInstance.getInstance().getMatcher("exit"), archetypeChooserControl); } /** {@inheritDoc} */ @NotNull public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newPickmapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject) { - return new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, CMainControl.getInstance(), objects, mapArchObject, true, GameObjectMatchers.getMatcher("exit"), archetypeChooserControl); + return new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, CMainControl.getInstance(), objects, mapArchObject, true, GameObjectMatchersInstance.getInstance().getMatcher("exit"), archetypeChooserControl); } /** {@inheritDoc} */ Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-06-15 12:37:09 UTC (rev 4190) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-06-15 13:31:11 UTC (rev 4191) @@ -52,8 +52,10 @@ protected static final Pattern lineSeparatorPattern = Pattern.compile("\n"); /** Static reference to the typeList (find syntax errors). */ - protected static CFArchTypeList typeList; + protected static CFArchTypeList typeList = null; + private static GameObjectMatchers gameObjectMatchers = null; + /** * If this flag is set, this Archetype is not a "real" Archetype but comes from the artifacts file. * Such Archetypes instances are not included in the Archetype collection process, since the artifacts file is the same for editor and server. @@ -169,9 +171,11 @@ /** * Sets the CFArchTypeList that should be used for finding syntax errors. * @param typeList CFArchTypeList to use + * @param gameObjectMatchers the instance to use */ - public static void setTypeList(final CFArchTypeList typeList) { + public static void initialize(final CFArchTypeList typeList, final GameObjectMatchers gameObjectMatchers) { GameObject.typeList = typeList; + GameObject.gameObjectMatchers = gameObjectMatchers; } /** {@inheritDoc} */ @@ -768,7 +772,7 @@ editType &= ~checkType; } - editType |= GameObjectMatchers.calculateEditType(this, checkType); + editType |= gameObjectMatchers.calculateEditType(this, checkType); return editType; } Modified: trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchers.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchers.java 2008-06-15 12:37:09 UTC (rev 4190) +++ trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchers.java 2008-06-15 13:31:11 UTC (rev 4191) @@ -52,10 +52,10 @@ * Map with arch object matchers and their IDs. * @todo turn static field into instance field */ - private static final Map<String, NamedGameObjectMatcher> gameObjectMatchersByIds = new HashMap<String, NamedGameObjectMatcher>(); + private final Map<String, NamedGameObjectMatcher> gameObjectMatchersByIds = new HashMap<String, NamedGameObjectMatcher>(); /** List with arch object matchers. */ - private static final List<NamedGameObjectMatcher> gameObjectMatchers = new ArrayList<NamedGameObjectMatcher>(); + private final List<NamedGameObjectMatcher> gameObjectMatchers = new ArrayList<NamedGameObjectMatcher>(); /** * Creates a new instance. @@ -76,7 +76,7 @@ * @param id the id * @return the matcher, or <code>null</code> if no such matcher exists */ - @Nullable public static NamedGameObjectMatcher getMatcher(@NotNull final String id) { + @Nullable public NamedGameObjectMatcher getMatcher(@NotNull final String id) { return gameObjectMatchersByIds.get(id); } @@ -95,7 +95,7 @@ * @param checkType the edit type to calculate * @return the edit type */ - public static int calculateEditType(@NotNull final GameObject gameObject, final int checkType) { + public int calculateEditType(@NotNull final GameObject gameObject, final int checkType) { int editType = 0; for (final NamedGameObjectMatcher matcher : gameObjectMatchers) { final int matcherEditType = matcher.getEditType(); Added: trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchersInstance.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchersInstance.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchersInstance.java 2008-06-15 13:31:11 UTC (rev 4191) @@ -0,0 +1,56 @@ +/* + * 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.gameobject.match; + +/** + * Singleton instance of {@link GameObjectMatchers}. + * @author Andreas Kirschbaum + */ +public class GameObjectMatchersInstance { + + /** + * The singleton instance. Set to <code>null</code> until {@link + * #setInstance(GameObjectMatchers)} has been called. + */ + private static GameObjectMatchers instance = null; + + /** + * Private constructor to prevent instantiation. + */ + private GameObjectMatchersInstance() { + } + + /** + * Returns the singleton {@link GameObjectMatchers} instance. + * @return the instance + */ + public static GameObjectMatchers getInstance() { + return instance; + } + + /** + * Sets the singleton instance. + * @param instance the instance + */ + public static void setInstance(final GameObjectMatchers instance) { + GameObjectMatchersInstance.instance = instance; + } + +} // class GameObjectMatchersInstance Property changes on: trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchersInstance.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-06-15 13:36:10
|
Revision: 4192 http://gridarta.svn.sourceforge.net/gridarta/?rev=4192&view=rev Author: akirschbaum Date: 2008-06-15 06:36:17 -0700 (Sun, 15 Jun 2008) Log Message: ----------- Whitespace changes. Modified Paths: -------------- trunk/crossfire/src/cfeditor/MapActions.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptedEvent.java trunk/src/app/net/sf/gridarta/gui/ObjectChooser.java trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java Modified: trunk/crossfire/src/cfeditor/MapActions.java =================================================================== --- trunk/crossfire/src/cfeditor/MapActions.java 2008-06-15 13:31:11 UTC (rev 4191) +++ trunk/crossfire/src/cfeditor/MapActions.java 2008-06-15 13:36:17 UTC (rev 4192) @@ -335,7 +335,7 @@ * @param currentMapView the map view to leave * @param path path to map that should be loaded * @param direction the direction to go - * @param destinationPoint the new cursor position + * @param destinationPoint the new cursor position * @param exit the applied exit object */ private void enterMap(@NotNull final MapView<GameObject, MapArchObject, Archetype, CMapViewBasic> currentMapView, @NotNull final String path, final int direction, final Point destinationPoint, final GameObject exit) { Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-06-15 13:31:11 UTC (rev 4191) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-06-15 13:36:17 UTC (rev 4192) @@ -341,7 +341,7 @@ } ScriptArchEditor.initEventTypeBoxes(".lua", "Lua"); - + final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, MainView.MAP_TILE_LIST_BOTTOM_DEFAULT); selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(ACTION_FACTORY, this, mainView, mapTileListBottom, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH)); // Initialize the main view Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptedEvent.java 2008-06-15 13:31:11 UTC (rev 4191) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptedEvent.java 2008-06-15 13:36:17 UTC (rev 4192) @@ -34,7 +34,7 @@ public abstract String getPluginName(); public abstract String getScriptPath(); - + public abstract String getOptions(); } // class ScriptedEvent Modified: trunk/src/app/net/sf/gridarta/gui/ObjectChooser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ObjectChooser.java 2008-06-15 13:31:11 UTC (rev 4191) +++ trunk/src/app/net/sf/gridarta/gui/ObjectChooser.java 2008-06-15 13:36:17 UTC (rev 4192) @@ -118,7 +118,7 @@ * Add the selected game object to the map. * * @param mapControl the map control to add to - * + * * @param pos The location to add to. * * @param allowMany Whether to allow multiple copies of the inserted game Modified: trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java 2008-06-15 13:31:11 UTC (rev 4191) +++ trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java 2008-06-15 13:36:17 UTC (rev 4192) @@ -70,7 +70,7 @@ private final EventListenerList listenerList = new EventListenerList(); /** - * The {@link GridartaObjectsFactory} instance. + * The {@link GridartaObjectsFactory} instance. */ @NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-06-15 13:55:42
|
Revision: 4193 http://gridarta.svn.sourceforge.net/gridarta/?rev=4193&view=rev Author: akirschbaum Date: 2008-06-15 06:55:50 -0700 (Sun, 15 Jun 2008) Log Message: ----------- Move MainControl.createImage() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/GlobalSettings.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-06-15 13:36:17 UTC (rev 4192) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-06-15 13:55:50 UTC (rev 4193) @@ -693,39 +693,6 @@ } } - /** {@inheritDoc} */ - public void createImage(@NotNull final MapView<GameObject, MapArchObject, Archetype, CMapViewBasic> mapView) { - if (globalSettings.getImageDir() == null) { - globalSettings.setImageDir(globalSettings.getMapDir().getAbsolutePath()); - } - - final File file = new File(globalSettings.getImageDir(), mapView.getMapControl().getMapFileName() + ".png"); - final JFileChooser fileChooser = new JFileChooser(globalSettings.getImageDir()); - fileChooser.setDialogTitle("Save Image As"); - fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - fileChooser.setMultiSelectionEnabled(false); - fileChooser.setSelectedFile(file); - // set a file filter for "*.png" files - fileChooser.setFileFilter(pngFileFilter); - - final int returnVal = fileChooser.showSaveDialog(mainView); - if (returnVal == JFileChooser.APPROVE_OPTION) { - // got the filepath, now create image - File imageFile = fileChooser.getSelectedFile(); - if (!imageFile.getName().endsWith(".png")) { - imageFile = new File(imageFile.getParentFile(), imageFile.getName() + ".png"); - } - globalSettings.setImageDir(imageFile.getParentFile().getAbsolutePath()); - if (!imageFile.exists() || ACTION_FACTORY.showConfirmDialog(mainView, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, "overwriteOtherFile", imageFile) == JOptionPane.YES_OPTION) { - try { - mapView.getView().getRenderer().printFullImage(imageFile); - } catch (final IOException e) { - ACTION_FACTORY.showMessageDialog(mainView, "createImageIOException", imageFile, e.getMessage()); - } - } - } - } - /** * Create an image of the specified map and save it as file. * In this method, the filename is already given, so the image Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-06-15 13:36:17 UTC (rev 4192) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-06-15 13:55:50 UTC (rev 4193) @@ -858,39 +858,6 @@ } } - /** {@inheritDoc} */ - public void createImage(@NotNull final MapView<GameObject, MapArchObject, Archetype, CMapViewBasic> mapView) { - if (globalSettings.getImageDir() == null) { - globalSettings.setImageDir(globalSettings.getMapDir().getAbsolutePath()); - } - - final File file = new File(globalSettings.getImageDir(), mapView.getMapControl().getMapFileName() + ".png"); - final JFileChooser fileChooser = new JFileChooser(globalSettings.getImageDir()); - fileChooser.setDialogTitle("Save Image As"); - fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - fileChooser.setMultiSelectionEnabled(false); - fileChooser.setSelectedFile(file); - // set a file filter for "*.png" files - fileChooser.setFileFilter(pngFileFilter); - - final int returnVal = fileChooser.showSaveDialog(mainView); - if (returnVal == JFileChooser.APPROVE_OPTION) { - // got the filepath, now create image - File imageFile = fileChooser.getSelectedFile(); - if (!imageFile.getName().endsWith(".png")) { - imageFile = new File(imageFile.getParentFile(), imageFile.getName() + ".png"); - } - globalSettings.setImageDir(imageFile.getParentFile().getAbsolutePath()); - if (!imageFile.exists() || ACTION_FACTORY.showConfirmDialog(mainView, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, "overwriteOtherFile", imageFile) == JOptionPane.YES_OPTION) { - try { - mapView.getView().getRenderer().printFullImage(imageFile); - } catch (final IOException e) { - ACTION_FACTORY.showMessageDialog(mainView, "createImageIOException", imageFile, e.getMessage()); - } - } - } - } - /** * Create an image of the specified map and save it as file. * In this method, the filename is already given, so the image Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-06-15 13:36:17 UTC (rev 4192) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-06-15 13:55:50 UTC (rev 4193) @@ -20,10 +20,12 @@ package net.sf.gridarta; import java.io.File; +import java.io.IOException; import java.util.MissingResourceException; import java.util.ResourceBundle; import javax.swing.ImageIcon; import javax.swing.JFileChooser; +import javax.swing.JOptionPane; import javax.swing.filechooser.FileFilter; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; @@ -31,6 +33,7 @@ import net.sf.gridarta.gui.HideFileFilterProxy; import net.sf.gridarta.gui.map.MapPreviewAccessory; import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; import net.sf.gridarta.updater.UpdaterManager; @@ -233,4 +236,37 @@ } } + /** {@inheritDoc} */ + public void createImage(@NotNull final MapView<G, A, R, V> mapView) { + if (getGlobalSettings().getImageDir() == null) { + getGlobalSettings().setImageDir(getGlobalSettings().getMapDir().getAbsolutePath()); + } + + final File file = new File(getGlobalSettings().getImageDir(), mapView.getMapControl().getMapFileName() + ".png"); + final JFileChooser fileChooser = new JFileChooser(getGlobalSettings().getImageDir()); + fileChooser.setDialogTitle("Save Image As"); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + fileChooser.setMultiSelectionEnabled(false); + fileChooser.setSelectedFile(file); + // set a file filter for "*.png" files + fileChooser.setFileFilter(pngFileFilter); + + final int returnVal = fileChooser.showSaveDialog(getMainView()); + if (returnVal == JFileChooser.APPROVE_OPTION) { + // got the filepath, now create image + File imageFile = fileChooser.getSelectedFile(); + if (!imageFile.getName().endsWith(".png")) { + imageFile = new File(imageFile.getParentFile(), imageFile.getName() + ".png"); + } + getGlobalSettings().setImageDir(imageFile.getParentFile().getAbsolutePath()); + if (!imageFile.exists() || ACTION_FACTORY.showConfirmDialog(getMainView(), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, "overwriteOtherFile", imageFile) == JOptionPane.YES_OPTION) { + try { + mapView.getView().getRenderer().printFullImage(imageFile); + } catch (final IOException e) { + ACTION_FACTORY.showMessageDialog(getMainView(), "createImageIOException", imageFile, e.getMessage()); + } + } + } + } + } // class AbstractMainControl Modified: trunk/src/app/net/sf/gridarta/GlobalSettings.java =================================================================== --- trunk/src/app/net/sf/gridarta/GlobalSettings.java 2008-06-15 13:36:17 UTC (rev 4192) +++ trunk/src/app/net/sf/gridarta/GlobalSettings.java 2008-06-15 13:55:50 UTC (rev 4193) @@ -52,6 +52,8 @@ */ String getScriptDefaultFolder(); + void setImageDir(String imageDir); + String getImageDir(); boolean isArchLoadedFromCollection(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-06-15 14:06:21
|
Revision: 4194 http://gridarta.svn.sourceforge.net/gridarta/?rev=4194&view=rev Author: akirschbaum Date: 2008-06-15 07:06:28 -0700 (Sun, 15 Jun 2008) Log Message: ----------- Move MainControl.createImageWanted() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-06-15 13:55:50 UTC (rev 4193) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-06-15 14:06:28 UTC (rev 4194) @@ -693,28 +693,6 @@ } } - /** - * Create an image of the specified map and save it as file. - * In this method, the filename is already given, so the image - * is created directly (if possible). - * @param mapView the map view of the map to save - * @param file the png image file to create - */ - public void createImageWanted(@NotNull final MapView<GameObject, MapArchObject, Archetype, CMapViewBasic> mapView, final File file) { - final File tmpFile = new File(file.getPath() + ".tmp"); - try { - mapView.getView().getRenderer().printFullImage(tmpFile); - if (!tmpFile.renameTo(file)) { - throw new IOException("cannot rename " + tmpFile + " to " + file); - } - if (log.isInfoEnabled()) { - log.info(ACTION_FACTORY.format("logImageCreated", file, mapView.getMapControl().getMapFileName())); - } - } catch (final IOException e) { - ACTION_FACTORY.showMessageDialog(mainView, "createImageIOException", file); - } - } - private PreferencesGroup prefsGroup; public void options() { Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-06-15 13:55:50 UTC (rev 4193) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-06-15 14:06:28 UTC (rev 4194) @@ -858,28 +858,6 @@ } } - /** - * Create an image of the specified map and save it as file. - * In this method, the filename is already given, so the image - * is created directly (if possible). - * @param mapView the map view of the map to save - * @param file the png image file to create - */ - public void createImageWanted(@NotNull final MapView<GameObject, MapArchObject, Archetype, CMapViewBasic> mapView, final File file) { - final File tmpFile = new File(file.getPath() + ".tmp"); - try { - mapView.getView().getRenderer().printFullImage(tmpFile); - if (!tmpFile.renameTo(file)) { - throw new IOException("cannot rename " + tmpFile + " to " + file); - } - if (log.isInfoEnabled()) { - log.info(ACTION_FACTORY.format("logImageCreated", file, mapView.getMapControl().getMapFileName())); - } - } catch (final IOException e) { - ACTION_FACTORY.showMessageDialog(mainView, "createImageIOException", file); - } - } - private PreferencesGroup prefsGroup; public void options() { Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-06-15 13:55:50 UTC (rev 4193) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-06-15 14:06:28 UTC (rev 4194) @@ -32,13 +32,14 @@ import net.sf.gridarta.gui.GUIConstants; import net.sf.gridarta.gui.HideFileFilterProxy; import net.sf.gridarta.gui.map.MapPreviewAccessory; +import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; -import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; import net.sf.gridarta.updater.UpdaterManager; import net.sf.japi.swing.ActionFactory; import net.sf.japi.util.filter.file.EndingFileFilter; +import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -54,6 +55,9 @@ /** Preferences default value for username. */ public static final String PREFS_USERNAME_DEFAULT = System.getProperty("user.name"); + /** The Logger for printing log messages. */ + private static final Logger log = Logger.getLogger(AbstractMainControl.class); + /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); @@ -269,4 +273,26 @@ } } + /** + * Create an image of the specified map and save it as file. + * In this method, the filename is already given, so the image + * is created directly (if possible). + * @param mapView the map view of the map to save + * @param file the png image file to create + */ + public void createImageWanted(@NotNull final MapView<G, A, R, V> mapView, final File file) { + final File tmpFile = new File(file.getPath() + ".tmp"); + try { + mapView.getView().getRenderer().printFullImage(tmpFile); + if (!tmpFile.renameTo(file)) { + throw new IOException("cannot rename " + tmpFile + " to " + file); + } + if (log.isInfoEnabled()) { + log.info(ACTION_FACTORY.format("logImageCreated", file, mapView.getMapControl().getMapFileName())); + } + } catch (final IOException e) { + ACTION_FACTORY.showMessageDialog(getMainView(), "createImageIOException", file); + } + } + } // class AbstractMainControl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-06-15 17:45:05
|
Revision: 4195 http://gridarta.svn.sourceforge.net/gridarta/?rev=4195&view=rev Author: akirschbaum Date: 2008-06-15 10:44:22 -0700 (Sun, 15 Jun 2008) Log Message: ----------- Use AnimationObjects from common code base where possible. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObjects.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java trunk/src/app/net/sf/gridarta/MainControl.java trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObjects.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-06-15 14:06:28 UTC (rev 4194) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-06-15 17:44:22 UTC (rev 4195) @@ -24,7 +24,7 @@ import cfeditor.gameobject.ArchetypeParser; import cfeditor.gameobject.ArchetypeSet; import cfeditor.gameobject.GameObject; -import cfeditor.gameobject.anim.AnimationObjects; +import cfeditor.gameobject.anim.AnimationObject; import cfeditor.gameobject.face.FaceObjects; import cfeditor.gameobject.scripts.ScriptArchEditor; import cfeditor.gameobject.scripts.ScriptArchUtils; @@ -58,6 +58,7 @@ import net.sf.gridarta.CommonConstants; import net.sf.gridarta.MainControl; import net.sf.gridarta.XmlHelper; +import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gameobject.match.GameObjectMatchers; import net.sf.gridarta.gameobject.match.GameObjectMatchersInstance; @@ -163,7 +164,7 @@ private final ArchetypeParser archetypeParser; /** The Animation Objects. */ - private final AnimationObjects animationObjects; + private final AnimationObjects<AnimationObject> animationObjects; /** The Face Objects. */ private final FaceObjects faceObjects = new FaceObjects(this); @@ -229,7 +230,7 @@ public CMainControl() { super(new CrossfireObjectsFactory(), "cfeditor"); instance = this; - animationObjects = new AnimationObjects(); + animationObjects = new cfeditor.gameobject.anim.AnimationObjects(); archetypeSet = new ArchetypeSet(this, animationObjects, faceObjects); scriptControl = new ScriptController(this); mapCursorControl = new MapCursorControl<GameObject, MapArchObject, Archetype, CMapViewBasic>("cfeditor", this, getMapManager()); @@ -445,7 +446,7 @@ * Get the Animation Objects. * @return animationObjects */ - public AnimationObjects getAnimationObjects() { + public AnimationObjects<AnimationObject> getAnimationObjects() { return animationObjects; } Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2008-06-15 14:06:28 UTC (rev 4194) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2008-06-15 17:44:22 UTC (rev 4195) @@ -56,7 +56,7 @@ private final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl; - private final AnimationObjects animationObjects; + private final AnimationObjects<?> animationObjects; /** * The archetype chooser to add parsed archetypes to. @@ -75,7 +75,7 @@ * @param archetypeChooserControl an archetype chooser to add parsed * archetypes to */ - public ArchetypeParser(final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final AnimationObjects animationObjects) { + public ArchetypeParser(final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final AnimationObjects<?> animationObjects) { this.mainControl = mainControl; this.archetypeChooserControl = archetypeChooserControl; this.animationObjects = animationObjects; Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-06-15 14:06:28 UTC (rev 4194) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-06-15 17:44:22 UTC (rev 4195) @@ -21,7 +21,7 @@ import cfeditor.CMainControl; import cfeditor.IGUIConstants; -import cfeditor.gameobject.anim.AnimationObjects; +import cfeditor.gameobject.anim.AnimationObject; import cfeditor.map.MapArchObject; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -38,6 +38,9 @@ import javax.swing.ImageIcon; import net.sf.gridarta.gameobject.AbstractArchetypeParser; import net.sf.gridarta.gameobject.AbstractArchetypeSet; +import net.sf.gridarta.gameobject.anim.AnimationObjects; +import net.sf.gridarta.gameobject.anim.AnimationParseException; +import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; import net.sf.gridarta.gameobject.face.ArchFaceProvider; import net.sf.gridarta.gameobject.face.DuplicateFaceException; import net.sf.gridarta.gameobject.face.FaceObjectProviders; @@ -66,7 +69,7 @@ private final CMainControl mainControl; - @NotNull private final AnimationObjects animationObjects; + @NotNull private final AnimationObjects<AnimationObject> animationObjects; /** The FaceObjects instance to use. */ @NotNull private final FaceObjects faceObjects; @@ -77,7 +80,7 @@ * @param animationObjects the animations to use * @param faceObjects the FaceObjects instance to use */ - public ArchetypeSet(final CMainControl mainControl, @NotNull final AnimationObjects animationObjects, @NotNull final FaceObjects faceObjects) { + public ArchetypeSet(final CMainControl mainControl, @NotNull final AnimationObjects<AnimationObject> animationObjects, @NotNull final FaceObjects faceObjects) { super(mainControl.getGridartaObjectsFactory()); this.mainControl = mainControl; this.animationObjects = animationObjects; @@ -245,6 +248,10 @@ log.warn("Error opening face file: " + e); } catch (final IOException e) { log.warn("Error reading face file: " + e); + } catch (AnimationParseException e) { + log.warn("Error reading face file: " + e); + } catch (DuplicateAnimationException e) { + log.warn("Error reading face file: " + e); } } Modified: trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObjects.java 2008-06-15 14:06:28 UTC (rev 4194) +++ trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObjects.java 2008-06-15 17:44:22 UTC (rev 4195) @@ -23,6 +23,7 @@ import java.io.File; import java.io.IOException; import java.io.Reader; +import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.List; import net.sf.gridarta.gameobject.anim.AbstractAnimationObjects; @@ -57,15 +58,7 @@ // TODO } - /** - * Loads any number of animations from a reader. It is not neccessary to - * provide a BufferedReader for buffering. This method will always wrap the - * supplied <var>reader</var> with a BufferedReader if the supplied reader - * isn't already a BufferedReader itself. - * @param reader Reader to load animations from - * @param path Path relative to the arch directory, used to create tree information - * @throws IOException in case of I/O errors - */ + /** {@inheritDoc} */ @SuppressWarnings({"IOResourceOpenedButNotSafelyClosed"}) public void loadAnims(final Reader reader, @Nullable final String path) throws IOException { final BufferedReader in = reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader); @@ -102,7 +95,11 @@ } /** {@inheritDoc} */ - @Override public void addAnimPath(final String name, final String path) { + public void loadAnimTree(final File animTreeFile) throws FileNotFoundException, IOException { } + /** {@inheritDoc} */ + public void addAnimPath(final String name, final String path) { + } + } // class AnimationObjects Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-06-15 14:06:28 UTC (rev 4194) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-06-15 17:44:22 UTC (rev 4195) @@ -23,7 +23,7 @@ import daieditor.gameobject.ArchetypeParser; import daieditor.gameobject.ArchetypeSet; import daieditor.gameobject.GameObject; -import daieditor.gameobject.anim.AnimationObjects; +import daieditor.gameobject.anim.AnimationObject; import daieditor.gameobject.face.FaceObjects; import daieditor.gameobject.scripts.ScriptArchEditor; import daieditor.gui.GameObjectAttributesDialog; @@ -61,6 +61,7 @@ import net.sf.gridarta.CommonConstants; import net.sf.gridarta.MainControl; import net.sf.gridarta.XmlHelper; +import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.face.FaceObjectProviders; import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gameobject.match.GameObjectMatchers; @@ -204,7 +205,7 @@ private final ArchetypeParser archetypeParser; /** The Animation Objects. */ - private final AnimationObjects animationObjects; + private final AnimationObjects<AnimationObject> animationObjects; /** The Face Objects. */ private final FaceObjects faceObjects = new FaceObjects(); @@ -280,7 +281,7 @@ public CMainControl() { super(new DaimoninObjectsFactory(), "daieditor"); instance = this; - animationObjects = new AnimationObjects(); + animationObjects = new daieditor.gameobject.anim.AnimationObjects(); archetypeSet = new ArchetypeSet(this, animationObjects, faceObjects); mapCursorControl = new MapCursorControl<GameObject, MapArchObject, Archetype, CMapViewBasic>("daieditor", this, getMapManager()); ACTION_FACTORY.createActions(true, this, "createNew", "open", "options", "exit", "newScript", "editScript", "controlServer", "controlClient", "cleanCompletelyBlockedSquares", "zoom", "gc", "onlineHelp", "tod", "about"); @@ -549,7 +550,7 @@ * Get the Animation Objects. * @return animationObjects */ - public AnimationObjects getAnimationObjects() { + public AnimationObjects<AnimationObject> getAnimationObjects() { return animationObjects; } Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2008-06-15 14:06:28 UTC (rev 4194) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2008-06-15 17:44:22 UTC (rev 4195) @@ -57,7 +57,7 @@ private final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl; - private final AnimationObjects animationObjects; + private final AnimationObjects<?> animationObjects; /** * The archetype chooser to add parsed archetypes to. @@ -76,7 +76,7 @@ * @param archetypeChooserControl an archetype chooser to add parsed * archetypes to */ - public ArchetypeParser(final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final AnimationObjects animationObjects) { + public ArchetypeParser(final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final AnimationObjects<?> animationObjects) { this.mainControl = mainControl; this.archetypeChooserControl = archetypeChooserControl; this.animationObjects = animationObjects; Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-06-15 14:06:28 UTC (rev 4194) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-06-15 17:44:22 UTC (rev 4195) @@ -21,7 +21,7 @@ import daieditor.CMainControl; import daieditor.IGUIConstants; -import daieditor.gameobject.anim.AnimationObjects; +import daieditor.gameobject.anim.AnimationObject; import daieditor.map.MapArchObject; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -39,6 +39,7 @@ import javax.swing.ImageIcon; import net.sf.gridarta.gameobject.AbstractArchetypeParser; import net.sf.gridarta.gameobject.AbstractArchetypeSet; +import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.anim.AnimationParseException; import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; import net.sf.gridarta.gameobject.face.ArchFaceProvider; @@ -69,7 +70,7 @@ private final CMainControl mainControl; - @NotNull private final AnimationObjects animationObjects; + @NotNull private final AnimationObjects<AnimationObject> animationObjects; /** The FaceObjects instance to use. */ @NotNull private final FaceObjects faceObjects; @@ -86,7 +87,7 @@ * @param animationObjects the animations to use * @param faceObjects the FaceObjects instance to use */ - public ArchetypeSet(final CMainControl mainControl, @NotNull final AnimationObjects animationObjects, @NotNull final FaceObjects faceObjects) { + public ArchetypeSet(final CMainControl mainControl, @NotNull final AnimationObjects<AnimationObject> animationObjects, @NotNull final FaceObjects faceObjects) { super(mainControl.getGridartaObjectsFactory()); this.mainControl = mainControl; this.animationObjects = animationObjects; Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-06-15 14:06:28 UTC (rev 4194) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-06-15 17:44:22 UTC (rev 4195) @@ -21,13 +21,13 @@ import daieditor.CMainControl; import daieditor.gameobject.anim.AnimationObject; -import daieditor.gameobject.anim.AnimationObjects; import daieditor.gameobject.scripts.ScriptArchData; import daieditor.gameobject.scripts.ScriptArchEditor; import daieditor.map.MapArchObject; import java.io.Serializable; import javax.swing.ImageIcon; import javax.swing.JList; +import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gui.GameObjectAttributesPanel; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -197,7 +197,7 @@ String effectiveFaceObjName; if (effectiveAnimName != null) { // we have a animation - get the frame picture - final AnimationObjects animationObjects = CMainControl.getInstance().getAnimationObjects(); + final AnimationObjects<AnimationObject> animationObjects = CMainControl.getInstance().getAnimationObjects(); final AnimationObject animationObject = animationObjects.get(effectiveAnimName); if (animationObject != null) { noface = false; Modified: trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java 2008-06-15 14:06:28 UTC (rev 4194) +++ trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java 2008-06-15 17:44:22 UTC (rev 4195) @@ -86,35 +86,7 @@ put(animationObject); } - /** - * Loads animations from a file. - * @param animFile file to load animations from - * @throws IOException in case of I/O errors - * @throws FileNotFoundException in case the file couldn't be opened - * @throws AnimationParseException in case parsing the animation reveals errors - * @throws DuplicateAnimationException in case an animation was not unique - */ - public void loadAnims(final File animFile) throws FileNotFoundException, IOException, AnimationParseException, DuplicateAnimationException { - final Reader in = new InputStreamReader(new FileInputStream(animFile), IOUtils.MAP_ENCODING); - try { - final String path = (new File(PathManager.getArchPath(animFile.getPath()))).getParent().replace('\\', '/'); - loadAnims(in, path); - } finally { - in.close(); - } - } - - /** - * Loads any number of animations from a reader. It is not neccessary to - * provide a BufferedReader for buffering. This method will always wrap the - * supplied <var>reader</var> with a BufferedReader if the supplied reader - * isn't already a BufferedReader itself. - * @param reader Reader to load animations from - * @param path Path relative to the arch directory, used to create tree information - * @throws IOException in case of I/O errors - * @throws AnimationParseException in case parsing the animation reveals errors - * @throws DuplicateAnimationException in case an animation was not unique - */ + /** {@inheritDoc} */ @SuppressWarnings({"IOResourceOpenedButNotSafelyClosed"}) public void loadAnims(final Reader reader, @Nullable final String path) throws IOException, AnimationParseException, DuplicateAnimationException { final BufferedReader in = reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader); @@ -152,7 +124,17 @@ } /** {@inheritDoc} */ - @Override public void addAnimPath(final String name, final String path) { + public void loadAnimTree(final File animTreeFile) throws FileNotFoundException, IOException { + final BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(animTreeFile), IOUtils.MAP_ENCODING)); + try { + loadAnimTree(in); + } finally { + in.close(); + } + } + + /** {@inheritDoc} */ + public void addAnimPath(final String name, final String path) { animMap.put(name, path); } @@ -165,21 +147,6 @@ } /** - * Loads animations from a file. - * @param animTreeFile file to load animations tree from - * @throws IOException in case of I/O errors - * @throws FileNotFoundException in case the file couldn't be opened - */ - public void loadAnimTree(final File animTreeFile) throws FileNotFoundException, IOException { - final BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(animTreeFile), IOUtils.MAP_ENCODING)); - try { - loadAnimTree(in); - } finally { - in.close(); - } - } - - /** * Reads Animation Tree from Stream. * @param reader Input stream * @throws IOException in case of I/O errors Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-06-15 14:06:28 UTC (rev 4194) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-06-15 17:44:22 UTC (rev 4195) @@ -26,7 +26,7 @@ import net.sf.gridarta.gameobject.ArchetypeParser; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gameobject.anim.AbstractAnimationObjects; +import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gui.MainActions; import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.ObjectChooser; @@ -108,7 +108,7 @@ * Get the AnimationObjects for the available Animations. * @return AnimationObjects */ - AbstractAnimationObjects getAnimationObjects(); + AnimationObjects<?> getAnimationObjects(); /** * Returns the MainView of this MainControl. Modified: trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java 2008-06-15 14:06:28 UTC (rev 4194) +++ trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java 2008-06-15 17:44:22 UTC (rev 4195) @@ -20,7 +20,15 @@ package net.sf.gridarta.gameobject.anim; import net.sf.gridarta.data.AbstractNamedObjects; +import net.sf.gridarta.io.IOUtils; +import net.sf.gridarta.io.PathManager; import net.sf.japi.swing.ActionFactory; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.Reader; +import java.io.InputStreamReader; +import java.io.FileInputStream; /** * Abstract base implementation of {@link AnimationObjects}. @@ -38,4 +46,15 @@ super(ACTION_FACTORY.getString("nameOfAnimationObject")); } + /** {@inheritDoc} */ + public void loadAnims(final File animFile) throws FileNotFoundException, IOException, AnimationParseException, DuplicateAnimationException { + final Reader in = new InputStreamReader(new FileInputStream(animFile), IOUtils.MAP_ENCODING); + try { + final String path = (new File(PathManager.getArchPath(animFile.getPath()))).getParent().replace('\\', '/'); + loadAnims(in, path); + } finally { + in.close(); + } + } + } // class AbstractAnimationObjects Modified: trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObjects.java 2008-06-15 14:06:28 UTC (rev 4194) +++ trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObjects.java 2008-06-15 17:44:22 UTC (rev 4195) @@ -19,8 +19,13 @@ package net.sf.gridarta.gameobject.anim; +import java.io.IOException; +import java.io.Reader; +import java.io.File; +import java.io.FileNotFoundException; import net.sf.gridarta.data.NamedObjects; import net.sf.gridarta.gameobject.Collectable; +import org.jetbrains.annotations.Nullable; /** * AnimationObjects is a container for {@link AnimationObject}s. @@ -43,4 +48,35 @@ */ void addAnimPath(String name, String path); + /** + * Loads animations from a file. + * @param animFile file to load animations from + * @throws java.io.IOException in case of I/O errors + * @throws java.io.FileNotFoundException in case the file couldn't be opened + * @throws AnimationParseException in case parsing the animation reveals errors + * @throws DuplicateAnimationException in case an animation was not unique + */ + void loadAnims(File animFile) throws FileNotFoundException, IOException, AnimationParseException, DuplicateAnimationException; + + /** + * Loads any number of animations from a reader. It is not neccessary to + * provide a BufferedReader for buffering. This method will always wrap the + * supplied <var>reader</var> with a BufferedReader if the supplied reader + * isn't already a BufferedReader itself. + * @param reader Reader to load animations from + * @param path Path relative to the arch directory, used to create tree information + * @throws IOException in case of I/O errors + * @throws AnimationParseException in case parsing the animation reveals errors + * @throws DuplicateAnimationException in case an animation was not unique + */ + void loadAnims(Reader reader, @Nullable String path) throws IOException, AnimationParseException, DuplicateAnimationException; + + /** + * Loads animations from a file. + * @param animTreeFile file to load animations tree from + * @throws IOException in case of I/O errors + * @throws FileNotFoundException in case the file couldn't be opened + */ + void loadAnimTree(File animTreeFile) throws FileNotFoundException, IOException; + } // interface AnimationObjects This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-06-15 18:07:13
|
Revision: 4196 http://gridarta.svn.sourceforge.net/gridarta/?rev=4196&view=rev Author: akirschbaum Date: 2008-06-15 11:05:56 -0700 (Sun, 15 Jun 2008) Log Message: ----------- Whitespace changes. 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-06-15 17:44:22 UTC (rev 4195) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-06-15 18:05:56 UTC (rev 4196) @@ -450,9 +450,7 @@ return animationObjects; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void validateMap(final MapModel<GameObject, MapArchObject, Archetype> map) { final ErrorCollector<GameObject, MapArchObject, Archetype> errorCollector = new DefaultErrorCollector<GameObject, MapArchObject, Archetype>(); validators.validateAll(map, errorCollector); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-06-15 17:44:22 UTC (rev 4195) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-06-15 18:05:56 UTC (rev 4196) @@ -565,9 +565,7 @@ controlServer.showDialog(mainView); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void validateMap(final MapModel<GameObject, MapArchObject, Archetype> map) { final ErrorCollector<GameObject, MapArchObject, Archetype> errorCollector = new DefaultErrorCollector<GameObject, MapArchObject, Archetype>(); validators.validateAll(map, errorCollector); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-06-15 18:13:34
|
Revision: 4197 http://gridarta.svn.sourceforge.net/gridarta/?rev=4197&view=rev Author: akirschbaum Date: 2008-06-15 11:13:15 -0700 (Sun, 15 Jun 2008) Log Message: ----------- Move MainControl.gc() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-06-15 18:05:56 UTC (rev 4196) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-06-15 18:13:15 UTC (rev 4197) @@ -457,16 +457,6 @@ map.setErrors(errorCollector); } - /** - * Runs the garbage collection. - */ - @SuppressWarnings({"InstanceMethodNamingConvention"}) - @ActionMethod public void gc() { - System.gc(); - System.runFinalization(); - mainView.getStatusBar().setStatusText("Garbage collection - done."); - } - /** View Treasure Lists. */ @ActionMethod public void viewTreasurelists() { treasureListTree.showDialog(); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-06-15 18:05:56 UTC (rev 4196) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-06-15 18:13:15 UTC (rev 4197) @@ -572,16 +572,6 @@ map.setErrors(errorCollector); } - /** - * Runs the garbage collection. - */ - @SuppressWarnings({"InstanceMethodNamingConvention"}) - @ActionMethod public void gc() { - System.gc(); - System.runFinalization(); - mainView.getStatusBar().setStatusText("Garbage collection - done."); - } - /** Control the client. */ @ActionMethod public void controlClient() { if (controlClient == null) { Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-06-15 18:05:56 UTC (rev 4196) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-06-15 18:13:15 UTC (rev 4197) @@ -38,6 +38,7 @@ import net.sf.gridarta.map.MapControl; import net.sf.gridarta.updater.UpdaterManager; import net.sf.japi.swing.ActionFactory; +import net.sf.japi.swing.ActionMethod; import net.sf.japi.util.filter.file.EndingFileFilter; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; @@ -295,4 +296,14 @@ } } + /** + * Runs the garbage collection. + */ + @SuppressWarnings({"InstanceMethodNamingConvention"}) + @ActionMethod public void gc() { + System.gc(); + System.runFinalization(); + getMainView().getStatusBar().setStatusText("Garbage collection - done."); + } + } // class AbstractMainControl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-06-15 18:14:35
|
Revision: 4198 http://gridarta.svn.sourceforge.net/gridarta/?rev=4198&view=rev Author: akirschbaum Date: 2008-06-15 11:14:17 -0700 (Sun, 15 Jun 2008) Log Message: ----------- Order import statements. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObjects.java trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObjects.java Modified: trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObjects.java 2008-06-15 18:13:15 UTC (rev 4197) +++ trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObjects.java 2008-06-15 18:14:17 UTC (rev 4198) @@ -21,9 +21,9 @@ import java.io.BufferedReader; import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.Reader; -import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.List; import net.sf.gridarta.gameobject.anim.AbstractAnimationObjects; Modified: trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java 2008-06-15 18:13:15 UTC (rev 4197) +++ trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java 2008-06-15 18:14:17 UTC (rev 4198) @@ -36,7 +36,6 @@ import net.sf.gridarta.gameobject.anim.AnimationParseException; import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; import net.sf.gridarta.io.IOUtils; -import net.sf.gridarta.io.PathManager; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.misc.Progress; import org.jetbrains.annotations.NotNull; Modified: trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java 2008-06-15 18:13:15 UTC (rev 4197) +++ trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java 2008-06-15 18:14:17 UTC (rev 4198) @@ -19,16 +19,16 @@ package net.sf.gridarta.gameobject.anim; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.Reader; import net.sf.gridarta.data.AbstractNamedObjects; import net.sf.gridarta.io.IOUtils; import net.sf.gridarta.io.PathManager; import net.sf.japi.swing.ActionFactory; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.Reader; -import java.io.InputStreamReader; -import java.io.FileInputStream; /** * Abstract base implementation of {@link AnimationObjects}. Modified: trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObjects.java 2008-06-15 18:13:15 UTC (rev 4197) +++ trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObjects.java 2008-06-15 18:14:17 UTC (rev 4198) @@ -19,10 +19,10 @@ package net.sf.gridarta.gameobject.anim; +import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.Reader; -import java.io.File; -import java.io.FileNotFoundException; import net.sf.gridarta.data.NamedObjects; import net.sf.gridarta.gameobject.Collectable; import org.jetbrains.annotations.Nullable; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-06-15 18:26:07
|
Revision: 4199 http://gridarta.svn.sourceforge.net/gridarta/?rev=4199&view=rev Author: akirschbaum Date: 2008-06-15 11:25:56 -0700 (Sun, 15 Jun 2008) Log Message: ----------- Move MainControl.newScript() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-06-15 18:14:17 UTC (rev 4198) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-06-15 18:25:56 UTC (rev 4199) @@ -462,11 +462,6 @@ treasureListTree.showDialog(); } - /** Create and open a new script. */ - @ActionMethod public void newScript() { - ScriptEditControlInstance.getInstance().openScriptNew(); - } - /** Edit an existing script. */ @ActionMethod public void editScript() { openFileWanted(false); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-06-15 18:14:17 UTC (rev 4198) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-06-15 18:25:56 UTC (rev 4199) @@ -592,11 +592,6 @@ treasureListTree.showDialog(); } - /** Create and open a new script. */ - @ActionMethod public void newScript() { - ScriptEditControlInstance.getInstance().openScriptNew(); - } - /** Edit an existing script. */ @ActionMethod public void editScript() { openFileWanted(false); Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-06-15 18:14:17 UTC (rev 4198) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-06-15 18:25:56 UTC (rev 4199) @@ -36,6 +36,7 @@ import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.textedit.scripteditor.ScriptEditControlInstance; import net.sf.gridarta.updater.UpdaterManager; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; @@ -306,4 +307,9 @@ getMainView().getStatusBar().setStatusText("Garbage collection - done."); } + /** Create and open a new script. */ + @ActionMethod public void newScript() { + ScriptEditControlInstance.getInstance().openScriptNew(); + } + } // class AbstractMainControl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-06-22 09:02:50
|
Revision: 4202 http://gridarta.svn.sourceforge.net/gridarta/?rev=4202&view=rev Author: akirschbaum Date: 2008-06-21 11:49:50 -0700 (Sat, 21 Jun 2008) Log Message: ----------- Fix crash when crossfire.0/daimonin.0 cannot be loaded. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-06-15 18:57:15 UTC (rev 4201) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-06-21 18:49:50 UTC (rev 4202) @@ -99,7 +99,7 @@ return SystemIcons.getNoarchTileIcon(); } - if (faceName == null) { + if (faceName == null || FaceObjectProviders.normal == null) { return SystemIcons.getNofaceTileIcon(); } Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-06-15 18:57:15 UTC (rev 4201) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-06-21 18:49:50 UTC (rev 4202) @@ -106,7 +106,7 @@ return SystemIcons.getNoarchTileIcon(); } - if (faceName == null) { + if (faceName == null || FaceObjectProviders.normal == null) { return SystemIcons.getNofaceTileIcon(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-06-22 10:34:32
|
Revision: 4203 http://gridarta.svn.sourceforge.net/gridarta/?rev=4203&view=rev Author: akirschbaum Date: 2008-06-21 11:54:01 -0700 (Sat, 21 Jun 2008) Log Message: ----------- Make method static. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-06-21 18:49:50 UTC (rev 4202) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-06-21 18:54:01 UTC (rev 4203) @@ -94,7 +94,7 @@ * referencing an undefined archetype * @return face ImageIcon for face <var>faceName</var> */ - @NotNull private ImageIcon getFace(@Nullable final String faceName, final boolean hasUndefinedArchetype) { + @NotNull private static ImageIcon getFace(@Nullable final String faceName, final boolean hasUndefinedArchetype) { if (hasUndefinedArchetype) { return SystemIcons.getNoarchTileIcon(); } Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-06-21 18:49:50 UTC (rev 4202) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-06-21 18:54:01 UTC (rev 4203) @@ -101,7 +101,7 @@ * referencing an undefined archetype * @return face ImageIcon for face <var>faceName</var> */ - @NotNull private ImageIcon getFace(@Nullable final String faceName, final boolean hasUndefinedArchetype) { + @NotNull private static ImageIcon getFace(@Nullable final String faceName, final boolean hasUndefinedArchetype) { if (hasUndefinedArchetype) { return SystemIcons.getNoarchTileIcon(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-06-22 17:01:19
|
Revision: 4205 http://gridarta.svn.sourceforge.net/gridarta/?rev=4205&view=rev Author: akirschbaum Date: 2008-06-22 10:01:27 -0700 (Sun, 22 Jun 2008) Log Message: ----------- Prepare unification. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java Modified: trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-06-21 21:17:10 UTC (rev 4204) +++ trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-06-22 17:01:27 UTC (rev 4205) @@ -133,8 +133,13 @@ } /** {@inheritDoc} */ + @Override protected String getPngFile() { + return IGUIConstants.PNG_FILE; + } + + /** {@inheritDoc} */ @Override protected void collectImageFile(@NotNull final Progress progress, @NotNull final File dir) throws IOException { - final File dfile = new File(dir, IGUIConstants.PNG_FILE); + final File dfile = new File(dir, getPngFile()); final FileOutputStream fout = new FileOutputStream(dfile); //It's safely closed because the stream is closed and that closes the channel. //noinspection ChannelOpenedButNotSafelyClosed Modified: trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-06-21 21:17:10 UTC (rev 4204) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-06-22 17:01:27 UTC (rev 4205) @@ -142,8 +142,13 @@ } /** {@inheritDoc} */ + @Override protected String getPngFile() { + return IGUIConstants.PNG_FILE; + } + + /** {@inheritDoc} */ @Override protected void collectImageFile(@NotNull final Progress progress, @NotNull final File dir) throws IOException { - final File dfile = new File(dir, IGUIConstants.PNG_FILE); + final File dfile = new File(dir, getPngFile()); final FileOutputStream fout = new FileOutputStream(dfile); //It's safely closed because the stream is closed and that closes the channel. //noinspection ChannelOpenedButNotSafelyClosed Modified: trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2008-06-21 21:17:10 UTC (rev 4204) +++ trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2008-06-22 17:01:27 UTC (rev 4205) @@ -129,4 +129,10 @@ put(faceObject); } + /** + * Returns the base name of the collected image file. + * @return the base name + */ + protected abstract String getPngFile(); + } // class AbstractFaceObjects This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-06-22 17:10:12
|
Revision: 4206 http://gridarta.svn.sourceforge.net/gridarta/?rev=4206&view=rev Author: akirschbaum Date: 2008-06-22 10:10:18 -0700 (Sun, 22 Jun 2008) Log Message: ----------- Move FaceObjects.collectImageFile() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java Modified: trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-06-22 17:01:27 UTC (rev 4205) +++ trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-06-22 17:10:18 UTC (rev 4206) @@ -138,52 +138,6 @@ } /** {@inheritDoc} */ - @Override protected void collectImageFile(@NotNull final Progress progress, @NotNull final File dir) throws IOException { - final File dfile = new File(dir, getPngFile()); - final FileOutputStream fout = new FileOutputStream(dfile); - //It's safely closed because the stream is closed and that closes the channel. - //noinspection ChannelOpenedButNotSafelyClosed - final FileChannel outChannel = fout.getChannel(); - final PrintStream binFile = new PrintStream(fout); - try { - final int numOfFaceObjects = size(); - progress.setLabel(ACTION_FACTORY.getString("archCollectImages"), numOfFaceObjects); - int i = 0; - for (final FaceObject faceObject : this) { - final String face = faceObject.getFaceName(); - final String path = ((ArchFaceProvider) FaceObjectProviders.normal).getFilename(face); - try { - final FileInputStream fin = new FileInputStream(path); - try { - //It's safely closed because the stream is closed and that closes the channel. - //noinspection ChannelOpenedButNotSafelyClosed - final FileChannel inChannel = fin.getChannel(); - final int imageSize = (int) inChannel.size(); - binFile.format("IMAGE %d %d %s\n", i, imageSize, face); - inChannel.transferTo(0, imageSize, outChannel); - } finally { - fin.close(); - } - } catch (final FileNotFoundException e) { - ACTION_FACTORY.showMessageDialog(progress.getParentComponent(), "archCollectErrorFileNotFound", path); - return; - } catch (final IOException e) { - ACTION_FACTORY.showMessageDialog(progress.getParentComponent(), "archCollectErrorIOException", path, e); - return; - } - - if (i++ % 100 == 0) { - progress.setValue(i); - } - } - progress.setValue(size()); // finished - progress.finished(); //getArchetypeCount(), faceListCount); - } finally { - binFile.close(); - } - } - - /** {@inheritDoc} */ @Override protected void collectTreeFile(@NotNull final Progress progress, @NotNull final File dir) throws IOException { final BufferedWriter treeFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(dir, IGUIConstants.FACETREE_FILE)), "us-ascii")); try { Modified: trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-06-22 17:01:27 UTC (rev 4205) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-06-22 17:10:18 UTC (rev 4206) @@ -147,52 +147,6 @@ } /** {@inheritDoc} */ - @Override protected void collectImageFile(@NotNull final Progress progress, @NotNull final File dir) throws IOException { - final File dfile = new File(dir, getPngFile()); - final FileOutputStream fout = new FileOutputStream(dfile); - //It's safely closed because the stream is closed and that closes the channel. - //noinspection ChannelOpenedButNotSafelyClosed - final FileChannel outChannel = fout.getChannel(); - final PrintStream binFile = new PrintStream(fout); - try { - final int numOfFaceObjects = size(); - progress.setLabel(ACTION_FACTORY.getString("archCollectImages"), numOfFaceObjects); - int i = 0; - for (final FaceObject faceObject : this) { - final String face = faceObject.getFaceName(); - final String path = ((ArchFaceProvider) FaceObjectProviders.normal).getFilename(face); - try { - final FileInputStream fin = new FileInputStream(path); - try { - //It's safely closed because the stream is closed and that closes the channel. - //noinspection ChannelOpenedButNotSafelyClosed - final FileChannel inChannel = fin.getChannel(); - final int imageSize = (int) inChannel.size(); - binFile.format("IMAGE %d %d %s\n", i, imageSize, face); - inChannel.transferTo(0, imageSize, outChannel); - } finally { - fin.close(); - } - } catch (final FileNotFoundException e) { - ACTION_FACTORY.showMessageDialog(progress.getParentComponent(), "archCollectErrorFileNotFound", path); - return; - } catch (final IOException e) { - ACTION_FACTORY.showMessageDialog(progress.getParentComponent(), "archCollectErrorIOException", path, e); - return; - } - - if (i++ % 100 == 0) { - progress.setValue(i); - } - } - progress.setValue(size()); // finished - progress.finished(); //getArchetypeCount(), faceListCount); - } finally { - binFile.close(); - } - } - - /** {@inheritDoc} */ @Override protected void collectTreeFile(@NotNull final Progress progress, @NotNull final File dir) throws IOException { final int stripPath = dir.getAbsolutePath().length(); final BufferedWriter treeFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(dir, IGUIConstants.FACETREE_FILE)), "us-ascii")); Modified: trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2008-06-22 17:01:27 UTC (rev 4205) +++ trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2008-06-22 17:10:18 UTC (rev 4206) @@ -23,9 +23,14 @@ import java.awt.image.RGBImageFilter; import java.io.BufferedWriter; import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; +import java.io.PrintStream; import java.io.PrintWriter; +import java.nio.channels.FileChannel; import net.sf.gridarta.CommonConstants; import net.sf.gridarta.data.AbstractNamedObjects; import net.sf.japi.swing.ActionFactory; @@ -84,8 +89,51 @@ * @param dir Destination directory to collect data to. * @throws IOException in case of I/O problems during collection */ - protected abstract void collectImageFile(@NotNull final Progress progress, @NotNull final File dir) throws IOException; + private void collectImageFile(@NotNull final Progress progress, @NotNull final File dir) throws IOException { + final File dfile = new File(dir, getPngFile()); + final FileOutputStream fout = new FileOutputStream(dfile); + //It's safely closed because the stream is closed and that closes the channel. + //noinspection ChannelOpenedButNotSafelyClosed + final FileChannel outChannel = fout.getChannel(); + final PrintStream binFile = new PrintStream(fout); + try { + final int numOfFaceObjects = size(); + progress.setLabel(ACTION_FACTORY.getString("archCollectImages"), numOfFaceObjects); + int i = 0; + for (final FaceObject faceObject : this) { + final String face = faceObject.getFaceName(); + final String path = ((ArchFaceProvider) FaceObjectProviders.normal).getFilename(face); + try { + final FileInputStream fin = new FileInputStream(path); + try { + //It's safely closed because the stream is closed and that closes the channel. + //noinspection ChannelOpenedButNotSafelyClosed + final FileChannel inChannel = fin.getChannel(); + final int imageSize = (int) inChannel.size(); + binFile.format("IMAGE %d %d %s\n", i, imageSize, face); + inChannel.transferTo(0, imageSize, outChannel); + } finally { + fin.close(); + } + } catch (final FileNotFoundException e) { + ACTION_FACTORY.showMessageDialog(progress.getParentComponent(), "archCollectErrorFileNotFound", path); + return; + } catch (final IOException e) { + ACTION_FACTORY.showMessageDialog(progress.getParentComponent(), "archCollectErrorIOException", path, e); + return; + } + if (i++ % 100 == 0) { + progress.setValue(i); + } + } + progress.setValue(size()); // finished + progress.finished(); //getArchetypeCount(), faceListCount); + } finally { + binFile.close(); + } + } + /** * Creates the tree file. * @param progress Progress to report progress to. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-06-22 18:50:54
|
Revision: 4209 http://gridarta.svn.sourceforge.net/gridarta/?rev=4209&view=rev Author: akirschbaum Date: 2008-06-22 11:50:05 -0700 (Sun, 22 Jun 2008) Log Message: ----------- Unify error checks. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java Modified: trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-06-22 18:28:22 UTC (rev 4208) +++ trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-06-22 18:50:05 UTC (rev 4209) @@ -131,8 +131,7 @@ final String faceName = faceB.toString().intern(); if (offset + size > data.length) { - log.warn("Truncated face data in file " + IGUIConstants.PNG_FILE + " at position " + offset + "."); - break; + throw new IOException("Truncated face data in file " + IGUIConstants.PNG_FILE + " at position " + offset); } if (treeIn != null) { Modified: trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-06-22 18:28:22 UTC (rev 4208) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-06-22 18:50:05 UTC (rev 4209) @@ -122,6 +122,11 @@ faceB.append(c); } final String faceName = faceB.toString().intern(); + + if (offset + size > data.length) { + throw new IOException("Truncated face data in file " + IGUIConstants.PNG_FILE + " at position " + offset); + } + if (treeIn != null) { final String originalFilename = treeIn.readLine(); if (originalFilename == null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-06-22 18:57:54
|
Revision: 4211 http://gridarta.svn.sourceforge.net/gridarta/?rev=4211&view=rev Author: akirschbaum Date: 2008-06-22 11:58:00 -0700 (Sun, 22 Jun 2008) Log Message: ----------- Order import statements. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java Modified: trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-06-22 18:53:28 UTC (rev 4210) +++ trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-06-22 18:58:00 UTC (rev 4211) @@ -20,6 +20,7 @@ package cfeditor.gameobject.face; import cfeditor.IGUIConstants; +import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.ByteArrayOutputStream; import java.io.File; @@ -28,11 +29,8 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.io.OutputStreamWriter; -import java.io.PrintStream; -import java.io.BufferedReader; import java.io.InputStreamReader; -import java.nio.channels.FileChannel; +import java.io.OutputStreamWriter; import net.sf.gridarta.gameobject.face.AbstractFaceObjects; import net.sf.gridarta.gameobject.face.ArchFaceProvider; import net.sf.gridarta.gameobject.face.CollectedFaceProvider; Modified: trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-06-22 18:53:28 UTC (rev 4210) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-06-22 18:58:00 UTC (rev 4211) @@ -31,8 +31,6 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; -import java.io.PrintStream; -import java.nio.channels.FileChannel; import net.sf.gridarta.gameobject.face.AbstractFaceObjects; import net.sf.gridarta.gameobject.face.ArchFaceProvider; import net.sf.gridarta.gameobject.face.CollectedFaceProvider; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-06-22 19:16:37
|
Revision: 4212 http://gridarta.svn.sourceforge.net/gridarta/?rev=4212&view=rev Author: akirschbaum Date: 2008-06-22 12:16:45 -0700 (Sun, 22 Jun 2008) Log Message: ----------- Move ScriptArchEditor.localizeEventPath() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java 2008-06-22 18:58:00 UTC (rev 4211) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java 2008-06-22 19:16:45 UTC (rev 4212) @@ -41,6 +41,7 @@ import javax.swing.JTextField; import javax.swing.WindowConstants; import net.sf.gridarta.AbstractMainControl; +import net.sf.gridarta.gameobject.scripts.AbstractScriptArchEditor; import net.sf.gridarta.gameobject.scripts.PathButtonListener; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeException; import net.sf.gridarta.io.PathManager; @@ -48,7 +49,7 @@ import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; -public class ScriptArchEditor { +public class ScriptArchEditor extends AbstractScriptArchEditor { /** The Logger for printing log messages. */ private static final Logger log = Logger.getLogger(ScriptArchEditor.class); @@ -110,57 +111,6 @@ } /** - * This method is called when the user selects a new event to be created. - * The path relative to the map dir is calculated, and if reasonable, - * a relative path is created (relative to the map the event is on). - * @param f script file - * @return local event path - */ - public static String localizeEventPath(final File f) { - final File localMapDir = AbstractMainControl.getInstance().getLocalMapDir(); - final File mapDir = new File(AbstractMainControl.getInstance().getGlobalSettings().getMapDefaultFolder()); // global map directory - - if (!mapDir.exists()) { - log.warn("Map directory '" + mapDir.getAbsolutePath() + "' does not exist!"); - return f.getName(); - } - - // find out if the scriptfile is in a subdirectory of the map file - File tmp; - for (tmp = f.getParentFile(); tmp != null && !tmp.getAbsolutePath().equalsIgnoreCase(localMapDir.getAbsolutePath()); tmp = tmp.getParentFile()) { - ; - } - - // FIXME: It would be a good idea to perform the canonization somewhere else. - // The paths returned by mapFile.getParentFile() and mControl.getMapDefaultFolder() should already be canonical - String path; - if (tmp == null) { - // scriptfile is NOT in a subirectory of mapfile -> absolute path - try { - path = f.getAbsolutePath().substring(mapDir.getCanonicalPath().length()); - } catch (final IOException e) { - path = f.getAbsolutePath().substring(mapDir.getAbsolutePath().length()); - } - path = path.replace('\\', '/'); - if (!path.startsWith("/")) { - path = "/" + path; // leading slash - } - } else { - // scriptfile is in a subirectory of mapfile -> relative path - try { - path = f.getAbsolutePath().substring(localMapDir.getCanonicalPath().length()); - } catch (final IOException e) { - path = f.getAbsolutePath().substring(localMapDir.getAbsolutePath().length()); - } - path = path.replace('\\', '/'); - while (path.length() > 0 && path.startsWith("/")) { - path = path.substring(1); // no leading slash - } - } - return path; - } - - /** * A popup is opened and the user can create a new scripting event * which gets attached to this gameObject. * @param panelList JList from the MapArchPanel (script tab) which displays the events Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java 2008-06-22 18:58:00 UTC (rev 4211) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java 2008-06-22 19:16:45 UTC (rev 4212) @@ -41,6 +41,7 @@ import javax.swing.JTextField; import javax.swing.WindowConstants; import net.sf.gridarta.AbstractMainControl; +import net.sf.gridarta.gameobject.scripts.AbstractScriptArchEditor; import net.sf.gridarta.gameobject.scripts.PathButtonListener; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeException; import net.sf.gridarta.io.PathManager; @@ -48,7 +49,7 @@ import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; -public class ScriptArchEditor { +public class ScriptArchEditor extends AbstractScriptArchEditor { /** The Logger for printing log messages. */ private static final Logger log = Logger.getLogger(ScriptArchEditor.class); @@ -110,57 +111,6 @@ } /** - * This method is called when the user selects a new event to be created. - * The path relative to the map dir is calculated, and if reasonable, - * a relative path is created (relative to the map the event is on). - * @param f script file - * @return local event path - */ - public static String localizeEventPath(final File f) { - final File localMapDir = AbstractMainControl.getInstance().getLocalMapDir(); - final File mapDir = new File(AbstractMainControl.getInstance().getGlobalSettings().getMapDefaultFolder()); // global map directory - - if (!mapDir.exists()) { - log.warn("Map directory '" + mapDir.getAbsolutePath() + "' does not exist!"); - return f.getName(); - } - - // find out if the scriptfile is in a subdirectory of the map file - File tmp; - for (tmp = f.getParentFile(); tmp != null && !tmp.getAbsolutePath().equalsIgnoreCase(localMapDir.getAbsolutePath()); tmp = tmp.getParentFile()) { - ; - } - - // FIXME: It would be a good idea to perform the canonization somewhere else. - // The paths returned by mapFile.getParentFile() and mControl.getMapDefaultFolder() should already be canonical - String path; - if (tmp == null) { - // scriptfile is NOT in a subirectory of mapfile -> absolute path - try { - path = f.getAbsolutePath().substring(mapDir.getCanonicalPath().length()); - } catch (final IOException e) { - path = f.getAbsolutePath().substring(mapDir.getAbsolutePath().length()); - } - path = path.replace('\\', '/'); - if (!path.startsWith("/")) { - path = "/" + path; // leading slash - } - } else { - // scriptfile is in a subirectory of mapfile -> relative path - try { - path = f.getAbsolutePath().substring(localMapDir.getCanonicalPath().length()); - } catch (final IOException e) { - path = f.getAbsolutePath().substring(localMapDir.getAbsolutePath().length()); - } - path = path.replace('\\', '/'); - while (path.length() > 0 && path.startsWith("/")) { - path = path.substring(1); // no leading slash - } - } - return path; - } - - /** * A popup is opened and the user can create a new scripting event * which gets attached to this gameObject. * @param panelList JList from the MapArchPanel (script tab) which displays the events Added: trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java 2008-06-22 19:16:45 UTC (rev 4212) @@ -0,0 +1,89 @@ +/* + * 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.gameobject.scripts; + +import java.io.File; +import java.io.IOException; +import net.sf.gridarta.AbstractMainControl; +import org.apache.log4j.Logger; + +public abstract class AbstractScriptArchEditor { + + /** The Logger for printing log messages. */ + private static final Logger log = Logger.getLogger(AbstractScriptArchEditor.class); + + /** + * Creates a new instance. + */ + protected AbstractScriptArchEditor() { + } + + /** + * This method is called when the user selects a new event to be created. + * The path relative to the map dir is calculated, and if reasonable, + * a relative path is created (relative to the map the event is on). + * @param f script file + * @return local event path + */ + protected static String localizeEventPath(final File f) { + final File localMapDir = AbstractMainControl.getInstance().getLocalMapDir(); + final File mapDir = new File(AbstractMainControl.getInstance().getGlobalSettings().getMapDefaultFolder()); // global map directory + + if (!mapDir.exists()) { + log.warn("Map directory '" + mapDir.getAbsolutePath() + "' does not exist!"); + return f.getName(); + } + + // find out if the scriptfile is in a subdirectory of the map file + File tmp; + for (tmp = f.getParentFile(); tmp != null && !tmp.getAbsolutePath().equalsIgnoreCase(localMapDir.getAbsolutePath()); tmp = tmp.getParentFile()) { + ; + } + + // FIXME: It would be a good idea to perform the canonization somewhere else. + // The paths returned by mapFile.getParentFile() and mControl.getMapDefaultFolder() should already be canonical + String path; + if (tmp == null) { + // scriptfile is NOT in a subirectory of mapfile -> absolute path + try { + path = f.getAbsolutePath().substring(mapDir.getCanonicalPath().length()); + } catch (final IOException e) { + path = f.getAbsolutePath().substring(mapDir.getAbsolutePath().length()); + } + path = path.replace('\\', '/'); + if (!path.startsWith("/")) { + path = "/" + path; // leading slash + } + } else { + // scriptfile is in a subirectory of mapfile -> relative path + try { + path = f.getAbsolutePath().substring(localMapDir.getCanonicalPath().length()); + } catch (final IOException e) { + path = f.getAbsolutePath().substring(localMapDir.getAbsolutePath().length()); + } + path = path.replace('\\', '/'); + while (path.length() > 0 && path.startsWith("/")) { + path = path.substring(1); // no leading slash + } + } + return path; + } + +} // class AbstractScriptArchEditor Property changes on: trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.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-06-22 19:26:22
|
Revision: 4213 http://gridarta.svn.sourceforge.net/gridarta/?rev=4213&view=rev Author: akirschbaum Date: 2008-06-22 12:26:31 -0700 (Sun, 22 Jun 2008) Log Message: ----------- Prepare unification. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-06-22 19:16:45 UTC (rev 4212) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-06-22 19:26:31 UTC (rev 4213) @@ -287,7 +287,7 @@ log.error("Cannot read " + CommonConstants.TYPEDEF_FILE + ": " + ex.getMessage()); } - ScriptArchEditor.initEventTypeBoxes(".py", "Python"); + ScriptArchEditor.initEventTypeBoxes(".py", "Python", ScriptArchUtils.createEventTypeBox()); final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, MainView.MAP_TILE_LIST_BOTTOM_DEFAULT); selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(ACTION_FACTORY, this, mainView, mapTileListBottom, null); Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java 2008-06-22 19:16:45 UTC (rev 4212) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java 2008-06-22 19:26:31 UTC (rev 4213) @@ -76,13 +76,13 @@ private static JTextField inputOptions; /** Initialize the JComboBox with the event types. */ - public static synchronized void initEventTypeBoxes(final String ending, final String name) { + public static synchronized void initEventTypeBoxes(final String ending, final String name, final JComboBox eventTypeBox) { scriptEnding = ending; pluginNameBox = new JComboBox(new String[]{name}); pluginNameBox.setSelectedIndex(0); - eventTypeBox = ScriptArchUtils.createEventTypeBox(); + ScriptArchEditor.eventTypeBox = eventTypeBox; } /** Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-06-22 19:16:45 UTC (rev 4212) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-06-22 19:26:31 UTC (rev 4213) @@ -26,6 +26,7 @@ import daieditor.gameobject.anim.AnimationObject; import daieditor.gameobject.face.FaceObjects; import daieditor.gameobject.scripts.ScriptArchEditor; +import daieditor.gameobject.scripts.ScriptArchUtils; import daieditor.gui.GameObjectAttributesDialog; import daieditor.gui.GameObjectAttributesPanel; import daieditor.gui.ObjectChooser; @@ -341,7 +342,7 @@ log.error("Cannot read " + CommonConstants.TYPEDEF_FILE + ": " + ex.getMessage()); } - ScriptArchEditor.initEventTypeBoxes(".lua", "Lua"); + ScriptArchEditor.initEventTypeBoxes(".lua", "Lua", ScriptArchUtils.createEventTypeBox()); final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, MainView.MAP_TILE_LIST_BOTTOM_DEFAULT); selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(ACTION_FACTORY, this, mainView, mapTileListBottom, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH)); Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java 2008-06-22 19:16:45 UTC (rev 4212) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java 2008-06-22 19:26:31 UTC (rev 4213) @@ -76,13 +76,13 @@ private static JTextField inputOptions; /** Initialize the JComboBox with the event types. */ - public static synchronized void initEventTypeBoxes(final String ending, final String name) { + public static synchronized void initEventTypeBoxes(final String ending, final String name, final JComboBox eventTypeBox) { scriptEnding = ending; pluginNameBox = new JComboBox(new String[]{name}); pluginNameBox.setSelectedIndex(0); - eventTypeBox = ScriptArchUtils.createEventTypeBox(); + ScriptArchEditor.eventTypeBox = eventTypeBox; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-06-22 19:37:05
|
Revision: 4214 http://gridarta.svn.sourceforge.net/gridarta/?rev=4214&view=rev Author: akirschbaum Date: 2008-06-22 12:37:14 -0700 (Sun, 22 Jun 2008) Log Message: ----------- Move ScriptArchEditor.initEventTypeBoxes() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-06-22 19:26:31 UTC (rev 4213) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-06-22 19:37:14 UTC (rev 4214) @@ -26,7 +26,6 @@ import cfeditor.gameobject.GameObject; import cfeditor.gameobject.anim.AnimationObject; import cfeditor.gameobject.face.FaceObjects; -import cfeditor.gameobject.scripts.ScriptArchEditor; import cfeditor.gameobject.scripts.ScriptArchUtils; import cfeditor.gui.GameObjectAttributesDialog; import cfeditor.gui.GameObjectAttributesPanel; @@ -62,6 +61,7 @@ import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gameobject.match.GameObjectMatchers; import net.sf.gridarta.gameobject.match.GameObjectMatchersInstance; +import net.sf.gridarta.gameobject.scripts.AbstractScriptArchEditor; import net.sf.gridarta.gui.About; import net.sf.gridarta.gui.HideFileFilterProxy; import net.sf.gridarta.gui.MainActions; @@ -287,7 +287,7 @@ log.error("Cannot read " + CommonConstants.TYPEDEF_FILE + ": " + ex.getMessage()); } - ScriptArchEditor.initEventTypeBoxes(".py", "Python", ScriptArchUtils.createEventTypeBox()); + AbstractScriptArchEditor.initEventTypeBoxes(".py", "Python", ScriptArchUtils.createEventTypeBox()); final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, MainView.MAP_TILE_LIST_BOTTOM_DEFAULT); selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(ACTION_FACTORY, this, mainView, mapTileListBottom, null); Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java 2008-06-22 19:26:31 UTC (rev 4213) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java 2008-06-22 19:37:14 UTC (rev 4214) @@ -31,7 +31,6 @@ import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton; -import javax.swing.JComboBox; import javax.swing.JDialog; import javax.swing.JFileChooser; import javax.swing.JLabel; @@ -57,9 +56,6 @@ /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); - /** The ending for scripts. */ - private static String scriptEnding; - // popup frame for new scripts: private static JDialog newScriptFrame; @@ -67,24 +63,10 @@ private static PathButtonListener nsOkListener; - private static JComboBox eventTypeBox; - - private static JComboBox pluginNameBox; - private static JTextField inputScriptPath; private static JTextField inputOptions; - /** Initialize the JComboBox with the event types. */ - public static synchronized void initEventTypeBoxes(final String ending, final String name, final JComboBox eventTypeBox) { - scriptEnding = ending; - - pluginNameBox = new JComboBox(new String[]{name}); - pluginNameBox.setSelectedIndex(0); - - ScriptArchEditor.eventTypeBox = eventTypeBox; - } - /** * Try to create a reasonable default script name for lazy users. * @param archName the best suitable name for the arch (see GameObject.getBestName()) Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-06-22 19:26:31 UTC (rev 4213) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-06-22 19:37:14 UTC (rev 4214) @@ -25,7 +25,6 @@ import daieditor.gameobject.GameObject; import daieditor.gameobject.anim.AnimationObject; import daieditor.gameobject.face.FaceObjects; -import daieditor.gameobject.scripts.ScriptArchEditor; import daieditor.gameobject.scripts.ScriptArchUtils; import daieditor.gui.GameObjectAttributesDialog; import daieditor.gui.GameObjectAttributesPanel; @@ -69,6 +68,7 @@ import net.sf.gridarta.gameobject.match.GameObjectMatchersInstance; import net.sf.gridarta.gameobject.match.MutableOrGameObjectMatcher; import net.sf.gridarta.gameobject.match.ViewGameObjectMatcherManager; +import net.sf.gridarta.gameobject.scripts.AbstractScriptArchEditor; import net.sf.gridarta.gui.About; import net.sf.gridarta.gui.GUIUtils; import net.sf.gridarta.gui.HideFileFilterProxy; @@ -342,7 +342,7 @@ log.error("Cannot read " + CommonConstants.TYPEDEF_FILE + ": " + ex.getMessage()); } - ScriptArchEditor.initEventTypeBoxes(".lua", "Lua", ScriptArchUtils.createEventTypeBox()); + AbstractScriptArchEditor.initEventTypeBoxes(".lua", "Lua", ScriptArchUtils.createEventTypeBox()); final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, MainView.MAP_TILE_LIST_BOTTOM_DEFAULT); selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(ACTION_FACTORY, this, mainView, mapTileListBottom, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH)); Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java 2008-06-22 19:26:31 UTC (rev 4213) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java 2008-06-22 19:37:14 UTC (rev 4214) @@ -31,7 +31,6 @@ import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton; -import javax.swing.JComboBox; import javax.swing.JDialog; import javax.swing.JFileChooser; import javax.swing.JLabel; @@ -57,9 +56,6 @@ /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); - /** The ending for scripts. */ - private static String scriptEnding; - // popup frame for new scripts: private static JDialog newScriptFrame; @@ -67,24 +63,10 @@ private static PathButtonListener nsOkListener; - private static JComboBox eventTypeBox; - - private static JComboBox pluginNameBox; - private static JTextField inputScriptPath; private static JTextField inputOptions; - /** Initialize the JComboBox with the event types. */ - public static synchronized void initEventTypeBoxes(final String ending, final String name, final JComboBox eventTypeBox) { - scriptEnding = ending; - - pluginNameBox = new JComboBox(new String[]{name}); - pluginNameBox.setSelectedIndex(0); - - ScriptArchEditor.eventTypeBox = eventTypeBox; - } - /** * Try to create a reasonable default script name for lazy users. * @param archName the best suitable name for the arch (see GameObject.getBestName()) Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java 2008-06-22 19:26:31 UTC (rev 4213) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java 2008-06-22 19:37:14 UTC (rev 4214) @@ -21,6 +21,7 @@ import java.io.File; import java.io.IOException; +import javax.swing.JComboBox; import net.sf.gridarta.AbstractMainControl; import org.apache.log4j.Logger; @@ -29,12 +30,29 @@ /** The Logger for printing log messages. */ private static final Logger log = Logger.getLogger(AbstractScriptArchEditor.class); + /** The ending for scripts. */ + protected static String scriptEnding; + + protected static JComboBox eventTypeBox; + + protected static JComboBox pluginNameBox; + /** * Creates a new instance. */ protected AbstractScriptArchEditor() { } + /** Initialize the JComboBox with the event types. */ + public static synchronized void initEventTypeBoxes(final String ending, final String name, final JComboBox eventTypeBox) { + scriptEnding = ending; + + pluginNameBox = new JComboBox(new String[]{name}); + pluginNameBox.setSelectedIndex(0); + + AbstractScriptArchEditor.eventTypeBox = eventTypeBox; + } + /** * This method is called when the user selects a new event to be created. * The path relative to the map dir is calculated, and if reasonable, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-06-22 19:42:59
|
Revision: 4215 http://gridarta.svn.sourceforge.net/gridarta/?rev=4215&view=rev Author: akirschbaum Date: 2008-06-22 12:43:03 -0700 (Sun, 22 Jun 2008) Log Message: ----------- Move ScriptArchEditor.chooseDefaultScriptName() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java 2008-06-22 19:37:14 UTC (rev 4214) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java 2008-06-22 19:43:03 UTC (rev 4215) @@ -43,7 +43,6 @@ import net.sf.gridarta.gameobject.scripts.AbstractScriptArchEditor; import net.sf.gridarta.gameobject.scripts.PathButtonListener; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeException; -import net.sf.gridarta.io.PathManager; import net.sf.gridarta.textedit.scripteditor.ScriptEditControlInstance; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; @@ -68,31 +67,6 @@ private static JTextField inputOptions; /** - * Try to create a reasonable default script name for lazy users. - * @param archName the best suitable name for the arch (see GameObject.getBestName()) - * @return a nice default script name without whitespaces - */ - public static String chooseDefaultScriptName(final String archName) { - String defScriptName = archName.trim(); - final int i; - if ((i = defScriptName.indexOf(" ")) >= 0) { - if (defScriptName.length() > 12 || defScriptName.lastIndexOf(" ") != i) { - // if there are several whitespaces or the name is too long, just cut off the end - defScriptName = defScriptName.substring(0, i); - } else { - // if there is only one whitespace in a short name, remove whitespace - defScriptName = defScriptName.substring(0, i) + defScriptName.substring(i + 1, i + 2).toUpperCase() + defScriptName.substring(i + 2); - } - } - if (defScriptName.length() >= 3) { - defScriptName = defScriptName.substring(0, 1).toUpperCase() + defScriptName.substring(1); - } - defScriptName += "Script" + scriptEnding; - - return PathManager.getMapPath(new File(AbstractMainControl.getInstance().getLocalMapDir(), defScriptName).getPath()); - } - - /** * A popup is opened and the user can create a new scripting event * which gets attached to this gameObject. * @param panelList JList from the MapArchPanel (script tab) which displays the events Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java 2008-06-22 19:37:14 UTC (rev 4214) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java 2008-06-22 19:43:03 UTC (rev 4215) @@ -43,7 +43,6 @@ import net.sf.gridarta.gameobject.scripts.AbstractScriptArchEditor; import net.sf.gridarta.gameobject.scripts.PathButtonListener; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeException; -import net.sf.gridarta.io.PathManager; import net.sf.gridarta.textedit.scripteditor.ScriptEditControlInstance; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; @@ -68,31 +67,6 @@ private static JTextField inputOptions; /** - * Try to create a reasonable default script name for lazy users. - * @param archName the best suitable name for the arch (see GameObject.getBestName()) - * @return a nice default script name without whitespaces - */ - public static String chooseDefaultScriptName(final String archName) { - String defScriptName = archName.trim(); - final int i; - if ((i = defScriptName.indexOf(" ")) >= 0) { - if (defScriptName.length() > 12 || defScriptName.lastIndexOf(" ") != i) { - // if there are several whitespaces or the name is too long, just cut off the end - defScriptName = defScriptName.substring(0, i); - } else { - // if there is only one whitespace in a short name, remove whitespace - defScriptName = defScriptName.substring(0, i) + defScriptName.substring(i + 1, i + 2).toUpperCase() + defScriptName.substring(i + 2); - } - } - if (defScriptName.length() >= 3) { - defScriptName = defScriptName.substring(0, 1).toUpperCase() + defScriptName.substring(1); - } - defScriptName += "Script" + scriptEnding; - - return PathManager.getMapPath(new File(AbstractMainControl.getInstance().getLocalMapDir(), defScriptName).getPath()); - } - - /** * A popup is opened and the user can create a new scripting event * which gets attached to this gameObject. * @param panelList JList from the MapArchPanel (script tab) which displays the events Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java 2008-06-22 19:37:14 UTC (rev 4214) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java 2008-06-22 19:43:03 UTC (rev 4215) @@ -23,6 +23,7 @@ import java.io.IOException; import javax.swing.JComboBox; import net.sf.gridarta.AbstractMainControl; +import net.sf.gridarta.io.PathManager; import org.apache.log4j.Logger; public abstract class AbstractScriptArchEditor { @@ -104,4 +105,29 @@ return path; } + /** + * Try to create a reasonable default script name for lazy users. + * @param archName the best suitable name for the arch (see GameObject.getBestName()) + * @return a nice default script name without whitespaces + */ + public static String chooseDefaultScriptName(final String archName) { + String defScriptName = archName.trim(); + final int i; + if ((i = defScriptName.indexOf(" ")) >= 0) { + if (defScriptName.length() > 12 || defScriptName.lastIndexOf(" ") != i) { + // if there are several whitespaces or the name is too long, just cut off the end + defScriptName = defScriptName.substring(0, i); + } else { + // if there is only one whitespace in a short name, remove whitespace + defScriptName = defScriptName.substring(0, i) + defScriptName.substring(i + 1, i + 2).toUpperCase() + defScriptName.substring(i + 2); + } + } + if (defScriptName.length() >= 3) { + defScriptName = defScriptName.substring(0, 1).toUpperCase() + defScriptName.substring(1); + } + defScriptName += "Script" + scriptEnding; + + return PathManager.getMapPath(new File(AbstractMainControl.getInstance().getLocalMapDir(), defScriptName).getPath()); + } + } // class AbstractScriptArchEditor This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-06-22 19:46:33
|
Revision: 4216 http://gridarta.svn.sourceforge.net/gridarta/?rev=4216&view=rev Author: akirschbaum Date: 2008-06-22 12:46:41 -0700 (Sun, 22 Jun 2008) Log Message: ----------- Prepare refactoring. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java 2008-06-22 19:43:03 UTC (rev 4215) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java 2008-06-22 19:46:41 UTC (rev 4216) @@ -76,7 +76,7 @@ public static void addEventScript(final JList panelList, final GameObject gameObject, final ScriptArchData scriptArchData) { final String archName = gameObject.getBestName(); // create a reasonable default script name for lazy users :-) - final String defScriptName = chooseDefaultScriptName(archName); + final String defScriptName = chooseDefaultScriptName(archName, scriptEnding); if (newScriptFrame == null) { // initialize popup frame Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java 2008-06-22 19:43:03 UTC (rev 4215) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java 2008-06-22 19:46:41 UTC (rev 4216) @@ -76,7 +76,7 @@ public static void addEventScript(final JList panelList, final GameObject gameObject, final ScriptArchData scriptArchData) { final String archName = gameObject.getBestName(); // create a reasonable default script name for lazy users :-) - final String defScriptName = chooseDefaultScriptName(archName); + final String defScriptName = chooseDefaultScriptName(archName, scriptEnding); if (newScriptFrame == null) { // initialize popup frame Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java 2008-06-22 19:43:03 UTC (rev 4215) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java 2008-06-22 19:46:41 UTC (rev 4216) @@ -108,9 +108,10 @@ /** * Try to create a reasonable default script name for lazy users. * @param archName the best suitable name for the arch (see GameObject.getBestName()) + * @param scriptEnding the ending for scripts * @return a nice default script name without whitespaces */ - public static String chooseDefaultScriptName(final String archName) { + public static String chooseDefaultScriptName(final String archName, final String scriptEnding) { String defScriptName = archName.trim(); final int i; if ((i = defScriptName.indexOf(" ")) >= 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-06-22 19:52:45
|
Revision: 4217 http://gridarta.svn.sourceforge.net/gridarta/?rev=4217&view=rev Author: akirschbaum Date: 2008-06-22 12:52:53 -0700 (Sun, 22 Jun 2008) Log Message: ----------- Move code from AbstractScriptArchEditor to ScriptUtils. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptUtils.java Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java 2008-06-22 19:46:41 UTC (rev 4216) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java 2008-06-22 19:52:53 UTC (rev 4217) @@ -42,6 +42,7 @@ import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.gameobject.scripts.AbstractScriptArchEditor; import net.sf.gridarta.gameobject.scripts.PathButtonListener; +import net.sf.gridarta.gameobject.scripts.ScriptUtils; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeException; import net.sf.gridarta.textedit.scripteditor.ScriptEditControlInstance; import net.sf.japi.swing.ActionFactory; @@ -76,7 +77,7 @@ public static void addEventScript(final JList panelList, final GameObject gameObject, final ScriptArchData scriptArchData) { final String archName = gameObject.getBestName(); // create a reasonable default script name for lazy users :-) - final String defScriptName = chooseDefaultScriptName(archName, scriptEnding); + final String defScriptName = ScriptUtils.chooseDefaultScriptName(archName, scriptEnding); if (newScriptFrame == null) { // initialize popup frame @@ -132,7 +133,7 @@ if (fileChooser.showOpenDialog(newScriptFrame) == JFileChooser.APPROVE_OPTION) { // user has selected a file final File f = fileChooser.getSelectedFile(); - inputScriptPath.setText(localizeEventPath(f)); + inputScriptPath.setText(ScriptUtils.localizeEventPath(f)); } } }); Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java 2008-06-22 19:46:41 UTC (rev 4216) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java 2008-06-22 19:52:53 UTC (rev 4217) @@ -42,6 +42,7 @@ import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.gameobject.scripts.AbstractScriptArchEditor; import net.sf.gridarta.gameobject.scripts.PathButtonListener; +import net.sf.gridarta.gameobject.scripts.ScriptUtils; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeException; import net.sf.gridarta.textedit.scripteditor.ScriptEditControlInstance; import net.sf.japi.swing.ActionFactory; @@ -76,7 +77,7 @@ public static void addEventScript(final JList panelList, final GameObject gameObject, final ScriptArchData scriptArchData) { final String archName = gameObject.getBestName(); // create a reasonable default script name for lazy users :-) - final String defScriptName = chooseDefaultScriptName(archName, scriptEnding); + final String defScriptName = ScriptUtils.chooseDefaultScriptName(archName, scriptEnding); if (newScriptFrame == null) { // initialize popup frame @@ -132,7 +133,7 @@ if (fileChooser.showOpenDialog(newScriptFrame) == JFileChooser.APPROVE_OPTION) { // user has selected a file final File f = fileChooser.getSelectedFile(); - inputScriptPath.setText(localizeEventPath(f)); + inputScriptPath.setText(ScriptUtils.localizeEventPath(f)); } } }); Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java 2008-06-22 19:46:41 UTC (rev 4216) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java 2008-06-22 19:52:53 UTC (rev 4217) @@ -19,11 +19,7 @@ package net.sf.gridarta.gameobject.scripts; -import java.io.File; -import java.io.IOException; import javax.swing.JComboBox; -import net.sf.gridarta.AbstractMainControl; -import net.sf.gridarta.io.PathManager; import org.apache.log4j.Logger; public abstract class AbstractScriptArchEditor { @@ -54,81 +50,4 @@ AbstractScriptArchEditor.eventTypeBox = eventTypeBox; } - /** - * This method is called when the user selects a new event to be created. - * The path relative to the map dir is calculated, and if reasonable, - * a relative path is created (relative to the map the event is on). - * @param f script file - * @return local event path - */ - protected static String localizeEventPath(final File f) { - final File localMapDir = AbstractMainControl.getInstance().getLocalMapDir(); - final File mapDir = new File(AbstractMainControl.getInstance().getGlobalSettings().getMapDefaultFolder()); // global map directory - - if (!mapDir.exists()) { - log.warn("Map directory '" + mapDir.getAbsolutePath() + "' does not exist!"); - return f.getName(); - } - - // find out if the scriptfile is in a subdirectory of the map file - File tmp; - for (tmp = f.getParentFile(); tmp != null && !tmp.getAbsolutePath().equalsIgnoreCase(localMapDir.getAbsolutePath()); tmp = tmp.getParentFile()) { - ; - } - - // FIXME: It would be a good idea to perform the canonization somewhere else. - // The paths returned by mapFile.getParentFile() and mControl.getMapDefaultFolder() should already be canonical - String path; - if (tmp == null) { - // scriptfile is NOT in a subirectory of mapfile -> absolute path - try { - path = f.getAbsolutePath().substring(mapDir.getCanonicalPath().length()); - } catch (final IOException e) { - path = f.getAbsolutePath().substring(mapDir.getAbsolutePath().length()); - } - path = path.replace('\\', '/'); - if (!path.startsWith("/")) { - path = "/" + path; // leading slash - } - } else { - // scriptfile is in a subirectory of mapfile -> relative path - try { - path = f.getAbsolutePath().substring(localMapDir.getCanonicalPath().length()); - } catch (final IOException e) { - path = f.getAbsolutePath().substring(localMapDir.getAbsolutePath().length()); - } - path = path.replace('\\', '/'); - while (path.length() > 0 && path.startsWith("/")) { - path = path.substring(1); // no leading slash - } - } - return path; - } - - /** - * Try to create a reasonable default script name for lazy users. - * @param archName the best suitable name for the arch (see GameObject.getBestName()) - * @param scriptEnding the ending for scripts - * @return a nice default script name without whitespaces - */ - public static String chooseDefaultScriptName(final String archName, final String scriptEnding) { - String defScriptName = archName.trim(); - final int i; - if ((i = defScriptName.indexOf(" ")) >= 0) { - if (defScriptName.length() > 12 || defScriptName.lastIndexOf(" ") != i) { - // if there are several whitespaces or the name is too long, just cut off the end - defScriptName = defScriptName.substring(0, i); - } else { - // if there is only one whitespace in a short name, remove whitespace - defScriptName = defScriptName.substring(0, i) + defScriptName.substring(i + 1, i + 2).toUpperCase() + defScriptName.substring(i + 2); - } - } - if (defScriptName.length() >= 3) { - defScriptName = defScriptName.substring(0, 1).toUpperCase() + defScriptName.substring(1); - } - defScriptName += "Script" + scriptEnding; - - return PathManager.getMapPath(new File(AbstractMainControl.getInstance().getLocalMapDir(), defScriptName).getPath()); - } - } // class AbstractScriptArchEditor Added: trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptUtils.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptUtils.java 2008-06-22 19:52:53 UTC (rev 4217) @@ -0,0 +1,115 @@ +/* + * 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.gameobject.scripts; + +import java.io.File; +import java.io.IOException; +import net.sf.gridarta.AbstractMainControl; +import net.sf.gridarta.io.PathManager; +import org.apache.log4j.Logger; + +public class ScriptUtils { + + /** The Logger for printing log messages. */ + private static final Logger log = Logger.getLogger(ScriptUtils.class); + + /** + * Private constructor to prevent instantiation. + */ + private ScriptUtils() { + } + + /** + * This method is called when the user selects a new event to be created. + * The path relative to the map dir is calculated, and if reasonable, + * a relative path is created (relative to the map the event is on). + * @param f script file + * @return local event path + */ + public static String localizeEventPath(final File f) { + final File localMapDir = AbstractMainControl.getInstance().getLocalMapDir(); + final File mapDir = new File(AbstractMainControl.getInstance().getGlobalSettings().getMapDefaultFolder()); // global map directory + + if (!mapDir.exists()) { + log.warn("Map directory '" + mapDir.getAbsolutePath() + "' does not exist!"); + return f.getName(); + } + + // find out if the scriptfile is in a subdirectory of the map file + File tmp; + for (tmp = f.getParentFile(); tmp != null && !tmp.getAbsolutePath().equalsIgnoreCase(localMapDir.getAbsolutePath()); tmp = tmp.getParentFile()) { + ; + } + + // FIXME: It would be a good idea to perform the canonization somewhere else. + // The paths returned by mapFile.getParentFile() and mControl.getMapDefaultFolder() should already be canonical + String path; + if (tmp == null) { + // scriptfile is NOT in a subirectory of mapfile -> absolute path + try { + path = f.getAbsolutePath().substring(mapDir.getCanonicalPath().length()); + } catch (final IOException e) { + path = f.getAbsolutePath().substring(mapDir.getAbsolutePath().length()); + } + path = path.replace('\\', '/'); + if (!path.startsWith("/")) { + path = "/" + path; // leading slash + } + } else { + // scriptfile is in a subirectory of mapfile -> relative path + try { + path = f.getAbsolutePath().substring(localMapDir.getCanonicalPath().length()); + } catch (final IOException e) { + path = f.getAbsolutePath().substring(localMapDir.getAbsolutePath().length()); + } + path = path.replace('\\', '/'); + while (path.length() > 0 && path.startsWith("/")) { + path = path.substring(1); // no leading slash + } + } + return path; + } + + /** + * Try to create a reasonable default script name for lazy users. + * @param archName the best suitable name for the arch (see GameObject.getBestName()) + * @param scriptEnding the ending for scripts + * @return a nice default script name without whitespaces + */ + public static String chooseDefaultScriptName(final String archName, final String scriptEnding) { + String defScriptName = archName.trim(); + final int i; + if ((i = defScriptName.indexOf(" ")) >= 0) { + if (defScriptName.length() > 12 || defScriptName.lastIndexOf(" ") != i) { + // if there are several whitespaces or the name is too long, just cut off the end + defScriptName = defScriptName.substring(0, i); + } else { + // if there is only one whitespace in a short name, remove whitespace + defScriptName = defScriptName.substring(0, i) + defScriptName.substring(i + 1, i + 2).toUpperCase() + defScriptName.substring(i + 2); + } + } + if (defScriptName.length() >= 3) { + defScriptName = defScriptName.substring(0, 1).toUpperCase() + defScriptName.substring(1); + } + defScriptName += "Script" + scriptEnding; + + return PathManager.getMapPath(new File(AbstractMainControl.getInstance().getLocalMapDir(), defScriptName).getPath()); + } +} // class ScriptUtils Property changes on: trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptUtils.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. |