From: <aki...@us...> - 2008-11-01 07:51:39
|
Revision: 5629 http://gridarta.svn.sourceforge.net/gridarta/?rev=5629&view=rev Author: akirschbaum Date: 2008-11-01 07:51:36 +0000 (Sat, 01 Nov 2008) Log Message: ----------- Extract code into functions. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-11-01 07:46:41 UTC (rev 5628) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-11-01 07:51:36 UTC (rev 5629) @@ -26,6 +26,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; +import java.io.Writer; import net.sf.gridarta.gameobject.AbstractArchetypeSet; import net.sf.gridarta.gameobject.ArchetypeFactory; import net.sf.gridarta.io.GameObjectParser; @@ -104,92 +105,9 @@ if (arch.getArchetypeName().equals(net.sf.gridarta.gameobject.ArchetypeParser.STARTARCH_NAME)) { // process map arch - - out.append("Object ").append(arch.getArchetypeName()).append('\n'); - - // map object hack: x/y is normally a reference for multi - // part arches - i include this hack until we rework the - // arch objects with more useful script names - if (arch.getArchetypeName().equals(net.sf.gridarta.gameobject.ArchetypeParser.STARTARCH_NAME)) { - out.append("x ").append(Integer.toString(arch.getMultiX())).append('\n'); - out.append("y ").append(Integer.toString(arch.getMultiY())).append('\n'); - } - - if (arch.getObjName() != null) { - out.append("name ").append(arch.getObjName()).append('\n'); - } - if (arch.getFaceName() != null) { - out.append("face ").append(arch.getFaceName()).append('\n'); - } - if (arch.getTypeNo() > 0) { - out.append("type ").append(Integer.toString(arch.getTypeNo())).append('\n'); - } - - out.append(arch.getObjectText()); - - out.append("end\n"); + collectStartArch(arch, out); } else { - out.append("Object ").append(arch.getArchetypeName()).append('\n'); - - if (arch.getObjName() != null) { - out.append("name ").append(arch.getObjName()).append('\n'); - } - if (arch.getFaceName() != null) { - out.append("face ").append(arch.getFaceName()).append('\n'); - } - if (arch.getTypeNo() > 0) { - out.append("type ").append(Integer.toString(arch.getTypeNo())).append('\n'); - } - - // special: add a string-attribute with the display-category - out.append("editor_folder ").append(arch.getEditorFolder()).append('\n'); - - // add message text - if (arch.getMsgText() != null) { - out.append("msg\n").append(arch.getMsgText()).append("endmsg\n"); - } - - out.append(arch.getObjectText()); - - for (final GameObject inv : arch) { - gameObjectParser.save(out, inv); - } - - out.append("end\n"); - - // process the multipart tails: - for (GameObject tail = arch.getMultiNext(); tail != null; tail = tail.getMultiNext()) { - out.append("More\n"); - - out.append("Object ").append(tail.getArchetypeName()).append('\n'); - - if (tail.getObjName() != null) { - out.append("name ").append(tail.getObjName()).append('\n'); - } - if (tail.getFaceName() != null) { - out.append("face ").append(tail.getFaceName()).append('\n'); - } - if (tail.getTypeNo() > 0) { - out.append("type ").append(Integer.toString(tail.getTypeNo())).append('\n'); - } - - out.append(tail.getObjectText()); - - // position of multi relative to head - if (tail.getMultiX() != 0) { - out.append("x ").append(Integer.toString(tail.getMultiX())).append('\n'); - } - if (tail.getMultiY() != 0) { - out.append("y ").append(Integer.toString(tail.getMultiY())).append('\n'); - } - - out.append("end\n"); - - count++; - if (count % 100 == 0) { - progress.setValue(count); - } - } + collectArch(arch, out); } count++; @@ -214,6 +132,91 @@ } } + private void collectStartArch(@NotNull final Archetype arch, @NotNull final Writer out) throws IOException { + out.append("Object ").append(arch.getArchetypeName()).append('\n'); + + // map object hack: x/y is normally a reference for multi + // part arches - i include this hack until we rework the + // arch objects with more useful script names + if (arch.getArchetypeName().equals(net.sf.gridarta.gameobject.ArchetypeParser.STARTARCH_NAME)) { + out.append("x ").append(Integer.toString(arch.getMultiX())).append('\n'); + out.append("y ").append(Integer.toString(arch.getMultiY())).append('\n'); + } + + if (arch.getObjName() != null) { + out.append("name ").append(arch.getObjName()).append('\n'); + } + if (arch.getFaceName() != null) { + out.append("face ").append(arch.getFaceName()).append('\n'); + } + if (arch.getTypeNo() > 0) { + out.append("type ").append(Integer.toString(arch.getTypeNo())).append('\n'); + } + + out.append(arch.getObjectText()); + + out.append("end\n"); + } + + private void collectArch(@NotNull final Archetype arch, @NotNull final Writer out) throws IOException { + out.append("Object ").append(arch.getArchetypeName()).append('\n'); + + if (arch.getObjName() != null) { + out.append("name ").append(arch.getObjName()).append('\n'); + } + if (arch.getFaceName() != null) { + out.append("face ").append(arch.getFaceName()).append('\n'); + } + if (arch.getTypeNo() > 0) { + out.append("type ").append(Integer.toString(arch.getTypeNo())).append('\n'); + } + + // special: add a string-attribute with the display-category + out.append("editor_folder ").append(arch.getEditorFolder()).append('\n'); + + // add message text + if (arch.getMsgText() != null) { + out.append("msg\n").append(arch.getMsgText()).append("endmsg\n"); + } + + out.append(arch.getObjectText()); + + for (final GameObject inv : arch) { + gameObjectParser.save(out, inv); + } + + out.append("end\n"); + + // process the multipart tails: + for (GameObject tail = arch.getMultiNext(); tail != null; tail = tail.getMultiNext()) { + out.append("More\n"); + + out.append("Object ").append(tail.getArchetypeName()).append('\n'); + + if (tail.getObjName() != null) { + out.append("name ").append(tail.getObjName()).append('\n'); + } + if (tail.getFaceName() != null) { + out.append("face ").append(tail.getFaceName()).append('\n'); + } + if (tail.getTypeNo() > 0) { + out.append("type ").append(Integer.toString(tail.getTypeNo())).append('\n'); + } + + out.append(tail.getObjectText()); + + // position of multi relative to head + if (tail.getMultiX() != 0) { + out.append("x ").append(Integer.toString(tail.getMultiX())).append('\n'); + } + if (tail.getMultiY() != 0) { + out.append("y ").append(Integer.toString(tail.getMultiY())).append('\n'); + } + + out.append("end\n"); + } + } + /** {@inheritDoc} */ @Nullable public String getImageSet() { Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-11-01 07:46:41 UTC (rev 5628) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-11-01 07:51:36 UTC (rev 5629) @@ -26,6 +26,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; +import java.io.Writer; import javax.swing.ImageIcon; import net.sf.gridarta.gameobject.AbstractArchetypeSet; import net.sf.gridarta.gameobject.ArchetypeFactory; @@ -128,104 +129,14 @@ if (arch.getArchetypeName().equals(net.sf.gridarta.gameobject.ArchetypeParser.STARTARCH_NAME)) { // process map arch - - out.append("Object ").append(arch.getArchetypeName()).append('\n'); - - // map object hack: x/y is normally a reference for multi - // part arches - i include this hack until we rework the - // arch objects with more useful script names - if (arch.getArchetypeName().equals(net.sf.gridarta.gameobject.ArchetypeParser.STARTARCH_NAME)) { - out.append("x ").append(Integer.toString(arch.getMultiX())).append('\n'); - out.append("y ").append(Integer.toString(arch.getMultiY())).append('\n'); - } - - if (arch.getObjName() != null) { - out.append("name ").append(arch.getObjName()).append('\n'); - } - //if(arch.getFaceName() != null) { - // out.append("face ").append(arch.getFaceNAme()).append('\n'); - //} - if (arch.getTypeNo() > 0) { - out.append("type ").append(Integer.toString(arch.getTypeNo())).append('\n'); - } - - out.append(arch.getObjectText()); - - out.append("end\n"); + collectStartArch(arch, out); } else { - out.append("Object ").append(arch.getArchetypeName()).append('\n'); + collectArch(arch, out); - if (arch.getObjName() != null) { - out.append("name ").append(arch.getObjName()).append('\n'); + count++; + if (count % 100 == 0) { + progress.setValue(count); } - //if(arch.getFaceName() != null) { - // out.append("face ").append(arch.getFaceName()).append('\n'); - //} - if (arch.getTypeNo() > 0) { - out.append("type ").append(Integer.toString(arch.getTypeNo())).append('\n'); - } - if (arch.getMultiShapeID() > 0) { - out.append("mpart_id ").append(Integer.toString(arch.getMultiShapeID())).append('\n'); - } - if (arch.getMultiPartNr() > 0) { - out.append("mpart_nr ").append(Integer.toString(arch.getMultiPartNr())).append('\n'); - } - - if (arch.getMsgText() != null) { - out.append("msg\n").append(arch.getMsgText()).append("endmsg\n"); - } - - // special: add a string-attribute with the display-category - out.append("editor_folder ").append(arch.getEditorFolder()).append('\n'); - - out.append(arch.getObjectText()); - - out.append("end\n"); - - // process the multipart tails: - for (GameObject tail = arch.getMultiNext(); tail != null; tail = tail.getMultiNext()) { - - out.append("More\n"); - - out.append("Object ").append(tail.getArchetypeName()).append('\n'); - - if (tail.getObjName() != null) { - out.append("name ").append(tail.getObjName()).append('\n'); - } - //if(arch.getFaceName() != null) { - // out.append("face ").append(arch.getFaceName()).append('\n'); - //} - if (tail.getTypeNo() > 0) { - out.append("type ").append(Integer.toString(tail.getTypeNo())).append('\n'); - } - if (tail.getMultiShapeID() > 0) { - out.append("mpart_id ").append(Integer.toString(tail.getMultiShapeID())).append('\n'); - } - if (tail.getMultiPartNr() > 0) { - out.append("mpart_nr ").append(Integer.toString(tail.getMultiPartNr())).append('\n'); - } - - if (tail.getMsgText() != null) { - out.append("msg\n").append(tail.getMsgText()).append("endmsg\n"); - } - - out.append(tail.getObjectText()); - - // position of multi relative to head - if (tail.getMultiX() != 0) { - out.append("x ").append(Integer.toString(tail.getMultiX())).append('\n'); - } - if (tail.getMultiY() != 0) { - out.append("y ").append(Integer.toString(tail.getMultiY())).append('\n'); - } - - out.append("end\n"); - - count++; - if (count % 100 == 0) { - progress.setValue(count); - } - } } count++; @@ -250,4 +161,101 @@ } } + private void collectStartArch(@NotNull final Archetype arch, @NotNull final Writer out) throws IOException { + out.append("Object ").append(arch.getArchetypeName()).append('\n'); + + // map object hack: x/y is normally a reference for multi + // part arches - i include this hack until we rework the + // arch objects with more useful script names + if (arch.getArchetypeName().equals(net.sf.gridarta.gameobject.ArchetypeParser.STARTARCH_NAME)) { + out.append("x ").append(Integer.toString(arch.getMultiX())).append('\n'); + out.append("y ").append(Integer.toString(arch.getMultiY())).append('\n'); + } + + if (arch.getObjName() != null) { + out.append("name ").append(arch.getObjName()).append('\n'); + } + //if(arch.getFaceName() != null) { + // out.append("face ").append(arch.getFaceNAme()).append('\n'); + //} + if (arch.getTypeNo() > 0) { + out.append("type ").append(Integer.toString(arch.getTypeNo())).append('\n'); + } + + out.append(arch.getObjectText()); + + out.append("end\n"); + } + + private void collectArch(@NotNull final Archetype arch, @NotNull final Writer out) throws IOException { + out.append("Object ").append(arch.getArchetypeName()).append('\n'); + + if (arch.getObjName() != null) { + out.append("name ").append(arch.getObjName()).append('\n'); + } + //if(arch.getFaceName() != null) { + // out.append("face ").append(arch.getFaceName()).append('\n'); + //} + if (arch.getTypeNo() > 0) { + out.append("type ").append(Integer.toString(arch.getTypeNo())).append('\n'); + } + if (arch.getMultiShapeID() > 0) { + out.append("mpart_id ").append(Integer.toString(arch.getMultiShapeID())).append('\n'); + } + if (arch.getMultiPartNr() > 0) { + out.append("mpart_nr ").append(Integer.toString(arch.getMultiPartNr())).append('\n'); + } + + if (arch.getMsgText() != null) { + out.append("msg\n").append(arch.getMsgText()).append("endmsg\n"); + } + + // special: add a string-attribute with the display-category + out.append("editor_folder ").append(arch.getEditorFolder()).append('\n'); + + out.append(arch.getObjectText()); + + out.append("end\n"); + + // process the multipart tails: + for (GameObject tail = arch.getMultiNext(); tail != null; tail = tail.getMultiNext()) { + + out.append("More\n"); + + out.append("Object ").append(tail.getArchetypeName()).append('\n'); + + if (tail.getObjName() != null) { + out.append("name ").append(tail.getObjName()).append('\n'); + } + //if(arch.getFaceName() != null) { + // out.append("face ").append(arch.getFaceName()).append('\n'); + //} + if (tail.getTypeNo() > 0) { + out.append("type ").append(Integer.toString(tail.getTypeNo())).append('\n'); + } + if (tail.getMultiShapeID() > 0) { + out.append("mpart_id ").append(Integer.toString(tail.getMultiShapeID())).append('\n'); + } + if (tail.getMultiPartNr() > 0) { + out.append("mpart_nr ").append(Integer.toString(tail.getMultiPartNr())).append('\n'); + } + + if (tail.getMsgText() != null) { + out.append("msg\n").append(tail.getMsgText()).append("endmsg\n"); + } + + out.append(tail.getObjectText()); + + // position of multi relative to head + if (tail.getMultiX() != 0) { + out.append("x ").append(Integer.toString(tail.getMultiX())).append('\n'); + } + if (tail.getMultiY() != 0) { + out.append("y ").append(Integer.toString(tail.getMultiY())).append('\n'); + } + + out.append("end\n"); + } + } + } // class ArchetypeSet This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-01 08:01:09
|
Revision: 5632 http://gridarta.svn.sourceforge.net/gridarta/?rev=5632&view=rev Author: akirschbaum Date: 2008-11-01 08:01:07 +0000 (Sat, 01 Nov 2008) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/src/app/net/sf/gridarta/gameobject/Collectable.java trunk/src/app/net/sf/gridarta/gameobject/Collector.java trunk/src/app/net/sf/gridarta/gameobject/anim/DefaultAnimationObjects.java trunk/src/app/net/sf/gridarta/gameobject/face/DefaultFaceObjects.java trunk/src/app/net/sf/gridarta/gui/MainActions.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-11-01 07:57:07 UTC (rev 5631) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-11-01 08:01:07 UTC (rev 5632) @@ -75,7 +75,7 @@ } /** {@inheritDoc} Collects the Archetypes. */ - public void collect(@NotNull final Progress progress, @NotNull final File collectedDirectory, @NotNull final File archDirectory) throws IOException { + public void collect(@NotNull final Progress progress, @NotNull final File collectedDirectory) throws IOException { final File dfile = new File(collectedDirectory, IGUIConstants.ARCH_FILE); // now open the output-stream final FileOutputStream fos = new FileOutputStream(dfile); Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-11-01 07:57:07 UTC (rev 5631) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-11-01 08:01:07 UTC (rev 5632) @@ -99,7 +99,7 @@ } /** {@inheritDoc} Collects the Archetypes. */ - public void collect(@NotNull final Progress progress, @NotNull final File collectedDirectory, @NotNull final File archDirectory) throws IOException { + public void collect(@NotNull final Progress progress, @NotNull final File collectedDirectory) throws IOException { final File dfile = new File(collectedDirectory, IGUIConstants.ARCH_FILE); // now open the output-stream final FileOutputStream fos = new FileOutputStream(dfile); Modified: trunk/src/app/net/sf/gridarta/gameobject/Collectable.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/Collectable.java 2008-11-01 07:57:07 UTC (rev 5631) +++ trunk/src/app/net/sf/gridarta/gameobject/Collectable.java 2008-11-01 08:01:07 UTC (rev 5632) @@ -36,10 +36,8 @@ * Collect information. * @param progress Progress to report progress to. * @param collectedDirectory the destination directory to collect data to - * @param archDirectory the base directory from where the archetypes have - * been collected * @throws IOException in case of I/O problems during collection */ - void collect(@NotNull final Progress progress, @NotNull final File collectedDirectory, @NotNull final File archDirectory) throws IOException; + void collect(@NotNull final Progress progress, @NotNull final File collectedDirectory) throws IOException; } // interface Collectable Modified: trunk/src/app/net/sf/gridarta/gameobject/Collector.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/Collector.java 2008-11-01 07:57:07 UTC (rev 5631) +++ trunk/src/app/net/sf/gridarta/gameobject/Collector.java 2008-11-01 08:01:07 UTC (rev 5632) @@ -41,9 +41,6 @@ /** The Collectables. */ private final List<Collectable> collectables = new ArrayList<Collectable>(); - /** The archetype directory to collect from. */ - private File archDirectory; - /** The destination directory to write files to. */ private File collectedDirectory; @@ -79,14 +76,6 @@ this.collectedDirectory = collectedDirectory; } - /** - * Sets the archetype directory to collect from to. - * @param archDirectory the archetype directory - */ - public void setArchDirectory(final File archDirectory) { - this.archDirectory = archDirectory; - } - /** Starts collecting. */ public synchronized void start() { if (thread != null) { @@ -121,7 +110,7 @@ try { for (final Collectable collectable : collectables) { try { - collectable.collect(progress, collectedDirectory, archDirectory); + collectable.collect(progress, collectedDirectory); } catch (final IOException e) { ACTION_FACTORY.showMessageDialog(progress.getParentComponent(), "archCollectErrorIOException", "arches, animations and animtree, images", e); } Modified: trunk/src/app/net/sf/gridarta/gameobject/anim/DefaultAnimationObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/anim/DefaultAnimationObjects.java 2008-11-01 07:57:07 UTC (rev 5631) +++ trunk/src/app/net/sf/gridarta/gameobject/anim/DefaultAnimationObjects.java 2008-11-01 08:01:07 UTC (rev 5632) @@ -195,7 +195,7 @@ * "animations". The tree information for the editor is written to * "animtree". */ - public void collect(@NotNull final Progress progress, @NotNull final File collectedDirectory, @NotNull final File archDirectory) throws IOException { + public void collect(@NotNull final Progress progress, @NotNull final File collectedDirectory) throws IOException { progress.setLabel(ACTION_FACTORY.getString("archCollectAnimations"), size()); collectAnims(progress, collectedDirectory); collectAnimTree(progress, collectedDirectory); Modified: trunk/src/app/net/sf/gridarta/gameobject/face/DefaultFaceObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/DefaultFaceObjects.java 2008-11-01 07:57:07 UTC (rev 5631) +++ trunk/src/app/net/sf/gridarta/gameobject/face/DefaultFaceObjects.java 2008-11-01 08:01:07 UTC (rev 5632) @@ -124,7 +124,7 @@ * Java image encoder isn't as good as that of gimp in many cases (yet much * better as the old visualtek's). */ - public void collect(@NotNull final Progress progress, @NotNull final File collectedDirectory, @NotNull final File archDirectory) throws IOException { + public void collect(@NotNull final Progress progress, @NotNull final File collectedDirectory) throws IOException { collectTreeFile(progress, collectedDirectory); collectBmapsFile(progress, collectedDirectory); collectImageFile(progress, collectedDirectory); Modified: trunk/src/app/net/sf/gridarta/gui/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-11-01 07:57:07 UTC (rev 5631) +++ trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-11-01 08:01:07 UTC (rev 5632) @@ -666,7 +666,6 @@ collectables.add(faceObjects); collector.setCollectables(collectables); collector.setCollectedDirectory(new File(globalSettings.getCollectedDirectory())); - collector.setArchDirectory(new File(globalSettings.getArchDirectory())); collector.start(); aCollectArches.setEnabled(isCollectArchesEnabled()); } Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-11-01 07:57:07 UTC (rev 5631) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-11-01 08:01:07 UTC (rev 5632) @@ -802,7 +802,7 @@ } /** {@inheritDoc} */ - public void collect(@NotNull final Progress progress, @NotNull final File collectedDirectory, @NotNull final File archDirectory) throws IOException { + public void collect(@NotNull final Progress progress, @NotNull final File collectedDirectory) throws IOException { throw new AssertionError(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-01 08:10:59
|
Revision: 5633 http://gridarta.svn.sourceforge.net/gridarta/?rev=5633&view=rev Author: akirschbaum Date: 2008-11-01 08:10:57 +0000 (Sat, 01 Nov 2008) Log Message: ----------- Move ArchetypeSet.collect() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-11-01 08:01:07 UTC (rev 5632) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-11-01 08:10:57 UTC (rev 5633) @@ -21,18 +21,12 @@ import cfeditor.IGUIConstants; import cfeditor.map.MapArchObject; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; -import java.io.OutputStreamWriter; import java.io.Writer; import net.sf.gridarta.gameobject.AbstractArchetypeSet; import net.sf.gridarta.gameobject.ArchetypeFactory; import net.sf.gridarta.io.GameObjectParser; -import net.sf.gridarta.utils.IOUtils; import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.misc.Progress; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -65,7 +59,7 @@ * @param archetypeFactory the archetype factory instance to use */ public ArchetypeSet(@Nullable final String imageSet, @NotNull final ArchetypeFactory<GameObject, MapArchObject, Archetype> archetypeFactory) { - super(archetypeFactory); + super(archetypeFactory, IGUIConstants.ARCH_FILE); this.imageSet = imageSet; } @@ -74,65 +68,9 @@ this.gameObjectParser = gameObjectParser; } - /** {@inheritDoc} Collects the Archetypes. */ - public void collect(@NotNull final Progress progress, @NotNull final File collectedDirectory) throws IOException { - final File dfile = new File(collectedDirectory, IGUIConstants.ARCH_FILE); - // now open the output-stream - final FileOutputStream fos = new FileOutputStream(dfile); - try { - final OutputStreamWriter osw = new OutputStreamWriter(fos, IOUtils.MAP_ENCODING); - try { - final BufferedWriter out = new BufferedWriter(osw); - try { - int artifactCount = 0; - - int count = 0; // count how much arches we've collected - - for (final Archetype arch : getArchetypes()) { - - // exclude arches generated from artifacts file from collection - if (arch.isArtifact()) { - artifactCount++; - continue; - } - if (arch.isUndefinedArchetype()) { - continue; - } - - if (arch.isTail()) { - continue; - } - - if (arch.getArchetypeName().equals(net.sf.gridarta.gameobject.ArchetypeParser.STARTARCH_NAME)) { - // process map arch - collectStartArch(arch, out); - } else { - collectArch(arch, out); - } - - count++; - if (count % 100 == 0) { - progress.setValue(count); - } - } - - // check if we still missed any arches - if ((count + artifactCount) - getArchetypeCount() != 0) { - ACTION_FACTORY.showMessageDialog(progress.getParentComponent(), "archCollectWarningMissed", getArchetypeCount() - count); - } - progress.setValue(count); - } finally { - out.close(); - } - } finally { - osw.close(); - } - } finally { - fos.close(); - } - } - - private void collectStartArch(@NotNull final Archetype arch, @NotNull final Writer out) throws IOException { + /** {@inheritDoc} */ + @Override + protected void collectStartArch(@NotNull final Archetype arch, @NotNull final Writer out) throws IOException { out.append("Object ").append(arch.getArchetypeName()).append('\n'); // map object hack: x/y is normally a reference for multi @@ -158,7 +96,9 @@ out.append("end\n"); } - private void collectArch(@NotNull final Archetype arch, @NotNull final Writer out) throws IOException { + /** {@inheritDoc} */ + @Override + protected void collectArch(@NotNull final Archetype arch, @NotNull final Writer out) throws IOException { out.append("Object ").append(arch.getArchetypeName()).append('\n'); if (arch.getObjName() != null) { Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-11-01 08:01:07 UTC (rev 5632) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-11-01 08:10:57 UTC (rev 5633) @@ -21,11 +21,7 @@ import daieditor.IGUIConstants; import daieditor.map.MapArchObject; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; -import java.io.OutputStreamWriter; import java.io.Writer; import javax.swing.ImageIcon; import net.sf.gridarta.gameobject.AbstractArchetypeSet; @@ -33,9 +29,7 @@ import net.sf.gridarta.gameobject.face.FaceObjectProviders; import net.sf.gridarta.gui.SystemIcons; import net.sf.gridarta.io.GameObjectParser; -import net.sf.gridarta.utils.IOUtils; import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.misc.Progress; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -55,7 +49,7 @@ * @param archetypeFactory the archetype factory instance to use */ public ArchetypeSet(@NotNull final ArchetypeFactory<GameObject, MapArchObject, Archetype> archetypeFactory) { - super(archetypeFactory); + super(archetypeFactory, IGUIConstants.ARCH_FILE); } /** {@inheritDoc} */ @@ -98,65 +92,9 @@ return null; } - /** {@inheritDoc} Collects the Archetypes. */ - public void collect(@NotNull final Progress progress, @NotNull final File collectedDirectory) throws IOException { - final File dfile = new File(collectedDirectory, IGUIConstants.ARCH_FILE); - // now open the output-stream - final FileOutputStream fos = new FileOutputStream(dfile); - try { - final OutputStreamWriter osw = new OutputStreamWriter(fos, IOUtils.MAP_ENCODING); - try { - final BufferedWriter out = new BufferedWriter(osw); - try { - int artifactCount = 0; - - int count = 0; // count how much arches we've collected - - for (final Archetype arch : getArchetypes()) { - - // exclude arches generated from artifacts file from collection - if (arch.isArtifact()) { - artifactCount++; - continue; - } - if (arch.isUndefinedArchetype()) { - continue; - } - - if (arch.isTail()) { - continue; - } - - if (arch.getArchetypeName().equals(net.sf.gridarta.gameobject.ArchetypeParser.STARTARCH_NAME)) { - // process map arch - collectStartArch(arch, out); - } else { - collectArch(arch, out); - } - - count++; - if (count % 100 == 0) { - progress.setValue(count); - } - } - - // check if we still missed any arches - if ((count + artifactCount) - getArchetypeCount() != 0) { - ACTION_FACTORY.showMessageDialog(progress.getParentComponent(), "archCollectWarningMissed", getArchetypeCount() - count); - } - progress.setValue(count); - } finally { - out.close(); - } - } finally { - osw.close(); - } - } finally { - fos.close(); - } - } - - private void collectStartArch(@NotNull final Archetype arch, @NotNull final Writer out) throws IOException { + /** {@inheritDoc} */ + @Override + protected void collectStartArch(@NotNull final Archetype arch, @NotNull final Writer out) throws IOException { out.append("Object ").append(arch.getArchetypeName()).append('\n'); // map object hack: x/y is normally a reference for multi @@ -182,7 +120,9 @@ out.append("end\n"); } - private void collectArch(@NotNull final Archetype arch, @NotNull final Writer out) throws IOException { + /** {@inheritDoc} */ + @Override + protected void collectArch(@NotNull final Archetype arch, @NotNull final Writer out) throws IOException { out.append("Object ").append(arch.getArchetypeName()).append('\n'); if (arch.getObjName() != null) { Modified: trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java 2008-11-01 08:01:07 UTC (rev 5632) +++ trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java 2008-11-01 08:10:57 UTC (rev 5633) @@ -21,7 +21,12 @@ import java.awt.BorderLayout; import java.awt.Component; +import java.io.BufferedWriter; import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.Writer; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Collection; @@ -41,7 +46,9 @@ import net.sf.gridarta.gameobject.face.FaceObjectProviders; import net.sf.gridarta.gui.SystemIcons; import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.utils.IOUtils; import net.sf.japi.swing.ActionFactory; +import net.sf.japi.swing.misc.Progress; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -58,6 +65,12 @@ @NotNull private final ArchetypeFactory<G, A, R> archetypeFactory; + /** + * The collected archetype file name. + */ + @NotNull + private final String archFile; + /** The load status of this ArchetypeSet. */ @NotNull private LoadStatus loadStatus = LoadStatus.EMPTY; @@ -104,9 +117,11 @@ /** * Create an AbstractArchetypeSet. * @param archetypeFactory the archetype factory to use + * @param archFile the collected archetypes file name */ - protected AbstractArchetypeSet(@NotNull final ArchetypeFactory<G, A, R> archetypeFactory) { + protected AbstractArchetypeSet(@NotNull final ArchetypeFactory<G, A, R> archetypeFactory, @NotNull final String archFile) { this.archetypeFactory = archetypeFactory; + this.archFile = archFile; } /** {@inheritDoc} */ @@ -289,4 +304,66 @@ } } + /** {@inheritDoc} Collects the Archetypes. */ + public void collect(@NotNull final Progress progress, @NotNull final File collectedDirectory) throws IOException { + final File dfile = new File(collectedDirectory, archFile); + // now open the output-stream + final FileOutputStream fos = new FileOutputStream(dfile); + try { + final OutputStreamWriter osw = new OutputStreamWriter(fos, IOUtils.MAP_ENCODING); + try { + final BufferedWriter out = new BufferedWriter(osw); + try { + int artifactCount = 0; + + int count = 0; // count how much arches we've collected + + for (final R arch : getArchetypes()) { + + // exclude arches generated from artifacts file from collection + if (arch.isArtifact()) { + artifactCount++; + continue; + } + if (arch.isUndefinedArchetype()) { + continue; + } + + if (arch.isTail()) { + continue; + } + + if (arch.getArchetypeName().equals(ArchetypeParser.STARTARCH_NAME)) { + // process map arch + collectStartArch(arch, out); + } else { + collectArch(arch, out); + } + + count++; + if (count % 100 == 0) { + progress.setValue(count); + } + } + + // check if we still missed any arches + if ((count + artifactCount) - getArchetypeCount() != 0) { + ACTION_FACTORY.showMessageDialog(progress.getParentComponent(), "archCollectWarningMissed", getArchetypeCount() - count); + } + progress.setValue(count); + } finally { + out.close(); + } + } finally { + osw.close(); + } + } finally { + fos.close(); + } + } + + protected abstract void collectStartArch(@NotNull final R arch, @NotNull final Writer out) throws IOException; + + protected abstract void collectArch(@NotNull final R arch, @NotNull final Writer out) throws IOException; + } // class AbstractArchetypeSet Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-11-01 08:01:07 UTC (rev 5632) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-11-01 08:10:57 UTC (rev 5633) @@ -25,6 +25,7 @@ import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; +import java.io.Writer; import java.util.List; import java.util.SortedSet; import java.util.TreeSet; @@ -770,7 +771,7 @@ * @param archetypeFactory the archetype factory to use */ protected TestArchetypeSet(@NotNull final ArchetypeFactory<TestGameObject, TestMapArchObject, TestArchetype> archetypeFactory) { - super(archetypeFactory); + super(archetypeFactory, "archetypes"); } /** {@inheritDoc} */ @@ -806,6 +807,18 @@ throw new AssertionError(); } + /** {@inheritDoc} */ + @Override + protected void collectStartArch(@NotNull final TestArchetype arch, @NotNull final Writer out) throws IOException { + throw new AssertionError(); + } + + /** {@inheritDoc} */ + @Override + protected void collectArch(@NotNull final TestArchetype arch, @NotNull final Writer out) throws IOException { + throw new AssertionError(); + } + } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-01 08:37:17
|
Revision: 5634 http://gridarta.svn.sourceforge.net/gridarta/?rev=5634&view=rev Author: akirschbaum Date: 2008-11-01 08:37:14 +0000 (Sat, 01 Nov 2008) Log Message: ----------- Move text resource to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/messages.properties trunk/crossfire/src/cfeditor/messages_de.properties trunk/crossfire/src/cfeditor/messages_fr.properties trunk/crossfire/src/cfeditor/messages_sv.properties trunk/daimonin/src/daieditor/messages.properties trunk/daimonin/src/daieditor/messages_de.properties trunk/daimonin/src/daieditor/messages_fr.properties trunk/daimonin/src/daieditor/messages_sv.properties trunk/src/app/net/sf/gridarta/messages.properties trunk/src/app/net/sf/gridarta/messages_de.properties trunk/src/app/net/sf/gridarta/messages_fr.properties trunk/src/app/net/sf/gridarta/messages_sv.properties Modified: trunk/crossfire/src/cfeditor/messages.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages.properties 2008-11-01 08:10:57 UTC (rev 5633) +++ trunk/crossfire/src/cfeditor/messages.properties 2008-11-01 08:37:14 UTC (rev 5634) @@ -87,10 +87,6 @@ optionsImageSet=Image Set -archCollectWarningMissed.title=Collect warning -archCollectWarningMissed.message=Collect Warning: {0} arches have been missed during collect! - - ####### # Map Modified: trunk/crossfire/src/cfeditor/messages_de.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_de.properties 2008-11-01 08:10:57 UTC (rev 5633) +++ trunk/crossfire/src/cfeditor/messages_de.properties 2008-11-01 08:37:14 UTC (rev 5634) @@ -83,10 +83,6 @@ optionsImageSet=Image Set -archCollectWarningMissed.title=Fehler beim Sammeln -archCollectWarningMissed.message=Warnung: Beim Sammeln der Archetypen sind wurden {0} Archetypen nicht gefunden. - - ####### # Map Modified: trunk/crossfire/src/cfeditor/messages_fr.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_fr.properties 2008-11-01 08:10:57 UTC (rev 5633) +++ trunk/crossfire/src/cfeditor/messages_fr.properties 2008-11-01 08:37:14 UTC (rev 5634) @@ -84,10 +84,6 @@ #optionsImageSet= -#archCollectWarningMissed.title= -#archCollectWarningMissed.message= - - ####### # Map Modified: trunk/crossfire/src/cfeditor/messages_sv.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_sv.properties 2008-11-01 08:10:57 UTC (rev 5633) +++ trunk/crossfire/src/cfeditor/messages_sv.properties 2008-11-01 08:37:14 UTC (rev 5634) @@ -83,10 +83,6 @@ #optionsImageSet= -archCollectWarningMissed.title=Varning under sammanst\xE4llning -archCollectWarningMissed.message=Varning under sammanst\xE4llning: {0} arketyper saknades under sammanst\xE4llningen! - - ####### # Map Modified: trunk/daimonin/src/daieditor/messages.properties =================================================================== --- trunk/daimonin/src/daieditor/messages.properties 2008-11-01 08:10:57 UTC (rev 5633) +++ trunk/daimonin/src/daieditor/messages.properties 2008-11-01 08:37:14 UTC (rev 5634) @@ -64,10 +64,7 @@ oldLibsFound.message=Old libraries found.\nLocation: {0}\nThey aren''t used anymore.\nDelete them? oldLibsFound.title=Delete old libraries? -archCollectWarningMissed.title=Collect warning -archCollectWarningMissed.message=Collect Warning: {0} arches have been missed during collect! - ####### # Map Modified: trunk/daimonin/src/daieditor/messages_de.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_de.properties 2008-11-01 08:10:57 UTC (rev 5633) +++ trunk/daimonin/src/daieditor/messages_de.properties 2008-11-01 08:37:14 UTC (rev 5634) @@ -64,10 +64,7 @@ #oldLibsFound.message= #oldLibsFound.title= -archCollectWarningMissed.title=Fehler beim Sammeln -archCollectWarningMissed.message=Warnung: Beim Sammeln der Archetypen sind wurden {0} Archetypen nicht gefunden. - ####### # Map Modified: trunk/daimonin/src/daieditor/messages_fr.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_fr.properties 2008-11-01 08:10:57 UTC (rev 5633) +++ trunk/daimonin/src/daieditor/messages_fr.properties 2008-11-01 08:37:14 UTC (rev 5634) @@ -66,10 +66,7 @@ #oldLibsFound.message= #oldLibsFound.title= -#archCollectWarningMissed.title= -#archCollectWarningMissed.message= - ####### # Map Modified: trunk/daimonin/src/daieditor/messages_sv.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_sv.properties 2008-11-01 08:10:57 UTC (rev 5633) +++ trunk/daimonin/src/daieditor/messages_sv.properties 2008-11-01 08:37:14 UTC (rev 5634) @@ -64,8 +64,6 @@ oldLibsFound.message=Hittade gamla bibliotek.\nS\xF6kv\xE4g: {0}\nDe anv\xE4nds inte l\xE4ngre. Skall jag ta bort dem? oldLibsFound.title=Ta bort gamla bibliotek? -archCollectWarningMissed.title=Varning under sammanst\xE4llning -archCollectWarningMissed.message=Varning under sammanst\xE4llning: {0} arketyper saknades under sammanst\xE4llningen! archCollectErrorIOException.title=Fel under sammanst\xE4llning archCollectErrorIOException.message=Fel under sammanst\xE4llning: ett I/O-fel intr\xE4ffade f\xF6r filen {0}:\n{1} Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2008-11-01 08:10:57 UTC (rev 5633) +++ trunk/src/app/net/sf/gridarta/messages.properties 2008-11-01 08:37:14 UTC (rev 5634) @@ -881,6 +881,8 @@ archCollectErrorFileNotFound.title=Collect error archCollectErrorFileNotFound.message=Collect Error: Cannot open input file\n{0} +archCollectWarningMissed.title=Collect warning +archCollectWarningMissed.message=Collect Warning: {0} arches have been missed during collect! arcDoc.htmlText=<html><head><meta name="Gridarta" content="tmp"><title>{0}</title></head><body><h1 style="text-align:center;colour:navy;">{0}</h1><h3 style="colour:navy;">Functionality of {0}:</h3><p>{1}</p><h3 style="colour:navy;">Notes on Usage:</h3><p>{2}</p></body></html> Modified: trunk/src/app/net/sf/gridarta/messages_de.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_de.properties 2008-11-01 08:10:57 UTC (rev 5633) +++ trunk/src/app/net/sf/gridarta/messages_de.properties 2008-11-01 08:37:14 UTC (rev 5634) @@ -829,6 +829,8 @@ archCollectErrorFileNotFound.title=Fehler beim Sammeln archCollectErrorFileNotFound.message=Kann Eingabedatei nicht \xF6ffnen:\n{0} +archCollectWarningMissed.title=Fehler beim Sammeln +archCollectWarningMissed.message=Warnung: Beim Sammeln der Archetypen sind wurden {0} Archetypen nicht gefunden. arcDoc.htmlText=<html><head meta name="Gridarta" content="tmp"><title>{0}</title></head><body><h1 style="text-align:center;colour:navy;">{0}</h1><h3 style="colour:navy;">Funktionalität von {0}:</h3><p>{1}</p><h3 style="colour:navy;">Nutzungshinweise:</h3><p>{2}</p></body></html> Modified: trunk/src/app/net/sf/gridarta/messages_fr.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-11-01 08:10:57 UTC (rev 5633) +++ trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-11-01 08:37:14 UTC (rev 5634) @@ -828,6 +828,8 @@ #archCollectErrorFileNotFound.title= #archCollectErrorFileNotFound.message= +#archCollectWarningMissed.title= +#archCollectWarningMissed.message= arcDoc.htmlText=<html><head><meta name="Gridarta" contents="tmp"><title>{0}</title></head><body><h1 style="text-align:center;colour:navy;">Type: {0}</h1><h3 style="colour:navy;">Fonctionalit\xE9s de {0}</h3><p>{1}</p><h3 style="colour:navy;">Notes d'utilisation:</h3><p>{2}</p></body></html> Modified: trunk/src/app/net/sf/gridarta/messages_sv.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-11-01 08:10:57 UTC (rev 5633) +++ trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-11-01 08:37:14 UTC (rev 5634) @@ -831,6 +831,8 @@ #optionsAppEditor.shortdescription= #optionsNetProxy= +archCollectWarningMissed.title=Varning under sammanst\xE4llning +archCollectWarningMissed.message=Varning under sammanst\xE4llning: {0} arketyper saknades under sammanst\xE4llningen! archCollectErrorFileNotFound.title=Fel under sammanst\xE4llning archCollectErrorFileNotFound.message=Fel under sammanst\xE4llning: kan inte \xF6ppna fil\n{0} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-01 08:54:30
|
Revision: 5635 http://gridarta.svn.sourceforge.net/gridarta/?rev=5635&view=rev Author: akirschbaum Date: 2008-11-01 08:54:25 +0000 (Sat, 01 Nov 2008) Log Message: ----------- Fix error message while collection. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-11-01 08:37:14 UTC (rev 5634) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-11-01 08:54:25 UTC (rev 5635) @@ -98,7 +98,7 @@ /** {@inheritDoc} */ @Override - protected void collectArch(@NotNull final Archetype arch, @NotNull final Writer out) throws IOException { + protected int collectArch(@NotNull final Archetype arch, @NotNull final Writer out) throws IOException { out.append("Object ").append(arch.getArchetypeName()).append('\n'); if (arch.getObjName() != null) { @@ -128,7 +128,10 @@ out.append("end\n"); // process the multipart tails: + int result = 1; for (GameObject tail = arch.getMultiNext(); tail != null; tail = tail.getMultiNext()) { + result++; + out.append("More\n"); out.append("Object ").append(tail.getArchetypeName()).append('\n'); @@ -155,6 +158,8 @@ out.append("end\n"); } + + return result; } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-11-01 08:37:14 UTC (rev 5634) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-11-01 08:54:25 UTC (rev 5635) @@ -122,7 +122,7 @@ /** {@inheritDoc} */ @Override - protected void collectArch(@NotNull final Archetype arch, @NotNull final Writer out) throws IOException { + protected int collectArch(@NotNull final Archetype arch, @NotNull final Writer out) throws IOException { out.append("Object ").append(arch.getArchetypeName()).append('\n'); if (arch.getObjName() != null) { @@ -153,7 +153,9 @@ out.append("end\n"); // process the multipart tails: + int result = 1; for (GameObject tail = arch.getMultiNext(); tail != null; tail = tail.getMultiNext()) { + result++; out.append("More\n"); @@ -191,6 +193,8 @@ out.append("end\n"); } + + return result; } } // class ArchetypeSet Modified: trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java 2008-11-01 08:37:14 UTC (rev 5634) +++ trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java 2008-11-01 08:54:25 UTC (rev 5635) @@ -336,11 +336,11 @@ if (arch.getArchetypeName().equals(ArchetypeParser.STARTARCH_NAME)) { // process map arch collectStartArch(arch, out); + count++; } else { - collectArch(arch, out); + count += collectArch(arch, out); } - count++; if (count % 100 == 0) { progress.setValue(count); } @@ -348,7 +348,7 @@ // check if we still missed any arches if ((count + artifactCount) - getArchetypeCount() != 0) { - ACTION_FACTORY.showMessageDialog(progress.getParentComponent(), "archCollectWarningMissed", getArchetypeCount() - count); + ACTION_FACTORY.showMessageDialog(progress.getParentComponent(), "archCollectWarningMissed", getArchetypeCount() - count - artifactCount); } progress.setValue(count); } finally { @@ -364,6 +364,6 @@ protected abstract void collectStartArch(@NotNull final R arch, @NotNull final Writer out) throws IOException; - protected abstract void collectArch(@NotNull final R arch, @NotNull final Writer out) throws IOException; + protected abstract int collectArch(@NotNull final R arch, @NotNull final Writer out) throws IOException; } // class AbstractArchetypeSet Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-11-01 08:37:14 UTC (rev 5634) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-11-01 08:54:25 UTC (rev 5635) @@ -815,7 +815,7 @@ /** {@inheritDoc} */ @Override - protected void collectArch(@NotNull final TestArchetype arch, @NotNull final Writer out) throws IOException { + protected int collectArch(@NotNull final TestArchetype arch, @NotNull final Writer out) throws IOException { throw new AssertionError(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-01 11:14:52
|
Revision: 5637 http://gridarta.svn.sourceforge.net/gridarta/?rev=5637&view=rev Author: akirschbaum Date: 2008-11-01 11:14:48 +0000 (Sat, 01 Nov 2008) Log Message: ----------- Remove dependency FaceObjects/AnimationObjects -> MainActions. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/gui/MainActions.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-01 11:03:31 UTC (rev 5636) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-01 11:14:48 UTC (rev 5637) @@ -54,6 +54,7 @@ import net.sf.gridarta.filter.FilterControl; import net.sf.gridarta.gameobject.AbstractArchetypeParser; import net.sf.gridarta.gameobject.ArchetypeFactory; +import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.GameObjectFactory; import net.sf.gridarta.gameobject.anim.AnimationObject; import net.sf.gridarta.gameobject.anim.DefaultAnimationObjects; @@ -138,6 +139,11 @@ } /** {@inheritDoc} */ + @Override + protected void addCollectables(@NotNull final List<Collectable> collectables) { + } + + /** {@inheritDoc} */ @NotNull @Override protected ScriptedEventFactory<GameObject> newScriptedEventFactory(@NotNull final ScriptArchUtils scriptArchUtils) { Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-11-01 11:03:31 UTC (rev 5636) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-11-01 11:14:48 UTC (rev 5637) @@ -56,6 +56,7 @@ import net.sf.gridarta.filter.FilterControl; import net.sf.gridarta.gameobject.AbstractArchetypeParser; import net.sf.gridarta.gameobject.ArchetypeFactory; +import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.GameObjectFactory; import net.sf.gridarta.gameobject.anim.AnimationObject; import net.sf.gridarta.gameobject.anim.DefaultAnimationObjects; @@ -179,6 +180,11 @@ /** {@inheritDoc} */ @NotNull + protected void addCollectables(@NotNull final List<Collectable> collectables) { + } + + /** {@inheritDoc} */ + @NotNull @Override protected ScriptedEventFactory<GameObject> newScriptedEventFactory(@NotNull final ScriptArchUtils scriptArchUtils) { return new DefaultScriptedEventFactory(scriptArchUtils, "sub_type"); Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-01 11:03:31 UTC (rev 5636) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-01 11:14:48 UTC (rev 5637) @@ -25,6 +25,7 @@ import java.io.FileReader; import java.io.IOException; import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; @@ -50,6 +51,7 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.ArchetypeFactory; import net.sf.gridarta.gameobject.ArchetypeSet; +import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gameobject.GameObjectFactory; import net.sf.gridarta.gameobject.anim.AnimationObject; @@ -399,7 +401,12 @@ log.error("Cannot read GameObjectMatchers.xml: " + ex.getMessage()); } validators = createMapValidators(globalSettings, gameObjectMatchers); - mainActions = new MainActions<G, A, R, V>(replaceDialogManager, this, mainView, globalSettings, validators, editTypes, archetypeSet, copyBuffer, animationObjects, ACTION_FACTORY, faceObjects, objectChooser, mapManager, mapViewManager); + final List<Collectable> collectables = new ArrayList<Collectable>(); + collectables.add(archetypeSet); + collectables.add(animationObjects); + collectables.add(faceObjects); + addCollectables(collectables); + mainActions = new MainActions<G, A, R, V>(replaceDialogManager, this, mainView, globalSettings, validators, editTypes, archetypeSet, copyBuffer, ACTION_FACTORY, objectChooser, mapManager, mapViewManager, collectables); final GameObjectMatcher floorMatcher = gameObjectMatchers.getMatcher("system_floor", "floor"); final GameObjectMatcher wallMatcher = gameObjectMatchers.getMatcher("system_wall", "wall"); final GameObjectMatcher monsterMatcher = gameObjectMatchers.getMatcherFatal("system_monster", "monster"); @@ -502,6 +509,12 @@ tmpMapManager.setFileControl(fileControl); } + /** + * Returns {@link Collectable} instances to use for collection. + * @param collectables the collection to add to + */ + protected abstract void addCollectables(@NotNull final List<Collectable> collectables); + @NotNull protected abstract ScriptedEventFactory<G> newScriptedEventFactory(@NotNull final ScriptArchUtils scriptArchUtils); Modified: trunk/src/app/net/sf/gridarta/gui/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-11-01 11:03:31 UTC (rev 5636) +++ trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-11-01 11:14:48 UTC (rev 5637) @@ -21,7 +21,6 @@ import java.awt.Component; import java.io.File; -import java.util.ArrayList; import java.util.List; import javax.swing.Action; import javax.swing.JFrame; @@ -38,8 +37,6 @@ import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.Collector; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gameobject.anim.AnimationObjects; -import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gui.map.FillUtils; import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapCursorListener; @@ -100,22 +97,20 @@ @NotNull private final CopyBuffer<G, A, R, V> copyBuffer; - /** The animation objects instance to use. */ - @NotNull - private final AnimationObjects<?> animationObjects; - /** The ActionFactory. */ @NotNull private final ActionFactory actionFactory; - /** The FaceObjects instance to use. */ - @NotNull - private final FaceObjects faceObjects; - /** The ObjectChooser instance to use. */ @NotNull private final ObjectChooser<G, A, R> objectChooser; + /** + * The {@link {@link Collectable}s to collect. + */ + @NotNull + private final List<Collectable> collectables; + /** Action called for "clear". */ private final Action aClear; @@ -330,14 +325,13 @@ * @param editTypes the edit types instance * @param archetypeSet the archetype set * @param copyBuffer the copy buffer instance - * @param animationObjects the animation object instance to use * @param actionFactory The action factory to create actions. - * @param faceObjects the FaceObjects instance to use * @param objectChooser the animation objects instance to use * @param mapManager the map manager instance * @param mapViewManager the map view manager instance + * @param collectables the collectables to collect */ - public MainActions(@NotNull final ReplaceDialogManager<G, A, R, V> replaceDialogManager, @NotNull final MainControl<G, A, R, V> mainControl, @NotNull final JFrame parent, @NotNull final GlobalSettings globalSettings, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final EditTypes editTypes, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final CopyBuffer<G, A, R, V> copyBuffer, @NotNull final AnimationObjects<?> animationObjects, @NotNull final ActionFactory actionFactory, @NotNull final FaceObjects faceObjects, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager) { + public MainActions(@NotNull final ReplaceDialogManager<G, A, R, V> replaceDialogManager, @NotNull final MainControl<G, A, R, V> mainControl, @NotNull final JFrame parent, @NotNull final GlobalSettings globalSettings, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final EditTypes editTypes, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final CopyBuffer<G, A, R, V> copyBuffer, @NotNull final ActionFactory actionFactory, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager, @NotNull final List<Collectable> collectables) { this.replaceDialogManager = replaceDialogManager; this.mainControl = mainControl; this.parent = parent; @@ -346,10 +340,9 @@ this.editTypes = editTypes; this.archetypeSet = archetypeSet; this.copyBuffer = copyBuffer; - this.animationObjects = animationObjects; this.actionFactory = actionFactory; - this.faceObjects = faceObjects; this.objectChooser = objectChooser; + this.collectables = collectables; aClear = actionFactory.createAction(true, "clear", this); aCut = actionFactory.createAction(true, "cut", this); aCopy = actionFactory.createAction(true, "copy", this); @@ -659,11 +652,7 @@ }; - final List<Collectable> collectables = new ArrayList<Collectable>(); collector = new Collector(collectArches); - collectables.add(archetypeSet); - collectables.add(animationObjects); - collectables.add(faceObjects); collector.setCollectables(collectables); collector.setCollectedDirectory(new File(globalSettings.getCollectedDirectory())); collector.start(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-01 11:53:25
|
Revision: 5638 http://gridarta.svn.sourceforge.net/gridarta/?rev=5638&view=rev Author: akirschbaum Date: 2008-11-01 11:53:15 +0000 (Sat, 01 Nov 2008) Log Message: ----------- Remove fully qualified class names. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-01 11:14:48 UTC (rev 5637) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-01 11:53:15 UTC (rev 5638) @@ -57,6 +57,7 @@ import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.GameObjectFactory; import net.sf.gridarta.gameobject.anim.AnimationObject; +import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.anim.DefaultAnimationObjects; import net.sf.gridarta.gameobject.face.DefaultFaceObjects; import net.sf.gridarta.gameobject.face.FaceObjectProviders; @@ -239,7 +240,7 @@ /** {@inheritDoc} */ @Override - protected AbstractArchetypeParser<GameObject, MapArchObject, Archetype> newArchetypeParser(final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final net.sf.gridarta.gameobject.anim.AnimationObjects<? extends AnimationObject> animationObjects, final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory) { + protected AbstractArchetypeParser<GameObject, MapArchObject, Archetype> newArchetypeParser(final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final AnimationObjects<? extends AnimationObject> animationObjects, final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory) { return new ArchetypeParser(gameObjectParser, archetypeChooserControl, animationObjects, archetypeSet, gameObjectFactory); } @@ -284,7 +285,7 @@ /** {@inheritDoc} */ @Override - protected void init4(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final net.sf.gridarta.gameobject.anim.AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { + protected void init4(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { new ArchetypeSetLoader(globalSettings, gameObjectParser, globalSettings.getCollectedDirectory(), archetypeSet, archetypeParser, editTypes, faceObjects, animationObjects, this).loadArchetypes(mainView); } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-11-01 11:14:48 UTC (rev 5637) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-11-01 11:53:15 UTC (rev 5638) @@ -59,6 +59,7 @@ import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.GameObjectFactory; import net.sf.gridarta.gameobject.anim.AnimationObject; +import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.anim.DefaultAnimationObjects; import net.sf.gridarta.gameobject.face.DefaultFaceObjects; import net.sf.gridarta.gameobject.face.FaceObjectProviders; @@ -279,7 +280,7 @@ /** {@inheritDoc} */ @Override - protected AbstractArchetypeParser<GameObject, MapArchObject, Archetype> newArchetypeParser(final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final net.sf.gridarta.gameobject.anim.AnimationObjects<? extends AnimationObject> animationObjects, final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory) { + protected AbstractArchetypeParser<GameObject, MapArchObject, Archetype> newArchetypeParser(final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final AnimationObjects<? extends AnimationObject> animationObjects, final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory) { return new ArchetypeParser(archetypeChooserControl, animationObjects, archetypeSet, gameObjectFactory); } @@ -325,7 +326,7 @@ /** {@inheritDoc} */ @Override - protected void init4(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final net.sf.gridarta.gameobject.anim.AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { + protected void init4(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { MultiPositionData.init(globalSettings.getConfigurationDirectory()); new ArchetypeSetLoader(globalSettings, gameObjectParser, globalSettings.getCollectedDirectory(), archetypeSet, archetypeParser, editTypes, faceObjects, animationObjects, this).loadArchetypes(mainView); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-01 12:01:03
|
Revision: 5640 http://gridarta.svn.sourceforge.net/gridarta/?rev=5640&view=rev Author: akirschbaum Date: 2008-11-01 12:00:58 +0000 (Sat, 01 Nov 2008) Log Message: ----------- Collect smoothface information into smooth file. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java trunk/src/app/net/sf/gridarta/utils/StringUtils.java Added Paths: ----------- trunk/crossfire/src/cfeditor/smoothface/ trunk/crossfire/src/cfeditor/smoothface/DuplicateSmoothFaceException.java trunk/crossfire/src/cfeditor/smoothface/SmoothFace.java trunk/crossfire/src/cfeditor/smoothface/SmoothFaces.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-11-01 11:53:42 UTC (rev 5639) +++ trunk/crossfire/ChangeLog 2008-11-01 12:00:58 UTC (rev 5640) @@ -1,5 +1,7 @@ 2008-11-01 Andreas Kirschbaum + * Collect smoothface information into smooth file. + * Add face/animation selector controls to game object attributes dialog. Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-01 11:53:42 UTC (rev 5639) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-01 12:00:58 UTC (rev 5640) @@ -38,6 +38,7 @@ import cfeditor.map.DefaultMapArchObjectFactory; import cfeditor.map.DefaultMapControlFactory; import cfeditor.map.MapArchObject; +import cfeditor.smoothface.SmoothFaces; import java.io.File; import java.util.List; import java.util.Map; @@ -132,6 +133,12 @@ private static final boolean PREFS_VALIDATOR_AUTO_DEFAULT = true; /** + * The {@link SmoothFaces} instance. + */ + @NotNull + private SmoothFaces smoothFaces; + + /** * Constructs the main controller and its model and view. * @throws RuntimeException If the controller cannot be initialized. */ @@ -142,6 +149,8 @@ /** {@inheritDoc} */ @Override protected void addCollectables(@NotNull final List<Collectable> collectables) { + smoothFaces = new SmoothFaces(); + collectables.add(smoothFaces); } /** {@inheritDoc} */ @@ -241,7 +250,7 @@ /** {@inheritDoc} */ @Override protected AbstractArchetypeParser<GameObject, MapArchObject, Archetype> newArchetypeParser(final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final AnimationObjects<? extends AnimationObject> animationObjects, final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory) { - return new ArchetypeParser(gameObjectParser, archetypeChooserControl, animationObjects, archetypeSet, gameObjectFactory); + return new ArchetypeParser(gameObjectParser, archetypeChooserControl, animationObjects, archetypeSet, gameObjectFactory, smoothFaces); } /** {@inheritDoc} */ Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2008-11-01 11:53:42 UTC (rev 5639) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2008-11-01 12:00:58 UTC (rev 5640) @@ -21,6 +21,9 @@ import cfeditor.gui.map.CMapViewBasic; import cfeditor.map.MapArchObject; +import cfeditor.smoothface.DuplicateSmoothFaceException; +import cfeditor.smoothface.SmoothFace; +import cfeditor.smoothface.SmoothFaces; import java.io.BufferedReader; import java.io.File; import java.io.IOException; @@ -33,6 +36,7 @@ import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.io.GameObjectParser; import net.sf.gridarta.io.PathManager; +import net.sf.gridarta.utils.StringUtils; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; @@ -75,6 +79,12 @@ @NotNull private final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory; + /** + * The {@link SmoothFaces} instance to update. + */ + @NotNull + private final SmoothFaces smoothFaces; + /** The archetype chooser to add parsed archetypes to. */ private final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl; @@ -86,13 +96,15 @@ * @param animationObjects the animation objects instance to use * @param archetypeSet the archetype set * @param gameObjectFactory the factory for creating game objects + * @param smoothFaces the smooth faces instance to update */ - public ArchetypeParser(final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final AnimationObjects<?> animationObjects, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory) { + public ArchetypeParser(final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final AnimationObjects<?> animationObjects, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SmoothFaces smoothFaces) { this.gameObjectParser = gameObjectParser; this.archetypeChooserControl = archetypeChooserControl; this.animationObjects = animationObjects; this.archetypeSet = archetypeSet; this.gameObjectFactory = gameObjectFactory; + this.smoothFaces = smoothFaces; } /** {@inheritDoc} */ @@ -330,6 +342,17 @@ archetype.setFaceName(faceName.length() == 0 ? null : faceName); } else if (thisLine.startsWith("editor_folder ")) { editorFolder = thisLine.substring(14).trim(); + } else if (thisLine.startsWith("smoothface ")) { + final String[] tmp = StringUtils.patternWhitespace.split(thisLine.substring(11)); + if (tmp.length != 2) { + log.warn(archetype.getArchetypeName() + ": invalid smoothface info: " + thisLine); + } else { + try { + smoothFaces.add(new SmoothFace(tmp[0], tmp[1])); + } catch (final DuplicateSmoothFaceException ex) { + log.warn(archetype.getArchetypeName() + ": duplicate smoothface info: " + thisLine); + } + } } else { archetype.addObjectText(thisLine); } Added: trunk/crossfire/src/cfeditor/smoothface/DuplicateSmoothFaceException.java =================================================================== --- trunk/crossfire/src/cfeditor/smoothface/DuplicateSmoothFaceException.java (rev 0) +++ trunk/crossfire/src/cfeditor/smoothface/DuplicateSmoothFaceException.java 2008-11-01 12:00:58 UTC (rev 5640) @@ -0,0 +1,43 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package cfeditor.smoothface; + +import org.jetbrains.annotations.NotNull; + +/** + * Thrown to indicate that a {@link SmoothFace} instance is not unique. + * @author Andreas Kirschbaum + */ +public class DuplicateSmoothFaceException extends Exception { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1; + + /** + * Creates a new instance. + * @param smoothFace the duplicate smooth face + */ + public DuplicateSmoothFaceException(@NotNull final SmoothFace smoothFace) { + super(smoothFace.getFace()); + } + +} // class DuplicateSmoothFaceException Property changes on: trunk/crossfire/src/cfeditor/smoothface/DuplicateSmoothFaceException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/crossfire/src/cfeditor/smoothface/SmoothFace.java =================================================================== --- trunk/crossfire/src/cfeditor/smoothface/SmoothFace.java (rev 0) +++ trunk/crossfire/src/cfeditor/smoothface/SmoothFace.java 2008-11-01 12:00:58 UTC (rev 5640) @@ -0,0 +1,70 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package cfeditor.smoothface; + +import org.jetbrains.annotations.NotNull; + +/** + * Smoothing information for one face name. + * @author Andreas Kirschbaum + */ +public class SmoothFace { + + /** + * The smoothed face. + */ + @NotNull + private final String face; + + /** + * The smooth information. + */ + @NotNull + private final String value; + + /** + * Creates a new instance. + * @param face the smoothed face + * @param value the smooth information + */ + public SmoothFace(@NotNull final String face, @NotNull final String value) { + this.face = face; + this.value = value; + } + + /** + * Returns the smoothed face. + * @return the smoothed face + */ + @NotNull + public String getFace() { + return face; + } + + /** + * Returns the smooth information. + * @return the smooth information + */ + @NotNull + public String getValue() { + return value; + } + +} // class SmoothFace Property changes on: trunk/crossfire/src/cfeditor/smoothface/SmoothFace.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/crossfire/src/cfeditor/smoothface/SmoothFaces.java =================================================================== --- trunk/crossfire/src/cfeditor/smoothface/SmoothFaces.java (rev 0) +++ trunk/crossfire/src/cfeditor/smoothface/SmoothFaces.java 2008-11-01 12:00:58 UTC (rev 5640) @@ -0,0 +1,88 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package cfeditor.smoothface; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.util.Map; +import java.util.TreeMap; +import net.sf.gridarta.gameobject.Collectable; +import net.sf.gridarta.utils.IOUtils; +import net.sf.japi.swing.misc.Progress; +import org.jetbrains.annotations.NotNull; + +/** + * Collection of all smoothing information. + * @author Andreas Kirschbaum + */ +public class SmoothFaces implements Collectable { + + /** + * The defined {@link SmoothFaces}. + */ + @NotNull + private final Map<String, SmoothFace> smoothFaces = new TreeMap<String, SmoothFace>(); + + /** {@inheritDoc} */ + public void collect(@NotNull final Progress progress, @NotNull final File collectedDirectory) throws IOException { + final FileOutputStream fos = new FileOutputStream(new File(collectedDirectory, "smooth")); + try { + final OutputStreamWriter osw = new OutputStreamWriter(fos, IOUtils.MAP_ENCODING); + try { + final BufferedWriter out = new BufferedWriter(osw); + try { + out.append("default_smoothed.111 sdefault.001\n"); + for (final Map.Entry<String, SmoothFace> e : smoothFaces.entrySet()) { + final SmoothFace smoothFace = e.getValue(); + out.append(smoothFace.getFace()).append(' ').append(smoothFace.getValue()).append('\n'); + } + } finally { + out.close(); + } + } finally { + osw.close(); + } + } finally { + fos.close(); + } + } + + /** + * Adds a {@link SmoothFace} instance. + * @param smoothFace the smooth face instance + * @throws DuplicateSmoothFaceException if the smooth face is not unique + */ + public void add(@NotNull final SmoothFace smoothFace) throws DuplicateSmoothFaceException { + final SmoothFace oldSmoothFace = smoothFaces.get(smoothFace.getFace()); + if (oldSmoothFace != null) { + if (oldSmoothFace.getValue().equals(smoothFace.getValue())) { + return; + } + + throw new DuplicateSmoothFaceException(smoothFace); + } + + smoothFaces.put(smoothFace.getFace(), smoothFace); + } + +} // class SmoothFaces Property changes on: trunk/crossfire/src/cfeditor/smoothface/SmoothFaces.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/utils/StringUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/utils/StringUtils.java 2008-11-01 11:53:42 UTC (rev 5639) +++ trunk/src/app/net/sf/gridarta/utils/StringUtils.java 2008-11-01 12:00:58 UTC (rev 5640) @@ -28,6 +28,9 @@ */ public class StringUtils { + /** Pattern to match whitespace. */ + public static final Pattern patternWhitespace = Pattern.compile("[\\x00-\\x09\\x0b\\x20]+"); + /** Pattern to match trailing whitespace. */ private static final Pattern patternTrailingWhitespace = Pattern.compile("[\\x00-\\x09\\x0b\\x20]+$"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-01 13:58:48
|
Revision: 5643 http://gridarta.svn.sourceforge.net/gridarta/?rev=5643&view=rev Author: akirschbaum Date: 2008-11-01 13:58:44 +0000 (Sat, 01 Nov 2008) Log Message: ----------- Make connection errors (connection without sink/source) highlight the affected game objects. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gui/ErrorListView.java trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java trunk/src/app/net/sf/gridarta/map/validation/GameObjectValidationError.java trunk/src/app/net/sf/gridarta/map/validation/GameObjectsValidationError.java trunk/src/app/net/sf/gridarta/map/validation/MapValidationError.java trunk/src/app/net/sf/gridarta/map/validation/SquareValidationError.java trunk/src/app/net/sf/gridarta/map/validation/ValidationError.java trunk/src/app/net/sf/gridarta/map/validation/checks/ConnectedInsideContainerError.java trunk/src/app/net/sf/gridarta/map/validation/checks/ConnectedPickableError.java trunk/src/app/net/sf/gridarta/map/validation/checks/ConnectionChecker.java trunk/src/app/net/sf/gridarta/map/validation/checks/ConnectionError.java trunk/src/app/net/sf/gridarta/map/validation/checks/ConnectionWithoutSinksError.java trunk/src/app/net/sf/gridarta/map/validation/checks/ConnectionWithoutSourcesError.java trunk/src/app/net/sf/gridarta/map/validation/checks/DoubleLayerChecker.java trunk/src/app/net/sf/gridarta/map/validation/checks/DoubleLayerError.java trunk/src/app/net/sf/gridarta/map/validation/checks/DoubleTypeChecker.java trunk/src/app/net/sf/gridarta/map/validation/checks/DoubleTypeError.java trunk/src/app/net/sf/gridarta/map/validation/checks/EnvironmentSensorSlayingError.java trunk/src/app/net/sf/gridarta/map/validation/checks/MobOutsideSpawnPointError.java trunk/src/app/net/sf/gridarta/map/validation/checks/SlayingError.java trunk/src/app/net/sf/gridarta/map/validation/checks/SysObjectNotOnLayerZeroError.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-11-01 12:04:39 UTC (rev 5642) +++ trunk/crossfire/ChangeLog 2008-11-01 13:58:44 UTC (rev 5643) @@ -1,5 +1,8 @@ 2008-11-01 Andreas Kirschbaum + * Make connection errors (connection without sink/source) + highlight the affected game objects. + * Collect smoothface information into smooth file. * Add face/animation selector controls to game object attributes Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-11-01 12:04:39 UTC (rev 5642) +++ trunk/daimonin/ChangeLog 2008-11-01 13:58:44 UTC (rev 5643) @@ -1,3 +1,8 @@ +2008-11-01 Andreas Kirschbaum + + * Make connection errors (connection without sink/source) + highlight the affected game objects. + 2008-10-31 Andreas Kirschbaum * Fix face tree collection. Modified: trunk/src/app/net/sf/gridarta/gui/ErrorListView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ErrorListView.java 2008-11-01 12:04:39 UTC (rev 5642) +++ trunk/src/app/net/sf/gridarta/gui/ErrorListView.java 2008-11-01 13:58:44 UTC (rev 5643) @@ -25,6 +25,7 @@ import java.awt.event.MouseEvent; import java.util.ArrayList; import java.util.IdentityHashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import javax.swing.DefaultListModel; @@ -208,15 +209,19 @@ } errorMsg.setText(error.getMessage()); - final G gameObject = error.getGameObject(); - if (gameObject != null) { + final Iterator<G> gameObjectIterator = error.getGameObjects().iterator(); + if (gameObjectIterator.hasNext()) { + final G gameObject = gameObjectIterator.next(); final G topContainer = gameObject.getTopContainer(); currentMapControl.getMapViewFrame().getMapViewBasic().getMapCursor().setLocation(new Point(topContainer.getMapX(), topContainer.getMapY())); selectedSquareView.setSelectedGameObject(gameObject); } else { - final MapSquare<G, A, R> mapSquare = error.getMapSquare(); - final Point location = mapSquare == null ? null : new Point(mapSquare.getMapX(), mapSquare.getMapY()); - currentMapControl.getMapViewFrame().getMapViewBasic().getMapCursor().setLocation(location); + final Iterator<MapSquare<G, A, R>> mapSquareIterator = error.getMapSquares().iterator(); + if (mapSquareIterator.hasNext()) { + final MapSquare<G, A, R> mapSquare = mapSquareIterator.next(); + final Point location = mapSquare == null ? null : new Point(mapSquare.getMapX(), mapSquare.getMapY()); + currentMapControl.getMapViewFrame().getMapViewBasic().getMapCursor().setLocation(location); + } } errorMsg.setCaretPosition(0); } Modified: trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java 2008-11-01 12:04:39 UTC (rev 5642) +++ trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java 2008-11-01 13:58:44 UTC (rev 5643) @@ -302,13 +302,11 @@ erroneousArchObjects.clear(); mapGrid.clearErrors(); for (final ValidationError<G, A, R> validationError : errors.getErrors()) { - final MapSquare<G, A, R> mapSquare = validationError.getMapSquare(); - final G archObject = validationError.getGameObject(); - if (mapSquare != null) { + for (final MapSquare<G, A, R> mapSquare : validationError.getMapSquares()) { erroneousMapSquares.put(mapSquare, validationError); mapGrid.setError(mapSquare.getMapX(), mapSquare.getMapY()); } - if (archObject != null) { + for (final G archObject : validationError.getGameObjects()) { erroneousArchObjects.put(archObject, validationError); final G topContainer = archObject.getTopContainer(); mapGrid.setError(topContainer.getMapX(), topContainer.getMapY()); Modified: trunk/src/app/net/sf/gridarta/map/validation/GameObjectValidationError.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/GameObjectValidationError.java 2008-11-01 12:04:39 UTC (rev 5642) +++ trunk/src/app/net/sf/gridarta/map/validation/GameObjectValidationError.java 2008-11-01 13:58:44 UTC (rev 5643) @@ -30,24 +30,13 @@ */ public class GameObjectValidationError<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends SquareValidationError<G, A, R> { - /** The GameObject which caused the error. */ - @NotNull - private final G gameObject; - /** * Create an GameObjectValidationError. * @param gameObject the GameObject on which the error occurred */ public GameObjectValidationError(@NotNull final G gameObject) { super(gameObject.getMapSquare()); - this.gameObject = gameObject; + addGameObject(gameObject); } - /** {@inheritDoc} */ - @NotNull - @Override - public G getGameObject() { - return gameObject; - } - } // class GameObjectValidationError Modified: trunk/src/app/net/sf/gridarta/map/validation/GameObjectsValidationError.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/GameObjectsValidationError.java 2008-11-01 12:04:39 UTC (rev 5642) +++ trunk/src/app/net/sf/gridarta/map/validation/GameObjectsValidationError.java 2008-11-01 13:58:44 UTC (rev 5643) @@ -19,10 +19,6 @@ package net.sf.gridarta.map.validation; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapArchObject; @@ -32,11 +28,8 @@ * Class for validation errors related to more than a single GameObject. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public class GameObjectsValidationError<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends SquareValidationError<G, A, R> implements Iterable<G> { +public class GameObjectsValidationError<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends SquareValidationError<G, A, R> { - /** The GameObjects which caused the error. */ - private final List<G> gameObjects = new ArrayList<G>(); - /** * Create an GameObjectValidationError. * @param mapSquare the square on which the error occurred @@ -44,20 +37,9 @@ */ public GameObjectsValidationError(final MapSquare<G, A, R> mapSquare, final G... gameObjects) { super(mapSquare); - this.gameObjects.addAll(Arrays.asList(gameObjects)); + for (final G gameObject : gameObjects) { + addGameObject(gameObject); + } } - /** - * Add another arch that is erroneous. - * @param gameObject erroneous arch - */ - public void addGameObject(final G gameObject) { - gameObjects.add(gameObject); - } - - /** {@inheritDoc} */ - public Iterator<G> iterator() { - return gameObjects.iterator(); - } - } // class GameObjectValidationError Modified: trunk/src/app/net/sf/gridarta/map/validation/MapValidationError.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/MapValidationError.java 2008-11-01 12:04:39 UTC (rev 5642) +++ trunk/src/app/net/sf/gridarta/map/validation/MapValidationError.java 2008-11-01 13:58:44 UTC (rev 5643) @@ -23,6 +23,7 @@ import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapModel; +import org.jetbrains.annotations.NotNull; /** * Base Class for validation errors on maps. Though you could use this class @@ -32,21 +33,12 @@ */ public class MapValidationError<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends ValidationError<G, A, R> { - /** The map on which the MapValidationError occurred. */ - private final MapModel<G, A, R> mapModel; - /** * Create a MapValidationError. * @param mapModel the map on which the error occurred */ - public MapValidationError(final MapModel<G, A, R> mapModel) { - this.mapModel = mapModel; + public MapValidationError(@NotNull final MapModel<G, A, R> mapModel) { + super(mapModel); } - /** {@inheritDoc} */ - @Override - public final MapModel<G, A, R> getMapModel() { - return mapModel; - } - } // class MapValidationError Modified: trunk/src/app/net/sf/gridarta/map/validation/SquareValidationError.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/SquareValidationError.java 2008-11-01 12:04:39 UTC (rev 5642) +++ trunk/src/app/net/sf/gridarta/map/validation/SquareValidationError.java 2008-11-01 13:58:44 UTC (rev 5643) @@ -30,44 +30,13 @@ */ public class SquareValidationError<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends MapValidationError<G, A, R> { - /** The MapSquare the error occurred on. */ - private final MapSquare<G, A, R> mapSquare; - /** * Create a SquareValidationError. * @param mapSquare the square on which the error occurred */ public SquareValidationError(final MapSquare<G, A, R> mapSquare) { super(mapSquare.getMapModel()); - this.mapSquare = mapSquare; + addMapSquare(mapSquare); } - /** {@inheritDoc} */ - @Override - public final MapSquare<G, A, R> getMapSquare() { - return mapSquare; - } - - /** - * Get the X coordinate of the square (proxy method). - * @return X coordinate of the square - */ - public final int getX() { - return mapSquare.getMapX(); - } - - /** - * Get the Y coordinate of the square (proxy method). - * @return Y coordinate of the square - */ - public final int getY() { - return mapSquare.getMapY(); - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return "[" + getX() + '|' + getY() + "] " + super.toString(); - } - } // class SquareValidationError Modified: trunk/src/app/net/sf/gridarta/map/validation/ValidationError.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/ValidationError.java 2008-11-01 12:04:39 UTC (rev 5642) +++ trunk/src/app/net/sf/gridarta/map/validation/ValidationError.java 2008-11-01 13:58:44 UTC (rev 5643) @@ -19,12 +19,16 @@ package net.sf.gridarta.map.validation; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapModel; import net.sf.gridarta.map.MapSquare; import net.sf.japi.swing.ActionFactory; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -39,28 +43,49 @@ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); /** Key. */ + @NotNull private final String key; /** + * The {@link MapModel} that caused the error. + */ + @NotNull + private final MapModel<G, A, R> mapModel; + + /** + * The {@link MapSquare}s that caused the error. + */ + private final List<MapSquare<G, A, R>> mapSquares = new ArrayList<MapSquare<G, A, R>>(0); + + /** + * The {@link GameObject}s that caused the error. + */ + private final List<G> gameObjects = new ArrayList<G>(0); + + /** * Create an AbstractMapValidator. The key is generated from the validator's * name, which must end on "Checker". + * @param mapModel the map model that caused the error * @throws IllegalArgumentException in case the validator's name does not * end on "Checker". */ - protected ValidationError() throws IllegalArgumentException { + protected ValidationError(@NotNull final MapModel<G, A, R> mapModel) throws IllegalArgumentException { final String name = getClass().getSimpleName(); if (!name.endsWith("Error")) { throw new IllegalArgumentException("Class name must end with \"Error\""); } key = "Validator." + name.substring(0, name.indexOf("Error")); + this.mapModel = mapModel; } /** * Create an AbstractMapValidator. * @param key Key + * @param mapModel the map model that caused the error */ - protected ValidationError(final String key) { + protected ValidationError(@NotNull final String key, @NotNull final MapModel<G, A, R> mapModel) { this.key = key; + this.mapModel = mapModel; } /** @@ -69,28 +94,52 @@ */ @Nullable public MapModel<G, A, R> getMapModel() { - return null; + return mapModel; } /** - * The MapSquare the error occurred on. - * @return MapSquare the error occurred on + * Returns the {@link MapSquare}s that caused the error. + * @return the map squares */ @Nullable - public MapSquare<G, A, R> getMapSquare() { - return null; + public List<MapSquare<G, A, R>> getMapSquares() { + return Collections.unmodifiableList(mapSquares); } /** - * The GameObject which caused the error. - * @return GameObject that caused the error + * Adds an errorneous {@link MapSquare}. + * @param mapSquare the erroneous map square */ - @Nullable - public G getGameObject() { - return null; + protected void addMapSquare(@NotNull final MapSquare<G, A, R> mapSquare) { + if (!mapSquares.contains(mapSquare)) { + if (mapSquare.getMapModel() != mapModel) { + throw new IllegalArgumentException(); + } + mapSquares.add(mapSquare); + } } /** + * Returns the {@link GameObject}s that caused the error. + * @return the game objects + */ + @NotNull + public List<G> getGameObjects() { + return Collections.unmodifiableList(gameObjects); + } + + /** + * Adds an errorneous {@link GameObject}. + * @param gameObject the erroneous game object + */ + protected void addGameObject(@NotNull final G gameObject) { + if (!gameObjects.contains(gameObject)) { + gameObjects.add(gameObject); + addMapSquare(gameObject.getMapSquare()); + } + } + + /** * A parameter string to be used in the error message. It can be accessed * with {4+<code>id</code>}. * @param id The error id. @@ -108,13 +157,18 @@ * message formatting */ public final String getMessage() { - final MapSquare<G, A, R> mapSquare = getMapSquare(); - final int x = mapSquare != null ? mapSquare.getMapX() : -1; - final int y = mapSquare != null ? mapSquare.getMapY() : -1; - final G archObject = getGameObject(); + final int x, y; + if (mapSquares.isEmpty()) { + x = 0; + y = 0; + } else { + final MapSquare<G, A, R> mapSquare = mapSquares.get(0); + x = mapSquare != null ? mapSquare.getMapX() : -1; + y = mapSquare != null ? mapSquare.getMapY() : -1; + } + final String archName = gameObjects.isEmpty() ? null : gameObjects.get(0).getBestName(); final String parameter0 = getParameter(0); final String parameter1 = getParameter(1); - final String archName = archObject != null ? archObject.getBestName() : null; return ACTION_FACTORY.format(key + ".msg", ACTION_FACTORY.getString(key + ".title"), x, y, archName, parameter0, parameter1); } @@ -122,7 +176,16 @@ @Nullable @Override public String toString() { - return ACTION_FACTORY.getString(key + ".title"); + final StringBuilder sb = new StringBuilder(); + if (!mapSquares.isEmpty()) { + final MapSquare<G, A, R> mapSquare = mapSquares.get(0); + sb.append('[').append(mapSquare.getMapX()).append('|').append(mapSquare.getMapY()).append("] "); + } else if (!gameObjects.isEmpty()) { + final G gameObject = gameObjects.get(0); + sb.append('[').append(gameObject.getBestName()).append("] "); + } + sb.append(ACTION_FACTORY.getString(key + ".title")); + return sb.toString(); } } // class ValidationError Modified: trunk/src/app/net/sf/gridarta/map/validation/checks/ConnectedInsideContainerError.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/checks/ConnectedInsideContainerError.java 2008-11-01 12:04:39 UTC (rev 5642) +++ trunk/src/app/net/sf/gridarta/map/validation/checks/ConnectedInsideContainerError.java 2008-11-01 13:58:44 UTC (rev 5643) @@ -43,7 +43,9 @@ /** {@inheritDoc} */ public void correct(final Component parentComponent) { // TODO: Ask user - getGameObject().remove(); + for (final G gameObject : getGameObjects()) { + gameObject.remove(); + } } } // class ConnectedInsideContainerError Modified: trunk/src/app/net/sf/gridarta/map/validation/checks/ConnectedPickableError.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/checks/ConnectedPickableError.java 2008-11-01 12:04:39 UTC (rev 5642) +++ trunk/src/app/net/sf/gridarta/map/validation/checks/ConnectedPickableError.java 2008-11-01 13:58:44 UTC (rev 5643) @@ -43,7 +43,9 @@ /** {@inheritDoc} */ public void correct(final Component parentComponent) { // TODO: Ask whether to clear connected attribute, remove or ignore - getGameObject().remove(); + for (final G gameObject : getGameObjects()) { + gameObject.remove(); + } } } // class ConnectedPickableError Modified: trunk/src/app/net/sf/gridarta/map/validation/checks/ConnectionChecker.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/checks/ConnectionChecker.java 2008-11-01 12:04:39 UTC (rev 5642) +++ trunk/src/app/net/sf/gridarta/map/validation/checks/ConnectionChecker.java 2008-11-01 13:58:44 UTC (rev 5643) @@ -214,10 +214,10 @@ return; } if (sourceGameObjects.isEmpty()) { - errorCollector.collect(new ConnectionWithoutSourcesError<G, A, R>(mapModel, connection)); + errorCollector.collect(new ConnectionWithoutSourcesError<G, A, R>(mapModel, connection, sinkGameObjects)); } if (sinkGameObjects.isEmpty()) { - errorCollector.collect(new ConnectionWithoutSinksError<G, A, R>(mapModel, connection)); + errorCollector.collect(new ConnectionWithoutSinksError<G, A, R>(mapModel, connection, sourceGameObjects)); } } Modified: trunk/src/app/net/sf/gridarta/map/validation/checks/ConnectionError.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/checks/ConnectionError.java 2008-11-01 12:04:39 UTC (rev 5642) +++ trunk/src/app/net/sf/gridarta/map/validation/checks/ConnectionError.java 2008-11-01 13:58:44 UTC (rev 5643) @@ -19,11 +19,13 @@ package net.sf.gridarta.map.validation.checks; +import java.util.Set; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapModel; import net.sf.gridarta.map.validation.MapValidationError; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -39,10 +41,14 @@ * Create a new instance. * @param mapModel The map on which the error occurred. * @param connected The erroneous connected value. + * @param gameObjects the erroneous game objects */ - protected ConnectionError(final MapModel<G, A, R> mapModel, final int connected) { + protected ConnectionError(final MapModel<G, A, R> mapModel, final int connected, @NotNull final Set<G> gameObjects) { super(mapModel); this.connected = connected; + for (final G gameObject : gameObjects) { + addGameObject(gameObject); + } } /** {@inheritDoc} */ Modified: trunk/src/app/net/sf/gridarta/map/validation/checks/ConnectionWithoutSinksError.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/checks/ConnectionWithoutSinksError.java 2008-11-01 12:04:39 UTC (rev 5642) +++ trunk/src/app/net/sf/gridarta/map/validation/checks/ConnectionWithoutSinksError.java 2008-11-01 13:58:44 UTC (rev 5643) @@ -19,10 +19,12 @@ package net.sf.gridarta.map.validation.checks; +import java.util.Set; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapModel; +import org.jetbrains.annotations.NotNull; /** * Validation error for a set of connected objects for which no sinks exist. @@ -34,9 +36,10 @@ * Create a new instance. * @param mapModel The map on which the error occurred. * @param connected The erroneous connected value. + * @param gameObjects the erroneous game objects */ - protected ConnectionWithoutSinksError(final MapModel<G, A, R> mapModel, final int connected) { - super(mapModel, connected); + protected ConnectionWithoutSinksError(final MapModel<G, A, R> mapModel, final int connected, @NotNull final Set<G> gameObjects) { + super(mapModel, connected, gameObjects); } } // class ConnectionWithoutSinksError Modified: trunk/src/app/net/sf/gridarta/map/validation/checks/ConnectionWithoutSourcesError.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/checks/ConnectionWithoutSourcesError.java 2008-11-01 12:04:39 UTC (rev 5642) +++ trunk/src/app/net/sf/gridarta/map/validation/checks/ConnectionWithoutSourcesError.java 2008-11-01 13:58:44 UTC (rev 5643) @@ -19,10 +19,12 @@ package net.sf.gridarta.map.validation.checks; +import java.util.Set; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapModel; +import org.jetbrains.annotations.NotNull; /** * Validation error for a set of connected objects for which no sources exist. @@ -34,9 +36,10 @@ * Create a new instance. * @param mapModel The map on which the error occurred. * @param connected The erroneous connected value. + * @param gameObjects the erroneous game objects */ - protected ConnectionWithoutSourcesError(final MapModel<G, A, R> mapModel, final int connected) { - super(mapModel, connected); + protected ConnectionWithoutSourcesError(final MapModel<G, A, R> mapModel, final int connected, @NotNull final Set<G> gameObjects) { + super(mapModel, connected, gameObjects); } } // class ConnectionWithoutSourcesError Modified: trunk/src/app/net/sf/gridarta/map/validation/checks/DoubleLayerChecker.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/checks/DoubleLayerChecker.java 2008-11-01 12:04:39 UTC (rev 5642) +++ trunk/src/app/net/sf/gridarta/map/validation/checks/DoubleLayerChecker.java 2008-11-01 13:58:44 UTC (rev 5643) @@ -52,7 +52,7 @@ errorCollector.collect(error); } else { assert o instanceof DoubleLayerError; - ((GameObjectsValidationError<G, A, R>) o).addGameObject(archObject); + ((DoubleLayerError<G, A, R>) o).addGameObject(archObject); } } else { layers.put(layer, archObject); Modified: trunk/src/app/net/sf/gridarta/map/validation/checks/DoubleLayerError.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/checks/DoubleLayerError.java 2008-11-01 12:04:39 UTC (rev 5642) +++ trunk/src/app/net/sf/gridarta/map/validation/checks/DoubleLayerError.java 2008-11-01 13:58:44 UTC (rev 5643) @@ -26,6 +26,7 @@ import net.sf.gridarta.map.MapSquare; import net.sf.gridarta.map.validation.CorrectableError; import net.sf.gridarta.map.validation.GameObjectsValidationError; +import org.jetbrains.annotations.NotNull; /** * Validation error that's used when the DoubleLayerChecker detected a possible @@ -49,4 +50,10 @@ // Then delete all arches except the selected one. } + /** {@inheritDoc} */ + @Override + public void addGameObject(@NotNull final G gameObject) { + super.addGameObject(gameObject); + } + } // class DoubleLayerError Modified: trunk/src/app/net/sf/gridarta/map/validation/checks/DoubleTypeChecker.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/checks/DoubleTypeChecker.java 2008-11-01 12:04:39 UTC (rev 5642) +++ trunk/src/app/net/sf/gridarta/map/validation/checks/DoubleTypeChecker.java 2008-11-01 13:58:44 UTC (rev 5643) @@ -27,8 +27,8 @@ import net.sf.gridarta.map.MapSquare; import net.sf.gridarta.map.validation.AbstractValidator; import net.sf.gridarta.map.validation.ErrorCollector; -import net.sf.gridarta.map.validation.GameObjectsValidationError; import net.sf.gridarta.map.validation.SquareValidator; +import net.sf.gridarta.map.validation.ValidationError; /** * A SquareValidator to assert that there are no two arches of the same type on @@ -50,7 +50,7 @@ errorCollector.collect(error); } else { assert o instanceof DoubleTypeError; - ((GameObjectsValidationError<G, A, R>) o).addGameObject(gameObject); + ((DoubleTypeError<G, A, R>) o).addGameObject(gameObject); } } else { typeNumbers.put(typeNo, gameObject); Modified: trunk/src/app/net/sf/gridarta/map/validation/checks/DoubleTypeError.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/checks/DoubleTypeError.java 2008-11-01 12:04:39 UTC (rev 5642) +++ trunk/src/app/net/sf/gridarta/map/validation/checks/DoubleTypeError.java 2008-11-01 13:58:44 UTC (rev 5643) @@ -26,6 +26,7 @@ import net.sf.gridarta.map.MapSquare; import net.sf.gridarta.map.validation.CorrectableError; import net.sf.gridarta.map.validation.GameObjectsValidationError; +import org.jetbrains.annotations.NotNull; /** * Validation error that's used when the DoubleTypeChecker detected a possible @@ -49,4 +50,10 @@ // Then delete all arches except the selected one. } + /** {@inheritDoc} */ + @Override + public void addGameObject(@NotNull final G gameObject) { + super.addGameObject(gameObject); + } + } // class DoubleTypeError Modified: trunk/src/app/net/sf/gridarta/map/validation/checks/EnvironmentSensorSlayingError.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/checks/EnvironmentSensorSlayingError.java 2008-11-01 12:04:39 UTC (rev 5642) +++ trunk/src/app/net/sf/gridarta/map/validation/checks/EnvironmentSensorSlayingError.java 2008-11-01 13:58:44 UTC (rev 5643) @@ -44,7 +44,9 @@ /** {@inheritDoc} */ public void correct(final Component parentComponent) { // TODO: Ask user - getGameObject().remove(); + for (final G gameObject : getGameObjects()) { + gameObject.remove(); + } } } // class EnvironmentSensorSlayingError Modified: trunk/src/app/net/sf/gridarta/map/validation/checks/MobOutsideSpawnPointError.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/checks/MobOutsideSpawnPointError.java 2008-11-01 12:04:39 UTC (rev 5642) +++ trunk/src/app/net/sf/gridarta/map/validation/checks/MobOutsideSpawnPointError.java 2008-11-01 13:58:44 UTC (rev 5643) @@ -42,7 +42,9 @@ /** {@inheritDoc} */ public void correct(final Component parentComponent) { - getGameObject().remove(); + for (final G gameObject : getGameObjects()) { + gameObject.remove(); + } } } // class MobOutsideSpawnPointError Modified: trunk/src/app/net/sf/gridarta/map/validation/checks/SlayingError.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/checks/SlayingError.java 2008-11-01 12:04:39 UTC (rev 5642) +++ trunk/src/app/net/sf/gridarta/map/validation/checks/SlayingError.java 2008-11-01 13:58:44 UTC (rev 5643) @@ -44,7 +44,9 @@ /** {@inheritDoc} */ public void correct(final Component parentComponent) { // TODO: Ask user - getGameObject().remove(); + for (final G gameObject : getGameObjects()) { + gameObject.remove(); + } } } // class SlayingError Modified: trunk/src/app/net/sf/gridarta/map/validation/checks/SysObjectNotOnLayerZeroError.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/checks/SysObjectNotOnLayerZeroError.java 2008-11-01 12:04:39 UTC (rev 5642) +++ trunk/src/app/net/sf/gridarta/map/validation/checks/SysObjectNotOnLayerZeroError.java 2008-11-01 13:58:44 UTC (rev 5643) @@ -44,7 +44,9 @@ /** {@inheritDoc} */ public void correct(final Component parentComponent) { // TODO: Ask user - getGameObject().addObjectText("layer 0"); + for (final G gameObject : getGameObjects()) { + gameObject.addObjectText("layer 0"); + } } } // class SysObjectNotOnLayerZeroError This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-02 14:20:12
|
Revision: 5649 http://gridarta.svn.sourceforge.net/gridarta/?rev=5649&view=rev Author: akirschbaum Date: 2008-11-02 14:20:09 +0000 (Sun, 02 Nov 2008) Log Message: ----------- Make sure all MapModel instances initially get valid edit types. Modified Paths: -------------- trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/DefaultMapManager.java trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java trunk/src/app/net/sf/gridarta/map/MapControlFactory.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java 2008-11-02 13:52:33 UTC (rev 5648) +++ trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java 2008-11-02 14:20:09 UTC (rev 5649) @@ -25,6 +25,7 @@ import java.awt.Component; import java.io.File; import java.util.List; +import net.sf.gridarta.EditTypes; import net.sf.gridarta.MapImageCache; import net.sf.gridarta.Size2D; import net.sf.gridarta.autojoin.AutojoinLists; @@ -110,6 +111,10 @@ @NotNull private GameObjectMatcher exitTypeGameObjectMatcher; + /** The edit types. */ + @NotNull + private EditTypes editTypes = null; + /** * Creates a new instance. * @param mapReaderFactory the map reader factory to use @@ -135,10 +140,19 @@ this.exitTypeGameObjectMatcher = exitTypeGameObjectMatcher; } + /** + * Sets the edit types instance to use. + * @param editTypes the edit types + */ + @Deprecated + public void setEditTypes(@NotNull final EditTypes editTypes) { + this.editTypes = editTypes; + } + /** {@inheritDoc} */ @NotNull public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControl(@NotNull final Component parent, @Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @NotNull final String mapName, @Nullable final File file) { - final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapViewFactory, mapArchObjectParserFactory, gameObjectParser, rendererFactory, parent, autojoinLists, mapImageCache, objects, mapArchObject, false, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); + final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapViewFactory, mapArchObjectParserFactory, gameObjectParser, rendererFactory, parent, autojoinLists, mapImageCache, objects, mapArchObject, false, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions, editTypes.getEditType()); mapControl.setMapFile(file); mapControl.setMapFileName(mapName); return mapControl; @@ -150,7 +164,7 @@ final MapArchObject mapArchObject = mapArchObjectFactory.newMapArchObject(true); mapArchObject.setMapSize(mapSize); mapArchObject.setMapName(pickmapName); - final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapViewFactory, mapArchObjectParserFactory, gameObjectParser, rendererFactory, parent, autojoinLists, mapImageCache, null, mapArchObject, true, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); + final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapViewFactory, mapArchObjectParserFactory, gameObjectParser, rendererFactory, parent, autojoinLists, mapImageCache, null, mapArchObject, true, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions, editTypes.getEditType()); mapControl.setMapFile(file); mapControl.setMapFileName(file.getPath()); mapControl.resetModified(); @@ -160,7 +174,7 @@ /** {@inheritDoc} */ @NotNull public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newPickmapControl(@NotNull final Component parent, @Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @NotNull final File file) { - final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapViewFactory, mapArchObjectParserFactory, gameObjectParser, rendererFactory, parent, autojoinLists, mapImageCache, objects, mapArchObject, true, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); + final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapViewFactory, mapArchObjectParserFactory, gameObjectParser, rendererFactory, parent, autojoinLists, mapImageCache, objects, mapArchObject, true, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions, editTypes.getEditType()); mapControl.setMapFile(file); mapControl.setMapFileName(file.getPath()); mapControl.resetModified(); Modified: trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java 2008-11-02 13:52:33 UTC (rev 5648) +++ trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java 2008-11-02 14:20:09 UTC (rev 5649) @@ -25,6 +25,7 @@ import java.awt.Component; import java.io.File; import java.util.List; +import net.sf.gridarta.EditTypes; import net.sf.gridarta.MapImageCache; import net.sf.gridarta.Size2D; import net.sf.gridarta.autojoin.AutojoinLists; @@ -110,6 +111,10 @@ @NotNull private GameObjectMatcher exitTypeGameObjectMatcher; + /** The edit types. */ + @NotNull + private EditTypes editTypes = null; + /** * Creates a new instance. * @param mapReaderFactory the map reader factory to use @@ -135,10 +140,19 @@ this.exitTypeGameObjectMatcher = exitTypeGameObjectMatcher; } + /** + * Sets the edit types instance to use. + * @param editTypes the edit types + */ + @Deprecated + public void setEditTypes(@NotNull final EditTypes editTypes) { + this.editTypes = editTypes; + } + /** {@inheritDoc} */ @NotNull public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControl(@NotNull final Component parent, @Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @NotNull final String mapName, @Nullable final File file) { - final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapViewFactory, mapArchObjectParserFactory, gameObjectParser, rendererFactory, parent, autojoinLists, mapImageCache, objects, mapArchObject, false, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); + final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapViewFactory, mapArchObjectParserFactory, gameObjectParser, rendererFactory, parent, autojoinLists, mapImageCache, objects, mapArchObject, false, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions, editTypes.getEditType()); mapControl.setMapFile(file); mapControl.setMapFileName(mapName); return mapControl; @@ -151,7 +165,7 @@ mapArchObject.setMapSize(mapSize); mapArchObject.setMapName(pickmapName); mapArchObject.setDifficulty(1); - final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapViewFactory, mapArchObjectParserFactory, gameObjectParser, rendererFactory, parent, autojoinLists, mapImageCache, null, mapArchObject, true, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); + final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapViewFactory, mapArchObjectParserFactory, gameObjectParser, rendererFactory, parent, autojoinLists, mapImageCache, null, mapArchObject, true, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions, editTypes.getEditType()); mapControl.setMapFile(file); mapControl.setMapFileName(file.getPath()); mapControl.resetModified(); @@ -162,7 +176,7 @@ @NotNull public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newPickmapControl(@NotNull final Component parent, @Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @NotNull final File file) { mapArchObject.setDifficulty(1); - final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapViewFactory, mapArchObjectParserFactory, gameObjectParser, rendererFactory, parent, autojoinLists, mapImageCache, objects, mapArchObject, true, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); + final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapViewFactory, mapArchObjectParserFactory, gameObjectParser, rendererFactory, parent, autojoinLists, mapImageCache, objects, mapArchObject, true, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions, editTypes.getEditType()); mapControl.setMapFile(file); mapControl.setMapFileName(file.getPath()); mapControl.resetModified(); Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-02 13:52:33 UTC (rev 5648) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-02 14:20:09 UTC (rev 5649) @@ -341,10 +341,10 @@ final DefaultMapReaderFactory<G, A, R, V> mapReaderFactory = new DefaultMapReaderFactory<G, A, R, V>(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory); final MapControlFactory<G, A, R, V> mapControlFactory = newMapControlFactory(mapReaderFactory, mapArchObjectFactory, mapArchObjectParserFactory); final DefaultMapManager<G, A, R, V> tmpMapManager = new DefaultMapManager<G, A, R, V>(key, mapReaderFactory, mapControlFactory, globalSettings); + mapManager = tmpMapManager; final EditTypes editTypes = new EditTypes(tmpMapManager); mapReaderFactory.setEditTypes(editTypes); - tmpMapManager.setEditTypes(editTypes); - mapManager = tmpMapManager; + mapControlFactory.setEditTypes(editTypes); this.rendererFactory = rendererFactory; globalSettings.readGlobalSettings(); ScriptedEventEditor.setGlobalSettings(globalSettings); Modified: trunk/src/app/net/sf/gridarta/DefaultMapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-11-02 13:52:33 UTC (rev 5648) +++ trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-11-02 14:20:09 UTC (rev 5649) @@ -83,10 +83,6 @@ @NotNull private final MapControlFactory<G, A, R, V> mapControlFactory; - /** The edit types. */ - @NotNull - private EditTypes editTypes = null; - /** The recent manager. */ private RecentManager recentManager = null; @@ -128,15 +124,6 @@ } /** - * Sets the edit types instance to use. - * @param editTypes the edit types - */ - @Deprecated - public void setEditTypes(@NotNull final EditTypes editTypes) { - this.editTypes = editTypes; - } - - /** * Sets the parent component for dialog windows. * @param parent the parent component */ @@ -263,7 +250,6 @@ final MapControl<G, A, R, V> mapControl = newMap(decoder.getGameObjects(), decoder.getMapArchObject(), file, file.getPath()); try { - mapControl.getMapModel().setActiveEditType(editTypes.getEditType()); mapControl.resetModified(); recentManager.addRecent(mapControl.getMapModel().getMapArchObject().getMapDisplayName(), file.toString()); Modified: trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java 2008-11-02 13:52:33 UTC (rev 5648) +++ trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java 2008-11-02 14:20:09 UTC (rev 5649) @@ -177,8 +177,9 @@ * @param exitTypeGameObjectMatcher the matcher to select exit objects * @param archetypeChooserModel the archeype chooser model to use * @param mapActions the map actions to use + * @param activeEditType the active edit types */ - public DefaultMapControl(@NotNull final MapViewFactory<G, A, R, V> mapViewFactory, @NotNull final MapArchObjectParserFactory<A> mapArchObjectParserFactory, @NotNull final GameObjectParser<G, A, R> gameObjectParser, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final Component parent, @NotNull final AutojoinLists<G, A, R> autojoinLists, @NotNull final MapImageCache<G, A, R, V> mapImageCache, @Nullable final List<G> objects, @NotNull final A mapArchObject, final boolean isPickmap, @Nullable final GameObjectMatcher exitTypeGameObjectMatcher, @NotNull final ArchetypeChooserModel<G, A, R, V> archetypeChooserModel, @NotNull final MapActions mapActions) { + public DefaultMapControl(@NotNull final MapViewFactory<G, A, R, V> mapViewFactory, @NotNull final MapArchObjectParserFactory<A> mapArchObjectParserFactory, @NotNull final GameObjectParser<G, A, R> gameObjectParser, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final Component parent, @NotNull final AutojoinLists<G, A, R> autojoinLists, @NotNull final MapImageCache<G, A, R, V> mapImageCache, @Nullable final List<G> objects, @NotNull final A mapArchObject, final boolean isPickmap, @Nullable final GameObjectMatcher exitTypeGameObjectMatcher, @NotNull final ArchetypeChooserModel<G, A, R, V> archetypeChooserModel, @NotNull final MapActions mapActions, final int activeEditType) { this.mapViewFactory = mapViewFactory; this.mapArchObjectParserFactory = mapArchObjectParserFactory; this.gameObjectParser = gameObjectParser; @@ -187,7 +188,7 @@ this.mapImageCache = mapImageCache; this.isPickmap = isPickmap; // we create model (= data) - mapModel = new DefaultMapModel<G, A, R>(parent, autojoinLists, this, objects, mapArchObject, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); + mapModel = new DefaultMapModel<G, A, R>(parent, autojoinLists, this, objects, mapArchObject, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions, activeEditType); mapModel.addMapModelListener(mapModelListener); } Modified: trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-11-02 13:52:33 UTC (rev 5648) +++ trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-11-02 14:20:09 UTC (rev 5649) @@ -168,8 +168,9 @@ * @param exitTypeGameObjectMatcher the matcher for selecting exit objects * @param archetypeChooserModel the archetype chooser control * @param mapActions the map actions to use + * @param activeEditType the active edit types */ - public DefaultMapModel(@NotNull final Component parent, @NotNull final AutojoinLists<G, A, R> autojoinLists, @NotNull final MapControl<G, A, R, ?> mapControl, @Nullable final List<G> objects, @NotNull final A mapArchObject, @Nullable final GameObjectMatcher exitTypeGameObjectMatcher, @NotNull final ArchetypeChooserModel<G, A, R, ?> archetypeChooserModel, @NotNull final MapActions mapActions) { + public DefaultMapModel(@NotNull final Component parent, @NotNull final AutojoinLists<G, A, R> autojoinLists, @NotNull final MapControl<G, A, R, ?> mapControl, @Nullable final List<G> objects, @NotNull final A mapArchObject, @Nullable final GameObjectMatcher exitTypeGameObjectMatcher, @NotNull final ArchetypeChooserModel<G, A, R, ?> archetypeChooserModel, @NotNull final MapActions mapActions, final int activeEditType) { this.mapControl = mapControl; this.mapArchObject = mapArchObject; this.parent = parent; @@ -177,6 +178,7 @@ this.archetypeChooserModel = archetypeChooserModel; this.exitTypeGameObjectMatcher = exitTypeGameObjectMatcher; this.mapActions = mapActions; + this.activeEditType = activeEditType; mapSize = mapArchObject.getMapSize(); mapGrid = new MapSquare[mapSize.getWidth()][mapSize.getHeight()]; beginTransaction("init"); Modified: trunk/src/app/net/sf/gridarta/map/MapControlFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapControlFactory.java 2008-11-02 13:52:33 UTC (rev 5648) +++ trunk/src/app/net/sf/gridarta/map/MapControlFactory.java 2008-11-02 14:20:09 UTC (rev 5649) @@ -25,6 +25,7 @@ import java.util.List; import net.sf.gridarta.MapImageCache; import net.sf.gridarta.Size2D; +import net.sf.gridarta.EditTypes; import net.sf.gridarta.autojoin.AutojoinLists; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; @@ -102,4 +103,7 @@ @NotNull MapControl<G, A, R, V> newPickmapControl(@NotNull Component parent, @NotNull File file) throws IOException; + @Deprecated + void setEditTypes(final EditTypes editTypes); + } // interface MapControlFactory Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-11-02 13:52:33 UTC (rev 5648) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-11-02 14:20:09 UTC (rev 5649) @@ -38,6 +38,7 @@ import net.sf.gridarta.MapImageCache; import net.sf.gridarta.MapManager; import net.sf.gridarta.Size2D; +import net.sf.gridarta.EditTypes; import net.sf.gridarta.autojoin.AutojoinLists; import net.sf.gridarta.gameobject.AbstractArchetypeSet; import net.sf.gridarta.gameobject.Archetype; @@ -418,8 +419,8 @@ final GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectFactory = new TestGameObjectFactory(); final GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParser = new TestGameObjectParser(gameObjectFactory); final MapViewFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapViewFactory = new TestMapViewFactory(); - final MapControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapControl = new DefaultMapControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(mapViewFactory, mapArchObjectParserFactory, gameObjectParser, rendererFactory, new JPanel(), autojoinLists, mapImageCache, null, mapArchObject, false, null, archetypeChooserModel, mapActions); - mapModel = new DefaultMapModel<TestGameObject, TestMapArchObject, TestArchetype>(new JPanel(), autojoinLists, mapControl, null, mapArchObject, null, archetypeChooserModel, mapActions); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapControl = new DefaultMapControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(mapViewFactory, mapArchObjectParserFactory, gameObjectParser, rendererFactory, new JPanel(), autojoinLists, mapImageCache, null, mapArchObject, false, null, archetypeChooserModel, mapActions, 0); + mapModel = new DefaultMapModel<TestGameObject, TestMapArchObject, TestArchetype>(new JPanel(), autojoinLists, mapControl, null, mapArchObject, null, archetypeChooserModel, mapActions, 0); result.setLength(0); mapModel.addMapModelListener(mapModelListener); @@ -931,6 +932,11 @@ throw new AssertionError(); } + /** {@inheritDoc} */ + public void setEditTypes(final EditTypes editTypes) { + throw new AssertionError(); + } + } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-02 14:35:49
|
Revision: 5651 http://gridarta.svn.sourceforge.net/gridarta/?rev=5651&view=rev Author: akirschbaum Date: 2008-11-02 14:35:47 +0000 (Sun, 02 Nov 2008) Log Message: ----------- Remove duplicate initialization. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-11-02 14:34:22 UTC (rev 5650) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-11-02 14:35:47 UTC (rev 5651) @@ -88,7 +88,6 @@ protected GameObject clone() { try { final GameObject clone = (GameObject) super.clone(); - clone.objectText = new StringBuilder(getObjectText()); clone.setMapX(-1); clone.setMapY(-1); clone.multi = null; Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-11-02 14:34:22 UTC (rev 5650) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-11-02 14:35:47 UTC (rev 5651) @@ -141,7 +141,6 @@ protected GameObject clone() { try { final GameObject clone = (GameObject) super.clone(); - clone.objectText = new StringBuilder(getObjectText()); clone.setMapX(-1); clone.setMapY(-1); clone.multi = null; Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-11-02 14:34:22 UTC (rev 5650) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-11-02 14:35:47 UTC (rev 5651) @@ -133,7 +133,7 @@ * createClone() any longer. */ @NotNull - protected StringBuilder objectText = new StringBuilder(); + private StringBuilder objectText = new StringBuilder(); /** * The msgText. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-02 14:39:29
|
Revision: 5652 http://gridarta.svn.sourceforge.net/gridarta/?rev=5652&view=rev Author: akirschbaum Date: 2008-11-02 14:39:26 +0000 (Sun, 02 Nov 2008) Log Message: ----------- Make fields private. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-11-02 14:35:47 UTC (rev 5651) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-11-02 14:39:26 UTC (rev 5652) @@ -161,8 +161,8 @@ final GameObject arch = new GameObject(); arch.setArchetypeName(archetypeName); arch.setArchetype(getArchetype()); - arch.setMultiX(multiX); - arch.setMultiY(multiY); + arch.setMultiX(getMultiX()); + arch.setMultiY(getMultiY()); arch.setObjectFace(); arch.setDirection(getDirection()); return arch; Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-11-02 14:35:47 UTC (rev 5651) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-11-02 14:39:26 UTC (rev 5652) @@ -212,8 +212,8 @@ final GameObject arch = new GameObject(); arch.setArchetypeName(archetypeName); arch.setArchetype(getArchetype()); - arch.setMultiX(multiX); - arch.setMultiY(multiY); + arch.setMultiX(getMultiX()); + arch.setMultiY(getMultiY()); arch.setLowestPart(isLowestPart); arch.setMultiPartNr(multiPartNr); arch.setObjectFace(); Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-11-02 14:35:47 UTC (rev 5651) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-11-02 14:39:26 UTC (rev 5652) @@ -161,13 +161,13 @@ * The x-distance of this part to the head part. Set to zero for single-part * objects. */ - protected int multiX = 0; + private int multiX = 0; /** * The y-distance of this part to the head part. Set to zero for single-part * objects. */ - protected int multiY = 0; + private int multiY = 0; /** Data for multitile-arches. Stays null for singlesquare-arches. */ @Nullable This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-02 15:01:30
|
Revision: 5653 http://gridarta.svn.sourceforge.net/gridarta/?rev=5653&view=rev Author: akirschbaum Date: 2008-11-02 15:01:24 +0000 (Sun, 02 Nov 2008) Log Message: ----------- Make sure every GameObject instance has an archetype name. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java trunk/crossfire/src/cfeditor/gameobject/DefaultGameObjectFactory.java trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/crossfire/src/cfeditor/gameobject/UndefinedArchetype.java trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java trunk/daimonin/src/daieditor/gameobject/DefaultGameObjectFactory.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gameobject/UndefinedArchetype.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/GameObjectFactory.java trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2008-11-02 14:39:26 UTC (rev 5652) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2008-11-02 15:01:24 UTC (rev 5653) @@ -112,7 +112,7 @@ // start with new clean GameObject instance @Nullable GameObject archetype; if (prototype == null) { - archetype = gameObjectFactory.newGameObject(); + archetype = gameObjectFactory.newGameObject(""); // XXX: undefined archetype name } else { archetype = prototype.createClone(0, 0); } @@ -168,7 +168,9 @@ archmore = true; } else if (thisLine.startsWith("Object ")) { if (archetype == null) { - archetype = gameObjectFactory.newGameObject(); + archetype = gameObjectFactory.newGameObject(archName != null ? archName : thisLine.substring(7)); + } else { + archetype.setArchetypeName(archName != null ? archName : thisLine.substring(7)); } parsearch = true; @@ -176,12 +178,6 @@ firstArch = null; } - if (archName == null) { - archetype.setArchetypeName(thisLine.substring(7)); - } else { - archetype.setArchetypeName(archName); - } - editorFolder = null; } } else { Modified: trunk/crossfire/src/cfeditor/gameobject/DefaultGameObjectFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/DefaultGameObjectFactory.java 2008-11-02 14:39:26 UTC (rev 5652) +++ trunk/crossfire/src/cfeditor/gameobject/DefaultGameObjectFactory.java 2008-11-02 15:01:24 UTC (rev 5653) @@ -31,8 +31,8 @@ /** {@inheritDoc} */ @NotNull - public GameObject newGameObject() { - return new GameObject(); + public GameObject newGameObject(@NotNull final String archetypeName) { + return new GameObject(archetypeName); } } // class DefaultGameObjectFactory Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-11-02 14:39:26 UTC (rev 5652) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-11-02 15:01:24 UTC (rev 5653) @@ -47,6 +47,14 @@ @NotNull private String loreText = ""; // lore text buffer + /** + * Creates a new instance. + * @param archetypeName the name of the base archetype + */ + public GameObject(@NotNull final String archetypeName) { + super(archetypeName); + } + /** {@inheritDoc} */ @Override public void propagateElevation(@NotNull final GameObject gameObject) { @@ -158,8 +166,7 @@ if (!isArchetype()) { return getArchetype().createGameObject(); } - final GameObject arch = new GameObject(); - arch.setArchetypeName(archetypeName); + final GameObject arch = new GameObject(getArchetypeName()); arch.setArchetype(getArchetype()); arch.setMultiX(getMultiX()); arch.setMultiY(getMultiY()); Modified: trunk/crossfire/src/cfeditor/gameobject/UndefinedArchetype.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/UndefinedArchetype.java 2008-11-02 14:39:26 UTC (rev 5652) +++ trunk/crossfire/src/cfeditor/gameobject/UndefinedArchetype.java 2008-11-02 15:01:24 UTC (rev 5653) @@ -36,7 +36,7 @@ * @param archetypeName the archetype name */ public UndefinedArchetype(@NotNull final String archetypeName) { - setArchetypeName(archetypeName); + super(archetypeName); setTypeNo(0); setIsArchetype(); setEditorFolder("intern"); Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2008-11-02 14:39:26 UTC (rev 5652) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2008-11-02 15:01:24 UTC (rev 5653) @@ -94,7 +94,7 @@ // start with new clean GameObject instance @Nullable GameObject archetype; if (prototype == null) { - archetype = gameObjectFactory.newGameObject(); + archetype = gameObjectFactory.newGameObject(""); // XXX: undefined archetype name } else { archetype = prototype.createClone(0, 0); } @@ -150,7 +150,9 @@ archmore = true; } else if (thisLine.startsWith("Object ") || thisLine.equals("Object")) { if (archetype == null) { - archetype = gameObjectFactory.newGameObject(); + archetype = gameObjectFactory.newGameObject(archName != null ? archName : thisLine.substring(7)); + } else { + archetype.setArchetypeName(archName != null ? archName : thisLine.substring(7)); } parsearch = true; @@ -158,12 +160,6 @@ firstArch = null; } - if (archName == null) { - archetype.setArchetypeName(thisLine.substring(7)); - } else { - archetype.setArchetypeName(archName); - } - multiShapeID = 0; editorFolder = null; } Modified: trunk/daimonin/src/daieditor/gameobject/DefaultGameObjectFactory.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/DefaultGameObjectFactory.java 2008-11-02 14:39:26 UTC (rev 5652) +++ trunk/daimonin/src/daieditor/gameobject/DefaultGameObjectFactory.java 2008-11-02 15:01:24 UTC (rev 5653) @@ -31,8 +31,8 @@ /** {@inheritDoc} */ @NotNull - public GameObject newGameObject() { - return new GameObject(); + public GameObject newGameObject(@NotNull final String archetypeName) { + return new GameObject(archetypeName); } } // class DefaultGameObjectFactory Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-11-02 14:39:26 UTC (rev 5652) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-11-02 15:01:24 UTC (rev 5653) @@ -59,6 +59,14 @@ @NotNull private ImageIcon transFace = noFace; + /** + * Creates a new instance. + * @param archetypeName the name of the base archetype + */ + public GameObject(@NotNull final String archetypeName) { + super(archetypeName); + } + /** {@inheritDoc} */ public int getMultiShapeID() { return multi != null ? multi.getMultiShapeID() : 0; @@ -209,8 +217,7 @@ if (!isArchetype()) { return getArchetype().createGameObject(); } - final GameObject arch = new GameObject(); - arch.setArchetypeName(archetypeName); + final GameObject arch = new GameObject(getArchetypeName()); arch.setArchetype(getArchetype()); arch.setMultiX(getMultiX()); arch.setMultiY(getMultiY()); Modified: trunk/daimonin/src/daieditor/gameobject/UndefinedArchetype.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/UndefinedArchetype.java 2008-11-02 14:39:26 UTC (rev 5652) +++ trunk/daimonin/src/daieditor/gameobject/UndefinedArchetype.java 2008-11-02 15:01:24 UTC (rev 5653) @@ -36,7 +36,7 @@ * @param archetypeName the archetype name */ public UndefinedArchetype(@NotNull final String archetypeName) { - setArchetypeName(archetypeName); + super(archetypeName); setTypeNo(0); setIsArchetype(); setEditorFolder("intern"); Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-11-02 14:39:26 UTC (rev 5652) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-11-02 15:01:24 UTC (rev 5653) @@ -119,7 +119,7 @@ * Archetypes name itself if this GameObject is an Archetype. */ @NotNull - protected String archetypeName; + private String archetypeName; /** The name of this object. */ @Nullable @@ -210,8 +210,10 @@ /** * Creates a new instance. + * @param archetypeName the name of the base archetype */ - protected GameObject() { + protected GameObject(@NotNull final String archetypeName) { + this.archetypeName = archetypeName; } /** Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObjectFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObjectFactory.java 2008-11-02 14:39:26 UTC (rev 5652) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObjectFactory.java 2008-11-02 15:01:24 UTC (rev 5653) @@ -30,9 +30,10 @@ /** * Creates a new {@link GameObject} instance. + * @param archetypeName the name of the base archetype * @return the new game object */ @NotNull - G newGameObject(); + G newGameObject(@NotNull String archetypeName); } // interface GameObjectFactory Modified: trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java 2008-11-02 14:39:26 UTC (rev 5652) +++ trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java 2008-11-02 15:01:24 UTC (rev 5653) @@ -91,8 +91,7 @@ return null; } - final G gameObject = gameObjectFactory.newGameObject(); - gameObject.setArchetypeName(archName); + final G gameObject = gameObjectFactory.newGameObject(archName); boolean msgflag = false; for (; ;) { Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-11-02 14:39:26 UTC (rev 5652) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-11-02 15:01:24 UTC (rev 5653) @@ -661,6 +661,13 @@ /** The serial version UID. */ private static final long serialVersionUID = 1; + /** + * Creates a new instance. + */ + public TestGameObject() { + super(""); + } + /** {@inheritDoc} */ public TestGameObject createGameObject() { throw new AssertionError(); @@ -967,7 +974,7 @@ /** {@inheritDoc} */ @NotNull - public TestGameObject newGameObject() { + public TestGameObject newGameObject(@NotNull final String archetypeName) { throw new AssertionError(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-02 15:05:33
|
Revision: 5654 http://gridarta.svn.sourceforge.net/gridarta/?rev=5654&view=rev Author: akirschbaum Date: 2008-11-02 15:05:30 +0000 (Sun, 02 Nov 2008) Log Message: ----------- Make field private. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-11-02 15:01:24 UTC (rev 5653) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-11-02 15:05:30 UTC (rev 5654) @@ -113,11 +113,6 @@ public GameObject createClone(final int posx, final int posy) { final GameObject clone = clone(); // The clone is a new object! - // Clone Recursion for complex types - if (msgText != null) { - clone.msgText = new StringBuilder(msgText); - } - if (multi != null && isHead()) { clone.multi = null; clone.initMultiData(); Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-11-02 15:01:24 UTC (rev 5653) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-11-02 15:05:30 UTC (rev 5654) @@ -166,11 +166,6 @@ public GameObject createClone(final int posx, final int posy) { final GameObject clone = clone(); // The clone is a new object! - // Clone Recursion for complex types - if (msgText != null) { - clone.msgText = new StringBuilder(msgText); - } - if (multi != null && isHead()) { clone.multi = null; clone.initMultiData(); Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-11-02 15:01:24 UTC (rev 5653) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-11-02 15:05:30 UTC (rev 5654) @@ -143,7 +143,7 @@ * message text. */ @Nullable - protected StringBuilder msgText; + private StringBuilder msgText; /** Map x position if on map. */ private int mapx; @@ -1142,6 +1142,9 @@ try { final GameObject<G, A, R> clone = (GameObject<G, A, R>) super.clone(); clone.objectText = new StringBuilder(getObjectText()); + if (msgText != null) { + clone.msgText = new StringBuilder(msgText); + } clone.attributeCache = new HashMap<String, String>(attributeCache); return clone; } catch (final CloneNotSupportedException e) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-02 15:24:58
|
Revision: 5655 http://gridarta.svn.sourceforge.net/gridarta/?rev=5655&view=rev Author: akirschbaum Date: 2008-11-02 15:24:49 +0000 (Sun, 02 Nov 2008) Log Message: ----------- Make field private. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-11-02 15:05:30 UTC (rev 5654) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-11-02 15:24:49 UTC (rev 5655) @@ -147,7 +147,7 @@ @Override public boolean isScripted() { for (final GameObject tmp : this) { - if (tmp.typeNo == TYPE_EVENT_CONNECTOR) { + if (tmp.getTypeNo() == TYPE_EVENT_CONNECTOR) { return true; } } @@ -177,18 +177,16 @@ return false; } - final Archetype archetype = getArchetype(); - return typeNo == archetype.getTypeNo(); -//XXX: && loreText.equals(archetype.getLoreText()) +//XXX: return loreText.equals(archetype.getLoreText()) + return true; } /** {@inheritDoc} */ @Override public boolean isEqual(@NotNull final GameObject gameObject) { return super.isEqual(gameObject) - && gameObject.loreText.equals(loreText) + && gameObject.loreText.equals(loreText); // ignore "scriptArchData" - && gameObject.typeNo == typeNo; } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-11-02 15:05:30 UTC (rev 5654) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-11-02 15:24:49 UTC (rev 5655) @@ -105,7 +105,7 @@ public void addLast(@NotNull final GameObject gameObject) { // force type change when a MONSTER is put in a spawn point if (archetypeTypeSet.getTypeOfArch(this) != null && archetypeTypeSet.getTypeOfArch(this).getTypeNo() == TYPE_SPAWN_POINT && archetypeTypeSet.getTypeOfArch(gameObject).getTypeNo() == TYPE_MOB) { - gameObject.typeNo = TYPE_SPAWN_POINT_MOB; // change to SPAWN_POINT_MOB + gameObject.setTypeNo(TYPE_SPAWN_POINT_MOB); // change to SPAWN_POINT_MOB } super.addLast(gameObject); } @@ -115,7 +115,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() == TYPE_SPAWN_POINT && archetypeTypeSet.getTypeOfArch(gameObject).getTypeNo() == TYPE_MOB) { - gameObject.typeNo = TYPE_SPAWN_POINT_MOB; // change to SPAWN_POINT_MOB + gameObject.setTypeNo(TYPE_SPAWN_POINT_MOB); // change to SPAWN_POINT_MOB } super.addFirst(gameObject); } @@ -198,7 +198,7 @@ @Override public boolean isScripted() { for (final GameObject tmp : this) { - if (tmp.typeNo == TYPE_EVENT_OBJECT) { + if (tmp.getTypeNo() == TYPE_EVENT_OBJECT) { return true; } } @@ -230,7 +230,6 @@ && gameObject.multiPartNr == multiPartNr && gameObject.isLowestPart == isLowestPart // ignore "scriptArchData" - && gameObject.typeNo == typeNo && gameObject.transFace == transFace; } Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-11-02 15:05:30 UTC (rev 5654) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-11-02 15:24:49 UTC (rev 5655) @@ -192,7 +192,7 @@ private String faceName = null; /** The object type. */ - protected int typeNo = TYPE_NO_UNSET; + private int typeNo = TYPE_NO_UNSET; /** Object animation <code>animation <var>animName</var></code>. */ private String animName; @@ -1324,7 +1324,8 @@ && multiX == archetype.getMultiY() && multiY == archetype.getMultiX() && (editorFolder == null || editorFolder.equals(archetype.getEditorFolder())) - && (faceName == null || faceName.equals(archetype.getFaceName())); + && (faceName == null || faceName.equals(archetype.getFaceName())) + && typeNo == archetype.getTypeNo(); } /** @@ -1354,6 +1355,7 @@ && (gameObject.editorFolder == null ? editorFolder == null : gameObject.editorFolder.equals(editorFolder)) && (gameObject.faceName == null ? faceName == null : gameObject.faceName.equals(faceName)) && (gameObject.animName == null ? animName == null : gameObject.animName.equals(animName)) + && gameObject.typeNo == typeNo && gameObject.direction == direction; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-02 18:11:49
|
Revision: 5659 http://gridarta.svn.sourceforge.net/gridarta/?rev=5659&view=rev Author: akirschbaum Date: 2008-11-02 18:11:45 +0000 (Sun, 02 Nov 2008) Log Message: ----------- Make code calling MapModel.begin/endTransaction() more robust. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java trunk/src/app/net/sf/gridarta/CopyBuffer.java trunk/src/app/net/sf/gridarta/floodfill/Floodfill.java trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ScriptTab.java trunk/src/app/net/sf/gridarta/gui/map/FillUtils.java 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/selectedsquare/SelectedSquareControl.java trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java Modified: trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java 2008-11-02 15:55:26 UTC (rev 5658) +++ trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java 2008-11-02 18:11:45 UTC (rev 5659) @@ -46,6 +46,7 @@ import net.sf.gridarta.io.MapArchObjectParserFactory; import net.sf.gridarta.map.MapArchObjectFactory; import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.map.MapModel; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; @@ -492,45 +493,49 @@ final MapArchObject map = mapControl.getMapModel().getMapArchObject(); - mapControl.getMapModel().beginTransaction("Map properties"); // TODO: I18N/L10N - map.beginTransaction(); + final MapModel<GameObject, MapArchObject, Archetype> mapModel = mapControl.getMapModel(); + try { + mapModel.beginTransaction("Map properties"); // TODO: I18N/L10N + map.beginTransaction(); - final String mapNameString = mapName.getText(); - mapControl.getMapModel().resizeMap(mapSize); - map.setText(mapDescription.getText()); - map.setLore(mapLore.getText()); - map.setMapName(mapNameString); + final String mapNameString = mapName.getText(); + mapModel.resizeMap(mapSize); + map.setText(mapDescription.getText()); + map.setLore(mapLore.getText()); + map.setMapName(mapNameString); - map.setRegion(region); - map.setEnterX(enterX); - map.setEnterY(enterY); - map.setResetTimeout(resetTimeout); - map.setBackgroundMusic(backgroundMusic); - map.setSwapTime(swapTime); - map.setDifficulty(difficulty); - map.setFixedReset(checkboxFixedReset.isSelected()); - map.setDarkness(darkness); - map.setUnique(checkboxUnique.isSelected()); - map.setOutdoor(checkboxOutdoor.isSelected()); - map.setNosmooth(checkboxNosmooth.isSelected()); + map.setRegion(region); + map.setEnterX(enterX); + map.setEnterY(enterY); + map.setResetTimeout(resetTimeout); + map.setBackgroundMusic(backgroundMusic); + map.setSwapTime(swapTime); + map.setDifficulty(difficulty); + map.setFixedReset(checkboxFixedReset.isSelected()); + map.setDarkness(darkness); + map.setUnique(checkboxUnique.isSelected()); + map.setOutdoor(checkboxOutdoor.isSelected()); + map.setNosmooth(checkboxNosmooth.isSelected()); - map.setShopItems(shopItems); - map.setShopRace(shopRace); - map.setShopMin(shopMin); - map.setShopMax(shopMax); - map.setShopGreed(shopGreedd); + map.setShopItems(shopItems); + map.setShopRace(shopRace); + map.setShopMin(shopMin); + map.setShopMax(shopMax); + map.setShopGreed(shopGreedd); - map.setTemp(temperature); - map.setPressure(pressure); - map.setHumid(humidity); - map.setWindspeed(windSpeed); - map.setWinddir(windDirection); - map.setSky(skySetting); + map.setTemp(temperature); + map.setPressure(pressure); + map.setHumid(humidity); + map.setWindspeed(windSpeed); + map.setWinddir(windDirection); + map.setSky(skySetting); - mapTilePane.modifyMapProperties(); + mapTilePane.modifyMapProperties(); - map.endTransaction(); - mapControl.getMapModel().endTransaction(); + map.endTransaction(); + } finally { + mapModel.endTransaction(); + } return true; } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-11-02 15:55:26 UTC (rev 5658) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-11-02 18:11:45 UTC (rev 5659) @@ -439,10 +439,13 @@ final MapModel<GameObject, MapArchObject, Archetype> mapModel = currentMap.getMapModel(); mapModel.beginTransaction("cleanCompletelyBlockedSquares"); // TODO: I18N/L10N - for (final MapSquare<GameObject, MapArchObject, Archetype> completelyBlockedSquare : BlockedSquareChecker.findCompletelyBlockedSquares(mapModel)) { - completelyBlockedSquare.removeAll(); + try { + for (final MapSquare<GameObject, MapArchObject, Archetype> completelyBlockedSquare : BlockedSquareChecker.findCompletelyBlockedSquares(mapModel)) { + completelyBlockedSquare.removeAll(); + } + } finally { + mapModel.endTransaction(); } - mapModel.endTransaction(); } /** Collect Spells. */ Modified: trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java 2008-11-02 15:55:26 UTC (rev 5658) +++ trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java 2008-11-02 18:11:45 UTC (rev 5659) @@ -57,6 +57,7 @@ import net.sf.gridarta.io.MapArchObjectParserFactory; import net.sf.gridarta.map.MapArchObjectFactory; import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.map.MapModel; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.misc.JFileChooserButton; import org.jetbrains.annotations.NotNull; @@ -473,38 +474,42 @@ final MapArchObject map = mapControl.getMapModel().getMapArchObject(); - mapControl.getMapModel().beginTransaction("Map properties"); // TODO: I18N/L10N - map.beginTransaction(); + final MapModel<GameObject, MapArchObject, Archetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("Map properties"); // TODO: I18N/L10N + try { + map.beginTransaction(); - final String mapNameString = mapName.getText() + (mapSound.getText().length() > 0 ? '§' + mapSound.getText() + "|0|-1" : ""); - mapControl.getMapModel().resizeMap(mapSize); - map.setText(mapDescription.getText()); - map.setMapName(mapNameString); + final String mapNameString = mapName.getText() + (mapSound.getText().length() > 0 ? '§' + mapSound.getText() + "|0|-1" : ""); + mapModel.resizeMap(mapSize); + map.setText(mapDescription.getText()); + map.setMapName(mapNameString); - map.setEnterX(enterX); - map.setEnterY(enterY); - map.setResetTimeout(resetTimeout); - map.setSwapTime(swapTime); - map.setDifficulty(difficulty); - map.setFixedReset(checkboxFixedReset.isSelected()); - map.setDarkness(darkness); - map.setOutdoor(checkboxOutdoor.isSelected()); + map.setEnterX(enterX); + map.setEnterY(enterY); + map.setResetTimeout(resetTimeout); + map.setSwapTime(swapTime); + map.setDifficulty(difficulty); + map.setFixedReset(checkboxFixedReset.isSelected()); + map.setDarkness(darkness); + map.setOutdoor(checkboxOutdoor.isSelected()); - map.setNoSave(checkboxNoSave.isSelected()); - map.setNoMagic(checkboxNoMagic.isSelected()); - map.setNoPriest(checkboxNoPriest.isSelected()); - map.setNoHarm(checkboxNoHarm.isSelected()); - map.setNoSummon(checkboxNoSummon.isSelected()); - map.setFixedLogin(checkboxNoFixedLogin.isSelected()); - map.setPermDeath(checkboxPermDeath.isSelected()); - map.setUltraDeath(checkboxUltraDeath.isSelected()); - map.setUltimateDeath(checkboxUltimateDeath.isSelected()); - map.setPvp(checkboxPvp.isSelected()); + map.setNoSave(checkboxNoSave.isSelected()); + map.setNoMagic(checkboxNoMagic.isSelected()); + map.setNoPriest(checkboxNoPriest.isSelected()); + map.setNoHarm(checkboxNoHarm.isSelected()); + map.setNoSummon(checkboxNoSummon.isSelected()); + map.setFixedLogin(checkboxNoFixedLogin.isSelected()); + map.setPermDeath(checkboxPermDeath.isSelected()); + map.setUltraDeath(checkboxUltraDeath.isSelected()); + map.setUltimateDeath(checkboxUltimateDeath.isSelected()); + map.setPvp(checkboxPvp.isSelected()); - mapTilePane.modifyMapProperties(); + mapTilePane.modifyMapProperties(); - map.endTransaction(); - mapControl.getMapModel().endTransaction(); + map.endTransaction(); + } finally { + mapModel.endTransaction(); + } return true; } Modified: trunk/src/app/net/sf/gridarta/CopyBuffer.java =================================================================== --- trunk/src/app/net/sf/gridarta/CopyBuffer.java 2008-11-02 15:55:26 UTC (rev 5658) +++ trunk/src/app/net/sf/gridarta/CopyBuffer.java 2008-11-02 18:11:45 UTC (rev 5659) @@ -150,47 +150,51 @@ final MapModel<G, A, R> mapModel = copyMapCtrl.getMapModel(); mapModel.beginTransaction("Cut / Clear"); + try { + // Prepare the buffer (if it's a cut or copy) + if (copyMode == CopyMode.DO_CUT || copyMode == CopyMode.DO_COPY) { + mapModel.resizeMap(new Size2D(selRec.width + 1, selRec.height + 1)); + mapModel.clearMap(); + } - // Prepare the buffer (if it's a cut or copy) - if (copyMode == CopyMode.DO_CUT || copyMode == CopyMode.DO_COPY) { - mapModel.resizeMap(new Size2D(selRec.width + 1, selRec.height + 1)); - mapModel.clearMap(); - } + final MapModel<G, A, R> mapModel2 = mapView.getMapControl().getMapModel(); + mapModel2.beginTransaction("Cut / Clear"); // TODO: I18N/L10N + try { + final Set<G> gameObjectsToDelete = new HashSet<G>(); + for (final MapSquare<G, A, R> square : mapView.getMapViewBasic().getSelectedSquares()) { + final int posx = square.getMapX(); + final int posy = square.getMapY(); + for (final G gameObject : square) { + // store a clone of the gameObject in the CopyBuffer + // (for multiparts, only the heads get copied into the buffer) + // arches that don't match the view settings are ignored! + if ((copyMode == CopyMode.DO_CUT || copyMode == CopyMode.DO_COPY) && gameObject.isHead() && !gameObject.isInContainer() && editTypes.isEditType(gameObject)) { + // copy this gameObject + final G clone = gameObject.createClone(posx - selRec.x, posy - selRec.y); + mapModel.addGameObjectToMap(clone, InsertionMode.TOPMOST); + } + // delete the gameObject if we have a "cut" or "clear" command + // again, arches that don't match the view settings are ignored + if ((copyMode == CopyMode.DO_CLEAR || copyMode == CopyMode.DO_CUT) && editTypes.isEditType(gameObject)) { + // delete gameObject (without redrawing the map) + // For CUT we don't delete multi tails of multis which are left or + // above the head (we would miss to copy them otherwise). + if (copyMode == CopyMode.DO_CLEAR || (gameObject.getMultiX() >= 0 && gameObject.getMultiY() >= 0)) { + gameObjectsToDelete.add(gameObject.getHead()); + } + } + } + } - mapView.getMapControl().getMapModel().beginTransaction("Cut / Clear"); // TODO: I18N/L10N - - final Set<G> gameObjectsToDelete = new HashSet<G>(); - for (final MapSquare<G, A, R> square : mapView.getMapViewBasic().getSelectedSquares()) { - final int posx = square.getMapX(); - final int posy = square.getMapY(); - for (final G gameObject : square) { - // store a clone of the gameObject in the CopyBuffer - // (for multiparts, only the heads get copied into the buffer) - // arches that don't match the view settings are ignored! - if ((copyMode == CopyMode.DO_CUT || copyMode == CopyMode.DO_COPY) && gameObject.isHead() && !gameObject.isInContainer() && editTypes.isEditType(gameObject)) { - // copy this gameObject - final G clone = gameObject.createClone(posx - selRec.x, posy - selRec.y); - mapModel.addGameObjectToMap(clone, InsertionMode.TOPMOST); + for (final G gameObject : gameObjectsToDelete) { + gameObject.remove(); } - // delete the gameObject if we have a "cut" or "clear" command - // again, arches that don't match the view settings are ignored - if ((copyMode == CopyMode.DO_CLEAR || copyMode == CopyMode.DO_CUT) && editTypes.isEditType(gameObject)) { - // delete gameObject (without redrawing the map) - // For CUT we don't delete multi tails of multis which are left or - // above the head (we would miss to copy them otherwise). - if (copyMode == CopyMode.DO_CLEAR || (gameObject.getMultiX() >= 0 && gameObject.getMultiY() >= 0)) { - gameObjectsToDelete.add(gameObject.getHead()); - } - } + } finally { + mapModel2.endTransaction(); } + } finally { + mapModel.endTransaction(); } - - mapModel.endTransaction(); - - for (final G gameObject : gameObjectsToDelete) { - gameObject.remove(); - } - mapView.getMapControl().getMapModel().endTransaction(); } /** @@ -204,31 +208,35 @@ final MapControl<G, A, R, V> mapControl = mapView.getMapControl(); - mapControl.getMapModel().beginTransaction("Paste"); // TODO: I18N/L10N - final Point pos = new Point(); - for (final MapSquare<G, A, R> square : copyMapCtrl.getMapModel()) { - pos.setLocation(startp.x + square.getMapX(), startp.y + square.getMapY()); - if (mapControl.getMapModel().isPointValid(pos)) { - for (final G gameObject : square) { - if (!gameObject.isMulti()) { - mapControl.getMapModel().addCopyToMap(gameObject, pos, true, InsertionMode.TOPMOST); + final MapModel<G, A, R> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("Paste"); // TODO: I18N/L10N + try { + final Point pos = new Point(); + for (final MapSquare<G, A, R> square : copyMapCtrl.getMapModel()) { + pos.setLocation(startp.x + square.getMapX(), startp.y + square.getMapY()); + if (mapModel.isPointValid(pos)) { + for (final G gameObject : square) { + if (!gameObject.isMulti()) { + mapModel.addCopyToMap(gameObject, pos, true, InsertionMode.TOPMOST); + } } } } - } - for (final MapSquare<G, A, R> square : copyMapCtrl.getMapModel()) { - pos.setLocation(startp); - pos.translate(square.getMapX(), square.getMapY()); - if (mapControl.getMapModel().isPointValid(pos)) { - for (final G gameObject : square) { - if (gameObject.isMulti()) { - mapControl.getMapModel().addCopyToMap(gameObject, pos, true, InsertionMode.TOPMOST); + for (final MapSquare<G, A, R> square : copyMapCtrl.getMapModel()) { + pos.setLocation(startp); + pos.translate(square.getMapX(), square.getMapY()); + if (mapModel.isPointValid(pos)) { + for (final G gameObject : square) { + if (gameObject.isMulti()) { + mapModel.addCopyToMap(gameObject, pos, true, InsertionMode.TOPMOST); + } } } } + } finally { + mapModel.endTransaction(); } - mapControl.getMapModel().endTransaction(); } /** Modified: trunk/src/app/net/sf/gridarta/floodfill/Floodfill.java =================================================================== --- trunk/src/app/net/sf/gridarta/floodfill/Floodfill.java 2008-11-02 15:55:26 UTC (rev 5658) +++ trunk/src/app/net/sf/gridarta/floodfill/Floodfill.java 2008-11-02 18:11:45 UTC (rev 5659) @@ -74,48 +74,51 @@ final byte[][] area = new byte[mapSize.getWidth()][mapSize.getHeight()]; area[start.x][start.y] = BORDER; mapModel.beginTransaction("Flood Fill"); // TODO: I18N/L10N - int border = 1; - while (border > 0) { - final Point p = new Point(); - for (p.x = 0; p.x < mapSize.getWidth(); p.x++) { - for (p.y = 0; p.y < mapSize.getHeight(); p.y++) { - if (area[p.x][p.y] == BORDER) { - border--; - if (mapModel.isPointValid(p) && mapModel.getMapSquare(p).isEmpty()) { - area[p.x][p.y] = WAS_EMPTY; - final G gameObject = archList.get(RandomUtils.rnd.nextInt(archList.size())); - mapModel.addCopyToMap(gameObject, p, false, InsertionMode.TOPMOST); - try { - if (area[p.x - 1][p.y] == NOT_LOOKED_AT) { - area[p.x - 1][p.y] = BORDER; - border++; - } - } catch (final ArrayIndexOutOfBoundsException e) { /* ignore */ } - try { - if (area[p.x + 1][p.y] == NOT_LOOKED_AT) { - area[p.x + 1][p.y] = BORDER; - border++; - } - } catch (final ArrayIndexOutOfBoundsException e) { /* ignore */ } - try { - if (area[p.x][p.y - 1] == NOT_LOOKED_AT) { - area[p.x][p.y - 1] = BORDER; - border++; - } - } catch (final ArrayIndexOutOfBoundsException e) { /* ignore */ } - try { - if (area[p.x][p.y + 1] == NOT_LOOKED_AT) { - area[p.x][p.y + 1] = BORDER; - border++; - } - } catch (final ArrayIndexOutOfBoundsException e) { /* ignore */ } - } else { - area[p.x][p.y] = BLOCKED; + try { + int border = 1; + while (border > 0) { + final Point p = new Point(); + for (p.x = 0; p.x < mapSize.getWidth(); p.x++) { + for (p.y = 0; p.y < mapSize.getHeight(); p.y++) { + if (area[p.x][p.y] == BORDER) { + border--; + if (mapModel.isPointValid(p) && mapModel.getMapSquare(p).isEmpty()) { + area[p.x][p.y] = WAS_EMPTY; + final G gameObject = archList.get(RandomUtils.rnd.nextInt(archList.size())); + mapModel.addCopyToMap(gameObject, p, false, InsertionMode.TOPMOST); + try { + if (area[p.x - 1][p.y] == NOT_LOOKED_AT) { + area[p.x - 1][p.y] = BORDER; + border++; + } + } catch (final ArrayIndexOutOfBoundsException e) { /* ignore */ } + try { + if (area[p.x + 1][p.y] == NOT_LOOKED_AT) { + area[p.x + 1][p.y] = BORDER; + border++; + } + } catch (final ArrayIndexOutOfBoundsException e) { /* ignore */ } + try { + if (area[p.x][p.y - 1] == NOT_LOOKED_AT) { + area[p.x][p.y - 1] = BORDER; + border++; + } + } catch (final ArrayIndexOutOfBoundsException e) { /* ignore */ } + try { + if (area[p.x][p.y + 1] == NOT_LOOKED_AT) { + area[p.x][p.y + 1] = BORDER; + border++; + } + } catch (final ArrayIndexOutOfBoundsException e) { /* ignore */ } + } else { + area[p.x][p.y] = BLOCKED; + } } } } } + } finally { + mapModel.endTransaction(); } - mapModel.endTransaction(); } } Modified: trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java 2008-11-02 15:55:26 UTC (rev 5658) +++ trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java 2008-11-02 18:11:45 UTC (rev 5659) @@ -49,6 +49,7 @@ import net.sf.gridarta.map.InsertionMode; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.map.MapModel; import net.sf.gridarta.map.MapSquare; import net.sf.gridarta.utils.RandomUtils; import net.sf.japi.swing.ActionFactory; @@ -392,63 +393,66 @@ final List<G> objectsToReplace = new ArrayList<G>(); final int replaceListSize = replaceList == null ? 0 : replaceList.size(); final MapControl<G, A, R, V> mapControl = mapView.getMapControl(); - mapControl.getMapModel().beginTransaction("Replace"); // TODO: I18N/L10N - int replaceCount = 0; - for (final MapSquare<G, A, R> square : entireMap ? mapControl.getMapModel() : mapView.getMapViewBasic().getSelectedSquares()) { - // Operate on a copy of the nodes to prevent ConcurrentModificationException + final MapModel<G, A, R> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("Replace"); // TODO: I18N/L10N + try { + int replaceCount = 0; + for (final MapSquare<G, A, R> square : entireMap ? mapModel : mapView.getMapViewBasic().getSelectedSquares()) { + // Operate on a copy of the nodes to prevent ConcurrentModificationException - // find objects to replace - objectsToReplace.clear(); - for (final G node : square) { - if (node.isHead() && ((matchCriteria == MATCH_ARCH_NAME && node.getArchetypeName() != null && node.getArchetypeName().equalsIgnoreCase(matchString)) || (matchCriteria == MATCH_OBJ_NAME && node.getBestName().equalsIgnoreCase(matchString)))) { - if (replaceDensity > RandomUtils.rnd.nextInt(100)) { - objectsToReplace.add(node); + // find objects to replace + objectsToReplace.clear(); + for (final G node : square) { + if (node.isHead() && ((matchCriteria == MATCH_ARCH_NAME && node.getArchetypeName() != null && node.getArchetypeName().equalsIgnoreCase(matchString)) || (matchCriteria == MATCH_OBJ_NAME && node.getBestName().equalsIgnoreCase(matchString)))) { + if (replaceDensity > RandomUtils.rnd.nextInt(100)) { + objectsToReplace.add(node); + } } } - } - // actually replace the objects - for (final G objectToReplace : objectsToReplace) { - final Iterator<G> it = square.iterator(); - G prevArch = null; - G node = null; - while (it.hasNext()) { - node = it.next(); + // actually replace the objects + for (final G objectToReplace : objectsToReplace) { + final Iterator<G> it = square.iterator(); + G prevArch = null; + G node = null; + while (it.hasNext()) { + node = it.next(); - if (node == objectToReplace) { - break; + if (node == objectToReplace) { + break; + } + + prevArch = node; } + assert node != null; - prevArch = node; - } - assert node != null; + // first, delete the old arch + node.remove(); - // first, delete the old arch - node.remove(); + if (replaceListSize > 0 && !deleteOnly) { + final G randomArch; + if (replaceListSize == 1) { + randomArch = replaceList.get(0); + } else { + randomArch = replaceList.get(RandomUtils.rnd.nextInt(replaceList.size())); + } + // insert replacement object + if (randomArch.isMulti()) { + // multi's cannot be inserted properly, so we just put them ontop + mapModel.insertArchetype(randomArch.getArchetype(), new Point(square.getMapX(), square.getMapY()), false, false, InsertionMode.TOPMOST); - if (replaceListSize > 0 && !deleteOnly) { - final G randomArch; - if (replaceListSize == 1) { - randomArch = replaceList.get(0); - } else { - randomArch = replaceList.get(RandomUtils.rnd.nextInt(replaceList.size())); + // TODO: if from pickmap it could have special attributes -> copy them + } else { + mapModel.insertArchToMap(randomArch, prevArch, new Point(square.getMapX(), square.getMapY()), false); + } } - // insert replacement object - if (randomArch.isMulti()) { - // multi's cannot be inserted properly, so we just put them ontop - mapControl.getMapModel().insertArchetype(randomArch.getArchetype(), new Point(square.getMapX(), square.getMapY()), false, false, InsertionMode.TOPMOST); - - // TODO: if from pickmap it could have special attributes -> copy them - } else { - mapControl.getMapModel().insertArchToMap(randomArch, prevArch, new Point(square.getMapX(), square.getMapY()), false); - } + replaceCount++; } - replaceCount++; } + return replaceCount; + } finally { + mapModel.endTransaction(); } - - mapControl.getMapModel().endTransaction(); - return replaceCount; } /** Item-listener for the "replace with"-selection box. */ Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2008-11-02 15:55:26 UTC (rev 5658) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2008-11-02 18:11:45 UTC (rev 5659) @@ -438,9 +438,12 @@ assert mapSquare != null; final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); mapModel.beginTransaction("Add to inventory"); - selectedGameObject.addLast(invnew); - invnew.setObjectFace(); - mapModel.endTransaction(); + try { + selectedGameObject.addLast(invnew); + invnew.setObjectFace(); + } finally { + mapModel.endTransaction(); + } } /** @@ -489,44 +492,46 @@ return; } - mapSquare.getMapModel().beginTransaction("Change object attributes"); + final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); + mapModel.beginTransaction("Change object attributes"); + try { + for (final GameObjectAttributesTab<G, A, R> tab : tabs) { + if (tab.canApply()) { + tab.apply(); + } + } - for (final GameObjectAttributesTab<G, A, R> tab : tabs) { - if (tab.canApply()) { - tab.apply(); + /* check we have a face and set the real face obj for fast access */ + final String face = selectedGameObject.getAttributeString("face", false); + // we have a new face name + selectedGameObject.setRealFace(face); + if (selectedGameObject.getAttributeString("animation", false).length() > 0) { + selectedGameObject.setAnimName(selectedGameObject.getAttributeString("animation", false)); + } else { + selectedGameObject.setAnimName(archetype.getAnimName()); } - } - /* check we have a face and set the real face obj for fast access */ - final String face = selectedGameObject.getAttributeString("face", false); - // we have a new face name - selectedGameObject.setRealFace(face); - if (selectedGameObject.getAttributeString("animation", false).length() > 0) { - selectedGameObject.setAnimName(selectedGameObject.getAttributeString("animation", false)); - } else { - selectedGameObject.setAnimName(archetype.getAnimName()); - } + if (selectedGameObject.getAttributeString("direction", false).length() > 0) { + final int dir = selectedGameObject.getAttributeInt("direction", false); + if (archetype.getDirection() != dir) { + selectedGameObject.setDirection(dir); + } + } else { + selectedGameObject.setDirection(archetype.getDirection()); + } + selectedGameObject.setObjectFace(); - if (selectedGameObject.getAttributeString("direction", false).length() > 0) { - final int dir = selectedGameObject.getAttributeInt("direction", false); - if (archetype.getDirection() != dir) { - selectedGameObject.setDirection(dir); + // we look for 'type' in the ArchText. In future maybe type should get + // a separate text field + if (selectedGameObject.getAttributeString("type", false).length() > 0) { + selectedGameObject.setTypeNo(selectedGameObject.getAttributeInt("type", false)); // specified type } - } else { - selectedGameObject.setDirection(archetype.getDirection()); - } - selectedGameObject.setObjectFace(); - // we look for 'type' in the ArchText. In future maybe type should get - // a separate text field - if (selectedGameObject.getAttributeString("type", false).length() > 0) { - selectedGameObject.setTypeNo(selectedGameObject.getAttributeInt("type", false)); // specified type + // recalculate the editType value; XXX: should use MVC + selectedGameObject.updateEditType(selectedGameObject.getMapSquare().getMapModel().getActiveEditType()); + } finally { + mapModel.endTransaction(); } - - // recalculate the editType value; XXX: should use MVC - selectedGameObject.updateEditType(selectedGameObject.getMapSquare().getMapModel().getActiveEditType()); - - mapSquare.getMapModel().endTransaction(); } private JPanel createButtonPanel() { Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ScriptTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ScriptTab.java 2008-11-02 15:55:26 UTC (rev 5658) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ScriptTab.java 2008-11-02 18:11:45 UTC (rev 5659) @@ -16,6 +16,7 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapModel; import net.sf.gridarta.map.MapSquare; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; @@ -177,9 +178,13 @@ if (selectedGameObject != null) { final MapSquare<G, A, R> mapSquare = selectedGameObject.getHead().getMapSquare(); assert mapSquare != null; - mapSquare.getMapModel().beginTransaction("Add event script"); - selectedGameObject.getHead().addEventScript(eventList, this, parent); - mapSquare.getMapModel().endTransaction(); + final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); + mapModel.beginTransaction("Add event script"); + try { + selectedGameObject.getHead().addEventScript(eventList, this, parent); + } finally { + mapModel.endTransaction(); + } } } @@ -202,9 +207,13 @@ if (index >= 0) { final MapSquare<G, A, R> mapSquare = selectedGameObject.getMapSquare(); assert mapSquare != null; - mapSquare.getMapModel().beginTransaction("Modify event script"); - selectedGameObject.getHead().modifyEventScript(index, task, eventList, this, mapManager, parent); - mapSquare.getMapModel().endTransaction(); + final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); + mapModel.beginTransaction("Modify event script"); + try { + selectedGameObject.getHead().modifyEventScript(index, task, eventList, this, mapManager, parent); + } finally { + mapModel.endTransaction(); + } } } } Modified: trunk/src/app/net/sf/gridarta/gui/map/FillUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/FillUtils.java 2008-11-02 15:55:26 UTC (rev 5658) +++ trunk/src/app/net/sf/gridarta/gui/map/FillUtils.java 2008-11-02 18:11:45 UTC (rev 5659) @@ -71,15 +71,19 @@ return; } - mapControl.getMapModel().beginTransaction("Fill"); // TODO; I18N/L10N - for (final Point p : selection) { - if (density != -1 && density != 100 && density < RandomUtils.rnd.nextInt(100) + 1) { - continue; + final MapModel<G, A, R> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("Fill"); // TODO; I18N/L10N + try { + for (final Point p : selection) { + if (density != -1 && density != 100 && density < RandomUtils.rnd.nextInt(100) + 1) { + continue; + } + final G gameObject = gameObjects.get(RandomUtils.rnd.nextInt(gameObjects.size())); + mapModel.addCopyToMap(gameObject, p, false, insertionMode); } - final G gameObject = gameObjects.get(RandomUtils.rnd.nextInt(gameObjects.size())); - mapControl.getMapModel().addCopyToMap(gameObject, p, false, insertionMode); + } finally { + mapModel.endTransaction(); } - mapControl.getMapModel().endTransaction(); } /** @@ -107,10 +111,13 @@ } mapModel.beginTransaction("Floodfill"); // TODO: I18N/L10N - //long start = System.currentTimeMillis(); - new Floodfill<G, A, R>().floodfill(mapModel, start, gameObjects); - //mainControl.setStatusText("Flood fill took " + (System.currentTimeMillis() - start) + " milliseconds in " + iter + " iterations."); - mapModel.endTransaction(); + try { + //long start = System.currentTimeMillis(); + new Floodfill<G, A, R>().floodfill(mapModel, start, gameObjects); + //mainControl.setStatusText("Flood fill took " + (System.currentTimeMillis() - start) + " milliseconds in " + iter + " iterations."); + } finally { + mapModel.endTransaction(); + } } } // class FillUtils Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java 2008-11-02 15:55:26 UTC (rev 5658) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java 2008-11-02 18:11:45 UTC (rev 5659) @@ -39,6 +39,7 @@ import net.sf.gridarta.gui.undo.SwingUtils; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.map.MapModel; import net.sf.gridarta.map.MapSquare; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ToggleAction; @@ -334,11 +335,15 @@ } } if (!gameObjectsToDelete.isEmpty()) { - mapSquare.getMapModel().beginTransaction("Delete Object"); - for (final G gameObjectToDelete : gameObjectsToDelete) { - mapSquare.getMapModel().deleteMapArch(gameObjectToDelete, true); + final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); + mapModel.beginTransaction("Delete Object"); + try { + for (final G gameObjectToDelete : gameObjectsToDelete) { + mapModel.deleteMapArch(gameObjectToDelete, true); + } + } finally { + mapModel.endTransaction(); } - mapSquare.getMapModel().endTransaction(); } } Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java 2008-11-02 15:55:26 UTC (rev 5658) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java 2008-11-02 18:11:45 UTC (rev 5659) @@ -37,6 +37,7 @@ import net.sf.gridarta.map.InsertionMode; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.map.MapModel; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -149,45 +150,49 @@ } } - mapControl.getMapModel().beginTransaction("Insert Object"); - @Nullable final G insertedObject; - if (mapControl.isPickmap()) { - final G selectedGameObject = selectedSquareView.getSelectedGameObject(); - if (selectedGameObject != null) { - mapControl.getMapModel().insertMapArchToPickmap(p, selectedGameObject); - } - insertedObject = null; - } else { - final int modeIndex = modeComboBox.getSelectedIndex(); - final InsertionMode insertionMode; - switch (modeIndex) { - case MODE_AUTO: - insertionMode = InsertionMode.AUTO; - break; + final MapModel<G, A, R> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("Insert Object"); + try { + @Nullable final G insertedObject; + if (mapControl.isPickmap()) { + final G selectedGameObject = selectedSquareView.getSelectedGameObject(); + if (selectedGameObject != null) { + mapModel.insertMapArchToPickmap(p, selectedGameObject); + } + insertedObject = null; + } else { + final int modeIndex = modeComboBox.getSelectedIndex(); + final InsertionMode insertionMode; + switch (modeIndex) { + case MODE_AUTO: + insertionMode = InsertionMode.AUTO; + break; - case MODE_TOPMOST: - insertionMode = InsertionMode.TOPMOST; - break; + case MODE_TOPMOST: + insertionMode = InsertionMode.TOPMOST; + break; - case MODE_ABOVE_FLOOR: - insertionMode = InsertionMode.ABOVE_FLOOR; - break; + case MODE_ABOVE_FLOOR: + insertionMode = InsertionMode.ABOVE_FLOOR; + break; - case MODE_BELOW_FLOOR: - insertionMode = InsertionMode.BELOW_FLOOR; - break; + case MODE_BELOW_FLOOR: + insertionMode = InsertionMode.BELOW_FLOOR; + break; - case MODE_BOTTOMMOST: - insertionMode = InsertionMode.BOTTOMMOST; - break; + case MODE_BOTTOMMOST: + insertionMode = InsertionMode.BOTTOMMOST; + break; - default: - throw new AssertionError(); + default: + throw new AssertionError(); + } + insertedObject = objectChooser.insertSelectedObject(mapModel, p, isPressed || modeIndex == MODE_AUTO, insertionMode); } - insertedObject = objectChooser.insertSelectedObject(mapControl.getMapModel(), p, isPressed || modeIndex == MODE_AUTO, insertionMode); + selectedSquareView.setSelectedGameObject(insertedObject); + } finally { + mapModel.endTransaction(); } - mapControl.getMapModel().endTransaction(); - selectedSquareView.setSelectedGameObject(insertedObject); } /** {@inheritDoc} */ Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java 2008-11-02 15:55:26 UTC (rev 5658) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java 2008-11-02 18:11:45 UTC (rev 5659) @@ -121,9 +121,13 @@ if (arch != null) { final MapSquare<G, A, R> mapSquare = arch.getMapSquare(); assert mapSquare != null; - mapSquare.getMapModel().beginTransaction("Move Top"); - arch.moveTop(); - mapSquare.getMapModel().endTransaction(); + final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); + mapModel.beginTransaction("Move Top"); + try { + arch.moveTop(); + } finally { + mapModel.endTransaction(); + } } } @@ -134,9 +138,13 @@ if (arch != null) { final MapSquare<G, A, R> mapSquare = arch.getMapSquare(); assert mapSquare != null; - mapSquare.getMapModel().beginTransaction("Move Up"); - arch.moveUp(); - mapSquare.getMapModel().endTransaction(); + final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); + mapModel.beginTransaction("Move Up"); + try { + arch.moveUp(); + } finally { + mapModel.endTransaction(); + } } } @@ -147,9 +155,13 @@ if (arch != null) { final MapSquare<G, A, R> mapSquare = arch.getMapSquare(); assert mapSquare != null; - mapSquare.getMapModel().beginTransaction("Move Down"); - arch.moveDown(); - mapSquare.getMapModel().endTransaction(); + final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); + mapModel.beginTransaction("Move Down"); + try { + arch.moveDown(); + } finally { + mapModel.endTransaction(); + } } } @@ -160,9 +172,13 @@ if (arch != null) { final MapSquare<G, A, R> mapSquare = arch.getMapSquare(); assert mapSquare != null; - mapSquare.getMapModel().beginTransaction("Move Bottom"); - arch.moveBottom(); - mapSquare.getMapModel().endTransaction(); + final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); + mapModel.beginTransaction("Move Bottom"); + try { + arch.moveBottom(); + } finally { + mapModel.endTransaction(); + } } } @@ -194,8 +210,11 @@ final MapModel<G, A, R> mapModel = mapView.getMapControl().getMapModel(); mapModel.beginTransaction("Delete"); // TODO; I18N/L10N - mapModel.deleteMapArch(entry, true); - mapModel.endTransaction(); + try { + mapModel.deleteMapArch(entry, true); + } finally { + mapModel.endTransaction(); + } @Nullable final G selectedGameObject; if (index < view.getModelSize()) { @@ -240,11 +259,15 @@ } final MapControl<G, A, R, V> mapControl = mapView.getMapControl(); - mapControl.getMapModel().beginTransaction("Insert"); // TODO; I18N/L10N - final G prevGameObject = index >= view.getModelSize() ? null : view.getListGameObject(index); - final G insertedGameObject = mapControl.getMapModel().insertArchToMap(gameObject, prevGameObject, new Point(currentMapSquare.getMapX(), currentMapSquare.getMapY()), true); - view.setSelectedGameObject(insertedGameObject); - mapControl.getMapModel().endTransaction(); + final MapModel<G, A, R> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("Insert"); // TODO; I18N/L10N + try { + final G prevGameObject = index >= view.getModelSize() ? null : view.getListGameObject(index); + final G insertedGameObject = mapModel.insertArchToMap(gameObject, prevGameObject, new Point(currentMapSquare.getMapX(), currentMapSquare.getMapY()), true); + view.setSelectedGameObject(insertedGameObject); + } finally { + mapModel.endTransaction(); + } } /** Modified: trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-11-02 15:55:26 UTC (rev 5658) +++ trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-11-02 18:11:45 UTC (rev 5659) @@ -182,9 +182,12 @@ mapSize = mapArchObject.getMapSize(); mapGrid = new MapSquare[mapSize.getWidth()][mapSize.getHeight()]; beginTransaction("init"); - clearMap(); - addObjectListToMap(objects); // init mapArchObject and (when not new map) the arch list - endTransaction(); + try { + clearMap(); + addObjectListToMap(objects); // init mapArchObject and (when not new map) the arch list + } finally { + endTransaction(); + } } /** {@inheritDoc} */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-02 18:14:12
|
Revision: 5660 http://gridarta.svn.sourceforge.net/gridarta/?rev=5660&view=rev Author: akirschbaum Date: 2008-11-02 18:14:07 +0000 (Sun, 02 Nov 2008) Log Message: ----------- Make code calling MapArchObject.begin/endTransaction() more robust. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java Modified: trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java 2008-11-02 18:11:45 UTC (rev 5659) +++ trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java 2008-11-02 18:14:07 UTC (rev 5660) @@ -497,42 +497,43 @@ try { mapModel.beginTransaction("Map properties"); // TODO: I18N/L10N map.beginTransaction(); + try { + final String mapNameString = mapName.getText(); + mapModel.resizeMap(mapSize); + map.setText(mapDescription.getText()); + map.setLore(mapLore.getText()); + map.setMapName(mapNameString); - final String mapNameString = mapName.getText(); - mapModel.resizeMap(mapSize); - map.setText(mapDescription.getText()); - map.setLore(mapLore.getText()); - map.setMapName(mapNameString); + map.setRegion(region); + map.setEnterX(enterX); + map.setEnterY(enterY); + map.setResetTimeout(resetTimeout); + map.setBackgroundMusic(backgroundMusic); + map.setSwapTime(swapTime); + map.setDifficulty(difficulty); + map.setFixedReset(checkboxFixedReset.isSelected()); + map.setDarkness(darkness); + map.setUnique(checkboxUnique.isSelected()); + map.setOutdoor(checkboxOutdoor.isSelected()); + map.setNosmooth(checkboxNosmooth.isSelected()); - map.setRegion(region); - map.setEnterX(enterX); - map.setEnterY(enterY); - map.setResetTimeout(resetTimeout); - map.setBackgroundMusic(backgroundMusic); - map.setSwapTime(swapTime); - map.setDifficulty(difficulty); - map.setFixedReset(checkboxFixedReset.isSelected()); - map.setDarkness(darkness); - map.setUnique(checkboxUnique.isSelected()); - map.setOutdoor(checkboxOutdoor.isSelected()); - map.setNosmooth(checkboxNosmooth.isSelected()); + map.setShopItems(shopItems); + map.setShopRace(shopRace); + map.setShopMin(shopMin); + map.setShopMax(shopMax); + map.setShopGreed(shopGreedd); - map.setShopItems(shopItems); - map.setShopRace(shopRace); - map.setShopMin(shopMin); - map.setShopMax(shopMax); - map.setShopGreed(shopGreedd); + map.setTemp(temperature); + map.setPressure(pressure); + map.setHumid(humidity); + map.setWindspeed(windSpeed); + map.setWinddir(windDirection); + map.setSky(skySetting); - map.setTemp(temperature); - map.setPressure(pressure); - map.setHumid(humidity); - map.setWindspeed(windSpeed); - map.setWinddir(windDirection); - map.setSky(skySetting); - - mapTilePane.modifyMapProperties(); - - map.endTransaction(); + mapTilePane.modifyMapProperties(); + } finally { + map.endTransaction(); + } } finally { mapModel.endTransaction(); } Modified: trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java 2008-11-02 18:11:45 UTC (rev 5659) +++ trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java 2008-11-02 18:14:07 UTC (rev 5660) @@ -478,35 +478,36 @@ mapModel.beginTransaction("Map properties"); // TODO: I18N/L10N try { map.beginTransaction(); + try { + final String mapNameString = mapName.getText() + (mapSound.getText().length() > 0 ? '§' + mapSound.getText() + "|0|-1" : ""); + mapModel.resizeMap(mapSize); + map.setText(mapDescription.getText()); + map.setMapName(mapNameString); - final String mapNameString = mapName.getText() + (mapSound.getText().length() > 0 ? '§' + mapSound.getText() + "|0|-1" : ""); - mapModel.resizeMap(mapSize); - map.setText(mapDescription.getText()); - map.setMapName(mapNameString); + map.setEnterX(enterX); + map.setEnterY(enterY); + map.setResetTimeout(resetTimeout); + map.setSwapTime(swapTime); + map.setDifficulty(difficulty); + map.setFixedReset(checkboxFixedReset.isSelected()); + map.setDarkness(darkness); + map.setOutdoor(checkboxOutdoor.isSelected()); - map.setEnterX(enterX); - map.setEnterY(enterY); - map.setResetTimeout(resetTimeout); - map.setSwapTime(swapTime); - map.setDifficulty(difficulty); - map.setFixedReset(checkboxFixedReset.isSelected()); - map.setDarkness(darkness); - map.setOutdoor(checkboxOutdoor.isSelected()); + map.setNoSave(checkboxNoSave.isSelected()); + map.setNoMagic(checkboxNoMagic.isSelected()); + map.setNoPriest(checkboxNoPriest.isSelected()); + map.setNoHarm(checkboxNoHarm.isSelected()); + map.setNoSummon(checkboxNoSummon.isSelected()); + map.setFixedLogin(checkboxNoFixedLogin.isSelected()); + map.setPermDeath(checkboxPermDeath.isSelected()); + map.setUltraDeath(checkboxUltraDeath.isSelected()); + map.setUltimateDeath(checkboxUltimateDeath.isSelected()); + map.setPvp(checkboxPvp.isSelected()); - map.setNoSave(checkboxNoSave.isSelected()); - map.setNoMagic(checkboxNoMagic.isSelected()); - map.setNoPriest(checkboxNoPriest.isSelected()); - map.setNoHarm(checkboxNoHarm.isSelected()); - map.setNoSummon(checkboxNoSummon.isSelected()); - map.setFixedLogin(checkboxNoFixedLogin.isSelected()); - map.setPermDeath(checkboxPermDeath.isSelected()); - map.setUltraDeath(checkboxUltraDeath.isSelected()); - map.setUltimateDeath(checkboxUltimateDeath.isSelected()); - map.setPvp(checkboxPvp.isSelected()); - - mapTilePane.modifyMapProperties(); - - map.endTransaction(); + mapTilePane.modifyMapProperties(); + } finally { + map.endTransaction(); + } } finally { mapModel.endTransaction(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-02 18:15:29
|
Revision: 5661 http://gridarta.svn.sourceforge.net/gridarta/?rev=5661&view=rev Author: akirschbaum Date: 2008-11-02 18:15:26 +0000 (Sun, 02 Nov 2008) Log Message: ----------- Rename variable name. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java Modified: trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java 2008-11-02 18:14:07 UTC (rev 5660) +++ trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java 2008-11-02 18:15:26 UTC (rev 5661) @@ -491,48 +491,47 @@ // now that all is well, write the new values into the map arch object - final MapArchObject map = mapControl.getMapModel().getMapArchObject(); - final MapModel<GameObject, MapArchObject, Archetype> mapModel = mapControl.getMapModel(); try { mapModel.beginTransaction("Map properties"); // TODO: I18N/L10N - map.beginTransaction(); + final MapArchObject mapArchObject = mapModel.getMapArchObject(); + mapArchObject.beginTransaction(); try { final String mapNameString = mapName.getText(); mapModel.resizeMap(mapSize); - map.setText(mapDescription.getText()); - map.setLore(mapLore.getText()); - map.setMapName(mapNameString); + mapArchObject.setText(mapDescription.getText()); + mapArchObject.setLore(mapLore.getText()); + mapArchObject.setMapName(mapNameString); - map.setRegion(region); - map.setEnterX(enterX); - map.setEnterY(enterY); - map.setResetTimeout(resetTimeout); - map.setBackgroundMusic(backgroundMusic); - map.setSwapTime(swapTime); - map.setDifficulty(difficulty); - map.setFixedReset(checkboxFixedReset.isSelected()); - map.setDarkness(darkness); - map.setUnique(checkboxUnique.isSelected()); - map.setOutdoor(checkboxOutdoor.isSelected()); - map.setNosmooth(checkboxNosmooth.isSelected()); + mapArchObject.setRegion(region); + mapArchObject.setEnterX(enterX); + mapArchObject.setEnterY(enterY); + mapArchObject.setResetTimeout(resetTimeout); + mapArchObject.setBackgroundMusic(backgroundMusic); + mapArchObject.setSwapTime(swapTime); + mapArchObject.setDifficulty(difficulty); + mapArchObject.setFixedReset(checkboxFixedReset.isSelected()); + mapArchObject.setDarkness(darkness); + mapArchObject.setUnique(checkboxUnique.isSelected()); + mapArchObject.setOutdoor(checkboxOutdoor.isSelected()); + mapArchObject.setNosmooth(checkboxNosmooth.isSelected()); - map.setShopItems(shopItems); - map.setShopRace(shopRace); - map.setShopMin(shopMin); - map.setShopMax(shopMax); - map.setShopGreed(shopGreedd); + mapArchObject.setShopItems(shopItems); + mapArchObject.setShopRace(shopRace); + mapArchObject.setShopMin(shopMin); + mapArchObject.setShopMax(shopMax); + mapArchObject.setShopGreed(shopGreedd); - map.setTemp(temperature); - map.setPressure(pressure); - map.setHumid(humidity); - map.setWindspeed(windSpeed); - map.setWinddir(windDirection); - map.setSky(skySetting); + mapArchObject.setTemp(temperature); + mapArchObject.setPressure(pressure); + mapArchObject.setHumid(humidity); + mapArchObject.setWindspeed(windSpeed); + mapArchObject.setWinddir(windDirection); + mapArchObject.setSky(skySetting); mapTilePane.modifyMapProperties(); } finally { - map.endTransaction(); + mapArchObject.endTransaction(); } } finally { mapModel.endTransaction(); Modified: trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java 2008-11-02 18:14:07 UTC (rev 5660) +++ trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java 2008-11-02 18:15:26 UTC (rev 5661) @@ -472,41 +472,40 @@ // now that all is well, write the new values into the map arch object - final MapArchObject map = mapControl.getMapModel().getMapArchObject(); - final MapModel<GameObject, MapArchObject, Archetype> mapModel = mapControl.getMapModel(); mapModel.beginTransaction("Map properties"); // TODO: I18N/L10N try { - map.beginTransaction(); + final MapArchObject mapArchObject = mapModel.getMapArchObject(); + mapArchObject.beginTransaction(); try { final String mapNameString = mapName.getText() + (mapSound.getText().length() > 0 ? '§' + mapSound.getText() + "|0|-1" : ""); mapModel.resizeMap(mapSize); - map.setText(mapDescription.getText()); - map.setMapName(mapNameString); + mapArchObject.setText(mapDescription.getText()); + mapArchObject.setMapName(mapNameString); - map.setEnterX(enterX); - map.setEnterY(enterY); - map.setResetTimeout(resetTimeout); - map.setSwapTime(swapTime); - map.setDifficulty(difficulty); - map.setFixedReset(checkboxFixedReset.isSelected()); - map.setDarkness(darkness); - map.setOutdoor(checkboxOutdoor.isSelected()); + mapArchObject.setEnterX(enterX); + mapArchObject.setEnterY(enterY); + mapArchObject.setResetTimeout(resetTimeout); + mapArchObject.setSwapTime(swapTime); + mapArchObject.setDifficulty(difficulty); + mapArchObject.setFixedReset(checkboxFixedReset.isSelected()); + mapArchObject.setDarkness(darkness); + mapArchObject.setOutdoor(checkboxOutdoor.isSelected()); - map.setNoSave(checkboxNoSave.isSelected()); - map.setNoMagic(checkboxNoMagic.isSelected()); - map.setNoPriest(checkboxNoPriest.isSelected()); - map.setNoHarm(checkboxNoHarm.isSelected()); - map.setNoSummon(checkboxNoSummon.isSelected()); - map.setFixedLogin(checkboxNoFixedLogin.isSelected()); - map.setPermDeath(checkboxPermDeath.isSelected()); - map.setUltraDeath(checkboxUltraDeath.isSelected()); - map.setUltimateDeath(checkboxUltimateDeath.isSelected()); - map.setPvp(checkboxPvp.isSelected()); + mapArchObject.setNoSave(checkboxNoSave.isSelected()); + mapArchObject.setNoMagic(checkboxNoMagic.isSelected()); + mapArchObject.setNoPriest(checkboxNoPriest.isSelected()); + mapArchObject.setNoHarm(checkboxNoHarm.isSelected()); + mapArchObject.setNoSummon(checkboxNoSummon.isSelected()); + mapArchObject.setFixedLogin(checkboxNoFixedLogin.isSelected()); + mapArchObject.setPermDeath(checkboxPermDeath.isSelected()); + mapArchObject.setUltraDeath(checkboxUltraDeath.isSelected()); + mapArchObject.setUltimateDeath(checkboxUltimateDeath.isSelected()); + mapArchObject.setPvp(checkboxPvp.isSelected()); mapTilePane.modifyMapProperties(); } finally { - map.endTransaction(); + mapArchObject.endTransaction(); } } finally { mapModel.endTransaction(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-02 19:11:00
|
Revision: 5666 http://gridarta.svn.sourceforge.net/gridarta/?rev=5666&view=rev Author: akirschbaum Date: 2008-11-02 19:10:56 +0000 (Sun, 02 Nov 2008) Log Message: ----------- Remove support for obsolete 'editable' attribute. Modified Paths: -------------- trunk/crossfire/resource/conf/archetypes trunk/src/app/net/sf/gridarta/gameobject/GameObject.java Modified: trunk/crossfire/resource/conf/archetypes =================================================================== --- trunk/crossfire/resource/conf/archetypes 2008-11-02 18:57:20 UTC (rev 5665) +++ trunk/crossfire/resource/conf/archetypes 2008-11-02 19:10:56 UTC (rev 5666) @@ -16287,7 +16287,6 @@ face Nimground3_purple.111 animation Nimground3_purple no_pick 1 -editable 8 is_floor 1 speed 0.3 end @@ -19986,7 +19985,6 @@ value 50 container 150000 weight 40000 -editable 128 identified 1 name_pl chests client_type 51 @@ -19999,7 +19997,6 @@ no_pick 1 no_drop 1 identified 1 -editable 0 end #This chest is for errac's heaven area. Don't use elsewhare please. --MikeeUSA-- @@ -20015,7 +20012,6 @@ value 50 container 150000 weight 40000 -editable 128 identified 1 name_pl chests client_type 51 @@ -20030,7 +20026,6 @@ no_pick 1 no_drop 1 identified 1 -editable 0 end Object depositbox @@ -23872,7 +23867,6 @@ can_cast_spell 1 can_see_in_dark 1 see_invisible 1 -editable 1 end More Object purple_worm_2 Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-11-02 18:57:20 UTC (rev 5665) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-11-02 19:10:56 UTC (rev 5666) @@ -1603,8 +1603,6 @@ } else if (line.startsWith("start_script_")) { addObjectText(line); scriptflag = true; - } else if (line.startsWith("editable ")) { - setEditType(Integer.parseInt(line.substring(9))); } else if (line.startsWith("name ")) { setObjName(line.substring(5)); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-02 20:13:07
|
Revision: 5667 http://gridarta.svn.sourceforge.net/gridarta/?rev=5667&view=rev Author: akirschbaum Date: 2008-11-02 20:13:05 +0000 (Sun, 02 Nov 2008) Log Message: ----------- Fix #1621868 (Connection view poorly placed). Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-11-02 19:10:56 UTC (rev 5666) +++ trunk/crossfire/ChangeLog 2008-11-02 20:13:05 UTC (rev 5667) @@ -1,3 +1,9 @@ +2008-11-02 Andreas Kirschbaum + + * Fix #1621868 (Connection view poorly placed): split the tabs + into "Game Object" (tabs related to the selected game object) and + "Map" (tabs related to the current map). + 2008-11-01 Andreas Kirschbaum * Make connection errors (connection without sink/source) Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-11-02 19:10:56 UTC (rev 5666) +++ trunk/daimonin/ChangeLog 2008-11-02 20:13:05 UTC (rev 5667) @@ -1,3 +1,9 @@ +2008-11-02 Andreas Kirschbaum + + * Fix #1621868 (Connection view poorly placed): split the tabs + into "Game Object" (tabs related to the selected game object) and + "Map" (tabs related to the current map). + 2008-11-01 Andreas Kirschbaum * Make connection errors (connection without sink/source) Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2008-11-02 19:10:56 UTC (rev 5666) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2008-11-02 20:13:05 UTC (rev 5667) @@ -95,10 +95,17 @@ @NotNull private final ObjectChooser<G, A, R> objectChooser; - /** The tabs of this GameObjectAttributesPanel. */ - private final JTabbedPane panelDesktop = new JTabbedPane(SwingConstants.TOP); + /** + * The tabs referring to the selected game object. + */ + private final JTabbedPane gameObjectPanelDesktop = new JTabbedPane(SwingConstants.TOP); /** + * The tabs referring to the selected map. + */ + private final JTabbedPane mapPanelDesktop = new JTabbedPane(SwingConstants.TOP); + + /** * The model used by this controller. */ private final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel; @@ -135,7 +142,8 @@ /** * Maps tab to index. Tabs not currently visible are missing. The game - * object text editor tab is not included. + * object text editor tab is not included. Negative indices map to {@link + * #mapPanelDesktop}, non-negative indices map to {@link #gameObjectPanelDesktop}. */ private final Map<GameObjectAttributesTab<G, A, R>, Integer> tabIndex = new IdentityHashMap<GameObjectAttributesTab<G, A, R>, Integer>(); @@ -317,17 +325,20 @@ this.gameObjectAttributesDialogFactory = gameObjectAttributesDialogFactory; this.objectChooser = objectChooser; + final JTabbedPane tabbedPane = new JTabbedPane(SwingConstants.LEFT); + add(tabbedPane, BorderLayout.CENTER); + mapArchPanel.setLayout(new BorderLayout()); splitPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, mapArchPanel, gameObjectTextEditor); splitPane.setContinuousLayout(true); splitPane.setResizeWeight(1); splitPane.setDividerLocation(prefs.getInt(MAPARCHPANEL_LOCATION_KEY, getMapArchPanelLocation())); - add(splitPane, BorderLayout.CENTER); + tabbedPane.add(splitPane, "Game Object"); final JPanel buttonPanel = createButtonPanel(); buttonPanel.setLayout(new GridLayout(0, 1)); mapArchPanel.add(buttonPanel, BorderLayout.WEST); - mapArchPanel.add(panelDesktop, BorderLayout.CENTER); + mapArchPanel.add(gameObjectPanelDesktop, BorderLayout.CENTER); selectedSquareControl.addSelectedSquareListener(selectedSquareListener); gameObjectAttributesModel.addGameObjectAttributesModelListener(gameObjectAttributesModelListener); // this listener must be registered before any tab, including TextEditorTab @@ -342,24 +353,29 @@ mapManager.addMapManagerListener(mapManagerListener); addTabInt(new TextEditorTab<G, A, R>(gameObjectAttributesModel, gameObjectTextEditor)); - addTab(new ArchTab<G, A, R>(archetypeTypeSet, gameObjectAttributesModel, gameObjectTextEditor)); - addTab(new MsgTextTab<G, A, R>(gameObjectAttributesModel)); - addTab(new ScriptTab<G, A, R>(parent, mapManager, gameObjectAttributesModel)); - addTab(new AnimationTab<G, A, R>(animationObjects, gameObjectAttributesModel)); - addTab(new ConnectionsTab<G, A, R, V>(mapManager, mapViewManager, gameObjectAttributesModel)); - addTab(new LockedItemsTab<G, A, R, V>(lockedItemsControl, gameObjectAttributesModel)); - addTab(new MonstersTab<G, A, R, V>(mapManager, mapViewManager, monsterMatcher, gameObjectAttributesModel)); - addTab(new WarningsTab<G, A, R, V>(mapManager, selectedSquareView, gameObjectAttributesModel)); + addTab(new ArchTab<G, A, R>(archetypeTypeSet, gameObjectAttributesModel, gameObjectTextEditor), true); + addTab(new MsgTextTab<G, A, R>(gameObjectAttributesModel), true); + addTab(new ScriptTab<G, A, R>(parent, mapManager, gameObjectAttributesModel), true); + addTab(new AnimationTab<G, A, R>(animationObjects, gameObjectAttributesModel), true); + addTab(new ConnectionsTab<G, A, R, V>(mapManager, mapViewManager, gameObjectAttributesModel), false); + addTab(new LockedItemsTab<G, A, R, V>(lockedItemsControl, gameObjectAttributesModel), false); + addTab(new MonstersTab<G, A, R, V>(mapManager, mapViewManager, monsterMatcher, gameObjectAttributesModel), false); + addTab(new WarningsTab<G, A, R, V>(mapManager, selectedSquareView, gameObjectAttributesModel), false); + + final JPanel mapPanel = new JPanel(); + mapPanel.setLayout(new BorderLayout()); + mapPanel.add(mapPanelDesktop, BorderLayout.CENTER); + tabbedPane.add(mapPanel, "Map"); } /** * Adds a tab. * @param tab the tab to add */ - public void addTab(final GameObjectAttributesTab<G, A, R> tab) { - tabIndex.put(tab, panelDesktop.getTabCount()); + public void addTab(final GameObjectAttributesTab<G, A, R> tab, final boolean gameObjectPanel) { + tabIndex.put(tab, (gameObjectPanel ? gameObjectPanelDesktop.getTabCount() : -1-mapPanelDesktop.getTabCount())); addTabInt(tab); - panelDesktop.add(tab.getPanel(), tab.getName()); + (gameObjectPanel ? gameObjectPanelDesktop : mapPanelDesktop).add(tab.getPanel(), tab.getName()); setTabColor(tab, tab.getTabColor()); } @@ -379,9 +395,13 @@ */ private void setTabColor(final GameObjectAttributesTab<G, A, R> tab, final Color tabColor) { final Integer index = tabIndex.get(tab); - if (index != null) { - panelDesktop.setForegroundAt(index, tabColor); + if (index == null) { + return; } + + final int index2 = index >= 0 ? index : -1-index; + final JTabbedPane tabbedPane = index >= 0 ? gameObjectPanelDesktop : mapPanelDesktop; + tabbedPane.setForegroundAt(index2, tabColor); } /** Update the displayed information for the selected game object. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-02 20:32:15
|
Revision: 5669 http://gridarta.svn.sourceforge.net/gridarta/?rev=5669&view=rev Author: akirschbaum Date: 2008-11-02 20:32:10 +0000 (Sun, 02 Nov 2008) Log Message: ----------- Fix #1650940 (face for disabled animation is not shown). Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gameobject/GameObject.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-11-02 20:25:59 UTC (rev 5668) +++ trunk/crossfire/ChangeLog 2008-11-02 20:32:10 UTC (rev 5669) @@ -1,5 +1,7 @@ 2008-11-02 Andreas Kirschbaum + * Fix #1650940 (face for disabled animation is not shown). + * Fix #1621868 (Connection view poorly placed): split the tabs into "Game Object" (tabs related to the selected game object) and "Map" (tabs related to the current map). Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-11-02 20:25:59 UTC (rev 5668) +++ trunk/daimonin/ChangeLog 2008-11-02 20:32:10 UTC (rev 5669) @@ -1,5 +1,7 @@ 2008-11-02 Andreas Kirschbaum + * Fix #1650940 (face for disabled animation is not shown). + * Fix #1621868 (Connection view poorly placed): split the tabs into "Game Object" (tabs related to the selected game object) and "Map" (tabs related to the current map). Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-11-02 20:25:59 UTC (rev 5668) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-11-02 20:32:10 UTC (rev 5669) @@ -1760,7 +1760,7 @@ @Nullable String effectiveFaceObjName; - if (effectiveAnimName != null) { // we have a animation - get the frame picture + if (effectiveAnimName != null && !effectiveAnimName.equals("NONE")) { // we have a animation - get the frame picture if (animationObjects == null) { effectiveFaceObjName = null; } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-05 20:28:21
|
Revision: 5670 http://gridarta.svn.sourceforge.net/gridarta/?rev=5670&view=rev Author: akirschbaum Date: 2008-11-05 20:28:09 +0000 (Wed, 05 Nov 2008) Log Message: ----------- Fix #2152115 (Event Types hardcoded). Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/resource/conf/types.xml trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/scripts/DefaultScriptArchUtils.java trunk/daimonin/ChangeLog trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gameobject/scripts/DefaultScriptArchUtils.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeSetParser.java trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchUtils.java trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchUtils.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-11-02 20:32:10 UTC (rev 5669) +++ trunk/crossfire/ChangeLog 2008-11-05 20:28:09 UTC (rev 5670) @@ -1,3 +1,8 @@ +2008-11-05 Andreas Kirschbaum + + * Fix #2152115 (Event Types hardcoded). Available event types are + read from types.xml from <list name="event">. + 2008-11-02 Andreas Kirschbaum * Fix #1650940 (face for disabled animation is not shown). Modified: trunk/crossfire/resource/conf/types.xml =================================================================== --- trunk/crossfire/resource/conf/types.xml 2008-11-02 20:32:10 UTC (rev 5669) +++ trunk/crossfire/resource/conf/types.xml 2008-11-05 20:28:09 UTC (rev 5670) @@ -71,7 +71,6 @@ # bool_special - Like bool, but with customized true/false values # # treasurelist - CF treasure list (see "treasures" file) # # list_LISTNAME - list, must be defined as a <list> element; # -# The list "event" is pre-defined. # # doublelist_LISTNAME,LISTNAME # # - two lists, must be defined as a <list> elements # # bitmask_BITMASKNAME - bitmask, must be defined as a <bitmask> # @@ -194,6 +193,23 @@ <listentry value="8" name="northwest" /> </list> + <list name="event"> + <listentry value="1" name="apply" /> + <listentry value="2" name="attack" /> + <listentry value="3" name="death" /> + <listentry value="4" name="drop" /> + <listentry value="5" name="pickup" /> + <listentry value="6" name="say" /> + <listentry value="7" name="stop" /> + <listentry value="8" name="time" /> + <listentry value="9" name="throw" /> + <listentry value="10" name="trigger" /> + <listentry value="11" name="close" /> + <listentry value="12" name="timer" /> + <listentry value="13" name="destroy" /> + <listentry value="31" name="user" /> + </list> + <list name="mood"> <listentry value="0" name="furious" /> <listentry value="1" name="angry" /> Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-02 20:32:10 UTC (rev 5669) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-05 20:28:09 UTC (rev 5670) @@ -51,7 +51,6 @@ import net.sf.gridarta.GlobalSettings; import net.sf.gridarta.MapImageCache; import net.sf.gridarta.MapManager; -import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.filter.FilterControl; import net.sf.gridarta.gameobject.AbstractArchetypeParser; import net.sf.gridarta.gameobject.ArchetypeFactory; @@ -276,8 +275,7 @@ /** {@inheritDoc} */ @NotNull @Override - protected MapActions init1(@NotNull final MapViewSettings mapViewSettings, @NotNull final ScriptArchUtils scriptArchUtils, @NotNull final MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final GlobalSettings globalSettings, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final GameObjectMatcher exitMatcher) { - archetypeTypeSet.getListTable().put("event", scriptArchUtils.getEventTypes()); + protected MapActions init1(@NotNull final MapViewSettings mapViewSettings, @NotNull final MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final GlobalSettings globalSettings, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final GameObjectMatcher exitMatcher) { final int[] directionMap = new int[] { CommonConstants.NORTH, CommonConstants.EAST, Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/DefaultScriptArchUtils.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/DefaultScriptArchUtils.java 2008-11-02 20:32:10 UTC (rev 5669) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/DefaultScriptArchUtils.java 2008-11-05 20:28:09 UTC (rev 5670) @@ -24,27 +24,6 @@ public class DefaultScriptArchUtils extends AbstractScriptArchUtils { - /** - * Creates a new instance. - */ - public DefaultScriptArchUtils() { - // FIXME: This should NOT BE HERE. Instead, it should be read from types.xml. - add(1, "apply"); - add(2, "attack"); - add(3, "death"); - add(4, "drop"); - add(5, "pickup"); - add(6, "say"); - add(7, "stop"); - add(8, "time"); - add(9, "throw"); - add(10, "trigger"); - add(11, "close"); - add(12, "timer"); - add(13, "destroy"); - add(31, "user"); - } - /** {@inheritDoc} */ @Nullable public String getArchetypeNameForEventType(final int eventType) { Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-11-02 20:32:10 UTC (rev 5669) +++ trunk/daimonin/ChangeLog 2008-11-05 20:28:09 UTC (rev 5670) @@ -1,3 +1,8 @@ +2008-11-05 Andreas Kirschbaum + + * Fix #2152115 (Event Types hardcoded). Available event types are + read from types.xml from <list name="event">. + 2008-11-02 Andreas Kirschbaum * Fix #1650940 (face for disabled animation is not shown). Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-11-02 20:32:10 UTC (rev 5669) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-11-05 20:28:09 UTC (rev 5670) @@ -52,7 +52,6 @@ import net.sf.gridarta.GlobalSettings; import net.sf.gridarta.MapImageCache; import net.sf.gridarta.MapManager; -import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.filter.FilterControl; import net.sf.gridarta.gameobject.AbstractArchetypeParser; import net.sf.gridarta.gameobject.ArchetypeFactory; @@ -309,7 +308,7 @@ /** {@inheritDoc} */ @NotNull @Override - protected MapActions init1(@NotNull final MapViewSettings mapViewSettings, @NotNull final ScriptArchUtils scriptArchUtils, @NotNull final MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final GlobalSettings globalSettings, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final GameObjectMatcher exitMatcher) { + protected MapActions init1(@NotNull final MapViewSettings mapViewSettings, @NotNull final MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final GlobalSettings globalSettings, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final GameObjectMatcher exitMatcher) { final int[] directionMap = new int[] { CommonConstants.NORTH_EAST, CommonConstants.SOUTH_EAST, Modified: trunk/daimonin/src/daieditor/gameobject/scripts/DefaultScriptArchUtils.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/DefaultScriptArchUtils.java 2008-11-02 20:32:10 UTC (rev 5669) +++ trunk/daimonin/src/daieditor/gameobject/scripts/DefaultScriptArchUtils.java 2008-11-05 20:28:09 UTC (rev 5670) @@ -24,26 +24,6 @@ public class DefaultScriptArchUtils extends AbstractScriptArchUtils { - /** - * Creates a new instance. - */ - public DefaultScriptArchUtils() { - // FIXME: This should NOT BE HERE. Instead, it should be read from types.xml. - add(1, "apply"); - add(2, "attack"); - add(3, "death"); - add(4, "drop"); - add(5, "pickup"); - add(6, "say"); - add(7, "stop"); - add(8, "time (don't use)"); - add(9, "throw"); - add(10, "trigger"); - add(11, "close"); - add(12, "examine"); - add(13, "talk"); - } - /** {@inheritDoc} */ @Nullable public String getArchetypeNameForEventType(final int eventType) { Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-02 20:32:10 UTC (rev 5669) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-05 20:28:09 UTC (rev 5670) @@ -416,7 +416,7 @@ final GameObjectMatcher exitMatcher = gameObjectMatchers.getMatcherFatal("system_exit", "exit"); final ScriptArchUtils scriptArchUtils = newScriptArchUtils(); final MapViewSettings mapViewSettings = new MapViewSettings(); - final MapActions mapActions = init1(mapViewSettings, scriptArchUtils, mapArchObjectParserFactory, mapArchObjectFactory, globalSettings, mapManager, mapViewManager, archetypeTypeSet, selectedSquareView, exitMatcher); + final MapActions mapActions = init1(mapViewSettings, mapArchObjectParserFactory, mapArchObjectFactory, globalSettings, mapManager, mapViewManager, selectedSquareView, exitMatcher); Map<String, TreasureTreeNode> specialTreasureLists; try { final Document specialTreasureListsDocument = xmlHelper.getDocumentBuilder().parse(IOUtils.getResourceURLAsString(globalSettings.getConfigurationDirectory(), "TreasureLists.xml")); @@ -438,6 +438,7 @@ } catch (final FileNotFoundException ex) { log.error("Cannot read " + CommonConstants.TYPEDEF_FILE + ": " + ex.getMessage()); } + scriptArchUtils.setEventTypes(archetypeTypeSet.getListTable().get("event")); final LockedItemsControl<G, A, R, V> lockedItemsControl = new LockedItemsControl<G, A, R, V>(mapManager, mapViewManager, lockedItemsTypeNumbers); final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel = new GameObjectAttributesModel<G, A, R>(); gameObjectAttributesControl = new GameObjectAttributesControl<G, A, R, V>(gameObjectAttributesModel, gameObjectAttributesDialogFactory, objectChooser, archetypeTypeSet, mapManager, mapViewManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); @@ -562,7 +563,7 @@ protected abstract CFTreasureListTree<G, A, R> createTreasureListTree(@NotNull final GlobalSettings globalSettings, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull Map<String, TreasureTreeNode> specialTreasureLists); @NotNull - protected abstract MapActions init1(@NotNull final MapViewSettings mapViewSettings, @NotNull final ScriptArchUtils scriptArchUtils, @NotNull final MapArchObjectParserFactory<A> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final GlobalSettings globalSettings, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager, @NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull final GameObjectMatcher exitMatcher); + protected abstract MapActions init1(@NotNull final MapViewSettings mapViewSettings, @NotNull final MapArchObjectParserFactory<A> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final GlobalSettings globalSettings, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull final GameObjectMatcher exitMatcher); protected abstract void init4(@NotNull final GameObjectParser<G, A, R> gameObjectParser, @NotNull final AbstractArchetypeParser<G, A, R> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, final MainView<G, A, R, V> mainView, @NotNull final GlobalSettings globalSettings, @NotNull final ArchetypeSet<G, A, R> archetypeSet); Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeSetParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeSetParser.java 2008-11-02 20:32:10 UTC (rev 5669) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeSetParser.java 2008-11-05 20:28:09 UTC (rev 5670) @@ -153,7 +153,7 @@ // every list entry adds value (Integer) and name (String) to the vector try { list.add(Integer.valueOf(elem.getAttribute("value"))); - list.add(" " + elem.getAttribute("name").trim()); + list.add(elem.getAttribute("name")); } catch (final NumberFormatException ignore) { throw new ArchetypeTypeParseException("In '" + CommonConstants.TYPEDEF_FILE + "', list " + root.getAttribute("name") + ": value '" + elem.getAttribute("value") + "' is not an integer."); } Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchUtils.java 2008-11-02 20:32:10 UTC (rev 5669) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchUtils.java 2008-11-05 20:28:09 UTC (rev 5670) @@ -21,10 +21,12 @@ import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import javax.swing.JComboBox; import net.sf.japi.util.Arrays2; +import org.jetbrains.annotations.NotNull; public abstract class AbstractScriptArchUtils implements ScriptArchUtils { @@ -54,7 +56,7 @@ * @param eventType the event type * @param eventName the event name */ - protected void add(final int eventType, final String eventName) { + private void add(final int eventType, final String eventName) { assert !allEventTypes.containsKey(eventType); allEventTypes.put(eventType, eventName); indexToEventType.put(eventNames.size(), eventType); @@ -85,13 +87,13 @@ } /** {@inheritDoc} */ - public List<?> getEventTypes() { - final List<Object> result = new ArrayList<Object>(); - for (final Map.Entry<Integer, String> e : allEventTypes.entrySet()) { - result.add(e.getKey()); - result.add(e.getValue()); + public void setEventTypes(@NotNull final List<?> eventTypes) { + final Iterator<?> it = eventTypes.iterator(); + while (it.hasNext()) { + final int eventType = (Integer) it.next(); + final String eventName = (String) it.next(); + add(eventType, eventName); } - return result; } } // class AbstractScriptArchUtils Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchUtils.java 2008-11-02 20:32:10 UTC (rev 5669) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchUtils.java 2008-11-05 20:28:09 UTC (rev 5670) @@ -21,6 +21,7 @@ import java.util.List; import javax.swing.JComboBox; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public interface ScriptArchUtils { @@ -51,9 +52,9 @@ int indexToEventType(int index); /** - * Returns all event types. - * @return the event types + * Sets all event types. + * @param eventTypes the event types */ - List<?> getEventTypes(); + void setEventTypes(@NotNull final List<?> eventTypes); } // interface ScriptArchUtils This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-06 17:29:49
|
Revision: 5671 http://gridarta.svn.sourceforge.net/gridarta/?rev=5671&view=rev Author: akirschbaum Date: 2008-11-06 17:29:33 +0000 (Thu, 06 Nov 2008) Log Message: ----------- Rename "Scripts" tab to "Events" in game object attributes panel. Use the term "event" for event game objects and "script" for script files. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/scripts/DefaultScriptArchData.java 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 trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ScriptTab.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-11-05 20:28:09 UTC (rev 5670) +++ trunk/crossfire/ChangeLog 2008-11-06 17:29:33 UTC (rev 5671) @@ -1,3 +1,9 @@ +2008-11-06 Andreas Kirschbaum + + * Rename "Scripts" tab to "Events" in game object attributes + panel. Use the term "event" for event game objects and "script" + for script files. + 2008-11-05 Andreas Kirschbaum * Fix #2152115 (Event Types hardcoded). Available event types are Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-11-05 20:28:09 UTC (rev 5670) +++ trunk/daimonin/ChangeLog 2008-11-06 17:29:33 UTC (rev 5671) @@ -1,3 +1,9 @@ +2008-11-06 Andreas Kirschbaum + + * Rename "Scripts" tab to "Events" in game object attributes + panel. Use the term "event" for event game objects and "script" + for script files. + 2008-11-05 Andreas Kirschbaum * Fix #2152115 (Event Types hardcoded). Available event types are Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-11-05 20:28:09 UTC (rev 5670) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-11-06 17:29:33 UTC (rev 5671) @@ -33,7 +33,7 @@ import net.sf.gridarta.gameobject.scripts.ScriptArchData; import net.sf.gridarta.gameobject.scripts.ScriptArchEditor; import net.sf.gridarta.gui.GUIConstants; -import net.sf.gridarta.gui.gameobjectattributespanel.ScriptTab; +import net.sf.gridarta.gui.gameobjectattributespanel.EventsTab; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapSquare; import net.sf.gridarta.utils.StringUtils; @@ -1461,11 +1461,11 @@ * @param parent the parent frame for dialog boxes * @xxx this method knows things it should never know, it is evil! */ - public void modifyEventScript(final int eventType, final int task, @NotNull final JList eventList, @NotNull final ScriptTab<G, A, R> mapanel, @NotNull final MapManager<?, ?, ?, ?> mapManager, @NotNull final Frame parent) { + public void modifyEventScript(final int eventType, final int task, @NotNull final JList eventList, @NotNull final EventsTab<G, A, R> mapanel, @NotNull final MapManager<?, ?, ?, ?> mapManager, @NotNull final Frame parent) { ((ScriptArchData<G>) scriptArchData).modifyEventScript(eventType, task, eventList, mapManager, parent, (G) this); if (((ScriptArchData<G>) scriptArchData).isEmpty((G) this)) { - mapanel.setScriptPanelButtonState(true, false, false, false); + mapanel.setEventPanelButtonState(true, false, false, false); } } @@ -1478,14 +1478,14 @@ * @param mapanel the MapArchPanel * @param parent the parent frame for the editor */ - public void addEventScript(@NotNull final JList eventList, @NotNull final ScriptTab<G, A, R> mapanel, @NotNull final Frame parent) { + public void addEventScript(@NotNull final JList eventList, @NotNull final EventsTab<G, A, R> mapanel, @NotNull final Frame parent) { ((ScriptArchEditor<G>) scriptArchEditor).addEventScript((G) this, (ScriptArchData<G>) scriptArchData, parent); if (!((ScriptArchData<G>) scriptArchData).isEmpty((G) this)) { - mapanel.setScriptPanelButtonState(true, true, true, true); + mapanel.setEventPanelButtonState(true, true, true, true); ((ScriptArchData<G>) scriptArchData).addEventsToJList(eventList, (G) this); } else { - mapanel.setScriptPanelButtonState(true, false, false, false); + mapanel.setEventPanelButtonState(true, false, false, false); } } Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/DefaultScriptArchData.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/DefaultScriptArchData.java 2008-11-05 20:28:09 UTC (rev 5670) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/DefaultScriptArchData.java 2008-11-06 17:29:33 UTC (rev 5671) @@ -28,7 +28,7 @@ import javax.swing.JOptionPane; import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gui.gameobjectattributespanel.ScriptTab; +import net.sf.gridarta.gui.gameobjectattributespanel.EventsTab; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -173,11 +173,11 @@ if (oldEvent != null) { final ScriptedEvent<G> event = scriptedEventFactory.newScriptedEvent(oldEvent); // now decide what to do: - if (task == ScriptTab.SCRIPT_OPEN) { + if (task == EventsTab.EVENT_OPEN) { ScriptedEventEditor.openScript(mapManager, event.getScriptPath(), parent); - } else if (task == ScriptTab.SCRIPT_EDIT_PATH) { + } else if (task == EventsTab.EVENT_EDIT_PATH) { ScriptedEventEditor.editParameters(event, parent); - } else if (task == ScriptTab.SCRIPT_REMOVE) { + } else if (task == EventsTab.EVENT_REMOVE) { // first ask for confirmation if (JOptionPane.showConfirmDialog(panelList, "Are you sure you want to remove this \"" + scriptArchUtils.typeName(event.getEventType()) + "\" event which is\n" + "linked to the script: '" + event.getScriptPath() + "'?\n" + "(The script file itself is not going to be deleted)", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { // remove this event from the GameObject Copied: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java (from rev 5666, trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ScriptTab.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java 2008-11-06 17:29:33 UTC (rev 5671) @@ -0,0 +1,235 @@ +package net.sf.gridarta.gui.gameobjectattributespanel; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.GridLayout; +import javax.swing.Action; +import javax.swing.DefaultListModel; +import javax.swing.JButton; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.ScrollPaneConstants; +import javax.swing.border.EtchedBorder; +import net.sf.gridarta.MapManager; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapModel; +import net.sf.gridarta.map.MapSquare; +import net.sf.japi.swing.ActionFactory; +import net.sf.japi.swing.ActionMethod; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The "Events" tab in the game object attributes panel. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @author Andreas Kirschbaum + */ +public class EventsTab<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractGameObjectAttributesTab<G, A, R> { + + // constants for the 'task' parameter in editEventWanted() + public static final int EVENT_OPEN = 0; + + public static final int EVENT_EDIT_PATH = 1; + + public static final int EVENT_REMOVE = 2; + + /** The action factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); + + /** + * The parent frame for dialog boxes. + */ + @NotNull + private final Frame parent; + + /** + * The map manager. + */ + @NotNull + private final MapManager<G, A, R, ?> mapManager; + + private final Action aEventAddNew = ACTION_FACTORY.createAction(false, "eventAddNew", this); + + private final Action aEventEditData = ACTION_FACTORY.createAction(false, "eventEditData", this); + + private final Action aEventEdit = ACTION_FACTORY.createAction(false, "eventEdit", this); + + private final Action aEventRemove = ACTION_FACTORY.createAction(false, "eventRemove", this); + + private final JList eventList = new JList(); + + /** + * The currently selected game object. + */ + @Nullable + private G selectedGameObject = null; + + /** + * Creates a new instance. + * @param parent the parent frame for dialog boxes + * @param mapManager the map manager + * @param gameObjectAttributesModel the model to track + */ + public EventsTab(@NotNull final Frame parent, @NotNull final MapManager<G, A, R, ?> mapManager, @NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel) { + super(gameObjectAttributesModel); + this.parent = parent; + this.mapManager = mapManager; + refresh(gameObjectAttributesModel.getSelectedGameObject()); + } + + /** {@inheritDoc} */ + @NotNull + public String getName() { + return "Events"; + } + + /** {@inheritDoc} */ + @NotNull + public JPanel getPanel() { + // create ScrollPane for jlist scrolling + final JScrollPane ssa = new JScrollPane(eventList); + ssa.setBorder(new EtchedBorder()); + ssa.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); + ssa.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + ssa.setPreferredSize(new Dimension(80, 40)); + + // create buttons + final JPanel grid = new JPanel(new GridLayout(4, 1)); + grid.add(new JButton(aEventAddNew)); + grid.add(new JButton(aEventEditData)); + grid.add(new JButton(aEventEdit)); + grid.add(new JButton(aEventRemove)); + + // disable all the buttons in the beginning + aEventAddNew.setEnabled(false); + aEventEditData.setEnabled(false); + aEventEdit.setEnabled(false); + aEventRemove.setEnabled(false); + + final JPanel panel = new JPanel(); // new panel + panel.setLayout(new BorderLayout()); + panel.add(ssa, BorderLayout.CENTER); + panel.add(grid, BorderLayout.EAST); + panel.setPreferredSize(new Dimension(100, 40)); + return panel; + } + + /** {@inheritDoc} */ + @Override + protected void refresh(@Nullable final G gameObject) { + selectedGameObject = gameObject; + if (gameObject == null || !gameObject.isScripted()) { + setTabColor(TAB_COLOR_DEFAULT); + if (eventList.getModel() != null && eventList.getModel().getSize() > 0) { + eventList.setModel(new DefaultListModel()); + } + + aEventAddNew.setEnabled(gameObject != null); + aEventEditData.setEnabled(false); + aEventEdit.setEnabled(false); + aEventRemove.setEnabled(false); + } else { + setTabColor(TAB_COLOR_CUSTOM); + eventList.removeAll(); + gameObject.addEventsToJList(eventList); + + aEventAddNew.setEnabled(true); + aEventEditData.setEnabled(true); + aEventEdit.setEnabled(true); + aEventRemove.setEnabled(true); + } + } + + /** {@inheritDoc} */ + @Override + protected void apply(@Nullable final G gameObject) { + } + + /** Action method for creating a new event. */ + @ActionMethod + public void eventAddNew() { + addNewEventWanted(); + } + + /** Action method for editing the data of an existing event. */ + @ActionMethod + public void eventEditData() { + editEventWanted(EVENT_EDIT_PATH); + } + + /** Action method for editing an existing event. */ + @ActionMethod + public void eventEdit() { + editEventWanted(EVENT_OPEN); + } + + /** Action method for removing an existing event. */ + @ActionMethod + public void eventRemove() { + editEventWanted(EVENT_REMOVE); + } + + /** This method is invoked when the user pressed the "new event" button. */ + public void addNewEventWanted() { + if (selectedGameObject != null) { + final MapSquare<G, A, R> mapSquare = selectedGameObject.getHead().getMapSquare(); + assert mapSquare != null; + final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); + mapModel.beginTransaction("Add event"); + try { + selectedGameObject.getHead().addEventScript(eventList, this, parent); + } finally { + mapModel.endTransaction(); + } + } + } + + /** + * This method is invoked when the user pressed the "edit + * event"/"path"/"remove" button from the event panel. If there is a valid + * selection in the event list, the appropriate action for this event is + * triggered. + * @param task event type to edit (?). + */ + public void editEventWanted(final int task) { + if (selectedGameObject == null) { + return; + } + + // check for a valid selection in the event list + if (eventList.getModel() != null && eventList.getModel().getSize() > 0 && eventList.getSelectedIndex() >= 0) { + // there + final int index = eventList.getSelectedIndex(); + if (index >= 0) { + final MapSquare<G, A, R> mapSquare = selectedGameObject.getMapSquare(); + assert mapSquare != null; + final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); + mapModel.beginTransaction("Modify event"); + try { + selectedGameObject.getHead().modifyEventScript(index, task, eventList, this, mapManager, parent); + } finally { + mapModel.endTransaction(); + } + } + } + } + + /** + * Set enable/disable states for the four buttons in the event panel. + * @param newButton Enabled state for the "new" button. + * @param modifyButton Enabled state for the "modify" button. + * @param pathButton Enabled state for the "path" button. + * @param removeButton Enabled state for the "remove" button. + */ + public void setEventPanelButtonState(final boolean newButton, final boolean modifyButton, final boolean pathButton, final boolean removeButton) { + aEventAddNew.setEnabled(newButton); + aEventEditData.setEnabled(pathButton); + aEventEdit.setEnabled(modifyButton); + aEventRemove.setEnabled(removeButton); + } + +} Property changes on: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2008-11-05 20:28:09 UTC (rev 5670) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2008-11-06 17:29:33 UTC (rev 5671) @@ -355,7 +355,7 @@ addTabInt(new TextEditorTab<G, A, R>(gameObjectAttributesModel, gameObjectTextEditor)); addTab(new ArchTab<G, A, R>(archetypeTypeSet, gameObjectAttributesModel, gameObjectTextEditor), true); addTab(new MsgTextTab<G, A, R>(gameObjectAttributesModel), true); - addTab(new ScriptTab<G, A, R>(parent, mapManager, gameObjectAttributesModel), true); + addTab(new EventsTab<G, A, R>(parent, mapManager, gameObjectAttributesModel), true); addTab(new AnimationTab<G, A, R>(animationObjects, gameObjectAttributesModel), true); addTab(new ConnectionsTab<G, A, R, V>(mapManager, mapViewManager, gameObjectAttributesModel), false); addTab(new LockedItemsTab<G, A, R, V>(lockedItemsControl, gameObjectAttributesModel), false); Deleted: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ScriptTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ScriptTab.java 2008-11-05 20:28:09 UTC (rev 5670) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ScriptTab.java 2008-11-06 17:29:33 UTC (rev 5671) @@ -1,235 +0,0 @@ -package net.sf.gridarta.gui.gameobjectattributespanel; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.GridLayout; -import javax.swing.Action; -import javax.swing.DefaultListModel; -import javax.swing.JButton; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.ScrollPaneConstants; -import javax.swing.border.EtchedBorder; -import net.sf.gridarta.MapManager; -import net.sf.gridarta.gameobject.Archetype; -import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.map.MapArchObject; -import net.sf.gridarta.map.MapModel; -import net.sf.gridarta.map.MapSquare; -import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.ActionMethod; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * The "Scripts" tab in the game object attributes panel. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @author Andreas Kirschbaum - */ -public class ScriptTab<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractGameObjectAttributesTab<G, A, R> { - - // constants for the 'task' parameter in editScriptWanted() - public static final int SCRIPT_OPEN = 0; - - public static final int SCRIPT_EDIT_PATH = 1; - - public static final int SCRIPT_REMOVE = 2; - - /** The action factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); - - /** - * The parent frame for dialog boxes. - */ - @NotNull - private final Frame parent; - - /** - * The map manager. - */ - @NotNull - private final MapManager<G, A, R, ?> mapManager; - - private final Action aScriptAddNew = ACTION_FACTORY.createAction(false, "scriptAddNew", this); - - private final Action aScriptEditData = ACTION_FACTORY.createAction(false, "scriptEditData", this); - - private final Action aScriptEdit = ACTION_FACTORY.createAction(false, "scriptEdit", this); - - private final Action aScriptRemove = ACTION_FACTORY.createAction(false, "scriptRemove", this); - - private final JList eventList = new JList(); - - /** - * The currently selected game object. - */ - @Nullable - private G selectedGameObject = null; - - /** - * Creates a new instance. - * @param parent the parent frame for dialog boxes - * @param mapManager the map manager - * @param gameObjectAttributesModel the model to track - */ - public ScriptTab(@NotNull final Frame parent, @NotNull final MapManager<G, A, R, ?> mapManager, @NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel) { - super(gameObjectAttributesModel); - this.parent = parent; - this.mapManager = mapManager; - refresh(gameObjectAttributesModel.getSelectedGameObject()); - } - - /** {@inheritDoc} */ - @NotNull - public String getName() { - return "Scripts"; - } - - /** {@inheritDoc} */ - @NotNull - public JPanel getPanel() { - // create ScrollPane for jlist scrolling - final JScrollPane ssa = new JScrollPane(eventList); - ssa.setBorder(new EtchedBorder()); - ssa.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); - ssa.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - ssa.setPreferredSize(new Dimension(80, 40)); - - // create buttons - final JPanel grid = new JPanel(new GridLayout(4, 1)); - grid.add(new JButton(aScriptAddNew)); - grid.add(new JButton(aScriptEditData)); - grid.add(new JButton(aScriptEdit)); - grid.add(new JButton(aScriptRemove)); - - // disable all the buttons in the beginning - aScriptAddNew.setEnabled(false); - aScriptEditData.setEnabled(false); - aScriptEdit.setEnabled(false); - aScriptRemove.setEnabled(false); - - final JPanel panel = new JPanel(); // new panel - panel.setLayout(new BorderLayout()); - panel.add(ssa, BorderLayout.CENTER); - panel.add(grid, BorderLayout.EAST); - panel.setPreferredSize(new Dimension(100, 40)); - return panel; - } - - /** {@inheritDoc} */ - @Override - protected void refresh(@Nullable final G gameObject) { - selectedGameObject = gameObject; - if (gameObject == null || !gameObject.isScripted()) { - setTabColor(TAB_COLOR_DEFAULT); - if (eventList.getModel() != null && eventList.getModel().getSize() > 0) { - eventList.setModel(new DefaultListModel()); - } - - aScriptAddNew.setEnabled(gameObject != null); - aScriptEditData.setEnabled(false); - aScriptEdit.setEnabled(false); - aScriptRemove.setEnabled(false); - } else { - setTabColor(TAB_COLOR_CUSTOM); - eventList.removeAll(); - gameObject.addEventsToJList(eventList); - - aScriptAddNew.setEnabled(true); - aScriptEditData.setEnabled(true); - aScriptEdit.setEnabled(true); - aScriptRemove.setEnabled(true); - } - } - - /** {@inheritDoc} */ - @Override - protected void apply(@Nullable final G gameObject) { - } - - /** Action method for creating a new Script. */ - @ActionMethod - public void scriptAddNew() { - addNewScriptWanted(); - } - - /** Action method for editing the data of an existing Script. */ - @ActionMethod - public void scriptEditData() { - editScriptWanted(SCRIPT_EDIT_PATH); - } - - /** Action method for editing an existing Script. */ - @ActionMethod - public void scriptEdit() { - editScriptWanted(SCRIPT_OPEN); - } - - /** Action method for removing an existing script. */ - @ActionMethod - public void scriptRemove() { - editScriptWanted(SCRIPT_REMOVE); - } - - /** This method is invoked when the user pressed the "new script" button. */ - public void addNewScriptWanted() { - if (selectedGameObject != null) { - final MapSquare<G, A, R> mapSquare = selectedGameObject.getHead().getMapSquare(); - assert mapSquare != null; - final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); - mapModel.beginTransaction("Add event script"); - try { - selectedGameObject.getHead().addEventScript(eventList, this, parent); - } finally { - mapModel.endTransaction(); - } - } - } - - /** - * This method is invoked when the user pressed the "edit - * script"/"path"/"remove" button from the script panel. If there is a valid - * selection in the event list, the appropriate action for this script is - * triggered. - * @param task Script type to edit (?). - */ - public void editScriptWanted(final int task) { - if (selectedGameObject == null) { - return; - } - - // check for a valid selection in the event list - if (eventList.getModel() != null && eventList.getModel().getSize() > 0 && eventList.getSelectedIndex() >= 0) { - // there - final int index = eventList.getSelectedIndex(); - if (index >= 0) { - final MapSquare<G, A, R> mapSquare = selectedGameObject.getMapSquare(); - assert mapSquare != null; - final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); - mapModel.beginTransaction("Modify event script"); - try { - selectedGameObject.getHead().modifyEventScript(index, task, eventList, this, mapManager, parent); - } finally { - mapModel.endTransaction(); - } - } - } - } - - /** - * Set enable/disable states for the four buttons in the script panel. - * @param newButton Enabled state for the "new" button. - * @param modifyButton Enabled state for the "modify" button. - * @param pathButton Enabled state for the "path" button. - * @param removeButton Enabled state for the "remove" button. - */ - public void setScriptPanelButtonState(final boolean newButton, final boolean modifyButton, final boolean pathButton, final boolean removeButton) { - aScriptAddNew.setEnabled(newButton); - aScriptEditData.setEnabled(pathButton); - aScriptEdit.setEnabled(modifyButton); - aScriptRemove.setEnabled(removeButton); - } - -} Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2008-11-05 20:28:09 UTC (rev 5670) +++ trunk/src/app/net/sf/gridarta/messages.properties 2008-11-06 17:29:33 UTC (rev 5671) @@ -761,10 +761,10 @@ mapArchAddInv.text=Add Inv mapArchAddInv.shortdescription=Add object to inventory -scriptAddNew.text=Create New -scriptEditData.text=Edit Data -scriptEdit.text=Edit Script -scriptRemove.text=Remove Script +eventAddNew.text=Add Event +eventEditData.text=Edit Event +eventEdit.text=Edit Script +eventRemove.text=Remove Event direction0.text=0 direction0.shortdescription=Use no direction for the inserted object Modified: trunk/src/app/net/sf/gridarta/messages_de.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_de.properties 2008-11-05 20:28:09 UTC (rev 5670) +++ trunk/src/app/net/sf/gridarta/messages_de.properties 2008-11-06 17:29:33 UTC (rev 5671) @@ -709,10 +709,10 @@ mapArchAddInv.text=Einf\xFCgen mapArchAddInv.shortdescription=F\xFCgt ein Objekt zum Inventory hinzu -scriptAddNew.text=Script hinzuf\xFCgen -scriptEditData.text=Daten \xE4ndern -scriptEdit.text=Script \xE4ndern -scriptRemove.text=Script l\xF6schen +eventAddNew.text=Event hinzuf\xFCgen +eventEditData.text=Event \xE4ndern +eventEdit.text=Script \xE4ndern +eventRemove.text=Event l\xF6schen direction0.text=0 direction0.shortdescription=Objekt ohne Ausrichtung einf\xFCgen Modified: trunk/src/app/net/sf/gridarta/messages_fr.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-11-05 20:28:09 UTC (rev 5670) +++ trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-11-06 17:29:33 UTC (rev 5671) @@ -708,10 +708,10 @@ #mapArchAddInv.text= #mapArchAddInv.shortdescription= -#scriptAddNew.text= -#scriptEditData.text= -#scriptEdit.text= -#scriptRemove.text= +#eventAddNew.text= +#eventEditData.text= +#eventEdit.text= +#eventRemove.text= #direction0.text= #direction0.shortdescription= Modified: trunk/src/app/net/sf/gridarta/messages_sv.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-11-05 20:28:09 UTC (rev 5670) +++ trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-11-06 17:29:33 UTC (rev 5671) @@ -713,10 +713,10 @@ mapArchAddInv.text=L\xE4gg inuti mapArchAddInv.shortdescription=L\xE4gg objektet inuti -scriptAddNew.text=Skapa nytt -scriptEditData.text=Redigera data -scriptEdit.text=Redigera script -scriptRemove.text=Ta bort script +#eventAddNew.text=Skapa nytt +#eventEditData.text=Redigera data +eventEdit.text=Redigera script +#eventRemove.text=Ta bort script direction0.text=0 direction0.shortdescription=riktning 0 Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-11-05 20:28:09 UTC (rev 5670) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-11-06 17:29:33 UTC (rev 5671) @@ -50,7 +50,7 @@ import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.GUIConstants; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; -import net.sf.gridarta.gui.gameobjectattributespanel.ScriptTab; +import net.sf.gridarta.gui.gameobjectattributespanel.EventsTab; import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapActions; import net.sf.gridarta.gui.map.MapView; @@ -736,12 +736,12 @@ } /** {@inheritDoc} */ - public void modifyEventScript(final int eventType, final int task, @NotNull final JList eventList, @NotNull final ScriptTab<TestGameObject, TestMapArchObject, TestArchetype> mapanel, @NotNull final MapManager<?, ?, ?, ?> mapManager, @NotNull final Frame parent) { + public void modifyEventScript(final int eventType, final int task, @NotNull final JList eventList, @NotNull final EventsTab<TestGameObject, TestMapArchObject, TestArchetype> mapanel, @NotNull final MapManager<?, ?, ?, ?> mapManager, @NotNull final Frame parent) { throw new AssertionError(); } /** {@inheritDoc} */ - public void addEventScript(@NotNull final JList eventList, @NotNull final ScriptTab<TestGameObject, TestMapArchObject, TestArchetype> mapanel, @NotNull final Frame parent) { + public void addEventScript(@NotNull final JList eventList, @NotNull final EventsTab<TestGameObject, TestMapArchObject, TestArchetype> mapanel, @NotNull final Frame parent) { throw new AssertionError(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-07 09:11:50
|
Revision: 5672 http://gridarta.svn.sourceforge.net/gridarta/?rev=5672&view=rev Author: akirschbaum Date: 2008-11-07 09:11:46 +0000 (Fri, 07 Nov 2008) Log Message: ----------- Remove parameter from AbstractMainControl's constructor. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-06 17:29:33 UTC (rev 5671) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-07 09:11:46 UTC (rev 5672) @@ -78,6 +78,7 @@ import net.sf.gridarta.gui.map.MapPropertiesDialogFactory; import net.sf.gridarta.gui.map.MapViewFactory; import net.sf.gridarta.gui.map.MapViewSettings; +import net.sf.gridarta.gui.map.RendererFactory; import net.sf.gridarta.gui.map.tools.ToolPalette; import net.sf.gridarta.gui.newmap.NewMapDialogFactory; import net.sf.gridarta.gui.prefs.AppPrefs; @@ -142,11 +143,18 @@ * @throws RuntimeException If the controller cannot be initialized. */ public CMainControl() { - super(new DefaultRendererFactory(), "cfeditor", new GlobalSettingsImpl(), new DefaultAnimationObjects<AnimationObject>(IGUIConstants.ANIMTREE_FILE), new DefaultFaceObjects(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^.*\t\\.?(.*)"), "\\%1$05d\t./arch%2$s"), false, ConfigFileUtils.getHomeFile("thumbnails"), null, "CrossfireEditor.jar", pythonFileFilter, ".py", "Python", Archetype.TYPE_SPELL, null, Archetype.TYPE_EVENT_CONNECTOR, false, 0, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SCRIPTS_DIR); + super("cfeditor", new GlobalSettingsImpl(), new DefaultAnimationObjects<AnimationObject>(IGUIConstants.ANIMTREE_FILE), new DefaultFaceObjects(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^.*\t\\.?(.*)"), "\\%1$05d\t./arch%2$s"), false, ConfigFileUtils.getHomeFile("thumbnails"), null, "CrossfireEditor.jar", pythonFileFilter, ".py", "Python", Archetype.TYPE_SPELL, null, Archetype.TYPE_EVENT_CONNECTOR, false, 0, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SCRIPTS_DIR); } /** {@inheritDoc} */ + @NotNull @Override + protected RendererFactory<GameObject, MapArchObject, Archetype> newRendererFactory() { + return new DefaultRendererFactory(); + } + + /** {@inheritDoc} */ + @Override protected void addCollectables(@NotNull final List<Collectable> collectables) { smoothFaces = new SmoothFaces(); collectables.add(smoothFaces); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-11-06 17:29:33 UTC (rev 5671) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-11-07 09:11:46 UTC (rev 5672) @@ -81,6 +81,7 @@ import net.sf.gridarta.gui.map.MapPropertiesDialogFactory; import net.sf.gridarta.gui.map.MapViewFactory; import net.sf.gridarta.gui.map.MapViewSettings; +import net.sf.gridarta.gui.map.RendererFactory; import net.sf.gridarta.gui.map.tools.ToolPalette; import net.sf.gridarta.gui.newmap.NewMapDialogFactory; import net.sf.gridarta.gui.prefs.AppPrefs; @@ -175,11 +176,18 @@ * @throws RuntimeException If the controller cannot be initialized. */ public CMainControl() { - super(new DefaultRendererFactory(), "daieditor", new GlobalSettingsImpl(), new DefaultAnimationObjects<AnimationObject>(IGUIConstants.ANIMTREE_FILE), new DefaultFaceObjects(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^(.*)"), "%2$s"), true, null, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", luaFileFilter, ".lua", "Lua", 0, IGUIConstants.SPELL_FILE, 0, true, -1, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SCRIPTS_DIR); + super("daieditor", new GlobalSettingsImpl(), new DefaultAnimationObjects<AnimationObject>(IGUIConstants.ANIMTREE_FILE), new DefaultFaceObjects(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^(.*)"), "%2$s"), true, null, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", luaFileFilter, ".lua", "Lua", 0, IGUIConstants.SPELL_FILE, 0, true, -1, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SCRIPTS_DIR); } /** {@inheritDoc} */ + @NotNull @Override + protected RendererFactory<GameObject, MapArchObject, Archetype> newRendererFactory() { + return new DefaultRendererFactory(); + } + + /** {@inheritDoc} */ + @Override protected void addCollectables(@NotNull final List<Collectable> collectables) { } Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-06 17:29:33 UTC (rev 5671) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-07 09:11:46 UTC (rev 5672) @@ -303,7 +303,6 @@ /** * Creates a new instance. - * @param rendererFactory the renderer factory * @param key The action factory key * @param globalSettings the global settings instance * @param animationObjects the animation objects instance @@ -330,7 +329,7 @@ * default * @param scriptsDir the plugin scripts directory */ - protected AbstractMainControl(@NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final String key, @NotNull final GlobalSettings globalSettings, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final FaceObjects faceObjects, final boolean createDirectionPane, @Nullable final File mapImageCacheDir, @Nullable final ImageIcon compassIcon, @NotNull final String gridartaJarFilename, @NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, @NotNull final String scriptName, final int spellType, @Nullable final String spellFile, final int typeNoEventConnector, final boolean includeFaceText, final int undefinedSpellIndex, @NotNull final int[] lockedItemsTypeNumbers, final boolean autoValidatorDefault, @NotNull final String scriptsDir) { + protected AbstractMainControl(@NotNull final String key, @NotNull final GlobalSettings globalSettings, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final FaceObjects faceObjects, final boolean createDirectionPane, @Nullable final File mapImageCacheDir, @Nullable final ImageIcon compassIcon, @NotNull final String gridartaJarFilename, @NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, @NotNull final String scriptName, final int spellType, @Nullable final String spellFile, final int typeNoEventConnector, final boolean includeFaceText, final int undefinedSpellIndex, @NotNull final int[] lockedItemsTypeNumbers, final boolean autoValidatorDefault, @NotNull final String scriptsDir) { this.scriptExtension = scriptExtension; this.globalSettings = globalSettings; appPrefsModel = createAppPrefsModel(); @@ -345,7 +344,6 @@ final EditTypes editTypes = new EditTypes(tmpMapManager); mapReaderFactory.setEditTypes(editTypes); mapControlFactory.setEditTypes(editTypes); - this.rendererFactory = rendererFactory; globalSettings.readGlobalSettings(); ScriptedEventEditor.setGlobalSettings(globalSettings); final ArchetypeFactory<G, A, R> archetypeFactory = newArchetypeFactory(); @@ -461,6 +459,7 @@ archetypeSet.init(gameObjectParser); final AbstractArchetypeParser<G, A, R> archetypeParser = newArchetypeParser(gameObjectParser, archetypeChooserControl, animationObjects, archetypeSet, gameObjectFactory); final MapViewFactory<G, A, R, V> mapViewFactory = newMapViewFactory(mapViewSettings, faceObjects, selectedSquareView, this, mainView, editTypes, mapImageCache, toolPalette, filterControl); + rendererFactory = newRendererFactory(); mapControlFactory.init(mapViewFactory, gameObjectParser, rendererFactory, mapActions, archetypeChooserModel, mapImageCache, autojoinLists, exitMatcher); copyBuffer.init(mapArchObjectFactory.newMapArchObject(false), mainView); final ScriptedEventFactory<G> scriptedEventFactory = newScriptedEventFactory(scriptArchUtils); @@ -510,6 +509,9 @@ tmpMapManager.setFileControl(fileControl); } + @NotNull + protected abstract RendererFactory<G, A, R> newRendererFactory(); + /** * Returns {@link Collectable} instances to use for collection. * @param collectables the collection to add to This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-07 09:32:12
|
Revision: 5673 http://gridarta.svn.sourceforge.net/gridarta/?rev=5673&view=rev Author: akirschbaum Date: 2008-11-07 09:32:09 +0000 (Fri, 07 Nov 2008) Log Message: ----------- Remove parameter from AbstractMainControl's constructor. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-07 09:11:46 UTC (rev 5672) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-07 09:32:09 UTC (rev 5673) @@ -143,12 +143,19 @@ * @throws RuntimeException If the controller cannot be initialized. */ public CMainControl() { - super("cfeditor", new GlobalSettingsImpl(), new DefaultAnimationObjects<AnimationObject>(IGUIConstants.ANIMTREE_FILE), new DefaultFaceObjects(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^.*\t\\.?(.*)"), "\\%1$05d\t./arch%2$s"), false, ConfigFileUtils.getHomeFile("thumbnails"), null, "CrossfireEditor.jar", pythonFileFilter, ".py", "Python", Archetype.TYPE_SPELL, null, Archetype.TYPE_EVENT_CONNECTOR, false, 0, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SCRIPTS_DIR); + super("cfeditor", new DefaultAnimationObjects<AnimationObject>(IGUIConstants.ANIMTREE_FILE), new DefaultFaceObjects(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^.*\t\\.?(.*)"), "\\%1$05d\t./arch%2$s"), false, ConfigFileUtils.getHomeFile("thumbnails"), null, "CrossfireEditor.jar", pythonFileFilter, ".py", "Python", Archetype.TYPE_SPELL, null, Archetype.TYPE_EVENT_CONNECTOR, false, 0, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SCRIPTS_DIR); } /** {@inheritDoc} */ @NotNull @Override + protected GlobalSettings newGlobalSettings() { + return new GlobalSettingsImpl(); + } + + /** {@inheritDoc} */ + @NotNull + @Override protected RendererFactory<GameObject, MapArchObject, Archetype> newRendererFactory() { return new DefaultRendererFactory(); } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-11-07 09:11:46 UTC (rev 5672) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-11-07 09:32:09 UTC (rev 5673) @@ -176,12 +176,19 @@ * @throws RuntimeException If the controller cannot be initialized. */ public CMainControl() { - super("daieditor", new GlobalSettingsImpl(), new DefaultAnimationObjects<AnimationObject>(IGUIConstants.ANIMTREE_FILE), new DefaultFaceObjects(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^(.*)"), "%2$s"), true, null, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", luaFileFilter, ".lua", "Lua", 0, IGUIConstants.SPELL_FILE, 0, true, -1, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SCRIPTS_DIR); + super("daieditor", new DefaultAnimationObjects<AnimationObject>(IGUIConstants.ANIMTREE_FILE), new DefaultFaceObjects(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^(.*)"), "%2$s"), true, null, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", luaFileFilter, ".lua", "Lua", 0, IGUIConstants.SPELL_FILE, 0, true, -1, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SCRIPTS_DIR); } /** {@inheritDoc} */ @NotNull @Override + protected GlobalSettings newGlobalSettings() { + return new GlobalSettingsImpl(); + } + + /** {@inheritDoc} */ + @NotNull + @Override protected RendererFactory<GameObject, MapArchObject, Archetype> newRendererFactory() { return new DefaultRendererFactory(); } Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-07 09:11:46 UTC (rev 5672) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-07 09:32:09 UTC (rev 5673) @@ -304,7 +304,6 @@ /** * Creates a new instance. * @param key The action factory key - * @param globalSettings the global settings instance * @param animationObjects the animation objects instance * @param faceObjects the face objects instance * @param createDirectionPane whether the direction panel should be created @@ -329,9 +328,8 @@ * default * @param scriptsDir the plugin scripts directory */ - protected AbstractMainControl(@NotNull final String key, @NotNull final GlobalSettings globalSettings, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final FaceObjects faceObjects, final boolean createDirectionPane, @Nullable final File mapImageCacheDir, @Nullable final ImageIcon compassIcon, @NotNull final String gridartaJarFilename, @NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, @NotNull final String scriptName, final int spellType, @Nullable final String spellFile, final int typeNoEventConnector, final boolean includeFaceText, final int undefinedSpellIndex, @NotNull final int[] lockedItemsTypeNumbers, final boolean autoValidatorDefault, @NotNull final String scriptsDir) { + protected AbstractMainControl(@NotNull final String key, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final FaceObjects faceObjects, final boolean createDirectionPane, @Nullable final File mapImageCacheDir, @Nullable final ImageIcon compassIcon, @NotNull final String gridartaJarFilename, @NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, @NotNull final String scriptName, final int spellType, @Nullable final String spellFile, final int typeNoEventConnector, final boolean includeFaceText, final int undefinedSpellIndex, @NotNull final int[] lockedItemsTypeNumbers, final boolean autoValidatorDefault, @NotNull final String scriptsDir) { this.scriptExtension = scriptExtension; - this.globalSettings = globalSettings; appPrefsModel = createAppPrefsModel(); final MapArchObjectFactory<A> mapArchObjectFactory = newMapArchObjectFactory(); final MapArchObjectParserFactory<A> mapArchObjectParserFactory = newMapArchObjectParserFactory(); @@ -339,6 +337,7 @@ final GameObjectParserFactory<G, A, R> gameObjectParserFactory = newGameObjectParserFactory(gameObjectFactory); final DefaultMapReaderFactory<G, A, R, V> mapReaderFactory = new DefaultMapReaderFactory<G, A, R, V>(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory); final MapControlFactory<G, A, R, V> mapControlFactory = newMapControlFactory(mapReaderFactory, mapArchObjectFactory, mapArchObjectParserFactory); + globalSettings = newGlobalSettings(); final DefaultMapManager<G, A, R, V> tmpMapManager = new DefaultMapManager<G, A, R, V>(key, mapReaderFactory, mapControlFactory, globalSettings); mapManager = tmpMapManager; final EditTypes editTypes = new EditTypes(tmpMapManager); @@ -510,6 +509,9 @@ } @NotNull + protected abstract GlobalSettings newGlobalSettings(); + + @NotNull protected abstract RendererFactory<G, A, R> newRendererFactory(); /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |