From: <aki...@us...> - 2010-07-22 16:56:27
|
Revision: 8602 http://gridarta.svn.sourceforge.net/gridarta/?rev=8602&view=rev Author: akirschbaum Date: 2010-07-22 16:56:19 +0000 (Thu, 22 Jul 2010) Log Message: ----------- Move hard-coded filenames and patterns for faces into text resources. Modified Paths: -------------- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/IGUIConstants.java trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages.properties trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/resource/CollectedResourcesReader.java trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParserTest.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/IGUIConstants.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/messages.properties trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/resource/CollectedResourcesReader.java trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParserTest.java trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/model/gameobject/GameObjectCreator.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/IGUIConstants.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/messages.properties trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/resource/CollectedResourcesReader.java trunk/model/src/app/net/sf/gridarta/model/face/FaceObjects.java trunk/model/src/test/net/sf/gridarta/model/face/TestFaceObjects.java trunk/src/app/net/sf/gridarta/model/face/DefaultFaceObjects.java trunk/utils/src/app/net/sf/gridarta/utils/CommonConstants.java Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/IGUIConstants.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/IGUIConstants.java 2010-07-22 16:23:36 UTC (rev 8601) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/IGUIConstants.java 2010-07-22 16:56:19 UTC (rev 8602) @@ -66,14 +66,7 @@ String ARCH_FILE = "archetypes"; // file with all arches - String PNG_FILE = "atrinik.0"; // file with all pngs - /** - * File to store the face tree information after arch collection. - */ - String FACETREE_FILE = "facetree"; - - /** * File to store the animation tree information after arch collection. */ String ANIMTREE_FILE = "animtree"; Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2010-07-22 16:23:36 UTC (rev 8601) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2010-07-22 16:56:19 UTC (rev 8602) @@ -287,7 +287,7 @@ @NotNull @Override public FaceObjects<GameObject, MapArchObject, Archetype> createFaceObjects(@NotNull final ArchFaceProvider archFaceProvider) { - return new DefaultFaceObjects<GameObject, MapArchObject, Archetype>(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^(.*)"), "%2$s", archFaceProvider); + return new DefaultFaceObjects<GameObject, MapArchObject, Archetype>(archFaceProvider); } /** Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages.properties =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages.properties 2010-07-22 16:23:36 UTC (rev 8601) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages.properties 2010-07-22 16:56:19 UTC (rev 8602) @@ -43,6 +43,13 @@ configSource.ARCH_DIRECTORY.treasures.0=${COLLECTED}/treasures configSource.ARCH_DIRECTORY.treasures.1=${MAPS} +configSource.image.name=atrinik.0 +configSource.face.name=bmaps +configSource.face.output=%1$05d %3$s +configSource.facetree.name=facetree +configSource.facetree.input=^(.*) +configSource.facetree.output=%2$s + # Internal version number of the included online-documentation. Increasing the # number causes an automated popup of the docu when users upgrade their editor # and run for the first time. Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/resource/CollectedResourcesReader.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/resource/CollectedResourcesReader.java 2010-07-22 16:23:36 UTC (rev 8601) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/resource/CollectedResourcesReader.java 2010-07-22 16:56:19 UTC (rev 8602) @@ -148,7 +148,7 @@ } catch (final IOException ex) { errorView.addWarning(ErrorViewCategory.ARCHETYPES_FILE_INVALID, IGUIConstants.ARCH_FILE + ": " + ex.getMessage()); } - return faceObjects.loadFacesCollection(errorView, collectedDirectory, IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE); + return faceObjects.loadFacesCollection(errorView, collectedDirectory); } } // class CollectedResourcesReader Modified: trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParserTest.java =================================================================== --- trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParserTest.java 2010-07-22 16:23:36 UTC (rev 8601) +++ trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParserTest.java 2010-07-22 16:56:19 UTC (rev 8602) @@ -118,7 +118,7 @@ @Override protected AbstractArchetypeParser<GameObject, MapArchObject, Archetype, ? extends AbstractArchetypeBuilder<GameObject, MapArchObject, Archetype>> newArchetypeParser() { final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); - final FaceObjects<GameObject, MapArchObject, Archetype> faceObjects = new DefaultFaceObjects<GameObject, MapArchObject, Archetype>("png", "facetree", Pattern.compile(".*"), "facetree.output", archFaceProvider); + final FaceObjects<GameObject, MapArchObject, Archetype> faceObjects = new DefaultFaceObjects<GameObject, MapArchObject, Archetype>(archFaceProvider); final GUIUtils guiUtils = new GUIUtils(); final SystemIcons systemIcons = new SystemIcons(guiUtils); final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/IGUIConstants.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/IGUIConstants.java 2010-07-22 16:23:36 UTC (rev 8601) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/IGUIConstants.java 2010-07-22 16:56:19 UTC (rev 8602) @@ -68,15 +68,11 @@ String ARCH_FILE = "archetypes"; // file with all arches - String PNG_FILE = "crossfire.0"; // file with all png files - /** * File to store the animation tree information after arch collection. */ String ANIMTREE_FILE = "animtree"; - String FACETREE_FILE = "bmaps.paths"; - String SMOOTH_FILE = "smooth"; } // interface IGUIConstants Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2010-07-22 16:23:36 UTC (rev 8601) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2010-07-22 16:56:19 UTC (rev 8602) @@ -20,7 +20,6 @@ package net.sf.gridarta.var.crossfire.maincontrol; import java.awt.Component; -import java.util.regex.Pattern; import net.sf.gridarta.gui.filter.FilterControl; import net.sf.gridarta.gui.io.GuiFileFilters; import net.sf.gridarta.gui.map.mapview.DefaultMapViewFactory; @@ -250,7 +249,7 @@ @NotNull @Override public FaceObjects<GameObject, MapArchObject, Archetype> createFaceObjects(@NotNull final ArchFaceProvider archFaceProvider) { - return new DefaultFaceObjects<GameObject, MapArchObject, Archetype>(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^.*\t\\.?(.*)"), "\\%1$05d\t./arch%2$s", archFaceProvider); + return new DefaultFaceObjects<GameObject, MapArchObject, Archetype>(archFaceProvider); } /** Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/messages.properties =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/messages.properties 2010-07-22 16:23:36 UTC (rev 8601) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/messages.properties 2010-07-22 16:56:19 UTC (rev 8602) @@ -41,6 +41,13 @@ configSource.COLLECTED.treasures.0=${COLLECTED}/treasures configSource.ARCH_DIRECTORY.treasures.0=${ARCH} +configSource.image.name=crossfire.0 +configSource.face.name=bmaps +configSource.face.output=%1$05d %3$s +configSource.facetree.name=bmaps.paths +configSource.facetree.input=^.*\t\\.?(.*) +configSource.facetree.output=\\%1$05d\t./arch%2$s + # Internal version number of the included online-documentation. Increasing the # number causes an automated popup of the docu when users upgrade their editor # and run for the first time. Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/resource/CollectedResourcesReader.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/resource/CollectedResourcesReader.java 2010-07-22 16:23:36 UTC (rev 8601) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/resource/CollectedResourcesReader.java 2010-07-22 16:56:19 UTC (rev 8602) @@ -166,7 +166,7 @@ } catch (final IOException ex) { errorView.addWarning(ErrorViewCategory.ARCHETYPES_FILE_INVALID, IGUIConstants.ARCH_FILE + ": " + ex.getMessage()); } - final FaceProvider faceProvider = faceObjects.loadFacesCollection(errorView, collectedDirectory, IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE); + final FaceProvider faceProvider = faceObjects.loadFacesCollection(errorView, collectedDirectory); try { final URL url = IOUtils.getResource(configurationDirectory, IGUIConstants.SMOOTH_FILE); SmoothFacesLoader.load(url, smoothFaces, errorView); Modified: trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParserTest.java =================================================================== --- trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParserTest.java 2010-07-22 16:23:36 UTC (rev 8601) +++ trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParserTest.java 2010-07-22 16:56:19 UTC (rev 8602) @@ -20,7 +20,6 @@ package net.sf.gridarta.var.crossfire.model.archetype; import java.io.IOException; -import java.util.regex.Pattern; import net.sf.gridarta.model.anim.AnimationObjects; import net.sf.gridarta.model.anim.DefaultAnimationObjects; import net.sf.gridarta.model.archetype.AbstractArchetypeBuilder; @@ -92,7 +91,7 @@ @Override protected AbstractArchetypeParser<GameObject, MapArchObject, Archetype, ? extends AbstractArchetypeBuilder<GameObject, MapArchObject, Archetype>> newArchetypeParser() { final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); - final FaceObjects<GameObject, MapArchObject, Archetype> faceObjects = new DefaultFaceObjects<GameObject, MapArchObject, Archetype>("png", "facetree", Pattern.compile(".*"), "facetree.output", archFaceProvider); + final FaceObjects<GameObject, MapArchObject, Archetype> faceObjects = new DefaultFaceObjects<GameObject, MapArchObject, Archetype>(archFaceProvider); final GUIUtils guiUtils = new GUIUtils(); final SystemIcons systemIcons = new SystemIcons(guiUtils); final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); Modified: trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/model/gameobject/GameObjectCreator.java =================================================================== --- trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/model/gameobject/GameObjectCreator.java 2010-07-22 16:23:36 UTC (rev 8601) +++ trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/model/gameobject/GameObjectCreator.java 2010-07-22 16:56:19 UTC (rev 8602) @@ -19,7 +19,6 @@ package net.sf.gridarta.var.crossfire.model.gameobject; -import java.util.regex.Pattern; import net.sf.gridarta.model.anim.AnimationObjects; import net.sf.gridarta.model.anim.DefaultAnimationObjects; import net.sf.gridarta.model.face.ArchFaceProvider; @@ -62,7 +61,7 @@ */ GameObjectCreator() { final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); - final FaceObjects<GameObject, MapArchObject, Archetype> faceObjects = new DefaultFaceObjects<GameObject, MapArchObject, Archetype>("pngFile", "faceTreeFile", Pattern.compile(""), "", archFaceProvider); + final FaceObjects<GameObject, MapArchObject, Archetype> faceObjects = new DefaultFaceObjects<GameObject, MapArchObject, Archetype>(archFaceProvider); final GUIUtils guiUtils = new GUIUtils(); final SystemIcons systemIcons = new SystemIcons(guiUtils); faceObjectProviders = new FaceObjectProviders(1, faceObjects, systemIcons); Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/IGUIConstants.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/IGUIConstants.java 2010-07-22 16:23:36 UTC (rev 8601) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/IGUIConstants.java 2010-07-22 16:56:19 UTC (rev 8602) @@ -66,14 +66,7 @@ String ARCH_FILE = "archetypes"; // file with all arches - String PNG_FILE = "daimonin.0"; // file with all pngs - /** - * File to store the face tree information after arch collection. - */ - String FACETREE_FILE = "facetree"; - - /** * File to store the animation tree information after arch collection. */ String ANIMTREE_FILE = "animtree"; Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2010-07-22 16:23:36 UTC (rev 8601) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2010-07-22 16:56:19 UTC (rev 8602) @@ -288,7 +288,7 @@ @NotNull @Override public FaceObjects<GameObject, MapArchObject, Archetype> createFaceObjects(@NotNull final ArchFaceProvider archFaceProvider) { - return new DefaultFaceObjects<GameObject, MapArchObject, Archetype>(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^(.*)"), "%2$s", archFaceProvider); + return new DefaultFaceObjects<GameObject, MapArchObject, Archetype>(archFaceProvider); } /** Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/messages.properties =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/messages.properties 2010-07-22 16:23:36 UTC (rev 8601) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/messages.properties 2010-07-22 16:56:19 UTC (rev 8602) @@ -43,6 +43,13 @@ configSource.ARCH_DIRECTORY.treasures.0=${COLLECTED}/treasures configSource.ARCH_DIRECTORY.treasures.1=${MAPS} +configSource.image.name=daimonin.0 +configSource.face.name=bmaps +configSource.face.output=%1$05d %3$s +configSource.facetree.name=facetree +configSource.facetree.input=^(.*) +configSource.facetree.output=%2$s + # Internal version number of the included online-documentation. Increasing the # number causes an automated popup of the docu when users upgrade their editor # and run for the first time. Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/resource/CollectedResourcesReader.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/resource/CollectedResourcesReader.java 2010-07-22 16:23:36 UTC (rev 8601) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/resource/CollectedResourcesReader.java 2010-07-22 16:56:19 UTC (rev 8602) @@ -148,7 +148,7 @@ } catch (final IOException ex) { errorView.addWarning(ErrorViewCategory.ARCHETYPES_FILE_INVALID, IGUIConstants.ARCH_FILE + ": " + ex.getMessage()); } - return faceObjects.loadFacesCollection(errorView, collectedDirectory, IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE); + return faceObjects.loadFacesCollection(errorView, collectedDirectory); } } // class CollectedResourcesReader Modified: trunk/model/src/app/net/sf/gridarta/model/face/FaceObjects.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/face/FaceObjects.java 2010-07-22 16:23:36 UTC (rev 8601) +++ trunk/model/src/app/net/sf/gridarta/model/face/FaceObjects.java 2010-07-22 16:56:19 UTC (rev 8602) @@ -38,12 +38,10 @@ * Loads all faces from a png collection file. * @param errorView the error view for reporting errors * @param collectedDirectory directory to load from - * @param faceFile file to load faces from - * @param treeFile file to load tree information from * @return the face provider for accessing the read faces */ @NotNull - FaceProvider loadFacesCollection(@NotNull ErrorView errorView, @NotNull File collectedDirectory, @NotNull String faceFile, @NotNull String treeFile); + FaceProvider loadFacesCollection(@NotNull ErrorView errorView, @NotNull File collectedDirectory); /** * Adds a new face object. Modified: trunk/model/src/test/net/sf/gridarta/model/face/TestFaceObjects.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/face/TestFaceObjects.java 2010-07-22 16:23:36 UTC (rev 8601) +++ trunk/model/src/test/net/sf/gridarta/model/face/TestFaceObjects.java 2010-07-22 16:56:19 UTC (rev 8602) @@ -52,7 +52,7 @@ */ @NotNull @Override - public FaceProvider loadFacesCollection(@NotNull final ErrorView errorView, @NotNull final File collectedDirectory, @NotNull final String faceFile, @NotNull final String treeFile) { + public FaceProvider loadFacesCollection(@NotNull final ErrorView errorView, @NotNull final File collectedDirectory) { throw new AssertionError(); } Modified: trunk/src/app/net/sf/gridarta/model/face/DefaultFaceObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/face/DefaultFaceObjects.java 2010-07-22 16:23:36 UTC (rev 8601) +++ trunk/src/app/net/sf/gridarta/model/face/DefaultFaceObjects.java 2010-07-22 16:56:19 UTC (rev 8602) @@ -45,7 +45,6 @@ import net.sf.gridarta.model.maparchobject.MapArchObject; import net.sf.gridarta.utils.ActionBuilderUtils; import net.sf.gridarta.utils.ArrayUtils; -import net.sf.gridarta.utils.CommonConstants; import net.sf.gridarta.utils.IOUtils; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; @@ -81,35 +80,6 @@ private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); /** - * The filename of the collected image file. - * @serial - */ - @NotNull - private final String pngFile; - - /** - * The filename of the face tree file. - * @serial - */ - @NotNull - private final String faceTreeFile; - - /** - * The {@link Pattern} for parsing face tree files. The pattern must return - * the face name in the first capturing group. - * @serial - */ - @NotNull - private final Pattern faceTreeInputPattern; - - /** - * The format string for writing face tree files. - * @serial - */ - @NotNull - private final String faceTreeOutputFormat; - - /** * The {@link ArchFaceProvider} to use for collection. */ @NotNull @@ -117,19 +87,10 @@ /** * Creates a new instance. - * @param pngFile the filename of the collected image file - * @param faceTreeFile the filename of the face tree file - * @param faceTreeInputPattern the pattern for parsing face tree files - * @param faceTreeOutputFormat the format string for writing face tree - * files * @param archFaceProvider the arch face provider to use for collection */ - public DefaultFaceObjects(@NotNull final String pngFile, @NotNull final String faceTreeFile, @NotNull final Pattern faceTreeInputPattern, @NotNull final String faceTreeOutputFormat, @NotNull final ArchFaceProvider archFaceProvider) { + public DefaultFaceObjects(@NotNull final ArchFaceProvider archFaceProvider) { super(ActionBuilderUtils.getString(ACTION_BUILDER, "nameOfFaceObject")); - this.pngFile = pngFile; - this.faceTreeFile = faceTreeFile; - this.faceTreeInputPattern = faceTreeInputPattern; - this.faceTreeOutputFormat = faceTreeOutputFormat; this.archFaceProvider = archFaceProvider; } @@ -155,7 +116,7 @@ * @throws IOException in case of I/O problems during collection */ private void collectImageFile(@NotNull final Progress progress, @NotNull final File collectedDirectory) throws IOException { - final File file = new File(collectedDirectory, pngFile); + final File file = new File(collectedDirectory, ActionBuilderUtils.getString(ACTION_BUILDER, "configSource.image.name")); final FileOutputStream fos = new FileOutputStream(file); try { final FileChannel outChannel = fos.getChannel(); @@ -209,7 +170,7 @@ * @throws IOException in case of I/O problems during collection */ private void collectTreeFile(@NotNull final Progress progress, @NotNull final File collectedDirectory) throws IOException { - collectFile(progress, new File(collectedDirectory, faceTreeFile), ActionBuilderUtils.getString(ACTION_BUILDER, "archCollectTree"), faceTreeOutputFormat); + collectFile(progress, new File(collectedDirectory, ActionBuilderUtils.getString(ACTION_BUILDER, "configSource.facetree.name")), ActionBuilderUtils.getString(ACTION_BUILDER, "archCollectTree"), ActionBuilderUtils.getString(ACTION_BUILDER, "configSource.facetree.output")); } /** @@ -219,7 +180,7 @@ * @throws IOException in case of I/O problems during collection */ private void collectBmapsFile(@NotNull final Progress progress, @NotNull final File collectedDirectory) throws IOException { - collectFile(progress, new File(collectedDirectory, CommonConstants.BMAPS_FILE), ActionBuilderUtils.getString(ACTION_BUILDER, "archCollectBmaps"), "%1$05d %3$s"); + collectFile(progress, new File(collectedDirectory, ActionBuilderUtils.getString(ACTION_BUILDER, "configSource.face.name")), ActionBuilderUtils.getString(ACTION_BUILDER, "archCollectBmaps"), ActionBuilderUtils.getString(ACTION_BUILDER, "configSource.face.output")); } /** @@ -262,7 +223,9 @@ @NotNull @Override - public FaceProvider loadFacesCollection(@NotNull final ErrorView errorView, @NotNull final File collectedDirectory, @NotNull final String faceFile, @NotNull final String treeFile) { + public FaceProvider loadFacesCollection(@NotNull final ErrorView errorView, @NotNull final File collectedDirectory) { + final String faceFile = ActionBuilderUtils.getString(ACTION_BUILDER, "configSource.image.name"); + final String treeFile = ActionBuilderUtils.getString(ACTION_BUILDER, "configSource.facetree.name"); final File tmpFaceFile; try { tmpFaceFile = IOUtils.getFile(collectedDirectory, faceFile); @@ -293,6 +256,7 @@ final byte[] tag = "IMAGE ".getBytes(); // this is the starting string for a new png final StringBuilder faceB = new StringBuilder(); // face name of png try { + final Pattern pattern = Pattern.compile(ActionBuilderUtils.getString(ACTION_BUILDER, "configSource.facetree.input")); int offset = 0; while (offset < data.length) { // File: Structure* @@ -341,7 +305,7 @@ if (originalFilename == null) { log.warn(ACTION_BUILDER.format("logFaceObjectWithoutOriginalName", faceName)); } else { - final Matcher matcher = faceTreeInputPattern.matcher(originalFilename); + final Matcher matcher = pattern.matcher(originalFilename); if (matcher.matches()) { try { addFaceObject(faceName, matcher.group(1), offset, size); Modified: trunk/utils/src/app/net/sf/gridarta/utils/CommonConstants.java =================================================================== --- trunk/utils/src/app/net/sf/gridarta/utils/CommonConstants.java 2010-07-22 16:23:36 UTC (rev 8601) +++ trunk/utils/src/app/net/sf/gridarta/utils/CommonConstants.java 2010-07-22 16:56:19 UTC (rev 8602) @@ -43,11 +43,6 @@ public static final String TYPEDEF_FILE = "types.xml"; /** - * Name of the file that contains the list of faces. - */ - public static final String BMAPS_FILE = "bmaps"; - - /** * The height of rigid area between the two tab-panes on the pickmap- and * arch-panel. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-07-23 21:32:53
|
Revision: 8605 http://gridarta.svn.sourceforge.net/gridarta/?rev=8605&view=rev Author: akirschbaum Date: 2010-07-23 21:32:47 +0000 (Fri, 23 Jul 2010) Log Message: ----------- (Re-)add "Save All Maps" function. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/action.properties trunk/crossfire/ChangeLog trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/action.properties trunk/daimonin/ChangeLog trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/action.properties Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-07-22 17:23:44 UTC (rev 8604) +++ trunk/atrinik/ChangeLog 2010-07-23 21:32:47 UTC (rev 8605) @@ -1,3 +1,7 @@ +2010-07-23 Andreas Kirschbaum + + * (Re-)add "Save All Maps" function. + 2010-07-22 Andreas Kirschbaum * Remove face numbers from generated "bmaps" file. Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/action.properties =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/action.properties 2010-07-22 17:23:44 UTC (rev 8604) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/action.properties 2010-07-23 21:32:47 UTC (rev 8605) @@ -25,7 +25,7 @@ ######## # Menus main.menubar=file edit map archetypes pickmaps resources tools analyze view bookmarks plugins window help -file.menu=newMap openFile recent closeMap - saveMap saveMapAs closeAllMaps revertMap createImage - options shortcuts - exit +file.menu=newMap openFile recent closeMap - saveMap saveMapAs saveAllMaps - closeAllMaps revertMap createImage - options shortcuts - exit edit.menu=undo redo - clear cut copy paste pasteTiled - shift - replace fillAuto fillAbove fillBelow randFillAuto randFillAbove randFillBelow floodFill - selectAll expandEmptySelection growSelection shrinkSelection map.menu=autoJoin - enterExit nextExit prevExit enterNorthMap enterEastMap enterSouthMap enterWestMap enterNorthEastMap enterSouthEastMap enterSouthWestMap enterNorthWestMap - mapCreateView mapProperties shrinkMapSize deleteUnknownObjects - gameObjectTextEditor archetypes.menu=displayGameObjectNames displayArchetypeNames displayIconsOnly - findArchetypes Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-07-22 17:23:44 UTC (rev 8604) +++ trunk/crossfire/ChangeLog 2010-07-23 21:32:47 UTC (rev 8605) @@ -1,3 +1,7 @@ +2010-07-23 Andreas Kirschbaum + + * (Re-)add "Save All Maps" function. + 2010-07-15 Andreas Kirschbaum * Add support for *.trs treasurelist files in arch directory. Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/action.properties =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/action.properties 2010-07-22 17:23:44 UTC (rev 8604) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/action.properties 2010-07-23 21:32:47 UTC (rev 8605) @@ -25,7 +25,7 @@ ######## # Menus main.menubar=file edit map archetypes pickmaps resources tools analyze view bookmarks plugins window help -file.menu=newMap openFile recent closeMap - saveMap saveMapAs closeAllMaps revertMap createImage - options shortcuts - exit +file.menu=newMap openFile recent closeMap - saveMap saveMapAs saveAllMaps - closeAllMaps revertMap createImage - options shortcuts - exit edit.menu=undo redo - clear cut copy paste pasteTiled - shift - replace fillAuto fillAbove fillBelow randFillAuto randFillAbove randFillBelow floodFill - selectAll expandEmptySelection growSelection shrinkSelection map.menu=autoJoin - enterExit nextExit prevExit enterNorthMap enterEastMap enterSouthMap enterWestMap tileShow - mapCreateView mapProperties shrinkMapSize deleteUnknownObjects - gameObjectTextEditor archetypes.menu=displayGameObjectNames displayArchetypeNames displayIconsOnly - findArchetypes Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-07-22 17:23:44 UTC (rev 8604) +++ trunk/daimonin/ChangeLog 2010-07-23 21:32:47 UTC (rev 8605) @@ -1,3 +1,7 @@ +2010-07-23 Andreas Kirschbaum + + * (Re-)add "Save All Maps" function. + 2010-07-15 Andreas Kirschbaum * Include correct filename for errors in *.tl treasurelists. Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/action.properties =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/action.properties 2010-07-22 17:23:44 UTC (rev 8604) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/action.properties 2010-07-23 21:32:47 UTC (rev 8605) @@ -25,7 +25,7 @@ ######## # Menus main.menubar=file edit map archetypes pickmaps resources tools analyze view bookmarks plugins window help -file.menu=newMap openFile recent closeMap - saveMap saveMapAs closeAllMaps revertMap createImage - options shortcuts - exit +file.menu=newMap openFile recent closeMap - saveMap saveMapAs saveAllMaps - closeAllMaps revertMap createImage - options shortcuts - exit edit.menu=undo redo - clear cut copy paste pasteTiled - shift - replace fillAuto fillAbove fillBelow randFillAuto randFillAbove randFillBelow floodFill - selectAll expandEmptySelection growSelection shrinkSelection map.menu=autoJoin - enterExit nextExit prevExit enterNorthMap enterEastMap enterSouthMap enterWestMap enterNorthEastMap enterSouthEastMap enterSouthWestMap enterNorthWestMap - mapCreateView mapProperties shrinkMapSize deleteUnknownObjects - gameObjectTextEditor archetypes.menu=displayGameObjectNames displayArchetypeNames displayIconsOnly - findArchetypes This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-07-24 06:46:08
|
Revision: 8607 http://gridarta.svn.sourceforge.net/gridarta/?rev=8607&view=rev Author: akirschbaum Date: 2010-07-24 06:46:01 +0000 (Sat, 24 Jul 2010) Log Message: ----------- Remove the "Apply" button from game object attributes panel as change are automatically applied. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.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/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-07-24 06:42:51 UTC (rev 8606) +++ trunk/atrinik/ChangeLog 2010-07-24 06:46:01 UTC (rev 8607) @@ -1,3 +1,8 @@ +2010-07-24 Andreas Kirschbaum + + * Remove the "Apply" button from game object attributes panel as + change are automatically applied. + 2010-07-23 Andreas Kirschbaum * (Re-)add "Save All Maps" function. Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-07-24 06:42:51 UTC (rev 8606) +++ trunk/crossfire/ChangeLog 2010-07-24 06:46:01 UTC (rev 8607) @@ -1,3 +1,8 @@ +2010-07-24 Andreas Kirschbaum + + * Remove the "Apply" button from game object attributes panel as + change are automatically applied. + 2010-07-23 Andreas Kirschbaum * (Re-)add "Save All Maps" function. Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-07-24 06:42:51 UTC (rev 8606) +++ trunk/daimonin/ChangeLog 2010-07-24 06:46:01 UTC (rev 8607) @@ -1,3 +1,8 @@ +2010-07-24 Andreas Kirschbaum + + * Remove the "Apply" button from game object attributes panel as + change are automatically applied. + 2010-07-23 Andreas Kirschbaum * (Re-)add "Save All Maps" function. Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2010-07-24 06:42:51 UTC (rev 8606) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2010-07-24 06:46:01 UTC (rev 8607) @@ -150,12 +150,6 @@ private Severity severity = Severity.DEFAULT; /** - * Action for "apply changes". - */ - @NotNull - private final Action aMapArchApply = ACTION_BUILDER.createAction(false, "mapArchApply", this); - - /** * Action for "add to inventory". */ @NotNull @@ -549,7 +543,6 @@ * Update the displayed information for the selected game object. */ private void refreshDisplay() { - aMapArchApply.setEnabled(selectedGameObject != null); aMapArchAddInv.setEnabled(selectedGameObject != null); aMapArchAddEnv.setEnabled(selectedGameObject != null); aMapArchAttribute.setEnabled(selectedGameObject != null); @@ -557,14 +550,6 @@ } /** - * Action method for applying the changes made in the arch panel. - */ - @ActionMethod - public void mapArchApply() { - applyArchPanelChanges(); - } - - /** * Action method for displaying the attributes of the currently selected * object. */ @@ -704,7 +689,6 @@ @NotNull private Container createButtonPanel() { final Container buttonPanel = new JPanel(); - buttonPanel.add(new JButton(aMapArchApply)); buttonPanel.add(new JButton(aMapArchAddInv)); buttonPanel.add(new JButton(aMapArchAddEnv)); buttonPanel.add(new JButton(aMapArchAttribute)); Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2010-07-24 06:42:51 UTC (rev 8606) +++ trunk/src/app/net/sf/gridarta/messages.properties 2010-07-24 06:46:01 UTC (rev 8607) @@ -939,9 +939,6 @@ ################# # Map Arch Panel -mapArchApply.text=Apply -mapArchApply.shortdescription=Apply object changes - mapArchAttrib.text=Attributes mapArchAttrib.shortdescription=Open attributes dialog Modified: trunk/src/app/net/sf/gridarta/messages_de.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_de.properties 2010-07-24 06:42:51 UTC (rev 8606) +++ trunk/src/app/net/sf/gridarta/messages_de.properties 2010-07-24 06:46:01 UTC (rev 8607) @@ -872,9 +872,6 @@ ################# # Map Arch Panel -mapArchApply.text=Anwenden -mapArchApply.shortdescription=\xDCbernimmt die \xC4nderungen - mapArchAttrib.text=Attribute mapArchAttrib.shortdescription=\xD6ffnet den Attribute-Dialog Modified: trunk/src/app/net/sf/gridarta/messages_fr.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_fr.properties 2010-07-24 06:42:51 UTC (rev 8606) +++ trunk/src/app/net/sf/gridarta/messages_fr.properties 2010-07-24 06:46:01 UTC (rev 8607) @@ -862,9 +862,6 @@ ################# # Map Arch Panel -mapArchApply.text=Appliquer -mapArchApply.shortdescription=Applique les modifications de l'objet. - mapArchAttrib.text=Attributs mapArchAttrib.shortdescription=Affiche les attributs de l'objet. Modified: trunk/src/app/net/sf/gridarta/messages_sv.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_sv.properties 2010-07-24 06:42:51 UTC (rev 8606) +++ trunk/src/app/net/sf/gridarta/messages_sv.properties 2010-07-24 06:46:01 UTC (rev 8607) @@ -870,9 +870,6 @@ ################# # Map Arch Panel -mapArchApply.text=Anv\xE4nd -mapArchApply.shortdescription=Anv\xE4nd \xE4ndringarna i objektet - mapArchAttrib.text=Attribut mapArchAttrib.shortdescription=\xD6ppna attributdialogen This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ryo...@us...> - 2010-08-02 17:03:06
|
Revision: 8609 http://gridarta.svn.sourceforge.net/gridarta/?rev=8609&view=rev Author: ryo_saeba Date: 2010-08-02 17:02:59 +0000 (Mon, 02 Aug 2010) Log Message: ----------- Some translations. Modified Paths: -------------- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/messages_fr.properties trunk/src/app/net/sf/gridarta/messages_fr.properties Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/messages_fr.properties =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/messages_fr.properties 2010-07-27 06:27:23 UTC (rev 8608) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/messages_fr.properties 2010-08-02 17:02:59 UTC (rev 8609) @@ -21,8 +21,8 @@ # See http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html#encoding # Translation done by Marmoth -application.name=Gridarta for Crossfire -mainWindow.title=Gridarta for Crossfire +application.name=Gridarta pour Crossfire +mainWindow.title=Gridarta pour Crossfire ########## Modified: trunk/src/app/net/sf/gridarta/messages_fr.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_fr.properties 2010-07-27 06:27:23 UTC (rev 8608) +++ trunk/src/app/net/sf/gridarta/messages_fr.properties 2010-08-02 17:02:59 UTC (rev 8609) @@ -113,27 +113,27 @@ #closeAllMaps.longdescription= closeAllMaps.mnemonic=U -#saveAllMaps.text= -#saveAllMaps.shortdescription= +saveAllMaps.text=Engistrer toutes les cartes +saveAllMaps.shortdescription=Enregistre toutes les cartes modifi\u00e9s. gridVisible.text=Montrer la grille gridVisible.mnemonic=G #gridVisible.shortdescription= -#smoothing.text= +smoothing.text=Lissage #smoothing.mnemonic= -#smoothing.shortdescription= +smoothing.shortdescription=Active le lissage des images, permettant un rendu moins carr\u00e9. tileShow.text=Montrer les cartes li\u00e9es tileShow.shortdescription=Affiche les cartes li\u00e9es. -#mapCreateView.text= -#mapCreateView.shortdescription= +mapCreateView.text=Nouvelle vue +mapCreateView.shortdescription=Ouvre une nouvelle vue sur la carte actuelle. #mapCreateView.longdescription= mapProperties.text=Propri\u00e9t\u00e9s de la carte mapProperties.mnemonic=R -#mapProperties.shortdescription= +mapProperties.shortdescription=Ouvre le dialogue des propri\u00e9t\u00e9s de la carte actuelle. #mapProperties.longdescription= shrinkMapSize.text=R\u00e9duire la carte @@ -210,11 +210,11 @@ enterNorthWestMap.text=Aller Carte Nord-Ouest #enterNorthWestMap.shortdescription= -#deleteUnknownObjects.text= -#deleteUnknownObjects.shortdescription= +deleteUnknownObjects.text=Supprimer les objets inconnus +deleteUnknownObjects.shortdescription=Supprime de la carte courante les objets se r\u00e9f\u00e9rant \u00e0 des arch\u00e9types inconnus. -#gameObjectTextEditor.text= -#gameObjectTextEditor.shortdescription= +gameObjectTextEditor.text=\u00c9diteur texte pour objet +gameObjectTextEditor.shortdescription=Affiche ou cache l'\u00e9diteur mode texte pour l'objet courant. #gameObjectTextEditor.longdescription= @@ -669,7 +669,7 @@ clear.text=Effacer clear.mnemonic=E -clear.shortdescription=Efface les cases s\u00e9lectionn\u00e9es +clear.shortdescription=Efface les cases s\u00e9lectionn\u00e9es. cut.text=Couper cut.mnemonic=O @@ -687,52 +687,52 @@ #pasteTiled.shortdescription= #pasteTiled.longdescription= -#shift.text= +shift.text=D\u00e9caler shift.mnemonic=S -#shift.shortdescription= +shift.shortdescription=D\u00e9cale les cases s\u00e9lectionn\u00e9es. -#shiftNorth.text= +shiftNorth.text=D\u00e9caler vers le nord #shiftNorth.mnemonic= -#shiftNorth.shortdescription= -#shiftNorthEast.text= -#shiftNorthEast.shortdescription= -#shiftEast.text= +shiftNorth.shortdescription=D\u00e9cale la s\u00e9lection vers le nord. +shiftNorthEast.text=D\u00e9caler vers le nord-est +shiftNorthEast.shortdescription=D\u00e9cale la s\u00e9lection vers le nord-est. +shiftEast.text=D\u00e9caler vers l'est #shiftEast.mnemonic= -#shiftEast.shortdescription= -#shiftSouthEast.text= -#shiftSouthEast.shortdescription= -#shiftSouth.text= +shiftEast.shortdescription=D\u00e9cale la s\u00e9lection vers l'est. +shiftSouthEast.text=D\u00e9caler vers le sud-est +shiftSouthEast.shortdescription=D\u00e9cale la s\u00e9lection vers le sud-est. +shiftSouth.text=D\u00e9caler vers le sud #shiftSouth.mnemonic= -#shiftSouth.shortdescription= -#shiftSouthWest.text= -#shiftSouthWest.shortdescription= -#shiftWest.text= +shiftSouth.shortdescription=D\u00e9cale la s\u00e9lection vers le sud. +shiftSouthWest.text=D\u00e9caler vers le sud-ouest +shiftSouthWest.shortdescription=D\u00e9cale la s\u00e9lection vers le sud-ouest. +shiftWest.text=D\u00e9caler vers l'ouest #shiftWest.mnemonic= -#shiftWest.shortdescription= -#shiftNorthWest.text= -#shiftNorthWest.shortdescription= +shiftWest.shortdescription=D\u00e9cale la s\u00e9lection vers l'ouest. +shiftNorthWest.text=D\u00e9caler vers le nord-ouest +shiftNorthWest.shortdescription=D\u00e9cale la s\u00e9lection vers le nord-ouest. replace.text=Remplacer replace.mnemonic=M #replace.shortdescription= -#fillAuto.text= +fillAuto.text=Remplir #fillAuto.mnemonic= -#fillAuto.shortdescription= +fillAuto.shortdescription=Remplit les cases s\u00e9lectionn\u00e9es, en effa\u00e7ant les objets existants. #fillAuto.longdescription= -fillAbove.text=Remplir vers le haut +fillAbove.text=Remplir au-dessus fillAbove.mnemonic=H -#fillAbove.shortdescription= +fillAbove.shortdescription=Remplit la s\u00e9lection en ajoutant au-dessus des objets existants. #fillAbove.longdescription= -fillBelow.text=Remplir vers le bas +fillBelow.text=Remplir en-dessous fillBelow.mnemonic=B -#fillBelow.shortdescription= +fillBelow.shortdescription=Remplit la s\u00e9lection en ajoutant au-dessous des objets existants. #fillBelow.longdescription= -#randFillAuto.text= -#randFillAuto.shortdescription= +randFillAuto.text=Remplir al\u00e9atoirement +randFillAuto.shortdescription=Remplit al\u00e9atoirement les cases s\u00e9lectionn\u00e9es, rempla\u00e7ant les objets existants. #randFillAuto.longdescription= randFillAbove.text=Remplir en haut al\u00e9atoirement @@ -743,22 +743,22 @@ #randFillBelow.shortdescription= #randFillBelow.longdescription= -#floodFill.text= -#floodFill.shortdescription= +floodFill.text=Remplir les zones vides +floodFill.shortdescription=Remplit les zones vides de la s\u00e9lection. #floodFill.longdescription= selectAll.text=Tout s\u00e9lectionner selectAll.mnemonic=T #selectAll.shortdescription= -#expandEmptySelection.text= -#expandEmptySelection.shortdescription= +expandEmptySelection.text=\u00c9tendre la s\u00e9lection aux carr\u00e9s vides +expandEmptySelection.shortdescription=\u00c9tend la s\u00e9lection aux carr\u00e9s vides adjacents \u00e0 un carr\u00e9 vide d\u00e9j\u00e0 s\u00e9lectionn\u00e9. -#growSelection.text= -#growSelection.shortdescription= +growSelection.text=Agrandir la s\u00e9lection +growSelection.shortdescription=Agrandit la s\u00e9lection d'une case autour des cases s\u00e9lectionn\u00e9es. -#shrinkSelection.text= -#shrinkSelection.shortdescription= +shrinkSelection.text=R\u00e9duire la s\u00e9lection +shrinkSelection.shortdescription=R\u00e9duit la s\u00e9lection d'une case autour des cases s\u00e9lectionn\u00e9es. ############ @@ -1343,35 +1343,35 @@ ########## # Main Window -#tabButton.gameObject.title1= -#tabButton.gameObject.title2= +tabButton.gameObject.title1=Objet +tabButton.gameObject.title2={0} : Objet #tabButton.gameObject.shortdescription= -#tabButton.selectedSquare.title1= -#tabButton.selectedSquare.title2= +tabButton.selectedSquare.title1=Objet s\u00e9lectionn\u00e9 +tabButton.selectedSquare.title2={0} : Objet s\u00e9lectionn\u00e9 #tabButton.selectedSquare.shortdescription= -#tabButton.tools.title1= -#tabButton.tools.title2= +tabButton.tools.title1=Outils +tabButton.tools.title2={0} : Outils #tabButton.tools.shortdescription= -#tabButton.objects.title1=Objects -#tabButton.objects.title2= +tabButton.objects.title1=Objets +tabButton.objects.title2={0} : Objets #tabButton.objects.shortdescription= -#tabButton.monsters.title1= -#tabButton.monsters.title2= +tabButton.monsters.title1=Monstres +tabButton.monsters.title2={0} : Monstres #tabButton.monsters.shortdescription= -#tabButton.connections.title1= -#tabButton.connections.title2= +tabButton.connections.title1=Connexions +tabButton.connections.title2={0} : Connexions #tabButton.connections.shortdescription= -#tabButton.lockedItems.title1= -#tabButton.lockedItems.title2= +tabButton.lockedItems.title1=Objets verrouill\u00e9s +tabButton.lockedItems.title2={0} : Objets verrouill\u00e9s #tabButton.lockedItems.shortdescription= -#tabButton.warnings.title1= -#tabButton.warnings.title2= +tabButton.warnings.title1=Alertes +tabButton.warnings.title2={0} : Alertes #tabButton.warnings.shortdescription= -#tabButtonMoveTo.text= -#tabButtonMoveToTop.text= -#tabButtonMoveToBottom.text= -#tabButtonMoveToLeft.text= -#tabButtonMoveToRight.text= +tabButtonMoveTo.text=D\u00e9placer vers +tabButtonMoveToTop.text=Haut +tabButtonMoveToBottom.text=Bas +tabButtonMoveToLeft.text=Gauche +tabButtonMoveToRight.text=Droite ############ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-08-05 17:03:03
|
Revision: 8611 http://gridarta.svn.sourceforge.net/gridarta/?rev=8611&view=rev Author: akirschbaum Date: 2010-08-05 17:02:56 +0000 (Thu, 05 Aug 2010) Log Message: ----------- Insert "direction" attribute only if the archetype supports a direction. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/daimonin/ChangeLog trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java trunk/model/src/test/net/sf/gridarta/model/archetype/TestArchetype.java trunk/model/src/test/net/sf/gridarta/model/mapmodel/DefaultMapModelTest.java trunk/model/src/test/net/sf/gridarta/model/mapmodel/TestMapModelCreator.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-08-02 18:44:42 UTC (rev 8610) +++ trunk/atrinik/ChangeLog 2010-08-05 17:02:56 UTC (rev 8611) @@ -1,3 +1,8 @@ +2010-08-05 Andreas Kirschbaum + + * Insert "direction" attribute only if the archetype supports a + direction. + 2010-07-27 Andreas Kirschbaum * Default loading config from 'archetype directory' rather than Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-08-02 18:44:42 UTC (rev 8610) +++ trunk/daimonin/ChangeLog 2010-08-05 17:02:56 UTC (rev 8611) @@ -1,3 +1,8 @@ +2010-08-05 Andreas Kirschbaum + + * Insert "direction" attribute only if the archetype supports a + direction. + 2010-07-24 Andreas Kirschbaum * Remove the "Apply" button from game object attributes panel as Modified: trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java 2010-08-02 18:44:42 UTC (rev 8610) +++ trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java 2010-08-05 17:02:56 UTC (rev 8611) @@ -783,7 +783,7 @@ return null; } - final Object direction = archetypeChooserModel.getDirection(); + final Object direction = effectiveArchetype.usesDirection() ? archetypeChooserModel.getDirection() : null; final List<G> parts = new ArrayList<G>(); for (R archetypePart = effectiveArchetype; archetypePart != null; archetypePart = archetypePart.getMultiNext()) { Modified: trunk/model/src/test/net/sf/gridarta/model/archetype/TestArchetype.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/archetype/TestArchetype.java 2010-08-02 18:44:42 UTC (rev 8610) +++ trunk/model/src/test/net/sf/gridarta/model/archetype/TestArchetype.java 2010-08-05 17:02:56 UTC (rev 8611) @@ -36,7 +36,13 @@ */ private static final long serialVersionUID = 1L; + /** + * The return value of {@link #usesDirection()}. + */ + private boolean usesDirection = false; + + /** * Creates a new instance. * @param archetypeName the name of the base archetype * @param faceObjectProviders the face object providers for looking up @@ -61,10 +67,18 @@ */ @Override public boolean usesDirection() { - return false; + return usesDirection; } /** + * Sets the return value of {@link #usesDirection()}. + * @param usesDirection the return value + */ + public void setUsesDirection(final boolean usesDirection) { + this.usesDirection = usesDirection; + } + + /** * {@inheritDoc} */ @NotNull Modified: trunk/model/src/test/net/sf/gridarta/model/mapmodel/DefaultMapModelTest.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/mapmodel/DefaultMapModelTest.java 2010-08-02 18:44:42 UTC (rev 8610) +++ trunk/model/src/test/net/sf/gridarta/model/mapmodel/DefaultMapModelTest.java 2010-08-05 17:02:56 UTC (rev 8611) @@ -343,6 +343,34 @@ } /** + * Test case for {@link DefaultMapModel#getAllGameObjects()}: the {@link + * BaseObject#DIRECTION} attribute is set only if the inserted object + * supports a direction. + */ + @Test + public void testUpdateDirectionOnInsert() { + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false); + mapModelCreator.getArchetypeChooserModel().setDirection(2); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator); + final BaseObject<TestGameObject, TestMapArchObject, TestArchetype, TestArchetype> archetypeWithoutDirection = mapModelCreator.getArchetype("arch_without"); + final TestArchetype archetypeWithDirection = mapModelCreator.getArchetype("arch_with"); + archetypeWithDirection.setUsesDirection(true); + + mapModel.beginTransaction("TEST"); + mapModel.getMapArchObject().setMapSize(new Size2D(1, 1)); + final TestGameObject gameObjectWithout = mapModel.insertBaseObject(archetypeWithoutDirection, new Point(0, 0), true, false, mapModelCreator.getInsertionModeSet().getAutoInsertionMode()); + final TestGameObject gameObjectWith = mapModel.insertBaseObject(archetypeWithDirection, new Point(0, 0), true, false, mapModelCreator.getInsertionModeSet().getAutoInsertionMode()); + mapModel.endTransaction(); + + Assert.assertNotNull(gameObjectWithout); + Assert.assertFalse(archetypeWithoutDirection.usesDirection()); + Assert.assertEquals(0, gameObjectWithout.getAttributeInt(BaseObject.DIRECTION)); + Assert.assertNotNull(gameObjectWith); + Assert.assertTrue(archetypeWithDirection.usesDirection()); + Assert.assertEquals(2, gameObjectWith.getAttributeInt(BaseObject.DIRECTION)); + } + + /** * Records a change event. * @param name the event name * @param mapSquares the changed map squares Modified: trunk/model/src/test/net/sf/gridarta/model/mapmodel/TestMapModelCreator.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/mapmodel/TestMapModelCreator.java 2010-08-02 18:44:42 UTC (rev 8610) +++ trunk/model/src/test/net/sf/gridarta/model/mapmodel/TestMapModelCreator.java 2010-08-05 17:02:56 UTC (rev 8611) @@ -274,4 +274,13 @@ return autojoinLists; } + /** + * Returns the {@link ArchetypeChooserModel} instance. + * @return the archetype chooser model instance + */ + @NotNull + public ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype> getArchetypeChooserModel() { + return archetypeChooserModel; + } + } // class TestMapModelCreator This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-08-26 05:20:22
|
Revision: 8616 http://gridarta.svn.sourceforge.net/gridarta/?rev=8616&view=rev Author: akirschbaum Date: 2010-08-26 05:20:16 +0000 (Thu, 26 Aug 2010) Log Message: ----------- Update project files to fix plugin scripts not working when Gridarta is started from the IDE. Modified Paths: -------------- trunk/atrinik.iml trunk/crossfire.iml trunk/daimonin.iml Modified: trunk/atrinik.iml =================================================================== --- trunk/atrinik.iml 2010-08-14 07:51:40 UTC (rev 8615) +++ trunk/atrinik.iml 2010-08-26 05:20:16 UTC (rev 8616) @@ -85,6 +85,15 @@ </library> </orderEntry> <orderEntry type="module" module-name="model" /> + <orderEntry type="module-library"> + <library> + <CLASSES> + <root url="jar://$MODULE_DIR$/lib/bsh-commands-2.0b4.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES /> + </library> + </orderEntry> </component> </module> Modified: trunk/crossfire.iml =================================================================== --- trunk/crossfire.iml 2010-08-14 07:51:40 UTC (rev 8615) +++ trunk/crossfire.iml 2010-08-26 05:20:16 UTC (rev 8616) @@ -122,6 +122,15 @@ </library> </orderEntry> <orderEntry type="module" module-name="model" /> + <orderEntry type="module-library"> + <library> + <CLASSES> + <root url="jar://$MODULE_DIR$/lib/bsh-commands-2.0b4.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES /> + </library> + </orderEntry> </component> </module> Modified: trunk/daimonin.iml =================================================================== --- trunk/daimonin.iml 2010-08-14 07:51:40 UTC (rev 8615) +++ trunk/daimonin.iml 2010-08-26 05:20:16 UTC (rev 8616) @@ -85,6 +85,15 @@ </library> </orderEntry> <orderEntry type="module" module-name="model" /> + <orderEntry type="module-library"> + <library> + <CLASSES> + <root url="jar://$MODULE_DIR$/lib/bsh-commands-2.0b4.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES /> + </library> + </orderEntry> </component> </module> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-08-26 05:41:24
|
Revision: 8617 http://gridarta.svn.sourceforge.net/gridarta/?rev=8617&view=rev Author: akirschbaum Date: 2010-08-26 05:41:18 +0000 (Thu, 26 Aug 2010) Log Message: ----------- Correctly update window menu when using 'enter xyz map' actions. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gui/mapdesktop/WindowMenuManager.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-08-26 05:20:16 UTC (rev 8616) +++ trunk/atrinik/ChangeLog 2010-08-26 05:41:18 UTC (rev 8617) @@ -1,3 +1,7 @@ +2010-08-26 Andreas Kirschbaum + + * Correctly update window menu when using 'enter xyz map' actions. + 2010-08-14 Andreas Kirschbaum * Do not anymore load maps/**/*.art or maps/**/*.trs files. Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-08-26 05:20:16 UTC (rev 8616) +++ trunk/crossfire/ChangeLog 2010-08-26 05:41:18 UTC (rev 8617) @@ -1,3 +1,7 @@ +2010-08-26 Andreas Kirschbaum + + * Correctly update window menu when using 'enter xyz map' actions. + 2010-07-24 Andreas Kirschbaum * Remove the "Apply" button from game object attributes panel as Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-08-26 05:20:16 UTC (rev 8616) +++ trunk/daimonin/ChangeLog 2010-08-26 05:41:18 UTC (rev 8617) @@ -1,3 +1,7 @@ +2010-08-26 Andreas Kirschbaum + + * Correctly update window menu when using 'enter xyz map' actions. + 2010-08-05 Andreas Kirschbaum * Insert "direction" attribute only if the archetype supports a Modified: trunk/src/app/net/sf/gridarta/gui/mapdesktop/WindowMenuManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/mapdesktop/WindowMenuManager.java 2010-08-26 05:20:16 UTC (rev 8616) +++ trunk/src/app/net/sf/gridarta/gui/mapdesktop/WindowMenuManager.java 2010-08-26 05:41:18 UTC (rev 8617) @@ -69,13 +69,13 @@ /** {@inheritDoc} */ @Override public void mapViewCreated(@NotNull final MapView<G, A, R> mapView) { - // ignore + rebuildWindowMenu(); } /** {@inheritDoc} */ @Override public void mapViewClosing(@NotNull final MapView<G, A, R> mapView) { - // ignore + rebuildWindowMenu(); } /** {@inheritDoc} */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-08-26 06:11:05
|
Revision: 8618 http://gridarta.svn.sourceforge.net/gridarta/?rev=8618&view=rev Author: akirschbaum Date: 2010-08-26 06:10:58 +0000 (Thu, 26 Aug 2010) Log Message: ----------- Dispose Graphics objects as soon as possible. Modified Paths: -------------- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/SimpleFlatMapRenderer.java trunk/src/app/net/sf/gridarta/gui/mapimagecache/MapImageCacheEntry.java trunk/src/app/net/sf/gridarta/gui/misc/MapPreview.java Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java 2010-08-26 05:41:18 UTC (rev 8617) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java 2010-08-26 06:10:58 UTC (rev 8618) @@ -347,16 +347,20 @@ // first create a storing place for the image final BufferedImage bufImage = new BufferedImage(viewWidth, viewHeight, BufferedImage.TYPE_INT_ARGB); final Graphics graphics = bufImage.getGraphics(); - graphics.setColor(Color.white); - graphics.fillRect(0, 0, viewWidth, viewHeight); + try { + graphics.setColor(Color.white); + graphics.fillRect(0, 0, viewWidth, viewHeight); - // paint the map view into the image - final Point storeOffset = new Point(borderOffset); - try { - borderOffset.setLocation(0, 0); - paintComponent(graphics, true, false); + // paint the map view into the image + final Point storeOffset = new Point(borderOffset); + try { + borderOffset.setLocation(0, 0); + paintComponent(graphics, true, false); + } finally { + borderOffset.setLocation(storeOffset); + } } finally { - borderOffset.setLocation(storeOffset); + graphics.dispose(); } return bufImage; } Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java 2010-08-26 05:41:18 UTC (rev 8617) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java 2010-08-26 06:10:58 UTC (rev 8618) @@ -176,9 +176,13 @@ } final Graphics g = backBuffer.getGraphics(); - paintSquare(g, getBorderOffsetX() + point.x * IGUIConstants.SQUARE_WIDTH, getBorderOffsetY() + point.y * IGUIConstants.SQUARE_HEIGHT, mapModel.getMapSquare(point)); - paintSquareGrid(g, point); - paintSquareSelection(g, point); + try { + paintSquare(g, getBorderOffsetX() + point.x * IGUIConstants.SQUARE_WIDTH, getBorderOffsetY() + point.y * IGUIConstants.SQUARE_HEIGHT, mapModel.getMapSquare(point)); + paintSquareGrid(g, point); + paintSquareSelection(g, point); + } finally { + g.dispose(); + } } /** @@ -212,7 +216,12 @@ return; } - paintComponent(backBuffer.getGraphics(), false, false); + final Graphics graphics = backBuffer.getGraphics(); + try { + paintComponent(graphics, false, false); + } finally { + graphics.dispose(); + } } /** @@ -257,8 +266,12 @@ return; } final Graphics g = newBackBuffer.getGraphics(); - g.setColor(getBackground()); - g.fillRect(0, 0, size.width, size.height); + try { + g.setColor(getBackground()); + g.fillRect(0, 0, size.width, size.height); + } finally { + g.dispose(); + } backBufferRef = new SoftReference<BufferedImage>(newBackBuffer); } Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/SimpleFlatMapRenderer.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/SimpleFlatMapRenderer.java 2010-08-26 05:41:18 UTC (rev 8617) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/SimpleFlatMapRenderer.java 2010-08-26 06:10:58 UTC (rev 8618) @@ -106,7 +106,12 @@ final int viewWidth = mapSize.getWidth() * IGUIConstants.SQUARE_WIDTH; final int viewHeight = mapSize.getHeight() * IGUIConstants.SQUARE_HEIGHT; final BufferedImage image = new BufferedImage(viewWidth, viewHeight, BufferedImage.TYPE_INT_ARGB); - paintComponent(image.getGraphics()); + final Graphics g = image.getGraphics(); + try { + paintComponent(g); + } finally { + g.dispose(); + } return image; } Modified: trunk/src/app/net/sf/gridarta/gui/mapimagecache/MapImageCacheEntry.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/mapimagecache/MapImageCacheEntry.java 2010-08-26 05:41:18 UTC (rev 8617) +++ trunk/src/app/net/sf/gridarta/gui/mapimagecache/MapImageCacheEntry.java 2010-08-26 06:10:58 UTC (rev 8618) @@ -19,6 +19,7 @@ package net.sf.gridarta.gui.mapimagecache; +import java.awt.Graphics; import java.awt.Image; import java.awt.image.BufferedImage; import java.io.File; @@ -152,7 +153,12 @@ return; } final BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - bufferedImage.getGraphics().drawImage(image, 0, 0, null); + final Graphics graphics = bufferedImage.getGraphics(); + try { + graphics.drawImage(image, 0, 0, null); + } finally { + graphics.dispose(); + } try { ImageIO.write(bufferedImage, "png", imageFile); Modified: trunk/src/app/net/sf/gridarta/gui/misc/MapPreview.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/misc/MapPreview.java 2010-08-26 05:41:18 UTC (rev 8617) +++ trunk/src/app/net/sf/gridarta/gui/misc/MapPreview.java 2010-08-26 06:10:58 UTC (rev 8618) @@ -242,7 +242,12 @@ img = (RenderedImage) image; } else { final BufferedImage img2 = new BufferedImage(image.getWidth(this), image.getHeight(this), BufferedImage.TYPE_INT_ARGB); - paintComponent(img2.getGraphics()); + final Graphics g = img2.getGraphics(); + try { + paintComponent(g); + } finally { + g.dispose(); + } img = img2; } ImageIO.write(img, "png", file); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-08-26 07:37:19
|
Revision: 8619 http://gridarta.svn.sourceforge.net/gridarta/?rev=8619&view=rev Author: akirschbaum Date: 2010-08-26 07:37:13 +0000 (Thu, 26 Aug 2010) Log Message: ----------- Fix memory leak when browsing maps. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gui/map/renderer/IsoMapRenderer.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-08-26 06:10:58 UTC (rev 8618) +++ trunk/atrinik/ChangeLog 2010-08-26 07:37:13 UTC (rev 8619) @@ -1,5 +1,7 @@ 2010-08-26 Andreas Kirschbaum + * Fix memory leak when browsing maps. + * Correctly update window menu when using 'enter xyz map' actions. 2010-08-14 Andreas Kirschbaum Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-08-26 06:10:58 UTC (rev 8618) +++ trunk/crossfire/ChangeLog 2010-08-26 07:37:13 UTC (rev 8619) @@ -1,5 +1,7 @@ 2010-08-26 Andreas Kirschbaum + * Fix memory leak when browsing maps. + * Correctly update window menu when using 'enter xyz map' actions. 2010-07-24 Andreas Kirschbaum Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java 2010-08-26 06:10:58 UTC (rev 8618) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java 2010-08-26 07:37:13 UTC (rev 8619) @@ -128,6 +128,23 @@ private final SmoothingRenderer smoothingRenderer; /** + * The {@link FilterConfigListener} attached to {@link #filterControl} to + * repaint all after config changes. + */ + @NotNull + private final FilterConfigListener filterConfigListener = new FilterConfigListener() { + + /** + * {@inheritDoc} + */ + @Override + public void configChanged(@NotNull final FilterConfigChangeType filterConfigChangeType, @NotNull final FilterConfig<?, ?> filterConfig) { + forceRepaint(); + } + + }; + + /** * Creates a new instance. * @param mapViewSettings the map view settings instance to use * @param filterControl the filter to use @@ -147,17 +164,6 @@ this.mapViewSettings = mapViewSettings; this.smoothingRenderer = smoothingRenderer; init(); - final FilterConfigListener filterConfigListener = new FilterConfigListener() { - - /** - * {@inheritDoc} - */ - @Override - public void configChanged(@NotNull final FilterConfigChangeType filterConfigChangeType, @NotNull final FilterConfig<?, ?> filterConfig) { - forceRepaint(); - } - - }; this.filterControl.addConfigListener(filterConfigListener); } @@ -165,6 +171,15 @@ * {@inheritDoc} */ @Override + public void closeNotify() { + super.closeNotify(); + filterControl.removeConfigListener(filterConfigListener); + } + + /** + * {@inheritDoc} + */ + @Override protected void updateSquare(@NotNull final Point point) { if (!mapModel.getMapArchObject().isPointValid(point)) { return; Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-08-26 06:10:58 UTC (rev 8618) +++ trunk/daimonin/ChangeLog 2010-08-26 07:37:13 UTC (rev 8619) @@ -1,5 +1,7 @@ 2010-08-26 Andreas Kirschbaum + * Fix memory leak when browsing maps. + * Correctly update window menu when using 'enter xyz map' actions. 2010-08-05 Andreas Kirschbaum Modified: trunk/src/app/net/sf/gridarta/gui/map/renderer/IsoMapRenderer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/renderer/IsoMapRenderer.java 2010-08-26 06:10:58 UTC (rev 8618) +++ trunk/src/app/net/sf/gridarta/gui/map/renderer/IsoMapRenderer.java 2010-08-26 07:37:13 UTC (rev 8619) @@ -92,6 +92,23 @@ private final int[] yPoints = new int[4]; /** + * The {@link FilterConfigListener} attached to {@link #filterControl} to + * repaint all after config changes. + */ + @NotNull + private final FilterConfigListener filterConfigListener = new FilterConfigListener() { + + /** + * {@inheritDoc} + */ + @Override + public void configChanged(@NotNull final FilterConfigChangeType filterConfigChangeType, @NotNull final FilterConfig<?, ?> filterConfig) { + forceRepaint(); + } + + }; + + /** * Creates a new instance. * @param spawnPointTypeNo the game object type number for spawn points * @param mapViewSettings the map view settings instance to use @@ -112,17 +129,6 @@ emptySquareIcon = systemIcons.getEmptySquareIcon(); this.mapViewSettings = mapViewSettings; this.isoMapSquareInfo = isoMapSquareInfo; - final FilterConfigListener filterConfigListener = new FilterConfigListener() { - - /** - * {@inheritDoc} - */ - @Override - public void configChanged(@NotNull final FilterConfigChangeType filterConfigChangeType, @NotNull final FilterConfig<?, ?> filterConfig) { - forceRepaint(); - } - - }; this.filterControl.addConfigListener(filterConfigListener); } @@ -130,6 +136,15 @@ * {@inheritDoc} */ @Override + public void closeNotify() { + super.closeNotify(); + filterControl.removeConfigListener(filterConfigListener); + } + + /** + * {@inheritDoc} + */ + @Override protected void clearBackground(@NotNull final Graphics g) { } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-08-30 18:30:35
|
Revision: 8621 http://gridarta.svn.sourceforge.net/gridarta/?rev=8621&view=rev Author: akirschbaum Date: 2010-08-30 18:30:27 +0000 (Mon, 30 Aug 2010) Log Message: ----------- Do not generate game object attributes redundant with archetype. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/gameobject/GameObject.java trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/scripts/DefaultScriptedEvent.java trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/scripts/DefaultScriptedEventFactory.java trunk/crossfire/ChangeLog trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/gameobject/GameObject.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/scripts/DefaultScriptedEvent.java trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/model/gameobject/GameObjectCreator.java trunk/daimonin/ChangeLog trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/gameobject/GameObject.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/scripts/DefaultScriptedEvent.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/scripts/DefaultScriptedEventFactory.java trunk/model/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java trunk/model/src/app/net/sf/gridarta/model/baseobject/BaseObject.java trunk/model/src/app/net/sf/gridarta/model/exitconnector/ExitLocation.java trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java trunk/model/src/app/net/sf/gridarta/model/validation/errors/SysObjectNotOnLayerZeroError.java trunk/model/src/test/net/sf/gridarta/model/baseobject/AbstractBaseObjectTest.java trunk/model/src/test/net/sf/gridarta/model/mapmodel/TestMapModelHelper.java trunk/model/src/test/net/sf/gridarta/model/match/NamedGameObjectMatcherTest.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/TypesBoxItemListener.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/FaceTab.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-08-26 07:57:35 UTC (rev 8620) +++ trunk/atrinik/ChangeLog 2010-08-30 18:30:27 UTC (rev 8621) @@ -1,3 +1,7 @@ +2010-08-30 Andreas Kirschbaum + + * Do not generate game object attributes redundant with archetype. + 2010-08-26 Andreas Kirschbaum * Fix memory leak when browsing maps. Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/gameobject/GameObject.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/gameobject/GameObject.java 2010-08-26 07:57:35 UTC (rev 8620) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/gameobject/GameObject.java 2010-08-30 18:30:27 UTC (rev 8621) @@ -73,7 +73,7 @@ public void addLast(@NotNull final GameObject gameObject) { // force type change when a MONSTER is put in a spawn point if (archetypeTypeSet.getTypeOfArch(this).getTypeNo() == Archetype.TYPE_SPAWN_POINT && archetypeTypeSet.getTypeOfArch(gameObject).getTypeNo() == Archetype.TYPE_MOB) { - gameObject.setAttributeString(TYPE, Integer.toString(Archetype.TYPE_SPAWN_POINT_MOB)); // change to SPAWN_POINT_MOB + gameObject.setAttributeInt(TYPE, Archetype.TYPE_SPAWN_POINT_MOB); // change to SPAWN_POINT_MOB } super.addLast(gameObject); } @@ -85,7 +85,7 @@ public void addFirst(@NotNull final GameObject gameObject) { // force type change when a MONSTER is put in a spawn point if (archetypeTypeSet.getTypeOfArch(this).getTypeNo() == Archetype.TYPE_SPAWN_POINT && archetypeTypeSet.getTypeOfArch(gameObject).getTypeNo() == Archetype.TYPE_MOB) { - gameObject.setAttributeString(TYPE, Integer.toString(Archetype.TYPE_SPAWN_POINT_MOB)); // change to SPAWN_POINT_MOB + gameObject.setAttributeInt(TYPE, Archetype.TYPE_SPAWN_POINT_MOB); // change to SPAWN_POINT_MOB } super.addFirst(gameObject); } Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/scripts/DefaultScriptedEvent.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/scripts/DefaultScriptedEvent.java 2010-08-26 07:57:35 UTC (rev 8620) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/scripts/DefaultScriptedEvent.java 2010-08-30 18:30:27 UTC (rev 8621) @@ -199,7 +199,7 @@ protected final void setEventData(@NotNull final String pluginName, @NotNull final String scriptPath, @NotNull final String options) { final int eventType = getEventType(); event.setObjectText(""); - event.setAttributeString(subtypeAttribute, Integer.toString(eventType)); + event.setAttributeInt(subtypeAttribute, eventType); event.setAttributeString(BaseObject.NAME, pluginName); event.setAttributeString(SCRIPT_PATH, scriptPath); event.setAttributeString(OPTIONS, options); Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/scripts/DefaultScriptedEventFactory.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/scripts/DefaultScriptedEventFactory.java 2010-08-26 07:57:35 UTC (rev 8620) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/scripts/DefaultScriptedEventFactory.java 2010-08-30 18:30:27 UTC (rev 8621) @@ -97,7 +97,7 @@ @Override public GameObject newEventGameObject(final int eventType) throws UndefinedEventArchetypeException { final GameObject eventGameObject = super.newEventGameObject(eventType); - eventGameObject.setAttributeString(subtypeAttribute, Integer.toString(eventType)); + eventGameObject.setAttributeInt(subtypeAttribute, eventType); return eventGameObject; } Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-08-26 07:57:35 UTC (rev 8620) +++ trunk/crossfire/ChangeLog 2010-08-30 18:30:27 UTC (rev 8621) @@ -1,3 +1,7 @@ +2010-08-30 Andreas Kirschbaum + + * Do not generate game object attributes redundant with archetype. + 2010-08-26 Andreas Kirschbaum * Fix memory leak when browsing maps. Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/gameobject/GameObject.java 2010-08-26 07:57:35 UTC (rev 8620) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/gameobject/GameObject.java 2010-08-30 18:30:27 UTC (rev 8621) @@ -69,11 +69,9 @@ */ @Override public void propagateElevation(@NotNull final BaseObject<?, ?, ?, ?> gameObject) { - final String elevation = gameObject.getAttributeString(ELEVATION, false); - if (elevation.length() != 0) { - setAttributeString(ELEVATION, elevation); - gameObject.removeAttribute(ELEVATION); - } + final int elevation = gameObject.getAttributeInt(ELEVATION, false); + setAttributeInt(ELEVATION, elevation); + gameObject.removeAttribute(ELEVATION); } /** Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/scripts/DefaultScriptedEvent.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/scripts/DefaultScriptedEvent.java 2010-08-26 07:57:35 UTC (rev 8620) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/scripts/DefaultScriptedEvent.java 2010-08-30 18:30:27 UTC (rev 8621) @@ -196,7 +196,7 @@ protected void setEventData(@NotNull final String pluginName, @NotNull final String scriptPath, @NotNull final String options) { final int eventType = getEventType(); event.setObjectText(""); - event.setAttributeString(subtypeAttribute, Integer.toString(eventType)); + event.setAttributeInt(subtypeAttribute, eventType); event.setAttributeString(PLUGIN_NAME, pluginName); event.setAttributeString(OPTIONS, scriptPath); event.setAttributeString(BaseObject.NAME, options); Modified: trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/model/gameobject/GameObjectCreator.java =================================================================== --- trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/model/gameobject/GameObjectCreator.java 2010-08-26 07:57:35 UTC (rev 8620) +++ trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/model/gameobject/GameObjectCreator.java 2010-08-30 18:30:27 UTC (rev 8621) @@ -78,7 +78,7 @@ public GameObject newGameObject(final int elevation) { final GameObject gameObject = new GameObject(archetype, faceObjectProviders, animationObjects); if (elevation != 0) { - gameObject.setAttributeString(GameObject.ELEVATION, Integer.toString(elevation)); + gameObject.setAttributeInt(GameObject.ELEVATION, elevation); } return gameObject; } Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-08-26 07:57:35 UTC (rev 8620) +++ trunk/daimonin/ChangeLog 2010-08-30 18:30:27 UTC (rev 8621) @@ -1,3 +1,7 @@ +2010-08-30 Andreas Kirschbaum + + * Do not generate game object attributes redundant with archetype. + 2010-08-26 Andreas Kirschbaum * Fix memory leak when browsing maps. Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/gameobject/GameObject.java 2010-08-26 07:57:35 UTC (rev 8620) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/gameobject/GameObject.java 2010-08-30 18:30:27 UTC (rev 8621) @@ -73,7 +73,7 @@ public void addLast(@NotNull final GameObject gameObject) { // force type change when a MONSTER is put in a spawn point if (archetypeTypeSet.getTypeOfArch(this).getTypeNo() == Archetype.TYPE_SPAWN_POINT && archetypeTypeSet.getTypeOfArch(gameObject).getTypeNo() == Archetype.TYPE_MOB) { - gameObject.setAttributeString(TYPE, Integer.toString(Archetype.TYPE_SPAWN_POINT_MOB)); // change to SPAWN_POINT_MOB + gameObject.setAttributeInt(TYPE, Archetype.TYPE_SPAWN_POINT_MOB); // change to SPAWN_POINT_MOB } super.addLast(gameObject); } @@ -85,7 +85,7 @@ public void addFirst(@NotNull final GameObject gameObject) { // force type change when a MONSTER is put in a spawn point if (archetypeTypeSet.getTypeOfArch(this).getTypeNo() == Archetype.TYPE_SPAWN_POINT && archetypeTypeSet.getTypeOfArch(gameObject).getTypeNo() == Archetype.TYPE_MOB) { - gameObject.setAttributeString(TYPE, Integer.toString(Archetype.TYPE_SPAWN_POINT_MOB)); // change to SPAWN_POINT_MOB + gameObject.setAttributeInt(TYPE, Archetype.TYPE_SPAWN_POINT_MOB); // change to SPAWN_POINT_MOB } super.addFirst(gameObject); } Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/scripts/DefaultScriptedEvent.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/scripts/DefaultScriptedEvent.java 2010-08-26 07:57:35 UTC (rev 8620) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/scripts/DefaultScriptedEvent.java 2010-08-30 18:30:27 UTC (rev 8621) @@ -199,7 +199,7 @@ protected void setEventData(@NotNull final String pluginName, @NotNull final String scriptPath, @NotNull final String options) { final int eventType = getEventType(); event.setObjectText(""); - event.setAttributeString(subtypeAttribute, Integer.toString(eventType)); + event.setAttributeInt(subtypeAttribute, eventType); event.setAttributeString(BaseObject.NAME, pluginName); event.setAttributeString(SCRIPT_PATH, scriptPath); event.setAttributeString(OPTIONS, options); Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/scripts/DefaultScriptedEventFactory.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/scripts/DefaultScriptedEventFactory.java 2010-08-26 07:57:35 UTC (rev 8620) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/scripts/DefaultScriptedEventFactory.java 2010-08-30 18:30:27 UTC (rev 8621) @@ -97,7 +97,7 @@ @Override public GameObject newEventGameObject(final int eventType) throws UndefinedEventArchetypeException { final GameObject eventGameObject = super.newEventGameObject(eventType); - eventGameObject.setAttributeString(subtypeAttribute, Integer.toString(eventType)); + eventGameObject.setAttributeInt(subtypeAttribute, eventType); return eventGameObject; } Modified: trunk/model/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2010-08-26 07:57:35 UTC (rev 8620) +++ trunk/model/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2010-08-30 18:30:27 UTC (rev 8621) @@ -377,6 +377,33 @@ * {@inheritDoc} */ @Override + public void setAttributeInt(@NotNull final String attributeName, final int value) { + final String attributeNameWithSpace = attributeName.trim() + " "; + final boolean sameAsInArchetype = getArchetype().getAttributeInt(attributeName) == value; + boolean exists = false; + final StringBuilder result = new StringBuilder(); + for (final String line : StringUtils.PATTERN_END_OF_LINE.split(getObjectText(), 0)) { + if (line.length() == 0) { + // skip empty lines that occur due to split on empty object texts. + } else if (!line.startsWith(attributeNameWithSpace)) { + result.append(line).append('\n'); + } else { + exists = true; + if (!sameAsInArchetype) { + result.append(attributeNameWithSpace).append(value).append('\n'); + } + } + } + if (!exists && !sameAsInArchetype) { + result.append(attributeNameWithSpace).append(value).append('\n'); + } + setObjectText(result.toString()); + } + + /** + * {@inheritDoc} + */ + @Override public void removeAttribute(@NotNull final String attributeName) { final String attributeNameWithSpace = attributeName.trim() + " "; // attributeName must be followed by space Modified: trunk/model/src/app/net/sf/gridarta/model/baseobject/BaseObject.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/baseobject/BaseObject.java 2010-08-26 07:57:35 UTC (rev 8620) +++ trunk/model/src/app/net/sf/gridarta/model/baseobject/BaseObject.java 2010-08-30 18:30:27 UTC (rev 8621) @@ -203,6 +203,13 @@ void setAttributeString(@NotNull String attributeName, @NotNull String value); /** + * Sets an int value attribute. + * @param attributeName the name of the attribute to update + * @param value the new value + */ + void setAttributeInt(@NotNull String attributeName, int value); + + /** * Remove the String of an arch attribute from the objectText. * @param attributeName search for "attributeName <string>" */ Modified: trunk/model/src/app/net/sf/gridarta/model/exitconnector/ExitLocation.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/exitconnector/ExitLocation.java 2010-08-26 07:57:35 UTC (rev 8620) +++ trunk/model/src/app/net/sf/gridarta/model/exitconnector/ExitLocation.java 2010-08-30 18:30:27 UTC (rev 8621) @@ -110,8 +110,8 @@ } } gameObject.setAttributeString("slaying", mapPath); - gameObject.setAttributeString("hp", Integer.toString(x)); - gameObject.setAttributeString("sp", Integer.toString(y)); + gameObject.setAttributeInt("hp", x); + gameObject.setAttributeInt("sp", y); if (updateName) { gameObject.setAttributeString(BaseObject.NAME, mapName); } Modified: trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java 2010-08-26 07:57:35 UTC (rev 8620) +++ trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java 2010-08-30 18:30:27 UTC (rev 8621) @@ -783,7 +783,7 @@ return null; } - final Object direction = effectiveArchetype.usesDirection() ? archetypeChooserModel.getDirection() : null; + final Integer direction = effectiveArchetype.usesDirection() ? archetypeChooserModel.getDirection() : null; final List<G> parts = new ArrayList<G>(); for (R archetypePart = effectiveArchetype; archetypePart != null; archetypePart = archetypePart.getMultiNext()) { @@ -795,7 +795,7 @@ part = archetypePart.newInstance(gameObjectFactory); } if (direction != null) { - part.setAttributeString(BaseObject.DIRECTION, direction.toString()); + part.setAttributeInt(BaseObject.DIRECTION, direction); } if (parts.isEmpty()) { gameObjectMatchers.updateEditType(part, activeEditType); Modified: trunk/model/src/app/net/sf/gridarta/model/validation/errors/SysObjectNotOnLayerZeroError.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/validation/errors/SysObjectNotOnLayerZeroError.java 2010-08-26 07:57:35 UTC (rev 8620) +++ trunk/model/src/app/net/sf/gridarta/model/validation/errors/SysObjectNotOnLayerZeroError.java 2010-08-30 18:30:27 UTC (rev 8621) @@ -53,7 +53,7 @@ public void correct(@NotNull final Component parentComponent) { // TODO: Ask user for (final BaseObject<G, A, R, ?> gameObject : getGameObjects()) { - gameObject.setAttributeString("layer", "0"); + gameObject.setAttributeInt("layer", 0); } } Modified: trunk/model/src/test/net/sf/gridarta/model/baseobject/AbstractBaseObjectTest.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/baseobject/AbstractBaseObjectTest.java 2010-08-26 07:57:35 UTC (rev 8620) +++ trunk/model/src/test/net/sf/gridarta/model/baseobject/AbstractBaseObjectTest.java 2010-08-30 18:30:27 UTC (rev 8621) @@ -374,6 +374,49 @@ } /** + * Checks that {@link AbstractBaseObject#setAttributeInt(String, int)} works + * as expected. + */ + @Test + public void testSetAttributeInt1() { + final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new TestAnimationObjects(); + final FaceObjectProviders faceObjectProviders = newFaceObjectProviders(); + final TestArchetype archetype1 = newArchetype("arch", "a 1\nb 0\nc 2", faceObjectProviders, animationObjects); + final GameObject<TestGameObject, TestMapArchObject, TestArchetype> gameObject = new TestGameObject(archetype1, faceObjectProviders, animationObjects); + Assert.assertEquals("", gameObject.getAttributeString("a", false)); + Assert.assertEquals("", gameObject.getAttributeString("b", false)); + Assert.assertEquals("", gameObject.getAttributeString("c", false)); + Assert.assertEquals("", gameObject.getAttributeString("d", false)); + + gameObject.setAttributeInt("a", 1); + gameObject.setAttributeInt("b", 0); + gameObject.setAttributeInt("c", 2); + gameObject.setAttributeInt("d", 0); + Assert.assertEquals("", gameObject.getAttributeString("a", false)); + Assert.assertEquals("", gameObject.getAttributeString("b", false)); + Assert.assertEquals("", gameObject.getAttributeString("c", false)); + Assert.assertEquals("", gameObject.getAttributeString("d", false)); + + gameObject.setAttributeInt("a", 0); + gameObject.setAttributeInt("b", 1); + gameObject.setAttributeInt("c", 0); + gameObject.setAttributeInt("d", 2); + Assert.assertEquals("0", gameObject.getAttributeString("a", false)); + Assert.assertEquals("1", gameObject.getAttributeString("b", false)); + Assert.assertEquals("0", gameObject.getAttributeString("c", false)); + Assert.assertEquals("2", gameObject.getAttributeString("d", false)); + + gameObject.setAttributeInt("a", 1); + gameObject.setAttributeInt("b", 0); + gameObject.setAttributeInt("c", 2); + gameObject.setAttributeInt("d", 0); + Assert.assertEquals("", gameObject.getAttributeString("a", false)); + Assert.assertEquals("", gameObject.getAttributeString("b", false)); + Assert.assertEquals("", gameObject.getAttributeString("c", false)); + Assert.assertEquals("", gameObject.getAttributeString("d", false)); + } + + /** * Checks that the {@link BaseObject#NAME} attribute of an {@link * GameObject} contains the expected value. * @param gameObject the game object to check Modified: trunk/model/src/test/net/sf/gridarta/model/mapmodel/TestMapModelHelper.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/mapmodel/TestMapModelHelper.java 2010-08-26 07:57:35 UTC (rev 8620) +++ trunk/model/src/test/net/sf/gridarta/model/mapmodel/TestMapModelHelper.java 2010-08-30 18:30:27 UTC (rev 8621) @@ -107,15 +107,15 @@ this.gameObjectFactory = gameObjectFactory; floorArchetype = new TestArchetype("floor", faceObjectProviders, animationObjects); - floorArchetype.setAttributeString(BaseObject.TYPE, Integer.toString(FLOOR_TYPE)); + floorArchetype.setAttributeInt(BaseObject.TYPE, FLOOR_TYPE); archetypeSet.addArchetype(floorArchetype); exitArchetype = new TestArchetype("exit", faceObjectProviders, animationObjects); - exitArchetype.setAttributeString(BaseObject.TYPE, Integer.toString(EXIT_TYPE)); + exitArchetype.setAttributeInt(BaseObject.TYPE, EXIT_TYPE); archetypeSet.addArchetype(exitArchetype); mob21Archetype = new TestArchetype("mob21", faceObjectProviders, animationObjects); - mob21Archetype.setAttributeString(BaseObject.TYPE, Integer.toString(MOB_TYPE)); + mob21Archetype.setAttributeInt(BaseObject.TYPE, MOB_TYPE); archetypeSet.addArchetype(mob21Archetype); final TestArchetype mob21bArchetype = new TestArchetype("mob21b", faceObjectProviders, animationObjects); mob21bArchetype.setMultiX(1); Modified: trunk/model/src/test/net/sf/gridarta/model/match/NamedGameObjectMatcherTest.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/match/NamedGameObjectMatcherTest.java 2010-08-26 07:57:35 UTC (rev 8620) +++ trunk/model/src/test/net/sf/gridarta/model/match/NamedGameObjectMatcherTest.java 2010-08-30 18:30:27 UTC (rev 8621) @@ -111,7 +111,7 @@ @NotNull private static TestArchetype newArchetype(@NotNull final String archetypeName, final int typeNo, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects) { final TestArchetype archetype = new TestArchetype(archetypeName, faceObjectProviders, animationObjects); - archetype.setAttributeString(BaseObject.TYPE, Integer.toString(typeNo)); + archetype.setAttributeInt(BaseObject.TYPE, typeNo); return archetype; } Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2010-08-26 07:57:35 UTC (rev 8620) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2010-08-30 18:30:27 UTC (rev 8621) @@ -1286,7 +1286,7 @@ // --- parsing succeeded, now we write it into the gameObject/map --- final int typeNo = gameObject.getTypeNo(); gameObject.setObjectText(newArchText.toString()); - gameObject.setAttributeString(BaseObject.TYPE, Integer.toString(typeNo)); + gameObject.setAttributeInt(BaseObject.TYPE, typeNo); if (newMsg[0] != null) { // set new msg text only when it is not equal to Archetype Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/TypesBoxItemListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/TypesBoxItemListener.java 2010-08-26 07:57:35 UTC (rev 8620) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/TypesBoxItemListener.java 2010-08-30 18:30:27 UTC (rev 8621) @@ -154,7 +154,7 @@ archetypeType = newType; // change the gameObject to be of the new type: - gameObject.setAttributeString(BaseObject.TYPE, Integer.toString(newType.getTypeNo())); + gameObject.setAttributeInt(BaseObject.TYPE, newType.getTypeNo()); dialogAttributes.clear(); type = typeComboBox.getSelectedIndex(); Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java 2010-08-26 07:57:35 UTC (rev 8620) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java 2010-08-30 18:30:27 UTC (rev 8621) @@ -473,7 +473,7 @@ final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); mapModel.beginTransaction("Change object attributes"); try { - selectedGameObject.setAttributeString(BaseObject.DIRECTION, Integer.toString(direction)); + selectedGameObject.setAttributeInt(BaseObject.DIRECTION, direction); } finally { mapModel.endTransaction(); } Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/FaceTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/FaceTab.java 2010-08-26 07:57:35 UTC (rev 8620) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/FaceTab.java 2010-08-30 18:30:27 UTC (rev 8621) @@ -121,7 +121,7 @@ final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); mapModel.beginTransaction("Change object attributes"); try { - gameObject.setAttributeString(BaseObject.DIRECTION, Integer.toString(dir)); + gameObject.setAttributeInt(BaseObject.DIRECTION, dir); } finally { mapModel.endTransaction(); } @@ -356,7 +356,7 @@ if (isAnimated == (gameObject.getArchetype().getAttributeInt("is_animated") != 0)) { gameObject.removeAttribute("is_animated"); } else { - gameObject.setAttributeString("is_animated", isAnimated ? "1" : "0"); + gameObject.setAttributeInt("is_animated", isAnimated ? 1 : 0); } final String animSpeed = animSpeedTextField.getText().trim(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-08-31 20:36:54
|
Revision: 8624 http://gridarta.svn.sourceforge.net/gridarta/?rev=8624&view=rev Author: akirschbaum Date: 2010-08-31 20:36:46 +0000 (Tue, 31 Aug 2010) Log Message: ----------- Add option to skip squares in "random fill" that contain similar game objects. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/model/src/app/net/sf/gridarta/model/floodfill/FillUtils.java trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java trunk/src/app/net/sf/gridarta/mainactions/MainActions.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 Added Paths: ----------- trunk/model/src/test/net/sf/gridarta/model/floodfill/ trunk/model/src/test/net/sf/gridarta/model/floodfill/FillUtilsTest.java trunk/src/app/net/sf/gridarta/mainactions/RandomFillDialog.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-08-31 20:08:36 UTC (rev 8623) +++ trunk/atrinik/ChangeLog 2010-08-31 20:36:46 UTC (rev 8624) @@ -1,3 +1,8 @@ +2010-08-31 Andreas Kirschbaum + + * Add option to skip squares in "random fill" that contain similar + game objects. + 2010-08-30 Andreas Kirschbaum * Do not generate game object attributes redundant with archetype. Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-08-31 20:08:36 UTC (rev 8623) +++ trunk/crossfire/ChangeLog 2010-08-31 20:36:46 UTC (rev 8624) @@ -1,3 +1,8 @@ +2010-08-31 Andreas Kirschbaum + + * Add option to skip squares in "random fill" that contain similar + game objects. + 2010-08-30 Andreas Kirschbaum * Do not generate game object attributes redundant with archetype. Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-08-31 20:08:36 UTC (rev 8623) +++ trunk/daimonin/ChangeLog 2010-08-31 20:36:46 UTC (rev 8624) @@ -1,3 +1,8 @@ +2010-08-31 Andreas Kirschbaum + + * Add option to skip squares in "random fill" that contain similar + game objects. + 2010-08-30 Andreas Kirschbaum * Do not generate game object attributes redundant with archetype. Modified: trunk/model/src/app/net/sf/gridarta/model/floodfill/FillUtils.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/floodfill/FillUtils.java 2010-08-31 20:08:36 UTC (rev 8623) +++ trunk/model/src/app/net/sf/gridarta/model/floodfill/FillUtils.java 2010-08-31 20:36:46 UTC (rev 8624) @@ -20,7 +20,10 @@ package net.sf.gridarta.model.floodfill; import java.awt.Point; +import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.baseobject.BaseObject; import net.sf.gridarta.model.gameobject.GameObject; @@ -28,8 +31,10 @@ import net.sf.gridarta.model.mapmodel.InsertionMode; import net.sf.gridarta.model.mapmodel.InsertionModeSet; import net.sf.gridarta.model.mapmodel.MapModel; +import net.sf.gridarta.model.mapmodel.MapSquare; import net.sf.gridarta.utils.RandomUtils; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Utility class implementing fill operations on map instances. @@ -50,8 +55,10 @@ * @param insertionMode the insertion mode to use * @param gameObjects the game objects to fill with * @param density the fill density in percent; -1 to disable + * @param noAdjacent whether squares are skipped if an adjacent squares is + * not free */ - public static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void fill(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Point[] selection, @NotNull final InsertionMode<G, A, R> insertionMode, @NotNull final List<? extends BaseObject<G, A, R, ?>> gameObjects, final int density) { + public static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void fill(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Point[] selection, @NotNull final InsertionMode<G, A, R> insertionMode, @NotNull final List<? extends BaseObject<G, A, R, ?>> gameObjects, final int density, final boolean noAdjacent) { if (selection.length <= 0) { return; } @@ -60,6 +67,16 @@ return; } + @Nullable final Set<String> archetypeNames; + if (noAdjacent) { + archetypeNames = new HashSet<String>(); + for (final BaseObject<?, ?, ?, ?> baseObject : gameObjects) { + archetypeNames.add(baseObject.getArchetype().getArchetypeName()); + } + } else { + archetypeNames = null; + } + mapModel.beginTransaction("Fill"); // TODO; I18N/L10N try { for (final Point p : selection) { @@ -67,6 +84,14 @@ continue; } final BaseObject<G, A, R, ?> gameObject = gameObjects.get(RandomUtils.rnd.nextInt(gameObjects.size())); + if (archetypeNames != null) { + final Archetype<G, A, R> archetype = gameObject.getArchetype(); + final int w = archetype.getSizeX(); + final int h = archetype.getSizeY(); + if (containsArchetype(mapModel, archetypeNames, p, w, h)) { + continue; + } + } mapModel.insertBaseObject(gameObject, p, false, false, insertionMode); } } finally { @@ -75,6 +100,41 @@ } /** + * Checks whether an area and its adjacent squares of a map does contain an + * archetype. + * @param mapModel the map model to check + * @param archetypeNames the archetype names to check for + * @param p the top left corner of the area to check + * @param w the width of the area to check + * @param h the height of the area to check + * @return whether a similar game object was found + */ + private static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> boolean containsArchetype(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Collection<String> archetypeNames, @NotNull final Point p, final int w, final int h) { + final Point pos = new Point(); + for (int dy = -1; dy < h+1; dy++) { + pos.y = p.y + dy; + for (int dx = -1; dx < w+1; dx++) { + pos.x = p.x + dx; + final MapSquare<G, A, R> mapSquare; + // This exception is expected at the border of the map. + //noinspection ProhibitedExceptionCaught + try { + mapSquare = mapModel.getMapSquare(pos); + } catch (final ArrayIndexOutOfBoundsException ignored) { + continue; + } + + for (final GameObject<G, A, R> gameObject : mapSquare) { + if (archetypeNames.contains(gameObject.getHead().getArchetype().getArchetypeName())) { + return true; + } + } + } + } + return false; + } + + /** * Flood-fill the the map, starting at the cursor position. * @param mapModel the map to fill * @param start the starting location Added: trunk/model/src/test/net/sf/gridarta/model/floodfill/FillUtilsTest.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/floodfill/FillUtilsTest.java (rev 0) +++ trunk/model/src/test/net/sf/gridarta/model/floodfill/FillUtilsTest.java 2010-08-31 20:36:46 UTC (rev 8624) @@ -0,0 +1,83 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.model.floodfill; + +import java.awt.Point; +import java.util.ArrayList; +import java.util.List; +import net.sf.gridarta.model.archetype.DuplicateArchetypeException; +import net.sf.gridarta.model.archetype.TestArchetype; +import net.sf.gridarta.model.baseobject.BaseObject; +import net.sf.gridarta.model.gameobject.TestGameObject; +import net.sf.gridarta.model.maparchobject.TestMapArchObject; +import net.sf.gridarta.model.mapmodel.CannotInsertGameObjectException; +import net.sf.gridarta.model.mapmodel.InsertionMode; +import net.sf.gridarta.model.mapmodel.MapModel; +import net.sf.gridarta.model.mapmodel.TestMapModelCreator; +import net.sf.gridarta.model.mapmodel.TestMapModelHelper; +import org.junit.Assert; +import org.junit.Test; + +/** + * Regression tests for {@link FillUtils}. + * @author Andreas Kirschbaum + */ +public class FillUtilsTest { + + /** + * Checks that {@link FillUtils#fill(MapModel, Point[], InsertionMode, List, + * int, boolean)} works correctly when skipping adjacent squares. + * @throws DuplicateArchetypeException if the test fails + * @throws CannotInsertGameObjectException if the test fails + */ + @Test + public void testFillAdjacent() throws CannotInsertGameObjectException, DuplicateArchetypeException { + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false); + final TestMapModelHelper mapModelHelper = mapModelCreator.newMapModelCreator(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapModelCreator.newMapModel(4, 5); + + final TestArchetype head = mapModelCreator.getArchetype("2x2a"); + head.setAttributeInt(BaseObject.TYPE, 1); + final TestArchetype tail1 = mapModelCreator.getArchetype("2x2b"); + tail1.setMultiX(1); + head.addTailPart(tail1); + final TestArchetype tail2 = mapModelCreator.getArchetype("2x2c"); + tail2.setMultiY(1); + head.addTailPart(tail2); + final TestArchetype tail3 = mapModelCreator.getArchetype("2x2d"); + tail3.setMultiX(1); + tail3.setMultiY(1); + head.addTailPart(tail3); + + mapModel.beginTransaction("TEST"); + mapModelHelper.insertArchetype(mapModel, new Point(0, 2), head, false); + + final Point[] selection = { new Point(2, 0), }; + final List<TestGameObject> gameObjects = new ArrayList<TestGameObject>(); + gameObjects.add(mapModelCreator.getGameObjectFactory().createGameObject(head)); + + FillUtils.fill(mapModel, selection, mapModelCreator.getInsertionModeSet().getTopmostInsertionMode(), gameObjects, 100, true); + Assert.assertTrue(mapModel.getMapSquare(new Point(2, 0)).isEmpty()); + + FillUtils.fill(mapModel, selection, mapModelCreator.getInsertionModeSet().getTopmostInsertionMode(), gameObjects, 100, false); + Assert.assertFalse(mapModel.getMapSquare(new Point(2, 0)).isEmpty()); + } + +} // class FillUtilsTest Property changes on: trunk/model/src/test/net/sf/gridarta/model/floodfill/FillUtilsTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java 2010-08-31 20:08:36 UTC (rev 8623) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java 2010-08-31 20:36:46 UTC (rev 8624) @@ -204,7 +204,7 @@ throw new AssertionError(); } final MapView<G, A, R> mapView = e.getMapView(); - FillUtils.fill(mapView.getMapControl().getMapModel(), mapView.getMapViewBasic().getSelection(), insertionMode, objectChooser.getSelections(), -1); + FillUtils.fill(mapView.getMapControl().getMapModel(), mapView.getMapViewBasic().getSelection(), insertionMode, objectChooser.getSelections(), -1, false); } } Modified: trunk/src/app/net/sf/gridarta/mainactions/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2010-08-31 20:08:36 UTC (rev 8623) +++ trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2010-08-31 20:36:46 UTC (rev 8624) @@ -29,7 +29,6 @@ import java.util.Set; import javax.swing.Action; import javax.swing.JFrame; -import javax.swing.JOptionPane; import net.sf.gridarta.commands.Collector; import net.sf.gridarta.gui.copybuffer.CopyBuffer; import net.sf.gridarta.gui.map.mapview.MapView; @@ -71,7 +70,6 @@ import net.sf.gridarta.utils.ActionUtils; import net.sf.gridarta.utils.Exiter; import net.sf.gridarta.utils.ExiterListener; -import net.sf.gridarta.utils.NumberUtils; import net.sf.gridarta.utils.Size2D; import net.sf.gridarta.validation.DelegatingMapValidator; import net.sf.japi.swing.action.ActionBuilder; @@ -336,6 +334,12 @@ private final Action aValidateMap; /** + * The {@link RandomFillDialog} instance. + */ + @NotNull + private final RandomFillDialog randomFillDialog = new RandomFillDialog(); + + /** * The last known active map, or <code>null</code> if no map is active. */ @Nullable @@ -1515,7 +1519,7 @@ * @param insertionMode the insertion mode to use */ private void fill(@NotNull final MapView<G, A, R> mapView, @NotNull final InsertionMode<G, A, R> insertionMode) { - FillUtils.fill(mapView.getMapControl().getMapModel(), mapView.getMapViewBasic().getSelection(), insertionMode, objectChooser.getSelections(), -1); + FillUtils.fill(mapView.getMapControl().getMapModel(), mapView.getMapViewBasic().getSelection(), insertionMode, objectChooser.getSelections(), -1, false); } /** @@ -1524,32 +1528,14 @@ * @param insertionMode the insertion mode to use */ private void fillRandom(@NotNull final MapView<G, A, R> mapView, @NotNull final InsertionMode<G, A, R> insertionMode) { - final int rand = getFillDensity("Random fill"); - if (rand >= 0) { - FillUtils.fill(mapView.getMapControl().getMapModel(), mapView.getMapViewBasic().getSelection(), insertionMode, objectChooser.getSelections(), rand); + if (!randomFillDialog.showRandomFillDialog(parent)) { + return; } - } - /** - * Asks the user for the fill density. - * @param title the title for the dialog box - * @return the fill density or <code>-1</code> if the dialog was cancelled - */ - private int getFillDensity(@NotNull final String title) { - String input = "100"; - while (true) { - input = (String) JOptionPane.showInputDialog(parent, "Enter a fill density between 1-100", title, JOptionPane.QUESTION_MESSAGE, null, null, input); - if (input == null) { - return -1; - } - - final int rand = NumberUtils.parseInt(input); - if (rand < 1 || rand > 100) { - JOptionPane.showMessageDialog(parent, "The fill density must be between 1-100.", "Illegal Value.", JOptionPane.ERROR_MESSAGE); - } else { - return rand; - } - } + final int fillDensity = randomFillDialog.getFillDensity(); + final boolean noAdjacent = randomFillDialog.isRandomFillSkipAdjacentSquares(); + final Point[] selection = mapView.getMapViewBasic().getSelection(); + FillUtils.fill(mapView.getMapControl().getMapModel(), selection, insertionMode, objectChooser.getSelections(), fillDensity, noAdjacent); } } // class MainActions Added: trunk/src/app/net/sf/gridarta/mainactions/RandomFillDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/mainactions/RandomFillDialog.java (rev 0) +++ trunk/src/app/net/sf/gridarta/mainactions/RandomFillDialog.java 2010-08-31 20:36:46 UTC (rev 8624) @@ -0,0 +1,289 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.mainactions; + +import java.awt.Component; +import java.awt.Dialog; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.JTextComponent; +import net.sf.gridarta.gui.utils.GUIConstants; +import net.sf.gridarta.gui.utils.TextComponentUtils; +import net.sf.gridarta.utils.ActionBuilderUtils; +import net.sf.gridarta.utils.NumberUtils; +import net.sf.japi.swing.action.ActionBuilder; +import net.sf.japi.swing.action.ActionBuilderFactory; +import net.sf.japi.swing.action.ActionMethod; +import net.sf.japi.swing.action.ToggleAction; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Displays a dialog asking for parameters for the "random fill" function. + * @author Andreas Kirschbaum + */ +public class RandomFillDialog { + + /** + * Action Builder to create Actions. + */ + @NotNull + private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); + + /** + * The {@link JOptionPane} instance used to create dialogs. + */ + @NotNull + private final JOptionPane optionPane = new JOptionPane(); + + /** + * The "OK" button. + */ + @NotNull + private final JButton okButton = new JButton(ACTION_BUILDER.createAction(false, "randomFillOkay", this)); + + /** + * The "Cancel" button. + */ + @NotNull + private final JButton cancelButton = new JButton(ACTION_BUILDER.createAction(false, "randomFillCancel", this)); + + /** + * The text field for specifying the fill density. + */ + @NotNull + private final JTextComponent fillDensityTextField = new JTextField(16); + + /** + * The {@link JDialog} instance or <code>null</code> if not yet created. + */ + @Nullable + private JDialog dialog = null; + + /** + * Whether adjacent squares are checked. + */ + private boolean skipAdjacentSquares = false; + + /** + * Creates a new instance. + */ + public RandomFillDialog() { + okButton.setDefaultCapable(true); + optionPane.setOptions(new Object[] { okButton, cancelButton }); + final JPanel panel = new JPanel(); + panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); + panel.setBorder(GUIConstants.DIALOG_BORDER); + panel.add(new JLabel(ActionBuilderUtils.getString(ACTION_BUILDER, "randomFillDensity.text"))); + panel.add(fillDensityTextField); + panel.add(Box.createVerticalStrut(5)); + final ToggleAction skipAdjacentSquaresAction = (ToggleAction) ACTION_BUILDER.createToggle(false, "randomFillSkipAdjacentSquares", this); + panel.add(skipAdjacentSquaresAction.createCheckBox()); + optionPane.setMessage(panel); + + fillDensityTextField.setText(ActionBuilderUtils.getString(ACTION_BUILDER, "randomFillDensity.default")); + TextComponentUtils.setAutoSelectOnFocus(fillDensityTextField); + final DocumentListener documentListener = new DocumentListener() { + + /** {@inheritDoc} */ + @Override + public void insertUpdate(@NotNull final DocumentEvent e) { + updateOkButton(); + } + + /** {@inheritDoc} */ + @Override + public void removeUpdate(@NotNull final DocumentEvent e) { + updateOkButton(); + } + + /** {@inheritDoc} */ + @Override + public void changedUpdate(@NotNull final DocumentEvent e) { + updateOkButton(); + } + + }; + + fillDensityTextField.getDocument().addDocumentListener(documentListener); + } + + /** + * The {@link WindowListener} attached to {@link #dialog} to call {@link + * JOptionPane#selectInitialValue()} after the dialog has been shown. + */ + @NotNull + private final WindowListener windowListener = new WindowListener() { + + /** + * {@inheritDoc} + */ + @Override + public void windowOpened(final WindowEvent e) { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override + public void windowClosing(final WindowEvent e) { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override + public void windowClosed(final WindowEvent e) { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override + public void windowIconified(final WindowEvent e) { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override + public void windowDeiconified(final WindowEvent e) { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override + public void windowActivated(final WindowEvent e) { + fillDensityTextField.requestFocusInWindow(); + assert dialog != null; + dialog.removeWindowListener(windowListener); + } + + /** + * {@inheritDoc} + */ + @Override + public void windowDeactivated(final WindowEvent e) { + // ignore + } + + }; + + /** + * Updates the enabled state of the "OK" button depending on the dialog's + * contents. + */ + private void updateOkButton() { + okButton.setEnabled(isOkButtonEnabled()); + } + + /** + * Displays the random fill dialog. + * @param parent the parent component for the dialog + * @return whether the dialog was closed with "OK" + */ + public boolean showRandomFillDialog(@NotNull final Component parent) { + final JDialog tmpDialog; + if (dialog == null) { + tmpDialog = optionPane.createDialog(parent, ActionBuilderUtils.getString(ACTION_BUILDER, "randomFillTitle")); + dialog = tmpDialog; + tmpDialog.getRootPane().setDefaultButton(okButton); + optionPane.selectInitialValue(); + tmpDialog.setModalityType(Dialog.ModalityType.DOCUMENT_MODAL); + } else { + tmpDialog = dialog; + } + okButton.setEnabled(isOkButtonEnabled()); + tmpDialog.addWindowListener(windowListener); + tmpDialog.setVisible(true); + tmpDialog.removeWindowListener(windowListener); + return optionPane.getValue() == okButton; + } + + /** + * Action method to close the dialog with "OK". + */ + @ActionMethod + public void randomFillOkay() { + if (isOkButtonEnabled()) { + optionPane.setValue(okButton); + } + } + + /** + * Action method for "skip adjacent squares" action. + * @return whether the checkbox is checked + */ + @ActionMethod + public boolean isRandomFillSkipAdjacentSquares() { + return skipAdjacentSquares; + } + + /** + * Action method for "skip adjacent squares" action. + * @param skipAdjacentSquares whether the checkbox is checked + */ + @ActionMethod + public void setRandomFillSkipAdjacentSquares(final boolean skipAdjacentSquares) { + this.skipAdjacentSquares = skipAdjacentSquares; + } + + /** + * Action method to close the dialog with "Cancel". + */ + @ActionMethod + public void randomFillCancel() { + optionPane.setValue(cancelButton); + } + + /** + * Returns whether the "OK" button is enabled. + * @return whether the "OK" button is enabled + */ + private boolean isOkButtonEnabled() { + final int fillDensity = getFillDensity(); + return 0 < fillDensity && fillDensity <= 100; + } + + /** + * Returns the fill density. + * @return the fill density + */ + public int getFillDensity() { + return NumberUtils.parseInt(fillDensityTextField.getText()); + } + +} // class RandomFillDialog Property changes on: trunk/src/app/net/sf/gridarta/mainactions/RandomFillDialog.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2010-08-31 20:08:36 UTC (rev 8623) +++ trunk/src/app/net/sf/gridarta/messages.properties 2010-08-31 20:36:46 UTC (rev 8624) @@ -1638,3 +1638,14 @@ createBookmark.description=Description: createBookmarkOk.text=Create createBookmarkCancel.text=Cancel + + +#################### +# Random Fill Dialog +randomFillTitle=Random Fill +randomFillDensity.text=Enter a fill density between 1-100: +randomFillDensity.default=10 +randomFillSkipAdjacentSquares.text=Skip if adjacent square is filled +randomFillSkipAdjacentSquares.shortdescription=If checked, do not fill squares for which an adjacent square contains a similar game object. +randomFillOkay.text=Ok +randomFillCancel.text=Cancel Modified: trunk/src/app/net/sf/gridarta/messages_de.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_de.properties 2010-08-31 20:08:36 UTC (rev 8623) +++ trunk/src/app/net/sf/gridarta/messages_de.properties 2010-08-31 20:36:46 UTC (rev 8624) @@ -1427,3 +1427,13 @@ createBookmark.description=Beschreibung: createBookmarkOk.text=OK createBookmarkCancel.text=Abbruch + + +#################### +# Random Fill Dialog +randomFillTitle=Z\xFCf\xE4llig F\xFCllen +randomFillDensity.text=F\xFClldichte in % (1-100): +randomFillSkipAdjacentSquares.text=Angrenzende Felder nicht f\xFCllen +randomFillSkipAdjacentSquares.shortdescription=Ignoriert Felder f\xFCr die ein angrenzendes Feld bereits ein \xE4hnliches Objekt enth\xE4lt. +randomFillOkay.text=OK +randomFillCancel.text=Abbrechen Modified: trunk/src/app/net/sf/gridarta/messages_fr.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_fr.properties 2010-08-31 20:08:36 UTC (rev 8623) +++ trunk/src/app/net/sf/gridarta/messages_fr.properties 2010-08-31 20:36:46 UTC (rev 8624) @@ -1410,3 +1410,13 @@ #createBookmark.description= #createBookmarkOk.text= #createBookmarkCancel.text= + + +#################### +# Random Fill Dialog +#randomFillTitle= +#randomFillDensity.text= +#randomFillSkipAdjacentSquares.text= +#randomFillSkipAdjacentSquares.shortdescription= +#randomFillOkay.text= +#randomFillCancel.text= Modified: trunk/src/app/net/sf/gridarta/messages_sv.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_sv.properties 2010-08-31 20:08:36 UTC (rev 8623) +++ trunk/src/app/net/sf/gridarta/messages_sv.properties 2010-08-31 20:36:46 UTC (rev 8624) @@ -1415,3 +1415,13 @@ #createBookmark.description= #createBookmarkOk.text= #createBookmarkCancel.text= + + +#################### +# Random Fill Dialog +#randomFillTitle= +#randomFillDensity.text= +#randomFillSkipAdjacentSquares.text= +#randomFillSkipAdjacentSquares.shortdescription= +randomFillOkay.text=Ok +randomFillCancel.text=Avbryt This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-09-01 05:45:45
|
Revision: 8625 http://gridarta.svn.sourceforge.net/gridarta/?rev=8625&view=rev Author: akirschbaum Date: 2010-09-01 05:45:39 +0000 (Wed, 01 Sep 2010) Log Message: ----------- Remove unused "Inventory:" element from game object attributes dialogs. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-08-31 20:36:46 UTC (rev 8624) +++ trunk/atrinik/ChangeLog 2010-09-01 05:45:39 UTC (rev 8625) @@ -1,3 +1,8 @@ +2010-09-01 Andreas Kirschbaum + + * Remove unused "Inventory:" element from game object attributes + dialogs. + 2010-08-31 Andreas Kirschbaum * Add option to skip squares in "random fill" that contain similar Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-08-31 20:36:46 UTC (rev 8624) +++ trunk/crossfire/ChangeLog 2010-09-01 05:45:39 UTC (rev 8625) @@ -1,3 +1,8 @@ +2010-09-01 Andreas Kirschbaum + + * Remove unused "Inventory:" element from game object attributes + dialogs. + 2010-08-31 Andreas Kirschbaum * Add option to skip squares in "random fill" that contain similar Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-08-31 20:36:46 UTC (rev 8624) +++ trunk/daimonin/ChangeLog 2010-09-01 05:45:39 UTC (rev 8625) @@ -1,3 +1,8 @@ +2010-09-01 Andreas Kirschbaum + + * Remove unused "Inventory:" element from game object attributes + dialogs. + 2010-08-31 Andreas Kirschbaum * Add option to skip squares in "random fill" that contain similar Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2010-08-31 20:36:46 UTC (rev 8624) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2010-09-01 05:45:39 UTC (rev 8625) @@ -52,13 +52,10 @@ import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; -import javax.swing.JSplitPane; import javax.swing.JTabbedPane; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.JTextPane; -import javax.swing.JViewport; -import javax.swing.ScrollPaneConstants; import javax.swing.SwingConstants; import javax.swing.filechooser.FileFilter; import javax.swing.text.BadLocationException; @@ -842,11 +839,7 @@ // first split top-left and -right final ArchetypeType archetypeType = archetypeTypeSet.getArchetypeType(gameObject); final JComponent leftPane = buildHeader(archetypeTypeSet.getArchetypeTypeIndex(archetypeType), archetypeType); - final JScrollPane rightPane = buildInv(); - //Create a split pane with the two scroll panes in it. - final Component splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPane, rightPane); - // Now split horizontally buildAttribute(); centerPanel = new JPanel(cardLayout); @@ -866,7 +859,7 @@ gbc.fill = GridBagConstraints.BOTH; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.weighty = 0.0; - contentPanel.add(splitPane, gbc); + contentPanel.add(leftPane, gbc); gbc.weighty = 1.0; contentPanel.add(centerPanel, gbc); @@ -1010,26 +1003,6 @@ } /** - * Constructs the upper right part of the attribute dialog, containing the - * object's inventory. - * @return a <code>JScrollPane</code> with the upper right part of the - * dialog window - */ - @NotNull - private static JScrollPane buildInv() { - final JPanel inv = new JPanel(); // the final thing, in a panel - inv.add(new JLabel("Inventory:")); // create label - - final JScrollPane scrollPane = new JScrollPane(inv); - scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); - scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); - scrollPane.setSize(80, 70); - - return scrollPane; - } - - /** * Constructs the central part of the attribute dialog, containing the * object's gameObject attributes. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-09-01 06:28:32
|
Revision: 8628 http://gridarta.svn.sourceforge.net/gridarta/?rev=8628&view=rev Author: akirschbaum Date: 2010-09-01 06:28:24 +0000 (Wed, 01 Sep 2010) Log Message: ----------- Extract PickmapSettings from PickmapChooserControl; removes some cyclic dependencies involving PickmapChooserControl. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java trunk/src/app/net/sf/gridarta/gui/map/tools/ToolPalette.java trunk/src/app/net/sf/gridarta/gui/map/tools/ToolSelector.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java Added Paths: ----------- trunk/model/src/app/net/sf/gridarta/model/pickmapsettings/ trunk/model/src/app/net/sf/gridarta/model/pickmapsettings/AbstractPickmapSettings.java trunk/model/src/app/net/sf/gridarta/model/pickmapsettings/DefaultPickmapSettings.java trunk/model/src/app/net/sf/gridarta/model/pickmapsettings/PickmapSettings.java trunk/model/src/app/net/sf/gridarta/model/pickmapsettings/PickmapSettingsListener.java Added: trunk/model/src/app/net/sf/gridarta/model/pickmapsettings/AbstractPickmapSettings.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/pickmapsettings/AbstractPickmapSettings.java (rev 0) +++ trunk/model/src/app/net/sf/gridarta/model/pickmapsettings/AbstractPickmapSettings.java 2010-09-01 06:28:24 UTC (rev 8628) @@ -0,0 +1,101 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.model.pickmapsettings; + +import net.sf.gridarta.utils.EventListenerList2; +import org.jetbrains.annotations.NotNull; + +/** + * Abstract base class for {@link PickmapSettings} implementations. + * @author Andreas Kirschbaum + */ +public abstract class AbstractPickmapSettings implements PickmapSettings { + + /** + * The MapViewSettingsListeners to inform of changes. + */ + @NotNull + private final EventListenerList2<PickmapSettingsListener> listenerList = new EventListenerList2<PickmapSettingsListener>(PickmapSettingsListener.class); + + /** + * The immutable state. + */ + private boolean locked = loadLocked(); + + /** + * {@inheritDoc} + */ + @Override + public void addPickmapSettingsListener(@NotNull final PickmapSettingsListener listener) { + listenerList.add(listener); + } + + /** + * {@inheritDoc} + */ + @Override + public void removePickmapSettingsListener(@NotNull final PickmapSettingsListener listener) { + listenerList.remove(listener); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean isLocked() { + return locked; + } + + /** + * {@inheritDoc} + */ + @Override + public void setLocked(final boolean locked) { + if (this.locked == locked) { + return; + } + + this.locked = locked; + saveLocked(locked); + fireLockedChanged(); + } + + /** + * Informs all registered listeners that the immutrable state has changed. + */ + private void fireLockedChanged() { + for (final PickmapSettingsListener listener : listenerList.getListeners()) { + listener.lockedChanged(locked); + } + } + + /** + * Loads the default value for {@link #locked}. + * @return the default value + */ + protected abstract boolean loadLocked(); + + /** + * Saves the {@link #locked} value. + * @param locked the locked value + */ + protected abstract void saveLocked(final boolean locked); + +} // class AbstractPickmapSettings Property changes on: trunk/model/src/app/net/sf/gridarta/model/pickmapsettings/AbstractPickmapSettings.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/model/src/app/net/sf/gridarta/model/pickmapsettings/DefaultPickmapSettings.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/pickmapsettings/DefaultPickmapSettings.java (rev 0) +++ trunk/model/src/app/net/sf/gridarta/model/pickmapsettings/DefaultPickmapSettings.java 2010-09-01 06:28:24 UTC (rev 8628) @@ -0,0 +1,62 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.model.pickmapsettings; + +import java.util.prefs.Preferences; +import net.sf.gridarta.MainControl; +import org.jetbrains.annotations.NotNull; + +/** + * Default {@link PickmapSettings} implementation. Attributes are retained + * across editor restarts. The attributes are stored in the {@link + * Preferences}. + * @author Andreas Kirschbaum + */ +public class DefaultPickmapSettings extends AbstractPickmapSettings { + + /** + * Key for saving {@link #locked} state in preferences. + */ + @NotNull + private static final String LOCKED_KEY = "pickmapSettings.locked"; + + /** + * Preferences. + */ + @NotNull + private static final Preferences preferences = Preferences.userNodeForPackage(MainControl.class); + + /** + * {@inheritDoc} + */ + @Override + protected boolean loadLocked() { + return preferences.getBoolean(LOCKED_KEY, false); + } + + /** + * {@inheritDoc} + */ + @Override + protected void saveLocked(final boolean locked) { + preferences.putBoolean(LOCKED_KEY, locked); + } + +} // class DefaultPickmapSettings Property changes on: trunk/model/src/app/net/sf/gridarta/model/pickmapsettings/DefaultPickmapSettings.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/model/src/app/net/sf/gridarta/model/pickmapsettings/PickmapSettings.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/pickmapsettings/PickmapSettings.java (rev 0) +++ trunk/model/src/app/net/sf/gridarta/model/pickmapsettings/PickmapSettings.java 2010-09-01 06:28:24 UTC (rev 8628) @@ -0,0 +1,54 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.model.pickmapsettings; + +import org.jetbrains.annotations.NotNull; + +/** + * Container for settings that affect pickmaps. + * @author Andreas Kirschbaum + */ +public interface PickmapSettings { + + /** + * Adds a {@link PickmapSettingsListener} to be notified about changes. + * @param listener the listener to add + */ + void addPickmapSettingsListener(@NotNull PickmapSettingsListener listener); + + /** + * Removes a {@link PickmapSettingsListener} to be notified about changes. + * @param listener the listener to remove + */ + void removePickmapSettingsListener(@NotNull PickmapSettingsListener listener); + + /** + * Returns whether pickmaps are immutable. + * @return whether pickmaps are immutable + */ + boolean isLocked(); + + /** + * Sets whether pickmaps are immutable. + * @param locked whether pickmaps are immutable + */ + void setLocked(boolean locked); + +} // interface PickmapSettings Property changes on: trunk/model/src/app/net/sf/gridarta/model/pickmapsettings/PickmapSettings.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/model/src/app/net/sf/gridarta/model/pickmapsettings/PickmapSettingsListener.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/pickmapsettings/PickmapSettingsListener.java (rev 0) +++ trunk/model/src/app/net/sf/gridarta/model/pickmapsettings/PickmapSettingsListener.java 2010-09-01 06:28:24 UTC (rev 8628) @@ -0,0 +1,37 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.model.pickmapsettings; + +import java.util.EventListener; + +/** + * Interface for event listeners that are interested in changes on {@link + * PickmapSettings}. + * @author Andreas Kirschbaum + */ +public interface PickmapSettingsListener extends EventListener { + + /** + * This event handler is called when the immutable state has changed. + * @param locked the new immutable state + */ + void lockedChanged(boolean locked); + +} // interface PickmapSettingsListener Property changes on: trunk/model/src/app/net/sf/gridarta/model/pickmapsettings/PickmapSettingsListener.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java 2010-09-01 06:24:01 UTC (rev 8627) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java 2010-09-01 06:28:24 UTC (rev 8628) @@ -30,7 +30,6 @@ import javax.swing.JPanel; import net.sf.gridarta.gui.map.event.MouseOpEvent; import net.sf.gridarta.gui.objectchooser.ObjectChooser; -import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; import net.sf.gridarta.gui.utils.SwingUtils; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; @@ -41,6 +40,7 @@ import net.sf.gridarta.model.mapmodel.MapSquare; import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.match.GameObjectMatcher; +import net.sf.gridarta.model.pickmapsettings.PickmapSettings; import net.sf.gridarta.utils.ActionBuilderUtils; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; @@ -138,10 +138,10 @@ private final ObjectChooser<G, A, R> objectChooser; /** - * The PickmapChooserControl to use. + * The {@link PickmapSettings} to use. */ @NotNull - private final PickmapChooserControl<G, A, R> pickmapChooserControl; + private final PickmapSettings pickmapSettings; /** * The action for "ignore walls". @@ -187,16 +187,16 @@ * Create a DeletionTool. * @param mapViewSettings the map view settings instance * @param objectChooser the object chooser to use - * @param pickmapChooserControl the pickmap chooser control to use + * @param pickmapSettings the pickmap settings to use * @param floorGameObjectMatcher the floor matcher to use * @param wallGameObjectMatcher the wall matcher to use * @param monsterGameObjectMatcher the monster matcher to use */ - public DeletionTool(@NotNull final MapViewSettings mapViewSettings, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final PickmapChooserControl<G, A, R> pickmapChooserControl, @Nullable final GameObjectMatcher floorGameObjectMatcher, @Nullable final GameObjectMatcher wallGameObjectMatcher, @Nullable final GameObjectMatcher monsterGameObjectMatcher) { + public DeletionTool(@NotNull final MapViewSettings mapViewSettings, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final PickmapSettings pickmapSettings, @Nullable final GameObjectMatcher floorGameObjectMatcher, @Nullable final GameObjectMatcher wallGameObjectMatcher, @Nullable final GameObjectMatcher monsterGameObjectMatcher) { super("deletion"); this.mapViewSettings = mapViewSettings; this.objectChooser = objectChooser; - this.pickmapChooserControl = pickmapChooserControl; + this.pickmapSettings = pickmapSettings; this.floorGameObjectMatcher = floorGameObjectMatcher; this.wallGameObjectMatcher = wallGameObjectMatcher; this.monsterGameObjectMatcher = monsterGameObjectMatcher; @@ -237,7 +237,7 @@ * @param mapControl map control of map to delete arch from */ private void deleteArch(final Point mapLoc, final MapControl<G, A, R> mapControl) { - if (mapControl.isPickmap() && pickmapChooserControl.isLockAllPickmaps()) { + if (mapControl.isPickmap() && pickmapSettings.isLocked()) { return; } Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java 2010-09-01 06:24:01 UTC (rev 8627) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java 2010-09-01 06:28:24 UTC (rev 8628) @@ -28,7 +28,6 @@ import javax.swing.JPanel; import net.sf.gridarta.gui.map.event.MouseOpEvent; import net.sf.gridarta.gui.objectchooser.ObjectChooser; -import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; import net.sf.gridarta.gui.selectedsquare.SelectedSquareModel; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.gui.utils.SwingUtils; @@ -41,6 +40,7 @@ import net.sf.gridarta.model.mapmodel.InsertionMode; import net.sf.gridarta.model.mapmodel.InsertionModeSet; import net.sf.gridarta.model.mapmodel.MapModel; +import net.sf.gridarta.model.pickmapsettings.PickmapSettings; import net.sf.gridarta.utils.ActionBuilderUtils; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; @@ -108,10 +108,10 @@ private final ObjectChooser<G, A, R> objectChooser; /** - * The PickmapChooserControl to use. + * The {@link PickmapSettings} to use. */ @NotNull - private final PickmapChooserControl<G, A, R> pickmapChooserControl; + private final PickmapSettings pickmapSettings; /** * The {@link InsertionModeSet} to use. @@ -124,15 +124,15 @@ * @param selectedSquareView the selected square view * @param selectedSquareModel the selected square model * @param objectChooser the ObjectChooser to use - * @param pickmapChooserControl the pickmap chooser control to use + * @param pickmapSettings the pickmap settings to use * @param insertionModeSet the insertion mode set to use */ - public InsertionTool(@NotNull final SelectedSquareView<G, A, R> selectedSquareView, @NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final PickmapChooserControl<G, A, R> pickmapChooserControl, @NotNull final InsertionModeSet<G, A, R> insertionModeSet) { + public InsertionTool(@NotNull final SelectedSquareView<G, A, R> selectedSquareView, @NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final PickmapSettings pickmapSettings, @NotNull final InsertionModeSet<G, A, R> insertionModeSet) { super("insertion"); this.selectedSquareView = selectedSquareView; this.selectedSquareModel = selectedSquareModel; this.objectChooser = objectChooser; - this.pickmapChooserControl = pickmapChooserControl; + this.pickmapSettings = pickmapSettings; this.insertionModeSet = insertionModeSet; } @@ -160,7 +160,7 @@ */ private void doInsert(final MouseOpEvent<G, A, R> e, final boolean isPressed) { final MapControl<G, A, R> mapControl = e.getMapControl(); - if (mapControl.isPickmap() && pickmapChooserControl.isLockAllPickmaps()) { + if (mapControl.isPickmap() && pickmapSettings.isLocked()) { return; } Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/ToolPalette.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/ToolPalette.java 2010-09-01 06:24:01 UTC (rev 8627) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/ToolPalette.java 2010-09-01 06:28:24 UTC (rev 8628) @@ -28,7 +28,6 @@ import net.sf.gridarta.gui.map.event.MouseOpEvent; import net.sf.gridarta.gui.map.event.MouseOpListener; import net.sf.gridarta.gui.objectchooser.ObjectChooser; -import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; import net.sf.gridarta.gui.selectedsquare.SelectedSquareModel; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.model.archetype.Archetype; @@ -37,6 +36,7 @@ import net.sf.gridarta.model.mapmodel.InsertionModeSet; import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.match.GameObjectMatcher; +import net.sf.gridarta.model.pickmapsettings.PickmapSettings; import net.sf.gridarta.utils.ActionBuilderUtils; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; @@ -81,17 +81,17 @@ * @param selectedSquareView the selected square view * @param selectedSquareModel the selected square model * @param objectChooser the object chooser to use - * @param pickmapChooserControl the pickmap chooser control to use + * @param pickmapSettings the pickmap settings to use * @param floorGameObjectMatcher the floor matcher to use * @param wallGameObjectMatcher the wall matcher to use * @param monsterGameObjectMatcher the monster matcher to use * @param insertionModeSet the insertion mode set to use */ - public ToolPalette(@NotNull final MapViewSettings mapViewSettings, @NotNull final SelectedSquareView<G, A, R> selectedSquareView, @NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final PickmapChooserControl<G, A, R> pickmapChooserControl, @Nullable final GameObjectMatcher floorGameObjectMatcher, @Nullable final GameObjectMatcher wallGameObjectMatcher, @Nullable final GameObjectMatcher monsterGameObjectMatcher, @NotNull final InsertionModeSet<G, A, R> insertionModeSet) { + public ToolPalette(@NotNull final MapViewSettings mapViewSettings, @NotNull final SelectedSquareView<G, A, R> selectedSquareView, @NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final PickmapSettings pickmapSettings, @Nullable final GameObjectMatcher floorGameObjectMatcher, @Nullable final GameObjectMatcher wallGameObjectMatcher, @Nullable final GameObjectMatcher monsterGameObjectMatcher, @NotNull final InsertionModeSet<G, A, R> insertionModeSet) { super(new BorderLayout()); - lmbSelector = new ToolSelector<G, A, R>("selection", mapViewSettings, selectedSquareView, selectedSquareModel, objectChooser, pickmapChooserControl, floorGameObjectMatcher, wallGameObjectMatcher, monsterGameObjectMatcher, insertionModeSet); - mmbSelector = new ToolSelector<G, A, R>("deletion", mapViewSettings, selectedSquareView, selectedSquareModel, objectChooser, pickmapChooserControl, floorGameObjectMatcher, wallGameObjectMatcher, monsterGameObjectMatcher, insertionModeSet); - rmbSelector = new ToolSelector<G, A, R>("insertion", mapViewSettings, selectedSquareView, selectedSquareModel, objectChooser, pickmapChooserControl, floorGameObjectMatcher, wallGameObjectMatcher, monsterGameObjectMatcher, insertionModeSet); + lmbSelector = new ToolSelector<G, A, R>("selection", mapViewSettings, selectedSquareView, selectedSquareModel, objectChooser, pickmapSettings, floorGameObjectMatcher, wallGameObjectMatcher, monsterGameObjectMatcher, insertionModeSet); + mmbSelector = new ToolSelector<G, A, R>("deletion", mapViewSettings, selectedSquareView, selectedSquareModel, objectChooser, pickmapSettings, floorGameObjectMatcher, wallGameObjectMatcher, monsterGameObjectMatcher, insertionModeSet); + rmbSelector = new ToolSelector<G, A, R>("insertion", mapViewSettings, selectedSquareView, selectedSquareModel, objectChooser, pickmapSettings, floorGameObjectMatcher, wallGameObjectMatcher, monsterGameObjectMatcher, insertionModeSet); add(ActionBuilderUtils.newLabel(ACTION_BUILDER, "mouse"), BorderLayout.NORTH); final Container mouseTabs = new JTabbedPane(); mouseTabs.add(ActionBuilderUtils.getString(ACTION_BUILDER, "left"), lmbSelector); Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/ToolSelector.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/ToolSelector.java 2010-09-01 06:24:01 UTC (rev 8627) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/ToolSelector.java 2010-09-01 06:28:24 UTC (rev 8628) @@ -36,7 +36,6 @@ import javax.swing.JToggleButton; import net.sf.gridarta.gui.map.event.MouseOpListener; import net.sf.gridarta.gui.objectchooser.ObjectChooser; -import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; import net.sf.gridarta.gui.selectedsquare.SelectedSquareModel; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.model.archetype.Archetype; @@ -45,6 +44,7 @@ import net.sf.gridarta.model.mapmodel.InsertionModeSet; import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.match.GameObjectMatcher; +import net.sf.gridarta.model.pickmapsettings.PickmapSettings; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; import org.jetbrains.annotations.NotNull; @@ -115,18 +115,18 @@ * @param selectedSquareView the selected square view * @param selectedSquareModel the selected square model * @param objectChooser the object chooser to use - * @param pickmapChooserControl the pickmap chooser control to use + * @param pickmapSettings the pickmap settings to use * @param floorGameObjectMatcher the floor matcher to use * @param wallGameObjectMatcher the wall matcher to use * @param monsterGameObjectMatcher the monster matcher to use * @param insertionModeSet the insertion mode set to use */ - public ToolSelector(@NotNull final String defaultTool, @NotNull final MapViewSettings mapViewSettings, @NotNull final SelectedSquareView<G, A, R> selectedSquareView, @NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final PickmapChooserControl<G, A, R> pickmapChooserControl, @Nullable final GameObjectMatcher floorGameObjectMatcher, @Nullable final GameObjectMatcher wallGameObjectMatcher, @Nullable final GameObjectMatcher monsterGameObjectMatcher, @NotNull final InsertionModeSet<G, A, R> insertionModeSet) { + public ToolSelector(@NotNull final String defaultTool, @NotNull final MapViewSettings mapViewSettings, @NotNull final SelectedSquareView<G, A, R> selectedSquareView, @NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final PickmapSettings pickmapSettings, @Nullable final GameObjectMatcher floorGameObjectMatcher, @Nullable final GameObjectMatcher wallGameObjectMatcher, @Nullable final GameObjectMatcher monsterGameObjectMatcher, @NotNull final InsertionModeSet<G, A, R> insertionModeSet) { createUI(); addTool(new VoidTool<G, A, R>(), defaultTool); addTool(new SelectionTool<G, A, R>(objectChooser, insertionModeSet), defaultTool); - addTool(new DeletionTool<G, A, R>(mapViewSettings, objectChooser, pickmapChooserControl, floorGameObjectMatcher, wallGameObjectMatcher, monsterGameObjectMatcher), defaultTool); - addTool(new InsertionTool<G, A, R>(selectedSquareView, selectedSquareModel, objectChooser, pickmapChooserControl, insertionModeSet), defaultTool); + addTool(new DeletionTool<G, A, R>(mapViewSettings, objectChooser, pickmapSettings, floorGameObjectMatcher, wallGameObjectMatcher, monsterGameObjectMatcher), defaultTool); + addTool(new InsertionTool<G, A, R>(selectedSquareView, selectedSquareModel, objectChooser, pickmapSettings, insertionModeSet), defaultTool); } /** Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2010-09-01 06:24:01 UTC (rev 8627) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2010-09-01 06:28:24 UTC (rev 8628) @@ -27,13 +27,11 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.prefs.Preferences; import javax.swing.Action; import javax.swing.JOptionPane; import javax.swing.JPopupMenu; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import net.sf.gridarta.MainControl; import net.sf.gridarta.gui.map.mapview.MapView; import net.sf.gridarta.gui.map.mapview.MapViewsManager; import net.sf.gridarta.gui.newmap.NewMapDialogFactory; @@ -56,6 +54,8 @@ import net.sf.gridarta.model.mapcontrol.MapControlListener; import net.sf.gridarta.model.mapmodel.MapModelListener; import net.sf.gridarta.model.mapmodel.MapSquare; +import net.sf.gridarta.model.pickmapsettings.PickmapSettings; +import net.sf.gridarta.model.pickmapsettings.PickmapSettingsListener; import net.sf.gridarta.model.validation.ErrorCollector; import net.sf.gridarta.utils.ActionBuilderUtils; import net.sf.gridarta.utils.ActionUtils; @@ -94,6 +94,12 @@ private final PickmapChooserModel<G, A, R> pickmapChooserModel; /** + * The {@link PickmapSettings} to use. + */ + @NotNull + private final PickmapSettings pickmapSettings; + + /** * The {@link MapArchObjectFactory} instance. */ @NotNull @@ -118,16 +124,6 @@ private final MapFolderTree<G, A, R> mapFolderTree; /** - * Preferences. - */ - private static final Preferences preferences = Preferences.userNodeForPackage(MainControl.class); - - /** - * Key for "all pickmaps are locked". - */ - private static final String PICKMAPS_LOCKED = "pickmapsLocked"; - - /** * The factory for creating new pickmaps. */ @NotNull @@ -195,11 +191,6 @@ private MapControl<G, A, R> currentPickmapControl = null; /** - * Set if all pickmaps are locked. - */ - private boolean lockAllPickmaps = false; - - /** * Set if the pickmap panel is active. */ private boolean active = false; @@ -345,8 +336,25 @@ }; /** + * The {@link PickmapSettingsListener} attached to {@link #pickmapSettings}. + */ + @NotNull + private final PickmapSettingsListener pickmapSettingsListener = new PickmapSettingsListener() { + + /** + * {@inheritDoc} + */ + @Override + public void lockedChanged(final boolean locked) { + refresh(); + } + + }; + + /** * Create a PickmapChooserControl. * @param pickmapChooserModel the pickmap chooser model to control + * @param pickmapSettings the pickmap settings to use * @param newMapDialogFactory the factory for creating new pickmaps * @param mapArchObjectFactory the map arch object factory instance * @param mapReaderFactory the map reader factory instance @@ -356,8 +364,9 @@ * @param pickmapManager the pickmap manager for loading pickmaps * @param mapViewsManager the map views */ - public PickmapChooserControl(@NotNull final PickmapChooserModel<G, A, R> pickmapChooserModel, @NotNull final NewMapDialogFactory<G, A, R> newMapDialogFactory, @NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final MapReaderFactory<G, A> mapReaderFactory, @NotNull final MapFolderTree<G, A, R> mapFolderTree, @NotNull final MapManager<G, A, R> mapManager, @NotNull final Component parent, @NotNull final MapManager<G, A, R> pickmapManager, @NotNull final MapViewsManager<G, A, R> mapViewsManager) { + public PickmapChooserControl(@NotNull final PickmapChooserModel<G, A, R> pickmapChooserModel, @NotNull final PickmapSettings pickmapSettings, @NotNull final NewMapDialogFactory<G, A, R> newMapDialogFactory, @NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final MapReaderFactory<G, A> mapReaderFactory, @NotNull final MapFolderTree<G, A, R> mapFolderTree, @NotNull final MapManager<G, A, R> mapManager, @NotNull final Component parent, @NotNull final MapManager<G, A, R> pickmapManager, @NotNull final MapViewsManager<G, A, R> mapViewsManager) { this.pickmapChooserModel = pickmapChooserModel; + this.pickmapSettings = pickmapSettings; this.mapArchObjectFactory = mapArchObjectFactory; this.mapReaderFactory = mapReaderFactory; this.mapFolderTree = mapFolderTree; @@ -365,13 +374,13 @@ this.newMapDialogFactory = newMapDialogFactory; this.pickmapManager = pickmapManager; this.mapViewsManager = mapViewsManager; - lockAllPickmaps = preferences.getBoolean(PICKMAPS_LOCKED, false); ACTION_BUILDER.createToggles(true, this, "lockAllPickmaps"); pickmapChooserModel.addPickmapChooserListener(pickmapChooserModelListener); view = new PickmapChooserView<G, A, R>(pickmapChooserModel, mapFolderTree); refresh(); view.addChangeListener(changeListener); mapManager.addMapManagerListener(mapManagerListener); + pickmapSettings.addPickmapSettingsListener(pickmapSettingsListener); } /** @@ -463,8 +472,9 @@ * Return whether all pickmaps are locked. * @return <code>true</code> if all pickmaps are locked */ + @ActionMethod public boolean isLockAllPickmaps() { - return lockAllPickmaps; + return pickmapSettings.isLocked(); } /** @@ -671,7 +681,7 @@ * <code>false</code> otherwise */ private boolean isAddNewPickmapEnabled() { - return !lockAllPickmaps; + return !pickmapSettings.isLocked(); } /** @@ -681,7 +691,7 @@ */ @Nullable private MapFile<G, A, R> getOpenPickmapMap() { - if (lockAllPickmaps || !active) { + if (pickmapSettings.isLocked() || !active) { return null; } return currentMapFile; @@ -694,7 +704,7 @@ */ @Nullable private MapFile<G, A, R> getDeletePickmap() { - if (lockAllPickmaps || !active) { + if (pickmapSettings.isLocked() || !active) { return null; } return currentMapFile; @@ -707,7 +717,7 @@ */ @Nullable private MapFile<G, A, R> getSavePickmap() { - if (lockAllPickmaps || !active) { + if (pickmapSettings.isLocked() || !active) { return null; } @@ -725,7 +735,7 @@ */ @Nullable private MapFile<G, A, R> getRevertPickmap() { - if (lockAllPickmaps || !active) { + if (pickmapSettings.isLocked() || !active) { return null; } @@ -766,14 +776,9 @@ * Set whether all pickmaps are locked. * @param lockAllPickmaps <code>true</code> if all pickmaps are locked */ + @ActionMethod public void setLockAllPickmaps(final boolean lockAllPickmaps) { - if (this.lockAllPickmaps == lockAllPickmaps) { - return; - } - - this.lockAllPickmaps = lockAllPickmaps; - preferences.putBoolean(PICKMAPS_LOCKED, this.lockAllPickmaps); - refresh(); + pickmapSettings.setLocked(lockAllPickmaps); } /** Modified: trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-09-01 06:24:01 UTC (rev 8627) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-09-01 06:28:24 UTC (rev 8628) @@ -152,6 +152,8 @@ import net.sf.gridarta.model.match.GameObjectMatcher; import net.sf.gridarta.model.match.GameObjectMatchers; import net.sf.gridarta.model.match.TypeNrsGameObjectMatcher; +import net.sf.gridarta.model.pickmapsettings.DefaultPickmapSettings; +import net.sf.gridarta.model.pickmapsettings.PickmapSettings; import net.sf.gridarta.model.resource.AbstractResources; import net.sf.gridarta.model.scripts.ScriptArchData; import net.sf.gridarta.model.scripts.ScriptArchUtils; @@ -447,7 +449,8 @@ mainViewFrame = new JFrame(ACTION_BUILDER.format("mainWindow.title", getBuildNumberAsString())); newMapDialogFactory = editorFactory.newNewMapDialogFactory(mapViewsManager, mapArchObjectFactory, mainViewFrame); final PickmapChooserModel<G, A, R> pickmapChooserModel = new PickmapChooserModel<G, A, R>(); - pickmapChooserControl = new PickmapChooserControl<G, A, R>(pickmapChooserModel, newMapDialogFactory, mapArchObjectFactory, mapReaderFactory, mapFolderTree, mapManager, mainViewFrame, pickmapManager, mapViewsManager); + final PickmapSettings pickmapSettings = new DefaultPickmapSettings(); + pickmapChooserControl = new PickmapChooserControl<G, A, R>(pickmapChooserModel, pickmapSettings, newMapDialogFactory, mapArchObjectFactory, mapReaderFactory, mapFolderTree, mapManager, mainViewFrame, pickmapManager, mapViewsManager); newMapDialogFactory.setPickmapChooserControl(pickmapChooserControl); final CFTreasureListTree<G, A, R> treasureListTree = new CFTreasureListTree<G, A, R>(treasureTree, mainViewFrame, archetypeSet, faceObjectProviders, systemIcons); final ImageIcon noFaceSquareIcon = systemIcons.getNoFaceSquareIcon(); @@ -491,7 +494,7 @@ final PluginParameterViewFactory<G, A, R> pluginParameterViewFactory = new PluginParameterViewFactory<G, A, R>(archetypeSet, gameObjectAttributesModel, objectChooser, mapManager, faceObjectProviders); final File scriptsFile = new File(globalSettings.getMapsDirectory(), scriptsDir); scriptControl = new ScriptController<G, A, R>(filterControl, scriptParameters, mainViewFrame, pluginParameterViewFactory, scriptsFile, scriptModel, pluginParameterFactory, scriptExecutor, systemIcons); - final ToolPalette<G, A, R> toolPalette = new ToolPalette<G, A, R>(mapViewSettings, selectedSquareView, selectedSquareModel, objectChooser, pickmapChooserControl, floorMatcher, wallMatcher, monsterMatcher, insertionModeSet); + final ToolPalette<G, A, R> toolPalette = new ToolPalette<G, A, R>(mapViewSettings, selectedSquareView, selectedSquareModel, objectChooser, pickmapSettings, floorMatcher, wallMatcher, monsterMatcher, insertionModeSet); updaterManager = new UpdaterManager(exiter, mapManager, mainViewFrame, gridartaJarFilename); final TextEditorTab<G, A, R> textEditorTab = new TextEditorTab<G, A, R>(gameObjectAttributesModel, archetypeTypeSet); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-09-01 06:39:26
|
Revision: 8629 http://gridarta.svn.sourceforge.net/gridarta/?rev=8629&view=rev Author: akirschbaum Date: 2010-09-01 06:39:19 +0000 (Wed, 01 Sep 2010) Log Message: ----------- Make "Lock All Pickmaps" affect "Create Pickmap Folder" and "Delete Current Pickmap Folder". Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gui/mapfiles/MapFolderTreeActions.java trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-09-01 06:28:24 UTC (rev 8628) +++ trunk/atrinik/ChangeLog 2010-09-01 06:39:19 UTC (rev 8629) @@ -1,5 +1,8 @@ 2010-09-01 Andreas Kirschbaum + * Make "Lock All Pickmaps" affect "Create Pickmap Folder" and + "Delete Current Pickmap Folder". + * Remove unused "Inventory:" element from game object attributes dialogs. Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-09-01 06:28:24 UTC (rev 8628) +++ trunk/crossfire/ChangeLog 2010-09-01 06:39:19 UTC (rev 8629) @@ -1,5 +1,8 @@ 2010-09-01 Andreas Kirschbaum + * Make "Lock All Pickmaps" affect "Create Pickmap Folder" and + "Delete Current Pickmap Folder". + * Remove unused "Inventory:" element from game object attributes dialogs. Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-09-01 06:28:24 UTC (rev 8628) +++ trunk/daimonin/ChangeLog 2010-09-01 06:39:19 UTC (rev 8629) @@ -1,5 +1,8 @@ 2010-09-01 Andreas Kirschbaum + * Make "Lock All Pickmaps" affect "Create Pickmap Folder" and + "Delete Current Pickmap Folder". + * Remove unused "Inventory:" element from game object attributes dialogs. Modified: trunk/src/app/net/sf/gridarta/gui/mapfiles/MapFolderTreeActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/mapfiles/MapFolderTreeActions.java 2010-09-01 06:28:24 UTC (rev 8628) +++ trunk/src/app/net/sf/gridarta/gui/mapfiles/MapFolderTreeActions.java 2010-09-01 06:39:19 UTC (rev 8629) @@ -31,6 +31,8 @@ import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.pickmapsettings.PickmapSettings; +import net.sf.gridarta.model.pickmapsettings.PickmapSettingsListener; import net.sf.gridarta.utils.ActionUtils; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; @@ -56,6 +58,12 @@ private final MapFolderTree<G, A, R> mapFolderTree; /** + * The {@link PickmapSettings} to use. + */ + @NotNull + private final PickmapSettings pickmapSettings; + + /** * The factory for creating new pickmap folders. */ @NotNull @@ -86,6 +94,12 @@ private MapFolder<G, A, R> activeMapFolder; /** + * Action for "create folder". + */ + @NotNull + private final Action aCreateFolderAction; + + /** * Action called for "delete active folder". */ private final Action aDeletePickmapFolder; @@ -118,8 +132,25 @@ }; /** + * The {@link PickmapSettingsListener} attached to {@link #pickmapSettings}. + */ + @NotNull + private final PickmapSettingsListener pickmapSettingsListener = new PickmapSettingsListener() { + + /** + * {@inheritDoc} + */ + @Override + public void lockedChanged(final boolean locked) { + refresh(); + } + + }; + + /** * Creates a new instance. * @param mapFolderTree the model to operate on + * @param pickmapSettings the pickmap settings to use * @param newMapDialogFactory the factory for creating new pickmap folders * @param createFolderKey the action key for "create folder" * @param deleteFolderKey the action key for "delete folder" @@ -128,15 +159,17 @@ * @param deleteFolderNotEmptyKey the dialog key for "delete folder not * empty" */ - public MapFolderTreeActions(@NotNull final MapFolderTree<G, A, R> mapFolderTree, @NotNull final NewMapDialogFactory<G, A, R> newMapDialogFactory, @NotNull final String createFolderKey, @NotNull final String deleteFolderKey, @NotNull final String confirmDeleteFolderKey, @NotNull final String deleteFolderNotEmptyKey) { + public MapFolderTreeActions(@NotNull final MapFolderTree<G, A, R> mapFolderTree, @NotNull final PickmapSettings pickmapSettings, @NotNull final NewMapDialogFactory<G, A, R> newMapDialogFactory, @NotNull final String createFolderKey, @NotNull final String deleteFolderKey, @NotNull final String confirmDeleteFolderKey, @NotNull final String deleteFolderNotEmptyKey) { this.mapFolderTree = mapFolderTree; + this.pickmapSettings = pickmapSettings; this.newMapDialogFactory = newMapDialogFactory; this.confirmDeleteFolderKey = confirmDeleteFolderKey; this.deleteFolderNotEmptyKey = deleteFolderNotEmptyKey; mapFolderTree.addModelListener(mapFolderTreeListener); activeMapFolder = mapFolderTree.getActiveMapFolder(); - ActionUtils.newAction(ACTION_BUILDER, "Pickmap", this, createFolderKey); + aCreateFolderAction = ActionUtils.newAction(ACTION_BUILDER, "Pickmap", this, createFolderKey); aDeletePickmapFolder = ActionUtils.newAction(ACTION_BUILDER, "Pickmap", this, deleteFolderKey); + pickmapSettings.addPickmapSettingsListener(pickmapSettingsListener); refresh(); } @@ -155,6 +188,7 @@ * Updates the actions' states. */ private void refresh() { + aCreateFolderAction.setEnabled(doCreateFolder(false)); aDeletePickmapFolder.setEnabled(doDeletePickmapFolder(false)); if (folderMenu == null) { @@ -176,10 +210,27 @@ */ @ActionMethod public void createPickmapFolder() { - newMapDialogFactory.showNewPickmapFolderDialog(mapFolderTree, activeMapFolder); + doCreateFolder(true); } /** + * Executes the "create folder" action. + * @param performAction whether the action should be performed + * @return whether the action was or can be performed + */ + private boolean doCreateFolder(final boolean performAction) { + if (pickmapSettings.isLocked()) { + return false; + } + + if (performAction) { + newMapDialogFactory.showNewPickmapFolderDialog(mapFolderTree, activeMapFolder); + } + + return true; + } + + /** * Action callback function to delete the current pickmap folder. */ @ActionMethod @@ -193,6 +244,10 @@ * @return whether the action was or can be performed */ private boolean doDeletePickmapFolder(final boolean performAction) { + if (pickmapSettings.isLocked()) { + return false; + } + final MapFolder<G, A, R> mapFolder = activeMapFolder; if (mapFolder == null || mapFolder.getParent() == null) { return false; Modified: trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-09-01 06:28:24 UTC (rev 8628) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-09-01 06:39:19 UTC (rev 8629) @@ -507,7 +507,7 @@ //noinspection ResultOfObjectAllocationIgnored new UndoControl<G, A, R>(mapManager, gameObjectFactory, gameObjectMatchers); final Action exitAction = ActionUtils.newAction(ACTION_BUILDER, "Other", this, "exit"); - final MapFolderTreeActions<G, A, R> mapFolderTreeActions = new MapFolderTreeActions<G, A, R>(mapFolderTree, newMapDialogFactory, "createPickmapFolder", "deletePickmapFolder", "confirmDeletePickmapFolder", "deletePickmapFolderNotEmpty"); + final MapFolderTreeActions<G, A, R> mapFolderTreeActions = new MapFolderTreeActions<G, A, R>(mapFolderTree, pickmapSettings, newMapDialogFactory, "createPickmapFolder", "deletePickmapFolder", "confirmDeletePickmapFolder", "deletePickmapFolderNotEmpty"); //noinspection ResultOfObjectAllocationIgnored new MapActions<G, A, R>(mainViewFrame, mainViewFrame, mapManager, mapViewManager, exitMatcher, GuiFileFilters.mapFileFilter, selectedSquareModel, directionMap, allowRandomMapParameters, mapPropertiesDialogFactory, mapViewSettings, mapPathNormalizer, mapViewsManager, fileControl); final ViewActions<G, A, R> viewActions = new ViewActions<G, A, R>(mapViewSettings, mapManager); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-09-01 17:50:54
|
Revision: 8630 http://gridarta.svn.sourceforge.net/gridarta/?rev=8630&view=rev Author: akirschbaum Date: 2010-09-01 17:50:47 +0000 (Wed, 01 Sep 2010) Log Message: ----------- Hide actions not applicable for an editor variant from Configure Shortcuts. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages.properties trunk/crossfire/ChangeLog trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/messages.properties trunk/daimonin/ChangeLog trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/messages.properties trunk/src/app/net/sf/gridarta/gui/filter/MenuItemCreator.java trunk/src/app/net/sf/gridarta/gui/shortcuts/ShortcutsManager.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-09-01 06:39:19 UTC (rev 8629) +++ trunk/atrinik/ChangeLog 2010-09-01 17:50:47 UTC (rev 8630) @@ -1,5 +1,8 @@ 2010-09-01 Andreas Kirschbaum + * Hide actions not applicable for Atrinik from Configure + Shortcuts. + * Make "Lock All Pickmaps" affect "Create Pickmap Folder" and "Delete Current Pickmap Folder". Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages.properties =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages.properties 2010-09-01 06:39:19 UTC (rev 8629) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages.properties 2010-09-01 17:50:47 UTC (rev 8630) @@ -149,3 +149,7 @@ ####################### # Various Log Messages logDefArchWithInvalidMpartId=Arch part {0} has mpart_id {2}, but head part {1} has mpart_id {3} + + +# Actions not to be shown in Configure Shortcuts +shortcutsIgnoreActions=smoothing Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-09-01 06:39:19 UTC (rev 8629) +++ trunk/crossfire/ChangeLog 2010-09-01 17:50:47 UTC (rev 8630) @@ -1,5 +1,8 @@ 2010-09-01 Andreas Kirschbaum + * Hide actions not applicable for Crossfire from Configure + Shortcuts. + * Make "Lock All Pickmaps" affect "Create Pickmap Folder" and "Delete Current Pickmap Folder". Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/messages.properties =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/messages.properties 2010-09-01 06:39:19 UTC (rev 8629) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/messages.properties 2010-09-01 17:50:47 UTC (rev 8630) @@ -130,3 +130,7 @@ about.title=About Gridarta for Crossfire about=<html><h1 align="center">Gridarta for Crossfire</h1><p>Editor for Crossfire MMORPG maps and arches</p><table><tr><td valign="top" align="right" width="50%">Copyright \xA9 2001-2010</td><td width="50%">Michael Toennies<br>Andreas Vogl<br>Peter Plischewsky<br>Gecko<br>Christian Hujer<br>Daniel Viegas<br>Andreas Kirschbaum</td></tr><tr><td align="right">Java version:</td><td>{0}</td></tr><tr><td align="right">Version:</td><td>{1}</td></tr><tr><td align="right">by:</td><td>{2}</td></tr><tr><td align="right">at:</td><td>{3}</td></tr></table></html> + + +# Actions not to be shown in Configure Shortcuts +shortcutsIgnoreActions=doubleFaces cleanCompletelyBlockedSquares collectSpells Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-09-01 06:39:19 UTC (rev 8629) +++ trunk/daimonin/ChangeLog 2010-09-01 17:50:47 UTC (rev 8630) @@ -1,5 +1,8 @@ 2010-09-01 Andreas Kirschbaum + * Hide actions not applicable for Daimonin from Configure + Shortcuts. + * Make "Lock All Pickmaps" affect "Create Pickmap Folder" and "Delete Current Pickmap Folder". Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/messages.properties =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/messages.properties 2010-09-01 06:39:19 UTC (rev 8629) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/messages.properties 2010-09-01 17:50:47 UTC (rev 8630) @@ -149,3 +149,7 @@ ####################### # Various Log Messages logDefArchWithInvalidMpartId=Arch part {0} has mpart_id {2}, but head part {1} has mpart_id {3} + + +# Actions not to be shown in Configure Shortcuts +shortcutsIgnoreActions=smoothing Modified: trunk/src/app/net/sf/gridarta/gui/filter/MenuItemCreator.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/filter/MenuItemCreator.java 2010-09-01 06:39:19 UTC (rev 8629) +++ trunk/src/app/net/sf/gridarta/gui/filter/MenuItemCreator.java 2010-09-01 17:50:47 UTC (rev 8630) @@ -65,7 +65,7 @@ /** {@inheritDoc} */ @Override public void visit(@NotNull final NamedGameObjectMatcherFilterConfig filterConfig) { - menuItem = new JCheckBoxMenuItem(ACTION_BUILDER.createToggle(true, "enabled", filterConfig)); + menuItem = new JCheckBoxMenuItem(ACTION_BUILDER.createToggle(false, "enabled", filterConfig)); } }; Modified: trunk/src/app/net/sf/gridarta/gui/shortcuts/ShortcutsManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/shortcuts/ShortcutsManager.java 2010-09-01 06:39:19 UTC (rev 8629) +++ trunk/src/app/net/sf/gridarta/gui/shortcuts/ShortcutsManager.java 2010-09-01 17:50:47 UTC (rev 8630) @@ -21,10 +21,13 @@ import java.awt.Component; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.Comparator; +import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Set; import java.util.prefs.AbstractPreferences; import java.util.prefs.BackingStoreException; import java.util.prefs.Preferences; @@ -32,6 +35,7 @@ import javax.swing.ActionMap; import javax.swing.KeyStroke; import net.sf.gridarta.MainControl; +import net.sf.gridarta.utils.ActionBuilderUtils; import net.sf.gridarta.utils.ActionUtils; import net.sf.japi.swing.action.ActionBuilder; import org.jetbrains.annotations.NotNull; @@ -57,6 +61,12 @@ private static final String PREFERENCES_COMMENT_PREFIX = "prefs." + PREFERENCES_SHORTCUT_PREFIX; /** + * The action names to hide. + */ + @NotNull + private final Set<String> ignoreActions = new HashSet<String>(); + + /** * A {@link Comparator} that compares {@link Action Actions} by name. */ @NotNull @@ -88,6 +98,8 @@ public ShortcutsManager(@NotNull final ActionBuilder actionBuilder) { this.actionBuilder = actionBuilder; + ignoreActions.addAll(Arrays.asList(ActionBuilderUtils.getString(actionBuilder, "shortcutsIgnoreActions").split(" +"))); + for (final Action action : this) { final Object acceleratorKey = action.getValue(Action.ACCELERATOR_KEY); if (acceleratorKey != null) { @@ -230,10 +242,13 @@ final ActionMap actionMap = actionBuilder.getActionMap(); for (final Object key : actionMap.allKeys()) { if (key instanceof String) { - final Action action = actionMap.get(key); - assert action != null; - if (isValidAction(action)) { - result.add(action); + final String actionName = (String) key; + if (!ignoreActions.contains(actionName)) { + final Action action = actionMap.get(key); + assert action != null; + if (isValidAction(action)) { + result.add(action); + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-09-01 18:12:29
|
Revision: 8631 http://gridarta.svn.sourceforge.net/gridarta/?rev=8631&view=rev Author: akirschbaum Date: 2010-09-01 18:12:22 +0000 (Wed, 01 Sep 2010) Log Message: ----------- Hide script editor actions from Configure Shortcuts. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages.properties trunk/crossfire/ChangeLog trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/messages.properties trunk/daimonin/ChangeLog trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/messages.properties Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-09-01 17:50:47 UTC (rev 8630) +++ trunk/atrinik/ChangeLog 2010-09-01 18:12:22 UTC (rev 8631) @@ -1,5 +1,7 @@ 2010-09-01 Andreas Kirschbaum + * Hide script editor actions from Configure Shortcuts. + * Hide actions not applicable for Atrinik from Configure Shortcuts. Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages.properties =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages.properties 2010-09-01 17:50:47 UTC (rev 8630) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages.properties 2010-09-01 18:12:22 UTC (rev 8631) @@ -152,4 +152,5 @@ # Actions not to be shown in Configure Shortcuts -shortcutsIgnoreActions=smoothing +shortcutsIgnoreActions=smoothing \ + scriptEditClose scriptEditCloseAll scriptEditCopy scriptEditCut scriptEditFind scriptEditFindAgain scriptEditNewScript scriptEditOpen scriptEditPaste scriptEditRedo scriptEditReplace scriptEditSave scriptEditSaveAs scriptEditUndo Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-09-01 17:50:47 UTC (rev 8630) +++ trunk/crossfire/ChangeLog 2010-09-01 18:12:22 UTC (rev 8631) @@ -1,5 +1,7 @@ 2010-09-01 Andreas Kirschbaum + * Hide script editor actions from Configure Shortcuts. + * Hide actions not applicable for Crossfire from Configure Shortcuts. Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/messages.properties =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/messages.properties 2010-09-01 17:50:47 UTC (rev 8630) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/messages.properties 2010-09-01 18:12:22 UTC (rev 8631) @@ -133,4 +133,5 @@ # Actions not to be shown in Configure Shortcuts -shortcutsIgnoreActions=doubleFaces cleanCompletelyBlockedSquares collectSpells +shortcutsIgnoreActions=doubleFaces cleanCompletelyBlockedSquares collectSpells \ + scriptEditClose scriptEditCloseAll scriptEditCopy scriptEditCut scriptEditFind scriptEditFindAgain scriptEditNewScript scriptEditOpen scriptEditPaste scriptEditRedo scriptEditReplace scriptEditSave scriptEditSaveAs scriptEditUndo Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-09-01 17:50:47 UTC (rev 8630) +++ trunk/daimonin/ChangeLog 2010-09-01 18:12:22 UTC (rev 8631) @@ -1,5 +1,7 @@ 2010-09-01 Andreas Kirschbaum + * Hide script editor actions from Configure Shortcuts. + * Hide actions not applicable for Daimonin from Configure Shortcuts. Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/messages.properties =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/messages.properties 2010-09-01 17:50:47 UTC (rev 8630) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/messages.properties 2010-09-01 18:12:22 UTC (rev 8631) @@ -152,4 +152,5 @@ # Actions not to be shown in Configure Shortcuts -shortcutsIgnoreActions=smoothing +shortcutsIgnoreActions=smoothing \ + scriptEditClose scriptEditCloseAll scriptEditCopy scriptEditCut scriptEditFind scriptEditFindAgain scriptEditNewScript scriptEditOpen scriptEditPaste scriptEditRedo scriptEditReplace scriptEditSave scriptEditSaveAs scriptEditUndo This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-09-01 18:13:46
|
Revision: 8632 http://gridarta.svn.sourceforge.net/gridarta/?rev=8632&view=rev Author: akirschbaum Date: 2010-09-01 18:13:39 +0000 (Wed, 01 Sep 2010) Log Message: ----------- Hide internal actions for menu bars from Configure Shortcuts. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gui/shortcuts/ShortcutsManager.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-09-01 18:12:22 UTC (rev 8631) +++ trunk/atrinik/ChangeLog 2010-09-01 18:13:39 UTC (rev 8632) @@ -1,5 +1,7 @@ 2010-09-01 Andreas Kirschbaum + * Hide internal actions for menu bars from Configure Shortcuts. + * Hide script editor actions from Configure Shortcuts. * Hide actions not applicable for Atrinik from Configure Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-09-01 18:12:22 UTC (rev 8631) +++ trunk/crossfire/ChangeLog 2010-09-01 18:13:39 UTC (rev 8632) @@ -1,5 +1,7 @@ 2010-09-01 Andreas Kirschbaum + * Hide internal actions for menu bars from Configure Shortcuts. + * Hide script editor actions from Configure Shortcuts. * Hide actions not applicable for Crossfire from Configure Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-09-01 18:12:22 UTC (rev 8631) +++ trunk/daimonin/ChangeLog 2010-09-01 18:13:39 UTC (rev 8632) @@ -1,5 +1,7 @@ 2010-09-01 Andreas Kirschbaum + * Hide internal actions for menu bars from Configure Shortcuts. + * Hide script editor actions from Configure Shortcuts. * Hide actions not applicable for Daimonin from Configure Modified: trunk/src/app/net/sf/gridarta/gui/shortcuts/ShortcutsManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/shortcuts/ShortcutsManager.java 2010-09-01 18:12:22 UTC (rev 8631) +++ trunk/src/app/net/sf/gridarta/gui/shortcuts/ShortcutsManager.java 2010-09-01 18:13:39 UTC (rev 8632) @@ -22,12 +22,12 @@ import java.awt.Component; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.Iterator; import java.util.List; -import java.util.Set; import java.util.prefs.AbstractPreferences; import java.util.prefs.BackingStoreException; import java.util.prefs.Preferences; @@ -38,6 +38,7 @@ import net.sf.gridarta.utils.ActionBuilderUtils; import net.sf.gridarta.utils.ActionUtils; import net.sf.japi.swing.action.ActionBuilder; +import net.sf.japi.swing.action.DummyAction; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -64,7 +65,7 @@ * The action names to hide. */ @NotNull - private final Set<String> ignoreActions = new HashSet<String>(); + private final Collection<String> ignoreActions = new HashSet<String>(); /** * A {@link Comparator} that compares {@link Action Actions} by name. @@ -242,13 +243,10 @@ final ActionMap actionMap = actionBuilder.getActionMap(); for (final Object key : actionMap.allKeys()) { if (key instanceof String) { - final String actionName = (String) key; - if (!ignoreActions.contains(actionName)) { - final Action action = actionMap.get(key); - assert action != null; - if (isValidAction(action)) { - result.add(action); - } + final Action action = actionMap.get(key); + assert action != null; + if (isValidAction(action)) { + result.add(action); } } } @@ -261,13 +259,19 @@ * @param action the action to check * @return whether the action is valid */ - private static boolean isValidAction(@NotNull final Action action) { + private boolean isValidAction(@NotNull final Action action) { + if (action instanceof DummyAction) { + return false; + } + + final String id; try { - ActionUtils.getActionId(action); - return true; + id = ActionUtils.getActionId(action); } catch (final IllegalArgumentException ignored) { return false; } + + return !ignoreActions.contains(id); } } // class ShortcutsManager This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-09-07 19:35:42
|
Revision: 8634 http://gridarta.svn.sourceforge.net/gridarta/?rev=8634&view=rev Author: akirschbaum Date: 2010-09-07 19:35:35 +0000 (Tue, 07 Sep 2010) Log Message: ----------- Fix "Move To" actions for tabs in main window. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gui/utils/tabbedpanel/TabbedPanel.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/utils/tabbedpanel/MoveToActions.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-09-01 18:31:10 UTC (rev 8633) +++ trunk/atrinik/ChangeLog 2010-09-07 19:35:35 UTC (rev 8634) @@ -1,3 +1,7 @@ +2010-09-06 Andreas Kirschbaum + + * Fix "Move To" actions for tabs in main window. + 2010-09-01 Andreas Kirschbaum * Hide internal actions for menu bars from Configure Shortcuts. Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-09-01 18:31:10 UTC (rev 8633) +++ trunk/crossfire/ChangeLog 2010-09-07 19:35:35 UTC (rev 8634) @@ -1,3 +1,7 @@ +2010-09-06 Andreas Kirschbaum + + * Fix "Move To" actions for tabs in main window. + 2010-09-01 Andreas Kirschbaum * Hide internal actions for menu bars from Configure Shortcuts. Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-09-01 18:31:10 UTC (rev 8633) +++ trunk/daimonin/ChangeLog 2010-09-07 19:35:35 UTC (rev 8634) @@ -1,3 +1,7 @@ +2010-09-06 Andreas Kirschbaum + + * Fix "Move To" actions for tabs in main window. + 2010-09-01 Andreas Kirschbaum * Hide internal actions for menu bars from Configure Shortcuts. Added: trunk/src/app/net/sf/gridarta/gui/utils/tabbedpanel/MoveToActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/utils/tabbedpanel/MoveToActions.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/utils/tabbedpanel/MoveToActions.java 2010-09-07 19:35:35 UTC (rev 8634) @@ -0,0 +1,86 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.utils.tabbedpanel; + +import net.sf.gridarta.gui.utils.borderpanel.Location; +import net.sf.japi.swing.action.ActionMethod; +import org.jetbrains.annotations.NotNull; + +/** + * Defines {@link ActionMethod ActionMethods} to move tab locations. + * @author Andreas Kirschbaum + */ +public class MoveToActions { + + /** + * The tab. + */ + @NotNull + private final Tab tab; + + /** + * The {@link TabbedPanel} to forward to. + */ + @NotNull + private final TabbedPanel tabbedPanel; + + /** + * Creates a new instance. + * @param tab the tab + * @param tabbedPanel the tabbed panel to forward to + */ + public MoveToActions(@NotNull final Tab tab, @NotNull final TabbedPanel tabbedPanel) { + this.tab = tab; + this.tabbedPanel = tabbedPanel; + } + + /** + * Action method to move the menu to {@link Location#TOP}. + */ + @ActionMethod + public void tabButtonMoveToTop() { + tabbedPanel.moveTab(tab, Location.TOP); + } + + /** + * Action method to move the menu to {@link Location#BOTTOM}. + */ + @ActionMethod + public void tabButtonMoveToBottom() { + tabbedPanel.moveTab(tab, Location.BOTTOM); + } + + /** + * Action method to move the menu to {@link Location#LEFT}. + */ + @ActionMethod + public void tabButtonMoveToLeft() { + tabbedPanel.moveTab(tab, Location.LEFT); + } + + /** + * Action method to move the menu to {@link Location#RIGHT}. + */ + @ActionMethod + public void tabButtonMoveToRight() { + tabbedPanel.moveTab(tab, Location.RIGHT); + } + +} // class MoveToActions Property changes on: trunk/src/app/net/sf/gridarta/gui/utils/tabbedpanel/MoveToActions.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gui/utils/tabbedpanel/TabbedPanel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/utils/tabbedpanel/TabbedPanel.java 2010-09-01 18:31:10 UTC (rev 8633) +++ trunk/src/app/net/sf/gridarta/gui/utils/tabbedpanel/TabbedPanel.java 2010-09-07 19:35:35 UTC (rev 8634) @@ -32,7 +32,6 @@ import net.sf.gridarta.gui.utils.borderpanel.Location; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; -import net.sf.japi.swing.action.ActionMethod; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -180,7 +179,7 @@ * @param tab the tab * @param location the location */ - private void moveTab(@NotNull final Tab tab, @NotNull final Location location) { + public void moveTab(@NotNull final Tab tab, @NotNull final Location location) { if (tabs.get(tab.getButton()) == null) { throw new IllegalArgumentException(); } @@ -229,11 +228,12 @@ private void fillContextMenu(@NotNull final Tab tab) { final JMenu moveToMenu = tab.getMoveToMenu(); MenuUtils.removeAll(moveToMenu); - final MoveToActions moveToActions = new MoveToActions(tab); + final MoveToActions moveToActions = new MoveToActions(tab, this); final Location location = tab.getLocation(); for (final Location thisLocation : Location.values()) { if (thisLocation != location) { - moveToMenu.add(ACTION_BUILDER.createAction(false, "tabButtonMoveTo" + thisLocation.getName(), moveToActions)); + final String XXX = "tabButtonMoveTo" + thisLocation.getName(); + moveToMenu.add(ACTION_BUILDER.createAction(true, XXX, moveToActions)); } } } @@ -266,57 +266,4 @@ openTabs.remove(tab.getComponent()); } - /** - * Defines {@link ActionMethod ActionMethods} to move tab locations. - * @author Andreas Kirschbaum - */ - private class MoveToActions { - - /** - * The tab. - */ - @NotNull - private final Tab tab; - - /** - * Creates a new instance. - * @param tab the tab - */ - private MoveToActions(@NotNull final Tab tab) { - this.tab = tab; - } - - /** - * Action method to move the menu to {@link Location#TOP}. - */ - @ActionMethod - public void tabButtonMoveToTop() { - moveTab(tab, Location.TOP); - } - - /** - * Action method to move the menu to {@link Location#BOTTOM}. - */ - @ActionMethod - public void tabButtonMoveToBottom() { - moveTab(tab, Location.BOTTOM); - } - - /** - * Action method to move the menu to {@link Location#LEFT}. - */ - @ActionMethod - public void tabButtonMoveToLeft() { - moveTab(tab, Location.LEFT); - } - - /** - * Action method to move the menu to {@link Location#RIGHT}. - */ - @ActionMethod - public void tabButtonMoveToRight() { - moveTab(tab, Location.RIGHT); - } - - } // class MoveToActions } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-09-08 17:02:48
|
Revision: 8640 http://gridarta.svn.sourceforge.net/gridarta/?rev=8640&view=rev Author: akirschbaum Date: 2010-09-08 17:02:41 +0000 (Wed, 08 Sep 2010) Log Message: ----------- Retain tab locations in main window across editor restarts. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gui/utils/tabbedpanel/Tab.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-09-08 16:47:32 UTC (rev 8639) +++ trunk/atrinik/ChangeLog 2010-09-08 17:02:41 UTC (rev 8640) @@ -1,3 +1,7 @@ +2010-09-08 Andreas Kirschbaum + + * Retain tab locations in main window across editor restarts. + 2010-09-06 Andreas Kirschbaum * Fix "Move To" actions for tabs in main window. Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-09-08 16:47:32 UTC (rev 8639) +++ trunk/crossfire/ChangeLog 2010-09-08 17:02:41 UTC (rev 8640) @@ -1,3 +1,7 @@ +2010-09-08 Andreas Kirschbaum + + * Retain tab locations in main window across editor restarts. + 2010-09-06 Andreas Kirschbaum * Fix "Move To" actions for tabs in main window. Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-09-08 16:47:32 UTC (rev 8639) +++ trunk/daimonin/ChangeLog 2010-09-08 17:02:41 UTC (rev 8640) @@ -1,3 +1,7 @@ +2010-09-08 Andreas Kirschbaum + + * Retain tab locations in main window across editor restarts. + 2010-09-06 Andreas Kirschbaum * Fix "Move To" actions for tabs in main window. Modified: trunk/src/app/net/sf/gridarta/gui/utils/tabbedpanel/Tab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/utils/tabbedpanel/Tab.java 2010-09-08 16:47:32 UTC (rev 8639) +++ trunk/src/app/net/sf/gridarta/gui/utils/tabbedpanel/Tab.java 2010-09-08 17:02:41 UTC (rev 8640) @@ -71,6 +71,11 @@ private static final String TAB_HEIGHT_PREFIX = "MainWindow.tab_height."; /** + * The key used to store the current location of a tab. + */ + private static final String TAB_LOCATION = "MainWindow.tab_location."; + + /** * The {@link ActionBuilder}. */ @NotNull @@ -198,11 +203,11 @@ * Creates a new instance. * @param ident the tab's identification string * @param component the component that is shown when this tab is active - * @param location the tab's location + * @param defaultLocation the tab's default location * @param index the tab's index for ordering * @param defaultOpen the tab's default opened status */ - public Tab(@NotNull final String ident, @NotNull final JComponent component, @NotNull final Location location, final int index, final boolean defaultOpen) { + public Tab(@NotNull final String ident, @NotNull final JComponent component, @NotNull final Location defaultLocation, final int index, final boolean defaultOpen) { this.ident = ident; this.component = component; final Dimension preferredSize = component.getPreferredSize(); @@ -213,7 +218,12 @@ height = Math.max(defaultHeight, minimumSize.height); open = preferences.getBoolean(TAB_OPEN_PREFIX + ident, defaultOpen); action = new TabButtonAction(ident); - this.location = location; + final String locationString = preferences.get(TAB_LOCATION + ident, defaultLocation.toString()); + try { + location = Location.valueOf(locationString); + } catch (final IllegalArgumentException ignored) { + location = defaultLocation; + } this.index = index; button = createButton(); final JMenu tmp = MenuUtils.findMenu(popupMenu, "tabButtonMoveTo"); @@ -313,6 +323,7 @@ this.location = location; button = createButton(); + preferences.put(TAB_LOCATION + ident, location.toString()); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-09-25 20:23:32
|
Revision: 8657 http://gridarta.svn.sourceforge.net/gridarta/?rev=8657&view=rev Author: akirschbaum Date: 2010-09-25 20:23:25 +0000 (Sat, 25 Sep 2010) Log Message: ----------- Merge duplicated code. Modified Paths: -------------- trunk/model/src/test/net/sf/gridarta/model/mapmodel/TestMapModelCreator.java trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java Modified: trunk/model/src/test/net/sf/gridarta/model/mapmodel/TestMapModelCreator.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/mapmodel/TestMapModelCreator.java 2010-09-23 18:33:03 UTC (rev 8656) +++ trunk/model/src/test/net/sf/gridarta/model/mapmodel/TestMapModelCreator.java 2010-09-25 20:23:25 UTC (rev 8657) @@ -41,6 +41,8 @@ import net.sf.gridarta.model.gameobject.GameObjectFactory; import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.gameobject.TestGameObjectFactory; +import net.sf.gridarta.model.io.GameObjectParser; +import net.sf.gridarta.model.io.TestGameObjectParser; import net.sf.gridarta.model.maparchobject.TestMapArchObject; import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.mapviewsettings.TestMapViewSettings; @@ -206,6 +208,15 @@ } /** + * Returns the "topmost" insertion mode. + * @return the "topmost" insertion mode + */ + @NotNull + public InsertionMode<TestGameObject, TestMapArchObject, TestArchetype> getTopmostInsertionMode() { + return topmostInsertionMode; + } + + /** * Returns an archetype. * @param archetypeName the archetype name * @return the archetype @@ -283,4 +294,39 @@ return archetypeChooserModel; } + /** + * Returns the {@link GameObjectMatchers} instance. + * @return the game object matchers instance + */ + @NotNull + public GameObjectMatchers getGameObjectMatchers() { + return gameObjectMatchers; + } + + /** + * Returns the {@link ArchetypeSet}. + * @return the archetype set + */ + @NotNull + public ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> getArchetypeSet() { + return archetypeSet; + } + + /** + * Creates a new {@link GameObjectParser} instance. + * @return the new game object parser instance + */ + public GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> newGameObjectParser() { + return new TestGameObjectParser(gameObjectFactory, gameObjectMatchers, archetypeSet); + } + + /** + * Returns the {@link FaceObjectProviders} instance. + * @return the face object providers instance + */ + @NotNull + public FaceObjectProviders getFaceObjectProviders() { + return faceObjectProviders; + } + } // class TestMapModelCreator Modified: trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java 2010-09-23 18:33:03 UTC (rev 8656) +++ trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java 2010-09-25 20:23:25 UTC (rev 8657) @@ -38,23 +38,12 @@ import net.sf.gridarta.mapmanager.FileControl; import net.sf.gridarta.mapmanager.MapManager; import net.sf.gridarta.mapmanager.TestFileControl; -import net.sf.gridarta.model.anim.AnimationObjects; -import net.sf.gridarta.model.anim.DefaultAnimationObjects; -import net.sf.gridarta.model.archetype.ArchetypeFactory; import net.sf.gridarta.model.archetype.ArchetypeSet; import net.sf.gridarta.model.archetype.DuplicateArchetypeException; import net.sf.gridarta.model.archetype.TestArchetype; -import net.sf.gridarta.model.archetype.TestArchetypeFactory; -import net.sf.gridarta.model.archetype.TestArchetypeSet; import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModel; -import net.sf.gridarta.model.autojoin.AutojoinLists; import net.sf.gridarta.model.exitconnector.ExitMatcher; -import net.sf.gridarta.model.face.FaceObjectProviders; -import net.sf.gridarta.model.face.FaceObjects; -import net.sf.gridarta.model.face.TestFaceObjects; -import net.sf.gridarta.model.gameobject.GameObjectFactory; import net.sf.gridarta.model.gameobject.TestGameObject; -import net.sf.gridarta.model.gameobject.TestGameObjectFactory; import net.sf.gridarta.model.io.CacheFiles; import net.sf.gridarta.model.io.DefaultMapWriter; import net.sf.gridarta.model.io.GameObjectParser; @@ -63,7 +52,6 @@ import net.sf.gridarta.model.io.MapWriter; import net.sf.gridarta.model.io.PathManager; import net.sf.gridarta.model.io.TestCacheFiles; -import net.sf.gridarta.model.io.TestGameObjectParser; import net.sf.gridarta.model.io.TestMapArchObjectParserFactory; import net.sf.gridarta.model.io.TestMapReaderFactory; import net.sf.gridarta.model.maparchobject.MapArchObjectFactory; @@ -72,21 +60,15 @@ import net.sf.gridarta.model.mapcontrol.MapControl; import net.sf.gridarta.model.mapcontrol.MapControlFactory; import net.sf.gridarta.model.mapcontrol.TestMapControlFactory; -import net.sf.gridarta.model.mapmodel.InsertionMode; import net.sf.gridarta.model.mapmodel.InsertionModeSet; import net.sf.gridarta.model.mapmodel.MapModelFactory; +import net.sf.gridarta.model.mapmodel.TestMapModelCreator; import net.sf.gridarta.model.mapmodel.TestMapModelHelper; -import net.sf.gridarta.model.mapmodel.TopmostInsertionMode; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; -import net.sf.gridarta.model.mapviewsettings.TestMapViewSettings; import net.sf.gridarta.model.match.GameObjectMatcher; -import net.sf.gridarta.model.match.GameObjectMatchers; import net.sf.gridarta.model.match.TypeNrsGameObjectMatcher; import net.sf.gridarta.model.settings.GlobalSettings; import net.sf.gridarta.model.settings.TestGlobalSettings; -import net.sf.gridarta.utils.GUIUtils; import net.sf.gridarta.utils.Size2D; -import net.sf.gridarta.utils.SystemIcons; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -97,12 +79,6 @@ public class TestMapControlCreator { /** - * The {@link AnimationObjects} instance. - */ - @NotNull - private final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects; - - /** * The {@link MapManager} instance. */ @NotNull @@ -115,54 +91,24 @@ private final MapManager<TestGameObject, TestMapArchObject, TestArchetype> pickmapManager; /** - * The {@link GameObjectFactory} instance. - */ - @NotNull - private final GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectFactory; - - /** * The {@link PathManager} instance. */ @NotNull private final PathManager pathManager; /** - * The "topmost" {@link InsertionMode} instance. - */ - @NotNull - private final InsertionMode<TestGameObject, TestMapArchObject, TestArchetype> topmostInsertionMode; - - /** * The {@link ExitMatcher} instance. */ @NotNull private final ExitMatcher<TestGameObject, TestMapArchObject, TestArchetype> exitMatcher; /** - * The {@link FaceObjectProviders} instance. - */ - @NotNull - private final FaceObjectProviders faceObjectProviders; - - /** - * The {@link ArchetypeSet} instance. - */ - @NotNull - private final ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeSet; - - /** * The {@link GlobalSettings} instance. */ @NotNull private final GlobalSettings globalSettings; /** - * The {@link MapViewSettings} instance. - */ - @NotNull - private final MapViewSettings mapViewSettings; - - /** * The {@link MapArchObjectFactory} instance. */ @NotNull @@ -181,44 +127,30 @@ private final MapModelFactory<TestGameObject, TestMapArchObject, TestArchetype> mapModelFactory; /** - * The {@link InsertionModeSet} instance. + * The {@link TestMapModelCreator} instance. */ @NotNull - private final InsertionModeSet<TestGameObject, TestMapArchObject, TestArchetype> insertionModeSet; + private final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false); /** * Creates a new instance. */ public TestMapControlCreator() { - final GUIUtils guiUtils = new GUIUtils(); - final SystemIcons systemIcons = new SystemIcons(guiUtils); - animationObjects = new DefaultAnimationObjects<TestGameObject, TestMapArchObject, TestArchetype>("anim"); final GameObjectMatcher exitGameObjectMatcher = new TypeNrsGameObjectMatcher(TestMapModelHelper.EXIT_TYPE); exitMatcher = new ExitMatcher<TestGameObject, TestMapArchObject, TestArchetype>(exitGameObjectMatcher); - final ArchetypeFactory<TestGameObject, TestMapArchObject, TestArchetype> archetypeFactory = new TestArchetypeFactory(); - final FaceObjects<TestGameObject, TestMapArchObject, TestArchetype> faceObjects = new TestFaceObjects(); - faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); - archetypeSet = new TestArchetypeSet(archetypeFactory, "archetypes", faceObjectProviders); final MapArchObjectParserFactory<TestMapArchObject> mapArchObjectParserFactory = new TestMapArchObjectParserFactory(); - mapViewSettings = new TestMapViewSettings(); - gameObjectFactory = new TestGameObjectFactory(faceObjectProviders, animationObjects); - final GameObjectMatchers gameObjectMatchers = new GameObjectMatchers(); - final GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParser = new TestGameObjectParser(gameObjectFactory, gameObjectMatchers, archetypeSet); - final MapReaderFactory<TestGameObject, TestMapArchObject> mapReaderFactory = new TestMapReaderFactory(mapArchObjectParserFactory, mapArchObjectFactory, gameObjectParser, mapViewSettings); + final GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParser = mapModelCreator.newGameObjectParser(); + final MapReaderFactory<TestGameObject, TestMapArchObject> mapReaderFactory = new TestMapReaderFactory(mapArchObjectParserFactory, mapArchObjectFactory, gameObjectParser, mapModelCreator.getMapViewSettings()); globalSettings = new TestGlobalSettings(); final MapWriter<TestGameObject, TestMapArchObject, TestArchetype> mapWriter = new DefaultMapWriter<TestGameObject, TestMapArchObject, TestArchetype>(mapArchObjectParserFactory, gameObjectParser); - final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists = new AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype>(mapViewSettings); final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype> archetypeChooserModel = new ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype>(); pathManager = new PathManager(globalSettings); - topmostInsertionMode = new TopmostInsertionMode<TestGameObject, TestMapArchObject, TestArchetype>(); - insertionModeSet = new InsertionModeSet<TestGameObject, TestMapArchObject, TestArchetype>(topmostInsertionMode); - insertionModeSet.init(new TypeNrsGameObjectMatcher(), new TypeNrsGameObjectMatcher(), new TypeNrsGameObjectMatcher()); - mapModelFactory = new MapModelFactory<TestGameObject, TestMapArchObject, TestArchetype>(archetypeChooserModel, autojoinLists, mapViewSettings, gameObjectFactory, gameObjectMatchers, topmostInsertionMode); + mapModelFactory = new MapModelFactory<TestGameObject, TestMapArchObject, TestArchetype>(archetypeChooserModel, mapModelCreator.getAutojoinLists(), mapModelCreator.getMapViewSettings(), mapModelCreator.getGameObjectFactory(), mapModelCreator.getGameObjectMatchers(), mapModelCreator.getTopmostInsertionMode()); final MapControlFactory<TestGameObject, TestMapArchObject, TestArchetype> mapControlFactory = new TestMapControlFactory(mapWriter, globalSettings, mapModelFactory); - final AbstractMapManager<TestGameObject, TestMapArchObject, TestArchetype> tmpMapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype>(mapReaderFactory, mapControlFactory, globalSettings, faceObjectProviders); + final AbstractMapManager<TestGameObject, TestMapArchObject, TestArchetype> tmpMapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype>(mapReaderFactory, mapControlFactory, globalSettings, mapModelCreator.getFaceObjectProviders()); tmpMapManager.setFileControl(fileControl); mapManager = tmpMapManager; - final AbstractMapManager<TestGameObject, TestMapArchObject, TestArchetype> tmpPickmapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype>(mapReaderFactory, mapControlFactory, globalSettings, faceObjectProviders); + final AbstractMapManager<TestGameObject, TestMapArchObject, TestArchetype> tmpPickmapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype>(mapReaderFactory, mapControlFactory, globalSettings, mapModelCreator.getFaceObjectProviders()); tmpPickmapManager.setFileControl(fileControl); pickmapManager = tmpPickmapManager; } @@ -229,7 +161,7 @@ * @throws DuplicateArchetypeException if an internal error occurs */ public TestMapModelHelper newMapModelCreator() throws DuplicateArchetypeException { - return new TestMapModelHelper(topmostInsertionMode, gameObjectFactory, archetypeSet, faceObjectProviders, animationObjects); + return mapModelCreator.newMapModelCreator(); } /** @@ -280,7 +212,7 @@ */ @NotNull public ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> getArchetypeSet() { - return archetypeSet; + return mapModelCreator.getArchetypeSet(); } /** @@ -298,7 +230,7 @@ */ @NotNull public InsertionModeSet<TestGameObject, TestMapArchObject, TestArchetype> getInsertionModeSet() { - return insertionModeSet; + return mapModelCreator.getInsertionModeSet(); } /** @@ -319,7 +251,7 @@ */ @NotNull public CopyBuffer<TestGameObject, TestMapArchObject, TestArchetype> newCopyBuffer() { - return new CopyBuffer<TestGameObject, TestMapArchObject, TestArchetype>(mapViewSettings, gameObjectFactory, mapArchObjectFactory, mapModelFactory, insertionModeSet); + return new CopyBuffer<TestGameObject, TestMapArchObject, TestArchetype>(mapModelCreator.getMapViewSettings(), mapModelCreator.getGameObjectFactory(), mapArchObjectFactory, mapModelFactory, mapModelCreator.getInsertionModeSet()); } /** @@ -329,7 +261,7 @@ @NotNull public MapViewsManager<TestGameObject, TestMapArchObject, TestArchetype> newMapViewsManager() { final MapViewFactory<TestGameObject, TestMapArchObject, TestArchetype> mapViewFactory = new TestMapViewFactory(); - return new MapViewsManager<TestGameObject, TestMapArchObject, TestArchetype>(mapViewSettings, mapViewFactory, mapManager, pickmapManager); + return new MapViewsManager<TestGameObject, TestMapArchObject, TestArchetype>(mapModelCreator.getMapViewSettings(), mapViewFactory, mapManager, pickmapManager); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-09-25 21:38:57
|
Revision: 8659 http://gridarta.svn.sourceforge.net/gridarta/?rev=8659&view=rev Author: akirschbaum Date: 2010-09-25 21:38:50 +0000 (Sat, 25 Sep 2010) Log Message: ----------- Correctly update archetypes when undoing/redoing operations involving autojoining. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/model/src/app/net/sf/gridarta/model/gameobject/AbstractGameObject.java trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java Added Paths: ----------- trunk/src/test/net/sf/gridarta/actions/ trunk/src/test/net/sf/gridarta/actions/UndoActionsTest.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-09-25 20:25:08 UTC (rev 8658) +++ trunk/atrinik/ChangeLog 2010-09-25 21:38:50 UTC (rev 8659) @@ -1,3 +1,8 @@ +2010-09-25 Andreas Kirschbaum + + * Correctly update archetypes when undoing/redoing operations + involving autojoining. + 2010-09-08 Andreas Kirschbaum * Retain tab locations in main window across editor restarts. Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-09-25 20:25:08 UTC (rev 8658) +++ trunk/crossfire/ChangeLog 2010-09-25 21:38:50 UTC (rev 8659) @@ -1,3 +1,8 @@ +2010-09-25 Andreas Kirschbaum + + * Correctly update archetypes when undoing/redoing operations + involving autojoining. + 2010-09-08 Andreas Kirschbaum * Retain tab locations in main window across editor restarts. Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-09-25 20:25:08 UTC (rev 8658) +++ trunk/daimonin/ChangeLog 2010-09-25 21:38:50 UTC (rev 8659) @@ -1,3 +1,8 @@ +2010-09-25 Andreas Kirschbaum + + * Correctly update archetypes when undoing/redoing operations + involving autojoining. + 2010-09-08 Andreas Kirschbaum * Retain tab locations in main window across editor restarts. Modified: trunk/model/src/app/net/sf/gridarta/model/gameobject/AbstractGameObject.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/gameobject/AbstractGameObject.java 2010-09-25 20:25:08 UTC (rev 8658) +++ trunk/model/src/app/net/sf/gridarta/model/gameobject/AbstractGameObject.java 2010-09-25 21:38:50 UTC (rev 8659) @@ -339,8 +339,13 @@ return; } - this.archetype = archetype; - updateArchetype(); + beginGameObjectChange(); + try { + this.archetype = archetype; + updateArchetype(); + } finally { + endGameObjectChange(); + } } /** Added: trunk/src/test/net/sf/gridarta/actions/UndoActionsTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/actions/UndoActionsTest.java (rev 0) +++ trunk/src/test/net/sf/gridarta/actions/UndoActionsTest.java 2010-09-25 21:38:50 UTC (rev 8659) @@ -0,0 +1,119 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.actions; + +import java.awt.Point; +import net.sf.gridarta.gui.map.test.TestMapControlCreator; +import net.sf.gridarta.gui.undo.UndoControl; +import net.sf.gridarta.mapmanager.MapManager; +import net.sf.gridarta.model.archetype.DuplicateArchetypeException; +import net.sf.gridarta.model.archetype.TestArchetype; +import net.sf.gridarta.model.autojoin.AutojoinListsHelper; +import net.sf.gridarta.model.autojoin.IllegalAutojoinListException; +import net.sf.gridarta.model.baseobject.BaseObject; +import net.sf.gridarta.model.gameobject.TestGameObject; +import net.sf.gridarta.model.maparchobject.TestMapArchObject; +import net.sf.gridarta.model.mapcontrol.MapControl; +import net.sf.gridarta.model.mapmodel.CannotInsertGameObjectException; +import net.sf.gridarta.model.mapmodel.MapModel; +import net.sf.gridarta.model.mapmodel.MapSquare; +import net.sf.gridarta.model.mapmodel.TestMapModelCreator; +import net.sf.gridarta.model.mapmodel.TestMapModelHelper; +import net.sf.gridarta.utils.Size2D; +import org.jetbrains.annotations.NotNull; +import org.junit.Assert; +import org.junit.Test; + +/** + * Regression tests for {@link UndoActions}. + * @author Andreas Kirschbaum + */ +public class UndoActionsTest { + + /** + * Checks that undo correctly sets the "face" attribute. + * @throws IllegalAutojoinListException if the test fails + * @throws DuplicateArchetypeException if the test fails + * @throws CannotInsertGameObjectException if the test fails + */ + @Test + public void testInsert1() throws CannotInsertGameObjectException, DuplicateArchetypeException, IllegalAutojoinListException { + final TestMapControlCreator mapControlCreator = new TestMapControlCreator(); + final TestMapModelCreator mapModelCreator = mapControlCreator.getMapModelCreator(); + final AutojoinListsHelper autojoinListsHelper = mapControlCreator.newAutojoinListsHelper(); + for (int i = 0; i < 16; i++) { + final TestArchetype a = mapModelCreator.getArchetype("a" + i); + a.setAttributeString("face", "face" + i); + } + autojoinListsHelper.newAutojoinLists("a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15"); + + final MapManager<TestGameObject, TestMapArchObject, TestArchetype> mapManager = mapControlCreator.newMapManager(); + final UndoControl<TestGameObject, TestMapArchObject, TestArchetype> undoControl = new UndoControl<TestGameObject, TestMapArchObject, TestArchetype>(mapManager, mapModelCreator.getGameObjectFactory(), mapModelCreator.getGameObjectMatchers()); + + final TestMapArchObject mapArchObject = new TestMapArchObject(); + mapArchObject.setMapSize(new Size2D(2, 1)); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = mapManager.newMap(null, mapArchObject, null, true); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); + final TestMapModelHelper testMapModelHelper = mapModelCreator.newTestMapModelHelper(); + + final TestArchetype a0 = mapModelCreator.getArchetype("a0"); + + mapModelCreator.getMapViewSettings().setAutojoin(true); + mapModel.beginTransaction("TEST"); + try { + testMapModelHelper.insertArchetype(mapModel, 0, 0, a0, false); + } finally { + mapModel.endTransaction(); + } + + TestMapModelHelper.checkMapContents(mapModel, "a0|"); + checkFace(mapModel, 0, 0, "face0"); + + mapModel.beginTransaction("TEST"); + try { + testMapModelHelper.insertArchetype(mapModel, 1, 0, a0, true); + } finally { + mapModel.endTransaction(); + } + + TestMapModelHelper.checkMapContents(mapModel, "a2|a8"); + checkFace(mapModel, 0, 0, "face2"); + checkFace(mapModel, 1, 0, "face8"); + + undoControl.undo(); + TestMapModelHelper.checkMapContents(mapModel, "a0|"); + checkFace(mapModel, 0, 0, "face0"); + } + + /** + * Checks the face name of the first object in a map square. + * @param mapModel the map model to check + * @param x the x coordinate of the map square to check + * @param y the y coordinate of the map square to check + * @param face the expected face name + */ + private static void checkFace(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, final int x, final int y, @NotNull final String face) { + final MapSquare<?, ?, ?> mapSquare = mapModel.getMapSquare(new Point(x, y)); + final BaseObject<?, ?, ?, ?> object = mapSquare.getFirst(); + Assert.assertNotNull(object); + Assert.assertEquals(face, object.getAttributeString("face")); + } + +} // class UndoActionsTest Property changes on: trunk/src/test/net/sf/gridarta/actions/UndoActionsTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java 2010-09-25 20:25:08 UTC (rev 8658) +++ trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java 2010-09-25 21:38:50 UTC (rev 8659) @@ -42,6 +42,7 @@ import net.sf.gridarta.model.archetype.DuplicateArchetypeException; import net.sf.gridarta.model.archetype.TestArchetype; import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModel; +import net.sf.gridarta.model.autojoin.AutojoinListsHelper; import net.sf.gridarta.model.exitconnector.ExitMatcher; import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.io.CacheFiles; @@ -103,6 +104,12 @@ private final ExitMatcher<TestGameObject, TestMapArchObject, TestArchetype> exitMatcher; /** + * The {@link MapReaderFactory} instance. + */ + @NotNull + private final MapReaderFactory<TestGameObject, TestMapArchObject> mapReaderFactory; + + /** * The {@link GlobalSettings} instance. */ @NotNull @@ -127,6 +134,12 @@ private final MapModelFactory<TestGameObject, TestMapArchObject, TestArchetype> mapModelFactory; /** + * The {@link MapControlFactory} instance. + */ + @NotNull + private final MapControlFactory<TestGameObject, TestMapArchObject, TestArchetype> mapControlFactory; + + /** * The {@link TestMapModelCreator} instance. */ @NotNull @@ -140,13 +153,13 @@ exitMatcher = new ExitMatcher<TestGameObject, TestMapArchObject, TestArchetype>(exitGameObjectMatcher); final MapArchObjectParserFactory<TestMapArchObject> mapArchObjectParserFactory = new TestMapArchObjectParserFactory(); final GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParser = mapModelCreator.newGameObjectParser(); - final MapReaderFactory<TestGameObject, TestMapArchObject> mapReaderFactory = new TestMapReaderFactory(mapArchObjectParserFactory, mapArchObjectFactory, gameObjectParser, mapModelCreator.getMapViewSettings()); + mapReaderFactory = new TestMapReaderFactory(mapArchObjectParserFactory, mapArchObjectFactory, gameObjectParser, mapModelCreator.getMapViewSettings()); globalSettings = new TestGlobalSettings(); final MapWriter<TestGameObject, TestMapArchObject, TestArchetype> mapWriter = new DefaultMapWriter<TestGameObject, TestMapArchObject, TestArchetype>(mapArchObjectParserFactory, gameObjectParser); final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype> archetypeChooserModel = new ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype>(); pathManager = new PathManager(globalSettings); mapModelFactory = new MapModelFactory<TestGameObject, TestMapArchObject, TestArchetype>(archetypeChooserModel, mapModelCreator.getAutojoinLists(), mapModelCreator.getMapViewSettings(), mapModelCreator.getGameObjectFactory(), mapModelCreator.getGameObjectMatchers(), mapModelCreator.getTopmostInsertionMode()); - final MapControlFactory<TestGameObject, TestMapArchObject, TestArchetype> mapControlFactory = new TestMapControlFactory(mapWriter, globalSettings, mapModelFactory); + mapControlFactory = new TestMapControlFactory(mapWriter, globalSettings, mapModelFactory); final AbstractMapManager<TestGameObject, TestMapArchObject, TestArchetype> tmpMapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype>(mapReaderFactory, mapControlFactory, globalSettings, mapModelCreator.getFaceObjectProviders()); tmpMapManager.setFileControl(fileControl); mapManager = tmpMapManager; @@ -286,4 +299,31 @@ return fileControl; } + /** + * Returns a new {@link AutojoinListsHelper} instance. + * @return the autojoin lists helper instance + */ + @NotNull + public AutojoinListsHelper newAutojoinListsHelper() { + return new AutojoinListsHelper(mapModelCreator); + } + + /** + * Returns the {@link TestMapModelCreator} instance. + * @return the test map model creator instance + */ + @NotNull + public TestMapModelCreator getMapModelCreator() { + return mapModelCreator; + } + + /** + * Returns a new {@link MapManager} instance. + * @return the map manager instance + */ + @NotNull + public MapManager<TestGameObject, TestMapArchObject, TestArchetype> newMapManager() { + return new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype>(mapReaderFactory, mapControlFactory, globalSettings, mapModelCreator.getFaceObjectProviders()); + } + } // class TestMapControlCreator This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-10-05 07:15:26
|
Revision: 8665 http://gridarta.svn.sourceforge.net/gridarta/?rev=8665&view=rev Author: akirschbaum Date: 2010-10-05 07:15:19 +0000 (Tue, 05 Oct 2010) Log Message: ----------- Use the def_arch's archetype name as the artifact's name for artifacts that do not specify a name attribute in def_arch or in the artifact definition. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/daimonin/ChangeLog trunk/model/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java trunk/model/src/test/net/sf/gridarta/model/artifact/ArtifactParserTest.java Added Paths: ----------- trunk/model/src/test/net/sf/gridarta/model/artifact/TestParser.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-10-04 20:18:20 UTC (rev 8664) +++ trunk/atrinik/ChangeLog 2010-10-05 07:15:19 UTC (rev 8665) @@ -1,3 +1,9 @@ +2010-10-05 Andreas Kirschbaum + + * Use the def_arch's archetype name as the artifact's name for + artifacts that do not specify a "name" attribute in def_arch or in + the artifact definition. + 2010-09-29 Alex Tokar * Update default path to client executable on GNU/Linux. Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-10-04 20:18:20 UTC (rev 8664) +++ trunk/daimonin/ChangeLog 2010-10-05 07:15:19 UTC (rev 8665) @@ -1,3 +1,9 @@ +2010-10-05 Andreas Kirschbaum + + * Use the def_arch's archetype name as the artifact's name for + artifacts that do not specify a "name" attribute in def_arch or in + the artifact definition. + 2010-09-25 Andreas Kirschbaum * Correctly update archetypes when undoing/redoing operations Modified: trunk/model/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java 2010-10-04 20:18:20 UTC (rev 8664) +++ trunk/model/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java 2010-10-05 07:15:19 UTC (rev 8665) @@ -25,6 +25,7 @@ import net.sf.gridarta.model.anim.AnimationObjects; import net.sf.gridarta.model.anim.DuplicateAnimationException; import net.sf.gridarta.model.anim.IllegalAnimationException; +import net.sf.gridarta.model.baseobject.BaseObject; import net.sf.gridarta.model.errorview.ErrorViewCategory; import net.sf.gridarta.model.errorview.ErrorViewCollector; import net.sf.gridarta.model.gameobject.GameObject; @@ -138,6 +139,9 @@ final String archetypeName = archName != null ? archName : thisLine2.trim().substring(7); archetypeBuilder.reInit(archetypeName); + if (prototype != null && prototype.getAttributeString(BaseObject.NAME).isEmpty()) { + archetypeBuilder.addObjectText(BaseObject.NAME + " " + prototype.getArchetypeName()); + } if (!archMore) { if (firstArch != null) { finishParseArchetype(firstArch); Modified: trunk/model/src/test/net/sf/gridarta/model/artifact/ArtifactParserTest.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/artifact/ArtifactParserTest.java 2010-10-04 20:18:20 UTC (rev 8664) +++ trunk/model/src/test/net/sf/gridarta/model/artifact/ArtifactParserTest.java 2010-10-05 07:15:19 UTC (rev 8665) @@ -19,34 +19,14 @@ package net.sf.gridarta.model.artifact; -import java.io.BufferedReader; -import java.io.File; import java.io.IOException; -import java.io.Reader; -import java.io.StringReader; -import java.util.ArrayList; -import java.util.List; -import net.sf.gridarta.model.anim.AnimationObjects; -import net.sf.gridarta.model.anim.TestAnimationObjects; -import net.sf.gridarta.model.archetype.AbstractArchetypeParser; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.archetype.DuplicateArchetypeException; import net.sf.gridarta.model.archetype.TestArchetype; -import net.sf.gridarta.model.archetype.TestArchetypeBuilder; -import net.sf.gridarta.model.archetype.TestArchetypeFactory; -import net.sf.gridarta.model.archetype.TestArchetypeParser; -import net.sf.gridarta.model.archetype.TestArchetypeSet; import net.sf.gridarta.model.archetype.UndefinedArchetypeException; -import net.sf.gridarta.model.errorview.ErrorViewCollector; import net.sf.gridarta.model.errorview.TestErrorView; -import net.sf.gridarta.model.face.FaceObjectProviders; -import net.sf.gridarta.model.face.FaceObjects; -import net.sf.gridarta.model.face.TestFaceObjects; import net.sf.gridarta.model.gameobject.TestGameObject; -import net.sf.gridarta.model.gameobject.TestGameObjectFactory; import net.sf.gridarta.model.maparchobject.TestMapArchObject; -import net.sf.gridarta.utils.GUIUtils; -import net.sf.gridarta.utils.SystemIcons; import org.junit.Assert; import org.junit.Test; @@ -64,36 +44,75 @@ */ @Test public void testMissingObject() throws DuplicateArchetypeException, IOException, UndefinedArchetypeException { - final TestArchetypeFactory archetypeFactory = new TestArchetypeFactory(); - final GUIUtils guiUtils = new GUIUtils(); - final SystemIcons systemIcons = new SystemIcons(guiUtils); - final FaceObjects<TestGameObject, TestMapArchObject, TestArchetype> faceObjects = new TestFaceObjects(); - final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); - final TestArchetypeSet archetypeSet = new TestArchetypeSet(archetypeFactory, "archetypes", faceObjectProviders); - final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new TestAnimationObjects(); - final TestArchetype baseArchetype = new TestArchetype("base", faceObjectProviders, animationObjects); - baseArchetype.setObjectText("sp 2\n"); - archetypeSet.addArchetype(baseArchetype); - final File file = new File("*string*"); final TestErrorView errorView = new TestErrorView(); - final ErrorViewCollector errorViewCollector = new ErrorViewCollector(errorView, file); - final TestGameObjectFactory gameObjectFactory = new TestGameObjectFactory(faceObjectProviders, animationObjects); - final TestArchetypeBuilder archetypeBuilder = new TestArchetypeBuilder(gameObjectFactory); - final AbstractArchetypeParser<TestGameObject, TestMapArchObject, TestArchetype, TestArchetypeBuilder> archetypeParser = new TestArchetypeParser(archetypeBuilder, animationObjects, archetypeSet); - final List<TestGameObject> invObjects = new ArrayList<TestGameObject>(); - final ArtifactParser<TestGameObject, TestMapArchObject, TestArchetype> artifactParser = new ArtifactParser<TestGameObject, TestMapArchObject, TestArchetype>(archetypeSet, errorView, archetypeParser, invObjects); - final Reader reader = new StringReader("artifact art\n" + "def_arch base\nObject obj\nsp 3\n" + "end\n"); - final BufferedReader bufferedReader = new BufferedReader(reader); - try { - artifactParser.loadArtifact(bufferedReader, errorViewCollector, "", "panel", "folder"); - } finally { - bufferedReader.close(); - } + final TestParser parser = new TestParser(errorView); + parser.addArchetype("base", "sp 2"); + parser.parseArtifacts("artifact art\n" + "def_arch base\nObject obj\nsp 3\n" + "end\n"); Assert.assertFalse(errorView.hasWarnings()); Assert.assertFalse(errorView.hasErrors()); - Assert.assertEquals(2, archetypeSet.getArchetypeCount()); - final Archetype<TestGameObject, TestMapArchObject, TestArchetype> archetype = archetypeSet.getArchetype("art"); - Assert.assertEquals("sp 3\n", archetype.getObjectText()); + Assert.assertEquals(2, parser.getArchetypeCount()); + final Archetype<TestGameObject, TestMapArchObject, TestArchetype> archetype = parser.getArchetype("art"); + Assert.assertEquals("name base\nsp 3\n", archetype.getObjectText()); } + /** + * Checks that an artifact definition inherits the def_arch archetype's name + * by default. + * @throws DuplicateArchetypeException if the test fails + * @throws IOException if the test fails + * @throws UndefinedArchetypeException if the test fails + */ + @Test + public void testDefaultName1() throws DuplicateArchetypeException, IOException, UndefinedArchetypeException { + final TestParser parser = new TestParser(); + parser.addArchetype("horn"); + parser.parseArtifacts("artifact horn_fools\n" + "def_arch horn\n" + "Object obj\n" + "title of fools\n" + "end\n"); + Assert.assertEquals("horn of fools", parser.getArchetype("horn_fools").getBestName()); + } + + /** + * Checks that an artifact definition inherits the def_arch archetype's name + * by default. + * @throws DuplicateArchetypeException if the test fails + * @throws IOException if the test fails + * @throws UndefinedArchetypeException if the test fails + */ + @Test + public void testDefaultName2() throws DuplicateArchetypeException, IOException, UndefinedArchetypeException { + final TestParser parser = new TestParser(); + parser.addArchetype("horn", "name horn2"); + parser.parseArtifacts("artifact horn_fools\n" + "def_arch horn\n" + "Object obj\n" + "title of fools\n" + "end\n"); + Assert.assertEquals("horn2 of fools", parser.getArchetype("horn_fools").getBestName()); + } + + /** + * Checks that an artifact definition inherits the def_arch archetype's name + * by default. + * @throws DuplicateArchetypeException if the test fails + * @throws IOException if the test fails + * @throws UndefinedArchetypeException if the test fails + */ + @Test + public void testDefaultName3() throws DuplicateArchetypeException, IOException, UndefinedArchetypeException { + final TestParser parser = new TestParser(); + parser.addArchetype("horn", "name base_horn"); + parser.parseArtifacts("artifact horn_fools\n" + "def_arch horn\n" + "Object obj\n" + "title of fools\n" + "end\n"); + Assert.assertEquals("base_horn of fools", parser.getArchetype("horn_fools").getBestName()); + } + + /** + * Checks that an artifact definition inherits the def_arch archetype's name + * by default. + * @throws DuplicateArchetypeException if the test fails + * @throws IOException if the test fails + * @throws UndefinedArchetypeException if the test fails + */ + @Test + public void testDefaultName4() throws DuplicateArchetypeException, IOException, UndefinedArchetypeException { + final TestParser parser = new TestParser(); + parser.addArchetype("horn", "name base_horn"); + parser.parseArtifacts("artifact horn_fools\n" + "def_arch horn\n" + "Object obj\n" + "name special_horn\n" + "title of fools\n" + "end\n"); + Assert.assertEquals("special_horn of fools", parser.getArchetype("horn_fools").getBestName()); + } + } // class ArtifactParserTest Added: trunk/model/src/test/net/sf/gridarta/model/artifact/TestParser.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/artifact/TestParser.java (rev 0) +++ trunk/model/src/test/net/sf/gridarta/model/artifact/TestParser.java 2010-10-05 07:15:19 UTC (rev 8665) @@ -0,0 +1,166 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.model.artifact; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.Reader; +import java.io.StringReader; +import java.util.ArrayList; +import java.util.List; +import net.sf.gridarta.model.anim.AnimationObjects; +import net.sf.gridarta.model.anim.TestAnimationObjects; +import net.sf.gridarta.model.archetype.AbstractArchetypeParser; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.archetype.DuplicateArchetypeException; +import net.sf.gridarta.model.archetype.TestArchetype; +import net.sf.gridarta.model.archetype.TestArchetypeBuilder; +import net.sf.gridarta.model.archetype.TestArchetypeFactory; +import net.sf.gridarta.model.archetype.TestArchetypeParser; +import net.sf.gridarta.model.archetype.TestArchetypeSet; +import net.sf.gridarta.model.archetype.UndefinedArchetypeException; +import net.sf.gridarta.model.errorview.ErrorViewCollector; +import net.sf.gridarta.model.errorview.TestErrorView; +import net.sf.gridarta.model.face.FaceObjectProviders; +import net.sf.gridarta.model.face.FaceObjects; +import net.sf.gridarta.model.face.TestFaceObjects; +import net.sf.gridarta.model.gameobject.TestGameObject; +import net.sf.gridarta.model.gameobject.TestGameObjectFactory; +import net.sf.gridarta.model.maparchobject.TestMapArchObject; +import net.sf.gridarta.utils.GUIUtils; +import net.sf.gridarta.utils.SystemIcons; +import org.jetbrains.annotations.NotNull; + +/** + * Parser for artifacts definitions. + * @author Andreas Kirschbaum + */ +public class TestParser { + + /** + * The {@link FaceObjectProviders} instance. + */ + @NotNull + private final FaceObjectProviders faceObjectProviders; + + /** + * The {@link TestArchetypeSet} instance. + */ + @NotNull + private final TestArchetypeSet archetypeSet; + + /** + * The {@link AnimationObjects} instance. + */ + @NotNull + private final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new TestAnimationObjects(); + + /** + * The {@link ErrorViewCollector} instance. + */ + @NotNull + private final ErrorViewCollector errorViewCollector; + + /** + * The {@link ArtifactParser} instance. + */ + @NotNull + private final ArtifactParser<TestGameObject, TestMapArchObject, TestArchetype> artifactParser; + + /** + * Creates a new instance. + */ + public TestParser() { + this(new TestErrorView()); + } + + /** + * Creates a new instance. + * @param errorView the error view to use for parsing + */ + public TestParser(@NotNull final TestErrorView errorView) { + final GUIUtils guiUtils = new GUIUtils(); + final SystemIcons systemIcons = new SystemIcons(guiUtils); + final TestArchetypeFactory archetypeFactory = new TestArchetypeFactory(); + final File file = new File("*string*"); + errorViewCollector = new ErrorViewCollector(errorView, file); + final FaceObjects<TestGameObject, TestMapArchObject, TestArchetype> faceObjects = new TestFaceObjects(); + faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); + final TestGameObjectFactory gameObjectFactory = new TestGameObjectFactory(faceObjectProviders, animationObjects); + archetypeSet = new TestArchetypeSet(archetypeFactory, "archetypes", faceObjectProviders); + final TestArchetypeBuilder archetypeBuilder = new TestArchetypeBuilder(gameObjectFactory); + final AbstractArchetypeParser<TestGameObject, TestMapArchObject, TestArchetype, TestArchetypeBuilder> archetypeParser = new TestArchetypeParser(archetypeBuilder, animationObjects, archetypeSet); + final List<TestGameObject> invObjects = new ArrayList<TestGameObject>(); + artifactParser = new ArtifactParser<TestGameObject, TestMapArchObject, TestArchetype>(archetypeSet, errorView, archetypeParser, invObjects); + } + + /** + * Adds a new archetype. + * @param archetypeName the archetype name + * @param attributes the archetype's attributes; may be empty + * @throws DuplicateArchetypeException if the archetype name is not unique + */ + public void addArchetype(@NotNull final String archetypeName, @NotNull final String... attributes) throws DuplicateArchetypeException { + final TestArchetype baseArchetype = new TestArchetype(archetypeName, faceObjectProviders, animationObjects); + final StringBuilder objectText = new StringBuilder(); + for (final String attribute : attributes) { + objectText.append(attribute); + objectText.append('\n'); + } + baseArchetype.setObjectText(objectText.toString()); + archetypeSet.addArchetype(baseArchetype); + } + + /** + * Parses artifacts definitions. + * @param artifacts the artifacts definitions + * @throws IOException if parsing fails + */ + public void parseArtifacts(@NotNull final String artifacts) throws IOException { + final Reader reader = new StringReader(artifacts); + final BufferedReader bufferedReader = new BufferedReader(reader); + try { + artifactParser.loadArtifact(bufferedReader, errorViewCollector, "", "panel", "folder"); + } finally { + bufferedReader.close(); + } + } + + /** + * Returns an {@link Archetype} by name. + * @param archetypeName the archetype name + * @return the archetype + * @throws UndefinedArchetypeException if the archetype name is undefined + */ + @NotNull + public Archetype<TestGameObject, TestMapArchObject, TestArchetype> getArchetype(@NotNull final String archetypeName) throws UndefinedArchetypeException { + return archetypeSet.getArchetype(archetypeName); + } + + /** + * Returns the number of defined archetypes. + * @return the number of defined archetypes + */ + public int getArchetypeCount() { + return archetypeSet.getArchetypeCount(); + } + +} // class TestParser Property changes on: trunk/model/src/test/net/sf/gridarta/model/artifact/TestParser.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-10-05 17:25:06
|
Revision: 8666 http://gridarta.svn.sourceforge.net/gridarta/?rev=8666&view=rev Author: akirschbaum Date: 2010-10-05 17:24:59 +0000 (Tue, 05 Oct 2010) Log Message: ----------- Remove dependency GameObjectMatchers -> GameObjectMatchersParser. Modified Paths: -------------- trunk/model/src/app/net/sf/gridarta/model/match/GameObjectMatchers.java trunk/model/src/app/net/sf/gridarta/model/match/GameObjectMatchersParser.java trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java Modified: trunk/model/src/app/net/sf/gridarta/model/match/GameObjectMatchers.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/match/GameObjectMatchers.java 2010-10-05 07:15:19 UTC (rev 8665) +++ trunk/model/src/app/net/sf/gridarta/model/match/GameObjectMatchers.java 2010-10-05 17:24:59 UTC (rev 8666) @@ -19,16 +19,12 @@ package net.sf.gridarta.model.match; -import java.io.IOException; import java.io.Serializable; -import java.net.URL; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Map; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.xpath.XPath; import net.sf.gridarta.gui.utils.GUIConstants; import net.sf.gridarta.model.errorview.ErrorViewCategory; import net.sf.gridarta.model.errorview.ErrorViewCollector; @@ -63,19 +59,6 @@ private final Collection<NamedGameObjectMatcher> gameObjectMatchers = new ArrayList<NamedGameObjectMatcher>(); /** - * Parses a .xml file defining game object matchers. - * @param documentBuilder the <code>DocumentBuilder</code> to use for - * parsing XML - * @param xpath XPath to use for applying for XPath expressions. - * @param url the URL to parse - * @param errorViewCollector the error view collector to use - * @throws IOException if the file cannot be parsed - */ - public void readGameObjectMatchers(@NotNull final DocumentBuilder documentBuilder, @NotNull final XPath xpath, @NotNull final URL url, @NotNull final ErrorViewCollector errorViewCollector) throws IOException { - new GameObjectMatchersParser(documentBuilder, xpath).readGameObjectMatchers(url, gameObjectMatchers, gameObjectMatchersByIds, errorViewCollector); - } - - /** * Returns a matcher by id; returns <code>null</code> if the matcher does * not exist. * @param ids the ids to find @@ -158,4 +141,13 @@ return editType; } + /** + * Adds a new {@link GameObjectMatcher}. + * @param gameObjectMatcher the game object matcher to add + */ + public void addGameObjectMatcher(@NotNull final NamedGameObjectMatcher gameObjectMatcher) { + gameObjectMatchers.add(gameObjectMatcher); + gameObjectMatchersByIds.put(gameObjectMatcher.getID(), gameObjectMatcher); + } + } // class GameObjectMatchers Modified: trunk/model/src/app/net/sf/gridarta/model/match/GameObjectMatchersParser.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/match/GameObjectMatchersParser.java 2010-10-05 07:15:19 UTC (rev 8665) +++ trunk/model/src/app/net/sf/gridarta/model/match/GameObjectMatchersParser.java 2010-10-05 17:24:59 UTC (rev 8666) @@ -21,9 +21,7 @@ import java.io.IOException; import java.net.URL; -import java.util.Collection; import java.util.Iterator; -import java.util.Map; import javax.xml.parsers.DocumentBuilder; import javax.xml.xpath.XPath; import net.sf.gridarta.model.errorview.ErrorViewCategory; @@ -76,12 +74,10 @@ * Parses a .xml file defining game object matchers. * @param url the URL to parse * @param gameObjectMatchers the game object matchers to update - * @param gameObjectMatchersByIds the numbered game object matchers to - * update * @param errorViewCollector the error view collector to use * @throws IOException if the file cannot be parsed */ - public void readGameObjectMatchers(@NotNull final URL url, @NotNull final Collection<NamedGameObjectMatcher> gameObjectMatchers, @NotNull final Map<String, NamedGameObjectMatcher> gameObjectMatchersByIds, @NotNull final ErrorViewCollector errorViewCollector) throws IOException { + public void readGameObjectMatchers(@NotNull final URL url, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ErrorViewCollector errorViewCollector) throws IOException { final GameObjectMatcherParser aom = new GameObjectMatcherParser(xpath); final Document doc; try { @@ -89,6 +85,7 @@ } catch (final SAXException ex) { throw new IOException("sax exception: " + ex.getMessage(), ex); } + int count = 0; int editType = 1; final Iterator<Element> it = new NodeListIterator<Element>(doc.getElementsByTagName("GameObjectMatcher")); while (it.hasNext()) { @@ -100,8 +97,8 @@ errorViewCollector.addWarning(ErrorViewCategory.GAMEOBJECTMATCHERS_ENTRY_INVALID, node.getAttribute("id") + ": " + ex.getMessage()); continue; } - gameObjectMatchers.add(archObjectMatcher); - gameObjectMatchersByIds.put(archObjectMatcher.getID(), archObjectMatcher); + gameObjectMatchers.addGameObjectMatcher(archObjectMatcher); + count++; if (editType != 0 && !archObjectMatcher.isSystemMatcher()) { editType <<= 1; if (editType == 0) { @@ -110,7 +107,7 @@ } } if (log.isInfoEnabled()) { - log.info("Loaded " + gameObjectMatchers.size() + " GameObjectMatchers from '" + url + "'."); + log.info("Loaded " + count + " GameObjectMatchers from '" + url + "'."); } } Modified: trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java 2010-10-05 07:15:19 UTC (rev 8665) +++ trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java 2010-10-05 17:24:59 UTC (rev 8666) @@ -74,6 +74,7 @@ import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.match.GameObjectMatcher; import net.sf.gridarta.model.match.GameObjectMatchers; +import net.sf.gridarta.model.match.GameObjectMatchersParser; import net.sf.gridarta.model.resource.AbstractResources; import net.sf.gridarta.model.scripts.ScriptArchData; import net.sf.gridarta.model.scripts.ScriptArchUtils; @@ -182,11 +183,12 @@ //noinspection ThrowInsideCatchBlockWhichIgnoresCaughtException throw new MissingResourceException("Cannot create XML parser: " + ex.getMessage(), null, null); } + final GameObjectMatchersParser gameObjectMatchersParser = new GameObjectMatchersParser(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath()); try { final URL url = IOUtils.getResource(globalSettings.getConfigurationDirectory(), "GameObjectMatchers.xml"); final ErrorViewCollector gameObjectMatchersErrorViewCollector = new ErrorViewCollector(errorView, url); try { - gameObjectMatchers.readGameObjectMatchers(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath(), url, gameObjectMatchersErrorViewCollector); + gameObjectMatchersParser.readGameObjectMatchers(url, gameObjectMatchers, gameObjectMatchersErrorViewCollector); } catch (final IOException ex) { gameObjectMatchersErrorViewCollector.addWarning(ErrorViewCategory.GAMEOBJECTMATCHERS_FILE_INVALID, ex.getMessage()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-10-05 18:26:25
|
Revision: 8667 http://gridarta.svn.sourceforge.net/gridarta/?rev=8667&view=rev Author: akirschbaum Date: 2010-10-05 18:26:18 +0000 (Tue, 05 Oct 2010) Log Message: ----------- Create AttributeRangeChecker instance more local. Modified Paths: -------------- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java trunk/build.xml trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java trunk/src/app/net/sf/gridarta/maincontrol/EditorFactory.java trunk/src/app/net/sf/gridarta/maincontrol/GridartaEditor.java Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2010-10-05 17:24:59 UTC (rev 8666) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2010-10-05 18:26:18 UTC (rev 8667) @@ -191,8 +191,8 @@ */ @NotNull @Override - public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final GlobalSettings globalSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory, @NotNull final ValidatorPreferences validatorPreferences) { - return new DefaultMainControl<GameObject, MapArchObject, Archetype>(GuiFileFilters.pythonFileFilter, ".py", "Python", 0, IGUIConstants.SPELL_FILE, IGUIConstants.SCRIPTS_DIR, errorView, this, forceReadFromFiles, globalSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, autojoinLists, mapManager, scriptModel, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, attributeRangeChecker, pluginParameterFactory, validatorPreferences); + public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final GlobalSettings globalSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory, @NotNull final ValidatorPreferences validatorPreferences) { + return new DefaultMainControl<GameObject, MapArchObject, Archetype>(GuiFileFilters.pythonFileFilter, ".py", "Python", 0, IGUIConstants.SPELL_FILE, IGUIConstants.SCRIPTS_DIR, errorView, this, forceReadFromFiles, globalSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, autojoinLists, mapManager, scriptModel, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, pluginParameterFactory, validatorPreferences); } /** Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2010-10-05 17:24:59 UTC (rev 8666) +++ trunk/build.xml 2010-10-05 18:26:18 UTC (rev 8667) @@ -282,6 +282,7 @@ <fileset dir="lib" includes="junit-4.2.jar"/> <pathelement location="dest/crossfire/app"/> <pathelement location="dest/gridarta/app"/> + <pathelement location="dest/gridarta/test"/> <pathelement location="dest/model/app"/> <pathelement location="dest/model/test"/> <pathelement location="dest/utils/app"/> @@ -885,6 +886,7 @@ <pathelement location="dest/crossfire/app"/> <pathelement location="dest/crossfire/test"/> <pathelement location="dest/gridarta/app"/> + <pathelement location="dest/gridarta/test"/> <pathelement location="dest/model/app"/> <pathelement location="dest/model/test"/> <pathelement location="dest/utils/app"/> Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2010-10-05 17:24:59 UTC (rev 8666) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2010-10-05 18:26:18 UTC (rev 8667) @@ -159,8 +159,8 @@ */ @NotNull @Override - public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final GlobalSettings globalSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory, @NotNull final ValidatorPreferences validatorPreferences) { - return new DefaultMainControl<GameObject, MapArchObject, Archetype>(GuiFileFilters.pythonFileFilter, ".py", "Python", Archetype.TYPE_SPELL, null, IGUIConstants.SCRIPTS_DIR, errorView, this, false, globalSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, autojoinLists, mapManager, scriptModel, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, attributeRangeChecker, pluginParameterFactory, validatorPreferences); + public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final GlobalSettings globalSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory, @NotNull final ValidatorPreferences validatorPreferences) { + return new DefaultMainControl<GameObject, MapArchObject, Archetype>(GuiFileFilters.pythonFileFilter, ".py", "Python", Archetype.TYPE_SPELL, null, IGUIConstants.SCRIPTS_DIR, errorView, this, false, globalSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, autojoinLists, mapManager, scriptModel, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, pluginParameterFactory, validatorPreferences); } /** Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2010-10-05 17:24:59 UTC (rev 8666) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2010-10-05 18:26:18 UTC (rev 8667) @@ -198,8 +198,8 @@ */ @NotNull @Override - public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final GlobalSettings globalSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory, @NotNull final ValidatorPreferences validatorPreferences) { - return new DefaultMainControl<GameObject, MapArchObject, Archetype>(GuiFileFilters.luaFileFilter, ".lua", "Lua", 0, IGUIConstants.SPELL_FILE, IGUIConstants.SCRIPTS_DIR, errorView, this, forceReadFromFiles, globalSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, autojoinLists, mapManager, scriptModel, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, attributeRangeChecker, pluginParameterFactory, validatorPreferences); + public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final GlobalSettings globalSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory, @NotNull final ValidatorPreferences validatorPreferences) { + return new DefaultMainControl<GameObject, MapArchObject, Archetype>(GuiFileFilters.luaFileFilter, ".lua", "Lua", 0, IGUIConstants.SPELL_FILE, IGUIConstants.SCRIPTS_DIR, errorView, this, forceReadFromFiles, globalSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, autojoinLists, mapManager, scriptModel, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, pluginParameterFactory, validatorPreferences); } /** Modified: trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java 2010-10-05 17:24:59 UTC (rev 8666) +++ trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java 2010-10-05 18:26:18 UTC (rev 8667) @@ -170,11 +170,10 @@ * @param resources the resources * @param numberSpells the number spells to use * @param gameObjectSpells the game object spells to use - * @param attributeRangeChecker the attribute range checker to use * @param pluginParameterFactory the plugin parameter factory to use * @param validatorPreferences the validator preferences to use */ - public DefaultMainControl(@NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, @NotNull final String scriptName, final int spellType, @Nullable final String spellFile, @NotNull final String scriptsDir, final ErrorView errorView, @NotNull final EditorFactory<G, A, R> editorFactory, final boolean forceReadFromFiles, @NotNull final GlobalSettings globalSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final AutojoinLists<G, A, R> autojoinLists, @NotNull final AbstractMapManager<G, A, R> mapManager, @NotNull final ScriptModel<G, A, R> scriptModel, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final AbstractResources<G, A, R> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final AttributeRangeChecker<G, A, R> attributeRangeChecker, @NotNull final PluginParameterFactory<G, A, R> pluginParameterFactory, @NotNull final ValidatorPreferences validatorPreferences) { + public DefaultMainControl(@NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, @NotNull final String scriptName, final int spellType, @Nullable final String spellFile, @NotNull final String scriptsDir, final ErrorView errorView, @NotNull final EditorFactory<G, A, R> editorFactory, final boolean forceReadFromFiles, @NotNull final GlobalSettings globalSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final AutojoinLists<G, A, R> autojoinLists, @NotNull final AbstractMapManager<G, A, R> mapManager, @NotNull final ScriptModel<G, A, R> scriptModel, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final AbstractResources<G, A, R> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final PluginParameterFactory<G, A, R> pluginParameterFactory, @NotNull final ValidatorPreferences validatorPreferences) { final XmlHelper xmlHelper; try { xmlHelper = new XmlHelper(); @@ -183,6 +182,7 @@ //noinspection ThrowInsideCatchBlockWhichIgnoresCaughtException throw new MissingResourceException("Cannot create XML parser: " + ex.getMessage(), null, null); } + final AttributeRangeChecker<G, A, R> attributeRangeChecker = new AttributeRangeChecker<G, A, R>(validatorPreferences); final GameObjectMatchersParser gameObjectMatchersParser = new GameObjectMatchersParser(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath()); try { final URL url = IOUtils.getResource(globalSettings.getConfigurationDirectory(), "GameObjectMatchers.xml"); Modified: trunk/src/app/net/sf/gridarta/maincontrol/EditorFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/EditorFactory.java 2010-10-05 17:24:59 UTC (rev 8666) +++ trunk/src/app/net/sf/gridarta/maincontrol/EditorFactory.java 2010-10-05 18:26:18 UTC (rev 8667) @@ -110,13 +110,12 @@ * @param resources the resources * @param numberSpells the number spells to use * @param gameObjectSpells the game object spells to use - * @param attributeRangeChecker the attribute range checker to use * @param pluginParameterFactory the plugin parameter factory to use * @param validatorPreferences the validator preferences to use * @return the new instance */ @NotNull - DefaultMainControl<G, A, R> newMainControl(boolean forceReadFromFiles, @NotNull ErrorView errorView, @NotNull GlobalSettings globalSettings, @NotNull ConfigSourceFactory configSourceFactory, @NotNull PathManager pathManager, @NotNull GameObjectMatchers gameObjectMatchers, @NotNull GameObjectFactory<G, A, R> gameObjectFactory, @NotNull ArchetypeTypeSet archetypeTypeSet, @NotNull ArchetypeSet<G, A, R> archetypeSet, @NotNull ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull AutojoinLists<G, A, R> autojoinLists, @NotNull AbstractMapManager<G, A, R> mapManager, @NotNull ScriptModel<G, A, R> scriptModel, @NotNull DelegatingMapValidator<G, A, R> validators, @NotNull ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull AbstractResources<G, A, R> resources, @NotNull Spells<NumberSpell> numberSpells, @NotNull Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull AttributeRangeChecker<G, A, R> attributeRangeChecker, @NotNull PluginParameterFactory<G, A, R> pluginParameterFactory, @NotNull final ValidatorPreferences validatorPreferences); + DefaultMainControl<G, A, R> newMainControl(boolean forceReadFromFiles, @NotNull ErrorView errorView, @NotNull GlobalSettings globalSettings, @NotNull ConfigSourceFactory configSourceFactory, @NotNull PathManager pathManager, @NotNull GameObjectMatchers gameObjectMatchers, @NotNull GameObjectFactory<G, A, R> gameObjectFactory, @NotNull ArchetypeTypeSet archetypeTypeSet, @NotNull ArchetypeSet<G, A, R> archetypeSet, @NotNull ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull AutojoinLists<G, A, R> autojoinLists, @NotNull AbstractMapManager<G, A, R> mapManager, @NotNull ScriptModel<G, A, R> scriptModel, @NotNull DelegatingMapValidator<G, A, R> validators, @NotNull ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull AbstractResources<G, A, R> resources, @NotNull Spells<NumberSpell> numberSpells, @NotNull Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull PluginParameterFactory<G, A, R> pluginParameterFactory, @NotNull final ValidatorPreferences validatorPreferences); /** * Returns the offset for drawing double faces. Modified: trunk/src/app/net/sf/gridarta/maincontrol/GridartaEditor.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GridartaEditor.java 2010-10-05 17:24:59 UTC (rev 8666) +++ trunk/src/app/net/sf/gridarta/maincontrol/GridartaEditor.java 2010-10-05 18:26:18 UTC (rev 8667) @@ -100,7 +100,6 @@ import net.sf.gridarta.validation.DefaultValidatorPreferences; import net.sf.gridarta.validation.DelegatingMapValidator; import net.sf.gridarta.validation.ValidatorPreferences; -import net.sf.gridarta.validation.checks.AttributeRangeChecker; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; import org.apache.log4j.Category; @@ -271,9 +270,8 @@ final AbstractResources<G, A, R> resources = editorFactory.newResources(gameObjectParser, archetypeSet, archetypeParser, mapViewSettings, faceObjects, animationObjects, archFaceProvider, faceObjectProviders); final Spells<NumberSpell> numberSpells = new Spells<NumberSpell>(); final Spells<GameObjectSpell<G, A, R>> gameObjectSpells = new Spells<GameObjectSpell<G, A, R>>(); - final AttributeRangeChecker<G, A, R> attributeRangeChecker = new AttributeRangeChecker<G, A, R>(validatorPreferences); final PluginParameterFactory<G, A, R> pluginParameterFactory = new PluginParameterFactory<G, A, R>(archetypeSet, mapManager, defaultFilterList); - final DefaultMainControl<G, A, R> mainControl = editorFactory.newMainControl(mode == GridartaRunMode.COLLECT_ARCHES, errorView, globalSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, autojoinLists, mapManager, scriptModel, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, attributeRangeChecker, pluginParameterFactory, validatorPreferences); + final DefaultMainControl<G, A, R> mainControl = editorFactory.newMainControl(mode == GridartaRunMode.COLLECT_ARCHES, errorView, globalSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, autojoinLists, mapManager, scriptModel, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, pluginParameterFactory, validatorPreferences); final NamedFilter defaultNamedFilterList = new NamedFilter(gameObjectMatchers.getFilters()); final FilterControl<G, A, R> filterControl = new DefaultFilterControl<G, A, R>(defaultNamedFilterList); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-10-06 18:39:23
|
Revision: 8668 http://gridarta.svn.sourceforge.net/gridarta/?rev=8668&view=rev Author: akirschbaum Date: 2010-10-06 18:39:14 +0000 (Wed, 06 Oct 2010) Log Message: ----------- Define and configure validators from "valdator.*" entries in messages.properties. Document available validators in validators.xhtml. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages.properties trunk/crossfire/ChangeLog trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/messages.properties trunk/daimonin/ChangeLog trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/messages.properties trunk/model/src/app/net/sf/gridarta/model/errorview/ErrorViewCategory.java trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java trunk/src/app/net/sf/gridarta/validation/DelegatingMapValidator.java trunk/src/app/net/sf/gridarta/validation/checks/ShopSquareChecker.java trunk/src/app/net/sf/gridarta/validation/checks/SquareWithoutFloorChecker.java Added Paths: ----------- trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/validation/ trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/validation/checks/ trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/validation/checks/ValidatorFactoryTest.java trunk/src/app/net/sf/gridarta/validation/NoSuchValidatorException.java trunk/src/app/net/sf/gridarta/validation/ValidatorFactory.java trunk/src/doc/ref/validators.xhtml trunk/src/test/net/sf/gridarta/validation/ValidationUtils.java trunk/src/test/net/sf/gridarta/validation/ValidatorFactoryTest.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-10-05 18:26:18 UTC (rev 8667) +++ trunk/atrinik/ChangeLog 2010-10-06 18:39:14 UTC (rev 8668) @@ -1,3 +1,9 @@ +2010-10-06 Andreas Kirschbaum + + * Define and configure validators from "valdator.*" entries in + messages.properties. Document available validators in + validators.xhtml. + 2010-10-05 Andreas Kirschbaum * Use the def_arch's archetype name as the artifact's name for Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2010-10-05 18:26:18 UTC (rev 8667) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2010-10-06 18:39:14 UTC (rev 8668) @@ -101,20 +101,7 @@ import net.sf.gridarta.validation.DelegatingMapValidator; import net.sf.gridarta.validation.ValidatorPreferences; import net.sf.gridarta.validation.checks.AttributeRangeChecker; -import net.sf.gridarta.validation.checks.BlockedMobOrSpawnPointChecker; -import net.sf.gridarta.validation.checks.BlockedSpawnPointChecker; -import net.sf.gridarta.validation.checks.ConnectedInsideContainerChecker; -import net.sf.gridarta.validation.checks.ConnectedPickableChecker; -import net.sf.gridarta.validation.checks.DoubleLayerChecker; -import net.sf.gridarta.validation.checks.EmptySpawnPointChecker; -import net.sf.gridarta.validation.checks.ExitChecker; import net.sf.gridarta.validation.checks.InvalidCheckException; -import net.sf.gridarta.validation.checks.MapDifficultyChecker; -import net.sf.gridarta.validation.checks.MobOutsideSpawnPointChecker; -import net.sf.gridarta.validation.checks.TilePathsChecker; -import net.sf.gridarta.validation.checks.UndefinedArchetypeChecker; -import net.sf.gridarta.validation.checks.UndefinedFaceChecker; -import net.sf.gridarta.validation.checks.UnsetSlayingChecker; import net.sf.gridarta.var.atrinik.IGUIConstants; import net.sf.gridarta.var.atrinik.gui.map.renderer.DefaultRendererFactory; import net.sf.gridarta.var.atrinik.gui.mappropertiesdialog.DefaultMapPropertiesDialogFactory; @@ -363,7 +350,6 @@ addAttributeRangeChecker(attributeRangeChecker, combatValuesObjectsMatcher, "resist_paralyze", "paralyze (effect)", Integer.MIN_VALUE, 100); addAttributeRangeChecker(attributeRangeChecker, combatValuesObjectsMatcher, "resist_snare", "snare (effect)", Integer.MIN_VALUE, 100); } - mapValidators.addValidators(new BlockedSpawnPointChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, Archetype.TYPE_SPAWN_POINT), new BlockedMobOrSpawnPointChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, Archetype.TYPE_MOB), new ConnectedInsideContainerChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new ConnectedPickableChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), attributeRangeChecker, new DoubleLayerChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new EmptySpawnPointChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, Archetype.TYPE_SPAWN_POINT), new ExitChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, globalSettings, Archetype.TYPE_EXIT), new MapDifficultyChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new MobOutsideSpawnPointChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, Archetype.TYPE_MOB), new TilePathsChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, globalSettings, 8), new UndefinedArchetypeChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new UndefinedFaceChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new UnsetSlayingChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_DETECTOR, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER)); } private static void addAttributeRangeChecker(@NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final GameObjectMatcher matcher, @NotNull final String name, @NotNull final String displayName, final int minValue, final int maxValue) { Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages.properties =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages.properties 2010-10-05 18:26:18 UTC (rev 8667) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages.properties 2010-10-06 18:39:14 UTC (rev 8668) @@ -154,3 +154,21 @@ # Actions not to be shown in Configure Shortcuts shortcutsIgnoreActions=smoothing \ scriptEditClose scriptEditCloseAll scriptEditCopy scriptEditCut scriptEditFind scriptEditFindAgain scriptEditNewScript scriptEditOpen scriptEditPaste scriptEditRedo scriptEditReplace scriptEditSave scriptEditSaveAs scriptEditUndo + + +########################### +# Map Validator definitions +validator.0=net.sf.gridarta.validation.checks.ConnectionChecker system_connection_source system_connection_sink system_connection_sink2 +validator.1=net.sf.gridarta.validation.checks.BlockedSpawnPointChecker 81 +validator.2=net.sf.gridarta.validation.checks.BlockedMobOrSpawnPointChecker 80 +validator.3=net.sf.gridarta.validation.checks.ConnectedInsideContainerChecker +validator.4=net.sf.gridarta.validation.checks.ConnectedPickableChecker +validator.5=net.sf.gridarta.validation.checks.DoubleLayerChecker +validator.6=net.sf.gridarta.validation.checks.EmptySpawnPointChecker 81 +validator.7=net.sf.gridarta.validation.checks.ExitChecker 66 +validator.8=net.sf.gridarta.validation.checks.MapDifficultyChecker +validator.9=net.sf.gridarta.validation.checks.MobOutsideSpawnPointChecker 80 +validator.10=net.sf.gridarta.validation.checks.TilePathsChecker 8 +validator.11=net.sf.gridarta.validation.checks.UndefinedArchetypeChecker +validator.12=net.sf.gridarta.validation.checks.UndefinedFaceChecker +validator.13=net.sf.gridarta.validation.checks.UnsetSlayingChecker 20,21,51,55,64,122 Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-10-05 18:26:18 UTC (rev 8667) +++ trunk/crossfire/ChangeLog 2010-10-06 18:39:14 UTC (rev 8668) @@ -1,3 +1,9 @@ +2010-10-06 Andreas Kirschbaum + + * Define and configure validators from "valdator.*" entries in + messages.properties. Document available validators in + validators.xhtml. + 2010-09-25 Andreas Kirschbaum * Correctly update archetypes when undoing/redoing operations Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2010-10-05 18:26:18 UTC (rev 8667) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2010-10-06 18:39:14 UTC (rev 8668) @@ -96,16 +96,7 @@ import net.sf.gridarta.validation.DelegatingMapValidator; import net.sf.gridarta.validation.ValidatorPreferences; import net.sf.gridarta.validation.checks.AttributeRangeChecker; -import net.sf.gridarta.validation.checks.ConnectedInsideContainerChecker; -import net.sf.gridarta.validation.checks.ConnectedPickableChecker; -import net.sf.gridarta.validation.checks.CustomTypeChecker; -import net.sf.gridarta.validation.checks.ExitChecker; import net.sf.gridarta.validation.checks.InvalidCheckException; -import net.sf.gridarta.validation.checks.MapDifficultyChecker; -import net.sf.gridarta.validation.checks.TilePathsChecker; -import net.sf.gridarta.validation.checks.UndefinedArchetypeChecker; -import net.sf.gridarta.validation.checks.UndefinedFaceChecker; -import net.sf.gridarta.validation.checks.UnsetSlayingChecker; import net.sf.gridarta.var.crossfire.IGUIConstants; import net.sf.gridarta.var.crossfire.gui.map.renderer.DefaultRendererFactory; import net.sf.gridarta.var.crossfire.gui.mappropertiesdialog.DefaultMapPropertiesDialogFactory; @@ -125,7 +116,6 @@ import net.sf.gridarta.var.crossfire.model.settings.DefaultGlobalSettings; import net.sf.gridarta.var.crossfire.model.smoothface.SmoothFaces; import net.sf.gridarta.var.crossfire.resource.DefaultResources; -import net.sf.gridarta.var.crossfire.validation.checks.NonAbsoluteExitPathChecker; import net.sf.japi.swing.prefs.PreferencesGroup; import org.apache.log4j.Category; import org.apache.log4j.Logger; @@ -276,16 +266,6 @@ log.warn(ex.getMessage() + " for monster checker"); } } - final CustomTypeChecker<GameObject, MapArchObject, Archetype> customTypeChecker = new CustomTypeChecker<GameObject, MapArchObject, Archetype>(validatorPreferences); - customTypeChecker.addIgnore(Archetype.TYPE_MISC, Archetype.TYPE_WALL); - customTypeChecker.addIgnore(Archetype.TYPE_MISC, Archetype.TYPE_FLOOR); - final UnsetSlayingChecker<GameObject, MapArchObject, Archetype> unsetSlayingChecker = new UnsetSlayingChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER); - unsetSlayingChecker.addAllowedValue("player"); - mapValidators.addValidators(attributeRangeChecker, new ConnectedInsideContainerChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new ConnectedPickableChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), customTypeChecker, new ExitChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, globalSettings, Archetype.TYPE_EXIT), new MapDifficultyChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new TilePathsChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, globalSettings, 4), new UndefinedFaceChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new UndefinedArchetypeChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), unsetSlayingChecker); - final GameObjectMatcher exitMatcher = gameObjectMatchers.getMatcherWarn(errorViewCollector, "system_exit"); - if (exitMatcher != null) { - mapValidators.addValidator(new NonAbsoluteExitPathChecker(validatorPreferences, exitMatcher)); - } } /** Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/messages.properties =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/messages.properties 2010-10-05 18:26:18 UTC (rev 8667) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/messages.properties 2010-10-06 18:39:14 UTC (rev 8668) @@ -135,3 +135,18 @@ # Actions not to be shown in Configure Shortcuts shortcutsIgnoreActions=doubleFaces cleanCompletelyBlockedSquares collectSpells \ scriptEditClose scriptEditCloseAll scriptEditCopy scriptEditCut scriptEditFind scriptEditFindAgain scriptEditNewScript scriptEditOpen scriptEditPaste scriptEditRedo scriptEditReplace scriptEditSave scriptEditSaveAs scriptEditUndo + + +########################### +# Map Validator definitions +validator.0=net.sf.gridarta.validation.checks.ConnectionChecker system_connection_source system_connection_sink system_connection_sink2 +validator.1=net.sf.gridarta.var.crossfire.validation.checks.NonAbsoluteExitPathChecker system_exit +validator.2=net.sf.gridarta.validation.checks.ConnectedInsideContainerChecker +validator.3=net.sf.gridarta.validation.checks.ConnectedPickableChecker +validator.4=net.sf.gridarta.validation.checks.ExitChecker 66 +validator.5=net.sf.gridarta.validation.checks.MapDifficultyChecker +validator.6=net.sf.gridarta.validation.checks.TilePathsChecker 4 +validator.7=net.sf.gridarta.validation.checks.UndefinedFaceChecker +validator.8=net.sf.gridarta.validation.checks.UndefinedArchetypeChecker +validator.9=net.sf.gridarta.validation.checks.UnsetSlayingChecker 20,21,51,52,55,64,122 player +validator.10=net.sf.gridarta.validation.checks.CustomTypeChecker 0,71 0,77 Added: trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/validation/checks/ValidatorFactoryTest.java =================================================================== --- trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/validation/checks/ValidatorFactoryTest.java (rev 0) +++ trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/validation/checks/ValidatorFactoryTest.java 2010-10-06 18:39:14 UTC (rev 8668) @@ -0,0 +1,43 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.var.crossfire.validation.checks; + +import net.sf.gridarta.validation.NoSuchValidatorException; +import net.sf.gridarta.validation.ValidationUtils; +import net.sf.gridarta.validation.ValidatorFactory; +import org.junit.Test; + +/** + * Regression tests for {@link ValidatorFactory} to create Crossfire specific + * validators. + * @author Andreas Kirschbaum + */ +public class ValidatorFactoryTest { + + /** + * Checks that {@link NonAbsoluteExitPathChecker} can be instantiated. + * @throws NoSuchValidatorException if the test fails + */ + @Test + public void testNewNonAbsoluteExitPathChecker() throws NoSuchValidatorException { + ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.var.crossfire.validation.checks.NonAbsoluteExitPathChecker matcher"); + } + +} // class ValidatorFactoryTest Property changes on: trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/validation/checks/ValidatorFactoryTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-10-05 18:26:18 UTC (rev 8667) +++ trunk/daimonin/ChangeLog 2010-10-06 18:39:14 UTC (rev 8668) @@ -1,3 +1,9 @@ +2010-10-06 Andreas Kirschbaum + + * Define and configure validators from "valdator.*" entries in + messages.properties. Document available validators in + validators.xhtml. + 2010-10-05 Andreas Kirschbaum * Use the def_arch's archetype name as the artifact's name for Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2010-10-05 18:26:18 UTC (rev 8667) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2010-10-06 18:39:14 UTC (rev 8668) @@ -22,7 +22,6 @@ import java.awt.Component; import java.io.IOException; import java.net.URL; -import java.util.regex.Pattern; import net.sf.gridarta.gui.filter.FilterControl; import net.sf.gridarta.gui.io.GuiFileFilters; import net.sf.gridarta.gui.map.mapview.DefaultMapViewFactory; @@ -102,26 +101,7 @@ import net.sf.gridarta.validation.DelegatingMapValidator; import net.sf.gridarta.validation.ValidatorPreferences; import net.sf.gridarta.validation.checks.AttributeRangeChecker; -import net.sf.gridarta.validation.checks.BlockedMobOrSpawnPointChecker; -import net.sf.gridarta.validation.checks.BlockedSpawnPointChecker; -import net.sf.gridarta.validation.checks.BlockedSquareChecker; -import net.sf.gridarta.validation.checks.ConnectedInsideContainerChecker; -import net.sf.gridarta.validation.checks.ConnectedPickableChecker; -import net.sf.gridarta.validation.checks.CustomTypeChecker; -import net.sf.gridarta.validation.checks.DoubleLayerChecker; -import net.sf.gridarta.validation.checks.DoubleTypeChecker; -import net.sf.gridarta.validation.checks.EmptySpawnPointChecker; -import net.sf.gridarta.validation.checks.ExitChecker; import net.sf.gridarta.validation.checks.InvalidCheckException; -import net.sf.gridarta.validation.checks.MapDifficultyChecker; -import net.sf.gridarta.validation.checks.MobOutsideSpawnPointChecker; -import net.sf.gridarta.validation.checks.SlayingChecker; -import net.sf.gridarta.validation.checks.SquareWithoutFloorChecker; -import net.sf.gridarta.validation.checks.SysObjectNotOnLayerZeroChecker; -import net.sf.gridarta.validation.checks.TilePathsChecker; -import net.sf.gridarta.validation.checks.UndefinedArchetypeChecker; -import net.sf.gridarta.validation.checks.UndefinedFaceChecker; -import net.sf.gridarta.validation.checks.UnsetSlayingChecker; import net.sf.gridarta.var.daimonin.IGUIConstants; import net.sf.gridarta.var.daimonin.gui.map.renderer.DefaultRendererFactory; import net.sf.gridarta.var.daimonin.gui.mappropertiesdialog.DefaultMapPropertiesDialogFactory; @@ -370,14 +350,6 @@ addAttributeRangeChecker(attributeRangeChecker, combatValuesObjectsMatcher, "resist_paralyze", "paralyze (effect)", Integer.MIN_VALUE, 100); addAttributeRangeChecker(attributeRangeChecker, combatValuesObjectsMatcher, "resist_snare", "snare (effect)", Integer.MIN_VALUE, 100); } - final CustomTypeChecker<GameObject, MapArchObject, Archetype> customTypeChecker = new CustomTypeChecker<GameObject, MapArchObject, Archetype>(validatorPreferences); - customTypeChecker.addIgnore(Archetype.TYPE_MOB, Archetype.TYPE_SPAWN_POINT_MOB, Archetype.TYPE_SPAWN_POINT); - final SlayingChecker<GameObject, MapArchObject, Archetype> slayingChecker = new SlayingChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, Pattern.compile("^[a-zA-Z_0-9/.]*$")); - final GameObjectMatcher environmentSensorMatcher = gameObjectMatchers.getMatcherWarn(errorViewCollector, "system_environment_sensor"); - if (environmentSensorMatcher != null) { - slayingChecker.addMatcher(environmentSensorMatcher, Pattern.compile("|([0-1][0-9]|2[0-3]):[0-5][0-9]-([0-1][0-9]|2[0-3]):[0-5][0-9]")); - } - mapValidators.addValidators(new BlockedSpawnPointChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, Archetype.TYPE_SPAWN_POINT), new BlockedMobOrSpawnPointChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, Archetype.TYPE_MOB), new BlockedSquareChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new ConnectedInsideContainerChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new ConnectedPickableChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), attributeRangeChecker, customTypeChecker, new DoubleTypeChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new DoubleLayerChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new EmptySpawnPointChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, Archetype.TYPE_SPAWN_POINT), new ExitChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, globalSettings, Archetype.TYPE_EXIT), new MapDifficultyChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new MobOutsideSpawnPointChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, Archetype.TYPE_MOB), new SquareWithoutFloorChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, Archetype.TYPE_FLOOR, Archetype.TYPE_SHOP_FLOOR), slayingChecker, new SysObjectNotOnLayerZeroChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new TilePathsChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, globalSettings, 8), new UndefinedArchetypeChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new UndefinedFaceChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new UnsetSlayingChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_DETECTOR, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER)); } private static void addAttributeRangeChecker(@NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final GameObjectMatcher matcher, @NotNull final String name, @NotNull final String displayName, final int minValue, final int maxValue) { Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/messages.properties =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/messages.properties 2010-10-05 18:26:18 UTC (rev 8667) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/messages.properties 2010-10-06 18:39:14 UTC (rev 8668) @@ -154,3 +154,27 @@ # Actions not to be shown in Configure Shortcuts shortcutsIgnoreActions=smoothing \ scriptEditClose scriptEditCloseAll scriptEditCopy scriptEditCut scriptEditFind scriptEditFindAgain scriptEditNewScript scriptEditOpen scriptEditPaste scriptEditRedo scriptEditReplace scriptEditSave scriptEditSaveAs scriptEditUndo + + +########################### +# Map Validator definitions +validator.0=net.sf.gridarta.validation.checks.ConnectionChecker system_connection_source system_connection_sink system_connection_sink2 +validator.1=net.sf.gridarta.validation.checks.BlockedSpawnPointChecker 81 +validator.2=net.sf.gridarta.validation.checks.BlockedMobOrSpawnPointChecker 80 +validator.3=net.sf.gridarta.validation.checks.BlockedSquareChecker +validator.4=net.sf.gridarta.validation.checks.ConnectedInsideContainerChecker +validator.5=net.sf.gridarta.validation.checks.ConnectedPickableChecker +validator.6=net.sf.gridarta.validation.checks.DoubleTypeChecker +validator.7=net.sf.gridarta.validation.checks.DoubleLayerChecker +validator.8=net.sf.gridarta.validation.checks.EmptySpawnPointChecker 81 +validator.9=net.sf.gridarta.validation.checks.ExitChecker 66 +validator.10=net.sf.gridarta.validation.checks.MapDifficultyChecker +validator.11=net.sf.gridarta.validation.checks.MobOutsideSpawnPointChecker 80 +validator.12=net.sf.gridarta.validation.checks.SquareWithoutFloorChecker 71,68 +validator.13=net.sf.gridarta.validation.checks.SysObjectNotOnLayerZeroChecker +validator.14=net.sf.gridarta.validation.checks.TilePathsChecker 8 +validator.15=net.sf.gridarta.validation.checks.UndefinedArchetypeChecker +validator.16=net.sf.gridarta.validation.checks.UndefinedFaceChecker +validator.17=net.sf.gridarta.validation.checks.UnsetSlayingChecker 20,21,51,55,64,122 +validator.18=net.sf.gridarta.validation.checks.CustomTypeChecker 80,83,81 +validator.19=net.sf.gridarta.validation.checks.SlayingChecker ^[a-zA-Z_0-9/.]*$ system_environment_sensor,|([0-1][0-9]|2[0-3]):[0-5][0-9]-([0-1][0-9]|2[0-3]):[0-5][0-9] Modified: trunk/model/src/app/net/sf/gridarta/model/errorview/ErrorViewCategory.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/errorview/ErrorViewCategory.java 2010-10-05 18:26:18 UTC (rev 8667) +++ trunk/model/src/app/net/sf/gridarta/model/errorview/ErrorViewCategory.java 2010-10-06 18:39:14 UTC (rev 8668) @@ -69,6 +69,8 @@ GAMEOBJECTMATCHERS_FILE_INVALID("Game object matcher definitions file cannot be read"), + MAP_VALIDATOR_ENTRY_INVALID("Invalid map validator"), + PICKMAPS_DIR_INVALID("Invalid pickmaps directory"), PICKMAPS_FILE_INVALID("Pickmap file cannot be read"), Modified: trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java 2010-10-05 18:26:18 UTC (rev 8667) +++ trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java 2010-10-06 18:39:14 UTC (rev 8668) @@ -100,11 +100,14 @@ import net.sf.gridarta.utils.SystemIcons; import net.sf.gridarta.utils.XmlHelper; import net.sf.gridarta.validation.DelegatingMapValidator; +import net.sf.gridarta.validation.NoSuchValidatorException; +import net.sf.gridarta.validation.ValidatorFactory; import net.sf.gridarta.validation.ValidatorPreferences; import net.sf.gridarta.validation.checks.AttributeRangeChecker; -import net.sf.gridarta.validation.checks.ConnectionChecker; import net.sf.gridarta.validation.checks.PaidItemShopSquareChecker; import net.sf.gridarta.validation.checks.ShopSquareChecker; +import net.sf.japi.swing.action.ActionBuilder; +import net.sf.japi.swing.action.ActionBuilderFactory; import org.apache.log4j.Category; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; @@ -192,17 +195,11 @@ } catch (final IOException ex) { gameObjectMatchersErrorViewCollector.addWarning(ErrorViewCategory.GAMEOBJECTMATCHERS_FILE_INVALID, ex.getMessage()); } + + final ValidatorFactory validatorFactory = new ValidatorFactory(validatorPreferences, gameObjectMatchers, globalSettings); + loadValidators(validators, validatorFactory, errorView); editorFactory.initMapValidators(validators, gameObjectMatchersErrorViewCollector, globalSettings, gameObjectMatchers, attributeRangeChecker, validatorPreferences); - final GameObjectMatcher connectionSourceMatcher = gameObjectMatchers.getMatcherWarn(gameObjectMatchersErrorViewCollector, "system_connection_source"); - if (connectionSourceMatcher != null) { - final GameObjectMatcher connectionSinkMatcher = gameObjectMatchers.getMatcherWarn(gameObjectMatchersErrorViewCollector, "system_connection_sink"); - if (connectionSinkMatcher != null) { - final GameObjectMatcher connectionSink2Matcher = gameObjectMatchers.getMatcherWarn(gameObjectMatchersErrorViewCollector, "system_connection_sink2"); - if (connectionSink2Matcher != null) { - validators.addValidator(new ConnectionChecker<G, A, R>(validatorPreferences, connectionSourceMatcher, connectionSinkMatcher, connectionSink2Matcher)); - } - } - } + validators.addValidator(attributeRangeChecker); } catch (final FileNotFoundException ex) { errorView.addWarning(ErrorViewCategory.GAMEOBJECTMATCHERS_FILE_INVALID, "GameObjectMatchers.xml: " + ex.getMessage()); } @@ -306,6 +303,33 @@ } /** + * Creates map validators from preferences. + * @param validators the validators to add the newly created validators to + * @param validatorFactory the validator factory for creating new + * validators + * @param errorView the error view to add error messages to + */ + private void loadValidators(@NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final ValidatorFactory validatorFactory, @NotNull final ErrorView errorView) { + final ActionBuilder actionBuilder = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); + int id = 0; + for (; ;) { + final String spec = actionBuilder.getString("validator." + id); + if (spec == null) { + break; + } + try { + validators.addValidator(validatorFactory.newValidator(spec)); + } catch (final NoSuchValidatorException ex) { + errorView.addWarning(ErrorViewCategory.MAP_VALIDATOR_ENTRY_INVALID, id, ex.getMessage()); + } + id++; + } + if (log.isInfoEnabled()) { + log.info("Loaded " + id + " map validators."); + } + } + + /** * Creates a new {@link GUIMainControl} instance. * @param scriptFileFilter the file filter for script files * @param scriptExtension the file extension for script files Modified: trunk/src/app/net/sf/gridarta/validation/DelegatingMapValidator.java =================================================================== --- trunk/src/app/net/sf/gridarta/validation/DelegatingMapValidator.java 2010-10-05 18:26:18 UTC (rev 8667) +++ trunk/src/app/net/sf/gridarta/validation/DelegatingMapValidator.java 2010-10-06 18:39:14 UTC (rev 8668) @@ -145,17 +145,6 @@ } /** - * Add Validators that might to be queried. Convenience method to loop - * around {@link #addValidator(Validator)}. - * @param validators map validators to add - */ - public void addValidators(@NotNull final Validator... validators) { - for (final Validator validator : validators) { - addValidator(validator); - } - } - - /** * {@inheritDoc} */ @NotNull Added: trunk/src/app/net/sf/gridarta/validation/NoSuchValidatorException.java =================================================================== --- trunk/src/app/net/sf/gridarta/validation/NoSuchValidatorException.java (rev 0) +++ trunk/src/app/net/sf/gridarta/validation/NoSuchValidatorException.java 2010-10-06 18:39:14 UTC (rev 8668) @@ -0,0 +1,52 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.validation; + +import org.jetbrains.annotations.NotNull; + +/** + * Exception thrown if a map validator cannot be created. + * @author Andreas Kirschbaum + */ +public class NoSuchValidatorException extends Exception { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Creates a new instance. + * @param reason the reason why the map validator could not be created + */ + public NoSuchValidatorException(@NotNull final String reason) { + super(reason); + } + + /** + * Creates a new instance. + * @param reason the reason why the map validator could not be created + * @param cause the cause + */ + public NoSuchValidatorException(@NotNull final String reason, final Throwable cause) { + super(reason, cause); + } + +} // class NoSuchValidatorException Property changes on: trunk/src/app/net/sf/gridarta/validation/NoSuchValidatorException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/validation/ValidatorFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/validation/ValidatorFactory.java (rev 0) +++ trunk/src/app/net/sf/gridarta/validation/ValidatorFactory.java 2010-10-06 18:39:14 UTC (rev 8668) @@ -0,0 +1,281 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.validation; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.regex.Pattern; +import java.util.regex.PatternSyntaxException; +import net.sf.gridarta.model.match.GameObjectMatcher; +import net.sf.gridarta.model.match.GameObjectMatchers; +import net.sf.gridarta.model.settings.GlobalSettings; +import net.sf.gridarta.utils.StringUtils; +import net.sf.gridarta.validation.checks.CustomTypeChecker; +import net.sf.gridarta.validation.checks.SlayingChecker; +import net.sf.gridarta.validation.checks.UnsetSlayingChecker; +import org.jetbrains.annotations.NotNull; + +/** + * A factory for creating {@link Validator} instances from string + * representation. The string representation consists of a class name (which + * must implement {@link Validator}) and optional constructor arguments. + * @author Andreas Kirschbaum + */ +public class ValidatorFactory { + + /** + * The {@link ValidatorPreferences} to pass to the newly created {@link + * Validator} instances. + */ + @NotNull + private final ValidatorPreferences validatorPreferences; + + /** + * The {@link GameObjectMatchers} for looking up {@link GameObjectMatcher} + * instances from string representation. + */ + @NotNull + private final GameObjectMatchers gameObjectMatchers; + + /** + * The {@link GlobalSettings} to pass to the newly created {@link Validator} + * instances. + */ + @NotNull + private final GlobalSettings globalSettings; + + /** + * Creates a new instance. + * @param validatorPreferences the validator preferences to pass to the + * newly created validator instances + * @param gameObjectMatchers the game object matchers for looking up game + * object matcher instances from string representation + * @param globalSettings the global settings to pass to the newly created + * validator instances + */ + public ValidatorFactory(@NotNull final ValidatorPreferences validatorPreferences, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GlobalSettings globalSettings) { + this.validatorPreferences = validatorPreferences; + this.gameObjectMatchers = gameObjectMatchers; + this.globalSettings = globalSettings; + } + + /** + * Creates a new {@link Validator} instance from string representation. + * @param spec the string representation + * @return the validator instance + * @throws NoSuchValidatorException if the validator cannot be created + */ + @NotNull + public Validator newValidator(@NotNull final String spec) throws NoSuchValidatorException { + final String[] args = StringUtils.PATTERN_WHITESPACE.split(spec); + final Class<?> tmpClass; + //noinspection ErrorNotRethrown + try { + tmpClass = Class.forName(args[0]); + } catch (final ClassNotFoundException ex) { + throw new NoSuchValidatorException("class " + args[0] + " does not exist", ex); + } catch (final ExceptionInInitializerError ex) { + throw new NoSuchValidatorException("class " + args[0] + " does not exist", ex); + } catch (final LinkageError ex) { + throw new NoSuchValidatorException("class " + args[0] + " does not exist", ex); + } + final Class<? extends Validator> classValidator; + try { + classValidator = tmpClass.asSubclass(Validator.class); + } catch (final ClassCastException ex) { + throw new NoSuchValidatorException("class " + args[0] + " does not exist", ex); + } + final Constructor<?>[] constructors = classValidator.getConstructors(); + if (constructors.length == 0) { + throw new NoSuchValidatorException("class " + args[0] + " has no public constructors"); + } else if (constructors.length > 1) { + throw new NoSuchValidatorException("class " + args[0] + " has more than one public constructor"); + } + @SuppressWarnings({ "unchecked" }) final Constructor<? extends Validator> constructor = (Constructor<? extends Validator>) constructors[0]; + final Class<?>[] constructorParameterTypes = constructor.getParameterTypes(); + final Object[] constructorArguments = new Object[constructorParameterTypes.length]; + int pos = 1; + for (int i = 0; i < constructorParameterTypes.length; i++) { + final Class<?> constructorParameterType = constructorParameterTypes[i]; + if (constructorParameterType == ValidatorPreferences.class) { + constructorArguments[i] = validatorPreferences; + } else if (constructorParameterType == GlobalSettings.class) { + constructorArguments[i] = globalSettings; + } else { + if (pos >= args.length) { + throw new NoSuchValidatorException("missing argument in '" + spec + "'"); + } + final String arg = args[pos++]; + if (constructorParameterType == Integer[].class) { + constructorArguments[i] = createIntegerArray(arg); + } else if (constructorParameterType == GameObjectMatcher.class) { + constructorArguments[i] = createGameObjectMatcher(arg); + } else if (constructorParameterType == int.class) { + constructorArguments[i] = createInteger(arg); + } else if (constructorParameterType == Pattern.class) { + constructorArguments[i] = createPattern(arg); + } else { + throw new NoSuchValidatorException("class " + args[0] + "'s constructor requires a parameter of type " + constructorParameterType.getName() + "; this type is not supported"); + } + } + } + final Validator validator; + //noinspection ErrorNotRethrown + try { + validator = constructor.newInstance(constructorArguments); + } catch (final ExceptionInInitializerError ex) { + throw new NoSuchValidatorException("cannot initialize class " + args[0], ex); + } catch (final InstantiationException ex) { + throw new NoSuchValidatorException("class " + args[0] + " is abstract", ex); + } catch (final IllegalAccessException ex) { + throw new AssertionError(ex); + } catch (final IllegalArgumentException ex) { + throw new AssertionError(ex); + } catch (final InvocationTargetException ex) { + throw new NoSuchValidatorException("cannot instantiate class " + args[0], ex); + } + if (pos < args.length) { + if (classValidator == UnsetSlayingChecker.class) { + final UnsetSlayingChecker<?, ?, ?> unsetSlayingChecker = (UnsetSlayingChecker<?, ?, ?>) validator; + do { + unsetSlayingChecker.addAllowedValue(args[pos]); + pos++; + } while (pos < args.length); + } else if (classValidator == CustomTypeChecker.class) { + final CustomTypeChecker<?, ?, ?> customTypeChecker = (CustomTypeChecker<?, ?, ?>) validator; + do { + final String[] tmp = args[pos].split(",", -1); + if (tmp.length != 2 && tmp.length != 3) { + throw new NoSuchValidatorException("invalid from,to or from,to,env type: " + args[pos]); + } + final int fromType; + try { + fromType = Integer.parseInt(tmp[0]); + } catch (final NumberFormatException ex) { + throw new NoSuchValidatorException("invalid from type: " + args[pos], ex); + } + final int toType; + try { + toType = Integer.parseInt(tmp[1]); + } catch (final NumberFormatException ex) { + throw new NoSuchValidatorException("invalid to type: " + args[pos], ex); + } + if (tmp.length == 2) { + customTypeChecker.addIgnore(fromType, toType); + } else { + final int envType; + try { + envType = Integer.parseInt(tmp[1]); + } catch (final NumberFormatException ex) { + throw new NoSuchValidatorException("invalid env type: " + args[pos], ex); + } + customTypeChecker.addIgnore(fromType, toType, envType); + } + pos++; + } while (pos < args.length); + } else if (classValidator == SlayingChecker.class) { + final SlayingChecker<?, ?, ?> slayingChecker = (SlayingChecker<?, ?, ?>) validator; + do { + final String[] tmp = args[pos].split(",", 2); + if (tmp.length != 2) { + throw new NoSuchValidatorException("invalid matcher,pattern: " + args[pos]); + } + final GameObjectMatcher matcher = createGameObjectMatcher(tmp[0]); + final Pattern pattern = createPattern(tmp[1]); + slayingChecker.addMatcher(matcher, pattern); + pos++; + } while (pos < args.length); + } else { + throw new NoSuchValidatorException("excess arguments for '" + spec + "'"); + } + } + return validator; + } + + /** + * Creates an <code>Integer[]</code> instance from string representation. + * @param arg the string representation + * @return the integer array instance + * @throws NoSuchValidatorException if the string representation is + * incorrect + */ + @NotNull + private static Integer[] createIntegerArray(@NotNull final String arg) throws NoSuchValidatorException { + final String[] tmp = arg.split(",", -1); + final Integer[] result = new Integer[tmp.length]; + for (int i = 0; i < tmp.length; i++) { + try { + result[i] = Integer.parseInt(tmp[i]); + } catch (final NumberFormatException ex) { + throw new NoSuchValidatorException("not a number: " + tmp[i], ex); + } + } + return result; + } + + /** + * Creates a {@link GameObjectMatcher} instance from string representation. + * @param arg the string representation + * @return the game object matcher instance + * @throws NoSuchValidatorException if the string representation is + * incorrect + */ + @NotNull + private GameObjectMatcher createGameObjectMatcher(@NotNull final String arg) throws NoSuchValidatorException { + final GameObjectMatcher gameObjectMatcher = gameObjectMatchers.getMatcher(arg); + if (gameObjectMatcher == null) { + throw new NoSuchValidatorException("undefined game object matcher: " + arg); + } + return gameObjectMatcher; + } + + /** + * Creates an <code>Integer</code> instance from string representation. + * @param arg the string representation + * @return the integer instance + * @throws NoSuchValidatorException if the string representation is + * incorrect + */ + @NotNull + private static Integer createInteger(@NotNull final String arg) throws NoSuchValidatorException { + try { + return Integer.parseInt(arg); + } catch (final NumberFormatException ex) { + throw new NoSuchValidatorException("invalid number: " + arg, ex); + } + } + + /** + * Creates an <code>Integer</code> instance from string representation. + * @param arg the string representation + * @return the integer instance + * @throws NoSuchValidatorException if the string representation is + * incorrect + */ + @NotNull + private static Pattern createPattern(@NotNull final String arg) throws NoSuchValidatorException { + try { + return Pattern.compile(arg); + } catch (final PatternSyntaxException ex) { + throw new NoSuchValidatorException("invalid pattern: " + arg, ex); + } + } + +} // class ValidatorFactory Property changes on: trunk/src/app/net/sf/gridarta/validation/ValidatorFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/validation/checks/ShopSquareChecker.java =================================================================== --- trunk/src/app/net/sf/gridarta/validation/checks/ShopSquareChecker.java 2010-10-05 18:26:18 UTC (rev 8667) +++ trunk/src/app/net/sf/gridarta/validation/checks/ShopSquareChecker.java 2010-10-06 18:39:14 UTC (rev 8668) @@ -32,8 +32,7 @@ /** * A {@link net.sf.gridarta.validation.MapValidator} to detect shop squares - * which allow magic or prayers, or which have adjacent squares that allow magic - * or prayers. + * which allow magic or prayers. * @author Andreas Kirschbaum */ public class ShopSquareChecker<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractShopSquareChecker<G, A, R> { Modified: trunk/src/app/net/sf/gridarta/validation/checks/SquareWithoutFloorChecker.java =================================================================== --- trunk/src/app/net/sf/gridarta/validation/checks/SquareWithoutFloorChecker.java 2010-10-05 18:26:18 UTC (rev 8667) +++ trunk/src/app/net/sf/gridarta/validation/checks/SquareWithoutFloorChecker.java 2010-10-06 18:39:14 UTC (rev 8668) @@ -61,16 +61,13 @@ */ @Override public void validateSquare(@NotNull final MapSquare<G, A, R> mapSquare, @NotNull final ErrorCollector<G, A, R> errorCollector) { - boolean floorFound = false; for (final BaseObject<G, A, R, ?> gameObject : mapSquare) { if (typeNumbers.contains(gameObject.getTypeNo())) { - floorFound = true; - break; + return; } } - if (!floorFound) { - errorCollector.collect(new SquareWithoutFloorError<G, A, R>(mapSquare)); - } + + errorCollector.collect(new SquareWithoutFloorError<G, A, R>(mapSquare)); } } // class SquareWithoutFloorChecker Added: trunk/src/doc/ref/validators.xhtml =================================================================== --- trunk/src/doc/ref/validators.xhtml (rev 0) +++ trunk/src/doc/ref/validators.xhtml 2010-10-06 18:39:14 UTC (rev 8668) @@ -0,0 +1,299 @@ +<?xml version="1.0" encoding="utf-8"?><!-- + ~ Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + ~ Copyright (C) 2000-2010 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. + --> + +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" + "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de"> +<head> + <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8"/> + <meta name="Date" content="$Date$"/> + <title>Validators</title> +</head> +<body> +<h1>Overview</h1> + +<p>This page explains "validators". Validators check for problems in + maps. There are three types of validators:</p> + +<ul> + <li>game object validators: these validators check single game objects.</li> + <li>square validators: these validators check problems related to a single + map square. They process all game objects on the map square. + </li> + <li>map validators: these validators check problems related to game objects + located on different map squares (on a single map) or related to map + attributes. + </li> +</ul> + +<h1>Reference</h1> + +<p>Map validators are defined in the editor specific messages.properties + file.</p> + +<p>A validator is defined by the key "validator.<id>". The first + validator uses <id> 0; all following validators use increasing + numbers. Duplicate numbers are invalid (but not detected and therefore no + warning message occurs; one of these definitions is ignored). Definitions + following a missing are ignored (and also not detected).</p> + +<p>The value for the keys are: <code><class name> <optional parameters></code>. +</p> + +<p><class name> is the Java class name that implements the validator; it + must be a subclass of <code>net.sf.gridarta.validation.Validator</code>.</p> + +<p><optional parameters" are parameters for the validator. Acceptable + values depend on the class name.</p> + +<p>The following sections describe all validators defined by Gridarta.</p> + +<h2>net.sf.gridarta.validation.checks.AttributeRangeChecker</h2> + +<p>This game object validator is used internally by Gridarta. Explicit + instantiation is not useful.</p> + +<h2>net.sf.gridarta.validation.checks.BlockedMobOrSpawnPointChecker type...</h2> + +<p>This square validator checks that mobs or spawn points aren't on blocked + squares. "type..." is a comma separated list of game object types + to check.</p> + +<p>A square is considered blocked if at least one game object on that square as + the attribute "no_pass" set to a non-zero value.</p> + +<h2>net.sf.gridarta.validation.checks.BlockedSpawnPointChecker type...</h2> + +<p>This map validator checks that spawn points aren't completely blocked. "type..." + is a comma separated list of game object types to check.</p> + +<p>A spawn point (an object that has one of the given types) may place a new mob + on some map squares around itself. The number of map squares to check is + given in the spawn point's "last_heal" attribute. The value zero + means only the spawn point's square. The value 1 means the spawn point and + the map square directly north of it. Higher values add more map squares + clockwise.</p> + +<p>A square is considered blocked if at least one game object on that square as + the attribute "no_pass" set to a non-zero value.</p> + +<h2>net.sf.gridarta.validation.checks.ConnectedInsideContainerChecker</h2> + +<p>A game object validator that checks for game objects having a non-empty + "connected" attribute and that are in the inventory of another + game object.</p> + +<h2>net.sf.gridarta.validation.checks.ConnectedPickableChecker</h2> + +<p>A game object validator that checks for game objects having a non-empty + "connected" attribute and that are "no_pick 0".</p> + +<h2>net.sf.gridarta.validation.checks.ConnectionChecker source_matcher + sink_matcher sink2_matcher</h2> + +<p>A map validator that checks for valid "connected" attributes:</p> + +<ul> + <li>A game object defines the "connected" attribute but is not + supposed to do so. + </li> + <li>A specific " connected" value appears only in connection + sources but in no connection sinks. These connections are not useful + because they have no effect when triggered. + </li> + <li>A specific " connected" value appears only in connection sinks + but in no connection sources. These connections are not useful because + they cannot be triggered. + </li> +</ul> + +<p>A game object is considered a connection source if the game object matcher + "source_matcher" matches the game object.</p> + +<p>A game object is considered a connection sink if either of the game object + matchers "sink_matcher" or "sink2_matcher" matches the + game object.</p> + +<p>A game object is not supposed to define a "connected" attribute if + it is neither a connection source nor a connection sink.</p> + +<h2>net.sf.gridarta.validation.checks.CustomTypeChecker from,to[,env]</h2> + +<p>A game object validator that checks that the "type" attribute is + not changed from the archetype's default value.</p> + +<p>The parameters "from,to" or "from,to.env" define allowed + exceptions: a change from archetype's type "from" to game object's + type "to" is allowed. The form "from,to,env" restricts + the allowed change for game objects in the inventory of game objects with + type "env".</p> + +<h2>net.sf.gridarta.validation.checks.DoubleLayerChecker</h2> + +<p>A square validator that checks that no layer within a given map square + contains more than one game object. The layer of a game object is given by + its "layer" attribute. The layer 0 is ignored; no warnings are + reported for game objects on layer 0.</p> + +<h2>net.sf.gridarta.validation.checks.DoubleTypeChecker</h2> + +<p>A square validator that checks that a given map square does not contain two + or more game objects having the same "type" attribute value.</p> + +<h2>net.sf.gridarta.validation.checks.EmptySpawnPointChecker type...</h2> + +<p>A game object validator that checks that spawn points are not empty. A spawn + point is a game object having one of the given types. "type..." is + a comma separated list.</p> + +<h2>net.sf.gridarta.validation.checks.ExitChecker type</h2> + +<p>A game object validator that checks for exit game objects having an invalid + "slaying" attribute. An exit is a game object having the given + type.</p> + +<p>A "slaying" attribute is considered valid if</p> + +<ul> + <li>it is empty or</li> + <li>it contains the value "/!" or</li> + <li>it references to an existing file in the maps directory (and that file + is not a directory) + </li> +</ul> + +<p>Note: relative "slaying" paths are not checked if the map has not + yet been saved. In this case there exists no base path to resolve the + relative path against.</p> + +<h2>net.sf.gridarta.validation.checks.MapDifficultyChecker</h2> + +<p>A map validator that checks for valid "difficulty" map attributes. + The map attribute is considered invalid if it is less than 1.</p> + +<h2>net.sf.gridarta.validation.checks.MobOutsideSpawnPointChecker type...</h2> + +<p>A game object validator that checks that mobs are not outside spawn points. A + mob is any game object that is placed directly on a map (but not in an + inventory) and has one of the given types. "type..." is a comma + separated list.</p> + +<h2>net.sf.gridarta.validation.checks.PaidItemShopSquareChecker shop_matcher + paid_item_matcher</h2> + +<p>A map validator that checks for shop squares that contain paid items.</p> + +<p>A map square is considered a shop square if at least one of the contained + game objects matches the game object matcher "shop_matcher".</p> + +<p>A paid game object is a game object that matches the game object matcher + "paid_item_matcher".</p> + +<p>Note: game object within inventories are not checked.</p> + +<h2>net.sf.gridarta.validation.checks.ShopSquareChecker shop_matcher + no_spells_matcher</h2> + +<p>A map validator that checks for shop squares which allow magic or + prayers.</p> + +<p>A map square is considered a shop square if at least one of the contained + game objects matches the game object matcher "shop_matcher".</p> + +<p>A map square is considered to block spells if at least one of the contained + game objects matches the game object matcher + "no_spells_matcher".</p> + +<p>Note: game object within inventories are not checked.</p> + +<h2>net.sf.gridarta.validation.checks.SlayingChecker pattern + matcher,pattern</h2> + +<h2>net.sf.gridarta.validation.checks.SquareWithoutFloorChecker type...</h2> + +<p>A square validator that checks that all squares include a floor game object. + A game object is considered a floor game object if it has one of the given + types. "type..." is a comma separated list.</p> + +<h2>net.sf.gridarta.validation.checks.SysObjectNotOnLayerZeroChecker</h2> + +<p>A game object validator that checks that system objects are placed on layer + zero. A game object is a system object if it has "sys_object 1". A + game object's layer is defined by the "layer" attribute.</p> + +<h2>net.sf.gridarta.validation.checks.TilePathsChecker number</h2> + +<p>A map validator that checks for valid tile paths. The parameter "number" + defines how many tile paths are checked. Typically this is either 4 (north,... [truncated message content] |