From: <aki...@us...> - 2008-04-11 17:50:25
|
Revision: 3875 http://gridarta.svn.sourceforge.net/gridarta/?rev=3875&view=rev Author: akirschbaum Date: 2008-04-11 10:50:16 -0700 (Fri, 11 Apr 2008) Log Message: ----------- Remove calls to AbstractMainControl.getInstance(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-09 23:23:28 UTC (rev 3874) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-11 17:50:16 UTC (rev 3875) @@ -299,7 +299,7 @@ scriptControl.getView().setMenu((JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "plugins")); archetypeParser = new ArchetypeParser(this, objectChooser.getArchetypeChooserControl()); animationObjects = new AnimationObjects(); - faceObjects = new FaceObjects(); + faceObjects = new FaceObjects(this); archetypeSet.loadArchetypes(archetypeParser); if (autoPopupDocu) { Modified: trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-04-09 23:23:28 UTC (rev 3874) +++ trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-04-11 17:50:16 UTC (rev 3875) @@ -32,7 +32,7 @@ import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Iterator; -import net.sf.gridarta.AbstractMainControl; +import net.sf.gridarta.MainControl; import net.sf.gridarta.gameobject.face.AbstractFaceObjects; import net.sf.gridarta.gameobject.face.DuplicateFaceException; import net.sf.japi.swing.ActionFactory; @@ -49,6 +49,17 @@ /** Size of the image buffer. */ private static final int IMAGE_BUFFER_SIZE = 50 * 1024; + /** The main control. */ + @NotNull private final MainControl<?, ?, ?, ?, ?> mainControl; + + /** + * Creates a new instance. + * @param mainControl the main control + */ + public FaceObjects(@NotNull final MainControl<?, ?, ?, ?, ?> mainControl) { + this.mainControl = mainControl; + } + /** Reloads all providers provided by this FaceObjects. */ public static void reloadAll() { // TODO @@ -83,7 +94,7 @@ DataOutputStream binFile = null; try { final File dfile = new File(dir, IGUIConstants.PNG_FILE); - AbstractMainControl.getInstance().getMainView().setStatusText("Collect Archfile: write images"); + mainControl.getMainView().setStatusText("Collect Archfile: write images"); binFile = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(dfile))); @@ -212,7 +223,7 @@ pname1 = faceObject.getPath().substring(tmp).replace('\\', '/').replace('.', '%'); } else { // hope nobody renames his arch-dir and ends up in here - pname1 = "arch" + faceObject.getPath().substring(AbstractMainControl.getInstance().getArchDefaultFolder().length()).replace('\\', '/'); + pname1 = "arch" + faceObject.getPath().substring(mainControl.getArchDefaultFolder().length()).replace('\\', '/'); } return "./" + pname1.substring(0, pname1.lastIndexOf("/") + 1); } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-04-09 23:23:28 UTC (rev 3874) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-04-11 17:50:16 UTC (rev 3875) @@ -353,7 +353,7 @@ mapActions.updateMenuState(); archetypeParser = new ArchetypeParser(this, objectChooser.getArchetypeChooserControl()); animationObjects = new AnimationObjects(); - faceObjects = new FaceObjects(); + faceObjects = new FaceObjects(this); archetypeSet.loadArchetypes(archetypeParser); if (autoPopupDocu) { Modified: trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-04-09 23:23:28 UTC (rev 3874) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-04-11 17:50:16 UTC (rev 3875) @@ -36,7 +36,7 @@ import java.io.PrintStream; import java.nio.channels.FileChannel; import javax.swing.GrayFilter; -import net.sf.gridarta.AbstractMainControl; +import net.sf.gridarta.MainControl; import net.sf.gridarta.gameobject.face.AbstractFaceObjects; import net.sf.gridarta.gameobject.face.DuplicateFaceException; import net.sf.japi.swing.ActionFactory; @@ -154,6 +154,17 @@ /** The FaceProvider for grid faces. */ public static final FaceProvider GRID = new FilterFaceProvider(GRID_FILTER); + /** The main control. */ + @NotNull private final MainControl<?, ?, ?, ?, ?> mainControl; + + /** + * Creates a new instance. + * @param mainControl the main control + */ + public FaceObjects(@NotNull final MainControl<?, ?, ?, ?, ?> mainControl) { + this.mainControl = mainControl; + } + /** Reloads all providers provided by this FaceObjects. */ public static void reloadAll() { for (final FaceProvider faceProvider : new FaceProvider[]{normal, GRAY, RED, GREEN, BLUE, ALPHA, GRID}) { @@ -241,7 +252,7 @@ //noinspection IOResourceOpenedButNotSafelyClosed treeIn = new BufferedReader(new InputStreamReader(new FileInputStream(treeFile), "us-ascii")); } catch (final FileNotFoundException e) { - ACTION_FACTORY.showMessageDialog(AbstractMainControl.getInstance().getMainView(), "errCantLoadFaceTree"); + ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "errCantLoadFaceTree"); } final byte[] tag = "IMAGE ".getBytes(); // this is the starting string for a new png final StringBuilder faceB = new StringBuilder(); // face name of png This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-11 19:22:05
|
Revision: 3877 http://gridarta.svn.sourceforge.net/gridarta/?rev=3877&view=rev Author: akirschbaum Date: 2008-04-11 12:22:08 -0700 (Fri, 11 Apr 2008) Log Message: ----------- Whitespace changes. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java trunk/src/app/net/sf/gridarta/treasurelist/CFTreasureListTree.java Modified: trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-04-11 19:16:00 UTC (rev 3876) +++ trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-04-11 19:22:08 UTC (rev 3877) @@ -57,7 +57,7 @@ * @param mainControl the main control */ public FaceObjects(@NotNull final MainControl<?, ?, ?, ?, ?> mainControl) { - this.mainControl = mainControl; + this.mainControl = mainControl; } /** Reloads all providers provided by this FaceObjects. */ Modified: trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-04-11 19:16:00 UTC (rev 3876) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-04-11 19:22:08 UTC (rev 3877) @@ -162,7 +162,7 @@ * @param mainControl the main control */ public FaceObjects(@NotNull final MainControl<?, ?, ?, ?, ?> mainControl) { - this.mainControl = mainControl; + this.mainControl = mainControl; } /** Reloads all providers provided by this FaceObjects. */ Modified: trunk/src/app/net/sf/gridarta/treasurelist/CFTreasureListTree.java =================================================================== --- trunk/src/app/net/sf/gridarta/treasurelist/CFTreasureListTree.java 2008-04-11 19:16:00 UTC (rev 3876) +++ trunk/src/app/net/sf/gridarta/treasurelist/CFTreasureListTree.java 2008-04-11 19:22:08 UTC (rev 3877) @@ -96,7 +96,7 @@ */ public CFTreasureListTree(@NotNull final MainView<G, A, R, ?, ?> mainView, @NotNull final ArchetypeSet<G, A, R> archetypeSet, final Map<String, TreasureTreeNode> specialTreasureLists, final TreasureLocation... treasures) { super(root); - this.mainView = mainView; + this.mainView = mainView; putClientProperty("JTree.lineStyle", "Angled"); setCellRenderer(new TreasureCellRenderer(archetypeSet, root)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-11 19:56:30
|
Revision: 3878 http://gridarta.svn.sourceforge.net/gridarta/?rev=3878&view=rev Author: akirschbaum Date: 2008-04-11 12:55:19 -0700 (Fri, 11 Apr 2008) Log Message: ----------- Remove calls to CMainControl.getAnimationObjects(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-11 19:22:08 UTC (rev 3877) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-11 19:55:19 UTC (rev 3878) @@ -246,7 +246,8 @@ public CMainControl() { super(new CrossfireObjectsFactory(), "cfeditor"); instance = this; - archetypeSet = new ArchetypeSet(this); + animationObjects = new AnimationObjects(); + archetypeSet = new ArchetypeSet(this, animationObjects); scriptControl = new ScriptController(this); mapCursorControl = new MapCursorControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>("cfeditor", this, getMapManager()); ACTION_FACTORY.createActions(true, this, "createNew", "open", "options", "exit", "gc", "onlineHelp", "tod", "about"); @@ -298,7 +299,6 @@ mapActions.updateMenuState(); scriptControl.getView().setMenu((JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "plugins")); archetypeParser = new ArchetypeParser(this, objectChooser.getArchetypeChooserControl()); - animationObjects = new AnimationObjects(); faceObjects = new FaceObjects(this); archetypeSet.loadArchetypes(archetypeParser); Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-04-11 19:22:08 UTC (rev 3877) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-04-11 19:55:19 UTC (rev 3878) @@ -21,6 +21,7 @@ import cfeditor.CMainControl; import cfeditor.IGUIConstants; +import cfeditor.gameobject.anim.AnimationObjects; import cfeditor.gameobject.face.FaceObject; import cfeditor.map.MapArchObject; import java.io.BufferedReader; @@ -64,13 +65,17 @@ private final CMainControl mainControl; + @NotNull private final AnimationObjects animationObjects; + /** * Create the ArchetypeSet. * @param mainControl reference to CMainControl + * @param animationObjects the animations to use */ - public ArchetypeSet(final CMainControl mainControl) { + public ArchetypeSet(final CMainControl mainControl, @NotNull final AnimationObjects animationObjects) { super(mainControl.getGridartaObjectsFactory()); this.mainControl = mainControl; + this.animationObjects = animationObjects; } /** {@inheritDoc} */ @@ -226,7 +231,7 @@ try { final BufferedReader myInput = new BufferedReader(new FileReader(filename)); try { - mainControl.getAnimationObjects().loadAnims(myInput, filename); + animationObjects.loadAnims(myInput, filename); } finally { myInput.close(); } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-04-11 19:22:08 UTC (rev 3877) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-04-11 19:55:19 UTC (rev 3878) @@ -298,7 +298,8 @@ public CMainControl() { super(new DaimoninObjectsFactory(), "daieditor"); instance = this; - archetypeSet = new ArchetypeSet(this); + animationObjects = new AnimationObjects(); + archetypeSet = new ArchetypeSet(this, animationObjects); mapCursorControl = new MapCursorControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>("daieditor", this, getMapManager()); ACTION_FACTORY.createActions(true, this, "createNew", "open", "options", "exit", "newScript", "editScript", "controlServer", "controlClient", "cleanCompletelyBlockedSquares", "zoom", "gc", "onlineHelp", "tod", "about"); ACTION_FACTORY.createToggles(true, this, "drawDouble"); @@ -352,7 +353,6 @@ mainView.init(new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER), selectedSquareControl.getSelectedSquareView(), typeList, mapTileListBottom); mapActions.updateMenuState(); archetypeParser = new ArchetypeParser(this, objectChooser.getArchetypeChooserControl()); - animationObjects = new AnimationObjects(); faceObjects = new FaceObjects(this); archetypeSet.loadArchetypes(archetypeParser); Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-04-11 19:22:08 UTC (rev 3877) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-04-11 19:55:19 UTC (rev 3878) @@ -67,6 +67,8 @@ private final CMainControl mainControl; + @NotNull private final AnimationObjects animationObjects; + /** * The animation files. * This variable is only used during arch collection from files. @@ -76,10 +78,12 @@ /** * Create the ArchetypeSet. * @param mainControl reference to CMainControl + * @param animationObjects the animations to use */ - public ArchetypeSet(final CMainControl mainControl) { + public ArchetypeSet(final CMainControl mainControl, @NotNull final AnimationObjects animationObjects) { super(mainControl.getGridartaObjectsFactory()); this.mainControl = mainControl; + this.animationObjects = animationObjects; } /** @@ -303,7 +307,7 @@ setLoadedFromArchive(true); // load from the collected files try { - mainControl.getAnimationObjects().loadAnimTree(new File(mainControl.getConfigurationDirectory(), IGUIConstants.ANIMTREE_FILE)); + animationObjects.loadAnimTree(new File(mainControl.getConfigurationDirectory(), IGUIConstants.ANIMTREE_FILE)); loadAllDaimoninAnimationsFromCollect(); // open the resource file final String baseDir = mainControl.getArchDefaultFolder(); @@ -386,10 +390,9 @@ * loadArchFromFiles() wasn't invoked. */ private void loadAnimsFromFiles() { - final AnimationObjects anims = mainControl.getAnimationObjects(); for (final File animFile : animFiles) { try { - anims.loadAnims(animFile); + animationObjects.loadAnims(animFile); } catch (final DuplicateAnimationException e) { mainControl.handleThrowable(e); } catch (final IOException e) { @@ -407,7 +410,7 @@ try { final Reader in = IOUtils.createReader(mainControl.getArchDefaultFolder(), "animations"); try { - mainControl.getAnimationObjects().loadAnims(in, null); + animationObjects.loadAnims(in, null); } finally { in.close(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-11 20:05:06
|
Revision: 3879 http://gridarta.svn.sourceforge.net/gridarta/?rev=3879&view=rev Author: akirschbaum Date: 2008-04-11 13:04:42 -0700 (Fri, 11 Apr 2008) Log Message: ----------- Remove calls to CMainControl.getAnimationObjects(). 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-04-11 19:55:19 UTC (rev 3878) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-11 20:04:42 UTC (rev 3879) @@ -485,7 +485,7 @@ final List<Collectable> collectables = new ArrayList<Collectable>(); final Collector collector = new Collector(progress); collectables.add(getArchetypeSet()); - collectables.add(getAnimationObjects()); + collectables.add(animationObjects); collectables.add(getFaceObjects()); collector.setCollectables(collectables); collector.setDestDir(new File(getConfigurationDirectory())); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-04-11 19:55:19 UTC (rev 3878) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-04-11 20:04:42 UTC (rev 3879) @@ -611,7 +611,7 @@ final List<Collectable> collectables = new ArrayList<Collectable>(); final Collector collector = new Collector(progress); collectables.add(getArchetypeSet()); - collectables.add(getAnimationObjects()); + collectables.add(animationObjects); collectables.add(getFaceObjects()); collector.setCollectables(collectables); collector.setDestDir(new File(getArchDefaultFolder())); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-11 20:20:20
|
Revision: 3880 http://gridarta.svn.sourceforge.net/gridarta/?rev=3880&view=rev Author: akirschbaum Date: 2008-04-11 13:20:22 -0700 (Fri, 11 Apr 2008) Log Message: ----------- Remove calls to CMainControl.getAnimationObjects(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 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-04-11 20:04:42 UTC (rev 3879) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-11 20:20:22 UTC (rev 3880) @@ -298,7 +298,7 @@ mainView.init(new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER), selectedSquareControl.getSelectedSquareView(), typeList, mapTileListBottom); mapActions.updateMenuState(); scriptControl.getView().setMenu((JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "plugins")); - archetypeParser = new ArchetypeParser(this, objectChooser.getArchetypeChooserControl()); + archetypeParser = new ArchetypeParser(this, objectChooser.getArchetypeChooserControl(), animationObjects); faceObjects = new FaceObjects(this); archetypeSet.loadArchetypes(archetypeParser); Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2008-04-11 20:04:42 UTC (rev 3879) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2008-04-11 20:20:22 UTC (rev 3880) @@ -29,6 +29,7 @@ import java.util.regex.Pattern; import net.sf.gridarta.MainControl; import net.sf.gridarta.gameobject.AbstractArchetypeParser; +import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.io.PathManager; @@ -56,6 +57,8 @@ private final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl; + private final AnimationObjects animationObjects; + /** * The archetype chooser to add parsed archetypes to. */ @@ -73,9 +76,10 @@ * @param archetypeChooserControl an archetype chooser to add parsed * archetypes to */ - public ArchetypeParser(final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> archetypeChooserControl) { + public ArchetypeParser(final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> archetypeChooserControl, final AnimationObjects animationObjects) { this.mainControl = mainControl; this.archetypeChooserControl = archetypeChooserControl; + this.animationObjects = animationObjects; } /** {@inheritDoc} */ @@ -157,8 +161,8 @@ if (thisLine.equals("mina")) { try { archetype.setAnimText(animText.toString()); - mainControl.getAnimationObjects().addAnimPath(archetype.getArchetypeName(), path.concat(archetype.getArchetypeName())); - mainControl.getAnimationObjects().addAnimationObject(archetype.getArchetypeName(), animText.toString()); + animationObjects.addAnimPath(archetype.getArchetypeName(), path.concat(archetype.getArchetypeName())); + animationObjects.addAnimationObject(archetype.getArchetypeName(), animText.toString()); animText = null; } catch (final DuplicateAnimationException e) { // TODO: Report to the user Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-04-11 20:04:42 UTC (rev 3879) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-04-11 20:20:22 UTC (rev 3880) @@ -352,7 +352,7 @@ // Initialize the main view mainView.init(new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER), selectedSquareControl.getSelectedSquareView(), typeList, mapTileListBottom); mapActions.updateMenuState(); - archetypeParser = new ArchetypeParser(this, objectChooser.getArchetypeChooserControl()); + archetypeParser = new ArchetypeParser(this, objectChooser.getArchetypeChooserControl(), animationObjects); faceObjects = new FaceObjects(this); archetypeSet.loadArchetypes(archetypeParser); Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2008-04-11 20:04:42 UTC (rev 3879) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2008-04-11 20:20:22 UTC (rev 3880) @@ -30,6 +30,7 @@ import java.util.regex.Pattern; import net.sf.gridarta.MainControl; import net.sf.gridarta.gameobject.AbstractArchetypeParser; +import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.io.PathManager; @@ -57,6 +58,8 @@ private final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl; + private final AnimationObjects animationObjects; + /** * The archetype chooser to add parsed archetypes to. */ @@ -74,9 +77,10 @@ * @param archetypeChooserControl an archetype chooser to add parsed * archetypes to */ - public ArchetypeParser(final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> archetypeChooserControl) { + public ArchetypeParser(final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> archetypeChooserControl, final AnimationObjects animationObjects) { this.mainControl = mainControl; this.archetypeChooserControl = archetypeChooserControl; + this.animationObjects = animationObjects; } /** {@inheritDoc} */ @@ -168,8 +172,8 @@ } else if (animflag) { if (thisLine.equals("mina")) { try { - mainControl.getAnimationObjects().addAnimPath(archetype.getArchetypeName(), path.concat(archetype.getArchetypeName())); - mainControl.getAnimationObjects().addAnimationObject(archetype.getArchetypeName(), animText.toString()); + animationObjects.addAnimPath(archetype.getArchetypeName(), path.concat(archetype.getArchetypeName())); + animationObjects.addAnimationObject(archetype.getArchetypeName(), animText.toString()); animText = null; } catch (final DuplicateAnimationException e) { // TODO: Report to the user Modified: trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java 2008-04-11 20:04:42 UTC (rev 3879) +++ trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java 2008-04-11 20:20:22 UTC (rev 3880) @@ -38,11 +38,4 @@ super(ACTION_FACTORY.getString("nameOfAnimationObject")); } - /** - * Adds name-path pair to <var>animHashTable</var>. - * @param name Name of the object - * @param path Path of directory containing the arc file - */ - public abstract void addAnimPath(final String name, final String path); - } // class AbstractAnimationObjects Modified: trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObjects.java 2008-04-11 20:04:42 UTC (rev 3879) +++ trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObjects.java 2008-04-11 20:20:22 UTC (rev 3880) @@ -36,4 +36,11 @@ */ void addAnimationObject(String animName, String list) throws DuplicateAnimationException; + /** + * Adds name-path pair to <var>animHashTable</var>. + * @param name Name of the object + * @param path Path of directory containing the arc file + */ + void addAnimPath(String name, String path); + } // interface AnimationObjects This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-11 20:31:41
|
Revision: 3881 http://gridarta.svn.sourceforge.net/gridarta/?rev=3881&view=rev Author: akirschbaum Date: 2008-04-11 13:31:29 -0700 (Fri, 11 Apr 2008) Log Message: ----------- Remove calls to CMainControl.getFaceObjects(). 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-04-11 20:20:22 UTC (rev 3880) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-11 20:31:29 UTC (rev 3881) @@ -486,7 +486,7 @@ final Collector collector = new Collector(progress); collectables.add(getArchetypeSet()); collectables.add(animationObjects); - collectables.add(getFaceObjects()); + collectables.add(faceObjects); collector.setCollectables(collectables); collector.setDestDir(new File(getConfigurationDirectory())); collector.start(); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-04-11 20:20:22 UTC (rev 3880) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-04-11 20:31:29 UTC (rev 3881) @@ -612,7 +612,7 @@ final Collector collector = new Collector(progress); collectables.add(getArchetypeSet()); collectables.add(animationObjects); - collectables.add(getFaceObjects()); + collectables.add(faceObjects); collector.setCollectables(collectables); collector.setDestDir(new File(getArchDefaultFolder())); collector.start(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-14 10:48:18
|
Revision: 3883 http://gridarta.svn.sourceforge.net/gridarta/?rev=3883&view=rev Author: akirschbaum Date: 2008-04-14 03:48:21 -0700 (Mon, 14 Apr 2008) Log Message: ----------- Do not use shift operators for artithmetic operations. Modified Paths: -------------- trunk/daimonin/src/daieditor/MultiPositionData.java trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/help/Help.java Modified: trunk/daimonin/src/daieditor/MultiPositionData.java =================================================================== --- trunk/daimonin/src/daieditor/MultiPositionData.java 2008-04-13 20:59:32 UTC (rev 3882) +++ trunk/daimonin/src/daieditor/MultiPositionData.java 2008-04-14 10:48:21 UTC (rev 3883) @@ -137,7 +137,7 @@ * @return x-offset */ public static int getXOffset(final int shapeID, final int positionID) { - return instance.data[shapeID][2 + (positionID << 1)]; + return instance.data[shapeID][2 + positionID * 2]; } /** @@ -150,7 +150,7 @@ * @return y-offset */ public static int getYOffset(final int shapeID, final int positionID) { - return instance.data[shapeID][1] - IGUIConstants.TILE_ISO_YLEN - instance.data[shapeID][3 + (positionID << 1)]; + return instance.data[shapeID][1] - IGUIConstants.TILE_ISO_YLEN - instance.data[shapeID][3 + positionID * 2]; } } // class MultiPositionData Modified: trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2008-04-13 20:59:32 UTC (rev 3882) +++ trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2008-04-14 10:48:21 UTC (rev 3883) @@ -323,7 +323,7 @@ int xstart = origin.x - (pos.y - rec.x + 1) * IGUIConstants.TILE_ISO_XLEN2; int ystart = origin.y + (pos.y + rec.x) * IGUIConstants.TILE_ISO_YLEN2; for (pos.x = rec.x; pos.x < endPos.x; pos.x++) { - if (grfx.hitClip(xstart, ystart - (IGUIConstants.TILE_ISO_YLEN << 2), IGUIConstants.TILE_ISO_XLEN, IGUIConstants.TILE_ISO_YLEN * 5)) { + if (grfx.hitClip(xstart, ystart - IGUIConstants.TILE_ISO_YLEN * 4, IGUIConstants.TILE_ISO_XLEN, IGUIConstants.TILE_ISO_YLEN * 5)) { paintSquare(grfx, xstart, ystart, mapModel.getMapSquare(pos)); } xstart += IGUIConstants.TILE_ISO_XLEN2; @@ -400,7 +400,7 @@ } else { int xoff = 0; if (img.getIconWidth() > IGUIConstants.TILE_ISO_XLEN) { - xoff = img.getIconWidth() - IGUIConstants.TILE_ISO_XLEN >> 1; + xoff = (img.getIconWidth() - IGUIConstants.TILE_ISO_XLEN) / 2; } img.paintIcon(this, grfx, xstart - xoff, ystart - yoff); if (drawDoubleFaces) { @@ -504,10 +504,10 @@ final int x0 = point.x - origin.x; final int y0 = point.y - origin.y; - final int yt = 2 * y0 - x0 >> 1; + final int yt = (2 * y0 - x0) / 2; final int xt = yt + x0; final int xm = xt / IGUIConstants.TILE_ISO_XLEN2; - final int ym = yt / (IGUIConstants.TILE_ISO_YLEN2 << 1); + final int ym = yt / IGUIConstants.TILE_ISO_YLEN2 / 2; if (xm < 0 || xm >= mapSize.getWidth() || ym < 0 || ym >= mapSize.getHeight()) { return null; } Modified: trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java 2008-04-13 20:59:32 UTC (rev 3882) +++ trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java 2008-04-14 10:48:21 UTC (rev 3883) @@ -125,7 +125,7 @@ int xstart = origin.x - (pos.y - rec.x + 1) * IGUIConstants.TILE_ISO_XLEN2; int ystart = origin.y + (pos.y + rec.x) * IGUIConstants.TILE_ISO_YLEN2; for (pos.x = rec.x; pos.x < endPos.x; pos.x++) { - if (grfx.hitClip(xstart, ystart - (IGUIConstants.TILE_ISO_YLEN << 2), IGUIConstants.TILE_ISO_XLEN, IGUIConstants.TILE_ISO_YLEN * 5)) { + if (grfx.hitClip(xstart, ystart - IGUIConstants.TILE_ISO_YLEN * 4, IGUIConstants.TILE_ISO_XLEN, IGUIConstants.TILE_ISO_YLEN * 5)) { final MapSquare<GameObject, MapArchObject, Archetype> square = mapModel.getMapSquare(pos); if (square.isEmpty()) { // empty square: Draw empty tile icon if not a pickmap @@ -179,7 +179,7 @@ } else { int xoff = 0; if (img.getIconWidth() > IGUIConstants.TILE_ISO_XLEN) { - xoff = img.getIconWidth() - IGUIConstants.TILE_ISO_XLEN >> 1; + xoff = (img.getIconWidth() - IGUIConstants.TILE_ISO_XLEN) / 2; } //img.paintIcon(this, grfx, xstart - xoff, ystart - yoff); grfx.drawImage(img.getImage(), xstart - xoff, ystart - yoff, img.getImageObserver()); Modified: trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java 2008-04-13 20:59:32 UTC (rev 3882) +++ trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java 2008-04-14 10:48:21 UTC (rev 3883) @@ -711,7 +711,7 @@ final List<?> listData = archTypeList.getListTable().get(attrib.getMisc()[j]); inputs[j] = buildArrayBox(attrib, listData); for (int k = 0; (double) k < listData.size() / 2.0; k++) { - if ((Integer) listData.get(k << 1) == activepart[j]) { + if ((Integer) listData.get(k * 2) == activepart[j]) { inputs[j].setSelectedIndex(k); // set active selection break; } Modified: trunk/src/app/net/sf/gridarta/help/Help.java =================================================================== --- trunk/src/app/net/sf/gridarta/help/Help.java 2008-04-13 20:59:32 UTC (rev 3882) +++ trunk/src/app/net/sf/gridarta/help/Help.java 2008-04-14 10:48:21 UTC (rev 3883) @@ -58,7 +58,7 @@ setResizable(true); final Rectangle mvb = parent.getBounds(); // get main view bounds - setBounds(mvb.x + (mvb.width >> 1) - 260, mvb.y + 70, 520, 600); // standard + setBounds(mvb.x + mvb.width / 2 - 260, mvb.y + 70, 520, 600); // standard if (fname == null) { // FIXME: Do not hard-code "start.html" fname = "start.html"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-16 09:10:42
|
Revision: 3885 http://gridarta.svn.sourceforge.net/gridarta/?rev=3885&view=rev Author: akirschbaum Date: 2008-04-16 02:10:28 -0700 (Wed, 16 Apr 2008) Log Message: ----------- Merge duplicated code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2008-04-16 08:24:59 UTC (rev 3884) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2008-04-16 09:10:28 UTC (rev 3885) @@ -361,12 +361,7 @@ gameObject.addObjectText("mina"); } - // Finally, we calculate the desired editType of the arch - if (gameObject.isTail()) { - gameObject.setEditType(gameObject.getHead().getEditType()); // copy from head - } else if (editType != 0) { - gameObject.setEditType(gameObject.calculateEditType(editType)); // calculate new - } + gameObject.updateEditType(editType); } } // class ArchetypeParser Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2008-04-16 08:24:59 UTC (rev 3884) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2008-04-16 09:10:28 UTC (rev 3885) @@ -590,8 +590,7 @@ } } - // recalculate the editType value - gameObject.calculateEditType(mapManager.getCurrentMap().getActiveEditType()); + gameObject.updateEditType(mapManager.getCurrentMap().getActiveEditType()); return true; // apply succeeded } Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2008-04-16 08:24:59 UTC (rev 3884) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2008-04-16 09:10:28 UTC (rev 3885) @@ -401,12 +401,7 @@ // validate the ScriptedEvents gameObject.validateAllEvents(); - // Finally, we calculate the desired editType of the arch - if (gameObject.isTail()) { - gameObject.setEditType(gameObject.getHead().getEditType()); // copy from head - } else if (editType != 0) { - gameObject.setEditType(gameObject.calculateEditType(editType)); // calculate new - } + gameObject.updateEditType(editType); } /** Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java 2008-04-16 08:24:59 UTC (rev 3884) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java 2008-04-16 09:10:28 UTC (rev 3885) @@ -523,8 +523,7 @@ } } - // recalculate the editType value - gameObject.calculateEditType(mapManager.getCurrentMap().getActiveEditType()); + gameObject.updateEditType(mapManager.getCurrentMap().getActiveEditType()); return true; // apply succeeded } Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-04-16 08:24:59 UTC (rev 3884) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-04-16 09:10:28 UTC (rev 3885) @@ -733,6 +733,18 @@ } /** + * Update the cached edit types. + * @param checkType the edit types to update + */ + public void updateEditType(final int checkType) { + if (isTail()) { + setEditType(getHead().calculateEditType(checkType)); + } else { + calculateEditType(checkType); + } + } + + /** * Get the EditType of an GameObject (e.g. floor, monster, etc). These are * determined by the various attributes of the GameObject (->objectText). * @param checkType bitmask containing the edit type(s) to be calculated @@ -741,7 +753,7 @@ * @see #setEditType(int) * @deprecated use arch object matchers, this method will be removed */ - @Deprecated public int calculateEditType(final int checkType) { + @Deprecated private int calculateEditType(final int checkType) { /* if one of the types in checkType already is in editType, // we exclude that one if ((checkType & editType) != 0) { Modified: trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java 2008-04-16 08:24:59 UTC (rev 3884) +++ trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java 2008-04-16 09:10:28 UTC (rev 3885) @@ -1504,7 +1504,7 @@ frame.update(frame.getGraphics()); // recalculate the editType value - gameObject.calculateEditType(mainControl.getMapManager().getCurrentMap().getActiveEditType()); + gameObject.updateEditType(mainControl.getMapManager().getCurrentMap().getActiveEditType()); } else { // change not wanted -> reset the choosebox ignoreEvent = true; // ignore events thrown by the forced reset Modified: trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java 2008-04-16 08:24:59 UTC (rev 3884) +++ trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java 2008-04-16 09:10:28 UTC (rev 3885) @@ -773,8 +773,7 @@ gameObject.setArchTypNr(gameObject.getAttributeInt("type", false)); // specified type } - // Recalculate the editType value. It shall stay 100% accurate ;) - gameObject.calculateEditType(mapManager.getCurrentMap().getActiveEditType()); + gameObject.updateEditType(mapManager.getCurrentMap().getActiveEditType()); mapSquare.getModel().endTransaction(); } Modified: trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java 2008-04-16 08:24:59 UTC (rev 3884) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java 2008-04-16 09:10:28 UTC (rev 3885) @@ -401,13 +401,7 @@ for (pos.x = 0; pos.x < mapSize.getWidth(); pos.x++) { for (pos.y = 0; pos.y < mapSize.getHeight(); pos.y++) { for (final G arch : getMapModel().getMapSquare(pos)) { - // calculate the new edit type - if (arch.isTail()) { - // multi tails get the value from their head - arch.setEditType(arch.getHead().calculateEditType(editType)); - } else { - arch.calculateEditType(editType); - } + arch.updateEditType(editType); } } } Modified: trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-04-16 08:24:59 UTC (rev 3884) +++ trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-04-16 09:10:28 UTC (rev 3885) @@ -713,11 +713,6 @@ /** {@inheritDoc} */ public void addGameObjectToMap(final G gameObject, final boolean insertBelow) { - // Make sure this arch has the proper edit_type - if (gameObject.getEditType() == GUIConstants.EDIT_TYPE_NONE) { - gameObject.calculateEditType(getMapControl().getActiveEditType()); - } - gameObject.setObjectFace(); final int mapx = gameObject.getMapX(); @@ -736,12 +731,7 @@ mapGrid[mapx][mapy].addLast(gameObject); } - // calculate edit type - if (gameObject.isTail()) { - gameObject.setEditType(gameObject.getHead().getEditType()); // copy from head - } else if (getMapControl().getActiveEditType() != 0) { - gameObject.setEditType(gameObject.calculateEditType(getMapControl().getActiveEditType())); // calculate new - } + gameObject.updateEditType(getMapControl().getActiveEditType()); } /** Iterator for iterating over all squares of a model. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-16 20:58:41
|
Revision: 3890 http://gridarta.svn.sourceforge.net/gridarta/?rev=3890&view=rev Author: akirschbaum Date: 2008-04-16 13:58:33 -0700 (Wed, 16 Apr 2008) Log Message: ----------- Move code to manage GameObjectMatchers into separate class. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/MapActions.java trunk/crossfire/src/cfeditor/filter/NamedFilterList.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/MapActions.java trunk/src/app/net/sf/gridarta/CFArchTypeList.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterView.java trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchers.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-16 20:39:00 UTC (rev 3889) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-16 20:58:33 UTC (rev 3890) @@ -57,6 +57,7 @@ import net.sf.gridarta.XmlHelper; import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.Collector; +import net.sf.gridarta.gameobject.match.GameObjectMatchers; import net.sf.gridarta.gui.About; import net.sf.gridarta.gui.HideFileFilterProxy; import net.sf.gridarta.gui.MainActions; @@ -212,6 +213,9 @@ /** The list of archtype-data (loaded from "types.xml"). */ private CFArchTypeList typeList = null; + /** The game object matchers. */ + private final GameObjectMatchers gameObjectMatchers; + /** The map validators. */ private final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators; @@ -276,10 +280,11 @@ 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()); new ArchetypeSetSpellLoader<GameObject, MapArchObject, Archetype>().load(archetypeSet, Archetype.TYPE_SPELL, gameObjectSpells); try { final String filename = IOUtils.getResourceURLAsString(getConfigurationDirectory(), "GameObjectMatchers.xml"); - typeList.readGameObjectMatchers(filename); + gameObjectMatchers.readGameObjectMatchers(filename); } catch (final FileNotFoundException ex) { log.error("Cannot read GameObjectMatchers.xml: " + ex.getMessage()); } Modified: trunk/crossfire/src/cfeditor/MapActions.java =================================================================== --- trunk/crossfire/src/cfeditor/MapActions.java 2008-04-16 20:39:00 UTC (rev 3889) +++ trunk/crossfire/src/cfeditor/MapActions.java 2008-04-16 20:58:33 UTC (rev 3890) @@ -31,11 +31,11 @@ import java.io.IOException; import java.util.prefs.Preferences; import javax.swing.Action; -import net.sf.gridarta.CFArchTypeList; import net.sf.gridarta.CommonConstants; import net.sf.gridarta.CurrentMapListener; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; +import net.sf.gridarta.gameobject.match.GameObjectMatchers; import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapView; import net.sf.japi.swing.ActionFactory; @@ -443,12 +443,12 @@ } final GameObject selectedExit = mainControl.getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject(); - if (selectedExit != null && CFArchTypeList.isExitType(selectedExit.getHead()) && selectedExit.getHead().getAttributeString("slaying").length() > 0) { + if (selectedExit != null && GameObjectMatchers.isExitType(selectedExit.getHead()) && selectedExit.getHead().getAttributeString("slaying").length() > 0) { return selectedExit.getHead(); } final GameObject cursorExit = mapView.getMapControl().getMapModel().getExit(mapView.getView().getMapCursor().getLocation()); - if (cursorExit != null && CFArchTypeList.isExitType(cursorExit.getHead()) && cursorExit.getHead().getAttributeString("slaying").length() > 0) { + if (cursorExit != null && GameObjectMatchers.isExitType(cursorExit.getHead()) && cursorExit.getHead().getAttributeString("slaying").length() > 0) { return cursorExit.getHead(); } Modified: trunk/crossfire/src/cfeditor/filter/NamedFilterList.java =================================================================== --- trunk/crossfire/src/cfeditor/filter/NamedFilterList.java 2008-04-16 20:39:00 UTC (rev 3889) +++ trunk/crossfire/src/cfeditor/filter/NamedFilterList.java 2008-04-16 20:58:33 UTC (rev 3890) @@ -27,8 +27,8 @@ import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.event.EventListenerList; -import net.sf.gridarta.CFArchTypeList; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gameobject.match.GameObjectMatchers; import net.sf.gridarta.gameobject.match.NamedGameObjectMatcher; import org.apache.log4j.Logger; import org.jdom.Element; @@ -57,7 +57,7 @@ /** Create a new NameFilterList. */ public NamedFilterList() { subFilters = new LinkedHashMap<String, Filter>(); - for (final NamedGameObjectMatcher matcher : CFArchTypeList.getFilters()) { // FIXME: use localized name; FIXME: sort by name + for (final NamedGameObjectMatcher matcher : GameObjectMatchers.getFilters()) { // FIXME: use localized name; FIXME: sort by name subFilters.put(matcher.getName(), new NamedGameObjectMatcherFilter(matcher)); } } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-04-16 20:39:00 UTC (rev 3889) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-04-16 20:58:33 UTC (rev 3890) @@ -62,6 +62,7 @@ import net.sf.gridarta.XmlHelper; import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.Collector; +import net.sf.gridarta.gameobject.match.GameObjectMatchers; import net.sf.gridarta.gameobject.match.MutableOrGameObjectMatcher; import net.sf.gridarta.gameobject.match.ViewGameObjectMatcherManager; import net.sf.gridarta.gui.About; @@ -249,6 +250,9 @@ /** 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; @@ -332,10 +336,11 @@ 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()); new XMLSpellLoader().load(getConfigurationDirectory(), CommonConstants.SPELL_FILE, xmlHelper.getDocumentBuilder(), numberSpells); try { final String filename = IOUtils.getResourceURLAsString(getConfigurationDirectory(), "GameObjectMatchers.xml"); - typeList.readGameObjectMatchers(filename); + gameObjectMatchers.readGameObjectMatchers(filename); } catch (final FileNotFoundException ex) { log.error("Cannot read GameObjectMatchers.xml: " + ex.getMessage()); } Modified: trunk/daimonin/src/daieditor/MapActions.java =================================================================== --- trunk/daimonin/src/daieditor/MapActions.java 2008-04-16 20:39:00 UTC (rev 3889) +++ trunk/daimonin/src/daieditor/MapActions.java 2008-04-16 20:58:33 UTC (rev 3890) @@ -30,11 +30,11 @@ import java.util.prefs.Preferences; import javax.swing.Action; import javax.swing.JOptionPane; -import net.sf.gridarta.CFArchTypeList; import net.sf.gridarta.CommonConstants; import net.sf.gridarta.CurrentMapListener; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; +import net.sf.gridarta.gameobject.match.GameObjectMatchers; import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapView; import net.sf.japi.swing.ActionFactory; @@ -421,12 +421,12 @@ } final GameObject selectedExit = mainControl.getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject(); - if (selectedExit != null && CFArchTypeList.isExitType(selectedExit.getHead()) && selectedExit.getHead().getAttributeString("slaying").length() > 0) { + if (selectedExit != null && GameObjectMatchers.isExitType(selectedExit.getHead()) && selectedExit.getHead().getAttributeString("slaying").length() > 0) { return selectedExit.getHead(); } final GameObject cursorExit = mapView.getMapControl().getMapModel().getExit(mapView.getView().getMapCursor().getLocation()); - if (cursorExit != null && CFArchTypeList.isExitType(cursorExit.getHead()) && cursorExit.getHead().getAttributeString("slaying").length() > 0) { + if (cursorExit != null && GameObjectMatchers.isExitType(cursorExit.getHead()) && cursorExit.getHead().getAttributeString("slaying").length() > 0) { return cursorExit.getHead(); } Modified: trunk/src/app/net/sf/gridarta/CFArchTypeList.java =================================================================== --- trunk/src/app/net/sf/gridarta/CFArchTypeList.java 2008-04-16 20:39:00 UTC (rev 3889) +++ trunk/src/app/net/sf/gridarta/CFArchTypeList.java 2008-04-16 20:58:33 UTC (rev 3890) @@ -21,8 +21,6 @@ import java.io.IOException; import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -89,15 +87,6 @@ private final Map<String, CFArchType> archTypeNames = new HashMap<String, CFArchType>(); /** - * 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>(); - - /** List with arch object matchers. */ - private final List<NamedGameObjectMatcher> gameObjectMatchers = new ArrayList<NamedGameObjectMatcher>(); - - /** * Constructor - Parsing all the data from the xml definitions file * 'types.xml'. * @param documentBuilder DocumentBuilder to use for parsing XML. @@ -114,102 +103,6 @@ bitmaskTable = new HashMap<String, CAttribBitmask>(); } - /** - * Check whether the GameObject has a given type. - * @param arch GameObject to check - * @param id the type to check for - * @return <code>true</code> if <var>arch</var> is of the given type, - * otherwise <code>false</code> - */ - private static boolean isType(final GameObject arch, final String id) { - if (arch == null) { - return false; - } - - final NamedGameObjectMatcher matcher = gameObjectMatchersByIds.get(id); - return matcher != null && matcher.isMatching(arch); - } - - /** - * Check whether the GameObject is background. - * @param arch GameObject to check - * @return <code>true</code> if <var>arch</var> is background, otherwise - * <code>false</code> - */ - public static boolean isBackgroundType(final GameObject arch) { - return isType(arch, "background"); - } - - /** - * Check whether the GameObject is a monster. - * @param arch GameObject to check - * @return <code>true</code> if <var>arch</var> is a monster, otherwise - * <code>false</code> - */ - public static boolean isMonsterType(final GameObject arch) { - return isType(arch, "monster"); - } - - /** - * Check whether the GameObject is a wall. - * @param arch GameObject to check - * @return <code>true</code> if <var>arch</var> is a wall, otherwise - * <code>false</code> - */ - public static boolean isWallType(final GameObject arch) { - return isType(arch, "wall"); - } - - /** - * Check whether the GameObject is connected. - * @param arch GameObject to check - * @return <code>true</code> if <var>arch</var> is connected, otherwise - * <code>false</code> - */ - public static boolean isConnectedType(final GameObject arch) { - return isType(arch, "connected"); - } - - /** - * Check whether the GameObject is an exit. - * @param arch GameObject to check - * @return <code>true</code> if <var>arch</var> is an exit, otherwise - * <code>false</code> - */ - public static boolean isExitType(final GameObject arch) { - return isType(arch, "exit"); - } - - /** - * Check whether the GameObject is a treasure. - * @param arch GameObject to check - * @return <code>true</code> if <var>arch</var> is a treasure, otherwise - * <code>false</code> - */ - public static boolean isTreasureType(final GameObject arch) { - return isType(arch, "treasure"); - } - - /** - * Check whether the GameObject is a door/gate/key. - * @param arch GameObject to check - * @return <code>true</code> if <var>arch</var> is a door/gate/key, - * otherwise <code>false</code> - */ - public static boolean isDoorType(final GameObject arch) { - return isType(arch, "door"); - } - - /** - * Check whether the GameObject is equipment. - * @param arch GameObject to check - * @return <code>true</code> if <var>arch</var> is equipment, - * otherwise <code>false</code> - */ - public static boolean isEquipmentType(final GameObject arch) { - return isType(arch, "equipment"); - } - public void loadTypesFromXML(@NotNull final String filename) { final Map<String, List<String>> ignoreListTable = new HashMap<String, List<String>>(); try { @@ -461,17 +354,4 @@ return defaultType; } - public void readGameObjectMatchers(@NotNull final String filename) { - new GameObjectMatchersParser(documentBuilder, xpath).readGameObjectMatchers(filename, gameObjectMatchers, gameObjectMatchersByIds); - } - - /** - * Return all known game object matchers that should be used as filters. - * - * @return the filter game object matches - */ - public static Collection<NamedGameObjectMatcher> getFilters() { - return Collections.unmodifiableCollection(gameObjectMatchersByIds.values()); - } - } // class CFArchTypeList Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-04-16 20:39:00 UTC (rev 3889) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-04-16 20:58:33 UTC (rev 3890) @@ -25,6 +25,7 @@ import javax.swing.JList; import net.sf.gridarta.CFArchType; import net.sf.gridarta.CFArchTypeList; +import net.sf.gridarta.gameobject.match.GameObjectMatchers; import net.sf.gridarta.gui.GameObjectAttributesPanel; import net.sf.gridarta.gui.GUIConstants; import net.sf.gridarta.map.MapArchObject; @@ -773,28 +774,28 @@ editType &= ~checkType; } - if ((checkType & GUIConstants.EDIT_TYPE_BACKGROUND) != 0 && CFArchTypeList.isBackgroundType(this)) { + if ((checkType & GUIConstants.EDIT_TYPE_BACKGROUND) != 0 && GameObjectMatchers.isBackgroundType(this)) { editType |= GUIConstants.EDIT_TYPE_BACKGROUND; } - if ((checkType & GUIConstants.EDIT_TYPE_MONSTER) != 0 && CFArchTypeList.isMonsterType(this)) { + if ((checkType & GUIConstants.EDIT_TYPE_MONSTER) != 0 && GameObjectMatchers.isMonsterType(this)) { editType |= GUIConstants.EDIT_TYPE_MONSTER; } - if ((checkType & GUIConstants.EDIT_TYPE_WALL) != 0 && CFArchTypeList.isWallType(this)) { + if ((checkType & GUIConstants.EDIT_TYPE_WALL) != 0 && GameObjectMatchers.isWallType(this)) { editType |= GUIConstants.EDIT_TYPE_WALL; } - if ((checkType & GUIConstants.EDIT_TYPE_CONNECTED) != 0 && CFArchTypeList.isConnectedType(this)) { + if ((checkType & GUIConstants.EDIT_TYPE_CONNECTED) != 0 && GameObjectMatchers.isConnectedType(this)) { editType |= GUIConstants.EDIT_TYPE_CONNECTED; } - if ((checkType & GUIConstants.EDIT_TYPE_EXIT) != 0 && CFArchTypeList.isExitType(this)) { + if ((checkType & GUIConstants.EDIT_TYPE_EXIT) != 0 && GameObjectMatchers.isExitType(this)) { editType |= GUIConstants.EDIT_TYPE_EXIT; } - if ((checkType & GUIConstants.EDIT_TYPE_TREASURE) != 0 && CFArchTypeList.isTreasureType(this)) { + if ((checkType & GUIConstants.EDIT_TYPE_TREASURE) != 0 && GameObjectMatchers.isTreasureType(this)) { editType |= GUIConstants.EDIT_TYPE_TREASURE; } - if ((checkType & GUIConstants.EDIT_TYPE_DOOR) != 0 && CFArchTypeList.isDoorType(this)) { + if ((checkType & GUIConstants.EDIT_TYPE_DOOR) != 0 && GameObjectMatchers.isDoorType(this)) { editType |= GUIConstants.EDIT_TYPE_DOOR; } - if ((checkType & GUIConstants.EDIT_TYPE_EQUIP) != 0 && CFArchTypeList.isEquipmentType(this)) { + if ((checkType & GUIConstants.EDIT_TYPE_EQUIP) != 0 && GameObjectMatchers.isEquipmentType(this)) { editType |= GUIConstants.EDIT_TYPE_EQUIP; } Added: trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchers.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchers.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchers.java 2008-04-16 20:58:33 UTC (rev 3890) @@ -0,0 +1,178 @@ +/* + * 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; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.xpath.XPath; +import net.sf.gridarta.gameobject.GameObject; +import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; + +/** + * Maintains {@link GameObjectMatcher} instances. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @author Andreas Kirschbaum + */ +public class GameObjectMatchers { + + /** The Logger for printing log messages. */ + private static final Logger log = Logger.getLogger(GameObjectMatchers.class); + + /** DocumentBuilder. */ + private final DocumentBuilder documentBuilder; + + /** The XPath for using XPath. */ + private final XPath xpath; + + /** + * 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>(); + + /** List with arch object matchers. */ + private final List<NamedGameObjectMatcher> gameObjectMatchers = new ArrayList<NamedGameObjectMatcher>(); + + /** + * Creates a new instance. + * @param documentBuilder the <code>DocumentBuilder</code> to use for parsing XML + * @param xpath XPath to use for applying for XPath expressions. + */ + public GameObjectMatchers(@NotNull final DocumentBuilder documentBuilder, @NotNull final XPath xpath) { + this.documentBuilder = documentBuilder; + this.xpath = xpath; + } + + /** + * Check whether the GameObject has a given type. + * @param arch GameObject to check + * @param id the type to check for + * @return <code>true</code> if <var>arch</var> is of the given type, + * otherwise <code>false</code> + */ + private static boolean isType(final GameObject arch, final String id) { + if (arch == null) { + return false; + } + + final NamedGameObjectMatcher matcher = gameObjectMatchersByIds.get(id); + return matcher != null && matcher.isMatching(arch); + } + + /** + * Check whether the GameObject is background. + * @param arch GameObject to check + * @return <code>true</code> if <var>arch</var> is background, otherwise + * <code>false</code> + */ + public static boolean isBackgroundType(final GameObject arch) { + return isType(arch, "background"); + } + + /** + * Check whether the GameObject is a monster. + * @param arch GameObject to check + * @return <code>true</code> if <var>arch</var> is a monster, otherwise + * <code>false</code> + */ + public static boolean isMonsterType(final GameObject arch) { + return isType(arch, "monster"); + } + + /** + * Check whether the GameObject is a wall. + * @param arch GameObject to check + * @return <code>true</code> if <var>arch</var> is a wall, otherwise + * <code>false</code> + */ + public static boolean isWallType(final GameObject arch) { + return isType(arch, "wall"); + } + + /** + * Check whether the GameObject is connected. + * @param arch GameObject to check + * @return <code>true</code> if <var>arch</var> is connected, otherwise + * <code>false</code> + */ + public static boolean isConnectedType(final GameObject arch) { + return isType(arch, "connected"); + } + + /** + * Check whether the GameObject is an exit. + * @param arch GameObject to check + * @return <code>true</code> if <var>arch</var> is an exit, otherwise + * <code>false</code> + */ + public static boolean isExitType(final GameObject arch) { + return isType(arch, "exit"); + } + + /** + * Check whether the GameObject is a treasure. + * @param arch GameObject to check + * @return <code>true</code> if <var>arch</var> is a treasure, otherwise + * <code>false</code> + */ + public static boolean isTreasureType(final GameObject arch) { + return isType(arch, "treasure"); + } + + /** + * Check whether the GameObject is a door/gate/key. + * @param arch GameObject to check + * @return <code>true</code> if <var>arch</var> is a door/gate/key, + * otherwise <code>false</code> + */ + public static boolean isDoorType(final GameObject arch) { + return isType(arch, "door"); + } + + /** + * Check whether the GameObject is equipment. + * @param arch GameObject to check + * @return <code>true</code> if <var>arch</var> is equipment, + * otherwise <code>false</code> + */ + public static boolean isEquipmentType(final GameObject arch) { + return isType(arch, "equipment"); + } + + public void readGameObjectMatchers(@NotNull final String filename) { + new GameObjectMatchersParser(documentBuilder, xpath).readGameObjectMatchers(filename, gameObjectMatchers, gameObjectMatchersByIds); + } + + /** + * Return all known game object matchers that should be used as filters. + * + * @return the filter game object matches + */ + public static Collection<NamedGameObjectMatcher> getFilters() { + return Collections.unmodifiableCollection(gameObjectMatchersByIds.values()); + } + +} // class GameObjectMatchers Property changes on: trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchers.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterView.java 2008-04-16 20:39:00 UTC (rev 3889) +++ trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterView.java 2008-04-16 20:58:33 UTC (rev 3890) @@ -19,10 +19,10 @@ package net.sf.gridarta.gui.connectionview; -import net.sf.gridarta.CFArchTypeList; import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gameobject.match.GameObjectMatchers; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; @@ -62,7 +62,7 @@ * @param gameObject The game object to process. */ private void scanGameObject(@NotNull final G gameObject) { - if (gameObject.isHead() && CFArchTypeList.isMonsterType(gameObject)) { + if (gameObject.isHead() && GameObjectMatchers.isMonsterType(gameObject)) { addConnection(gameObject.getBestName(), gameObject); } } Modified: trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-04-16 20:39:00 UTC (rev 3889) +++ trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-04-16 20:58:33 UTC (rev 3890) @@ -26,11 +26,11 @@ import java.util.NoSuchElementException; import java.util.Set; import javax.swing.event.EventListenerList; -import net.sf.gridarta.CFArchTypeList; import net.sf.gridarta.MainControl; import net.sf.gridarta.Size2D; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gameobject.match.GameObjectMatchers; import net.sf.gridarta.gui.GUIConstants; import net.sf.gridarta.map.validation.DefaultErrorCollector; import net.sf.gridarta.map.validation.ErrorCollector; @@ -529,7 +529,7 @@ return null; // out of map } for (final G arch : mapGrid[hspot.x][hspot.y]) { - if (CFArchTypeList.isExitType(arch) && arch.getAttributeString("slaying").length() > 0) { + if (GameObjectMatchers.isExitType(arch) && arch.getAttributeString("slaying").length() > 0) { return arch; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-16 21:03:41
|
Revision: 3891 http://gridarta.svn.sourceforge.net/gridarta/?rev=3891&view=rev Author: akirschbaum Date: 2008-04-16 14:03:41 -0700 (Wed, 16 Apr 2008) Log Message: ----------- Remove unused import statements. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainView.java trunk/daimonin/src/daieditor/CMainView.java trunk/src/app/net/sf/gridarta/CFArchTypeList.java trunk/src/app/net/sf/gridarta/gui/map/MapCursorControl.java trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-04-16 20:58:33 UTC (rev 3890) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-04-16 21:03:41 UTC (rev 3891) @@ -29,7 +29,6 @@ import java.awt.Rectangle; import java.awt.Toolkit; import java.beans.PropertyVetoException; -import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.List; Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-04-16 20:58:33 UTC (rev 3890) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-04-16 21:03:41 UTC (rev 3891) @@ -29,7 +29,6 @@ import java.awt.Rectangle; import java.awt.Toolkit; import java.beans.PropertyVetoException; -import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.List; Modified: trunk/src/app/net/sf/gridarta/CFArchTypeList.java =================================================================== --- trunk/src/app/net/sf/gridarta/CFArchTypeList.java 2008-04-16 20:58:33 UTC (rev 3890) +++ trunk/src/app/net/sf/gridarta/CFArchTypeList.java 2008-04-16 21:03:41 UTC (rev 3891) @@ -30,8 +30,6 @@ import javax.xml.xpath.XPathExpressionException; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gameobject.match.GameObjectMatchersParser; -import net.sf.gridarta.gameobject.match.NamedGameObjectMatcher; import net.sf.japi.xml.NodeListIterator; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; Modified: trunk/src/app/net/sf/gridarta/gui/map/MapCursorControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapCursorControl.java 2008-04-16 20:58:33 UTC (rev 3890) +++ trunk/src/app/net/sf/gridarta/gui/map/MapCursorControl.java 2008-04-16 21:03:41 UTC (rev 3891) @@ -24,7 +24,6 @@ import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.map.MapArchObject; Modified: trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-04-16 20:58:33 UTC (rev 3890) +++ trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-04-16 21:03:41 UTC (rev 3891) @@ -31,7 +31,6 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gameobject.match.GameObjectMatchers; -import net.sf.gridarta.gui.GUIConstants; import net.sf.gridarta.map.validation.DefaultErrorCollector; import net.sf.gridarta.map.validation.ErrorCollector; import net.sf.japi.swing.ActionFactory; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-16 21:13:25
|
Revision: 3892 http://gridarta.svn.sourceforge.net/gridarta/?rev=3892&view=rev Author: akirschbaum Date: 2008-04-16 14:12:56 -0700 (Wed, 16 Apr 2008) Log Message: ----------- Convert static method into instance method. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/filter/NamedFilterList.java trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchers.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-16 21:03:41 UTC (rev 3891) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-16 21:12:56 UTC (rev 3892) @@ -331,7 +331,7 @@ // browse arch archive // load object from a arch file you found - defaultNamedFilterList = new NamedFilterList(); + defaultNamedFilterList = new NamedFilterList(gameObjectMatchers.getFilters()); filterControl = new CFilterControl(null, this, defaultNamedFilterList); final JMenu menuAnalyze = (JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "analyze"); if (menuAnalyze != null) { Modified: trunk/crossfire/src/cfeditor/filter/NamedFilterList.java =================================================================== --- trunk/crossfire/src/cfeditor/filter/NamedFilterList.java 2008-04-16 21:03:41 UTC (rev 3891) +++ trunk/crossfire/src/cfeditor/filter/NamedFilterList.java 2008-04-16 21:12:56 UTC (rev 3892) @@ -20,6 +20,7 @@ package cfeditor.filter; import java.util.ArrayList; +import java.util.Collection; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -28,10 +29,10 @@ import javax.swing.JMenuItem; import javax.swing.event.EventListenerList; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gameobject.match.GameObjectMatchers; import net.sf.gridarta.gameobject.match.NamedGameObjectMatcher; import org.apache.log4j.Logger; import org.jdom.Element; +import org.jetbrains.annotations.NotNull; /** * Filter that aggregates named filters. @@ -54,10 +55,13 @@ private final EventListenerList listenerList = new EventListenerList(); - /** Create a new NameFilterList. */ - public NamedFilterList() { + /** + * Create a new NameFilterList. + * @param matchers the matchers to use + */ + public NamedFilterList(@NotNull final Collection<NamedGameObjectMatcher> matchers) { subFilters = new LinkedHashMap<String, Filter>(); - for (final NamedGameObjectMatcher matcher : GameObjectMatchers.getFilters()) { // FIXME: use localized name; FIXME: sort by name + for (final NamedGameObjectMatcher matcher : matchers) { // FIXME: use localized name; FIXME: sort by name subFilters.put(matcher.getName(), new NamedGameObjectMatcherFilter(matcher)); } } Modified: trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchers.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchers.java 2008-04-16 21:03:41 UTC (rev 3891) +++ trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchers.java 2008-04-16 21:12:56 UTC (rev 3892) @@ -171,7 +171,7 @@ * * @return the filter game object matches */ - public static Collection<NamedGameObjectMatcher> getFilters() { + public Collection<NamedGameObjectMatcher> getFilters() { return Collections.unmodifiableCollection(gameObjectMatchersByIds.values()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-16 21:22:17
|
Revision: 3893 http://gridarta.svn.sourceforge.net/gridarta/?rev=3893&view=rev Author: akirschbaum Date: 2008-04-16 14:22:16 -0700 (Wed, 16 Apr 2008) Log Message: ----------- Preparations for converting static method into instance method. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/MapActions.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/MapActions.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-16 21:12:56 UTC (rev 3892) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-16 21:22:16 UTC (rev 3893) @@ -256,7 +256,6 @@ mapCursorControl = new MapCursorControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>("cfeditor", this, getMapManager()); ACTION_FACTORY.createActions(true, this, "createNew", "open", "options", "exit", "gc", "onlineHelp", "tod", "about"); mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager()); - mapActions = new MapActions(this, getMapManager()); readGlobalSettings(); objectChooser = new ObjectChooser(newMapDialogFactory, this, new File(mapDir, IGUIConstants.PICKMAP_DIR)); mainView = new CMainView(this, objectChooser, getMapManager(), ACTION_FACTORY, mapManagerActions.getCloseAllAction()); @@ -288,6 +287,7 @@ } catch (final FileNotFoundException ex) { log.error("Cannot read GameObjectMatchers.xml: " + ex.getMessage()); } + mapActions = new MapActions(this, getMapManager(), gameObjectMatchers); typeList.getListTable().put("event", getEventTypes()); try { final String filename = IOUtils.getResourceURLAsString(getConfigurationDirectory(), CommonConstants.TYPEDEF_FILE); Modified: trunk/crossfire/src/cfeditor/MapActions.java =================================================================== --- trunk/crossfire/src/cfeditor/MapActions.java 2008-04-16 21:12:56 UTC (rev 3892) +++ trunk/crossfire/src/cfeditor/MapActions.java 2008-04-16 21:22:16 UTC (rev 3893) @@ -106,6 +106,9 @@ /** The map manager. */ private final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager; + /** The game object matchers. */ + private final GameObjectMatchers gameObjectMatchers; + /** * The current map listener used to detect current map/map view changes. */ @@ -117,10 +120,13 @@ * @param mainControl the main control to use * * @param mapManager the map manager + * + * @param GameObjectMatchers the game object matchers */ - public MapActions(final CMainControl mainControl, final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager) { + public MapActions(final CMainControl mainControl, final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager, final GameObjectMatchers gameObjectMatchers) { this.mainControl = mainControl; this.mapManager = mapManager; + this.gameObjectMatchers = gameObjectMatchers; autoJoin = prefs.getBoolean(AUTOJOIN_KEY, false); @@ -443,12 +449,12 @@ } final GameObject selectedExit = mainControl.getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject(); - if (selectedExit != null && GameObjectMatchers.isExitType(selectedExit.getHead()) && selectedExit.getHead().getAttributeString("slaying").length() > 0) { + if (selectedExit != null && gameObjectMatchers.isExitType(selectedExit.getHead()) && selectedExit.getHead().getAttributeString("slaying").length() > 0) { return selectedExit.getHead(); } final GameObject cursorExit = mapView.getMapControl().getMapModel().getExit(mapView.getView().getMapCursor().getLocation()); - if (cursorExit != null && GameObjectMatchers.isExitType(cursorExit.getHead()) && cursorExit.getHead().getAttributeString("slaying").length() > 0) { + if (cursorExit != null && gameObjectMatchers.isExitType(cursorExit.getHead()) && cursorExit.getHead().getAttributeString("slaying").length() > 0) { return cursorExit.getHead(); } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-04-16 21:12:56 UTC (rev 3892) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-04-16 21:22:16 UTC (rev 3893) @@ -309,7 +309,6 @@ ACTION_FACTORY.createToggles(true, this, "drawDouble"); aCollectSpells = ACTION_FACTORY.createAction(true, "collectSpells", this); mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager()); - mapActions = new MapActions(this, getMapManager()); readGlobalSettings(); objectChooser = new ObjectChooser(newMapDialogFactory, this, new File(strArchDir, IGUIConstants.PICKMAP_DIR)); mainView = new CMainView(this, objectChooser, getMapManager(), ACTION_FACTORY, mapManagerActions.getCloseAllAction()); @@ -344,6 +343,7 @@ } catch (final FileNotFoundException ex) { log.error("Cannot read GameObjectMatchers.xml: " + ex.getMessage()); } + mapActions = new MapActions(this, getMapManager(), gameObjectMatchers); try { final String filename = IOUtils.getResourceURLAsString(getConfigurationDirectory(), CommonConstants.TYPEDEF_FILE); typeList.loadTypesFromXML(filename); Modified: trunk/daimonin/src/daieditor/MapActions.java =================================================================== --- trunk/daimonin/src/daieditor/MapActions.java 2008-04-16 21:12:56 UTC (rev 3892) +++ trunk/daimonin/src/daieditor/MapActions.java 2008-04-16 21:22:16 UTC (rev 3893) @@ -102,6 +102,9 @@ /** The map manager. */ private final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager; + /** The game object matchers. */ + private final GameObjectMatchers gameObjectMatchers; + /** * The current map listener used to detect current map/map view changes. */ @@ -113,10 +116,13 @@ * @param mainControl the main control to use * * @param mapManager the map manager + * + * @param GameObjectMatchers the game object matchers */ - public MapActions(final CMainControl mainControl, final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager) { + public MapActions(final CMainControl mainControl, final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager, final GameObjectMatchers gameObjectMatchers) { this.mainControl = mainControl; this.mapManager = mapManager; + this.gameObjectMatchers = gameObjectMatchers; autoJoin = prefs.getBoolean(AUTOJOIN_KEY, false); @@ -421,12 +427,12 @@ } final GameObject selectedExit = mainControl.getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject(); - if (selectedExit != null && GameObjectMatchers.isExitType(selectedExit.getHead()) && selectedExit.getHead().getAttributeString("slaying").length() > 0) { + if (selectedExit != null && gameObjectMatchers.isExitType(selectedExit.getHead()) && selectedExit.getHead().getAttributeString("slaying").length() > 0) { return selectedExit.getHead(); } final GameObject cursorExit = mapView.getMapControl().getMapModel().getExit(mapView.getView().getMapCursor().getLocation()); - if (cursorExit != null && GameObjectMatchers.isExitType(cursorExit.getHead()) && cursorExit.getHead().getAttributeString("slaying").length() > 0) { + if (cursorExit != null && gameObjectMatchers.isExitType(cursorExit.getHead()) && cursorExit.getHead().getAttributeString("slaying").length() > 0) { return cursorExit.getHead(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-17 18:15:39
|
Revision: 3898 http://gridarta.svn.sourceforge.net/gridarta/?rev=3898&view=rev Author: akirschbaum Date: 2008-04-17 11:15:19 -0700 (Thu, 17 Apr 2008) Log Message: ----------- Remove call to GameObjectMatchers.isExitType(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java trunk/crossfire/src/cfeditor/map/MapControl.java trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java trunk/daimonin/src/daieditor/map/MapControl.java trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchers.java trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java Modified: trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-04-17 17:58:10 UTC (rev 3897) +++ trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-04-17 18:15:19 UTC (rev 3898) @@ -33,6 +33,7 @@ import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.GridartaObjectsFactory; import net.sf.gridarta.MainControl; +import net.sf.gridarta.gameobject.match.GameObjectMatchers; import net.sf.gridarta.io.DefaultMapReader; import net.sf.gridarta.io.MapReader; import org.jetbrains.annotations.NotNull; @@ -84,12 +85,12 @@ /** {@inheritDoc} */ @NotNull public MapControl newMapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject) { - return new MapControl(CMainControl.getInstance(), objects, mapArchObject, false); + return new MapControl(CMainControl.getInstance(), objects, mapArchObject, false, GameObjectMatchers.getMatcher("exit")); } /** {@inheritDoc} */ @NotNull public MapControl newPickmapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject) { - return new MapControl(CMainControl.getInstance(), objects, mapArchObject, true); + return new MapControl(CMainControl.getInstance(), objects, mapArchObject, true, GameObjectMatchers.getMatcher("exit")); } } // class CrossfireObjectsFactory Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2008-04-17 17:58:10 UTC (rev 3897) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2008-04-17 18:15:19 UTC (rev 3898) @@ -27,6 +27,7 @@ import java.awt.Point; import java.lang.ref.SoftReference; import java.util.List; +import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.map.AbstractMapControl; @@ -71,12 +72,13 @@ * @param mapArchObject the <code>MapArchObject</code> of the map * @param objects list of Objects (ArchObjects) which should be filled in map or <code>null</code> for empty * @param isPickmap true if this is a pickmap + * @param exitTypeGameObjectMatcher the matcher for selecting exit objects */ - public MapControl(final CMainControl mainControl, final List<GameObject> objects, final MapArchObject mapArchObject, final boolean isPickmap) { + public MapControl(final CMainControl mainControl, final List<GameObject> objects, final MapArchObject mapArchObject, final boolean isPickmap, @Nullable final GameObjectMatcher exitTypeGameObjectMatcher) { super(mainControl, isPickmap); this.mainControl = mainControl; // we create model (= data) - mapModel = new DefaultMapModel<GameObject, MapArchObject, Archetype>(mainControl, this, objects, mapArchObject); + mapModel = new DefaultMapModel<GameObject, MapArchObject, Archetype>(mainControl, this, objects, mapArchObject, exitTypeGameObjectMatcher); init(); } Modified: trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java =================================================================== --- trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java 2008-04-17 17:58:10 UTC (rev 3897) +++ trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java 2008-04-17 18:15:19 UTC (rev 3898) @@ -33,6 +33,7 @@ import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.GridartaObjectsFactory; import net.sf.gridarta.MainControl; +import net.sf.gridarta.gameobject.match.GameObjectMatchers; import net.sf.gridarta.io.DefaultMapReader; import net.sf.gridarta.io.MapReader; import org.jetbrains.annotations.NotNull; @@ -84,12 +85,12 @@ /** {@inheritDoc} */ @NotNull public MapControl newMapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject) { - return new MapControl(CMainControl.getInstance(), objects, mapArchObject, false); + return new MapControl(CMainControl.getInstance(), objects, mapArchObject, false, GameObjectMatchers.getMatcher("exit")); } /** {@inheritDoc} */ @NotNull public MapControl newPickmapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject) { - return new MapControl(CMainControl.getInstance(), objects, mapArchObject, true); + return new MapControl(CMainControl.getInstance(), objects, mapArchObject, true, GameObjectMatchers.getMatcher("exit")); } } // class DaimoninObjectsFactory Modified: trunk/daimonin/src/daieditor/map/MapControl.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapControl.java 2008-04-17 17:58:10 UTC (rev 3897) +++ trunk/daimonin/src/daieditor/map/MapControl.java 2008-04-17 18:15:19 UTC (rev 3898) @@ -27,6 +27,7 @@ import java.awt.Point; import java.lang.ref.SoftReference; import java.util.List; +import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.map.AbstractMapControl; @@ -71,12 +72,13 @@ * @param mapArchObject the <code>MapArchObject</code> of the map * @param objects list of Objects (ArchObjects) which should be filled in map or <code>null</code> for empty * @param isPickmap true if this is a pickmap + * @param exitTypeGameObjectMatcher the matcher for selecting exit objects */ - public MapControl(final CMainControl mainControl, final List<GameObject> objects, final MapArchObject mapArchObject, final boolean isPickmap) { + public MapControl(final CMainControl mainControl, final List<GameObject> objects, final MapArchObject mapArchObject, final boolean isPickmap, @Nullable final GameObjectMatcher exitTypeGameObjectMatcher) { super(mainControl, isPickmap); this.mainControl = mainControl; // we create model (= data) - mapModel = new DefaultMapModel<GameObject, MapArchObject, Archetype>(mainControl, this, objects, mapArchObject); + mapModel = new DefaultMapModel<GameObject, MapArchObject, Archetype>(mainControl, this, objects, mapArchObject, exitTypeGameObjectMatcher); init(); } Modified: trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchers.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchers.java 2008-04-17 17:58:10 UTC (rev 3897) +++ trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchers.java 2008-04-17 18:15:19 UTC (rev 3898) @@ -31,6 +31,7 @@ import net.sf.gridarta.gui.GUIConstants; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Maintains {@link GameObjectMatcher} instances. @@ -168,6 +169,15 @@ } /** + * Returns a matcher by id. + * @param id the id + * @return the matcher, or <code>null</code> if no such matcher exists + */ + @Nullable public static GameObjectMatcher getMatcher(@NotNull final String id) { + return gameObjectMatchersByIds.get(id); + } + + /** * Return all known game object matchers that should be used as filters. * * @return the filter game object matches Modified: trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-04-17 17:58:10 UTC (rev 3897) +++ trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-04-17 18:15:19 UTC (rev 3898) @@ -30,7 +30,7 @@ import net.sf.gridarta.Size2D; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gameobject.match.GameObjectMatchers; +import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.map.validation.DefaultErrorCollector; import net.sf.gridarta.map.validation.ErrorCollector; import net.sf.japi.swing.ActionFactory; @@ -77,6 +77,11 @@ */ @Deprecated private final transient MainControl<G, A, R, ?, ?> mainControl; + /** + * The {@link GameObjectMatcher} for selecting exit objects. + */ + @Nullable private final GameObjectMatcher exitTypeGameObjectMatcher; + /** Size of this map. */ private Size2D mapSize; @@ -126,11 +131,13 @@ * @param mapControl MapControl to associate with this model. * @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 */ - public DefaultMapModel(final MainControl<G, A, R, ?, ?> mainControl, final MapControl<G, A, R> mapControl, final List<G> objects, final A mapArchObject) { + 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) { this.mapControl = mapControl; this.mapArchObject = mapArchObject; this.mainControl = mainControl; + this.exitTypeGameObjectMatcher = exitTypeGameObjectMatcher; mapSize = mapArchObject.getMapSize(); mapGrid = new MapSquare[mapSize.getWidth()][mapSize.getHeight()]; beginTransaction("init"); @@ -524,11 +531,11 @@ /** {@inheritDoc} */ @Nullable public G getExit(@Nullable final Point hspot) { - if (hspot == null || !isPointValid(hspot)) { - return null; // out of map + if (exitTypeGameObjectMatcher == null || hspot == null || !isPointValid(hspot)) { + return null; } for (final G arch : mapGrid[hspot.x][hspot.y]) { - if (GameObjectMatchers.isExitType(arch) && arch.getAttributeString("slaying").length() > 0) { + if (exitTypeGameObjectMatcher.isMatching(arch) && arch.getAttributeString("slaying").length() > 0) { return arch; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-17 18:35:55
|
Revision: 3899 http://gridarta.svn.sourceforge.net/gridarta/?rev=3899&view=rev Author: akirschbaum Date: 2008-04-17 11:35:36 -0700 (Thu, 17 Apr 2008) Log Message: ----------- Remove call to GameObjectMatchers.isMonsterType(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterControl.java trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterView.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-17 18:15:19 UTC (rev 3898) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-17 18:35:36 UTC (rev 3899) @@ -57,6 +57,7 @@ import net.sf.gridarta.XmlHelper; import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.Collector; +import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gameobject.match.GameObjectMatchers; import net.sf.gridarta.gui.About; import net.sf.gridarta.gui.HideFileFilterProxy; @@ -300,7 +301,12 @@ final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT); selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(ACTION_FACTORY, this, mainView, mapTileListBottom, null); // Initialize the main view - mainView.init(new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER), selectedSquareControl.getSelectedSquareView(), typeList, mapTileListBottom); + 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); + } + mainView.init(new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER), selectedSquareControl.getSelectedSquareView(), typeList, mapTileListBottom, monsterMatcher); mapActions.updateMenuState(); scriptControl.getView().setMenu((JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "plugins")); archetypeParser = new ArchetypeParser(this, objectChooser.getArchetypeChooserControl(), animationObjects); Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-04-17 18:15:19 UTC (rev 3898) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-04-17 18:35:36 UTC (rev 3899) @@ -46,6 +46,7 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; import net.sf.gridarta.MenuHelper; +import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.ArchetypesActions; import net.sf.gridarta.gui.GSplitPane; import net.sf.gridarta.gui.GUIConstants; @@ -166,8 +167,10 @@ * @param lockedItemsControl the locked items control * @param selectedSquareView the selected square view * @param archTypeList the instance for looking up archetype types + * @param monsterMatcher the <code>GameObjectMatcher</code> for matching + * monster objects */ - void init(@NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> selectedSquareView, final CFArchTypeList archTypeList, final boolean mapTileListBottom) { + void init(@NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> selectedSquareView, final CFArchTypeList archTypeList, final boolean mapTileListBottom, @NotNull final GameObjectMatcher monsterMatcher) { // calculate some default values in case there is no settings file final Rectangle screen = getGraphicsConfiguration().getBounds(); final int defwidth = (int) (0.9 * screen.getWidth()); @@ -177,7 +180,7 @@ final JPanel toolbarPanel = new JPanel(new BorderLayout()); toolbarPanel.add(mainToolbar, BorderLayout.NORTH); - toolbarPanel.add(createCenterPanel(defwidth, defheight, lockedItemsControl, selectedSquareView, mapTileListBottom), BorderLayout.CENTER); + toolbarPanel.add(createCenterPanel(defwidth, defheight, lockedItemsControl, selectedSquareView, mapTileListBottom, monsterMatcher), BorderLayout.CENTER); add(toolbarPanel, BorderLayout.CENTER); archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser, archTypeList); @@ -212,16 +215,18 @@ * @param defheight default height * @param lockedItemsControl the locked items control * @param selectedSquareView the selected square view + * @param monsterMatcher the <code>GameObjectMatcher</code> for matching + * monster objects * @return center panel */ - private JPanel createCenterPanel(final int defwidth, final int defheight, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> selectedSquareView, final boolean mapTileListBottom) { + private JPanel createCenterPanel(final int defwidth, final int defheight, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> selectedSquareView, final boolean mapTileListBottom, @NotNull final GameObjectMatcher monsterMatcher) { final JPanel centerPanel = new JPanel(new BorderLayout()); final int divLocationRight = prefs.getInt(DIVIDER_LOCATION_KEY3, (int) (defwidth * 0.62)); final int divLocationDown = prefs.getInt(DIVIDER_LOCATION_KEY2, (int) (defheight * 0.76)); final int divLocation = prefs.getInt(DIVIDER_LOCATION_KEY, (int) (defwidth * 0.17)); - gameObjectAttributesPanel = new GameObjectAttributesPanel(mainControl, mapManager, this, lockedItemsControl); + gameObjectAttributesPanel = new GameObjectAttributesPanel(mainControl, mapManager, this, lockedItemsControl, monsterMatcher); if (mapTileListBottom) { splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, gameObjectAttributesPanel, selectedSquareView); Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-04-17 18:15:19 UTC (rev 3898) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-04-17 18:35:36 UTC (rev 3899) @@ -26,6 +26,7 @@ import cfeditor.map.MapControl; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; +import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.connectionview.LockedItemsControl; import org.jetbrains.annotations.NotNull; @@ -43,8 +44,8 @@ private static final long serialVersionUID = 1L; /* Build Panel */ - public GameObjectAttributesPanel(final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl, final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager, final MainView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> view, final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl) { - super(mainControl, mapManager, view, lockedItemsControl); + public GameObjectAttributesPanel(final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl, final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager, final MainView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> view, final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher) { + super(mainControl, mapManager, view, lockedItemsControl, monsterMatcher); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-04-17 18:15:19 UTC (rev 3898) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-04-17 18:35:36 UTC (rev 3899) @@ -62,6 +62,7 @@ import net.sf.gridarta.XmlHelper; import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.Collector; +import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gameobject.match.GameObjectMatchers; import net.sf.gridarta.gameobject.match.MutableOrGameObjectMatcher; import net.sf.gridarta.gameobject.match.ViewGameObjectMatcherManager; @@ -355,7 +356,12 @@ final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT); selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(ACTION_FACTORY, this, mainView, mapTileListBottom, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH)); // Initialize the main view - mainView.init(new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER), selectedSquareControl.getSelectedSquareView(), typeList, mapTileListBottom); + 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); + } + mainView.init(new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER), selectedSquareControl.getSelectedSquareView(), typeList, mapTileListBottom, monsterMatcher); mapActions.updateMenuState(); archetypeParser = new ArchetypeParser(this, objectChooser.getArchetypeChooserControl(), animationObjects); faceObjects = new FaceObjects(this); Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-04-17 18:15:19 UTC (rev 3898) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-04-17 18:35:36 UTC (rev 3899) @@ -46,6 +46,7 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; import net.sf.gridarta.MenuHelper; +import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.ArchetypesActions; import net.sf.gridarta.gui.GSplitPane; import net.sf.gridarta.gui.GUIConstants; @@ -166,8 +167,10 @@ * @param lockedItemsControl the locked items control * @param selectedSquareView the selected square view * @param archTypeList the instance for looking up archetype types + * @param monsterMatcher the <code>GameObjectMatcher</code> for matching + * monster objects */ - void init(@NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> selectedSquareView, final CFArchTypeList archTypeList, final boolean mapTileListBottom) { + void init(@NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> selectedSquareView, final CFArchTypeList archTypeList, final boolean mapTileListBottom, @NotNull final GameObjectMatcher monsterMatcher) { // calculate some default values in case there is no settings file final Rectangle screen = getGraphicsConfiguration().getBounds(); final int defwidth = (int) (0.9 * screen.getWidth()); @@ -177,7 +180,7 @@ final JPanel toolbarPanel = new JPanel(new BorderLayout()); toolbarPanel.add(mainToolbar, BorderLayout.NORTH); - toolbarPanel.add(createCenterPanel(defwidth, defheight, lockedItemsControl, selectedSquareView, mapTileListBottom), BorderLayout.CENTER); + toolbarPanel.add(createCenterPanel(defwidth, defheight, lockedItemsControl, selectedSquareView, mapTileListBottom, monsterMatcher), BorderLayout.CENTER); add(toolbarPanel, BorderLayout.CENTER); archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser, archTypeList); @@ -212,16 +215,18 @@ * @param defheight default height * @param lockedItemsControl the locked items control * @param selectedSquareView the selected square view + * @param monsterMatcher the <code>GameObjectMatcher</code> for matching + * monster objects * @return center panel */ - private JPanel createCenterPanel(final int defwidth, final int defheight, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> selectedSquareView, final boolean mapTileListBottom) { + private JPanel createCenterPanel(final int defwidth, final int defheight, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> selectedSquareView, final boolean mapTileListBottom, @NotNull final GameObjectMatcher monsterMatcher) { final JPanel centerPanel = new JPanel(new BorderLayout()); final int divLocationRight = prefs.getInt(DIVIDER_LOCATION_KEY3, (int) (defwidth * 0.62)); final int divLocationDown = prefs.getInt(DIVIDER_LOCATION_KEY2, (int) (defheight * 0.76)); final int divLocation = prefs.getInt(DIVIDER_LOCATION_KEY, (int) (defwidth * 0.17)); - gameObjectAttributesPanel = new GameObjectAttributesPanel(mainControl, mapManager, this, lockedItemsControl); + gameObjectAttributesPanel = new GameObjectAttributesPanel(mainControl, mapManager, this, lockedItemsControl, monsterMatcher); if (mapTileListBottom) { splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, gameObjectAttributesPanel, selectedSquareView); Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-04-17 18:15:19 UTC (rev 3898) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-04-17 18:35:36 UTC (rev 3899) @@ -26,6 +26,7 @@ import daieditor.map.MapControl; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; +import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.connectionview.LockedItemsControl; import org.jetbrains.annotations.NotNull; @@ -43,8 +44,8 @@ private static final long serialVersionUID = 1L; /* Build Panel */ - public GameObjectAttributesPanel(final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl, final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager, final MainView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> view, final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl) { - super(mainControl, mapManager, view, lockedItemsControl); + public GameObjectAttributesPanel(final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl, final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager, final MainView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> view, final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher) { + super(mainControl, mapManager, view, lockedItemsControl, monsterMatcher); } /** {@inheritDoc} */ Modified: trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java 2008-04-17 18:15:19 UTC (rev 3898) +++ trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java 2008-04-17 18:35:36 UTC (rev 3899) @@ -50,6 +50,7 @@ import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.connectionview.ConnectionControl; import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.connectionview.MonsterControl; @@ -280,8 +281,10 @@ /** * Create the GameObjectAttributesPanel. * @param mainControl MainControl to use, e.g. for accessing AnimationObjects. + * @param monsterMatcher the <code>GameObjectMatcher</code> for matching + * monster objects */ - protected GameObjectAttributesPanel(@NotNull final MainControl<G, A, R, C, V> mainControl, @NotNull final MapManager<G, A, R, C, V> mapManager, final MainView<G, A, R, C, V> mainView, final LockedItemsControl<G, A, R, C, V> lockedItemsControl) { + protected GameObjectAttributesPanel(@NotNull final MainControl<G, A, R, C, V> mainControl, @NotNull final MapManager<G, A, R, C, V> mapManager, final MainView<G, A, R, C, V> mainView, final LockedItemsControl<G, A, R, C, V> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher) { super(new BorderLayout()); this.mainControl = mainControl; this.mapManager = mapManager; @@ -308,7 +311,7 @@ panelDesktop.add(animationPanel, "Animation"); panelDesktop.add(createConnectionPanel(), "Connection"); panelDesktop.add(lockedItemsControl.getView(), "Locked Items"); - panelDesktop.add(createMonsterPanel(), "Monster"); + panelDesktop.add(createMonsterPanel(monsterMatcher), "Monster"); panelDesktop.add(errorListView, "Warnings"); mainControl.getSelectedSquareControl().addSelectedSquareListener(selectedSquareListener); @@ -1044,8 +1047,8 @@ return connectionControl.getView(); } - private JPanel createMonsterPanel() { - final MonsterControl<G, A, R, C, V> monsterControl = new MonsterControl<G, A, R, C, V>(mapManager); + private JPanel createMonsterPanel(@NotNull final GameObjectMatcher monsterMatcher) { + final MonsterControl<G, A, R, C, V> monsterControl = new MonsterControl<G, A, R, C, V>(mapManager, monsterMatcher); return monsterControl.getView(); } Modified: trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterControl.java 2008-04-17 18:15:19 UTC (rev 3898) +++ trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterControl.java 2008-04-17 18:35:36 UTC (rev 3899) @@ -22,6 +22,7 @@ import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; @@ -38,9 +39,12 @@ * Create a new instance. * * @param mapManager the map manager + * + * @param monsterMatcher the <code>GameObjectMatcher</code> for matching + * monster objects */ - public MonsterControl(@NotNull final MapManager<G, A, R, C, V> mapManager) { - super(new MonsterView<G, A, R, C, V>(mapManager)); + public MonsterControl(@NotNull final MapManager<G, A, R, C, V> mapManager, @NotNull final GameObjectMatcher monsterMatcher) { + super(new MonsterView<G, A, R, C, V>(mapManager, monsterMatcher)); } } // class MonsterControl Modified: trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterView.java 2008-04-17 18:15:19 UTC (rev 3898) +++ trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterView.java 2008-04-17 18:35:36 UTC (rev 3899) @@ -22,7 +22,7 @@ import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gameobject.match.GameObjectMatchers; +import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; @@ -41,11 +41,19 @@ private static final long serialVersionUID = 1; /** + * The {@link GameObjectMatcher} for matching monster objects. + */ + @NotNull private final GameObjectMatcher monsterMatcher; + + /** * Create a MonsterView. * @param mapManager the map manager + * @param monsterMatcher the <code>GameObjectMatcher</code> for matching + * monster objects */ - public MonsterView(@NotNull final MapManager<G, A, R, C, V> mapManager) { + public MonsterView(@NotNull final MapManager<G, A, R, C, V> mapManager, @NotNull final GameObjectMatcher monsterMatcher) { super(mapManager); + this.monsterMatcher = monsterMatcher; } /** {@inheritDoc} */ @@ -57,12 +65,12 @@ } /** - * Add the given game object as a connection if it has a "connected" field. + * Add the given game object as a connection if it is a monster object. * * @param gameObject The game object to process. */ private void scanGameObject(@NotNull final G gameObject) { - if (gameObject.isHead() && GameObjectMatchers.isMonsterType(gameObject)) { + if (gameObject.isHead() && monsterMatcher.isMatching(gameObject)) { addConnection(gameObject.getBestName(), gameObject); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-17 18:57:16
|
Revision: 3900 http://gridarta.svn.sourceforge.net/gridarta/?rev=3900&view=rev Author: akirschbaum Date: 2008-04-17 11:57:16 -0700 (Thu, 17 Apr 2008) Log Message: ----------- Remove calls to GameObjectMatchers.isExitType(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/MapActions.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/MapActions.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-17 18:35:36 UTC (rev 3899) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-17 18:57:16 UTC (rev 3900) @@ -288,7 +288,12 @@ } catch (final FileNotFoundException ex) { log.error("Cannot read GameObjectMatchers.xml: " + ex.getMessage()); } - mapActions = new MapActions(this, getMapManager(), 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); + } + mapActions = new MapActions(this, getMapManager(), exitMatcher); typeList.getListTable().put("event", getEventTypes()); try { final String filename = IOUtils.getResourceURLAsString(getConfigurationDirectory(), CommonConstants.TYPEDEF_FILE); Modified: trunk/crossfire/src/cfeditor/MapActions.java =================================================================== --- trunk/crossfire/src/cfeditor/MapActions.java 2008-04-17 18:35:36 UTC (rev 3899) +++ trunk/crossfire/src/cfeditor/MapActions.java 2008-04-17 18:57:16 UTC (rev 3900) @@ -35,7 +35,7 @@ import net.sf.gridarta.CurrentMapListener; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; -import net.sf.gridarta.gameobject.match.GameObjectMatchers; +import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapView; import net.sf.japi.swing.ActionFactory; @@ -106,8 +106,8 @@ /** The map manager. */ private final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager; - /** The game object matchers. */ - private final GameObjectMatchers gameObjectMatchers; + /** The matcher for selecting exit objects. */ + private final GameObjectMatcher exitMatcher; /** * The current map listener used to detect current map/map view changes. @@ -123,10 +123,10 @@ * * @param GameObjectMatchers the game object matchers */ - public MapActions(final CMainControl mainControl, final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager, final GameObjectMatchers gameObjectMatchers) { + public MapActions(final CMainControl mainControl, final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager, final GameObjectMatcher exitMatcher) { this.mainControl = mainControl; this.mapManager = mapManager; - this.gameObjectMatchers = gameObjectMatchers; + this.exitMatcher = exitMatcher; autoJoin = prefs.getBoolean(AUTOJOIN_KEY, false); @@ -449,12 +449,12 @@ } final GameObject selectedExit = mainControl.getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject(); - if (selectedExit != null && gameObjectMatchers.isExitType(selectedExit.getHead()) && selectedExit.getHead().getAttributeString("slaying").length() > 0) { + if (selectedExit != null && exitMatcher.isMatching(selectedExit.getHead()) && selectedExit.getHead().getAttributeString("slaying").length() > 0) { return selectedExit.getHead(); } final GameObject cursorExit = mapView.getMapControl().getMapModel().getExit(mapView.getView().getMapCursor().getLocation()); - if (cursorExit != null && gameObjectMatchers.isExitType(cursorExit.getHead()) && cursorExit.getHead().getAttributeString("slaying").length() > 0) { + if (cursorExit != null && exitMatcher.isMatching(cursorExit.getHead()) && cursorExit.getHead().getAttributeString("slaying").length() > 0) { return cursorExit.getHead(); } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-04-17 18:35:36 UTC (rev 3899) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-04-17 18:57:16 UTC (rev 3900) @@ -344,7 +344,12 @@ } catch (final FileNotFoundException ex) { log.error("Cannot read GameObjectMatchers.xml: " + ex.getMessage()); } - mapActions = new MapActions(this, getMapManager(), 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); + } + mapActions = new MapActions(this, getMapManager(), exitMatcher); try { final String filename = IOUtils.getResourceURLAsString(getConfigurationDirectory(), CommonConstants.TYPEDEF_FILE); typeList.loadTypesFromXML(filename); Modified: trunk/daimonin/src/daieditor/MapActions.java =================================================================== --- trunk/daimonin/src/daieditor/MapActions.java 2008-04-17 18:35:36 UTC (rev 3899) +++ trunk/daimonin/src/daieditor/MapActions.java 2008-04-17 18:57:16 UTC (rev 3900) @@ -34,7 +34,7 @@ import net.sf.gridarta.CurrentMapListener; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; -import net.sf.gridarta.gameobject.match.GameObjectMatchers; +import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapView; import net.sf.japi.swing.ActionFactory; @@ -102,8 +102,8 @@ /** The map manager. */ private final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager; - /** The game object matchers. */ - private final GameObjectMatchers gameObjectMatchers; + /** The matcher for selecting exit objects. */ + private final GameObjectMatcher exitMatcher; /** * The current map listener used to detect current map/map view changes. @@ -119,10 +119,10 @@ * * @param GameObjectMatchers the game object matchers */ - public MapActions(final CMainControl mainControl, final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager, final GameObjectMatchers gameObjectMatchers) { + public MapActions(final CMainControl mainControl, final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager, final GameObjectMatcher exitMatcher) { this.mainControl = mainControl; this.mapManager = mapManager; - this.gameObjectMatchers = gameObjectMatchers; + this.exitMatcher = exitMatcher; autoJoin = prefs.getBoolean(AUTOJOIN_KEY, false); @@ -427,12 +427,12 @@ } final GameObject selectedExit = mainControl.getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject(); - if (selectedExit != null && gameObjectMatchers.isExitType(selectedExit.getHead()) && selectedExit.getHead().getAttributeString("slaying").length() > 0) { + if (selectedExit != null && exitMatcher.isMatching(selectedExit.getHead()) && selectedExit.getHead().getAttributeString("slaying").length() > 0) { return selectedExit.getHead(); } final GameObject cursorExit = mapView.getMapControl().getMapModel().getExit(mapView.getView().getMapCursor().getLocation()); - if (cursorExit != null && gameObjectMatchers.isExitType(cursorExit.getHead()) && cursorExit.getHead().getAttributeString("slaying").length() > 0) { + if (cursorExit != null && exitMatcher.isMatching(cursorExit.getHead()) && cursorExit.getHead().getAttributeString("slaying").length() > 0) { return cursorExit.getHead(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-19 14:04:07
|
Revision: 3904 http://gridarta.svn.sourceforge.net/gridarta/?rev=3904&view=rev Author: akirschbaum Date: 2008-04-19 07:04:06 -0700 (Sat, 19 Apr 2008) Log Message: ----------- Dynamically build 'Show xxx' menu entries from GameObjectMatchers.xml. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/action.properties trunk/crossfire/src/cfeditor/messages.properties trunk/crossfire/src/cfeditor/messages_de.properties trunk/crossfire/src/cfeditor/messages_fr.properties trunk/crossfire/src/cfeditor/messages_sv.properties trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/action.properties trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatcherParser.java trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchers.java trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchersParser.java trunk/src/app/net/sf/gridarta/gameobject/match/NamedGameObjectMatcher.java trunk/src/app/net/sf/gridarta/gui/GUIConstants.java trunk/src/app/net/sf/gridarta/gui/map/ViewActions.java trunk/src/app/net/sf/gridarta/messages.properties trunk/src/app/net/sf/gridarta/messages_de.properties trunk/src/app/net/sf/gridarta/messages_fr.properties trunk/src/app/net/sf/gridarta/messages_sv.properties Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-04-18 22:10:29 UTC (rev 3903) +++ trunk/crossfire/ChangeLog 2008-04-19 14:04:06 UTC (rev 3904) @@ -1,3 +1,9 @@ +2008-04-19 Andreas Kirschbaum + + * Add more 'Show xxx' entries to View menu. + + * Remove 'View' menu from map windows. + 2008-04-07 Andreas Kirschbaum * Implement pickmap folders. Pickmap groups allow grouping Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-18 22:10:29 UTC (rev 3903) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-19 14:04:06 UTC (rev 3904) @@ -311,7 +311,7 @@ log.fatal("GameObjectMatcher 'monster' does not exist"); throw new MissingResourceException("GameObjectMatcher 'monster' does not exist", null, null); } - mainView.init(new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER), selectedSquareControl.getSelectedSquareView(), typeList, mapTileListBottom, monsterMatcher); + mainView.init(new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER), selectedSquareControl.getSelectedSquareView(), typeList, mapTileListBottom, monsterMatcher, gameObjectMatchers); mapActions.updateMenuState(); scriptControl.getView().setMenu((JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "plugins")); archetypeParser = new ArchetypeParser(this, objectChooser.getArchetypeChooserControl(), animationObjects); Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-04-18 22:10:29 UTC (rev 3903) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-04-19 14:04:06 UTC (rev 3904) @@ -47,6 +47,7 @@ import net.sf.gridarta.MapManager; import net.sf.gridarta.MenuHelper; import net.sf.gridarta.gameobject.match.GameObjectMatcher; +import net.sf.gridarta.gameobject.match.GameObjectMatchers; import net.sf.gridarta.gui.ArchetypesActions; import net.sf.gridarta.gui.GSplitPane; import net.sf.gridarta.gui.GUIConstants; @@ -169,8 +170,9 @@ * @param archTypeList the instance for looking up archetype types * @param monsterMatcher the <code>GameObjectMatcher</code> for matching * monster objects + * @param gameObjectMatchers the game object matchers */ - void init(@NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> selectedSquareView, final CFArchTypeList archTypeList, final boolean mapTileListBottom, @NotNull final GameObjectMatcher monsterMatcher) { + void init(@NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> selectedSquareView, final CFArchTypeList archTypeList, final boolean mapTileListBottom, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final GameObjectMatchers gameObjectMatchers) { // calculate some default values in case there is no settings file final Rectangle screen = getGraphicsConfiguration().getBounds(); final int defwidth = (int) (0.9 * screen.getWidth()); @@ -186,6 +188,8 @@ archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser, archTypeList); setJMenuBar(actionFactory.createMenuBar(true, "main")); objectChooser.setPickmapFoldersMenu((JMenu) actionFactory.find(getJMenuBar(), "pickmapFolders")); + viewActions.init(gameObjectMatchers); + viewActions.setMenu((JMenu) actionFactory.find(getJMenuBar(), "view")); // set bounds (location and size) of the main frame setBounds( Modified: trunk/crossfire/src/cfeditor/action.properties =================================================================== --- trunk/crossfire/src/cfeditor/action.properties 2008-04-18 22:10:29 UTC (rev 3903) +++ trunk/crossfire/src/cfeditor/action.properties 2008-04-19 14:04:06 UTC (rev 3904) @@ -36,18 +36,17 @@ resources.menu=collectArches - viewTreasurelists tools.menu=validateMap - gc analyze.menu= -view.menu=showMonster showExit showBackground showDoor showWall showEquipment showTreasure showConnected resetView - prevWindow nextWindow +view.menu=resetView - prevWindow nextWindow plugins.menu=- editPlugins - savePlugins importPlugin window.menu=closeAll help.menu=onlineHelp tod about update -mapwindow.menubar=mapwindowFile mapwindowEdit mapwindowMap mapwindowCursor mapwindowView +mapwindow.menubar=mapwindowFile mapwindowEdit mapwindowMap mapwindowCursor mapwindowFile.menu=save saveAs createImage - revert - close mapwindowEdit.menu=undo redo - clear cut copy paste - shift - replace fillAbove fillBelow randFillAbove randFillBelow floodfill mapwindowMap.menu=gridVisible enterExit enterNorthMap enterEastMap enterSouthMap enterWestMap tileShow - mapCreateView mapProperties mapwindowCursor.menu=moveCursor - selectTile startStopDrag addToSelection subFromSelection releaseDrag - insertArch deleteArch - selectArchAbove selectArchBelow - archAttributes -mapwindowView.menu=showMonster showExit showBackground showDoor showWall showEquipment showTreasure showConnected resetView ########## # ToolBars Modified: trunk/crossfire/src/cfeditor/messages.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages.properties 2008-04-18 22:10:29 UTC (rev 3903) +++ trunk/crossfire/src/cfeditor/messages.properties 2008-04-19 14:04:06 UTC (rev 3904) @@ -350,10 +350,7 @@ mapwindowCursor.text=Cursor mapwindowCursor.mnemonic=C -mapwindowView.text=View -mapwindowView.mnemonic=V - ################# # Map Arch Panel Modified: trunk/crossfire/src/cfeditor/messages_de.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_de.properties 2008-04-18 22:10:29 UTC (rev 3903) +++ trunk/crossfire/src/cfeditor/messages_de.properties 2008-04-19 14:04:06 UTC (rev 3904) @@ -312,10 +312,7 @@ mapwindowCursor.text=Cursor mapwindowCursor.mnemonic=C -mapwindowView.text=Ansicht -mapwindowView.mnemonic=A - ################# # Map Arch Panel Modified: trunk/crossfire/src/cfeditor/messages_fr.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_fr.properties 2008-04-18 22:10:29 UTC (rev 3903) +++ trunk/crossfire/src/cfeditor/messages_fr.properties 2008-04-19 14:04:06 UTC (rev 3904) @@ -313,10 +313,7 @@ #mapwindowCursor.text= #mapwindowCursor.mnemonic= -mapwindowView.text=Affichage -mapwindowView.mnemonic=A - ################# # Map Arch Panel Modified: trunk/crossfire/src/cfeditor/messages_sv.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_sv.properties 2008-04-18 22:10:29 UTC (rev 3903) +++ trunk/crossfire/src/cfeditor/messages_sv.properties 2008-04-19 14:04:06 UTC (rev 3904) @@ -311,10 +311,7 @@ mapwindowCursor.text=Mark\xF6r mapwindowCursor.mnemonic=M -mapwindowView.text=Visning -mapwindowView.mnemonic=V - ################# # Map Arch Panel Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-04-18 22:10:29 UTC (rev 3903) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-04-19 14:04:06 UTC (rev 3904) @@ -366,7 +366,7 @@ log.fatal("GameObjectMatcher 'monster' does not exist"); throw new MissingResourceException("GameObjectMatcher 'monster' does not exist", null, null); } - mainView.init(new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER), selectedSquareControl.getSelectedSquareView(), typeList, mapTileListBottom, monsterMatcher); + mainView.init(new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER), selectedSquareControl.getSelectedSquareView(), typeList, mapTileListBottom, monsterMatcher, gameObjectMatchers); mapActions.updateMenuState(); archetypeParser = new ArchetypeParser(this, objectChooser.getArchetypeChooserControl(), animationObjects); faceObjects = new FaceObjects(this); Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-04-18 22:10:29 UTC (rev 3903) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-04-19 14:04:06 UTC (rev 3904) @@ -47,6 +47,7 @@ import net.sf.gridarta.MapManager; import net.sf.gridarta.MenuHelper; import net.sf.gridarta.gameobject.match.GameObjectMatcher; +import net.sf.gridarta.gameobject.match.GameObjectMatchers; import net.sf.gridarta.gui.ArchetypesActions; import net.sf.gridarta.gui.GSplitPane; import net.sf.gridarta.gui.GUIConstants; @@ -169,8 +170,9 @@ * @param archTypeList the instance for looking up archetype types * @param monsterMatcher the <code>GameObjectMatcher</code> for matching * monster objects + * @param gameObjectMatchers the game object matchers */ - void init(@NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> selectedSquareView, final CFArchTypeList archTypeList, final boolean mapTileListBottom, @NotNull final GameObjectMatcher monsterMatcher) { + void init(@NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> selectedSquareView, final CFArchTypeList archTypeList, final boolean mapTileListBottom, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final GameObjectMatchers gameObjectMatchers) { // calculate some default values in case there is no settings file final Rectangle screen = getGraphicsConfiguration().getBounds(); final int defwidth = (int) (0.9 * screen.getWidth()); @@ -186,6 +188,8 @@ archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser, archTypeList); setJMenuBar(actionFactory.createMenuBar(true, "main")); objectChooser.setPickmapFoldersMenu((JMenu) actionFactory.find(getJMenuBar(), "pickmapFolders")); + viewActions.init(gameObjectMatchers); + viewActions.setMenu((JMenu) actionFactory.find(getJMenuBar(), "view")); // set bounds (location and size) of the main frame setBounds( Modified: trunk/daimonin/src/daieditor/action.properties =================================================================== --- trunk/daimonin/src/daieditor/action.properties 2008-04-18 22:10:29 UTC (rev 3903) +++ trunk/daimonin/src/daieditor/action.properties 2008-04-19 14:04:06 UTC (rev 3904) @@ -34,11 +34,10 @@ #pickmaps.menu: See gridarta resources.menu=collectArches collectSpells - reloadFaces - viewTreasurelists tools.menu=newScript editScript - controlServer controlClient - validateMap cleanCompletelyBlockedSquares - zoom gc -#view.menu=+lafs - changeFont - showMonsters showExits showBackground showDoorsKeys showWall showEquipment showTreasure showConnected resetShow -#view.menu=changeFont - viewShow viewAlpha -#view.menu=viewShow viewAlpha gridVisible drawDouble - prevWindow nextWindow -view.menu=viewShow gridVisible drawDouble - prevWindow nextWindow -viewShow.menu=showMonster showExit showBackground showDoor showWall showEquipment showTreasure showConnected resetView +#view.menu=+lafs - changeFont - resetShow +#view.menu=resetView - changeFont - viewAlpha +#view.menu=resetView - viewAlpha gridVisible drawDouble - prevWindow nextWindow +view.menu=resetView - gridVisible drawDouble - prevWindow nextWindow #viewAlpha.menu = alphaMonsters alphaExits alphaBackground alphaDoorsKeys alphaWall alphaEquipment alphaTreasure alphaConnected resetAlpha #window.menu=newWindow - closeAll +windows window.menu=closeAll @@ -124,8 +123,6 @@ gc.icon=general/Delete16 -#viewShow.icon=general/Find16 - #viewAlpha.icon=general/Find16 nextWindow.icon=navigation/Forward16 Modified: trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatcherParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatcherParser.java 2008-04-18 22:10:29 UTC (rev 3903) +++ trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatcherParser.java 2008-04-19 14:04:06 UTC (rev 3904) @@ -60,11 +60,13 @@ * * @param el the XML node to create from * + * @param editType the edit type for the new matcher + * * @return the created matcher * * @throws XPathExpressionException in case of XPath problems (shouldn't happen) */ - public NamedGameObjectMatcher parseMatcher(final Element el) throws XPathExpressionException { + public NamedGameObjectMatcher parseMatcher(final Element el, final int editType) throws XPathExpressionException { final String currentLanguage = Locale.getDefault().getLanguage(); final String localName = el.getLocalName(); if (!"GameObjectMatcher".equals(localName)) { @@ -81,7 +83,7 @@ final Node content = (Node) xpath.evaluate("*[last()]", el, XPathConstants.NODE); assert content.getNodeType() == Node.ELEMENT_NODE; final GameObjectMatcher matcher = createMatcher((Element) content); - return new NamedGameObjectMatcher(id, title, matcher); + return new NamedGameObjectMatcher(editType, id, title, matcher); } /** Modified: trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchers.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchers.java 2008-04-18 22:10:29 UTC (rev 3903) +++ trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchers.java 2008-04-19 14:04:06 UTC (rev 3904) @@ -56,7 +56,7 @@ private static final Map<String, NamedGameObjectMatcher> gameObjectMatchersByIds = new HashMap<String, NamedGameObjectMatcher>(); /** List with arch object matchers. */ - private final List<NamedGameObjectMatcher> gameObjectMatchers = new ArrayList<NamedGameObjectMatcher>(); + private static final List<NamedGameObjectMatcher> gameObjectMatchers = new ArrayList<NamedGameObjectMatcher>(); /** * Creates a new instance. @@ -68,18 +68,6 @@ this.xpath = xpath; } - /** - * Check whether the GameObject has a given type. - * @param arch GameObject to check - * @param id the type to check for - * @return <code>true</code> if <var>arch</var> is of the given type, - * otherwise <code>false</code> - */ - private static boolean isType(@NotNull final GameObject arch, final String id) { - final NamedGameObjectMatcher matcher = gameObjectMatchersByIds.get(id); - return matcher != null && matcher.isMatching(arch); - } - public void readGameObjectMatchers(@NotNull final String filename) { new GameObjectMatchersParser(documentBuilder, xpath).readGameObjectMatchers(filename, gameObjectMatchers, gameObjectMatchersByIds); } @@ -89,7 +77,7 @@ * @param id the id * @return the matcher, or <code>null</code> if no such matcher exists */ - @Nullable public static GameObjectMatcher getMatcher(@NotNull final String id) { + @Nullable public static NamedGameObjectMatcher getMatcher(@NotNull final String id) { return gameObjectMatchersByIds.get(id); } @@ -110,30 +98,12 @@ */ public static int calculateEditType(@NotNull final GameObject gameObject, final int checkType) { int editType = 0; - if ((checkType & GUIConstants.EDIT_TYPE_BACKGROUND) != 0 && isType(gameObject, "background")) { - editType |= GUIConstants.EDIT_TYPE_BACKGROUND; + for (final NamedGameObjectMatcher matcher : gameObjectMatchers) { + final int matcherEditType = matcher.getEditType(); + if ((checkType & matcherEditType) != 0 && matcher.isMatching(gameObject)) { + editType |= matcherEditType; + } } - if ((checkType & GUIConstants.EDIT_TYPE_MONSTER) != 0 && isType(gameObject, "monster")) { - editType |= GUIConstants.EDIT_TYPE_MONSTER; - } - if ((checkType & GUIConstants.EDIT_TYPE_WALL) != 0 && isType(gameObject, "wall")) { - editType |= GUIConstants.EDIT_TYPE_WALL; - } - if ((checkType & GUIConstants.EDIT_TYPE_CONNECTED) != 0 && isType(gameObject, "connected")) { - editType |= GUIConstants.EDIT_TYPE_CONNECTED; - } - if ((checkType & GUIConstants.EDIT_TYPE_EXIT) != 0 && isType(gameObject, "exit")) { - editType |= GUIConstants.EDIT_TYPE_EXIT; - } - if ((checkType & GUIConstants.EDIT_TYPE_TREASURE) != 0 && isType(gameObject, "treasure")) { - editType |= GUIConstants.EDIT_TYPE_TREASURE; - } - if ((checkType & GUIConstants.EDIT_TYPE_DOOR) != 0 && isType(gameObject, "door")) { - editType |= GUIConstants.EDIT_TYPE_DOOR; - } - if ((checkType & GUIConstants.EDIT_TYPE_EQUIP) != 0 && isType(gameObject, "equipment")) { - editType |= GUIConstants.EDIT_TYPE_EQUIP; - } return editType; } Modified: trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchersParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchersParser.java 2008-04-18 22:10:29 UTC (rev 3903) +++ trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchersParser.java 2008-04-19 14:04:06 UTC (rev 3904) @@ -61,12 +61,18 @@ final GameObjectMatcherParser aom = new GameObjectMatcherParser(xpath); try { final Document doc = documentBuilder.parse(filename); + int editType = 1; for (final Element node : new NodeListIterator<Element>(doc.getElementsByTagName("GameObjectMatcher"))) { - final NamedGameObjectMatcher archObjectMatcher = aom.parseMatcher(node); + if (editType == 0) { + log.warn("Too many GameObjectMatchers, ignoring rest"); + break; + } + final NamedGameObjectMatcher archObjectMatcher = aom.parseMatcher(node, editType); gameObjectMatchers.add(archObjectMatcher); if (archObjectMatcher.getID() != null) { gameObjectMatchersByIds.put(archObjectMatcher.getID(), archObjectMatcher); } + editType <<= 1; } if (log.isInfoEnabled()) { log.info("Loaded " + gameObjectMatchers.size() + " GameObjectMatchers from '" + filename + "'."); Modified: trunk/src/app/net/sf/gridarta/gameobject/match/NamedGameObjectMatcher.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/match/NamedGameObjectMatcher.java 2008-04-18 22:10:29 UTC (rev 3903) +++ trunk/src/app/net/sf/gridarta/gameobject/match/NamedGameObjectMatcher.java 2008-04-19 14:04:06 UTC (rev 3904) @@ -35,6 +35,11 @@ /** The serial version UID. */ private static final long serialVersionUID = 1; + /** + * The edit type of this matcher. + */ + private final int editType; + /** The localized name. */ private final String name; @@ -48,13 +53,16 @@ /** * Creates a <code>NamedGameObjectMatcher</code>. * + * @param editType the edit type + * * @param id the ID for this <code>GameObjectMachter</code> * * @param name the localized name * * @param gameObjectMatcher the matcher to delegate to */ - public NamedGameObjectMatcher(final String id, final String name, final GameObjectMatcher gameObjectMatcher) { + public NamedGameObjectMatcher(final int editType, final String id, final String name, final GameObjectMatcher gameObjectMatcher) { + this.editType = editType; this.id = id; this.name = name; this.gameObjectMatcher = gameObjectMatcher; @@ -82,4 +90,13 @@ return id; } + /** + * Returns the edit type associated with this matcher. This value is a bit + * mask and uniquely identifies this matcher. + * @return the edit type + */ + public int getEditType() { + return editType; + } + } // class NamedGameObjectMatcher Modified: trunk/src/app/net/sf/gridarta/gui/GUIConstants.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/GUIConstants.java 2008-04-18 22:10:29 UTC (rev 3903) +++ trunk/src/app/net/sf/gridarta/gui/GUIConstants.java 2008-04-19 14:04:06 UTC (rev 3904) @@ -41,22 +41,6 @@ /** The directory that contains the system icons. */ String SYSTEM_DIR = "resource/system"; - int EDIT_TYPE_MONSTER = 1; - - int EDIT_TYPE_EXIT = 2; - - int EDIT_TYPE_BACKGROUND = 4; - - int EDIT_TYPE_DOOR = 8; - - int EDIT_TYPE_WALL = 16; - - int EDIT_TYPE_EQUIP = 32; - - int EDIT_TYPE_TREASURE = 64; - - int EDIT_TYPE_CONNECTED = 128; - int EDIT_TYPE_NONE = 0x10000; // special case String TILE_SEL_TILE = "seltile.png"; Modified: trunk/src/app/net/sf/gridarta/gui/map/ViewActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/ViewActions.java 2008-04-18 22:10:29 UTC (rev 3903) +++ trunk/src/app/net/sf/gridarta/gui/map/ViewActions.java 2008-04-19 14:04:06 UTC (rev 3904) @@ -19,18 +19,26 @@ package net.sf.gridarta.gui.map; +import java.awt.event.ActionEvent; +import java.util.LinkedList; +import java.util.List; +import javax.swing.AbstractAction; +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JMenu; import net.sf.gridarta.CurrentMapListener; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gui.GUIConstants; +import net.sf.gridarta.gameobject.match.GameObjectMatchers; +import net.sf.gridarta.gameobject.match.NamedGameObjectMatcher; import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ToggleAction; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Manages edit type actions in "view" menu. @@ -47,30 +55,9 @@ /** The listener to check for current map changes. */ private final CurrentMapListener<G, A, R, C, V> currentMapListener; - /** Action for "show monster". */ - private final ToggleAction aShowMonster = (ToggleAction) ACTION_FACTORY.createToggle(true, "showMonster", this); + /** The view actions. */ + private final List<ViewAction> viewActions = new LinkedList<ViewAction>(); - /** Action for "show exit". */ - private final ToggleAction aShowExit = (ToggleAction) ACTION_FACTORY.createToggle(true, "showExit", this); - - /** Action for "show background". */ - private final ToggleAction aShowBackground = (ToggleAction) ACTION_FACTORY.createToggle(true, "showBackground", this); - - /** Action for "show door". */ - private final ToggleAction aShowDoor = (ToggleAction) ACTION_FACTORY.createToggle(true, "showDoor", this); - - /** Action for "show wall". */ - private final ToggleAction aShowWall = (ToggleAction) ACTION_FACTORY.createToggle(true, "showWall", this); - - /** Action for "show equipment". */ - private final ToggleAction aShowEquipment = (ToggleAction) ACTION_FACTORY.createToggle(true, "showEquipment", this); - - /** Action for "show treasure". */ - private final ToggleAction aShowTreasure = (ToggleAction) ACTION_FACTORY.createToggle(true, "showTreasure", this); - - /** Action for "show connected". */ - private final ToggleAction aShowConnected = (ToggleAction) ACTION_FACTORY.createToggle(true, "showConnected", this); - /** * Create a new instance. * @@ -109,6 +96,31 @@ } /** + * Creates the view actions. + * @param gameObjectMatchers the game object matchers + */ + public void init(@NotNull final GameObjectMatchers gameObjectMatchers) { + for (final NamedGameObjectMatcher matcher : gameObjectMatchers.getFilters()) { + viewActions.add(new ViewAction(mainControl, matcher)); + } + } + + /** + * Sets the menu to add the actions to. + * @param viewActionsMenu the menu + */ + public void setMenu(@Nullable final JMenu viewActionsMenu) { + if (viewActionsMenu == null) { + return; + } + + int index = 0; + for (final ViewAction viewAction : viewActions) { + viewActionsMenu.add(viewAction.getCheckBoxMenuItem(), index++); + } + } + + /** * Unregister all registered listeners. Must be called when this instance * is freed. */ @@ -127,134 +139,73 @@ * Update the actions' state to the current edit mode. */ private void updateActions() { - aShowMonster.setSelected(isShowMonster()); - aShowExit.setSelected(isShowExit()); - aShowBackground.setSelected(isShowBackground()); - aShowDoor.setSelected(isShowDoor()); - aShowWall.setSelected(isShowWall()); - aShowEquipment.setSelected(isShowEquipment()); - aShowTreasure.setSelected(isShowTreasure()); - aShowConnected.setSelected(isShowConnected()); + for (final ViewAction viewAction : viewActions) { + viewAction.updateAction(); + } } - /** Action method for "show monster". - * @return <code>true</code> if showMonster is active, otherwise <code>false</code>. + /** + * Action to manage one edit type represented by one {@link + * NamedGameObjectMatcher}. */ - public boolean isShowMonster() { - return mainControl.isEditType(GUIConstants.EDIT_TYPE_MONSTER); - } + private static class ViewAction extends AbstractAction { - /** Action method for "show monster". - * @param showMonster <code>true</code> if showMonster should be activated, otherwise <code>false</code>. - */ - public void setShowMonster(final boolean showMonster) { - setShow(showMonster, GUIConstants.EDIT_TYPE_MONSTER); - } + /** The serial version UID. */ + private static final long serialVersionUID = 1; - /** Action method for "show exit". - * @return <code>true</code> if showExit is active, otherwise <code>false</code>. - */ - public boolean isShowExit() { - return mainControl.isEditType(GUIConstants.EDIT_TYPE_EXIT); - } + /** The main control to use. */ + @NotNull private final transient MainControl<?, ?, ?, ?, ?> mainControl; - /** Action method for "show exit". - * @param showExit <code>true</code> if showExit should be activated, otherwise <code>false</code>. - */ - public void setShowExit(final boolean showExit) { - setShow(showExit, GUIConstants.EDIT_TYPE_EXIT); - } + /** + * The managed edit type. + */ + private final int editType; - /** Action method for "show background". - * @return <code>true</code> if showBackground is active, otherwise <code>false</code>. - */ - public boolean isShowBackground() { - return mainControl.isEditType(GUIConstants.EDIT_TYPE_BACKGROUND); - } + /** + * The menu item for this action. + */ + private final JCheckBoxMenuItem checkBoxMenuItem = new JCheckBoxMenuItem(this); - /** Action method for "show background". - * @param showBackground <code>true</code> if showBackground should be activated, otherwise <code>false</code>. - */ - public void setShowBackground(final boolean showBackground) { - setShow(showBackground, GUIConstants.EDIT_TYPE_BACKGROUND); - } + /** + * Creates a new instance. + * @param mainControl the main control + * @param matcher the matcher + */ + public ViewAction(@NotNull final MainControl<?, ?, ?, ?, ?> mainControl, @NotNull final NamedGameObjectMatcher matcher) { + super(ACTION_FACTORY.format("show.text", matcher.getName())); + this.mainControl = mainControl; + this.editType = matcher.getEditType(); + } - /** Action method for "show door". - * @return <code>true</code> if showDoor is active, otherwise <code>false</code>. - */ - public boolean isShowDoor() { - return mainControl.isEditType(GUIConstants.EDIT_TYPE_DOOR); - } + /** + * Update the action's state to match the current edit type settings. + */ + public void updateAction() { + checkBoxMenuItem.setSelected(mainControl.isEditType(editType)); + } - /** Action method for "show door". - * @param showDoor <code>true</code> if showDoor should be activated, otherwise <code>false</code>. - */ - public void setShowDoor(final boolean showDoor) { - setShow(showDoor, GUIConstants.EDIT_TYPE_DOOR); - } + /** {@inheritDoc} */ + public void actionPerformed(final ActionEvent e) { + if (!isEnabled()) { + return; + } - /** Action method for "show wall". - * @return <code>true</code> if showWall is active, otherwise <code>false</code>. - */ - public boolean isShowWall() { - return mainControl.isEditType(GUIConstants.EDIT_TYPE_WALL); - } + if (mainControl.isEditType(editType)) { + mainControl.unsetEditType(editType); + } else { + mainControl.setEditType(editType); + } + updateAction(); + } - /** Action method for "show wall". - * @param showWall <code>true</code> if showWall should be activated, otherwise <code>false</code>. - */ - public void setShowWall(final boolean showWall) { - setShow(showWall, GUIConstants.EDIT_TYPE_WALL); - } - - /** Action method for "show equipment". - * @return <code>true</code> if showEquipment is active, otherwise <code>false</code>. - */ - public boolean isShowEquipment() { - return mainControl.isEditType(GUIConstants.EDIT_TYPE_EQUIP); - } - - /** Action method for "show equipment". - * @param showEquipment <code>true</code> if showEquipment should be activated, otherwise <code>false</code>. - */ - public void setShowEquipment(final boolean showEquipment) { - setShow(showEquipment, GUIConstants.EDIT_TYPE_EQUIP); - } - - /** Action method for "show treasure". - * @return <code>true</code> if showTreasure is active, otherwise <code>false</code>. - */ - public boolean isShowTreasure() { - return mainControl.isEditType(GUIConstants.EDIT_TYPE_TREASURE); - } - - /** Action method for "show treasure". - * @param showTreasure <code>true</code> if showTreasure should be activated, otherwise <code>false</code>. - */ - public void setShowTreasure(final boolean showTreasure) { - setShow(showTreasure, GUIConstants.EDIT_TYPE_TREASURE); - } - - /** Action method for "show connected". - * @return <code>true</code> if showConnected is active, otherwise <code>false</code>. - */ - public boolean isShowConnected() { - return mainControl.isEditType(GUIConstants.EDIT_TYPE_CONNECTED); - } - - /** Action method for "show connected". - * @param showConnected <code>true</code> if showConnected should be activated, otherwise <code>false</code>. - */ - public void setShowConnected(final boolean showConnected) { - setShow(showConnected, GUIConstants.EDIT_TYPE_CONNECTED); - } - - private void setShow(final boolean show, final int editType) { - if (show) { - mainControl.setEditType(editType); - } else { - mainControl.unsetEditType(editType); + /** + * Returns the menu item for this action. + * @return the menu item + */ + public JCheckBoxMenuItem getCheckBoxMenuItem() { + return checkBoxMenuItem; } - } + } // class ViewAction + } // class ViewActions Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2008-04-18 22:10:29 UTC (rev 3903) +++ trunk/src/app/net/sf/gridarta/messages.properties 2008-04-19 14:04:06 UTC (rev 3904) @@ -537,30 +537,8 @@ view.text=View view.mnemonic=V -showMonster.text=Show monsters -showMonster.mnemonic=M +show.text=Show {0} -showExit.text=Show exits -showExit.mnemonic=X - -showBackground.text=Show background -showBackground.mnemonic=B - -showDoor.text=Show doors & keys -showDoor.mnemonic=D - -showWall.text=Show walls -showWall.mnemonic=W - -showEquipment.text=Show equipment -showEquipment.mnemonic=E - -showTreasure.text=Show treasure -showTreasure.mnemonic=T - -showConnected.text=Show connected -showConnected.mnemonic=C - resetView.text=Reset view resetView.mnemonic=R Modified: trunk/src/app/net/sf/gridarta/messages_de.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_de.properties 2008-04-18 22:10:29 UTC (rev 3903) +++ trunk/src/app/net/sf/gridarta/messages_de.properties 2008-04-19 14:04:06 UTC (rev 3904) @@ -501,30 +501,8 @@ view.text=Ansicht view.mnemonic=A -showMonster.text=Monster anzeigen -showMonster.mnemonic=M +show.text={0} anzeigen -showExit.text=Ausg\xE4nge anzeigen -showExit.mnemonic=A - -showBackground.text=Hintergrund anzeigen -showBackground.mnemonic=H - -showDoor.text=T\xFCren und Schl\xFCssel anzeigen -showDoor.mnemonic=T - -showWall.text=W\xE4nde anzeigen -showWall.mnemonic=W - -showEquipment.text=Ausr\xFCstung anzeigen -showEquipment.mnemonic=U - -showTreasure.text=Sch\xE4tze anzeigen -showTreasure.mnemonic=S - -showConnected.text=Verbindungen anzeigen -showConnected.mnemonic=V - resetView.text=Ansicht zur\xFCcksetzen resetView.mnemonic=Z Modified: trunk/src/app/net/sf/gridarta/messages_fr.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-04-18 22:10:29 UTC (rev 3903) +++ trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-04-19 14:04:06 UTC (rev 3904) @@ -500,30 +500,8 @@ view.text=Affichage view.mnemonic=A -showMonster.text=Afficher monstres -showMonster.mnemonic=M +showMonster.text=Afficher {0} -showExit.text=Afficher sorties -showExit.mnemonic=S - -showBackground.text=Afficher fond -showBackground.mnemonic=F - -showDoor.text=Afficher portes et cl\xE9s -showDoor.mnemonic=P - -showWall.text=Afficher murs -showWall.mnemonic=U - -showEquipment.text=Afficher \xE9quipement -showEquipment.mnemonic=E - -showTreasure.text=Afficher tr\xE9sors -showTreasure.mnemonic=T - -showConnected.text=Afficher objets connect\xE9s -showConnected.mnemonic=C - resetView.text=Vue normale resetView.mnemonic=N Modified: trunk/src/app/net/sf/gridarta/messages_sv.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-04-18 22:10:29 UTC (rev 3903) +++ trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-04-19 14:04:06 UTC (rev 3904) @@ -501,30 +501,8 @@ view.text=Visning view.mnemonic=V -showMonster.text=Monster -showMonster.mnemonic=M +show.text={0} -showExit.text=Utg\xE5ngar -showExit.mnemonic=U - -showBackground.text=Bakgrund -showBackground.mnemonic=B - -showDoor.text=D\xF6rrar och nycklar -showDoor.mnemonic=D - -showWall.text=V\xE4ggar -showWall.mnemonic=V - -showEquipment.text=Utrustning -showEquipment.mnemonic=R - -showTreasure.text=Skatter -showTreasure.mnemonic=S - -showConnected.text=Anslutna -showConnected.mnemonic=A - resetView.text=\xC5terst\xE4ll visning resetView.mnemonic=V This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-19 15:37:11
|
Revision: 3905 http://gridarta.svn.sourceforge.net/gridarta/?rev=3905&view=rev Author: akirschbaum Date: 2008-04-19 08:37:16 -0700 (Sat, 19 Apr 2008) Log Message: ----------- Sort 'Show xxx' menu entries by name. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gui/map/ViewActions.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-04-19 14:04:06 UTC (rev 3904) +++ trunk/crossfire/ChangeLog 2008-04-19 15:37:16 UTC (rev 3905) @@ -1,5 +1,7 @@ 2008-04-19 Andreas Kirschbaum + * Sort 'Show xxx' menu entries by name. + * Add more 'Show xxx' entries to View menu. * Remove 'View' menu from map windows. Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-04-19 14:04:06 UTC (rev 3904) +++ trunk/daimonin/ChangeLog 2008-04-19 15:37:16 UTC (rev 3905) @@ -1,3 +1,7 @@ +2008-04-19 Andreas Kirschbaum + + * Sort 'Show xxx' menu entries by name. + 2008-04-13 Andreas Kirschbaum * Fix crash when selecting from pickmaps. Modified: trunk/src/app/net/sf/gridarta/gui/map/ViewActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/ViewActions.java 2008-04-19 14:04:06 UTC (rev 3904) +++ trunk/src/app/net/sf/gridarta/gui/map/ViewActions.java 2008-04-19 15:37:16 UTC (rev 3905) @@ -20,6 +20,8 @@ package net.sf.gridarta.gui.map; import java.awt.event.ActionEvent; +import java.util.Arrays; +import java.util.Comparator; import java.util.LinkedList; import java.util.List; import javax.swing.AbstractAction; @@ -96,6 +98,18 @@ } /** + * The comparator for sorting menu entries. + */ + private static final Comparator<ViewAction> actionNameComparator = new Comparator<ViewAction>() { + + /** {@inheritDoc} */ + public int compare(final ViewAction o1, final ViewAction o2) { + return String.CASE_INSENSITIVE_ORDER.compare(o1.getName(), o2.getName()); + } + + }; + + /** * Creates the view actions. * @param gameObjectMatchers the game object matchers */ @@ -114,8 +128,10 @@ return; } + final ViewAction[] actions = viewActions.toArray(new ViewAction[viewActions.size()]); + Arrays.sort(actions, actionNameComparator); int index = 0; - for (final ViewAction viewAction : viewActions) { + for (final ViewAction viewAction : actions) { viewActionsMenu.add(viewAction.getCheckBoxMenuItem(), index++); } } @@ -157,6 +173,11 @@ @NotNull private final transient MainControl<?, ?, ?, ?, ?> mainControl; /** + * The name for sorting the menu entries. + */ + private final String name; + + /** * The managed edit type. */ private final int editType; @@ -174,10 +195,19 @@ public ViewAction(@NotNull final MainControl<?, ?, ?, ?, ?> mainControl, @NotNull final NamedGameObjectMatcher matcher) { super(ACTION_FACTORY.format("show.text", matcher.getName())); this.mainControl = mainControl; + name = matcher.getName(); this.editType = matcher.getEditType(); } /** + * Returns the name for sorting the menu entries. + * @return the name + */ + public String getName() { + return name; + } + + /** * Update the action's state to match the current edit type settings. */ public void updateAction() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-20 17:00:18
|
Revision: 3907 http://gridarta.svn.sourceforge.net/gridarta/?rev=3907&view=rev Author: akirschbaum Date: 2008-04-20 10:00:18 -0700 (Sun, 20 Apr 2008) Log Message: ----------- Unify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/src/app/net/sf/gridarta/MainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-20 15:58:33 UTC (rev 3906) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-20 17:00:18 UTC (rev 3907) @@ -380,7 +380,7 @@ specialTreasureLists = Collections.emptyMap(); } treasureListTree = new CFTreasureListTree<GameObject, MapArchObject, Archetype>(mainView, archetypeSet, specialTreasureLists, - new TreasureLocation(getConfigurationDirectory(), IGUIConstants.TREASURES_FILE) + new TreasureLocation(getCollectedDirectory(), IGUIConstants.TREASURES_FILE) ); recentManager.initRecent(); validators = createMapValidators(); @@ -504,7 +504,7 @@ collectables.add(animationObjects); collectables.add(faceObjects); collector.setCollectables(collectables); - collector.setDestDir(new File(getConfigurationDirectory())); + collector.setDestDir(new File(getCollectedDirectory())); collector.start(); } @@ -975,6 +975,11 @@ return "resource/conf"; } + /** {@inheritDoc} */ + @NotNull public String getCollectedDirectory() { + return getConfigurationDirectory(); + } + private List<?> getEventTypes() { final List<Object> result = new ArrayList<Object>(); for (int typeNumber = 1; ScriptArchData.typeArchName(typeNumber) != null; typeNumber++) { Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-04-20 15:58:33 UTC (rev 3906) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-04-20 17:00:18 UTC (rev 3907) @@ -156,7 +156,7 @@ try { // open the resource file - final BufferedReader stream = IOUtils.createReader(mainControl.getConfigurationDirectory(), IGUIConstants.ARCH_FILE); + final BufferedReader stream = IOUtils.createReader(mainControl.getCollectedDirectory(), IGUIConstants.ARCH_FILE); try { // load all arches archetypeParser.parseArchetypeFromStream(stream, "default", "default", null, invObjects); @@ -244,7 +244,7 @@ /** Loads all pngs from the big collected png file. */ @SuppressWarnings({"UnnecessaryLabelOnBreakStatement"}) private void loadAllCrossfirePNGFromCollect() { - final String baseDir = mainControl.getConfigurationDirectory(); + final String baseDir = mainControl.getCollectedDirectory(); final byte[] buf; try { final InputStream inputStream = IOUtils.createStream(baseDir, IGUIConstants.PNG_FILE); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-04-20 15:58:33 UTC (rev 3906) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-04-20 17:00:18 UTC (rev 3907) @@ -448,7 +448,7 @@ specialTreasureLists = Collections.emptyMap(); } treasureListTree = new CFTreasureListTree<GameObject, MapArchObject, Archetype>(mainView, archetypeSet, specialTreasureLists, - new TreasureLocation(getArchDefaultFolder(), IGUIConstants.TREASURES_FILE), + new TreasureLocation(getCollectedDirectory(), IGUIConstants.TREASURES_FILE), new TreasureLocation(getMapDefaultFolder(), null) ); recentManager.initRecent(); @@ -630,7 +630,7 @@ collectables.add(animationObjects); collectables.add(faceObjects); collector.setCollectables(collectables); - collector.setDestDir(new File(getArchDefaultFolder())); + collector.setDestDir(new File(getCollectedDirectory())); collector.start(); } @@ -1145,6 +1145,11 @@ } /** {@inheritDoc} */ + @NotNull public String getCollectedDirectory() { + return getArchDefaultFolder(); + } + + /** {@inheritDoc} */ public boolean isAutoJoin() { return mapActions.isAutoJoin(); } Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-04-20 15:58:33 UTC (rev 3906) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-04-20 17:00:18 UTC (rev 3907) @@ -170,7 +170,7 @@ } reportErrors(mainControl.getMainView()); - loadArchesFromArtifacts(archetypeParser, mainControl.getArchDefaultFolder() + "/" + IGUIConstants.ARTIFACTS_FILE, "Artifacts", "artifacts", invObjects); + loadArchesFromArtifacts(archetypeParser, mainControl.getCollectedDirectory() + "/" + IGUIConstants.ARTIFACTS_FILE, "Artifacts", "artifacts", invObjects); loadArchesFromArtifacts(archetypeParser, mainControl.getMapDefaultFolder(), "Artifacts", "maps", invObjects); mainControl.getGridartaObjectsFactory().newGameObjectParser().collectTempList(mainControl, invObjects, fname, true); @@ -310,12 +310,12 @@ animationObjects.loadAnimTree(new File(mainControl.getConfigurationDirectory(), IGUIConstants.ANIMTREE_FILE)); loadAllDaimoninAnimationsFromCollect(); // open the resource file - final String baseDir = mainControl.getArchDefaultFolder(); + final String baseDir = mainControl.getCollectedDirectory(); final BufferedReader stream = IOUtils.createReader(baseDir, IGUIConstants.ARCH_FILE); try { // load all arches archetypeParser.parseArchetypeFromStream(stream, "default", "default", IGUIConstants.ARCH_FILE, invObjects); - mainControl.getFaceObjects().loadFacesCollection(new File(mainControl.getArchDefaultFolder(), IGUIConstants.PNG_FILE), new File(mainControl.getConfigurationDirectory(), IGUIConstants.FACETREE_FILE)); + mainControl.getFaceObjects().loadFacesCollection(new File(mainControl.getCollectedDirectory(), IGUIConstants.PNG_FILE), new File(mainControl.getConfigurationDirectory(), IGUIConstants.FACETREE_FILE)); } finally { stream.close(); } @@ -408,7 +408,7 @@ @SuppressWarnings({"InstanceMethodNamingConvention"}) private void loadAllDaimoninAnimationsFromCollect() { try { - final Reader in = IOUtils.createReader(mainControl.getArchDefaultFolder(), "animations"); + final Reader in = IOUtils.createReader(mainControl.getCollectedDirectory(), "animations"); try { animationObjects.loadAnims(in, null); } finally { @@ -441,7 +441,7 @@ private void addPNGFace(final String filename, final String name) { final String facename = generateFaceName(name); ((ArchFaceProvider) FaceObjects.normal).addInfo(facename, filename); - final int stripPath = new File(mainControl.getArchDefaultFolder()).getAbsolutePath().length(); + final int stripPath = new File(mainControl.getCollectedDirectory()).getAbsolutePath().length(); try { mainControl.getFaceObjects().addFaceObject(facename, filename.substring(stripPath, filename.length() - 4).replace('\\', '/')); } catch (final DuplicateFaceException e) { Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-04-20 15:58:33 UTC (rev 3906) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-04-20 17:00:18 UTC (rev 3907) @@ -216,6 +216,12 @@ @NotNull String getConfigurationDirectory(); /** + * Returns the directory where collected archetypes are stored. + * @return the directory + */ + @NotNull String getCollectedDirectory(); + + /** * Get the map directory. * @return map directory */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-20 17:09:22
|
Revision: 3908 http://gridarta.svn.sourceforge.net/gridarta/?rev=3908&view=rev Author: akirschbaum Date: 2008-04-20 10:09:21 -0700 (Sun, 20 Apr 2008) Log Message: ----------- Unify code. 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-04-20 17:00:18 UTC (rev 3907) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-04-20 17:09:21 UTC (rev 3908) @@ -156,7 +156,8 @@ try { // open the resource file - final BufferedReader stream = IOUtils.createReader(mainControl.getCollectedDirectory(), IGUIConstants.ARCH_FILE); + final String baseDir = mainControl.getCollectedDirectory(); + final BufferedReader stream = IOUtils.createReader(baseDir, IGUIConstants.ARCH_FILE); try { // load all arches archetypeParser.parseArchetypeFromStream(stream, "default", "default", null, invObjects); Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-04-20 17:00:18 UTC (rev 3907) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-04-20 17:09:21 UTC (rev 3908) @@ -315,7 +315,7 @@ try { // load all arches archetypeParser.parseArchetypeFromStream(stream, "default", "default", IGUIConstants.ARCH_FILE, invObjects); - mainControl.getFaceObjects().loadFacesCollection(new File(mainControl.getCollectedDirectory(), IGUIConstants.PNG_FILE), new File(mainControl.getConfigurationDirectory(), IGUIConstants.FACETREE_FILE)); + mainControl.getFaceObjects().loadFacesCollection(new File(baseDir, IGUIConstants.PNG_FILE), new File(mainControl.getConfigurationDirectory(), IGUIConstants.FACETREE_FILE)); } finally { stream.close(); } @@ -407,8 +407,9 @@ /** Loading all animations from the big collected animations file. */ @SuppressWarnings({"InstanceMethodNamingConvention"}) private void loadAllDaimoninAnimationsFromCollect() { + final String baseDir = mainControl.getCollectedDirectory(); try { - final Reader in = IOUtils.createReader(mainControl.getCollectedDirectory(), "animations"); + final Reader in = IOUtils.createReader(baseDir, "animations"); try { animationObjects.loadAnims(in, null); } finally { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-20 17:27:08
|
Revision: 3909 http://gridarta.svn.sourceforge.net/gridarta/?rev=3909&view=rev Author: akirschbaum Date: 2008-04-20 10:27:09 -0700 (Sun, 20 Apr 2008) Log Message: ----------- Move CMainControl.collectArches() to MainActions.collectArches(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/DaimoninEditor.java trunk/src/app/net/sf/gridarta/MainControl.java trunk/src/app/net/sf/gridarta/gui/MainActions.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-20 17:09:21 UTC (rev 3908) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-20 17:27:09 UTC (rev 3909) @@ -55,8 +55,6 @@ import net.sf.gridarta.CommonConstants; import net.sf.gridarta.MainControl; import net.sf.gridarta.XmlHelper; -import net.sf.gridarta.gameobject.Collectable; -import net.sf.gridarta.gameobject.Collector; import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gameobject.match.GameObjectMatchers; import net.sf.gridarta.gui.About; @@ -103,7 +101,6 @@ import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; import net.sf.japi.swing.misc.Progress; -import net.sf.japi.swing.misc.ProgressDisplay; import net.sf.japi.swing.prefs.PreferencesGroup; import net.sf.japi.swing.prefs.PreferencesPane; import net.sf.japi.swing.tod.TipOfTheDayManager; @@ -487,27 +484,6 @@ mainView.setStatusText("Garbage collection - done."); } - /** {@inheritDoc} */ - public void collectArches() { - final Progress progress = new ProgressDisplay(mainView, ACTION_FACTORY.getString("archCollectTitle"), 0, ACTION_FACTORY.getString("archCollectArches")); - collectArches(progress); - } - - /** - * Collect CF arches, animations and faces. - * @param progress Progress to use for showing the progress. - */ - public void collectArches(final Progress progress) { - final List<Collectable> collectables = new ArrayList<Collectable>(); - final Collector collector = new Collector(progress); - collectables.add(getArchetypeSet()); - collectables.add(animationObjects); - collectables.add(faceObjects); - collector.setCollectables(collectables); - collector.setDestDir(new File(getCollectedDirectory())); - collector.start(); - } - /** View Treasure Lists. */ @ActionMethod public void viewTreasurelists() { treasureListTree.showDialog(); @@ -1004,4 +980,9 @@ return selectedSquareControl; } + /** {@inheritDoc} */ + @NotNull public MainActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> getMainActions() { + return mainActions; + } + } // class CMainControl Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-04-20 17:09:21 UTC (rev 3908) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-04-20 17:27:09 UTC (rev 3909) @@ -60,8 +60,6 @@ import net.sf.gridarta.CommonConstants; import net.sf.gridarta.MainControl; import net.sf.gridarta.XmlHelper; -import net.sf.gridarta.gameobject.Collectable; -import net.sf.gridarta.gameobject.Collector; import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gameobject.match.GameObjectMatchers; import net.sf.gridarta.gameobject.match.MutableOrGameObjectMatcher; @@ -119,8 +117,6 @@ import net.sf.gridarta.updater.UpdaterManager; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; -import net.sf.japi.swing.misc.Progress; -import net.sf.japi.swing.misc.ProgressDisplay; import net.sf.japi.swing.prefs.PreferencesGroup; import net.sf.japi.swing.prefs.PreferencesPane; import net.sf.japi.swing.tod.TipOfTheDayManager; @@ -613,27 +609,6 @@ controlClient.showDialog(mainView); } - /** {@inheritDoc} */ - public void collectArches() { - final Progress progress = new ProgressDisplay(mainView, ACTION_FACTORY.getString("archCollectTitle"), 0, ACTION_FACTORY.getString("archCollectArches")); - collectArches(progress); - } - - /** - * Collect CF arches, animations and faces. - * @param progress Progress to use for showing the progress. - */ - public void collectArches(final Progress progress) { - final List<Collectable> collectables = new ArrayList<Collectable>(); - final Collector collector = new Collector(progress); - collectables.add(getArchetypeSet()); - collectables.add(animationObjects); - collectables.add(faceObjects); - collector.setCollectables(collectables); - collector.setDestDir(new File(getCollectedDirectory())); - collector.start(); - } - /** Collect Spells. */ @ActionMethod public void collectSpells() { numberSpells.importSpellsWanted(this); @@ -1164,4 +1139,9 @@ return selectedSquareControl; } + /** {@inheritDoc} */ + @NotNull public MainActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> getMainActions() { + return mainActions; + } + } // class CMainControl Modified: trunk/daimonin/src/daieditor/DaimoninEditor.java =================================================================== --- trunk/daimonin/src/daieditor/DaimoninEditor.java 2008-04-20 17:09:21 UTC (rev 3908) +++ trunk/daimonin/src/daieditor/DaimoninEditor.java 2008-04-20 17:27:09 UTC (rev 3909) @@ -249,7 +249,7 @@ * @todo allow arch collection to be configured (input directories, output directory) */ private int runCollectArches(@NotNull final List<String> args) throws Exception { - mainControl.collectArches(new ConsoleProgress()); + mainControl.getMainActions().collectArches(new ConsoleProgress()); return 0; } Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-04-20 17:09:21 UTC (rev 3908) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-04-20 17:27:09 UTC (rev 3909) @@ -28,6 +28,7 @@ import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gameobject.anim.AbstractAnimationObjects; import net.sf.gridarta.gameobject.face.AbstractFaceObjects; +import net.sf.gridarta.gui.MainActions; import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.map.MapPreviewAccessory; @@ -294,11 +295,6 @@ void reloadFaces(); /** - * Collect archetypes, animations and faces. - */ - void collectArches(); - - /** * Return the autojoin lists. * * @return The autojoin lists. @@ -326,4 +322,10 @@ */ @NotNull SelectedSquareControl<G, A, R, C, V> getSelectedSquareControl(); + /** + * Returns the main actions. + * @return the main actions + */ + @NotNull MainActions<G, A, R, C, V> getMainActions(); + } // interface MainControl Modified: trunk/src/app/net/sf/gridarta/gui/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-04-20 17:09:21 UTC (rev 3908) +++ trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-04-20 17:27:09 UTC (rev 3909) @@ -19,6 +19,9 @@ package net.sf.gridarta.gui; +import java.io.File; +import java.util.ArrayList; +import java.util.List; import javax.swing.Action; import javax.swing.JOptionPane; import net.sf.gridarta.MainControl; @@ -26,6 +29,8 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.ArchetypeSetListener; +import net.sf.gridarta.gameobject.Collectable; +import net.sf.gridarta.gameobject.Collector; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapCursorListener; @@ -41,6 +46,8 @@ import net.sf.gridarta.map.MapModelListener; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; +import net.sf.japi.swing.misc.Progress; +import net.sf.japi.swing.misc.ProgressDisplay; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -53,6 +60,9 @@ /** The MainControl. */ private final MainControl<G, A, R, C, V> mainControl; + /** The ActionFactory. */ + @NotNull private final ActionFactory actionFactory; + /** Action called for "clear". */ private final Action aClear; @@ -258,6 +268,7 @@ */ public MainActions(@NotNull final MainControl<G, A, R, C, V> mainControl, @NotNull final ActionFactory actionFactory) { this.mainControl = mainControl; + this.actionFactory = actionFactory; aClear = actionFactory.createAction(true, "clear", this); aCut = actionFactory.createAction(true, "cut", this); aCopy = actionFactory.createAction(true, "copy", this); @@ -525,9 +536,22 @@ /** Invoked when "collect archetypes" was selected. */ @ActionMethod public void collectArches() { - mainControl.collectArches(); + final Progress progress = new ProgressDisplay(mainControl.getMainView(), actionFactory.getString("archCollectTitle"), 0, actionFactory.getString("archCollectArches")); + collectArches(progress); } + /** {@inheritDoc} */ + public void collectArches(final Progress progress) { + final List<Collectable> collectables = new ArrayList<Collectable>(); + final Collector collector = new Collector(progress); + collectables.add(mainControl.getArchetypeSet()); + collectables.add(mainControl.getAnimationObjects()); + collectables.add(mainControl.getFaceObjects()); + collector.setCollectables(collectables); + collector.setDestDir(new File(mainControl.getCollectedDirectory())); + collector.start(); + } + /** Invoked when the user wants to reload the images. */ public void reloadFaces() { mainControl.reloadFaces(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-20 17:41:26
|
Revision: 3910 http://gridarta.svn.sourceforge.net/gridarta/?rev=3910&view=rev Author: akirschbaum Date: 2008-04-20 10:41:31 -0700 (Sun, 20 Apr 2008) Log Message: ----------- Disable menu entry 'Collect archetypes' while collection is in progress. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gui/MainActions.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-04-20 17:27:09 UTC (rev 3909) +++ trunk/crossfire/ChangeLog 2008-04-20 17:41:31 UTC (rev 3910) @@ -1,3 +1,8 @@ +2008-04-20 Andreas Kirschbaum + + * Disable menu entry 'Collect archetypes' while collection is in + progress. + 2008-04-19 Andreas Kirschbaum * Sort 'Show xxx' menu entries by name. Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-04-20 17:27:09 UTC (rev 3909) +++ trunk/daimonin/ChangeLog 2008-04-20 17:41:31 UTC (rev 3910) @@ -1,3 +1,8 @@ +2008-04-20 Andreas Kirschbaum + + * Disable menu entry 'Collect archetypes' while collection is in + progress. + 2008-04-19 Andreas Kirschbaum * Sort 'Show xxx' menu entries by name. Modified: trunk/src/app/net/sf/gridarta/gui/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-04-20 17:27:09 UTC (rev 3909) +++ trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-04-20 17:41:31 UTC (rev 3910) @@ -19,6 +19,7 @@ package net.sf.gridarta.gui; +import java.awt.Component; import java.io.File; import java.util.ArrayList; import java.util.List; @@ -141,6 +142,12 @@ @Nullable private MapView<G, A, R, C, V> currentMapView; /** + * The progress tracker if an archetype collection is running, or else + * <code>null</code>. + */ + private Progress collectArches = null; + + /** * The map manager listener to detect created and closed map views. */ private final MapManagerListener<G, A, R, C, V> mapManagerListener = new MapManagerListener<G, A, R, C, V>() { @@ -328,7 +335,7 @@ aRandFillBelow.setEnabled(getRandFillBelowEnabled() != null); aFloodfill.setEnabled(getFloodfillEnabled() != null); aSelectAll.setEnabled(getSelectAllEnabled() != null); - aCollectArches.setEnabled(!mainControl.getArchetypeSet().isLoadedFromArchive()); + aCollectArches.setEnabled(isCollectArchesEnabled()); aReloadFaces.setEnabled(!mainControl.getArchetypeSet().isLoadedFromArchive()); aValidateMap.setEnabled(getValidateMapEnabled() != null); } @@ -541,9 +548,41 @@ } /** {@inheritDoc} */ - public void collectArches(final Progress progress) { + public synchronized void collectArches(final Progress progress) { + if (collectArches != null) { + progress.finished(); + return; + } + + collectArches = new Progress() { + + /** {@inheritDoc} */ + public void finished() { + progress.finished(); + collectArches = null; + aCollectArches.setEnabled(isCollectArchesEnabled()); + } + + /** {@inheritDoc} */ + public Component getParentComponent() { + return progress.getParentComponent(); + } + + /** {@inheritDoc} */ + public void setLabel(final String msg, final int max) { + progress.setLabel(msg, max); + } + + /** {@inheritDoc} */ + public void setValue(final int value) { + progress.setValue(value); + } + + }; + aCollectArches.setEnabled(isCollectArchesEnabled()); + final List<Collectable> collectables = new ArrayList<Collectable>(); - final Collector collector = new Collector(progress); + final Collector collector = new Collector(collectArches); collectables.add(mainControl.getArchetypeSet()); collectables.add(mainControl.getAnimationObjects()); collectables.add(mainControl.getFaceObjects()); @@ -686,6 +725,14 @@ } /** + * Returns whether "collect archetypes" is enabled. + * @return whether "collect archetypes" is enabled + */ + private boolean isCollectArchesEnabled() { + return collectArches == null && !mainControl.getArchetypeSet().isLoadedFromArchive(); + } + + /** * Determine if "validate map" is enabled. * @return The map model to check if "validate map" is enabled, or * <code>null</code> otherwise. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-26 06:43:27
|
Revision: 3918 http://gridarta.svn.sourceforge.net/gridarta/?rev=3918&view=rev Author: akirschbaum Date: 2008-04-25 23:43:34 -0700 (Fri, 25 Apr 2008) Log Message: ----------- Make autojoin code work in Daimonin editor. Modified Paths: -------------- trunk/daimonin/src/daieditor/gui/map/tools/DeletionTool.java trunk/src/app/net/sf/gridarta/AutojoinList.java Modified: trunk/daimonin/src/daieditor/gui/map/tools/DeletionTool.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/DeletionTool.java 2008-04-25 23:33:26 UTC (rev 3917) +++ trunk/daimonin/src/daieditor/gui/map/tools/DeletionTool.java 2008-04-26 06:43:34 UTC (rev 3918) @@ -101,7 +101,7 @@ } if (delArch != null) { mapSquare.getModel().beginTransaction("Delete Object"); - delArch.remove(); + mapSquare.getModel().deleteMapArch(delArch, mapLoc, true); mapSquare.getModel().endTransaction(); } } Modified: trunk/src/app/net/sf/gridarta/AutojoinList.java =================================================================== --- trunk/src/app/net/sf/gridarta/AutojoinList.java 2008-04-25 23:33:26 UTC (rev 3917) +++ trunk/src/app/net/sf/gridarta/AutojoinList.java 2008-04-26 06:43:34 UTC (rev 3918) @@ -196,6 +196,7 @@ // set face of new default arch gameObject.setFaceName(null); // take default face + gameObject.setObjectFace(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-05-02 19:51:18
|
Revision: 3920 http://gridarta.svn.sourceforge.net/gridarta/?rev=3920&view=rev Author: akirschbaum Date: 2008-05-02 12:51:22 -0700 (Fri, 02 May 2008) Log Message: ----------- Reorder import statements. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java trunk/src/app/net/sf/gridarta/MapImageCache.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchers.java trunk/src/app/net/sf/gridarta/gui/map/ViewActions.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Model.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Pickmap.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapSelectionListener.java trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java trunk/src/app/net/sf/gridarta/io/GameObjectParser.java trunk/src/app/net/sf/gridarta/io/MapArchObjectParser.java trunk/src/app/net/sf/gridarta/map/AutoValidator.java trunk/src/app/net/sf/gridarta/textedit/textarea/actions/Replace.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-26 08:21:15 UTC (rev 3919) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-05-02 19:51:22 UTC (rev 3920) @@ -82,8 +82,8 @@ import net.sf.gridarta.map.validation.ErrorCollector; import net.sf.gridarta.map.validation.checks.AttributeRangeChecker; import net.sf.gridarta.map.validation.checks.ConnectedInsideContainerChecker; -import net.sf.gridarta.map.validation.checks.ConnectionChecker; import net.sf.gridarta.map.validation.checks.ConnectedPickableChecker; +import net.sf.gridarta.map.validation.checks.ConnectionChecker; import net.sf.gridarta.map.validation.checks.CustomTypeChecker; import net.sf.gridarta.map.validation.checks.MapDifficultyChecker; import net.sf.gridarta.map.validation.checks.UndefinedArchetypeChecker; @@ -100,7 +100,6 @@ import net.sf.gridarta.updater.UpdaterManager; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; -import net.sf.japi.swing.misc.Progress; import net.sf.japi.swing.prefs.PreferencesGroup; import net.sf.japi.swing.prefs.PreferencesPane; import net.sf.japi.swing.tod.TipOfTheDayManager; Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-04-26 08:21:15 UTC (rev 3919) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-05-02 19:51:22 UTC (rev 3920) @@ -32,9 +32,9 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.prefs.Preferences; import java.util.prefs.PreferenceChangeEvent; import java.util.prefs.PreferenceChangeListener; +import java.util.prefs.Preferences; import javax.swing.Action; import javax.swing.ImageIcon; import javax.swing.JMenu; Modified: trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-04-26 08:21:15 UTC (rev 3919) +++ trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-05-02 19:51:22 UTC (rev 3920) @@ -19,10 +19,6 @@ package cfeditor; -import java.io.File; -import java.io.FileNotFoundException; -import java.util.List; -import java.util.prefs.Preferences; import cfeditor.gameobject.Archetype; import cfeditor.gameobject.GameObject; import cfeditor.gameobject.UndefinedArchetype; @@ -30,6 +26,10 @@ import cfeditor.io.MapArchObjectParser; import cfeditor.map.MapArchObject; import cfeditor.map.MapControl; +import java.io.File; +import java.io.FileNotFoundException; +import java.util.List; +import java.util.prefs.Preferences; import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.GridartaObjectsFactory; import net.sf.gridarta.MainControl; Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-04-26 08:21:15 UTC (rev 3919) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-05-02 19:51:22 UTC (rev 3920) @@ -41,10 +41,8 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.List; import java.util.Map; import java.util.MissingResourceException; import java.util.ResourceBundle; Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-04-26 08:21:15 UTC (rev 3919) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-05-02 19:51:22 UTC (rev 3920) @@ -32,9 +32,9 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.prefs.Preferences; import java.util.prefs.PreferenceChangeEvent; import java.util.prefs.PreferenceChangeListener; +import java.util.prefs.Preferences; import javax.swing.Action; import javax.swing.ImageIcon; import javax.swing.JMenu; Modified: trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java =================================================================== --- trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java 2008-04-26 08:21:15 UTC (rev 3919) +++ trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java 2008-05-02 19:51:22 UTC (rev 3920) @@ -19,10 +19,6 @@ package daieditor; -import java.io.File; -import java.io.FileNotFoundException; -import java.util.List; -import java.util.prefs.Preferences; import daieditor.gameobject.Archetype; import daieditor.gameobject.GameObject; import daieditor.gameobject.UndefinedArchetype; @@ -30,6 +26,10 @@ import daieditor.io.MapArchObjectParser; import daieditor.map.MapArchObject; import daieditor.map.MapControl; +import java.io.File; +import java.io.FileNotFoundException; +import java.util.List; +import java.util.prefs.Preferences; import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.GridartaObjectsFactory; import net.sf.gridarta.MainControl; Modified: trunk/src/app/net/sf/gridarta/MapImageCache.java =================================================================== --- trunk/src/app/net/sf/gridarta/MapImageCache.java 2008-04-26 08:21:15 UTC (rev 3919) +++ trunk/src/app/net/sf/gridarta/MapImageCache.java 2008-05-02 19:51:22 UTC (rev 3920) @@ -29,11 +29,11 @@ import java.util.Map; import javax.imageio.ImageIO; import javax.swing.ImageIcon; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; -import net.sf.gridarta.map.MapArchObject; -import net.sf.gridarta.gui.map.MapViewBasic; -import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gameobject.Archetype; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-04-26 08:21:15 UTC (rev 3919) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-05-02 19:51:22 UTC (rev 3920) @@ -26,8 +26,8 @@ import net.sf.gridarta.CFArchType; import net.sf.gridarta.CFArchTypeList; import net.sf.gridarta.gameobject.match.GameObjectMatchers; +import net.sf.gridarta.gui.GUIConstants; import net.sf.gridarta.gui.GameObjectAttributesPanel; -import net.sf.gridarta.gui.GUIConstants; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapSquare; import org.jetbrains.annotations.NotNull; Modified: trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchers.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchers.java 2008-04-26 08:21:15 UTC (rev 3919) +++ trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchers.java 2008-05-02 19:51:22 UTC (rev 3920) @@ -28,7 +28,6 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.xpath.XPath; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gui.GUIConstants; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; Modified: trunk/src/app/net/sf/gridarta/gui/map/ViewActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/ViewActions.java 2008-04-26 08:21:15 UTC (rev 3919) +++ trunk/src/app/net/sf/gridarta/gui/map/ViewActions.java 2008-05-02 19:51:22 UTC (rev 3920) @@ -34,11 +34,9 @@ import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gameobject.match.GameObjectMatchers; import net.sf.gridarta.gameobject.match.NamedGameObjectMatcher; -import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.ToggleAction; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Model.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Model.java 2008-04-26 08:21:15 UTC (rev 3919) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Model.java 2008-05-02 19:51:22 UTC (rev 3920) @@ -22,8 +22,8 @@ import java.io.File; import java.util.Collection; import java.util.Collections; +import java.util.Iterator; import java.util.Map; -import java.util.Iterator; import java.util.TreeMap; import javax.swing.event.EventListenerList; import net.sf.gridarta.gameobject.Archetype; Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Pickmap.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Pickmap.java 2008-04-26 08:21:15 UTC (rev 3919) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Pickmap.java 2008-05-02 19:51:22 UTC (rev 3920) @@ -26,9 +26,9 @@ import net.sf.gridarta.GridartaObjectsFactory; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.io.MapReader; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.io.MapReader; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; import org.jetbrains.annotations.NotNull; Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapSelectionListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapSelectionListener.java 2008-04-26 08:21:15 UTC (rev 3919) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapSelectionListener.java 2008-05-02 19:51:22 UTC (rev 3920) @@ -19,7 +19,6 @@ package net.sf.gridarta.gui.pickmapchooser; -import net.sf.gridarta.map.MapControl; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import net.sf.gridarta.gameobject.Archetype; @@ -27,6 +26,7 @@ import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapControl; import org.jetbrains.annotations.NotNull; /** Modified: trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java 2008-04-26 08:21:15 UTC (rev 3919) +++ trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java 2008-05-02 19:51:22 UTC (rev 3920) @@ -26,8 +26,8 @@ import java.util.List; import java.util.Set; import java.util.TreeSet; +import net.sf.gridarta.GridartaObjectsFactory; import net.sf.gridarta.MainControl; -import net.sf.gridarta.GridartaObjectsFactory; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapArchObject; Modified: trunk/src/app/net/sf/gridarta/io/GameObjectParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/GameObjectParser.java 2008-04-26 08:21:15 UTC (rev 3919) +++ trunk/src/app/net/sf/gridarta/io/GameObjectParser.java 2008-05-02 19:51:22 UTC (rev 3920) @@ -19,8 +19,8 @@ package net.sf.gridarta.io; +import java.io.BufferedReader; import java.io.IOException; -import java.io.BufferedReader; import java.util.Collection; import java.util.List; import net.sf.gridarta.MainControl; Modified: trunk/src/app/net/sf/gridarta/io/MapArchObjectParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/MapArchObjectParser.java 2008-04-26 08:21:15 UTC (rev 3919) +++ trunk/src/app/net/sf/gridarta/io/MapArchObjectParser.java 2008-05-02 19:51:22 UTC (rev 3920) @@ -19,8 +19,8 @@ package net.sf.gridarta.io; +import java.io.BufferedReader; import java.io.IOException; -import java.io.BufferedReader; import net.sf.gridarta.map.MapArchObject; import org.jetbrains.annotations.NotNull; Modified: trunk/src/app/net/sf/gridarta/map/AutoValidator.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AutoValidator.java 2008-04-26 08:21:15 UTC (rev 3919) +++ trunk/src/app/net/sf/gridarta/map/AutoValidator.java 2008-05-02 19:51:22 UTC (rev 3920) @@ -21,9 +21,9 @@ import java.util.IdentityHashMap; import java.util.Map; +import java.util.prefs.PreferenceChangeEvent; +import java.util.prefs.PreferenceChangeListener; import java.util.prefs.Preferences; -import java.util.prefs.PreferenceChangeListener; -import java.util.prefs.PreferenceChangeEvent; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.gameobject.Archetype; Modified: trunk/src/app/net/sf/gridarta/textedit/textarea/actions/Replace.java =================================================================== --- trunk/src/app/net/sf/gridarta/textedit/textarea/actions/Replace.java 2008-04-26 08:21:15 UTC (rev 3919) +++ trunk/src/app/net/sf/gridarta/textedit/textarea/actions/Replace.java 2008-05-02 19:51:22 UTC (rev 3920) @@ -28,8 +28,8 @@ import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JOptionPane; +import javax.swing.JPanel; import javax.swing.JTextField; -import javax.swing.JPanel; import javax.swing.WindowConstants; import net.sf.gridarta.textedit.textarea.InputHandler; import net.sf.gridarta.textedit.textarea.JEditTextArea; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-05-02 22:23:15
|
Revision: 3921 http://gridarta.svn.sourceforge.net/gridarta/?rev=3921&view=rev Author: akirschbaum Date: 2008-05-02 15:23:13 -0700 (Fri, 02 May 2008) Log Message: ----------- Wait until archetype collection has finished before exiting the application. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/ChangeLog trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/gameobject/Collector.java trunk/src/app/net/sf/gridarta/gui/MainActions.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-05-02 19:51:22 UTC (rev 3920) +++ trunk/crossfire/ChangeLog 2008-05-02 22:23:13 UTC (rev 3921) @@ -1,3 +1,8 @@ +2008-05-03 Andreas Kirschbaum + + * Wait until archetype collection has finished before exiting the + application. + 2008-04-20 Andreas Kirschbaum * Disable menu entry 'Collect archetypes' while collection is in Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-05-02 19:51:22 UTC (rev 3920) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-05-02 22:23:13 UTC (rev 3921) @@ -38,6 +38,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -48,6 +49,7 @@ import javax.swing.JFileChooser; import javax.swing.JMenu; import javax.swing.JOptionPane; +import javax.swing.SwingUtilities; import javax.swing.filechooser.FileFilter; import javax.xml.parsers.ParserConfigurationException; import net.sf.gridarta.AbstractMainControl; @@ -844,17 +846,40 @@ /** {@inheritDoc} */ public void doExit() { + mainView.setEnabled(false); appExitNotify(); ScriptEditControl.getInstance().appExitNotify(); - mainView.dispose(); - if (prefs.getBoolean(PREFS_SYSTEM_EXIT, PREFS_SYSTEM_EXIT_DEFAULT)) { - if (log.isDebugEnabled()) { - log.debug(ACTION_FACTORY.getString("logExitWithExit")); - } - System.exit(0); - } else { - log.debug(ACTION_FACTORY.getString("logExitWithoutExit")); - } + final Thread thread = new Thread() { + /** {@inheritDoc} */ + public void run() { + try { + mainActions.waitUntilArchCollectionFinished(); + } catch (final InterruptedException ex) { + log.warn("Archetype collection was interrupted"); + } + try { + SwingUtilities.invokeAndWait(new Runnable() { + /** {@inheritDoc} */ + public void run() { + mainView.dispose(); + } + }); + } catch (final InterruptedException ex) { + log.warn("Cannot destroy main view: " + ex.getMessage()); + } catch (final InvocationTargetException ex) { + log.warn("Cannot destroy main view: " + ex.getMessage()); + } + if (prefs.getBoolean(PREFS_SYSTEM_EXIT, PREFS_SYSTEM_EXIT_DEFAULT)) { + if (log.isDebugEnabled()) { + log.debug(ACTION_FACTORY.getString("logExitWithExit")); + } + System.exit(0); + } else { + log.debug(ACTION_FACTORY.getString("logExitWithoutExit")); + } + }; + }; + thread.start(); } /** {@inheritDoc} */ Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-05-02 19:51:22 UTC (rev 3920) +++ trunk/daimonin/ChangeLog 2008-05-02 22:23:13 UTC (rev 3921) @@ -1,3 +1,8 @@ +2008-05-03 Andreas Kirschbaum + + * Wait until archetype collection has finished before exiting the + application. + 2008-04-26 Andreas Kirschbaum * Implement autojoin feature for easier wall creation. If Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-05-02 19:51:22 UTC (rev 3920) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-05-02 22:23:13 UTC (rev 3921) @@ -41,6 +41,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import java.util.Arrays; import java.util.Collections; import java.util.Map; @@ -51,6 +52,7 @@ import javax.swing.JFileChooser; import javax.swing.JMenu; import javax.swing.JOptionPane; +import javax.swing.SwingUtilities; import javax.swing.filechooser.FileFilter; import javax.xml.parsers.ParserConfigurationException; import net.sf.gridarta.AbstractMainControl; @@ -1010,17 +1012,40 @@ /** {@inheritDoc} */ public void doExit() { + mainView.setEnabled(false); appExitNotify(); ScriptEditControl.getInstance().appExitNotify(); - mainView.dispose(); - if (prefs.getBoolean(PREFS_SYSTEM_EXIT, PREFS_SYSTEM_EXIT_DEFAULT)) { - if (log.isDebugEnabled()) { - log.debug(ACTION_FACTORY.getString("logExitWithExit")); - } - System.exit(0); - } else { - log.debug(ACTION_FACTORY.getString("logExitWithoutExit")); - } + final Thread thread = new Thread() { + /** {@inheritDoc} */ + public void run() { + try { + mainActions.waitUntilArchCollectionFinished(); + } catch (final InterruptedException ex) { + log.warn("Archetype collection was interrupted"); + } + try { + SwingUtilities.invokeAndWait(new Runnable() { + /** {@inheritDoc} */ + public void run() { + mainView.dispose(); + } + }); + } catch (final InterruptedException ex) { + log.warn("Cannot destroy main view: " + ex.getMessage()); + } catch (final InvocationTargetException ex) { + log.warn("Cannot destroy main view: " + ex.getMessage()); + } + if (prefs.getBoolean(PREFS_SYSTEM_EXIT, PREFS_SYSTEM_EXIT_DEFAULT)) { + if (log.isDebugEnabled()) { + log.debug(ACTION_FACTORY.getString("logExitWithExit")); + } + System.exit(0); + } else { + log.debug(ACTION_FACTORY.getString("logExitWithoutExit")); + } + }; + }; + thread.start(); } /** {@inheritDoc} */ Modified: trunk/src/app/net/sf/gridarta/gameobject/Collector.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/Collector.java 2008-05-02 19:51:22 UTC (rev 3920) +++ trunk/src/app/net/sf/gridarta/gameobject/Collector.java 2008-05-02 22:23:13 UTC (rev 3921) @@ -45,6 +45,11 @@ /** The Progress to use. */ private final Progress progress; + /** + * The worker thread, or <code>null</code> if not running. + */ + private Thread thread = null; + /** Create a Collector. * @param progress Progress to use. */ @@ -72,10 +77,26 @@ /** * Starts collecting. */ - public void start() { - new Thread(this).start(); + public synchronized void start() { + if (thread != null) { + throw new IllegalStateException(); + } + + thread = new Thread(this); + thread.start(); } + /** + * Waits until collection has finished. + * @throws InterruptedException if waiting was interrupted + */ + public synchronized void waitUntilFinished() throws InterruptedException { + if (thread != null) { + thread.join(); + assert thread == null; + } + } + /* * Collect the existing arches and create archive-files for editor use as * well as the Crossfire or Daimonin server. The arches also get a special path variable @@ -86,15 +107,19 @@ /** {@inheritDoc} */ public void run() { try { - for (final Collectable collectable : collectables) { - try { - collectable.collect(progress, destDir); - } catch (final IOException e) { - ACTION_FACTORY.showMessageDialog(progress.getParentComponent(), "archCollectErrorIOException", "arches, animations and animtree, images", e); + try { + for (final Collectable collectable : collectables) { + try { + collectable.collect(progress, destDir); + } catch (final IOException e) { + ACTION_FACTORY.showMessageDialog(progress.getParentComponent(), "archCollectErrorIOException", "arches, animations and animtree, images", e); + } } + } finally { + progress.finished(); } } finally { - progress.finished(); + thread = null; } //mainControl.setStatusText(ACTION_FACTORY.getString("archCollectDone")); } Modified: trunk/src/app/net/sf/gridarta/gui/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-05-02 19:51:22 UTC (rev 3920) +++ trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-05-02 22:23:13 UTC (rev 3921) @@ -142,10 +142,10 @@ @Nullable private MapView<G, A, R, C, V> currentMapView; /** - * The progress tracker if an archetype collection is running, or else + * The {@link Collector} if an archetype collection is running, or else * <code>null</code>. */ - private Progress collectArches = null; + private Collector collector = null; /** * The map manager listener to detect created and closed map views. @@ -549,17 +549,17 @@ /** {@inheritDoc} */ public synchronized void collectArches(final Progress progress) { - if (collectArches != null) { + if (collector != null) { progress.finished(); return; } - collectArches = new Progress() { + final Progress collectArches = new Progress() { /** {@inheritDoc} */ public void finished() { progress.finished(); - collectArches = null; + collector = null; aCollectArches.setEnabled(isCollectArchesEnabled()); } @@ -579,18 +579,29 @@ } }; - aCollectArches.setEnabled(isCollectArchesEnabled()); final List<Collectable> collectables = new ArrayList<Collectable>(); - final Collector collector = new Collector(collectArches); + collector = new Collector(collectArches); collectables.add(mainControl.getArchetypeSet()); collectables.add(mainControl.getAnimationObjects()); collectables.add(mainControl.getFaceObjects()); collector.setCollectables(collectables); collector.setDestDir(new File(mainControl.getCollectedDirectory())); collector.start(); + aCollectArches.setEnabled(isCollectArchesEnabled()); } + /** + * Blocks until archetype collection has finished. + * @throws InterruptedException if waiting was interrupted + */ + public void waitUntilArchCollectionFinished() throws InterruptedException { + final Collector tmp = collector; + if (tmp != null) { + tmp.waitUntilFinished(); + } + } + /** Invoked when the user wants to reload the images. */ public void reloadFaces() { mainControl.reloadFaces(); @@ -729,7 +740,7 @@ * @return whether "collect archetypes" is enabled */ private boolean isCollectArchesEnabled() { - return collectArches == null && !mainControl.getArchetypeSet().isLoadedFromArchive(); + return collector == null && !mainControl.getArchetypeSet().isLoadedFromArchive(); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-05-02 23:27:34
|
Revision: 3929 http://gridarta.svn.sourceforge.net/gridarta/?rev=3929&view=rev Author: akirschbaum Date: 2008-05-02 16:27:32 -0700 (Fri, 02 May 2008) Log Message: ----------- Make fields private. Modified Paths: -------------- trunk/crossfire/src/cfeditor/filter/NamedGameObjectMatcherFilter.java trunk/crossfire/src/cfeditor/script/parameter/ArchParameter.java trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialogFactory.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java Modified: trunk/crossfire/src/cfeditor/filter/NamedGameObjectMatcherFilter.java =================================================================== --- trunk/crossfire/src/cfeditor/filter/NamedGameObjectMatcherFilter.java 2008-05-02 23:23:18 UTC (rev 3928) +++ trunk/crossfire/src/cfeditor/filter/NamedGameObjectMatcherFilter.java 2008-05-02 23:27:32 UTC (rev 3929) @@ -42,7 +42,7 @@ /** * The game object matcher to use. */ - @NotNull final NamedGameObjectMatcher matcher; + @NotNull private final NamedGameObjectMatcher matcher; /** * Create a new instance. Modified: trunk/crossfire/src/cfeditor/script/parameter/ArchParameter.java =================================================================== --- trunk/crossfire/src/cfeditor/script/parameter/ArchParameter.java 2008-05-02 23:23:18 UTC (rev 3928) +++ trunk/crossfire/src/cfeditor/script/parameter/ArchParameter.java 2008-05-02 23:27:32 UTC (rev 3929) @@ -29,7 +29,7 @@ public class ArchParameter extends PluginParameter { - @NotNull final ArchetypeSet archetypeSet = CMainControl.getInstance().getArchetypeSet(); + @NotNull private final ArchetypeSet archetypeSet = CMainControl.getInstance().getArchetypeSet(); private String valueString; Modified: trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java 2008-05-02 23:23:18 UTC (rev 3928) +++ trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java 2008-05-02 23:27:32 UTC (rev 3929) @@ -47,7 +47,7 @@ private final ToggleAction insertBelowAction = (ToggleAction) ACTION_FACTORY.createToggle(true, "insertBelow", this); /** The main control. */ - @NotNull final CMainControl mainControl; + @NotNull private final CMainControl mainControl; /** The position for insertion. */ private boolean insertBelow; Modified: trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialogFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialogFactory.java 2008-05-02 23:23:18 UTC (rev 3928) +++ trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialogFactory.java 2008-05-02 23:27:32 UTC (rev 3929) @@ -55,17 +55,17 @@ /** * The default difficulty for new maps. */ - final int defaultMapDifficulty; + private final int defaultMapDifficulty; /** * Whether to show the "mapSizeDefault" checkbox. */ - final boolean showMapDifficulty; + private final boolean showMapDifficulty; /** * Whether to show the "mapDifficulty" field. */ - final boolean showMapSizeDefault; + private final boolean showMapSizeDefault; /** * The default width for new pickmaps. Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java 2008-05-02 23:23:18 UTC (rev 3928) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java 2008-05-02 23:27:32 UTC (rev 3929) @@ -77,7 +77,7 @@ @NotNull private final MainControl<G, A, R, C, V> mainControl; /** The controller for this view. */ - @NotNull final SelectedSquareControl<G, A, R, C, V> control; + @NotNull private final SelectedSquareControl<G, A, R, C, V> control; /** The "Import..." button. */ private final JList list; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |