You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(103) |
Jun
(121) |
Jul
(16) |
Aug
(67) |
Sep
(126) |
Oct
(161) |
Nov
(164) |
Dec
(588) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(394) |
Feb
(181) |
Mar
(131) |
Apr
(180) |
May
(255) |
Jun
(11) |
Jul
(79) |
Aug
(70) |
Sep
(274) |
Oct
(138) |
Nov
(195) |
Dec
(8) |
2008 |
Jan
(3) |
Feb
(142) |
Mar
(162) |
Apr
(124) |
May
(148) |
Jun
(157) |
Jul
(425) |
Aug
(373) |
Sep
(264) |
Oct
(315) |
Nov
(225) |
Dec
(6) |
2009 |
Jan
(67) |
Feb
(78) |
Mar
(279) |
Apr
(294) |
May
(92) |
Jun
(65) |
Jul
(134) |
Aug
(41) |
Sep
(138) |
Oct
(125) |
Nov
(126) |
Dec
(122) |
2010 |
Jan
(15) |
Feb
(48) |
Mar
(9) |
Apr
(195) |
May
(373) |
Jun
(507) |
Jul
(42) |
Aug
(16) |
Sep
(38) |
Oct
(81) |
Nov
(64) |
Dec
(18) |
2011 |
Jan
(13) |
Feb
(12) |
Mar
(39) |
Apr
(1) |
May
(2) |
Jun
(27) |
Jul
(27) |
Aug
(31) |
Sep
(14) |
Oct
(102) |
Nov
(20) |
Dec
(37) |
2012 |
Jan
(22) |
Feb
(1) |
Mar
(1) |
Apr
(2) |
May
(2) |
Jun
(18) |
Jul
(6) |
Aug
(1) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
2013 |
Jan
(1) |
Feb
(2) |
Mar
(1) |
Apr
(1) |
May
(47) |
Jun
(7) |
Jul
(107) |
Aug
|
Sep
|
Oct
(112) |
Nov
(31) |
Dec
(17) |
2014 |
Jan
(29) |
Feb
(111) |
Mar
(34) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(18) |
Dec
(10) |
From: <aki...@us...> - 2010-06-03 20:39:15
|
Revision: 8085 http://gridarta.svn.sourceforge.net/gridarta/?rev=8085&view=rev Author: akirschbaum Date: 2010-06-03 20:39:09 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Remove GameObjectContainer.insertAfter(). Modified Paths: -------------- trunk/src/app/net/sf/gridarta/model/baseobject/GameObjectContainer.java trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java Modified: trunk/src/app/net/sf/gridarta/model/baseobject/GameObjectContainer.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/baseobject/GameObjectContainer.java 2010-06-03 20:01:58 UTC (rev 8084) +++ trunk/src/app/net/sf/gridarta/model/baseobject/GameObjectContainer.java 2010-06-03 20:39:09 UTC (rev 8085) @@ -445,24 +445,25 @@ } /** - * Adds the given {@link GameObject} before another game object. - * @param gameObject the game object to insert - * @param nextGameObject the game object to insert before; adds last if - * <code>null</code> - * @throws IllegalArgumentException if <var>gameObject</var> already is - * inside another container + * Add a GameObject after another. + * @param previousGameObject previous anchor or <code>null</code> to insert + * last + * @param newGameObject GameObject to insert + * @throws IllegalArgumentException if <var>newGameObject</var> already is + * inside another container or <var>previousGameObject</var> isn't inside + * this container */ - public void addBefore(@NotNull final G gameObject, @Nullable final G nextGameObject) { - if (gameObject.isInContainer()) { - throw new IllegalArgumentException("Can't add " + gameObject + " to " + this + " because it's already inside " + gameObject.getContainer()); + public void insertAfter(@Nullable final G previousGameObject, @NotNull final G newGameObject) { + if (newGameObject.isInContainer()) { + throw new IllegalArgumentException("Can't add " + newGameObject + " to " + this + " because it's already inside " + newGameObject.getContainer()); } - if (nextGameObject == null) { - addLast(gameObject); + if (previousGameObject == null) { + addLast(newGameObject); return; } - if (!nextGameObject.isHead()) { + if (!previousGameObject.isHead()) { throw new IllegalArgumentException(); } @@ -471,42 +472,16 @@ boolean added = false; int index = 0; for (final G tmpGameObject : contents) { - if (tmpGameObject.getHead() == nextGameObject) { - contents.add(index, gameObject); + if (tmpGameObject.getHead() == previousGameObject) { + contents.add(index, newGameObject); added = true; break; } index++; } if (!added) { - throw new IllegalArgumentException("Can't add " + gameObject + " to " + this + " because " + nextGameObject + " is not inside"); + throw new IllegalArgumentException("Can't add " + newGameObject + " to " + this + " because " + previousGameObject + " is not inside"); } - setThisContainer(gameObject); - } finally { - notifyEndChange(); - } - } - - /** - * Add a GameObject after another. - * @param previousGameObject previous anchor - * @param newGameObject GameObject to insert - * @throws IllegalArgumentException if <var>newGameObject</var> already is - * inside another container or <var>previousGameObject</var> isn't inside - * this container - */ - public void insertAfter(@NotNull final G previousGameObject, @NotNull final G newGameObject) { - if (newGameObject.isInContainer()) { - throw new IllegalArgumentException("Can't add " + newGameObject + " to " + this + " because it's already inside " + newGameObject.getContainer()); - } - - notifyBeginChange(); - try { - final int insertIndex = contents.indexOf(previousGameObject); - if (insertIndex == -1) { - throw new IllegalArgumentException("Can't insert " + newGameObject + " after " + previousGameObject + " because that isn't inside " + this); - } - contents.add(insertIndex, newGameObject); setThisContainer(newGameObject); } finally { notifyEndChange(); @@ -517,7 +492,7 @@ * Add a GameObject before another. * @param newGameObject GameObject to insert * @param nextGameObject nextGameObject anchor - * @throws IllegalArgumentException if <var>newGameObject</var> already is + * @throws IllegalArgumentException if <var>gameObject</var> already is * inside another container or <var>prev</var> isn't inside this container */ public void insertBefore(@NotNull final G newGameObject, @NotNull final G nextGameObject) { Modified: trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-03 20:01:58 UTC (rev 8084) +++ trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-03 20:39:09 UTC (rev 8085) @@ -903,7 +903,7 @@ throw new IllegalArgumentException(); } gameObject.remove(); - nextGameObjectContainer.addBefore(gameObject, nextGameObject); + nextGameObjectContainer.insertAfter(nextGameObject, gameObject); // regenerate tail parts when inserted into a map square if (!nextGameObject.isInContainer() && gameObject.getArchetype().isMulti()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-03 20:02:04
|
Revision: 8084 http://gridarta.svn.sourceforge.net/gridarta/?rev=8084&view=rev Author: akirschbaum Date: 2010-06-03 20:01:58 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Replace string constant with named constant. Modified Paths: -------------- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/gameobject/GameObject.java Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/gameobject/GameObject.java 2010-06-03 17:06:41 UTC (rev 8083) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/gameobject/GameObject.java 2010-06-03 20:01:58 UTC (rev 8084) @@ -48,6 +48,12 @@ private static final long serialVersionUID = 1L; /** + * The name of the "elevation" attribute. + */ + @NotNull + public static final String ELEVATION = "elevation"; + + /** * Creates a new instance. * @param archetypeName the name of the base archetype * @param faceObjectProviders the face object providers for looking up @@ -75,10 +81,10 @@ */ @Override public void propagateElevation(@NotNull final BaseObject<GameObject, MapArchObject, Archetype, ?> gameObject) { - final String elevation = gameObject.getAttributeString("elevation", false); + final String elevation = gameObject.getAttributeString(ELEVATION, false); if (elevation.length() != 0) { - setAttributeString("elevation", elevation); - gameObject.removeAttribute("elevation"); + setAttributeString(ELEVATION, elevation); + gameObject.removeAttribute(ELEVATION); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-03 17:06:47
|
Revision: 8083 http://gridarta.svn.sourceforge.net/gridarta/?rev=8083&view=rev Author: akirschbaum Date: 2010-06-03 17:06:41 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Simplify code. Modified Paths: -------------- trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java Modified: trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java 2010-06-03 17:05:07 UTC (rev 8082) +++ trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java 2010-06-03 17:06:41 UTC (rev 8083) @@ -960,22 +960,18 @@ final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); - final Point point0 = new Point(0, 0); - final Point point1 = new Point(1, 0); final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); mapModel.beginTransaction("TEST"); - final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare0 = mapModel.getMapSquare(point0); - final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare1 = mapModel.getMapSquare(point1); - final TestGameObject ob1 = testMapControlCreator.insertMob21(mapModel, point0); + final TestGameObject ob1 = testMapControlCreator.insertMob21(mapModel, new Point(0, 0)); final TestGameObject ob2 = testMapControlCreator.insertMob21(ob1); TestMapControlCreator.checkMapContents(mapModel, "mob21|mob21b|"); - // select ob2 in mapSquare1 - selectedSquareModel.setSelectedMapSquare(mapSquare1, null, 0); + // select ob2 in (1,0) + selectedSquareModel.setSelectedMapSquare(mapModel.getMapSquare(new Point(1, 0)), null, 0); selectedSquareModel.setSelectedGameObject(ob2, 0); - // move ob2 into mapSquare1 + // move ob2 into (1,0) Assert.assertTrue(selectedSquareActions.doMoveSquareEnv(true)); TestMapControlCreator.checkMapContents(mapModel, "mob21|mob21,mob21b|mob21b"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-03 17:05:14
|
Revision: 8082 http://gridarta.svn.sourceforge.net/gridarta/?rev=8082&view=rev Author: akirschbaum Date: 2010-06-03 17:05:07 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Fix checkstyle issues. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java trunk/src/test/net/sf/gridarta/gui/copybuffer/CopyBufferTest.java trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java trunk/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java Modified: trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java 2010-06-03 16:58:45 UTC (rev 8081) +++ trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java 2010-06-03 17:05:07 UTC (rev 8082) @@ -54,7 +54,7 @@ @Override public void mapCreated(@NotNull final MapControl<G, A, R> mapControl, final boolean interactive) { if (interactive) { - final MapModel<G,A,R> mapModel = mapControl.getMapModel(); + final MapModel<G, A, R> mapModel = mapControl.getMapModel(); mapMenuManager.addRecent(mapModel, mapModel.getMapArchObject().getMapName()); } } Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java 2010-06-03 16:58:45 UTC (rev 8081) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java 2010-06-03 17:05:07 UTC (rev 8082) @@ -192,7 +192,7 @@ if (mapSquare == null) { return false; } - + final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); final Point pos = new Point(mapSquare.getMapX(), mapSquare.getMapY()); if (!envGameObject.isInContainer() && gameObject.getArchetype().isMulti() && !mapModel.isMultiArchFittingToMap(gameObject.getArchetype(), pos, true)) { Modified: trunk/src/test/net/sf/gridarta/gui/copybuffer/CopyBufferTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/copybuffer/CopyBufferTest.java 2010-06-03 16:58:45 UTC (rev 8081) +++ trunk/src/test/net/sf/gridarta/gui/copybuffer/CopyBufferTest.java 2010-06-03 17:05:07 UTC (rev 8082) @@ -61,7 +61,7 @@ final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(3, 3)); final Point point = new Point(1, 1); - final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); mapModel.beginTransaction("TEST"); final TestGameObject ob1 = testMapControlCreator.insertFloor(mapModel, point); final TestGameObject ob2 = testMapControlCreator.insertMob21(ob1); Modified: trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java 2010-06-03 16:58:45 UTC (rev 8081) +++ trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java 2010-06-03 17:05:07 UTC (rev 8082) @@ -64,7 +64,7 @@ final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); final Point point = new Point(0, 0); - final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); mapModel.beginTransaction("TEST"); final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare = mapModel.getMapSquare(point); final TestGameObject ob2 = testMapControlCreator.insertFloor(mapModel, point); @@ -104,7 +104,7 @@ final Point pointHead = new Point(0, 0); final Point pointTail = new Point(1, 0); - final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); mapModel.beginTransaction("TEST"); final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareHead = mapModel.getMapSquare(pointHead); final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareTail = mapModel.getMapSquare(pointTail); @@ -164,7 +164,7 @@ final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); final Point point = new Point(0, 0); - final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); mapModel.beginTransaction("TEST"); final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare = mapModel.getMapSquare(point); final TestGameObject ob2 = testMapControlCreator.insertFloor(mapModel, point); @@ -204,7 +204,7 @@ final Point pointHead = new Point(0, 0); final Point pointTail = new Point(1, 0); - final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); mapModel.beginTransaction("TEST"); final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareHead = mapModel.getMapSquare(pointHead); final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareTail = mapModel.getMapSquare(pointTail); @@ -264,7 +264,7 @@ final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); final Point point = new Point(0, 0); - final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); mapModel.beginTransaction("TEST"); final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare = mapModel.getMapSquare(point); final TestGameObject ob1 = testMapControlCreator.insertExit(mapModel, point); @@ -304,7 +304,7 @@ final Point pointHead = new Point(0, 0); final Point pointTail = new Point(1, 0); - final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); mapModel.beginTransaction("TEST"); final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareHead = mapModel.getMapSquare(pointHead); final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareTail = mapModel.getMapSquare(pointTail); @@ -364,7 +364,7 @@ final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); final Point point = new Point(0, 0); - final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); mapModel.beginTransaction("TEST"); final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare = mapModel.getMapSquare(point); final TestGameObject ob1 = testMapControlCreator.insertExit(mapModel, point); @@ -404,7 +404,7 @@ final Point pointHead = new Point(0, 0); final Point pointTail = new Point(1, 0); - final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); mapModel.beginTransaction("TEST"); final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareHead = mapModel.getMapSquare(pointHead); final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareTail = mapModel.getMapSquare(pointTail); @@ -464,7 +464,7 @@ final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); final Point point = new Point(0, 0); - final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); mapModel.beginTransaction("TEST"); final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare = mapModel.getMapSquare(point); final TestGameObject ob1 = testMapControlCreator.insertExit(mapModel, point); @@ -497,7 +497,7 @@ final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); final Point point = new Point(0, 0); - final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); mapModel.beginTransaction("TEST"); final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare = mapModel.getMapSquare(point); final TestGameObject ob1 = testMapControlCreator.insertExit(mapModel, point); @@ -543,7 +543,7 @@ final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); final Point point = new Point(0, 0); - final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); mapModel.beginTransaction("TEST"); final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare = mapModel.getMapSquare(point); final TestGameObject ob1 = testMapControlCreator.insertExit(mapModel, point); @@ -604,7 +604,7 @@ final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); final Point point = new Point(0, 0); - final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); mapModel.beginTransaction("TEST"); final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareHead = mapModel.getMapSquare(point); final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareTail = mapModel.getMapSquare(new Point(1, 0)); @@ -675,7 +675,7 @@ final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); final Point point = new Point(0, 0); - final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); mapModel.beginTransaction("TEST"); final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareHead = mapModel.getMapSquare(point); final TestGameObject ob1 = testMapControlCreator.insertExit(mapModel, point); @@ -708,7 +708,7 @@ final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); final Point point = new Point(0, 0); - final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); mapModel.beginTransaction("TEST"); final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare = mapModel.getMapSquare(point); final TestGameObject ob4 = testMapControlCreator.insertExit(mapModel, point); @@ -818,7 +818,7 @@ final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); final Point point = new Point(0, 0); - final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); mapModel.beginTransaction("TEST"); final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareHead = mapModel.getMapSquare(point); final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareTail = mapModel.getMapSquare(new Point(1, 0)); @@ -887,7 +887,7 @@ final Point point0 = new Point(0, 0); final Point point1 = new Point(1, 0); - final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); mapModel.beginTransaction("TEST"); final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare0 = mapModel.getMapSquare(point0); final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare1 = mapModel.getMapSquare(point1); @@ -924,7 +924,7 @@ final Point pointHead = new Point(0, 0); final Point pointTail = new Point(1, 0); - final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); mapModel.beginTransaction("TEST"); final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareTail = mapModel.getMapSquare(pointTail); testMapControlCreator.insertExit(mapModel, pointHead); @@ -962,7 +962,7 @@ final Point point0 = new Point(0, 0); final Point point1 = new Point(1, 0); - final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); mapModel.beginTransaction("TEST"); final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare0 = mapModel.getMapSquare(point0); final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare1 = mapModel.getMapSquare(point1); Modified: trunk/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java 2010-06-03 16:58:45 UTC (rev 8081) +++ trunk/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java 2010-06-03 17:05:07 UTC (rev 8082) @@ -22,7 +22,6 @@ import java.awt.Point; import java.io.File; import net.sf.gridarta.gui.map.test.TestMapControlCreator; -import net.sf.gridarta.gui.selectedsquare.SelectedSquareActions; import net.sf.gridarta.model.archetype.DuplicateArchetypeException; import net.sf.gridarta.model.archetype.TestArchetype; import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; @@ -39,8 +38,9 @@ public class GameObjectFactoryTest { /** - * Checks that {@link SelectedSquareActions#doMoveSquareTop(boolean)} does - * work for single-square game objects. + * Checks that {@link + * net.sf.gridarta.model.gameobject.GameObjectFactory#cloneGameObject(GameObject)} + * correctly updates the container. * @throws DuplicateArchetypeException if the test fails */ @Test @@ -49,7 +49,7 @@ final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(new File("file"), "name", new Size2D(1, 1)); final Point point = new Point(0, 0); - final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); mapModel.beginTransaction("TEST"); final TestGameObject ob1 = testMapControlCreator.insertFloor(mapModel, point); final TestGameObject ob2 = testMapControlCreator.insertExit(ob1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-03 16:58:55
|
Revision: 8081 http://gridarta.svn.sourceforge.net/gridarta/?rev=8081&view=rev Author: akirschbaum Date: 2010-06-03 16:58:45 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Make "Move Env" to always insert into the selected map square. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java trunk/src/app/net/sf/gridarta/model/baseobject/GameObjectContainer.java trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-06-03 16:28:17 UTC (rev 8080) +++ trunk/atrinik/ChangeLog 2010-06-03 16:58:45 UTC (rev 8081) @@ -1,5 +1,7 @@ 2010-06-03 Andreas Kirschbaum + * Make "Move Env" to always insert into the selected map square. + * Make "Move Inv" to always insert into the head part. * Prevent the selected square view from moving around tail parts. Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-06-03 16:28:17 UTC (rev 8080) +++ trunk/crossfire/ChangeLog 2010-06-03 16:58:45 UTC (rev 8081) @@ -1,5 +1,7 @@ 2010-06-03 Andreas Kirschbaum + * Make "Move Env" to always insert into the selected map square. + * Make "Move Inv" to always insert into the head part. * Prevent the selected square view from moving around tail parts. Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-06-03 16:28:17 UTC (rev 8080) +++ trunk/daimonin/ChangeLog 2010-06-03 16:58:45 UTC (rev 8081) @@ -1,5 +1,7 @@ 2010-06-03 Andreas Kirschbaum + * Make "Move Env" to always insert into the selected map square. + * Make "Move Inv" to always insert into the head part. * Prevent the selected square view from moving around tail parts. Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java 2010-06-03 16:28:17 UTC (rev 8080) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java 2010-06-03 16:58:45 UTC (rev 8081) @@ -183,8 +183,16 @@ return false; } - final MapSquare<G, A, R> mapSquare = gameObject.getMapSquare(); - assert mapSquare != null; + final MapSquareSelection<G, A, R> mapSquareSelection = selectedSquareModel.getSelectedMapSquare(); + if (mapSquareSelection == null) { + return false; + } + + final MapSquare<G, A, R> mapSquare = mapSquareSelection.getMapSquare(); + if (mapSquare == null) { + return false; + } + final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); final Point pos = new Point(mapSquare.getMapX(), mapSquare.getMapY()); if (!envGameObject.isInContainer() && gameObject.getArchetype().isMulti() && !mapModel.isMultiArchFittingToMap(gameObject.getArchetype(), pos, true)) { Modified: trunk/src/app/net/sf/gridarta/model/baseobject/GameObjectContainer.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/baseobject/GameObjectContainer.java 2010-06-03 16:28:17 UTC (rev 8080) +++ trunk/src/app/net/sf/gridarta/model/baseobject/GameObjectContainer.java 2010-06-03 16:58:45 UTC (rev 8081) @@ -462,12 +462,16 @@ return; } + if (!nextGameObject.isHead()) { + throw new IllegalArgumentException(); + } + notifyBeginChange(); try { boolean added = false; int index = 0; for (final G tmpGameObject : contents) { - if (tmpGameObject == nextGameObject) { + if (tmpGameObject.getHead() == nextGameObject) { contents.add(index, gameObject); added = true; break; Modified: trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-03 16:28:17 UTC (rev 8080) +++ trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-03 16:58:45 UTC (rev 8081) @@ -885,11 +885,19 @@ */ @Override public void moveEnv(@NotNull final G gameObject, @NotNull final Point pos, @NotNull final G nextGameObject) { - assert !gameObject.isMulti(); // no tail parts should be present when inside inventory of another game object - final GameObjectContainer<G,A,R> nextGameObjectContainer = nextGameObject.getContainer(); - if (nextGameObjectContainer == null) { + if (!nextGameObject.isHead()) { throw new IllegalArgumentException(); } + assert !gameObject.isMulti(); // no tail parts should be present when inside inventory of another game object + final GameObjectContainer<G, A, R> nextGameObjectContainer; + if (nextGameObject.isInContainer()) { + nextGameObjectContainer = nextGameObject.getContainer(); + if (nextGameObjectContainer == null) { + throw new IllegalArgumentException(); + } + } else { + nextGameObjectContainer = getMapSquare(pos); + } final MapSquare<G, A, R> mapSquare = nextGameObjectContainer.getMapSquare(); if (mapSquare == null || mapSquare.getMapModel() != this) { throw new IllegalArgumentException(); Modified: trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java 2010-06-03 16:28:17 UTC (rev 8080) +++ trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java 2010-06-03 16:58:45 UTC (rev 8081) @@ -949,6 +949,39 @@ } /** + * Checks that {@link SelectedSquareActions#doMoveSquareEnv(boolean)} + * inserts into selected map square. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testMoveEnvIntoSelectedMapSquare() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(3, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point point0 = new Point(0, 0); + final Point point1 = new Point(1, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare0 = mapModel.getMapSquare(point0); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare1 = mapModel.getMapSquare(point1); + final TestGameObject ob1 = testMapControlCreator.insertMob21(mapModel, point0); + final TestGameObject ob2 = testMapControlCreator.insertMob21(ob1); + + TestMapControlCreator.checkMapContents(mapModel, "mob21|mob21b|"); + + // select ob2 in mapSquare1 + selectedSquareModel.setSelectedMapSquare(mapSquare1, null, 0); + selectedSquareModel.setSelectedGameObject(ob2, 0); + + // move ob2 into mapSquare1 + Assert.assertTrue(selectedSquareActions.doMoveSquareEnv(true)); + + TestMapControlCreator.checkMapContents(mapModel, "mob21|mob21,mob21b|mob21b"); + } + + /** * Creates a new {@link SelectedSquareModel}. * @param mapControl the associated map control * @param testMapControlCreator the test map control creator to use This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-03 16:28:24
|
Revision: 8080 http://gridarta.svn.sourceforge.net/gridarta/?rev=8080&view=rev Author: akirschbaum Date: 2010-06-03 16:28:17 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Correctly update selected square view after "Move Env" from tail part. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareModel.java Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareModel.java 2010-06-03 16:19:36 UTC (rev 8079) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareModel.java 2010-06-03 16:28:17 UTC (rev 8080) @@ -138,9 +138,11 @@ } for (final GameObject<G, A, R> gameObject : gameObjects) { - final MapSquare<G, A, R> mapSquare = gameObject.getMapSquare(); - if (mapSquare != null && mapSquareSelection.checkForChangedMapSquare(mapSquare)) { - return true; + for (GameObject<G, A, R> gameObjectPart = gameObject; gameObjectPart != null; gameObjectPart = gameObjectPart.getMultiNext()) { + final MapSquare<G, A, R> mapSquare = gameObjectPart.getMapSquare(); + if (mapSquare != null && mapSquareSelection.checkForChangedMapSquare(mapSquare)) { + return true; + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-03 16:19:43
|
Revision: 8079 http://gridarta.svn.sourceforge.net/gridarta/?rev=8079&view=rev Author: akirschbaum Date: 2010-06-03 16:19:36 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Make "Move Inv" to always insert into the head part. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-06-03 16:17:16 UTC (rev 8078) +++ trunk/atrinik/ChangeLog 2010-06-03 16:19:36 UTC (rev 8079) @@ -1,5 +1,7 @@ 2010-06-03 Andreas Kirschbaum + * Make "Move Inv" to always insert into the head part. + * Prevent the selected square view from moving around tail parts. * Prevent Paste/Undo/Redo from breaking the map when applied to Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-06-03 16:17:16 UTC (rev 8078) +++ trunk/crossfire/ChangeLog 2010-06-03 16:19:36 UTC (rev 8079) @@ -1,5 +1,7 @@ 2010-06-03 Andreas Kirschbaum + * Make "Move Inv" to always insert into the head part. + * Prevent the selected square view from moving around tail parts. * Prevent Paste/Undo/Redo from breaking the map when applied to Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java 2010-06-03 16:17:16 UTC (rev 8078) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java 2010-06-03 16:19:36 UTC (rev 8079) @@ -204,9 +204,11 @@ private void addMapSquares(@NotNull final Iterable<GameObject> gameObjects, @NotNull final Collection<MapSquare<GameObject, MapArchObject, Archetype>> toRepaint) { for (final net.sf.gridarta.model.gameobject.GameObject<GameObject, MapArchObject, Archetype> gameObject : gameObjects) { if (!gameObject.isInContainer()) { - final MapSquare<GameObject, MapArchObject, Archetype> square = gameObject.getMapSquare(); - if (square != null) { - getSquaresToRepaint(square, toRepaint); + for (net.sf.gridarta.model.gameobject.GameObject<GameObject, MapArchObject, Archetype> gameObjectPart = gameObject; gameObjectPart != null; gameObjectPart = gameObjectPart.getMultiNext()) { + final MapSquare<GameObject, MapArchObject, Archetype> square = gameObjectPart.getMapSquare(); + if (square != null) { + getSquaresToRepaint(square, toRepaint); + } } } } Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-06-03 16:17:16 UTC (rev 8078) +++ trunk/daimonin/ChangeLog 2010-06-03 16:19:36 UTC (rev 8079) @@ -1,5 +1,7 @@ 2010-06-03 Andreas Kirschbaum + * Make "Move Inv" to always insert into the head part. + * Prevent the selected square view from moving around tail parts. * Prevent Paste/Undo/Redo from breaking the map when applied to Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java 2010-06-03 16:17:16 UTC (rev 8078) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java 2010-06-03 16:19:36 UTC (rev 8079) @@ -225,7 +225,7 @@ final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); mapModel.beginTransaction("Move To Inventory"); try { - mapModel.moveInv(gameObject, prevGameObject); + mapModel.moveInv(gameObject, prevGameObject.getHead()); } finally { mapModel.endTransaction(); } Modified: trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-03 16:17:16 UTC (rev 8078) +++ trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-03 16:19:36 UTC (rev 8079) @@ -915,6 +915,10 @@ */ @Override public void moveInv(@NotNull final G gameObject, @NotNull final GameObject<G, A, R> prevGameObject) { + if (!gameObject.isHead() || !prevGameObject.isHead()) { + throw new IllegalArgumentException(); + } + gameObject.remove(); gameObject.removeTailParts(); prevGameObject.addFirst(gameObject); Modified: trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java 2010-06-03 16:17:16 UTC (rev 8078) +++ trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java 2010-06-03 16:19:36 UTC (rev 8079) @@ -874,6 +874,44 @@ } /** + * Checks that {@link SelectedSquareActions#doMoveSquareInv(boolean)} always + * inserts into the head-part. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareInvIntoHead1() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(3, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point point0 = new Point(0, 0); + final Point point1 = new Point(1, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare0 = mapModel.getMapSquare(point0); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare1 = mapModel.getMapSquare(point1); + final TestGameObject ob2 = testMapControlCreator.insertMob21(mapModel, point1); + final TestGameObject ob1 = testMapControlCreator.insertMob21(mapModel, point0); + + TestMapControlCreator.checkMapContents(mapModel, "mob21|mob21,mob21b|mob21b"); + + // select ob2 + selectedSquareModel.setSelectedMapSquare(mapSquare1, null, 0); + selectedSquareModel.setSelectedGameObject(ob2, 0); + + // move ob2 into ob1 + Assert.assertTrue(selectedSquareActions.doMoveSquareInv(true)); + + TestMapControlCreator.checkMapContents(mapModel, "mob21|mob21b|"); + TestMapControlCreator.checkContents(mapSquare0, ob1); + final TestGameObject ob1Tail = ob1.getMultiNext(); + Assert.assertNotNull(ob1Tail); + TestMapControlCreator.checkContents(mapSquare1, ob1Tail); + TestMapControlCreator.checkContents(ob1, ob2); + } + + /** * Checks that tail parts cannot be moved. * @throws DuplicateArchetypeException if the test fails */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-03 16:17:23
|
Revision: 8078 http://gridarta.svn.sourceforge.net/gridarta/?rev=8078&view=rev Author: akirschbaum Date: 2010-06-03 16:17:16 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Merge duplicated code. Modified Paths: -------------- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java 2010-06-03 15:22:30 UTC (rev 8077) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java 2010-06-03 16:17:16 UTC (rev 8078) @@ -188,6 +188,20 @@ @Override public void mapObjectsChanged(@NotNull final Set<GameObject> gameObjects, @NotNull final Set<GameObject> transientGameObjects) { final Collection<MapSquare<GameObject, MapArchObject, Archetype>> toRepaint = new HashSet<MapSquare<GameObject, MapArchObject, Archetype>>(); + addMapSquares(gameObjects, toRepaint); + addMapSquares(transientGameObjects, toRepaint); + for (final MapSquare<GameObject, MapArchObject, Archetype> mapSquare : toRepaint) { + paintSquare(mapSquare); + } + } + + /** + * Adds all {@link MapSquare MapSquares} a {@link GameObject} occupies + * to a collection. + * @param gameObjects the game objects to process + * @param toRepaint the collection + */ + private void addMapSquares(@NotNull final Iterable<GameObject> gameObjects, @NotNull final Collection<MapSquare<GameObject, MapArchObject, Archetype>> toRepaint) { for (final net.sf.gridarta.model.gameobject.GameObject<GameObject, MapArchObject, Archetype> gameObject : gameObjects) { if (!gameObject.isInContainer()) { final MapSquare<GameObject, MapArchObject, Archetype> square = gameObject.getMapSquare(); @@ -196,17 +210,6 @@ } } } - for (final net.sf.gridarta.model.gameobject.GameObject<GameObject, MapArchObject, Archetype> gameObject : transientGameObjects) { - if (!gameObject.isInContainer()) { - final MapSquare<GameObject, MapArchObject, Archetype> square = gameObject.getMapSquare(); - if (square != null) { - getSquaresToRepaint(square, toRepaint); - } - } - } - for (final MapSquare<GameObject, MapArchObject, Archetype> mapSquare : toRepaint) { - paintSquare(mapSquare); - } } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-03 16:02:04
|
Revision: 8066 http://gridarta.svn.sourceforge.net/gridarta/?rev=8066&view=rev Author: akirschbaum Date: 2010-06-03 12:30:17 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Merge duplicated code. Modified Paths: -------------- trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java Modified: trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java 2010-06-03 11:02:59 UTC (rev 8065) +++ trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java 2010-06-03 12:30:17 UTC (rev 8066) @@ -387,10 +387,11 @@ public static void checkContents(@NotNull final Iterable<TestGameObject> mapSquare, @NotNull final TestGameObject... gameObjects) { int i = 0; for (final TestGameObject gameObject : mapSquare) { + final String gameObjectName = gameObject.getBestName(); if (i >= gameObjects.length) { - Assert.fail("map square contains excess game object '" + gameObject.getBestName() + "'"); + Assert.fail("map square contains excess game object '" + gameObjectName + "'"); } else if (gameObject != gameObjects[i]) { - Assert.fail("map square contains wrong game object '" + gameObject.getBestName() + "' at index " + i + ", expected '" + gameObjects[i].getBestName() + "'"); + Assert.fail("map square contains wrong game object '" + gameObjectName + "' at index " + i + ", expected '" + gameObjects[i].getBestName() + "'"); } i++; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-03 15:22:36
|
Revision: 8077 http://gridarta.svn.sourceforge.net/gridarta/?rev=8077&view=rev Author: akirschbaum Date: 2010-06-03 15:22:30 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Fix possible NullPointerException. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java 2010-06-03 15:20:43 UTC (rev 8076) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java 2010-06-03 15:22:30 UTC (rev 8077) @@ -146,7 +146,10 @@ public void mousePressed(final MouseEvent e) { if (isSelect(e)) { if (e.getClickCount() > 1) { // LMB Double click - gameObjectAttributesDialogFactory.showAttributeDialog(selectedSquareModel.getSelectedGameObject()); + final G gameObject = selectedSquareModel.getSelectedGameObject(); + if (gameObject != null) { + gameObjectAttributesDialogFactory.showAttributeDialog(gameObject); + } } } else if (isInsert(e)) { insertGameObjectFromObjectChooser(selectedSquareView.getListIndex(e)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-03 15:20:49
|
Revision: 8076 http://gridarta.svn.sourceforge.net/gridarta/?rev=8076&view=rev Author: akirschbaum Date: 2010-06-03 15:20:43 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java Modified: trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java 2010-06-03 15:17:35 UTC (rev 8075) +++ trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java 2010-06-03 15:20:43 UTC (rev 8076) @@ -888,13 +888,12 @@ final Point pointTail = new Point(1, 0); final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); mapModel.beginTransaction("TEST"); - final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareHead = mapModel.getMapSquare(pointHead); final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareTail = mapModel.getMapSquare(pointTail); - final TestGameObject ob1Head = testMapControlCreator.insertExit(mapModel, pointHead); - final TestGameObject ob1Tail = testMapControlCreator.insertExit(mapModel, pointTail); + testMapControlCreator.insertExit(mapModel, pointHead); + testMapControlCreator.insertExit(mapModel, pointTail); final TestGameObject ob2Head = testMapControlCreator.insertMob21(mapModel, pointHead); - final TestGameObject ob3Head = testMapControlCreator.insertExit(mapModel, pointHead); - final TestGameObject ob3Tail = testMapControlCreator.insertExit(mapModel, pointTail); + testMapControlCreator.insertExit(mapModel, pointHead); + testMapControlCreator.insertExit(mapModel, pointTail); TestMapControlCreator.checkMapContents(mapModel, "exit,mob21,exit|exit,mob21b,exit"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-03 15:17:42
|
Revision: 8075 http://gridarta.svn.sourceforge.net/gridarta/?rev=8075&view=rev Author: akirschbaum Date: 2010-06-03 15:17:35 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Prevent the selected square view from moving around tail parts. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-06-03 15:06:06 UTC (rev 8074) +++ trunk/atrinik/ChangeLog 2010-06-03 15:17:35 UTC (rev 8075) @@ -1,5 +1,7 @@ 2010-06-03 Andreas Kirschbaum + * Prevent the selected square view from moving around tail parts. + * Prevent Paste/Undo/Redo from breaking the map when applied to game objects having inventories. Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-06-03 15:06:06 UTC (rev 8074) +++ trunk/crossfire/ChangeLog 2010-06-03 15:17:35 UTC (rev 8075) @@ -1,5 +1,7 @@ 2010-06-03 Andreas Kirschbaum + * Prevent the selected square view from moving around tail parts. + * Prevent Paste/Undo/Redo from breaking the map when applied to game objects having inventories. Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-06-03 15:06:06 UTC (rev 8074) +++ trunk/daimonin/ChangeLog 2010-06-03 15:17:35 UTC (rev 8075) @@ -1,5 +1,7 @@ 2010-06-03 Andreas Kirschbaum + * Prevent the selected square view from moving around tail parts. + * Prevent Paste/Undo/Redo from breaking the map when applied to game objects having inventories. Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java 2010-06-03 15:06:06 UTC (rev 8074) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java 2010-06-03 15:17:35 UTC (rev 8075) @@ -54,7 +54,7 @@ */ public boolean doMoveSquareTop(final boolean performAction) { final GameObject<G, A, R> gameObject = selectedSquareModel.getSelectedGameObject(); - if (gameObject == null) { + if (gameObject == null || !gameObject.isHead()) { return false; } @@ -84,7 +84,7 @@ */ public boolean doMoveSquareUp(final boolean performAction) { final GameObject<G, A, R> gameObject = selectedSquareModel.getSelectedGameObject(); - if (gameObject == null) { + if (gameObject == null || !gameObject.isHead()) { return false; } @@ -114,7 +114,7 @@ */ public boolean doMoveSquareDown(final boolean performAction) { final GameObject<G, A, R> gameObject = selectedSquareModel.getSelectedGameObject(); - if (gameObject == null) { + if (gameObject == null || !gameObject.isHead()) { return false; } @@ -144,7 +144,7 @@ */ public boolean doMoveSquareBottom(final boolean performAction) { final GameObject<G, A, R> gameObject = selectedSquareModel.getSelectedGameObject(); - if (gameObject == null) { + if (gameObject == null || !gameObject.isHead()) { return false; } @@ -174,7 +174,7 @@ */ public boolean doMoveSquareEnv(final boolean performAction) { final G gameObject = selectedSquareModel.getSelectedGameObject(); - if (gameObject == null) { + if (gameObject == null || !gameObject.isHead()) { return false; } @@ -210,7 +210,7 @@ */ public boolean doMoveSquareInv(final boolean performAction) { final G gameObject = selectedSquareModel.getSelectedGameObject(); - if (gameObject == null) { + if (gameObject == null || !gameObject.isHead()) { return false; } Modified: trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java 2010-06-03 15:06:06 UTC (rev 8074) +++ trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java 2010-06-03 15:17:35 UTC (rev 8075) @@ -874,6 +874,44 @@ } /** + * Checks that tail parts cannot be moved. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testMoveTailPart() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(2, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point pointHead = new Point(0, 0); + final Point pointTail = new Point(1, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareHead = mapModel.getMapSquare(pointHead); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareTail = mapModel.getMapSquare(pointTail); + final TestGameObject ob1Head = testMapControlCreator.insertExit(mapModel, pointHead); + final TestGameObject ob1Tail = testMapControlCreator.insertExit(mapModel, pointTail); + final TestGameObject ob2Head = testMapControlCreator.insertMob21(mapModel, pointHead); + final TestGameObject ob3Head = testMapControlCreator.insertExit(mapModel, pointHead); + final TestGameObject ob3Tail = testMapControlCreator.insertExit(mapModel, pointTail); + + TestMapControlCreator.checkMapContents(mapModel, "exit,mob21,exit|exit,mob21b,exit"); + + // select ob2Tail + selectedSquareModel.setSelectedMapSquare(mapSquareTail, null, 0); + selectedSquareModel.setSelectedGameObject(ob2Head.getMultiNext(), 0); + + // ob2Tail cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareTop(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareUp(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareDown(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareBottom(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareInv(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(false)); + } + + /** * Creates a new {@link SelectedSquareModel}. * @param mapControl the associated map control * @param testMapControlCreator the test map control creator to use This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-03 15:06:13
|
Revision: 8074 http://gridarta.svn.sourceforge.net/gridarta/?rev=8074&view=rev Author: akirschbaum Date: 2010-06-03 15:06:06 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Add @NotNull annotations. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/selectedsquare/MapSquareSelection.java Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/MapSquareSelection.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/MapSquareSelection.java 2010-06-03 15:00:12 UTC (rev 8073) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/MapSquareSelection.java 2010-06-03 15:06:06 UTC (rev 8074) @@ -44,11 +44,13 @@ /** * The {@link Logger} for printing log messages. */ + @NotNull private static final Category log = Logger.getLogger(MapSquareSelection.class); /** * The {@link MapSquareSelectionListener}s to inform of changes. */ + @NotNull private final EventListenerList2<MapSquareSelectionListener<G, A, R>> listenerList = new EventListenerList2<MapSquareSelectionListener<G, A, R>>(MapSquareSelectionListener.class); /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-03 15:00:19
|
Revision: 8073 http://gridarta.svn.sourceforge.net/gridarta/?rev=8073&view=rev Author: akirschbaum Date: 2010-06-03 15:00:12 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Add @NotNull annotation. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareModel.java Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareModel.java 2010-06-03 14:04:49 UTC (rev 8072) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareModel.java 2010-06-03 15:00:12 UTC (rev 8073) @@ -38,6 +38,7 @@ /** * The listeners to inform of changes. */ + @NotNull private final EventListenerList2<SelectedSquareModelListener<G, A, R>> listenerList = new EventListenerList2<SelectedSquareModelListener<G, A, R>>(SelectedSquareModelListener.class); /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-03 14:04:57
|
Revision: 8072 http://gridarta.svn.sourceforge.net/gridarta/?rev=8072&view=rev Author: akirschbaum Date: 2010-06-03 14:04:49 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Extract UndoActions from UndoControl. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/actions/UndoActions.java Added: trunk/src/app/net/sf/gridarta/actions/UndoActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/actions/UndoActions.java (rev 0) +++ trunk/src/app/net/sf/gridarta/actions/UndoActions.java 2010-06-03 14:04:49 UTC (rev 8072) @@ -0,0 +1,98 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.actions; + +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.map.maparchobject.MapArchObject; +import net.sf.gridarta.model.map.mapmodel.MapModel; +import net.sf.gridarta.model.undo.UndoModel; +import net.sf.gridarta.model.undo.UndoState; +import org.jetbrains.annotations.NotNull; + +/** + * Utility class implementing undo and redo actions. + * @author Andreas Kirschbaum + */ +public class UndoActions { + + /** + * Private constructor to prevent instantiation. + */ + private UndoActions() { + } + + /** + * Perform an "undo" action on a {@link MapModel}. + * @param undoModel the state to undo + * @param mapModel the map model to affect + */ + public static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void undo(@NotNull final UndoModel<G, A, R> undoModel, @NotNull final MapModel<G, A, R> mapModel) { + final UndoState<G, A, R> undoState = undoModel.undo(); + try { + mapModel.beginTransaction(undoState.getName()); + try { + final A newMapArchObject = undoState.getMapArchObject(); + mapModel.resizeMap(newMapArchObject.getMapSize()); + final MapArchObject<A> mapArchObject = mapModel.getMapArchObject(); + mapArchObject.beginTransaction(); + try { + mapArchObject.setState(newMapArchObject); + } finally { + mapArchObject.endTransaction(); + } + undoState.getSavedSquares().applyChanges(mapModel); + } finally { + mapModel.endTransaction(); + } + } finally { + undoModel.finish(); + } + } + + /** + * Perform a "redo" action on a {@link MapModel}. + * @param undoModel the state to redo + * @param mapModel the map model to affect + */ + public static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void redo(@NotNull final UndoModel<G, A, R> undoModel, @NotNull final MapModel<G, A, R> mapModel) { + final UndoState<G, A, R> undoState = undoModel.redo(); + try { + mapModel.beginTransaction(undoState.getName()); + try { + final A newMapArchObject = undoState.getMapArchObject(); + mapModel.resizeMap(newMapArchObject.getMapSize()); + final MapArchObject<A> mapArchObject = mapModel.getMapArchObject(); + mapArchObject.beginTransaction(); + try { + mapArchObject.setState(newMapArchObject); + } finally { + mapArchObject.endTransaction(); + } + undoState.getSavedSquares().applyChanges(mapModel); + } finally { + mapModel.endTransaction(); + } + } finally { + undoModel.finish(); + } + } + +} // class UndoActions Property changes on: trunk/src/app/net/sf/gridarta/actions/UndoActions.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java 2010-06-03 13:53:53 UTC (rev 8071) +++ trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java 2010-06-03 14:04:49 UTC (rev 8072) @@ -22,6 +22,7 @@ import java.util.IdentityHashMap; import java.util.Map; import javax.swing.Action; +import net.sf.gridarta.actions.UndoActions; import net.sf.gridarta.mapmanager.MapManager; import net.sf.gridarta.mapmanager.MapManagerListener; import net.sf.gridarta.model.archetype.Archetype; @@ -284,26 +285,7 @@ } if (performAction) { - final UndoState<G, A, R> undoState = undoModel.undo(); - try { - tmpMapModel.beginTransaction(undoState.getName()); - try { - final A newMapArchObject = undoState.getMapArchObject(); - tmpMapModel.resizeMap(newMapArchObject.getMapSize()); - final MapArchObject<A> mapArchObject = tmpMapModel.getMapArchObject(); - mapArchObject.beginTransaction(); - try { - mapArchObject.setState(newMapArchObject); - } finally { - mapArchObject.endTransaction(); - } - undoState.getSavedSquares().applyChanges(tmpMapModel); - } finally { - tmpMapModel.endTransaction(); - } - } finally { - undoModel.finish(); - } + UndoActions.undo(undoModel, tmpMapModel); refreshMenus(); } @@ -335,26 +317,7 @@ } if (performAction) { - final UndoState<G, A, R> undoState = undoModel.redo(); - try { - tmpMapModel.beginTransaction(undoState.getName()); - try { - final A newMapArchObject = undoState.getMapArchObject(); - tmpMapModel.resizeMap(newMapArchObject.getMapSize()); - final MapArchObject<A> mapArchObject = tmpMapModel.getMapArchObject(); - mapArchObject.beginTransaction(); - try { - mapArchObject.setState(newMapArchObject); - } finally { - mapArchObject.endTransaction(); - } - undoState.getSavedSquares().applyChanges(tmpMapModel); - } finally { - tmpMapModel.endTransaction(); - } - } finally { - undoModel.finish(); - } + UndoActions.redo(undoModel, tmpMapModel); refreshMenus(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-03 13:54:00
|
Revision: 8071 http://gridarta.svn.sourceforge.net/gridarta/?rev=8071&view=rev Author: akirschbaum Date: 2010-06-03 13:53:53 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Merge duplicated code. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java Modified: trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java 2010-06-03 13:52:09 UTC (rev 8070) +++ trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java 2010-06-03 13:53:53 UTC (rev 8071) @@ -191,8 +191,7 @@ }; mapManager.addMapManagerListener(mapManagerListener); - aUndo.setEnabled(false); - aRedo.setEnabled(false); + refreshMenus(); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-03 13:52:15
|
Revision: 8070 http://gridarta.svn.sourceforge.net/gridarta/?rev=8070&view=rev Author: akirschbaum Date: 2010-06-03 13:52:09 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Remove UndoControl.mapManagerListener. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java Modified: trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java 2010-06-03 13:51:12 UTC (rev 8069) +++ trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java 2010-06-03 13:52:09 UTC (rev 8070) @@ -56,18 +56,6 @@ private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); /** - * The {@link GameObjectFactory} to use. - */ - @NotNull - private final GameObjectFactory<G, A, R> gameObjectFactory; - - /** - * The {@link GameObjectMatchers} to use. - */ - @NotNull - private final GameObjectMatchers gameObjectMatchers; - - /** * Contains an {@link UndoModel} for each known {@link MapModel}. */ @NotNull @@ -153,41 +141,6 @@ }; /** - * Listener to be notified for created/deleted maps. - */ - @NotNull - private final MapManagerListener<G, A, R> mapManagerListener = new MapManagerListener<G, A, R>() { - - /** {@inheritDoc} */ - @Override - public void currentMapChanged(@Nullable final MapControl<G, A, R> mapControl) { - mapModel = mapControl == null ? null : mapControl.getMapModel(); - refreshMenus(); - } - - /** {@inheritDoc} */ - @Override - public void mapCreated(@NotNull final MapControl<G, A, R> mapControl, final boolean interactive) { - undoModels.put(mapControl.getMapModel(), new UndoModel<G, A, R>(gameObjectFactory, gameObjectMatchers)); - mapControl.getMapModel().addMapTransactionListener(mapTransactionListener); - } - - /** {@inheritDoc} */ - @Override - public void mapClosing(@NotNull final MapControl<G, A, R> mapControl) { - // ignore - } - - /** {@inheritDoc} */ - @Override - public void mapClosed(@NotNull final MapControl<G, A, R> mapControl) { - undoModels.remove(mapControl.getMapModel()); - mapControl.getMapModel().removeMapTransactionListener(mapTransactionListener); - } - - }; - - /** * Action for "undo" function. */ @NotNull @@ -206,9 +159,38 @@ * @param gameObjectMatchers the game object matchers to use */ public UndoControl(@NotNull final MapManager<G, A, R> mapManager, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final GameObjectMatchers gameObjectMatchers) { - this.gameObjectFactory = gameObjectFactory; - this.gameObjectMatchers = gameObjectMatchers; + final MapManagerListener<G, A, R> mapManagerListener = new MapManagerListener<G, A, R>() { + + /** {@inheritDoc} */ + @Override + public void currentMapChanged(@Nullable final MapControl<G, A, R> mapControl) { + mapModel = mapControl == null ? null : mapControl.getMapModel(); + refreshMenus(); + } + + /** {@inheritDoc} */ + @Override + public void mapCreated(@NotNull final MapControl<G, A, R> mapControl, final boolean interactive) { + undoModels.put(mapControl.getMapModel(), new UndoModel<G, A, R>(gameObjectFactory, gameObjectMatchers)); + mapControl.getMapModel().addMapTransactionListener(mapTransactionListener); + } + + /** {@inheritDoc} */ + @Override + public void mapClosing(@NotNull final MapControl<G, A, R> mapControl) { + // ignore + } + + /** {@inheritDoc} */ + @Override + public void mapClosed(@NotNull final MapControl<G, A, R> mapControl) { + undoModels.remove(mapControl.getMapModel()); + mapControl.getMapModel().removeMapTransactionListener(mapTransactionListener); + } + + }; mapManager.addMapManagerListener(mapManagerListener); + aUndo.setEnabled(false); aRedo.setEnabled(false); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-03 13:51:18
|
Revision: 8069 http://gridarta.svn.sourceforge.net/gridarta/?rev=8069&view=rev Author: akirschbaum Date: 2010-06-03 13:51:12 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Add @NotNull annotations. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java Modified: trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java 2010-06-03 13:50:15 UTC (rev 8068) +++ trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java 2010-06-03 13:51:12 UTC (rev 8069) @@ -52,6 +52,7 @@ /** * Action Builder to create Actions. */ + @NotNull private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); /** @@ -69,6 +70,7 @@ /** * Contains an {@link UndoModel} for each known {@link MapModel}. */ + @NotNull private final Map<MapModel<G, A, R>, UndoModel<G, A, R>> undoModels = new IdentityHashMap<MapModel<G, A, R>, UndoModel<G, A, R>>(); /** @@ -87,6 +89,7 @@ * Listener to be notified for map transactions. The same listener is * registered for all known maps. */ + @NotNull private final MapTransactionListener<G, A, R> mapTransactionListener = new MapTransactionListener<G, A, R>() { /** @@ -152,6 +155,7 @@ /** * Listener to be notified for created/deleted maps. */ + @NotNull private final MapManagerListener<G, A, R> mapManagerListener = new MapManagerListener<G, A, R>() { /** {@inheritDoc} */ @@ -186,11 +190,13 @@ /** * Action for "undo" function. */ + @NotNull private final Action aUndo = ActionUtils.newAction(ACTION_BUILDER, "Undo", this, "undo"); /** * Action for "redo" function. */ + @NotNull private final Action aRedo = ActionUtils.newAction(ACTION_BUILDER, "Undo", this, "redo"); /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-03 13:50:22
|
Revision: 8068 http://gridarta.svn.sourceforge.net/gridarta/?rev=8068&view=rev Author: akirschbaum Date: 2010-06-03 13:50:15 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Merge duplicated code. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java Modified: trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java 2010-06-03 12:37:19 UTC (rev 8067) +++ trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java 2010-06-03 13:50:15 UTC (rev 8068) @@ -211,8 +211,9 @@ * Enable/disable menu entries based on the current state. */ private void refreshMenus() { - aUndo.setEnabled(isUndoEnabled()); - if (isUndoEnabled()) { + final boolean undoEnabled = doUndo(false); + aUndo.setEnabled(undoEnabled); + if (undoEnabled) { final UndoModel<G, A, R> undoModel = undoModels.get(mapModel); assert undoModel != null; aUndo.putValue(Action.NAME, ACTION_BUILDER.format("undo.name", undoModel.undoName())); @@ -220,8 +221,9 @@ aUndo.putValue(Action.NAME, ACTION_BUILDER.getString("undo.text")); } - aRedo.setEnabled(isRedoEnabled()); - if (isRedoEnabled()) { + final boolean redoEnabled = doRedo(false); + aRedo.setEnabled(redoEnabled); + if (redoEnabled) { final UndoModel<G, A, R> redoModel = undoModels.get(mapModel); assert redoModel != null; aRedo.putValue(Action.NAME, ACTION_BUILDER.format("redo.name", redoModel.redoName())); @@ -235,34 +237,7 @@ */ @ActionMethod public void undo() { - final MapModel<G, A, R> localMapModel = mapModel; - if (!isUndoEnabled() || localMapModel == null) { - return; - } - - final UndoModel<G, A, R> undoModel = undoModels.get(localMapModel); - assert undoModel != null; - final UndoState<G, A, R> undoState = undoModel.undo(); - try { - localMapModel.beginTransaction(undoState.getName()); - try { - final A newMapArchObject = undoState.getMapArchObject(); - localMapModel.resizeMap(newMapArchObject.getMapSize()); - final MapArchObject<A> mapArchObject = localMapModel.getMapArchObject(); - mapArchObject.beginTransaction(); - try { - mapArchObject.setState(newMapArchObject); - } finally { - mapArchObject.endTransaction(); - } - undoState.getSavedSquares().applyChanges(localMapModel); - } finally { - localMapModel.endTransaction(); - } - } finally { - undoModel.finish(); - } - refreshMenus(); + doUndo(true); } /** @@ -270,47 +245,45 @@ */ @ActionMethod public void redo() { - final MapModel<G, A, R> localMapModel = mapModel; - if (!isRedoEnabled() || localMapModel == null) { - return; - } + doRedo(true); + } - final UndoModel<G, A, R> undoModel = undoModels.get(localMapModel); - assert undoModel != null; - final UndoState<G, A, R> undoState = undoModel.redo(); - try { - localMapModel.beginTransaction(undoState.getName()); - try { - final A newMapArchObject = undoState.getMapArchObject(); - localMapModel.resizeMap(newMapArchObject.getMapSize()); - final MapArchObject<A> mapArchObject = localMapModel.getMapArchObject(); - mapArchObject.beginTransaction(); - try { - mapArchObject.setState(newMapArchObject); - } finally { - mapArchObject.endTransaction(); - } - undoState.getSavedSquares().applyChanges(localMapModel); - } finally { - localMapModel.endTransaction(); + /** + * Returns the maximum number of undo states saved for each map. + * @return the maximum number of undo states saved for each map; + * <code>0</code>=unlimited + */ + public int getMaxUndoStates() { + return maxUndoStates; + } + + /** + * Sets the maximum number of undo states saved for each map. + * @param maxUndoStates the maximum number of undo states saved for each + * map; <code>0</code>=unlimited + */ + public void setMaxUndoStates(final int maxUndoStates) { + this.maxUndoStates = maxUndoStates; + + if (maxUndoStates > 0) { + for (final UndoModel<G, A, R> undoModel : undoModels.values()) { + undoModel.trimToSize(maxUndoStates); } - } finally { - undoModel.finish(); } - refreshMenus(); } /** - * Determine if "undo" is enabled. - * @return <code>true</code> if "undo" is enabled, <code>false</code> - * otherwise + * Performs the "undo" action. + * @param performAction whether to perform or check the action + * @return whether the action was or can be performed */ - private boolean isUndoEnabled() { - if (mapModel == null) { + private boolean doUndo(final boolean performAction) { + final MapModel<G, A, R> tmpMapModel = mapModel; + if (tmpMapModel == null) { return false; } - final UndoModel<G, A, R> undoModel = undoModels.get(mapModel); + final UndoModel<G, A, R> undoModel = undoModels.get(tmpMapModel); if (undoModel == null) { // XXX: should be "assert undoModel != null"; this does not work // because MapViewManager.activateMapView() calls @@ -318,20 +291,50 @@ // currentMapChanged() event before a mapCreated() event return false; } - return undoModel.canUndo(); + + if (!undoModel.canUndo()) { + return false; + } + + if (performAction) { + final UndoState<G, A, R> undoState = undoModel.undo(); + try { + tmpMapModel.beginTransaction(undoState.getName()); + try { + final A newMapArchObject = undoState.getMapArchObject(); + tmpMapModel.resizeMap(newMapArchObject.getMapSize()); + final MapArchObject<A> mapArchObject = tmpMapModel.getMapArchObject(); + mapArchObject.beginTransaction(); + try { + mapArchObject.setState(newMapArchObject); + } finally { + mapArchObject.endTransaction(); + } + undoState.getSavedSquares().applyChanges(tmpMapModel); + } finally { + tmpMapModel.endTransaction(); + } + } finally { + undoModel.finish(); + } + refreshMenus(); + } + + return true; } /** - * Determine if "redo" is enabled. - * @return <code>true</code> if "redo" is enabled, <code>false</code> - * otherwise + * Performs the "redo" action. + * @param performAction whether to perform or check the action + * @return whether the action was or can be performed */ - private boolean isRedoEnabled() { - if (mapModel == null) { + private boolean doRedo(final boolean performAction) { + final MapModel<G, A, R> tmpMapModel = mapModel; + if (tmpMapModel == null) { return false; } - final UndoModel<G, A, R> undoModel = undoModels.get(mapModel); + final UndoModel<G, A, R> undoModel = undoModels.get(tmpMapModel); if (undoModel == null) { // XXX: should be "assert undoModel != null"; this does not work // because MapViewManager.activateMapView() calls @@ -339,31 +342,36 @@ // currentMapChanged() event before a mapCreated() event return false; } - return undoModel.canRedo(); - } - /** - * Returns the maximum number of undo states saved for each map. - * @return the maximum number of undo states saved for each map; - * <code>0</code>=unlimited - */ - public int getMaxUndoStates() { - return maxUndoStates; - } + if (!undoModel.canRedo()) { + return false; + } - /** - * Sets the maximum number of undo states saved for each map. - * @param maxUndoStates the maximum number of undo states saved for each - * map; <code>0</code>=unlimited - */ - public void setMaxUndoStates(final int maxUndoStates) { - this.maxUndoStates = maxUndoStates; - - if (maxUndoStates > 0) { - for (final UndoModel<G, A, R> undoModel : undoModels.values()) { - undoModel.trimToSize(maxUndoStates); + if (performAction) { + final UndoState<G, A, R> undoState = undoModel.redo(); + try { + tmpMapModel.beginTransaction(undoState.getName()); + try { + final A newMapArchObject = undoState.getMapArchObject(); + tmpMapModel.resizeMap(newMapArchObject.getMapSize()); + final MapArchObject<A> mapArchObject = tmpMapModel.getMapArchObject(); + mapArchObject.beginTransaction(); + try { + mapArchObject.setState(newMapArchObject); + } finally { + mapArchObject.endTransaction(); + } + undoState.getSavedSquares().applyChanges(tmpMapModel); + } finally { + tmpMapModel.endTransaction(); + } + } finally { + undoModel.finish(); } + refreshMenus(); } + + return true; } } // UndoControl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-03 12:37:27
|
Revision: 8067 http://gridarta.svn.sourceforge.net/gridarta/?rev=8067&view=rev Author: akirschbaum Date: 2010-06-03 12:37:19 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Prevent Paste/Undo/Redo from breaking the map when applied to game objects having inventories. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/model/baseobject/GameObjectContainer.java trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java Added Paths: ----------- trunk/src/test/net/sf/gridarta/gui/copybuffer/ trunk/src/test/net/sf/gridarta/gui/copybuffer/CopyBufferTest.java trunk/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java trunk/src/test/net/sf/gridarta/model/map/maparchobject/TestMapArchObjectFactory.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-06-03 12:30:17 UTC (rev 8066) +++ trunk/atrinik/ChangeLog 2010-06-03 12:37:19 UTC (rev 8067) @@ -1,5 +1,8 @@ 2010-06-03 Andreas Kirschbaum + * Prevent Paste/Undo/Redo from breaking the map when applied to + game objects having inventories. + * Fix "Move Env" and "Move Inv" actions in selected square view when applied to multi-part game objects. Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-06-03 12:30:17 UTC (rev 8066) +++ trunk/crossfire/ChangeLog 2010-06-03 12:37:19 UTC (rev 8067) @@ -1,5 +1,8 @@ 2010-06-03 Andreas Kirschbaum + * Prevent Paste/Undo/Redo from breaking the map when applied to + game objects having inventories. + * Fix "Move Env" and "Move Inv" actions in selected square view when applied to multi-part game objects. Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-06-03 12:30:17 UTC (rev 8066) +++ trunk/daimonin/ChangeLog 2010-06-03 12:37:19 UTC (rev 8067) @@ -1,5 +1,8 @@ 2010-06-03 Andreas Kirschbaum + * Prevent Paste/Undo/Redo from breaking the map when applied to + game objects having inventories. + * Fix "Move Env" and "Move Inv" actions in selected square view when applied to multi-part game objects. Modified: trunk/src/app/net/sf/gridarta/model/baseobject/GameObjectContainer.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/baseobject/GameObjectContainer.java 2010-06-03 12:30:17 UTC (rev 8066) +++ trunk/src/app/net/sf/gridarta/model/baseobject/GameObjectContainer.java 2010-06-03 12:37:19 UTC (rev 8067) @@ -600,7 +600,7 @@ for (final BaseObject<G, A, R, G> gameObject : contents) { final G clonedGameObject = gameObject.clone(); clone.contents.add(clonedGameObject); - setThisContainer(clonedGameObject); + clone.setThisContainer(clonedGameObject); } return clone; } catch (final CloneNotSupportedException e) { Added: trunk/src/test/net/sf/gridarta/gui/copybuffer/CopyBufferTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/copybuffer/CopyBufferTest.java (rev 0) +++ trunk/src/test/net/sf/gridarta/gui/copybuffer/CopyBufferTest.java 2010-06-03 12:37:19 UTC (rev 8067) @@ -0,0 +1,95 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.copybuffer; + +import java.awt.Point; +import java.awt.Rectangle; +import java.io.File; +import net.sf.gridarta.gui.map.mapview.MapView; +import net.sf.gridarta.gui.map.test.TestMapControlCreator; +import net.sf.gridarta.model.archetype.DuplicateArchetypeException; +import net.sf.gridarta.model.archetype.TestArchetype; +import net.sf.gridarta.model.gameobject.TestGameObject; +import net.sf.gridarta.model.map.grid.SelectionMode; +import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; +import net.sf.gridarta.model.map.mapcontrol.MapControl; +import net.sf.gridarta.model.map.mapmodel.MapModel; +import net.sf.gridarta.utils.Size2D; +import org.junit.Test; + +/** + * Regression tests for {@link CopyBuffer}. + * @author Andreas Kirschbaum + */ +public class CopyBufferTest { + + /** + * The first map file. + */ + private static final File MAP_FILE1 = new File("a"); + + /** + * The first map name. + */ + private static final String MAP_NAME1 = "name1"; + + /** + * Checks that {@link CopyBuffer#cut(MapView, Rectangle)} followed by {@link + * CopyBuffer#paste(MapView, Point)} does work. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testCutPaste1() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(3, 3)); + + final Point point = new Point(1, 1); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final TestGameObject ob1 = testMapControlCreator.insertFloor(mapModel, point); + final TestGameObject ob2 = testMapControlCreator.insertMob21(ob1); + + TestMapControlCreator.checkMapContents(mapModel, + "||", + "|floor|", + "||"); + TestMapControlCreator.checkContents(ob1, ob2); + + // select + cut + final CopyBuffer<TestGameObject, TestMapArchObject, TestArchetype> copyBuffer = testMapControlCreator.newCopyBuffer(); + final MapView<TestGameObject, TestMapArchObject, TestArchetype> mapView = testMapControlCreator.newMapView(mapControl); + mapView.getMapViewBasic().getMapGrid().select(new Point(1, 1), new Point(1, 1), SelectionMode.ADD); + copyBuffer.cut(mapView, new Rectangle(1, 1, 1, 1)); + + TestMapControlCreator.checkMapContents(mapModel, + "||", + "||", + "||"); + + // paste + copyBuffer.paste(mapView, new Point(1, 1)); + + TestMapControlCreator.checkMapContents(mapModel, + "||", + "|floor|", + "||"); + } + +} // class CopyBufferTest Property changes on: trunk/src/test/net/sf/gridarta/gui/copybuffer/CopyBufferTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java 2010-06-03 12:30:17 UTC (rev 8066) +++ trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java 2010-06-03 12:37:19 UTC (rev 8067) @@ -22,6 +22,7 @@ import java.awt.Point; import java.io.File; import java.util.regex.Pattern; +import net.sf.gridarta.gui.copybuffer.CopyBuffer; import net.sf.gridarta.gui.map.mapview.MapView; import net.sf.gridarta.gui.map.mapview.MapViewBasic; import net.sf.gridarta.gui.map.renderer.RendererFactory; @@ -47,6 +48,7 @@ import net.sf.gridarta.model.face.DefaultFaceObjects; import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.face.FaceObjects; +import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.gameobject.GameObjectFactory; import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.gameobject.TestGameObjectFactory; @@ -55,7 +57,9 @@ import net.sf.gridarta.model.io.PathManager; import net.sf.gridarta.model.io.TestMapReaderFactory; import net.sf.gridarta.model.io.TestMapWriter; +import net.sf.gridarta.model.map.maparchobject.MapArchObjectFactory; import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; +import net.sf.gridarta.model.map.maparchobject.TestMapArchObjectFactory; import net.sf.gridarta.model.map.mapcontrol.MapControl; import net.sf.gridarta.model.map.mapcontrol.MapControlFactory; import net.sf.gridarta.model.map.mapcontrol.TestMapControlFactory; @@ -99,6 +103,12 @@ private static final int MOB_TYPE = 3; /** + * An empty array of strings. + */ + @NotNull + private static final String[] EMPTY_STRING_ARRAY = new String[0]; + + /** * The {@link SystemIcons} instance. */ @NotNull @@ -159,6 +169,23 @@ private final GlobalSettings globalSettings; /** + * The {@link MapViewSettings} instance. + */ + @NotNull + private final MapViewSettings mapViewSettings; + + /** + * The {@link MapArchObjectFactory} instance. + */ + @NotNull + private final MapArchObjectFactory<TestMapArchObject> mapArchObjectFactory = new TestMapArchObjectFactory(); + /** + * The {@link MapControlFactory} instance. + */ + @NotNull + private final MapControlFactory<TestGameObject, TestMapArchObject, TestArchetype> mapControlFactory; + + /** * The "topmost" {@link InsertionMode} instance. */ @NotNull @@ -184,7 +211,7 @@ archetypeSet = new TestArchetypeSet(archetypeFactory, "archetypes"); final MapReaderFactory<TestGameObject, TestMapArchObject> mapReaderFactory = new TestMapReaderFactory(); globalSettings = new TestGlobalSettings(); - final MapViewSettings mapViewSettings = new MapViewSettings(); + mapViewSettings = new MapViewSettings(); final MapWriter<TestGameObject, TestMapArchObject, TestArchetype> mapWriter = new TestMapWriter(); final FaceObjectProviders faceObjectProviders = newFaceObjectProviders(); final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists = new AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype>(mapViewSettings); @@ -195,7 +222,7 @@ topmostInsertionMode = new TopmostInsertionMode<TestGameObject, TestMapArchObject, TestArchetype>(); insertionModeSet = new InsertionModeSet<TestGameObject, TestMapArchObject, TestArchetype>(topmostInsertionMode); insertionModeSet.init(new TypeNrsGameObjectMatcher(), new TypeNrsGameObjectMatcher(), new TypeNrsGameObjectMatcher()); - final MapControlFactory<TestGameObject, TestMapArchObject, TestArchetype> mapControlFactory = new TestMapControlFactory(mapWriter, autojoinLists, archetypeChooserModel, gameObjectFactory, globalSettings, gameObjectMatchers, topmostInsertionMode); + mapControlFactory = new TestMapControlFactory(mapWriter, autojoinLists, archetypeChooserModel, gameObjectFactory, globalSettings, gameObjectMatchers, topmostInsertionMode); final AbstractMapManager<TestGameObject, TestMapArchObject, TestArchetype> tmpMapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype>(mapReaderFactory, mapControlFactory, globalSettings); tmpMapManager.setFileControl(new TestFileControl()); mapManager = tmpMapManager; @@ -225,7 +252,7 @@ * @return the map control */ public MapControl<TestGameObject, TestMapArchObject, TestArchetype> newMapControl(@Nullable final File mapFile, @NotNull final String mapName, @NotNull final Size2D mapSize) { - final TestMapArchObject mapArchObject = new TestMapArchObject(); + final TestMapArchObject mapArchObject = mapArchObjectFactory.newMapArchObject(false); mapArchObject.setMapSize(mapSize); mapArchObject.setMapName(mapName); final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = mapManager.newMap(null, mapArchObject, mapFile, true); @@ -398,9 +425,42 @@ if (i < gameObjects.length) { Assert.fail("map square is missing game object '" + gameObjects[i].getBestName() + "'"); } + + final boolean inContainer = mapSquare instanceof GameObject; + for (final TestGameObject gameObject : mapSquare) { + Assert.assertEquals(inContainer, gameObject.isInContainer()); + if (inContainer) { + // game objects within inventories must not contain tail parts + Assert.assertFalse(gameObject.isMulti()); + } else { + // game objects on the map must have expanded tail parts + Assert.assertEquals(gameObject.getArchetype().isMulti(), gameObject.isMulti()); + } + } } /** + * Checks that a {@link MapSquare} contains the given game objects. + * @param mapSquare the map square + * @param gameObjects the game object + */ + public static void checkContentsString(@NotNull final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare, @NotNull final String... gameObjects) { + int i = 0; + for (final TestGameObject gameObject : mapSquare) { + final String gameObjectName = gameObject.getBestName(); + if (i >= gameObjects.length) { + Assert.fail("map square " + mapSquare.getMapX() + "/" + mapSquare.getMapY() + " contains excess game object '" + gameObjectName + "'"); + } else if (!gameObjectName.equals(gameObjects[i])) { + Assert.fail("map square " + mapSquare.getMapX() + "/" + mapSquare.getMapY() + " contains wrong game object '" + gameObjectName + "' at index " + i + ", expected '" + gameObjects[i] + "'"); + } + i++; + } + if (i < gameObjects.length) { + Assert.fail("map square " + mapSquare.getMapX() + "/" + mapSquare.getMapY() + " is missing game object '" + gameObjects[i] + "'"); + } + } + + /** * Creates a new {@link MapView} instance. * @param mapControl the associated map control * @return the map view instance @@ -413,4 +473,48 @@ return mapView; } + /** + * Returns a new {@link CopyBuffer} instance. + * @return the copy buffer instance + */ + @NotNull + public CopyBuffer<TestGameObject, TestMapArchObject, TestArchetype> newCopyBuffer() { + return new CopyBuffer<TestGameObject, TestMapArchObject, TestArchetype>(mapViewSettings, gameObjectFactory, mapArchObjectFactory, mapControlFactory, insertionModeSet); + } + + /** + * Checks for expected {@link MapModel}'s contents. + * @param mapModel the map model + * @param lines the expected contents + */ + public static void checkMapContents(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, @NotNull final String... lines) { + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); + Assert.assertEquals(lines.length, mapSize.getHeight()); + final Pattern pattern1 = Pattern.compile("\\|"); + final Pattern pattern2 = Pattern.compile(","); + final Point pos = new Point(); + for (int y = 0; y < lines.length; y++) { + final String line = lines[y]; + final String[] square = pattern1.split(line, -1); + Assert.assertEquals(square.length, mapSize.getWidth()); + + for (int x = 0; x < square.length; x++) { + final String square2 = square[x]; + final String[] gameObjects = square2.isEmpty() ? EMPTY_STRING_ARRAY : pattern2.split(square2, -1); + pos.x = x; + pos.y = y; + checkContentsString(mapModel.getMapSquare(pos), gameObjects); + } + } + } + + /** + * Returns the {@link GameObjectFactory} instance. + * @return the game object factory + */ + @NotNull + public GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> getGameObjectFactory() { + return gameObjectFactory; + } + } // class TestMapControlCreator Added: trunk/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java (rev 0) +++ trunk/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java 2010-06-03 12:37:19 UTC (rev 8067) @@ -0,0 +1,69 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.model.gameobject; + +import java.awt.Point; +import java.io.File; +import net.sf.gridarta.gui.map.test.TestMapControlCreator; +import net.sf.gridarta.gui.selectedsquare.SelectedSquareActions; +import net.sf.gridarta.model.archetype.DuplicateArchetypeException; +import net.sf.gridarta.model.archetype.TestArchetype; +import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; +import net.sf.gridarta.model.map.mapcontrol.MapControl; +import net.sf.gridarta.model.map.mapmodel.MapModel; +import net.sf.gridarta.utils.Size2D; +import org.junit.Assert; +import org.junit.Test; + +/** + * Regression tests for {@link GameObjectFactory}. + * @author Andreas Kirschbaum + */ +public class GameObjectFactoryTest { + + /** + * Checks that {@link SelectedSquareActions#doMoveSquareTop(boolean)} does + * work for single-square game objects. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareTopSingle() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(new File("file"), "name", new Size2D(1, 1)); + + final Point point = new Point(0, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final TestGameObject ob1 = testMapControlCreator.insertFloor(mapModel, point); + final TestGameObject ob2 = testMapControlCreator.insertExit(ob1); + + final TestGameObject ob1Clone = testMapControlCreator.getGameObjectFactory().cloneGameObject(ob1); + + Assert.assertNotSame(ob1, ob1Clone); + Assert.assertEquals(1, ob1Clone.countInvObjects()); + final TestGameObject ob2Clone = ob1Clone.getFirst(); + Assert.assertNotNull(ob2Clone); + Assert.assertNotSame(ob2, ob2Clone); + + Assert.assertSame(ob1, ob2.getContainer()); + Assert.assertSame(ob1Clone, ob2Clone.getContainer()); + } + +} // class GameObjectFactoryTest Property changes on: trunk/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/src/test/net/sf/gridarta/model/map/maparchobject/TestMapArchObjectFactory.java =================================================================== --- trunk/src/test/net/sf/gridarta/model/map/maparchobject/TestMapArchObjectFactory.java (rev 0) +++ trunk/src/test/net/sf/gridarta/model/map/maparchobject/TestMapArchObjectFactory.java 2010-06-03 12:37:19 UTC (rev 8067) @@ -0,0 +1,39 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.model.map.maparchobject; + +import org.jetbrains.annotations.NotNull; + +/** + * A {@link MapArchObjectFactory} for regression tests. + * @author Andreas Kirschbaum + */ +public class TestMapArchObjectFactory implements MapArchObjectFactory<TestMapArchObject> { + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public TestMapArchObject newMapArchObject(final boolean addDefaultAttributes) { + return new TestMapArchObject(); + } + +} // class TestMapArchObjectFactory Property changes on: trunk/src/test/net/sf/gridarta/model/map/maparchobject/TestMapArchObjectFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-03 11:03:07
|
Revision: 8065 http://gridarta.svn.sourceforge.net/gridarta/?rev=8065&view=rev Author: akirschbaum Date: 2010-06-03 11:02:59 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Extract TestMapControlCreator.newMapView() from SelectedSquareActionsTest. Modified Paths: -------------- trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java Modified: trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java 2010-06-03 10:48:17 UTC (rev 8064) +++ trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java 2010-06-03 11:02:59 UTC (rev 8065) @@ -22,6 +22,10 @@ import java.awt.Point; import java.io.File; import java.util.regex.Pattern; +import net.sf.gridarta.gui.map.mapview.MapView; +import net.sf.gridarta.gui.map.mapview.MapViewBasic; +import net.sf.gridarta.gui.map.renderer.RendererFactory; +import net.sf.gridarta.gui.map.renderer.TestRendererFactory; import net.sf.gridarta.mapmanager.AbstractMapManager; import net.sf.gridarta.mapmanager.DefaultMapManager; import net.sf.gridarta.mapmanager.MapManager; @@ -395,4 +399,17 @@ } } + /** + * Creates a new {@link MapView} instance. + * @param mapControl the associated map control + * @return the map view instance + */ + @NotNull + public MapView<TestGameObject, TestMapArchObject, TestArchetype> newMapView(@NotNull final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl) { + final RendererFactory<TestGameObject, TestMapArchObject, TestArchetype> rendererFactory = new TestRendererFactory(); + final MapViewBasic<TestGameObject, TestMapArchObject, TestArchetype> mapViewBasic = new MapViewBasic<TestGameObject, TestMapArchObject, TestArchetype>(mapControl.getMapModel(), false, null, 1, 1, rendererFactory); + final MapView<TestGameObject, TestMapArchObject, TestArchetype> mapView = new MapView<TestGameObject, TestMapArchObject, TestArchetype>(mapControl, 0, mapViewBasic, pathManager); + return mapView; + } + } // class TestMapControlCreator Modified: trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java 2010-06-03 10:48:17 UTC (rev 8064) +++ trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java 2010-06-03 11:02:59 UTC (rev 8065) @@ -22,9 +22,6 @@ import java.awt.Point; import java.io.File; import net.sf.gridarta.gui.map.mapview.MapView; -import net.sf.gridarta.gui.map.mapview.MapViewBasic; -import net.sf.gridarta.gui.map.renderer.RendererFactory; -import net.sf.gridarta.gui.map.renderer.TestRendererFactory; import net.sf.gridarta.gui.map.test.TestMapControlCreator; import net.sf.gridarta.model.archetype.DuplicateArchetypeException; import net.sf.gridarta.model.archetype.TestArchetype; @@ -885,9 +882,7 @@ @NotNull private static SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> newSelectedSquareModel(@NotNull final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl, @NotNull final TestMapControlCreator testMapControlCreator) { final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = new SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype>(); - final RendererFactory<TestGameObject, TestMapArchObject, TestArchetype> rendererFactory = new TestRendererFactory(); - final MapViewBasic<TestGameObject, TestMapArchObject, TestArchetype> mapViewBasic = new MapViewBasic<TestGameObject, TestMapArchObject, TestArchetype>(mapControl.getMapModel(), false, null, 1, 1, rendererFactory); - final MapView<TestGameObject, TestMapArchObject, TestArchetype> mapView = new MapView<TestGameObject, TestMapArchObject, TestArchetype>(mapControl, 0, mapViewBasic, testMapControlCreator.getPathManager()); + final MapView<TestGameObject, TestMapArchObject, TestArchetype> mapView = testMapControlCreator.newMapView(mapControl); selectedSquareModel.setSelectedMapSquare(new MapSquareSelection<TestGameObject, TestMapArchObject, TestArchetype>(mapView)); return selectedSquareModel; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-03 10:48:24
|
Revision: 8064 http://gridarta.svn.sourceforge.net/gridarta/?rev=8064&view=rev Author: akirschbaum Date: 2010-06-03 10:48:17 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Fix "Move Env" and "Move Inv" actions in selected square view when applied to multi-part game objects. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java trunk/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java trunk/src/app/net/sf/gridarta/model/baseobject/BaseObject.java trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java trunk/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java trunk/src/test/net/sf/gridarta/model/gameobject/TestGameObject.java Added Paths: ----------- trunk/src/test/net/sf/gridarta/gui/selectedsquare/ trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-06-03 10:30:20 UTC (rev 8063) +++ trunk/atrinik/ChangeLog 2010-06-03 10:48:17 UTC (rev 8064) @@ -1,3 +1,8 @@ +2010-06-03 Andreas Kirschbaum + + * Fix "Move Env" and "Move Inv" actions in selected square view + when applied to multi-part game objects. + 2010-06-02 Andreas Kirschbaum * Fix archetype collection: do not drop mpart_id attributes for Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-06-03 10:30:20 UTC (rev 8063) +++ trunk/crossfire/ChangeLog 2010-06-03 10:48:17 UTC (rev 8064) @@ -1,3 +1,8 @@ +2010-06-03 Andreas Kirschbaum + + * Fix "Move Env" and "Move Inv" actions in selected square view + when applied to multi-part game objects. + 2010-05-29 Andreas Kirschbaum * Fix incorrect resource path names on Windows machines. Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-06-03 10:30:20 UTC (rev 8063) +++ trunk/daimonin/ChangeLog 2010-06-03 10:48:17 UTC (rev 8064) @@ -1,3 +1,8 @@ +2010-06-03 Andreas Kirschbaum + + * Fix "Move Env" and "Move Inv" actions in selected square view + when applied to multi-part game objects. + 2010-06-02 Andreas Kirschbaum * Fix archetype collection: do not drop mpart_id attributes for Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java 2010-06-03 10:30:20 UTC (rev 8063) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java 2010-06-03 10:48:17 UTC (rev 8064) @@ -19,8 +19,8 @@ package net.sf.gridarta.gui.selectedsquare; +import java.awt.Point; import net.sf.gridarta.model.archetype.Archetype; -import net.sf.gridarta.model.baseobject.GameObjectContainer; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; import net.sf.gridarta.model.map.mapmodel.MapModel; @@ -183,17 +183,18 @@ return false; } + final MapSquare<G, A, R> mapSquare = gameObject.getMapSquare(); + assert mapSquare != null; + final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); + final Point pos = new Point(mapSquare.getMapX(), mapSquare.getMapY()); + if (!envGameObject.isInContainer() && gameObject.getArchetype().isMulti() && !mapModel.isMultiArchFittingToMap(gameObject.getArchetype(), pos, true)) { + return false; + } + if (performAction) { - final GameObjectContainer<G, A, R> envGameObjectContainer = envGameObject.getContainer(); - assert envGameObjectContainer != null; - - final MapSquare<G, A, R> mapSquare = gameObject.getMapSquare(); - assert mapSquare != null; - final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); mapModel.beginTransaction("Move To Environment"); try { - gameObject.remove(); - envGameObjectContainer.addBefore(gameObject, envGameObject); + mapModel.moveEnv(gameObject, pos, envGameObject); } finally { mapModel.endTransaction(); } @@ -224,8 +225,7 @@ final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); mapModel.beginTransaction("Move To Inventory"); try { - gameObject.remove(); - prevGameObject.addFirst(gameObject); + mapModel.moveInv(gameObject, prevGameObject); } finally { mapModel.endTransaction(); } Modified: trunk/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2010-06-03 10:30:20 UTC (rev 8063) +++ trunk/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2010-06-03 10:48:17 UTC (rev 8064) @@ -573,6 +573,14 @@ * {@inheritDoc} */ @Override + public void removeTailParts() { + multi = null; + } + + /** + * {@inheritDoc} + */ + @Override public T getHead() { return multi != null ? multi.getHead() : getThis(); } Modified: trunk/src/app/net/sf/gridarta/model/baseobject/BaseObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/baseobject/BaseObject.java 2010-06-03 10:30:20 UTC (rev 8063) +++ trunk/src/app/net/sf/gridarta/model/baseobject/BaseObject.java 2010-06-03 10:48:17 UTC (rev 8064) @@ -339,6 +339,12 @@ void addTailPart(@NotNull T tail); /** + * Removes all tail parts of this game object. Afterwards {@link #isMulti()} + * will return <code>false</code>. + */ + void removeTailParts(); + + /** * Return the head part of a multi-part object. For single-part objects it * is the object itself. * @return the head of the object Modified: trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-03 10:30:20 UTC (rev 8063) +++ trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-03 10:48:17 UTC (rev 8064) @@ -32,6 +32,7 @@ import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.model.autojoin.AutojoinLists; import net.sf.gridarta.model.baseobject.BaseObject; +import net.sf.gridarta.model.baseobject.GameObjectContainer; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.gameobject.GameObjectFactory; import net.sf.gridarta.model.map.maparchobject.MapArchObject; @@ -716,17 +717,10 @@ } /** - * Checks whether an GameObject (multi-arch) would still fit on this map. - * @param archetype the archetype to check - * @param pos position of multi-square head - * @param allowDouble whether overlapping multi-square arches should be - * allowed (check is done using the arch name) - * @return whether the multi-arch would still fit on this map - * @retval <code>true</code> if the multi-square arch would still fit on - * this map - * @retval <code>false</code> otherwise + * {@inheritDoc} */ - private boolean isMultiArchFittingToMap(@NotNull final Archetype<G, A, R> archetype, @NotNull final Point pos, final boolean allowDouble) { + @Override + public boolean isMultiArchFittingToMap(@NotNull final Archetype<G, A, R> archetype, @NotNull final Point pos, final boolean allowDouble) { for (Archetype<G, A, R> part = archetype; part != null; part = part.getMultiNext()) { final Point point = new Point(part.getMultiX(), part.getMultiY()); point.translate(pos.x, pos.y); @@ -890,6 +884,46 @@ * {@inheritDoc} */ @Override + public void moveEnv(@NotNull final G gameObject, @NotNull final Point pos, @NotNull final G nextGameObject) { + assert !gameObject.isMulti(); // no tail parts should be present when inside inventory of another game object + final GameObjectContainer<G,A,R> nextGameObjectContainer = nextGameObject.getContainer(); + if (nextGameObjectContainer == null) { + throw new IllegalArgumentException(); + } + final MapSquare<G, A, R> mapSquare = nextGameObjectContainer.getMapSquare(); + if (mapSquare == null || mapSquare.getMapModel() != this) { + throw new IllegalArgumentException(); + } + gameObject.remove(); + nextGameObjectContainer.addBefore(gameObject, nextGameObject); + + // regenerate tail parts when inserted into a map square + if (!nextGameObject.isInContainer() && gameObject.getArchetype().isMulti()) { + final Point tmp = new Point(); + for (R archetypeTail = gameObject.getArchetype().getMultiNext(); archetypeTail != null; archetypeTail = archetypeTail.getMultiNext()) { + final G gameObjectTail = archetypeTail.newInstance(gameObjectFactory); + gameObject.addTailPart(gameObjectTail); + tmp.x = pos.x + archetypeTail.getMultiX(); + tmp.y = pos.y + archetypeTail.getMultiY(); + addGameObjectToMap(gameObjectTail, tmp, topmostInsertionMode); + } + } + } + + /** + * {@inheritDoc} + */ + @Override + public void moveInv(@NotNull final G gameObject, @NotNull final GameObject<G, A, R> prevGameObject) { + gameObject.remove(); + gameObject.removeTailParts(); + prevGameObject.addFirst(gameObject); + } + + /** + * {@inheritDoc} + */ + @Override public boolean isAreaEmpty(final int left, final int top, final int width, final int height) { final Point point = new Point(); for (int x = left; x < left + width; x++) { Modified: trunk/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java 2010-06-03 10:30:20 UTC (rev 8063) +++ trunk/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java 2010-06-03 10:48:17 UTC (rev 8064) @@ -314,6 +314,21 @@ void addGameObjectToMap(@NotNull G gameObject, @NotNull Point pos, @NotNull InsertionMode<G, A, R> insertionMode); /** + * Moves a {@link GameObject} to its environment. + * @param gameObject the game object to move + * @param pos the insertion position + * @param nextGameObject the next game object + */ + void moveEnv(@NotNull G gameObject, @NotNull Point pos, @NotNull G nextGameObject); + + /** + * Moves a {@link GameObject} to the inventory of another game object. + * @param gameObject the game object to move + * @param prevGameObject the previous game object + */ + void moveInv(@NotNull G gameObject, @NotNull GameObject<G, A, R> prevGameObject); + + /** * Inserts a {@link BaseObject} to a map. Archetypes are instantiated, game * objects are cloned. The direction of the inserted game object is set to * the direction of the archetype chooser. This function allows multi-square @@ -357,6 +372,19 @@ void removeGameObject(@NotNull G gameObject, boolean join); /** + * Checks whether an GameObject (multi-arch) would still fit on this map. + * @param archetype the archetype to check + * @param pos position of multi-square head + * @param allowDouble whether overlapping multi-square arches should be + * allowed (check is done using the arch name) + * @return whether the multi-arch would still fit on this map + * @retval <code>true</code> if the multi-square arch would still fit on + * this map + * @retval <code>false</code> otherwise + */ + boolean isMultiArchFittingToMap(@NotNull Archetype<G, A, R> archetype, @NotNull Point pos, boolean allowDouble); + + /** * Sets the errors in this map. * @param errors the errors */ Added: trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java (rev 0) +++ trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java 2010-06-03 10:48:17 UTC (rev 8064) @@ -0,0 +1,895 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.selectedsquare; + +import java.awt.Point; +import java.io.File; +import net.sf.gridarta.gui.map.mapview.MapView; +import net.sf.gridarta.gui.map.mapview.MapViewBasic; +import net.sf.gridarta.gui.map.renderer.RendererFactory; +import net.sf.gridarta.gui.map.renderer.TestRendererFactory; +import net.sf.gridarta.gui.map.test.TestMapControlCreator; +import net.sf.gridarta.model.archetype.DuplicateArchetypeException; +import net.sf.gridarta.model.archetype.TestArchetype; +import net.sf.gridarta.model.gameobject.TestGameObject; +import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; +import net.sf.gridarta.model.map.mapcontrol.MapControl; +import net.sf.gridarta.model.map.mapmodel.MapModel; +import net.sf.gridarta.model.map.mapmodel.MapSquare; +import net.sf.gridarta.utils.Size2D; +import org.jetbrains.annotations.NotNull; +import org.junit.Assert; +import org.junit.Test; + +/** + * Regression tests for {@link SelectedSquareActions}. + * @author Andreas Kirschbaum + */ +public class SelectedSquareActionsTest { + + /** + * The first map file. + */ + private static final File MAP_FILE1 = new File("a"); + + /** + * The first map name. + */ + private static final String MAP_NAME1 = "name1"; + + /** + * Checks that {@link SelectedSquareActions#doMoveSquareTop(boolean)} does + * work for single-square game objects. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareTopSingle() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(1, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point point = new Point(0, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare = mapModel.getMapSquare(point); + final TestGameObject ob2 = testMapControlCreator.insertFloor(mapModel, point); + final TestGameObject ob1 = testMapControlCreator.insertExit(mapModel, point); + + TestMapControlCreator.checkContents(mapSquare, ob2, ob1); + + // empty selection => nothing to move + Assert.assertFalse(selectedSquareActions.doMoveSquareTop(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareTop(true)); + + selectedSquareModel.setSelectedMapSquare(mapSquare, null, 0); + selectedSquareModel.setSelectedGameObject(ob2, 1); + + // [ob2, ob1] => ob2 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareTop(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareTop(true)); + TestMapControlCreator.checkContents(mapSquare, ob1, ob2); + + // [ob1, ob2] => ob2 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareTop(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareTop(true)); + TestMapControlCreator.checkContents(mapSquare, ob1, ob2); + } + + /** + * Checks that {@link SelectedSquareActions#doMoveSquareTop(boolean)} does + * work for multi-square game objects. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareTopMulti() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(2, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point pointHead = new Point(0, 0); + final Point pointTail = new Point(1, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareHead = mapModel.getMapSquare(pointHead); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareTail = mapModel.getMapSquare(pointTail); + final TestGameObject ob1Head = testMapControlCreator.insertFloor(mapModel, pointHead); + final TestGameObject ob1Tail = testMapControlCreator.insertFloor(mapModel, pointTail); + final TestGameObject ob2Head = testMapControlCreator.insertMob21(mapModel, pointHead); + final TestGameObject ob2Tail = ob2Head.getMultiNext(); + + TestMapControlCreator.checkContents(mapSquareHead, ob1Head, ob2Head); + TestMapControlCreator.checkContents(mapSquareTail, ob1Tail, ob2Tail); + + // empty selection => nothing to move + Assert.assertFalse(selectedSquareActions.doMoveSquareTop(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareTop(true)); + + selectedSquareModel.setSelectedMapSquare(mapSquareHead, null, 0); + selectedSquareModel.setSelectedGameObject(ob1Head, 1); + + // [ob1, ob2] => ob1 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareTop(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareTop(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob2Head, ob1Head); + TestMapControlCreator.checkContents(mapSquareTail, ob1Tail, ob2Tail); + + // [ob2, ob1] => ob1 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareTop(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareTop(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob2Head, ob1Head); + TestMapControlCreator.checkContents(mapSquareTail, ob1Tail, ob2Tail); + + selectedSquareModel.setSelectedMapSquare(mapSquareTail, null, 0); + selectedSquareModel.setSelectedGameObject(ob1Tail, 1); + + // [ob1, ob2] => ob1 can move // XXX: this probably should be changed: moving tail parts is not sensible + Assert.assertTrue(selectedSquareActions.doMoveSquareTop(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareTop(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob2Head, ob1Head); + TestMapControlCreator.checkContents(mapSquareTail, ob2Tail, ob1Tail); + + // [ob2, ob1] => ob1 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareTop(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareTop(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob2Head, ob1Head); + TestMapControlCreator.checkContents(mapSquareTail, ob2Tail, ob1Tail); + } + + /** + * Checks that {@link SelectedSquareActions#doMoveSquareUp(boolean)} does + * work for single-square game objects. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareUpSingle() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(1, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point point = new Point(0, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare = mapModel.getMapSquare(point); + final TestGameObject ob2 = testMapControlCreator.insertFloor(mapModel, point); + final TestGameObject ob1 = testMapControlCreator.insertExit(mapModel, point); + + TestMapControlCreator.checkContents(mapSquare, ob2, ob1); + + // empty selection => nothing to move + Assert.assertFalse(selectedSquareActions.doMoveSquareUp(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareUp(true)); + + selectedSquareModel.setSelectedMapSquare(mapSquare, null, 0); + selectedSquareModel.setSelectedGameObject(ob2, 1); + + // [ob2, ob1] => ob2 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareUp(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareUp(true)); + TestMapControlCreator.checkContents(mapSquare, ob1, ob2); + + // [ob1, ob2] => ob2 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareUp(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareUp(true)); + TestMapControlCreator.checkContents(mapSquare, ob1, ob2); + } + + /** + * Checks that {@link SelectedSquareActions#doMoveSquareUp(boolean)} does + * work for multi-square game objects. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareUpMulti() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(2, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point pointHead = new Point(0, 0); + final Point pointTail = new Point(1, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareHead = mapModel.getMapSquare(pointHead); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareTail = mapModel.getMapSquare(pointTail); + final TestGameObject ob2Head = testMapControlCreator.insertFloor(mapModel, pointHead); + final TestGameObject ob2Tail = testMapControlCreator.insertFloor(mapModel, pointTail); + final TestGameObject ob1Head = testMapControlCreator.insertMob21(mapModel, pointHead); + final TestGameObject ob1Tail = ob1Head.getMultiNext(); + + TestMapControlCreator.checkContents(mapSquareHead, ob2Head, ob1Head); + TestMapControlCreator.checkContents(mapSquareTail, ob2Tail, ob1Tail); + + // empty selection => nothing to move + Assert.assertFalse(selectedSquareActions.doMoveSquareUp(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareUp(true)); + + selectedSquareModel.setSelectedMapSquare(mapSquareHead, null, 0); + selectedSquareModel.setSelectedGameObject(ob2Head, 1); + + // [ob2, ob1] => ob2 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareUp(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareUp(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob1Head, ob2Head); + TestMapControlCreator.checkContents(mapSquareTail, ob2Tail, ob1Tail); + + // [ob1, ob2] => ob2 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareUp(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareUp(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob1Head, ob2Head); + TestMapControlCreator.checkContents(mapSquareTail, ob2Tail, ob1Tail); + + selectedSquareModel.setSelectedMapSquare(mapSquareTail, null, 0); + selectedSquareModel.setSelectedGameObject(ob2Tail, 1); + + // [ob2, ob1] => ob2 can move // XXX: this probably should be changed: moving tail parts is not sensible + Assert.assertTrue(selectedSquareActions.doMoveSquareUp(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareUp(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob1Head, ob2Head); + TestMapControlCreator.checkContents(mapSquareTail, ob1Tail, ob2Tail); + + // [ob1, ob2] => ob2 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareUp(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareUp(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob1Head, ob2Head); + TestMapControlCreator.checkContents(mapSquareTail, ob1Tail, ob2Tail); + } + + /** + * Checks that {@link SelectedSquareActions#doMoveSquareDown(boolean)} does + * work for single-square game objects. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareDownSingle() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(1, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point point = new Point(0, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare = mapModel.getMapSquare(point); + final TestGameObject ob1 = testMapControlCreator.insertExit(mapModel, point); + final TestGameObject ob2 = testMapControlCreator.insertFloor(mapModel, point); + + TestMapControlCreator.checkContents(mapSquare, ob1, ob2); + + // empty selection => nothing to move + Assert.assertFalse(selectedSquareActions.doMoveSquareDown(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareDown(true)); + + selectedSquareModel.setSelectedMapSquare(mapSquare, null, 0); + selectedSquareModel.setSelectedGameObject(ob2, 1); + + // [ob1, ob2] => ob2 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareDown(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareDown(true)); + TestMapControlCreator.checkContents(mapSquare, ob2, ob1); + + // [ob2, ob1] => ob2 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareDown(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareDown(true)); + TestMapControlCreator.checkContents(mapSquare, ob2, ob1); + } + + /** + * Checks that {@link SelectedSquareActions#doMoveSquareDown(boolean)} does + * work for multi-square game objects. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareDownMulti() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(2, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point pointHead = new Point(0, 0); + final Point pointTail = new Point(1, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareHead = mapModel.getMapSquare(pointHead); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareTail = mapModel.getMapSquare(pointTail); + final TestGameObject ob1Head = testMapControlCreator.insertMob21(mapModel, pointHead); + final TestGameObject ob1Tail = ob1Head.getMultiNext(); + final TestGameObject ob2Head = testMapControlCreator.insertFloor(mapModel, pointHead); + final TestGameObject ob2Tail = testMapControlCreator.insertFloor(mapModel, pointTail); + + TestMapControlCreator.checkContents(mapSquareHead, ob1Head, ob2Head); + TestMapControlCreator.checkContents(mapSquareTail, ob1Tail, ob2Tail); + + // empty selection => nothing to move + Assert.assertFalse(selectedSquareActions.doMoveSquareDown(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareDown(true)); + + selectedSquareModel.setSelectedMapSquare(mapSquareHead, null, 0); + selectedSquareModel.setSelectedGameObject(ob2Head, 1); + + // [ob2, ob1] => ob2 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareDown(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareDown(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob2Head, ob1Head); + TestMapControlCreator.checkContents(mapSquareTail, ob1Tail, ob2Tail); + + // [ob1, ob2] => ob2 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareDown(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareDown(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob2Head, ob1Head); + TestMapControlCreator.checkContents(mapSquareTail, ob1Tail, ob2Tail); + + selectedSquareModel.setSelectedMapSquare(mapSquareTail, null, 0); + selectedSquareModel.setSelectedGameObject(ob2Tail, 1); + + // [ob2, ob1] => ob2 can move // XXX: this probably should be changed: moving tail parts is not sensible + Assert.assertTrue(selectedSquareActions.doMoveSquareDown(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareDown(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob2Head, ob1Head); + TestMapControlCreator.checkContents(mapSquareTail, ob2Tail, ob1Tail); + + // [ob1, ob2] => ob2 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareDown(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareDown(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob2Head, ob1Head); + TestMapControlCreator.checkContents(mapSquareTail, ob2Tail, ob1Tail); + } + + /** + * Checks that {@link SelectedSquareActions#doMoveSquareBottom(boolean)} does + * work for single-square game objects. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareBottomSingle() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(1, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point point = new Point(0, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare = mapModel.getMapSquare(point); + final TestGameObject ob1 = testMapControlCreator.insertExit(mapModel, point); + final TestGameObject ob2 = testMapControlCreator.insertFloor(mapModel, point); + + TestMapControlCreator.checkContents(mapSquare, ob1, ob2); + + // empty selection => nothing to move + Assert.assertFalse(selectedSquareActions.doMoveSquareBottom(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareBottom(true)); + + selectedSquareModel.setSelectedMapSquare(mapSquare, null, 0); + selectedSquareModel.setSelectedGameObject(ob2, 1); + + // [ob1, ob2] => ob2 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareBottom(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareBottom(true)); + TestMapControlCreator.checkContents(mapSquare, ob2, ob1); + + // [ob2, ob1] => ob2 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareBottom(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareBottom(true)); + TestMapControlCreator.checkContents(mapSquare, ob2, ob1); + } + + /** + * Checks that {@link SelectedSquareActions#doMoveSquareBottom(boolean)} does + * work for multi-square game objects. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareBottomMulti() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(2, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point pointHead = new Point(0, 0); + final Point pointTail = new Point(1, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareHead = mapModel.getMapSquare(pointHead); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareTail = mapModel.getMapSquare(pointTail); + final TestGameObject ob1Head = testMapControlCreator.insertMob21(mapModel, pointHead); + final TestGameObject ob1Tail = ob1Head.getMultiNext(); + final TestGameObject ob2Head = testMapControlCreator.insertFloor(mapModel, pointHead); + final TestGameObject ob2Tail = testMapControlCreator.insertFloor(mapModel, pointTail); + + TestMapControlCreator.checkContents(mapSquareHead, ob1Head, ob2Head); + TestMapControlCreator.checkContents(mapSquareTail, ob1Tail, ob2Tail); + + // empty selection => nothing to move + Assert.assertFalse(selectedSquareActions.doMoveSquareBottom(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareBottom(true)); + + selectedSquareModel.setSelectedMapSquare(mapSquareHead, null, 0); + selectedSquareModel.setSelectedGameObject(ob2Head, 1); + + // [ob2, ob1] => ob2 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareBottom(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareBottom(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob2Head, ob1Head); + TestMapControlCreator.checkContents(mapSquareTail, ob1Tail, ob2Tail); + + // [ob1, ob2] => ob2 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareBottom(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareBottom(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob2Head, ob1Head); + TestMapControlCreator.checkContents(mapSquareTail, ob1Tail, ob2Tail); + + selectedSquareModel.setSelectedMapSquare(mapSquareTail, null, 0); + selectedSquareModel.setSelectedGameObject(ob2Tail, 1); + + // [ob2, ob1] => ob2 can move // XXX: this probably should be changed: moving tail parts is not sensible + Assert.assertTrue(selectedSquareActions.doMoveSquareBottom(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareBottom(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob2Head, ob1Head); + TestMapControlCreator.checkContents(mapSquareTail, ob2Tail, ob1Tail); + + // [ob1, ob2] => ob2 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareBottom(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareBottom(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob2Head, ob1Head); + TestMapControlCreator.checkContents(mapSquareTail, ob2Tail, ob1Tail); + } + + /** + * Checks that {@link SelectedSquareActions#doMoveSquareEnv(boolean)} does + * work for single-square game objects. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareEnvSingle1() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(1, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point point = new Point(0, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare = mapModel.getMapSquare(point); + final TestGameObject ob1 = testMapControlCreator.insertExit(mapModel, point); + + TestMapControlCreator.checkContents(mapSquare, ob1); + + // empty selection => nothing to move + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(true)); + + selectedSquareModel.setSelectedMapSquare(mapSquare, null, 0); + selectedSquareModel.setSelectedGameObject(ob1, 0); + + // [ob1] => ob1 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(true)); + TestMapControlCreator.checkContents(mapSquare, ob1); + } + + /** + * Checks that {@link SelectedSquareActions#doMoveSquareEnv(boolean)} does + * work for single-square game objects. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareEnvSingle2() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(1, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point point = new Point(0, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare = mapModel.getMapSquare(point); + final TestGameObject ob1 = testMapControlCreator.insertExit(mapModel, point); + final TestGameObject ob2 = testMapControlCreator.insertExit(mapModel, point); + final TestGameObject ob3 = testMapControlCreator.insertExit(mapModel, point); + final TestGameObject ob4 = testMapControlCreator.insertExit(ob2); + + TestMapControlCreator.checkContents(mapSquare, ob1, ob2, ob3); + TestMapControlCreator.checkContents(ob2, ob4); + + // empty selection => nothing to move + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(true)); + + selectedSquareModel.setSelectedMapSquare(mapSquare, null, 0); + selectedSquareModel.setSelectedGameObject(ob4, 0); + + // ob4 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareEnv(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareEnv(true)); + TestMapControlCreator.checkContents(mapSquare, ob1, ob4, ob2, ob3); + Assert.assertEquals(mapSquare, selectedSquareModel.getCurrentMapSquare()); + Assert.assertEquals(ob4, selectedSquareModel.getSelectedGameObject()); + + // ob4 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(true)); + TestMapControlCreator.checkContents(mapSquare, ob1, ob4, ob2, ob3); + Assert.assertEquals(mapSquare, selectedSquareModel.getCurrentMapSquare()); + Assert.assertEquals(ob4, selectedSquareModel.getSelectedGameObject()); + } + + /** + * Checks that {@link SelectedSquareActions#doMoveSquareEnv(boolean)} does + * work for single-square game objects. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareEnvSingle3() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(1, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point point = new Point(0, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare = mapModel.getMapSquare(point); + final TestGameObject ob1 = testMapControlCreator.insertExit(mapModel, point); + final TestGameObject ob2 = testMapControlCreator.insertExit(ob1); + final TestGameObject ob3 = testMapControlCreator.insertExit(ob2); + final TestGameObject ob4 = testMapControlCreator.insertExit(ob2); + final TestGameObject ob5 = testMapControlCreator.insertExit(ob2); + + TestMapControlCreator.checkContents(mapSquare, ob1); + TestMapControlCreator.checkContents(ob1, ob2); + TestMapControlCreator.checkContents(ob2, ob3, ob4, ob5); + + // empty selection => nothing to move + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(true)); + + selectedSquareModel.setSelectedMapSquare(mapSquare, null, 0); + selectedSquareModel.setSelectedGameObject(ob4, 0); + + // ob4 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareEnv(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareEnv(true)); + TestMapControlCreator.checkContents(mapSquare, ob1); + TestMapControlCreator.checkContents(ob1, ob4, ob2); + TestMapControlCreator.checkContents(ob2, ob3, ob5); + Assert.assertEquals(mapSquare, selectedSquareModel.getCurrentMapSquare()); + Assert.assertEquals(ob4, selectedSquareModel.getSelectedGameObject()); + + // ob4 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareEnv(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareEnv(true)); + TestMapControlCreator.checkContents(mapSquare, ob4, ob1); + TestMapControlCreator.checkContents(ob1, ob2); + TestMapControlCreator.checkContents(ob2, ob3, ob5); + Assert.assertEquals(mapSquare, selectedSquareModel.getCurrentMapSquare()); + Assert.assertEquals(ob4, selectedSquareModel.getSelectedGameObject()); + + // ob4 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(true)); + TestMapControlCreator.checkContents(mapSquare, ob4, ob1); + TestMapControlCreator.checkContents(ob1, ob2); + TestMapControlCreator.checkContents(ob2, ob3, ob5); + Assert.assertEquals(mapSquare, selectedSquareModel.getCurrentMapSquare()); + Assert.assertEquals(ob4, selectedSquareModel.getSelectedGameObject()); + } + + /** + * Checks that {@link SelectedSquareActions#doMoveSquareEnv(boolean)} does + * work for multi-square game objects. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareEnvMulti3() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(2, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point point = new Point(0, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareHead = mapModel.getMapSquare(point); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareTail = mapModel.getMapSquare(new Point(1, 0)); + final TestGameObject ob1 = testMapControlCreator.insertExit(mapModel, point); + final TestGameObject ob2 = testMapControlCreator.insertExit(ob1); + final TestGameObject ob3 = testMapControlCreator.insertExit(ob2); + final TestGameObject ob4Head = testMapControlCreator.insertMob21(ob2); + final TestGameObject ob5 = testMapControlCreator.insertExit(ob2); + + TestMapControlCreator.checkContents(mapSquareHead, ob1); + TestMapControlCreator.checkContents(ob1, ob2); + TestMapControlCreator.checkContents(ob2, ob3, ob4Head, ob5); + TestMapControlCreator.checkContents(mapSquareTail); + + // empty selection => nothing to move + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(true)); + + selectedSquareModel.setSelectedMapSquare(mapSquareHead, null, 0); + selectedSquareModel.setSelectedGameObject(ob4Head, 0); + + // ob4Head can move + Assert.assertTrue(selectedSquareActions.doMoveSquareEnv(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareEnv(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob1); + TestMapControlCreator.checkContents(ob1, ob4Head, ob2); + final TestGameObject ob4Tail1 = ob4Head.getMultiNext(); + Assert.assertNull(ob4Tail1); + TestMapControlCreator.checkContents(ob2, ob3, ob5); + TestMapControlCreator.checkContents(mapSquareTail); + Assert.assertEquals(mapSquareHead, selectedSquareModel.getCurrentMapSquare()); + Assert.assertEquals(ob4Head, selectedSquareModel.getSelectedGameObject()); + + // ob4Head can move + Assert.assertTrue(selectedSquareActions.doMoveSquareEnv(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareEnv(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob4Head, ob1); + TestMapControlCreator.checkContents(ob1, ob2); + TestMapControlCreator.checkContents(ob2, ob3, ob5); + final TestGameObject ob4Tail2 = ob4Head.getMultiNext(); + Assert.assertNotNull(ob4Tail2); + TestMapControlCreator.checkContents(mapSquareTail, ob4Tail2); + Assert.assertEquals(mapSquareHead, selectedSquareModel.getCurrentMapSquare()); + Assert.assertEquals(ob4Head, selectedSquareModel.getSelectedGameObject()); + + // ob4Head cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob4Head, ob1); + TestMapControlCreator.checkContents(ob1, ob2); + TestMapControlCreator.checkContents(ob2, ob3, ob5); + Assert.assertEquals(ob4Tail2, ob4Head.getMultiNext()); + TestMapControlCreator.checkContents(mapSquareTail, ob4Tail2); + Assert.assertEquals(mapSquareHead, selectedSquareModel.getCurrentMapSquare()); + Assert.assertEquals(ob4Head, selectedSquareModel.getSelectedGameObject()); + } + + /** + * Checks that {@link SelectedSquareActions#doMoveSquareEnv(boolean)} does + * work for multi-square game objects. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareEnvMulti4() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(1, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point point = new Point(0, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareHead = mapModel.getMapSquare(point); + final TestGameObject ob1 = testMapControlCreator.insertExit(mapModel, point); + final TestGameObject ob2Head = testMapControlCreator.insertMob21(ob1); + + TestMapControlCreator.checkContents(mapSquareHead, ob1); + TestMapControlCreator.checkContents(ob1, ob2Head); + + selectedSquareModel.setSelectedMapSquare(mapSquareHead, null, 0); + selectedSquareModel.setSelectedGameObject(ob2Head, 0); + + // ob2Head cannot move: would not fit into map + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob1); + TestMapControlCreator.checkContents(ob1, ob2Head); + Assert.assertNull(ob2Head.getMultiNext()); + } + + /** + * Checks that {@link SelectedSquareActions#doMoveSquareInv(boolean)} does + * work for single-square game objects. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareInvSingle1() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(1, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point point = new Point(0, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare = mapModel.getMapSquare(point); + final TestGameObject ob4 = testMapControlCreator.insertExit(mapModel, point); + final TestGameObject ob3 = testMapControlCreator.insertExit(mapModel, point); + final TestGameObject ob2 = testMapControlCreator.insertExit(mapModel, point); + final TestGameObject ob1 = testMapControlCreator.insertExit(mapModel, point); + + TestMapControlCreator.checkContents(mapSquare, ob4, ob3, ob2, ob1); + + // empty selection => nothing to move + Assert.assertFalse(selectedSquareActions.doMoveSquareInv(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareInv(true)); + + // select ob3 + selectedSquareModel.setSelectedMapSquare(mapSquare, null, 0); + selectedSquareModel.setSelectedGameObject(ob3, 0); + + // ob3 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareInv(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareInv(true)); + TestMapControlCreator.checkContents(mapSquare, ob4, ob2, ob1); + TestMapControlCreator.checkContents(ob2, ob3); + Assert.assertEquals(mapSquare, selectedSquareModel.getCurrentMapSquare()); + Assert.assertEquals(ob3, selectedSquareModel.getSelectedGameObject()); + + // ob3 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareInv(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareInv(true)); + TestMapControlCreator.checkContents(mapSquare, ob4, ob2, ob1); + TestMapControlCreator.checkContents(ob2, ob3); + Assert.assertEquals(mapSquare, selectedSquareModel.getCurrentMapSquare()); + Assert.assertEquals(ob3, selectedSquareModel.getSelectedGameObject()); + + // select ob2 + selectedSquareModel.setSelectedGameObject(ob2, 0); + + // ob2 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareInv(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareInv(true)); + TestMapControlCreator.checkContents(mapSquare, ob4, ob1); + TestMapControlCreator.checkContents(ob1, ob2); + TestMapControlCreator.checkContents(ob2, ob3); + Assert.assertEquals(mapSquare, selectedSquareModel.getCurrentMapSquare()); + Assert.assertEquals(ob2, selectedSquareModel.getSelectedGameObject()); + + // ob2 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareInv(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareInv(true)); + TestMapControlCreator.checkContents(mapSquare, ob4, ob1); + TestMapControlCreator.checkContents(ob1, ob2); + TestMapControlCreator.checkContents(ob2, ob3); + Assert.assertEquals(mapSquare, selectedSquareModel.getCurrentMapSquare()); + Assert.assertEquals(ob2, selectedSquareModel.getSelectedGameObject()); + + // select ob4 + selectedSquareModel.setSelectedGameObject(ob4, 0); + + // ob4 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareInv(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareInv(true)); + TestMapControlCreator.checkContents(mapSquare, ob1); + TestMapControlCreator.checkContents(ob1, ob4, ob2); + TestMapControlCreator.checkContents(ob2, ob3); + Assert.assertEquals(mapSquare, selectedSquareModel.getCurrentMapSquare()); + Assert.assertEquals(ob4, selectedSquareModel.getSelectedGameObject()); + + // ob4 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareInv(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareInv(true)); + TestMapControlCreator.checkContents(mapSquare, ob1); + TestMapControlCreator.checkContents(ob1, ob2); + TestMapControlCreator.checkContents(ob2, ob4, ob3); + Assert.assertEquals(mapSquare, selectedSquareModel.getCurrentMapSquare()); + Assert.assertEquals(ob4, selectedSquareModel.getSelectedGameObject()); + + // ob4 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareInv(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareInv(true)); + TestMapControlCreator.checkContents(mapSquare, ob1); + TestMapControlCreator.checkCont... [truncated message content] |
From: <aki...@us...> - 2010-06-03 10:30:27
|
Revision: 8063 http://gridarta.svn.sourceforge.net/gridarta/?rev=8063&view=rev Author: akirschbaum Date: 2010-06-03 10:30:20 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Extract TestMapControlCreator from ExitConnectorActionsTest. Modified Paths: -------------- trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java Added Paths: ----------- trunk/src/test/net/sf/gridarta/gui/map/test/ trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java Modified: trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java 2010-06-03 09:18:31 UTC (rev 8062) +++ trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java 2010-06-03 10:30:20 UTC (rev 8063) @@ -21,55 +21,19 @@ import java.awt.Point; import java.io.File; -import java.util.regex.Pattern; -import net.sf.gridarta.mapmanager.AbstractMapManager; -import net.sf.gridarta.mapmanager.DefaultMapManager; -import net.sf.gridarta.mapmanager.MapManager; +import net.sf.gridarta.gui.map.test.TestMapControlCreator; import net.sf.gridarta.mapmanager.TestFileControl; -import net.sf.gridarta.model.anim.AnimationObjects; -import net.sf.gridarta.model.anim.DefaultAnimationObjects; -import net.sf.gridarta.model.archetype.ArchetypeFactory; -import net.sf.gridarta.model.archetype.ArchetypeSet; import net.sf.gridarta.model.archetype.DuplicateArchetypeException; import net.sf.gridarta.model.archetype.TestArchetype; -import net.sf.gridarta.model.archetype.TestArchetypeFactory; -import net.sf.gridarta.model.archetype.TestArchetypeSet; -import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModel; -import net.sf.gridarta.model.autojoin.AutojoinLists; import net.sf.gridarta.model.baseobject.BaseObject; import net.sf.gridarta.model.exitconnector.ExitConnectorModel; import net.sf.gridarta.model.exitconnector.ExitLocation; -import net.sf.gridarta.model.exitconnector.ExitMatcher; -import net.sf.gridarta.model.face.ArchFaceProvider; -import net.sf.gridarta.model.face.DefaultFaceObjects; -import net.sf.gridarta.model.face.FaceObjectProviders; -import net.sf.gridarta.model.face.FaceObjects; -import net.sf.gridarta.model.gameobject.GameObjectFactory; import net.sf.gridarta.model.gameobject.TestGameObject; -import net.sf.gridarta.model.gameobject.TestGameObjectFactory; -import net.sf.gridarta.model.io.MapReaderFactory; -import net.sf.gridarta.model.io.MapWriter; -import net.sf.gridarta.model.io.PathManager; -import net.sf.gridarta.model.io.TestMapReaderFactory; -import net.sf.gridarta.model.io.TestMapWriter; import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; import net.sf.gridarta.model.map.mapcontrol.MapControl; -import net.sf.gridarta.model.map.mapcontrol.MapControlFactory; -import net.sf.gridarta.model.map.mapcontrol.TestMapControlFactory; -import net.sf.gridarta.model.map.mapmodel.InsertionMode; -import net.sf.gridarta.model.map.mapmodel.InsertionModeSet; import net.sf.gridarta.model.map.mapmodel.MapModel; -import net.sf.gridarta.model.map.mapmodel.TopmostInsertionMode; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; -import net.sf.gridarta.model.match.GameObjectMatcher; -import net.sf.gridarta.model.match.GameObjectMatchers; -import net.sf.gridarta.model.match.TypeNrsGameObjectMatcher; -import net.sf.gridarta.model.settings.GlobalSettings; -import net.sf.gridarta.model.settings.TestGlobalSettings; import net.sf.gridarta.preferences.FilePreferencesFactory; -import net.sf.gridarta.utils.GUIUtils; import net.sf.gridarta.utils.Size2D; -import net.sf.gridarta.utils.SystemIcons; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.junit.Assert; @@ -84,16 +48,6 @@ public class ExitConnectorActionsTest { /** - * The archetype type used for "exit" game objects. - */ - private static final int EXIT_TYPE = 1; - - /** - * The archetype type used for "floor" game objects. - */ - private static final int FLOOR_TYPE = 2; - - /** * The first map file. */ private static final File MAP_FILE1 = new File("a"); @@ -114,57 +68,12 @@ private static final String MAP_NAME2 = "name2"; /** - * The {@link SystemIcons} instance. + * The {@link TestMapControlCreator} for creating maps. */ @Nullable - private SystemIcons systemIcons = null; + private TestMapControlCreator testMapControlCreator = null; /** - * The {@link MapManager} instance. - */ - private MapManager<TestGameObject, TestMapArchObject, TestArchetype> mapManager = null; - - /** - * The {@link PathManager} instance. - */ - private PathManager pathManager = null; - - /** - * The {@link ExitMatcher} instance. - */ - private ExitMatcher<TestGameObject, TestMapArchObject, TestArchetype> exitMatcher; - - /** - * The {@link ArchetypeSet} instance. - */ - private ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeSet; - - /** - * The archetype to create floor game objects. - */ - private TestArchetype floorArchetype; - - /** - * The archetype to create exit game objects. - */ - private TestArchetype exitArchetype; - - /** - * The {@link GlobalSettings} instance. - */ - private GlobalSettings globalSettings; - - /** - * The "topmost" {@link InsertionMode} instance. - */ - private InsertionMode<TestGameObject, TestMapArchObject, TestArchetype> topmostInsertionMode; - - /** - * The {@link InsertionModeSet} instance. - */ - private InsertionModeSet<TestGameObject, TestMapArchObject, TestArchetype> insertionModeSet; - - /** * Checks that {@link ExitConnectorActions#doExitCopy(boolean, MapControl, * Point)} does work. */ @@ -172,7 +81,9 @@ public void testExitCopy1() { final ExitConnectorModel model = new ExitConnectorModel(); final ExitConnectorActions<TestGameObject, TestMapArchObject, TestArchetype> actions = createActions(model); - final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(5, 5)); + final Size2D mapSize = new Size2D(5, 5); + assert testMapControlCreator != null; + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, mapSize); // active ==> enabled final Point point1 = new Point(3, 4); @@ -181,12 +92,14 @@ // perform copy Assert.assertTrue(actions.doExitCopy(true, mapControl, point1)); - Assert.assertEquals(new ExitLocation(MAP_FILE1, point1, MAP_NAME1, pathManager), model.getExitLocation()); + assert testMapControlCreator != null; + Assert.assertEquals(new ExitLocation(MAP_FILE1, point1, MAP_NAME1, testMapControlCreator.getPathManager()), model.getExitLocation()); // unsaved map ==> disabled mapControl.getMapModel().setMapFile(null); Assert.assertFalse(actions.doExitCopy(false, mapControl, point1)); - Assert.assertEquals(new ExitLocation(MAP_FILE1, point1, MAP_NAME1, pathManager), model.getExitLocation()); // disabled -> unchanged model + assert testMapControlCreator != null; + Assert.assertEquals(new ExitLocation(MAP_FILE1, point1, MAP_NAME1, testMapControlCreator.getPathManager()), model.getExitLocation()); // disabled -> unchanged model } /** @@ -197,23 +110,28 @@ public void testExitPaste1() { final ExitConnectorModel model = new ExitConnectorModel(); final ExitConnectorActions<TestGameObject, TestMapArchObject, TestArchetype> actions = createActions(model); - final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(5, 5)); + final Size2D mapSize = new Size2D(5, 5); + assert testMapControlCreator != null; + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, mapSize); final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); final Point point1 = new Point(3, 4); final Point point2 = new Point(1, 2); - model.setExitLocation(new ExitLocation(MAP_FILE2, point2, MAP_NAME2, pathManager)); + assert testMapControlCreator != null; + model.setExitLocation(new ExitLocation(MAP_FILE2, point2, MAP_NAME2, testMapControlCreator.getPathManager())); // no exit at cursor and no auto-create ==> disabled Assert.assertFalse(actions.doExitPaste(false, mapControl, point1)); - insertFloor(mapModel, point1); + assert testMapControlCreator != null; + testMapControlCreator.insertFloor(mapModel, point1); // no exit at cursor and no auto-create ==> disabled Assert.assertFalse(actions.doExitPaste(false, mapControl, point1)); - insertExit(mapModel, point1); + assert testMapControlCreator != null; + testMapControlCreator.insertExit(mapModel, point1); // exit at cursor ==> enabled Assert.assertTrue(actions.doExitPaste(false, mapControl, point1)); @@ -233,31 +151,38 @@ final ExitConnectorModel model = new ExitConnectorModel(); final ExitConnectorActions<TestGameObject, TestMapArchObject, TestArchetype> actions = createActions(model); - final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl1 = newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(5, 5)); + final Size2D mapSize = new Size2D(5, 5); + assert testMapControlCreator != null; + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl1 = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, mapSize); final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel1 = mapControl1.getMapModel(); - final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl2 = newMapControl(MAP_FILE2, MAP_NAME2, new Size2D(5, 5)); + assert testMapControlCreator != null; + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl2 = testMapControlCreator.newMapControl(MAP_FILE2, MAP_NAME2, mapSize); final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel2 = mapControl2.getMapModel(); final Point point1 = new Point(3, 4); final Point point2 = new Point(1, 2); - model.setExitLocation(new ExitLocation(MAP_FILE2, point2, MAP_NAME2, pathManager)); + assert testMapControlCreator != null; + model.setExitLocation(new ExitLocation(MAP_FILE2, point2, MAP_NAME2, testMapControlCreator.getPathManager())); // no exit at cursor and no auto-create ==> disabled Assert.assertFalse(actions.doExitConnect(false, mapControl1, point1)); - insertFloor(mapModel1, point1); + assert testMapControlCreator != null; + testMapControlCreator.insertFloor(mapModel1, point1); // no exit at cursor and no auto-create ==> disabled Assert.assertFalse(actions.doExitConnect(false, mapControl1, point1)); - insertExit(mapModel1, point1); + assert testMapControlCreator != null; + testMapControlCreator.insertExit(mapModel1, point1); // no exit at source and no auto-create ==> disabled Assert.assertFalse(actions.doExitConnect(false, mapControl1, point1)); - insertExit(mapModel2, point2); + assert testMapControlCreator != null; + testMapControlCreator.insertExit(mapModel2, point2); // exit at source and cursor ==> enabled Assert.assertTrue(actions.doExitConnect(false, mapControl1, point1)); @@ -279,16 +204,20 @@ final ExitConnectorModel model = new ExitConnectorModel(); final ExitConnectorActions<TestGameObject, TestMapArchObject, TestArchetype> actions = createActions(model); - final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl1 = newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(5, 5)); + final Size2D mapSize = new Size2D(5, 5); + assert testMapControlCreator != null; + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl1 = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, mapSize); final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel1 = mapControl1.getMapModel(); - final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl2 = newMapControl(MAP_FILE2, MAP_NAME2, new Size2D(5, 5)); + assert testMapControlCreator != null; + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl2 = testMapControlCreator.newMapControl(MAP_FILE2, MAP_NAME2, mapSize); final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel2 = mapControl2.getMapModel(); final Point point1 = new Point(3, 4); final Point point2 = new Point(1, 2); - model.setExitLocation(new ExitLocation(MAP_FILE2, point2, MAP_NAME2, pathManager)); + assert testMapControlCreator != null; + model.setExitLocation(new ExitLocation(MAP_FILE2, point2, MAP_NAME2, testMapControlCreator.getPathManager())); model.setAutoCreateExit(true); // fails due to undefined archetype @@ -346,18 +275,23 @@ final ExitConnectorModel model = new ExitConnectorModel(); final ExitConnectorActions<TestGameObject, TestMapArchObject, TestArchetype> actions = createActions(model); - final File mapDir = globalSettings.getMapsDirectory(); + assert testMapControlCreator != null; + final File mapDir = testMapControlCreator.getGlobalSettings().getMapsDirectory(); final File mapFileFrom = new File(mapDir, mapPathFrom); final File mapFileTo = new File(mapDir, mapPathTo); - final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = newMapControl(mapFileFrom, MAP_NAME1, new Size2D(5, 5)); + final Size2D mapSize = new Size2D(5, 5); + assert testMapControlCreator != null; + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(mapFileFrom, MAP_NAME1, mapSize); final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); final Point pointFrom = new Point(3, 4); final Point pointTo = new Point(1, 2); - model.setExitLocation(new ExitLocation(mapFileTo, pointTo, MAP_NAME2, pathManager)); - insertExit(mapModel, pointFrom); + assert testMapControlCreator != null; + model.setExitLocation(new ExitLocation(mapFileTo, pointTo, MAP_NAME2, testMapControlCreator.getPathManager())); + assert testMapControlCreator != null; + testMapControlCreator.insertExit(mapModel, pointFrom); // perform connect Assert.assertTrue(actions.doExitPaste(true, mapControl, pointFrom)); @@ -379,38 +313,7 @@ */ @Before public void setUp() throws DuplicateArchetypeException { - final GUIUtils guiUtils = new GUIUtils(); - systemIcons = new SystemIcons(guiUtils); - final AnimationObjects animationObjects = new DefaultAnimationObjects("anim"); - final GameObjectMatcher exitGameObjectMatcher = new TypeNrsGameObjectMatcher(EXIT_TYPE); - exitMatcher = new ExitMatcher<TestGameObject, TestMapArchObject, TestArchetype>(exitGameObjectMatcher); - final ArchetypeFactory<TestGameObject, TestMapArchObject, TestArchetype> archetypeFactory = new TestArchetypeFactory(); - archetypeSet = new TestArchetypeSet(archetypeFactory, "archetypes"); - final MapReaderFactory<TestGameObject, TestMapArchObject> mapReaderFactory = new TestMapReaderFactory(); - globalSettings = new TestGlobalSettings(); - final MapViewSettings mapViewSettings = new MapViewSettings(); - final MapWriter<TestGameObject, TestMapArchObject, TestArchetype> mapWriter = new TestMapWriter(); - final FaceObjectProviders faceObjectProviders = newFaceObjectProviders(); - final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists = new AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype>(mapViewSettings); - final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype> archetypeChooserModel = new ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype>(); - pathManager = new PathManager(globalSettings); - final GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectFactory = new TestGameObjectFactory(faceObjectProviders, animationObjects); - final GameObjectMatchers gameObjectMatchers = new GameObjectMatchers(); - topmostInsertionMode = new TopmostInsertionMode<TestGameObject, TestMapArchObject, TestArchetype>(); - insertionModeSet = new InsertionModeSet<TestGameObject, TestMapArchObject, TestArchetype>(topmostInsertionMode); - insertionModeSet.init(new TypeNrsGameObjectMatcher(), new TypeNrsGameObjectMatcher(), new TypeNrsGameObjectMatcher()); - final MapControlFactory<TestGameObject, TestMapArchObject, TestArchetype> mapControlFactory = new TestMapControlFactory(mapWriter, autojoinLists, archetypeChooserModel, gameObjectFactory, globalSettings, gameObjectMatchers, topmostInsertionMode); - final AbstractMapManager<TestGameObject, TestMapArchObject, TestArchetype> tmpMapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype>(mapReaderFactory, mapControlFactory, globalSettings); - tmpMapManager.setFileControl(new TestFileControl()); - mapManager = tmpMapManager; - - floorArchetype = new TestArchetype("floor", faceObjectProviders, animationObjects); - floorArchetype.setAttributeString(BaseObject.TYPE, Integer.toString(FLOOR_TYPE)); - archetypeSet.addArchetype(floorArchetype); - - exitArchetype = new TestArchetype("exit", faceObjectProviders, animationObjects); - exitArchetype.setAttributeString(BaseObject.TYPE, Integer.toString(EXIT_TYPE)); - archetypeSet.addArchetype(exitArchetype); + testMapControlCreator = new TestMapControlCreator(); } /** @@ -419,58 +322,12 @@ * @return the new exit connector actions instance */ private ExitConnectorActions<TestGameObject, TestMapArchObject, TestArchetype> createActions(@NotNull final ExitConnectorModel model) { - return new ExitConnectorActions<TestGameObject, TestMapArchObject, TestArchetype>(model, exitMatcher, archetypeSet, mapManager, new TestFileControl(), pathManager, insertionModeSet); + final TestMapControlCreator tmpTestMapControlCreator = testMapControlCreator; + assert tmpTestMapControlCreator != null; + return new ExitConnectorActions<TestGameObject, TestMapArchObject, TestArchetype>(model, tmpTestMapControlCreator.getExitMatcher(), tmpTestMapControlCreator.getArchetypeSet(), tmpTestMapControlCreator.getMapManager(), new TestFileControl(), tmpTestMapControlCreator.getPathManager(), tmpTestMapControlCreator.getInsertionModeSet()); } /** - * Creates a new map control. - * @param mapFile the map file - * @param mapName the map name - * @param mapSize the map size - * @return the map control - */ - private MapControl<TestGameObject, TestMapArchObject, TestArchetype> newMapControl(@Nullable final File mapFile, @NotNull final String mapName, @NotNull final Size2D mapSize) { - final TestMapArchObject mapArchObject = new TestMapArchObject(); - mapArchObject.setMapSize(mapSize); - mapArchObject.setMapName(mapName); - final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = mapManager.newMap(null, mapArchObject, mapFile, true); - return mapControl; - } - - /** - * Inserts a {@link #floorArchetype} game object into a map model. - * @param mapModel the map model to insert into - * @param point the position to insert at - */ - private void insertFloor(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, @NotNull final Point point) { - insertArchetype(mapModel, point, floorArchetype); - } - - /** - * Inserts a {@link #exitArchetype} game object into a map model. - * @param mapModel the map model to insert into - * @param point the position to insert at - */ - private void insertExit(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, @NotNull final Point point) { - insertArchetype(mapModel, point, exitArchetype); - } - - /** - * Inserts an archetype game object into a map model. - * @param mapModel the map model to insert into - * @param point the position to insert at - * @param archetype the archetype to insert - */ - private void insertArchetype(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, @NotNull final Point point, @NotNull final BaseObject<TestGameObject, TestMapArchObject, TestArchetype, ?> archetype) { - mapModel.beginTransaction("test"); - try { - mapModel.insertBaseObject(archetype, point, true, false, topmostInsertionMode); - } finally { - mapModel.endTransaction(); - } - } - - /** * Checks that a map model contains an exit game object. * @param mapModel the map model to check * @param point the position to check @@ -484,7 +341,7 @@ int thisIndex = 0; for (final BaseObject<?, ?, ?, ?> gameObject : mapModel.getMapSquare(point)) { if (thisIndex == index) { - if (gameObject.getTypeNo() != EXIT_TYPE) { + if (gameObject.getTypeNo() != TestMapControlCreator.EXIT_TYPE) { break; } @@ -507,16 +364,4 @@ } } - /** - * Creates a new {@link FaceObjectProviders} instance. - * @return the face object providers instance - */ - private FaceObjectProviders newFaceObjectProviders() { - final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); - final FaceObjects faceObjects = new DefaultFaceObjects("test", "bmaps.paths", Pattern.compile("^.*\t\\.?(.*)"), "\\%1$05d\t./arch%2$s", archFaceProvider); - assert systemIcons != null; - final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); - return faceObjectProviders; - } - } // class ExitConnectorActionsTest Added: trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java (rev 0) +++ trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java 2010-06-03 10:30:20 UTC (rev 8063) @@ -0,0 +1,398 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.map.test; + +import java.awt.Point; +import java.io.File; +import java.util.regex.Pattern; +import net.sf.gridarta.mapmanager.AbstractMapManager; +import net.sf.gridarta.mapmanager.DefaultMapManager; +import net.sf.gridarta.mapmanager.MapManager; +import net.sf.gridarta.mapmanager.TestFileControl; +import net.sf.gridarta.model.anim.AnimationObjects; +import net.sf.gridarta.model.anim.DefaultAnimationObjects; +import net.sf.gridarta.model.archetype.ArchetypeFactory; +import net.sf.gridarta.model.archetype.ArchetypeSet; +import net.sf.gridarta.model.archetype.DuplicateArchetypeException; +import net.sf.gridarta.model.archetype.TestArchetype; +import net.sf.gridarta.model.archetype.TestArchetypeFactory; +import net.sf.gridarta.model.archetype.TestArchetypeSet; +import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModel; +import net.sf.gridarta.model.autojoin.AutojoinLists; +import net.sf.gridarta.model.baseobject.BaseObject; +import net.sf.gridarta.model.baseobject.GameObjectContainer; +import net.sf.gridarta.model.exitconnector.ExitMatcher; +import net.sf.gridarta.model.face.ArchFaceProvider; +import net.sf.gridarta.model.face.DefaultFaceObjects; +import net.sf.gridarta.model.face.FaceObjectProviders; +import net.sf.gridarta.model.face.FaceObjects; +import net.sf.gridarta.model.gameobject.GameObjectFactory; +import net.sf.gridarta.model.gameobject.TestGameObject; +import net.sf.gridarta.model.gameobject.TestGameObjectFactory; +import net.sf.gridarta.model.io.MapReaderFactory; +import net.sf.gridarta.model.io.MapWriter; +import net.sf.gridarta.model.io.PathManager; +import net.sf.gridarta.model.io.TestMapReaderFactory; +import net.sf.gridarta.model.io.TestMapWriter; +import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; +import net.sf.gridarta.model.map.mapcontrol.MapControl; +import net.sf.gridarta.model.map.mapcontrol.MapControlFactory; +import net.sf.gridarta.model.map.mapcontrol.TestMapControlFactory; +import net.sf.gridarta.model.map.mapmodel.InsertionMode; +import net.sf.gridarta.model.map.mapmodel.InsertionModeSet; +import net.sf.gridarta.model.map.mapmodel.MapModel; +import net.sf.gridarta.model.map.mapmodel.MapSquare; +import net.sf.gridarta.model.map.mapmodel.TopmostInsertionMode; +import net.sf.gridarta.model.mapviewsettings.MapViewSettings; +import net.sf.gridarta.model.match.GameObjectMatcher; +import net.sf.gridarta.model.match.GameObjectMatchers; +import net.sf.gridarta.model.match.TypeNrsGameObjectMatcher; +import net.sf.gridarta.model.settings.GlobalSettings; +import net.sf.gridarta.model.settings.TestGlobalSettings; +import net.sf.gridarta.utils.GUIUtils; +import net.sf.gridarta.utils.Size2D; +import net.sf.gridarta.utils.SystemIcons; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.junit.Assert; + +/** + * Helper class for creating {@link MapControl} instances for regression tests. + * @author Andreas Kirschbaum + */ +public class TestMapControlCreator { + + /** + * The archetype type used for "exit" game objects. + */ + public static final int EXIT_TYPE = 1; + + /** + * The archetype type used for "floor" game objects. + */ + private static final int FLOOR_TYPE = 2; + + /** + * The archetype type used for "mob" game objects. + */ + private static final int MOB_TYPE = 3; + + /** + * The {@link SystemIcons} instance. + */ + @NotNull + private final SystemIcons systemIcons; + + /** + * The {@link MapManager} instance. + */ + @NotNull + private final MapManager<TestGameObject, TestMapArchObject, TestArchetype> mapManager; + + /** + * The {@link GameObjectFactory} instance. + */ + @NotNull + private final GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectFactory; + + /** + * The {@link PathManager} instance. + */ + @NotNull + private final PathManager pathManager; + + /** + * The {@link ExitMatcher} instance. + */ + @NotNull + private final ExitMatcher<TestGameObject, TestMapArchObject, TestArchetype> exitMatcher; + + /** + * The {@link ArchetypeSet} instance. + */ + @NotNull + private final ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeSet; + + /** + * The archetype to create floor game objects. + */ + @NotNull + private final TestArchetype floorArchetype; + + /** + * The archetype to create exit game objects. + */ + @NotNull + private final TestArchetype exitArchetype; + + /** + * The archetype to create 2x1 mob game objects. + */ + @NotNull + private final TestArchetype mob21Archetype; + + /** + * The {@link GlobalSettings} instance. + */ + @NotNull + private final GlobalSettings globalSettings; + + /** + * The "topmost" {@link InsertionMode} instance. + */ + @NotNull + private final InsertionMode<TestGameObject, TestMapArchObject, TestArchetype> topmostInsertionMode; + + /** + * The {@link InsertionModeSet} instance. + */ + @NotNull + private final InsertionModeSet<TestGameObject, TestMapArchObject, TestArchetype> insertionModeSet; + + /** + * Creates a new instance. + * @throws DuplicateArchetypeException if an internal error occurs + */ + public TestMapControlCreator() throws DuplicateArchetypeException { + final GUIUtils guiUtils = new GUIUtils(); + systemIcons = new SystemIcons(guiUtils); + final AnimationObjects animationObjects = new DefaultAnimationObjects("anim"); + final GameObjectMatcher exitGameObjectMatcher = new TypeNrsGameObjectMatcher(EXIT_TYPE); + exitMatcher = new ExitMatcher<TestGameObject, TestMapArchObject, TestArchetype>(exitGameObjectMatcher); + final ArchetypeFactory<TestGameObject, TestMapArchObject, TestArchetype> archetypeFactory = new TestArchetypeFactory(); + archetypeSet = new TestArchetypeSet(archetypeFactory, "archetypes"); + final MapReaderFactory<TestGameObject, TestMapArchObject> mapReaderFactory = new TestMapReaderFactory(); + globalSettings = new TestGlobalSettings(); + final MapViewSettings mapViewSettings = new MapViewSettings(); + final MapWriter<TestGameObject, TestMapArchObject, TestArchetype> mapWriter = new TestMapWriter(); + final FaceObjectProviders faceObjectProviders = newFaceObjectProviders(); + final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists = new AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype>(mapViewSettings); + final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype> archetypeChooserModel = new ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype>(); + pathManager = new PathManager(globalSettings); + gameObjectFactory = new TestGameObjectFactory(faceObjectProviders, animationObjects); + final GameObjectMatchers gameObjectMatchers = new GameObjectMatchers(); + topmostInsertionMode = new TopmostInsertionMode<TestGameObject, TestMapArchObject, TestArchetype>(); + insertionModeSet = new InsertionModeSet<TestGameObject, TestMapArchObject, TestArchetype>(topmostInsertionMode); + insertionModeSet.init(new TypeNrsGameObjectMatcher(), new TypeNrsGameObjectMatcher(), new TypeNrsGameObjectMatcher()); + final MapControlFactory<TestGameObject, TestMapArchObject, TestArchetype> mapControlFactory = new TestMapControlFactory(mapWriter, autojoinLists, archetypeChooserModel, gameObjectFactory, globalSettings, gameObjectMatchers, topmostInsertionMode); + final AbstractMapManager<TestGameObject, TestMapArchObject, TestArchetype> tmpMapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype>(mapReaderFactory, mapControlFactory, globalSettings); + tmpMapManager.setFileControl(new TestFileControl()); + mapManager = tmpMapManager; + + floorArchetype = new TestArchetype("floor", faceObjectProviders, animationObjects); + floorArchetype.setAttributeString(BaseObject.TYPE, Integer.toString(FLOOR_TYPE)); + archetypeSet.addArchetype(floorArchetype); + + exitArchetype = new TestArchetype("exit", faceObjectProviders, animationObjects); + exitArchetype.setAttributeString(BaseObject.TYPE, Integer.toString(EXIT_TYPE)); + archetypeSet.addArchetype(exitArchetype); + + mob21Archetype = new TestArchetype("mob21", faceObjectProviders, animationObjects); + mob21Archetype.setAttributeString(BaseObject.TYPE, Integer.toString(MOB_TYPE)); + archetypeSet.addArchetype(mob21Archetype); + final TestArchetype mob21bArchetype = new TestArchetype("mob21b", faceObjectProviders, animationObjects); + mob21bArchetype.setMultiX(1); + mob21Archetype.addTailPart(mob21bArchetype); + archetypeSet.addArchetype(mob21bArchetype); + } + + /** + * Creates a new map control. + * @param mapFile the map file + * @param mapName the map name + * @param mapSize the map size + * @return the map control + */ + public MapControl<TestGameObject, TestMapArchObject, TestArchetype> newMapControl(@Nullable final File mapFile, @NotNull final String mapName, @NotNull final Size2D mapSize) { + final TestMapArchObject mapArchObject = new TestMapArchObject(); + mapArchObject.setMapSize(mapSize); + mapArchObject.setMapName(mapName); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = mapManager.newMap(null, mapArchObject, mapFile, true); + return mapControl; + } + + /** + * Inserts a {@link #floorArchetype} game object into a map model. + * @param mapModel the map model to insert into + * @param point the position to insert at + * @return the inserted game object + */ + @NotNull + public TestGameObject insertFloor(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, @NotNull final Point point) { + return insertArchetype(mapModel, point, floorArchetype); + } + + /** + * Inserts an {@link #exitArchetype} game object into a map model. + * @param mapModel the map model to insert into + * @param point the position to insert at + * @return the inserted game object + */ + @NotNull + public TestGameObject insertExit(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, @NotNull final Point point) { + return insertArchetype(mapModel, point, exitArchetype); + } + + /** + * Inserts a {@link #mob21Archetype} game object into a map model. + * @param mapModel the map model to insert into + * @param point the position to insert at + * @return the inserted game object + */ + @NotNull + public TestGameObject insertMob21(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, @NotNull final Point point) { + return insertArchetype(mapModel, point, mob21Archetype); + } + + /** + * Inserts an archetype game object into a map model. + * @param mapModel the map model to insert into + * @param point the position to insert at + * @param archetype the archetype to insert + * @return the inserted game object + */ + @NotNull + private TestGameObject insertArchetype(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, @NotNull final Point point, @NotNull final BaseObject<TestGameObject, TestMapArchObject, TestArchetype, ?> archetype) { + final TestGameObject gameObject = mapModel.insertBaseObject(archetype, point, true, false, topmostInsertionMode); + if (gameObject == null) { + throw new AssertionError(); + } + return gameObject; + } + + /** + * Inserts an {@link #exitArchetype} game object into a game object. + * @param gameObject the game object + * @return the inserted game object + */ + @NotNull + public TestGameObject insertExit(@NotNull final GameObjectContainer<TestGameObject, TestMapArchObject, TestArchetype> gameObject) { + return insertArchetype(gameObject, exitArchetype); + } + + /** + * Inserts a {@link #mob21Archetype} game object into a game object. + * @param gameObject the game object + * @return the inserted game object + */ + @NotNull + public TestGameObject insertMob21(@NotNull final GameObjectContainer<TestGameObject, TestMapArchObject, TestArchetype> gameObject) { + return insertArchetype(gameObject, mob21Archetype); + } + + /** + * Inserts an archetype into a game object. + * @param gameObject the game object + * @param archetype the archetype to insert + * @return the inserted game object + */ + @NotNull + public TestGameObject insertArchetype(@NotNull final GameObjectContainer<TestGameObject, TestMapArchObject, TestArchetype> gameObject, @NotNull final BaseObject<TestGameObject, TestMapArchObject, TestArchetype, ?> archetype) { + final TestGameObject newGameObject = archetype.newInstance(gameObjectFactory); + gameObject.addLast(newGameObject); + return newGameObject; + } + + /** + * Creates a new {@link FaceObjectProviders} instance. + * @return the face object providers instance + */ + private FaceObjectProviders newFaceObjectProviders() { + final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); + final FaceObjects faceObjects = new DefaultFaceObjects("test", "bmaps.paths", Pattern.compile("^.*\t\\.?(.*)"), "\\%1$05d\t./arch%2$s", archFaceProvider); + final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); + return faceObjectProviders; + } + + /** + * Returns the {@link PathManager}. + * @return the path manager + */ + @NotNull + public PathManager getPathManager() { + return pathManager; + } + + /** + * Returns the {@link GlobalSettings}. + * @return the global settings + */ + @NotNull + public GlobalSettings getGlobalSettings() { + return globalSettings; + } + + /** + * Returns the {@link ExitMatcher}. + * @return the exit matcher + */ + @NotNull + public ExitMatcher<TestGameObject, TestMapArchObject, TestArchetype> getExitMatcher() { + return exitMatcher; + } + + /** + * Returns the {@link ArchetypeSet}. + * @return the archetype set + */ + @NotNull + public ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> getArchetypeSet() { + return archetypeSet; + } + + /** + * Returns the {@link MapManager}. + * @return the map manager + */ + @NotNull + public MapManager<TestGameObject, TestMapArchObject, TestArchetype> getMapManager() { + return mapManager; + } + + /** + * Returns the {@link InsertionModeSet}. + * @return the insertion mode set + */ + @NotNull + public InsertionModeSet<TestGameObject, TestMapArchObject, TestArchetype> getInsertionModeSet() { + return insertionModeSet; + } + + /** + * Checks that a {@link MapSquare} contains the given game objects. + * @param mapSquare the map square + * @param gameObjects the game object + */ + public static void checkContents(@NotNull final Iterable<TestGameObject> mapSquare, @NotNull final TestGameObject... gameObjects) { + int i = 0; + for (final TestGameObject gameObject : mapSquare) { + if (i >= gameObjects.length) { + Assert.fail("map square contains excess game object '" + gameObject.getBestName() + "'"); + } else if (gameObject != gameObjects[i]) { + Assert.fail("map square contains wrong game object '" + gameObject.getBestName() + "' at index " + i + ", expected '" + gameObjects[i].getBestName() + "'"); + } + i++; + } + if (i < gameObjects.length) { + Assert.fail("map square is missing game object '" + gameObjects[i].getBestName() + "'"); + } + } + +} // class TestMapControlCreator Property changes on: trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-03 09:18:37
|
Revision: 8062 http://gridarta.svn.sourceforge.net/gridarta/?rev=8062&view=rev Author: akirschbaum Date: 2010-06-03 09:18:31 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Add @Nullable annotation. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareModel.java Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareModel.java 2010-06-02 07:35:58 UTC (rev 8061) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareModel.java 2010-06-03 09:18:31 UTC (rev 8062) @@ -200,7 +200,7 @@ return selectedMapSquare != null && selectedMapSquare.setSelectedGameObject(gameObject); } - public void setSelectedGameObject(final G gameObject, final int actualIndex) { + public void setSelectedGameObject(@Nullable final G gameObject, final int actualIndex) { if (selectedMapSquare != null) { selectedMapSquare.setGameObject(gameObject, actualIndex); setSelectedGameObject(gameObject); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-02 07:36:05
|
Revision: 8061 http://gridarta.svn.sourceforge.net/gridarta/?rev=8061&view=rev Author: akirschbaum Date: 2010-06-02 07:35:58 +0000 (Wed, 02 Jun 2010) Log Message: ----------- Suppress warnings. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/connectionview/Control.java trunk/src/app/net/sf/gridarta/gui/data/NamedObjectsUtils.java trunk/src/app/net/sf/gridarta/gui/filter/BtnPopup.java trunk/src/app/net/sf/gridarta/gui/findarchetypes/FindArchetypesDialog.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ErrorListView.java trunk/src/app/net/sf/gridarta/gui/script/CloseableTabbedPane.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java trunk/src/app/net/sf/gridarta/gui/utils/tabbedpanel/Tab.java trunk/src/app/net/sf/gridarta/gui/utils/tristate/TristateCheckBox.java trunk/src/app/net/sf/gridarta/textedit/textarea/JEditTextArea.java Modified: trunk/src/app/net/sf/gridarta/gui/connectionview/Control.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/connectionview/Control.java 2010-06-02 07:20:40 UTC (rev 8060) +++ trunk/src/app/net/sf/gridarta/gui/connectionview/Control.java 2010-06-02 07:35:58 UTC (rev 8061) @@ -61,7 +61,10 @@ }); view.addListMouseListener(new MouseAdapter() { - /** {@inheritDoc} */ + /** + * {@inheritDoc} + * @noinspection RefusedBequest + */ @Override public void mousePressed(final MouseEvent e) { highlightSelectedEntries(); Modified: trunk/src/app/net/sf/gridarta/gui/data/NamedObjectsUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/data/NamedObjectsUtils.java 2010-06-02 07:20:40 UTC (rev 8060) +++ trunk/src/app/net/sf/gridarta/gui/data/NamedObjectsUtils.java 2010-06-02 07:35:58 UTC (rev 8061) @@ -81,6 +81,11 @@ final Window dialog = pane.createDialog(parentComponent, ACTION_BUILDER.format("chooseNamedObject.title", namedObjects.getName())); pane.selectInitialValue(); tree.addMouseListener(new MouseAdapter() { + + /** + * {@inheritDoc} + * @noinspection RefusedBequest + */ @Override public void mousePressed(final MouseEvent e) { if (e.getClickCount() == 2) { @@ -93,6 +98,7 @@ } } } + }); dialog.setVisible(true); dialog.dispose(); Modified: trunk/src/app/net/sf/gridarta/gui/filter/BtnPopup.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/filter/BtnPopup.java 2010-06-02 07:20:40 UTC (rev 8060) +++ trunk/src/app/net/sf/gridarta/gui/filter/BtnPopup.java 2010-06-02 07:35:58 UTC (rev 8061) @@ -36,6 +36,10 @@ button = new JButton(name); popupMenu = menu.getPopupMenu(); button.addMouseListener(new MouseAdapter() { + /** + * {@inheritDoc} + * @noinspection RefusedBequest + */ @Override public void mousePressed(final MouseEvent e) { popupMenu.show(button, e.getX(), e.getY()); Modified: trunk/src/app/net/sf/gridarta/gui/findarchetypes/FindArchetypesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/findarchetypes/FindArchetypesDialog.java 2010-06-02 07:20:40 UTC (rev 8060) +++ trunk/src/app/net/sf/gridarta/gui/findarchetypes/FindArchetypesDialog.java 2010-06-02 07:35:58 UTC (rev 8061) @@ -171,7 +171,10 @@ } }); resultTable.addMouseListener(new MouseAdapter() { - /** {@inheritDoc} */ + /** + * {@inheritDoc} + * @noinspection RefusedBequest + */ @Override public void mousePressed(final MouseEvent e) { highlightSelectedEntry(); Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ErrorListView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ErrorListView.java 2010-06-02 07:20:40 UTC (rev 8060) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ErrorListView.java 2010-06-02 07:35:58 UTC (rev 8061) @@ -241,7 +241,10 @@ errorMsg.setEditable(false); errorList.addListSelectionListener(listSelectionListener); errorList.addMouseListener(new MouseAdapter() { - /** {@inheritDoc} */ + /** + * {@inheritDoc} + * @noinspection RefusedBequest + */ @Override public void mousePressed(final MouseEvent e) { highlightEntries(errorList.getSelectedIndex()); Modified: trunk/src/app/net/sf/gridarta/gui/script/CloseableTabbedPane.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/script/CloseableTabbedPane.java 2010-06-02 07:20:40 UTC (rev 8060) +++ trunk/src/app/net/sf/gridarta/gui/script/CloseableTabbedPane.java 2010-06-02 07:35:58 UTC (rev 8061) @@ -90,6 +90,10 @@ private class ClosingListener extends MouseAdapter { + /** + * {@inheritDoc} + * @noinspection RefusedBequest + */ @Override public void mouseReleased(@NotNull final MouseEvent e) { final int i = getSelectedIndex(); Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java 2010-06-02 07:20:40 UTC (rev 8060) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java 2010-06-02 07:35:58 UTC (rev 8061) @@ -138,7 +138,10 @@ @NotNull private final MouseListener mouseListener = new MouseAdapter() { - /** {@inheritDoc} */ + /** + * {@inheritDoc} + * @noinspection RefusedBequest + */ @Override public void mousePressed(final MouseEvent e) { if (isSelect(e)) { Modified: trunk/src/app/net/sf/gridarta/gui/utils/tabbedpanel/Tab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/utils/tabbedpanel/Tab.java 2010-06-02 07:20:40 UTC (rev 8060) +++ trunk/src/app/net/sf/gridarta/gui/utils/tabbedpanel/Tab.java 2010-06-02 07:35:58 UTC (rev 8061) @@ -164,6 +164,7 @@ /** * {@inheritDoc} + * @noinspection RefusedBequest */ @Override public void mousePressed(@NotNull final MouseEvent e) { @@ -172,6 +173,7 @@ /** * {@inheritDoc} + * @noinspection RefusedBequest */ @Override public void mouseReleased(@NotNull final MouseEvent e) { Modified: trunk/src/app/net/sf/gridarta/gui/utils/tristate/TristateCheckBox.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/utils/tristate/TristateCheckBox.java 2010-06-02 07:20:40 UTC (rev 8060) +++ trunk/src/app/net/sf/gridarta/gui/utils/tristate/TristateCheckBox.java 2010-06-02 07:35:58 UTC (rev 8061) @@ -104,6 +104,7 @@ /** * {@inheritDoc} + * @noinspection RefusedBequest */ @Override public void mousePressed(@NotNull final MouseEvent e) { Modified: trunk/src/app/net/sf/gridarta/textedit/textarea/JEditTextArea.java =================================================================== --- trunk/src/app/net/sf/gridarta/textedit/textarea/JEditTextArea.java 2010-06-02 07:20:40 UTC (rev 8060) +++ trunk/src/app/net/sf/gridarta/textedit/textarea/JEditTextArea.java 2010-06-02 07:35:58 UTC (rev 8061) @@ -1645,6 +1645,7 @@ /** * {@inheritDoc} + * @noinspection RefusedBequest */ @Override public void mousePressed(@NotNull final MouseEvent e) { @@ -1678,6 +1679,7 @@ /** * {@inheritDoc} + * @noinspection RefusedBequest */ @Override public void mouseWheelMoved(@NotNull final MouseWheelEvent e) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |