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...> - 2006-12-17 12:53:54
|
Revision: 1134 http://svn.sourceforge.net/gridarta/?rev=1134&view=rev Author: akirschbaum Date: 2006-12-17 04:53:55 -0800 (Sun, 17 Dec 2006) Log Message: ----------- Add filling of non-rectangular selections. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/CopyBuffer.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-17 12:44:17 UTC (rev 1133) +++ trunk/crossfire/ChangeLog 2006-12-17 12:53:55 UTC (rev 1134) @@ -1,5 +1,7 @@ 2006-12-17 Andreas Kirschbaum + * Add filling of non-rectangular selections. + * Add copy/cut/paste for non-rectangular selections. * Properly enable/disable cursor menu entries. Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 12:44:17 UTC (rev 1133) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 12:53:55 UTC (rev 1134) @@ -429,6 +429,20 @@ } } + public Point[] getSelection() { + final List<Point> selection = new ArrayList<Point>(); + final Size2D mapSize = mapModel.getMapSize(); + final Point pos = new Point(); + for (pos.x = 0; pos.x < mapSize.getWidth(); pos.x++) { + for (pos.y = 0; pos.y < mapSize.getHeight(); pos.y++) { + if ((mapGrid.getFlags(pos) & MapGrid.GRID_FLAG_SELECTION) > 0) { + selection.add((Point) pos.clone()); + } + } + } + return selection.toArray(new Point[selection.size()]); + } + /** * Get the selected squares. * @return selected squares Modified: trunk/crossfire/src/cfeditor/CopyBuffer.java =================================================================== --- trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-17 12:44:17 UTC (rev 1133) +++ trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-17 12:53:55 UTC (rev 1134) @@ -245,7 +245,6 @@ final Rectangle selRec = mapControl.getMapGrid().getSelectedRec();; final Point cursor = mapControl.getMapViewFrame().getView().getCursorPosition(); - final Point pos = new Point(); if (mainControl.getArchPanelHighlight() == null) { // no selected arch to fill with return; @@ -259,19 +258,15 @@ floodfill(mapControl, cursor.x, cursor.y, arch); } } else { - // get the arch to fill with - arch = mainControl.getArchPanelHighlight(); - - // cycle through all tile coordinates which are highlighted: - for (pos.x = selRec.x; pos.x - selRec.x <= selRec.width; pos.x++) { - for (pos.y = selRec.y; pos.y - selRec.y <= selRec.height; pos.y++) { - if (density != -1 && density != 100 && density < MainControl.rnd.nextInt(100) + 1) { - continue; - } - // Insert the new arch into the map - addArchToMap(mapControl, arch, pos, false, fillBelow); + mapControl.getMapModel().beginTransaction("Fill"); // TODO; I18N/L10N + for (final Point p : mapControl.getMapViewFrame().getView().getSelection()) { + if (density != -1 && density != 100 && density < MainControl.rnd.nextInt(100) + 1) { + continue; } + final GameObject gameObject = mainControl.getArchPanelHighlight(); + addArchToMap(mapControl, gameObject, p, false, fillBelow); } + mapControl.getMapModel().endTransaction(); } // now the map and toolbars must be redrawn This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-17 12:44:17
|
Revision: 1133 http://svn.sourceforge.net/gridarta/?rev=1133&view=rev Author: akirschbaum Date: 2006-12-17 04:44:17 -0800 (Sun, 17 Dec 2006) Log Message: ----------- Unify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CopyBuffer.java trunk/daimonin/src/daieditor/CopyBuffer.java Modified: trunk/crossfire/src/cfeditor/CopyBuffer.java =================================================================== --- trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-17 12:36:33 UTC (rev 1132) +++ trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-17 12:44:17 UTC (rev 1133) @@ -239,14 +239,14 @@ * @todo the fill density is ignored for floodfill */ public void fill(final MapControl mapControl, final boolean fillBelow, final int density) { + if (!mapControl.getMapViewFrame().isHighlight()) { + return; // should actually never happen + } + final Rectangle selRec = mapControl.getMapGrid().getSelectedRec();; final Point cursor = mapControl.getMapViewFrame().getView().getCursorPosition(); final Point pos = new Point(); - if (!mapControl.getMapViewFrame().isHighlight()) { - return; // should actually never happen - } - if (mainControl.getArchPanelHighlight() == null) { // no selected arch to fill with return; } Modified: trunk/daimonin/src/daieditor/CopyBuffer.java =================================================================== --- trunk/daimonin/src/daieditor/CopyBuffer.java 2006-12-17 12:36:33 UTC (rev 1132) +++ trunk/daimonin/src/daieditor/CopyBuffer.java 2006-12-17 12:44:17 UTC (rev 1133) @@ -237,7 +237,6 @@ * @param rand Percentage of filling (e.g. 100 for 100%, 10 for 10%). */ public void fill(final MapControl mapControl, final boolean fillBelow, final MapControl seed, final int rand) { - if (!mapControl.getMapViewFrame().isHighlight()) { return; // should actually never happen } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-17 12:36:34
|
Revision: 1132 http://svn.sourceforge.net/gridarta/?rev=1132&view=rev Author: akirschbaum Date: 2006-12-17 04:36:33 -0800 (Sun, 17 Dec 2006) Log Message: ----------- Remove explicit map redraw. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CopyBuffer.java Modified: trunk/crossfire/src/cfeditor/CopyBuffer.java =================================================================== --- trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-17 12:33:53 UTC (rev 1131) +++ trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-17 12:36:33 UTC (rev 1132) @@ -182,10 +182,6 @@ gameObject.remove(); } mapControl.getMapModel().endTransaction(); - // finally redraw the map - if (mode != Mode.DO_COPY) { - mainControl.refreshCurrentMap(); - } } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-17 12:33:53
|
Revision: 1131 http://svn.sourceforge.net/gridarta/?rev=1131&view=rev Author: akirschbaum Date: 2006-12-17 04:33:53 -0800 (Sun, 17 Dec 2006) Log Message: ----------- Unify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CopyBuffer.java trunk/daimonin/src/daieditor/CopyBuffer.java Modified: trunk/crossfire/src/cfeditor/CopyBuffer.java =================================================================== --- trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-17 12:26:53 UTC (rev 1130) +++ trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-17 12:33:53 UTC (rev 1131) @@ -148,7 +148,6 @@ } } - final Point offset = selRec.getLocation(); mapControl.getMapModel().beginTransaction("Cut / Clear"); // TODO: I18N/L10N final HashSet<GameObject> gameObjectsToDelete = new HashSet<GameObject>(); for (final MapSquare<GameObject> square : mapControl.getMapViewFrame().getView().getSelectedSquares()) { Modified: trunk/daimonin/src/daieditor/CopyBuffer.java =================================================================== --- trunk/daimonin/src/daieditor/CopyBuffer.java 2006-12-17 12:26:53 UTC (rev 1130) +++ trunk/daimonin/src/daieditor/CopyBuffer.java 2006-12-17 12:33:53 UTC (rev 1131) @@ -149,7 +149,6 @@ } } - final Point offset = selRec.getLocation(); mapControl.getMapModel().beginTransaction("Cut / Clear"); // TODO: I18N/L10N final HashSet<GameObject> gameObjectsToDelete = new HashSet<GameObject>(); for (final MapSquare<GameObject> square : mapControl.getMapViewFrame().getView().getSelectedSquares()) { @@ -161,7 +160,7 @@ // arches that don't match the view settings are ignored! if ((mode == Mode.DO_CUT || mode == Mode.DO_COPY) && gameObject.isHead() && !gameObject.isInContainer() && mainControl.isTileEdit(gameObject)) { // copy this gameObject - final GameObject clone = gameObject.createClone(posx - offset.x, posy - offset.y); + final GameObject clone = gameObject.createClone(posx - selRec.x, posy - selRec.y); assert copyMapCtrl != null; copyMapCtrl.getMapModel().addGameObjectToMap(clone, false); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-17 12:26:52
|
Revision: 1130 http://svn.sourceforge.net/gridarta/?rev=1130&view=rev Author: akirschbaum Date: 2006-12-17 04:26:53 -0800 (Sun, 17 Dec 2006) Log Message: ----------- Remove obsolete TODO comment. Modified Paths: -------------- trunk/daimonin/src/daieditor/CFTreasureListTree.java Modified: trunk/daimonin/src/daieditor/CFTreasureListTree.java =================================================================== --- trunk/daimonin/src/daieditor/CFTreasureListTree.java 2006-12-17 12:25:17 UTC (rev 1129) +++ trunk/daimonin/src/daieditor/CFTreasureListTree.java 2006-12-17 12:26:53 UTC (rev 1130) @@ -89,13 +89,10 @@ private static final DefaultMutableTreeNode root = new DefaultMutableTreeNode("Treasurelists:"); // hashtable containing references to all treasurelists (tree nodes) - // TODO: replace with HashMap private static Map<String, TreasureTreeNode> treasureTable = null; // hashtable temporarily containing names of special treasurelists (like gods' lists) // as keys and folder-nodes where to put these treasurelists as values - // TODO: replace with HashMap - // TODO: generify private Map<String, TreasureTreeNode> specialTreasureLists = null; // all syntax-errors encountered during datafile-parsing get written in this log This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-17 12:25:16
|
Revision: 1129 http://svn.sourceforge.net/gridarta/?rev=1129&view=rev Author: akirschbaum Date: 2006-12-17 04:25:17 -0800 (Sun, 17 Dec 2006) Log Message: ----------- Unify comment. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapTileList.java Modified: trunk/crossfire/src/cfeditor/CMapTileList.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapTileList.java 2006-12-17 12:24:20 UTC (rev 1128) +++ trunk/crossfire/src/cfeditor/CMapTileList.java 2006-12-17 12:25:17 UTC (rev 1129) @@ -60,8 +60,7 @@ import org.jetbrains.annotations.Nullable; /** - * The panel that holds the map-tiles of the selected map square. (The window - * to the right) + * The panel that displays the arches of the currently selected map square. * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-17 12:24:20
|
Revision: 1128 http://svn.sourceforge.net/gridarta/?rev=1128&view=rev Author: akirschbaum Date: 2006-12-17 04:24:20 -0800 (Sun, 17 Dec 2006) Log Message: ----------- Unify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapTileList.java trunk/daimonin/src/daieditor/CMapTileList.java Modified: trunk/crossfire/src/cfeditor/CMapTileList.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapTileList.java 2006-12-17 12:16:48 UTC (rev 1127) +++ trunk/crossfire/src/cfeditor/CMapTileList.java 2006-12-17 12:24:20 UTC (rev 1128) @@ -95,8 +95,8 @@ /** * Create a CMapTileList. - * @param mainControl MainControl, used for some icons. - * @param mainView View to attach to. + * @param mainControl MainControl, used for icons + * @param mainView MainView, used for updating UI */ public CMapTileList(final CMainControl mainControl, final CMainView mainView) { this.mainControl = mainControl; @@ -112,11 +112,11 @@ scrollPane.getViewport().setScrollMode(SIMPLE_SCROLL_MODE); add(scrollPane, BorderLayout.CENTER); - final JPanel dummy = new JPanel(); + final JPanel arrows = new JPanel(); if (mainView.isMapTileListBottom()) { - dummy.setLayout(new GridLayout(2, 1)); + arrows.setLayout(new GridLayout(2, 1)); } - final JScrollPane scrollPane2 = new JScrollPane(dummy); + final JScrollPane scrollPane2 = new JScrollPane(arrows); scrollPane2.setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_NEVER); scrollPane2.setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_NEVER); scrollPane2.getViewport().setScrollMode(SIMPLE_SCROLL_MODE); @@ -141,7 +141,7 @@ buttonDown.setVerticalTextPosition(SwingConstants.BOTTOM); buttonDown.setHorizontalTextPosition(SwingConstants.CENTER); if (!mainView.isMapTileListBottom()) { - dummy.add(buttonDown, BorderLayout.EAST); + arrows.add(buttonDown, BorderLayout.EAST); } final CFancyButton buttonUp = new CFancyButton(null, "Move Tile Position Up", @@ -158,10 +158,10 @@ buttonUp.setVerticalTextPosition(SwingConstants.BOTTOM); buttonUp.setHorizontalTextPosition(SwingConstants.CENTER); if (!mainView.isMapTileListBottom()) { - dummy.add(buttonUp, BorderLayout.WEST); + arrows.add(buttonUp, BorderLayout.WEST); } else { - dummy.add(buttonUp); - dummy.add(buttonDown); + arrows.add(buttonUp); + arrows.add(buttonDown); } list.addListSelectionListener(new ListSelectionListener() { @@ -375,14 +375,14 @@ */ private int addInvObjects(final GameObject node, final GameObject gameObject) { int selListCounter = -1; - for (final GameObject invItem : node.getHead()) { - if (invItem == gameObject) { + for (final GameObject invObject : node.getHead()) { + if (invObject == gameObject) { selListCounter = listCounter; } listCounter++; - model.addElement(invItem); + model.addElement(invObject); - final int tmpListCounter = addInvObjects(invItem, gameObject); + final int tmpListCounter = addInvObjects(invObject, gameObject); if (tmpListCounter != -1) { selListCounter = tmpListCounter; } Modified: trunk/daimonin/src/daieditor/CMapTileList.java =================================================================== --- trunk/daimonin/src/daieditor/CMapTileList.java 2006-12-17 12:16:48 UTC (rev 1127) +++ trunk/daimonin/src/daieditor/CMapTileList.java 2006-12-17 12:24:20 UTC (rev 1128) @@ -58,6 +58,7 @@ import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * The panel that displays the arches of the currently selected map square. @@ -90,11 +91,10 @@ private transient MapSquare<GameObject> currentSquare; /** - * Creates a CMapTileList. - * @param mainControl MainControl, used for icons. - * @param mainView MainView, used for updating UI. + * Create a CMapTileList. + * @param mainControl MainControl, used for icons + * @param mainView MainView, used for updating UI */ - /** Build Panel. */ public CMapTileList(final CMainControl mainControl, final CMainView mainView) { this.mainControl = mainControl; this.mainView = mainView; @@ -283,7 +283,7 @@ * Return the currently selected GameObject within this list (currently selected MapSquare). * @return the currently selected GameObject */ - public GameObject getMapTileSelection() { + @Nullable public GameObject getMapTileSelection() { return (GameObject) list.getSelectedValue(); } @@ -393,14 +393,14 @@ */ private int addInvObjects(final GameObject node, final GameObject gameObject) { int selListCounter = -1; - for (GameObject arch : node.reverse()) { - if (arch == gameObject) { + for (final GameObject invObject : node.reverse()) { + if (invObject == gameObject) { selListCounter = listCounter; } listCounter++; - model.addElement(arch); + model.addElement(invObject); - final int tmpListCounter = addInvObjects(arch, gameObject); + final int tmpListCounter = addInvObjects(invObject, gameObject); if (tmpListCounter != -1) { selListCounter = tmpListCounter; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-17 12:16:53
|
Revision: 1127 http://svn.sourceforge.net/gridarta/?rev=1127&view=rev Author: akirschbaum Date: 2006-12-17 04:16:48 -0800 (Sun, 17 Dec 2006) Log Message: ----------- Add comment. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 12:15:34 UTC (rev 1126) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 12:16:48 UTC (rev 1127) @@ -429,6 +429,10 @@ } } + /** + * Get the selected squares. + * @return selected squares + */ public List<MapSquare<GameObject>> getSelectedSquares() { final List<MapSquare<GameObject>> selection = new ArrayList<MapSquare<GameObject>>(); final Size2D mapSize = mapModel.getMapSize(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-17 12:15:35
|
Revision: 1126 http://svn.sourceforge.net/gridarta/?rev=1126&view=rev Author: akirschbaum Date: 2006-12-17 04:15:34 -0800 (Sun, 17 Dec 2006) Log Message: ----------- Unify order of methods. Modified Paths: -------------- trunk/crossfire/src/cfeditor/map/MapControl.java Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-17 11:37:45 UTC (rev 1125) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-17 12:15:34 UTC (rev 1126) @@ -231,10 +231,22 @@ return mapModel.getMapArch(gameObject, pos); } + /** + * Return the size of the level. + * @return the map size + */ + public Size2D getMapSize() { + return mapModel.getMapSize(); + } + public String getMapTilePath(final int direction) { return mapModel.getMapArchObject().getTilePath(direction); } + public boolean isCutoffSafe(final Size2D size) { + return mapModel.isCutoffSafe(size); + } + public String getMapFileName() { return mapArch.getFileName(); } @@ -279,6 +291,18 @@ return mainControl.getCurrentMap().getMapFileName() != null && mainControl.getCurrentMap().getMapFileName().compareTo(IGUIConstants.DEF_MAPFNAME) != 0; } + public File getMapFile() { + return mapFile; + } + + /** + * Returns model (= map data of this level). + * @return model (= map data of this level) + */ + public MapModel getMapModel() { + return mapModel; + } + public MapCursor getMapCursor() { assert mapViewFrame != null; return mapViewFrame.getBasicView().getMapCursor(); @@ -447,14 +471,6 @@ } /** - * Return the size of the level. - * @return the map size - */ - public Size2D getMapSize() { - return mapModel.getMapSize(); - } - - /** * Return the current view position. * @return the current view position */ @@ -519,10 +535,6 @@ return mapModel.isPointValid(pos); } - public boolean isCutoffSafe(final Size2D size) { - return mapModel.isCutoffSafe(size); - } - /** * Resize the map. * @param size the new level size @@ -536,6 +548,14 @@ } /** + * Get the last used view of this level. + * @return the last used view + */ + public MapViewIFrame getMapViewFrame() { + return mapViewFrame; + } + + /** * Save the level to a file. */ public void save() { @@ -565,20 +585,8 @@ mapFile = file; } - public MapModel getMapModel() { - return mapModel; - } - - public MapViewIFrame getMapViewFrame() { - return mapViewFrame; - } - public MapArchObject getMapArch() { return mapModel.getMapArchObject(); } - public File getMapFile() { - return mapFile; - } - } // class MapControl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <der...@us...> - 2006-12-17 11:37:48
|
Revision: 1125 http://svn.sourceforge.net/gridarta/?rev=1125&view=rev Author: derdanny Date: 2006-12-17 03:37:45 -0800 (Sun, 17 Dec 2006) Log Message: ----------- Replaced number with constant. Modified Paths: -------------- trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java Modified: trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2006-12-17 10:21:59 UTC (rev 1124) +++ trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2006-12-17 11:37:45 UTC (rev 1125) @@ -344,7 +344,7 @@ } img.paintIcon(this, grfx, xstart - xoff, ystart - yoff); if (checkDouble && mainControl.getFaceObjects().get(node.getFaceObjName()).isDouble()) { - img.paintIcon(this, grfx, xstart - xoff, ystart - yoff - 22); + img.paintIcon(this, grfx, xstart - xoff, ystart - yoff - IGUIConstants.TILE_ISO_YLEN + 1); } } // Paint first object (most likely a mob) in spawn points. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <der...@us...> - 2006-12-17 10:22:01
|
Revision: 1124 http://svn.sourceforge.net/gridarta/?rev=1124&view=rev Author: derdanny Date: 2006-12-17 02:21:59 -0800 (Sun, 17 Dec 2006) Log Message: ----------- Replaced x,y-pair with Point. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-17 00:53:47 UTC (rev 1123) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-17 10:21:59 UTC (rev 1124) @@ -246,35 +246,36 @@ // this vector contains all heads of multi-tiles with oversized images final Vector<GameObject> oversizedMultiHeads = new Vector<GameObject>(); final CFilterControl filter = mainControl.getFilterControl(); - for (int y = 0; y < mapGrid.getSize().getHeight(); y++) { - for (int x = 0; x < mapGrid.getSize().getWidth(); x++) { + final Point point = new Point(); + for (point.y = 0; point.y < mapGrid.getSize().getHeight(); point.y++) { + for (point.x = 0; point.x < mapGrid.getSize().getWidth(); point.x++) { filter.newSquare(); - if (!mapControl.getMapModel().containsArchObject(new Point(x, y))) { + if (!mapControl.getMapModel().containsArchObject(point)) { // empty square if (isPickmap) { - grfx.fillRect(x * 32 + borderOffset, y * 32 + borderOffset, 32, 32); + grfx.fillRect(point.x * 32 + borderOffset, point.y * 32 + borderOffset, 32, 32); } else { - CMainControl.getUnknownTileIcon().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); + CMainControl.getUnknownTileIcon().paintIcon(this, grfx, point.x * 32 + borderOffset, point.y * 32 + borderOffset); } } else { - for (final GameObject node : mapControl.getMapModel().getMapSquare(new Point(x, y))) { + for (final GameObject node : mapControl.getMapModel().getMapSquare(point)) { filter.objectInSquare(node); if (!filter.canShow(node)) { continue; } if (mainControl.isTileEdit(node.getEditType()) || mainControl.getTileEdit() == 0 || isPickmap) { if (node.getArchetypeName() == null) { - CMainControl.getNoarchTileIcon().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); + CMainControl.getNoarchTileIcon().paintIcon(this, grfx, point.x * 32 + borderOffset, point.y * 32 + borderOffset); } else if (node.getFaceFlag()) { - CMainControl.getNofaceTileIcon().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); + CMainControl.getNofaceTileIcon().paintIcon(this, grfx, point.x * 32 + borderOffset, point.y * 32 + borderOffset); } else { if (node.getFaceNr() == -1) { - CMainControl.getUnknownTileIcon().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); + CMainControl.getUnknownTileIcon().paintIcon(this, grfx, point.x * 32 + borderOffset, point.y * 32 + borderOffset); } else { // draw object face final ImageIcon img = archlist.getFace(node.getFaceNr()); if (!node.isMulti() || (img.getIconWidth() == 32 && img.getIconHeight() == 32)) { - archlist.getFace(node.getFaceNr()).paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); + archlist.getFace(node.getFaceNr()).paintIcon(this, grfx, point.x * 32 + borderOffset, point.y * 32 + borderOffset); } else if (node.isHead()) { oversizedMultiHeads.addElement(node); // store oversized arches for later } @@ -290,7 +291,7 @@ final Color alpha = highLightMask[i]; final Color c = grfx.getColor(); grfx.setColor(alpha); - grfx.fillRect(x * 32 + borderOffset, y * 32 + borderOffset, 32, 32); + grfx.fillRect(point.x * 32 + borderOffset, point.y * 32 + borderOffset, 32, 32); grfx.setColor(c); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-17 00:53:47
|
Revision: 1123 http://svn.sourceforge.net/gridarta/?rev=1123&view=rev Author: akirschbaum Date: 2006-12-16 16:53:47 -0800 (Sat, 16 Dec 2006) Log Message: ----------- Add copy/cut/paste for non-rectangular selections. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/CopyBuffer.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-17 00:38:22 UTC (rev 1122) +++ trunk/crossfire/ChangeLog 2006-12-17 00:53:47 UTC (rev 1123) @@ -1,5 +1,7 @@ 2006-12-17 Andreas Kirschbaum + * Add copy/cut/paste for non-rectangular selections. + * Properly enable/disable cursor menu entries. 2006-12-16 Andreas Kirschbaum Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 00:38:22 UTC (rev 1122) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 00:53:47 UTC (rev 1123) @@ -38,7 +38,9 @@ import java.awt.event.InputEvent; import java.io.File; import java.io.IOException; +import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import javax.imageio.ImageIO; import javax.swing.JScrollPane; import javax.swing.JViewport; @@ -51,6 +53,7 @@ import net.sf.gridarta.gui.map.MapGrid; import net.sf.gridarta.map.MapModelEvent; import net.sf.gridarta.map.MapModelListener; +import net.sf.gridarta.map.MapSquare; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -85,6 +88,9 @@ /** The controller of this view. */ private final MapControl mapControl; + /** The MapModel. */ + private final MapModel mapModel; + /** The CMainControl. */ private final CMainControl mainControl; @@ -121,7 +127,7 @@ //super("Map ["+control.getMapFileName()+"]", true, true, true, true); super(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); this.mapControl = mapControl; - final MapModel mapModel = mapControl.getMapModel(); + mapModel = mapControl.getMapModel(); mapGrid = new MapGrid(mapModel.getMapSize()); mapCursor = new MapCursor(mapGrid); mapCursor.addMapCursorListener(this); @@ -423,6 +429,20 @@ } } + public List<MapSquare<GameObject>> getSelectedSquares() { + final List<MapSquare<GameObject>> selection = new ArrayList<MapSquare<GameObject>>(); + final Size2D mapSize = mapModel.getMapSize(); + final Point pos = new Point(); + for (pos.x = 0; pos.x < mapSize.getWidth(); pos.x++) { + for (pos.y = 0; pos.y < mapSize.getHeight(); pos.y++) { + if ((mapGrid.getFlags(pos) & MapGrid.GRID_FLAG_SELECTION) > 0) { + selection.add(mapModel.getMapSquare(pos)); + } + } + } + return selection; + } + /** * Return the current view position. * @return the current view position Modified: trunk/crossfire/src/cfeditor/CopyBuffer.java =================================================================== --- trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-17 00:38:22 UTC (rev 1122) +++ trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-17 00:53:47 UTC (rev 1123) @@ -148,35 +148,32 @@ } } - // cycle through all tile coordinates which are highlighted: - final Point pos = new Point(); + final Point offset = selRec.getLocation(); mapControl.getMapModel().beginTransaction("Cut / Clear"); // TODO: I18N/L10N final HashSet<GameObject> gameObjectsToDelete = new HashSet<GameObject>(); - for (pos.x = selRec.x; pos.x - selRec.x <= selRec.width; pos.x++) { - for (pos.y = selRec.y; pos.y - selRec.y <= selRec.height; pos.y++) { - // do the copying for one tile position: - for (final GameObject gameObject : mapControl.getMapModel().getMapSquare(pos)) { - // store a clone of the gameObject in the CopyBuffer - // (for multiparts, only the heads get copied into the buffer) - // arches that don't match the view settings are ignored! - if ((mode == Mode.DO_CUT || mode == Mode.DO_COPY) && gameObject.isHead() && !gameObject.isInContainer() && (mainControl.getTileEdit() == 0 || mainControl.isTileEdit(gameObject.getEditType()))) { - // copy this gameObject - final GameObject clone = gameObject.createClone(pos.x - selRec.x, pos.y - selRec.y); - assert copyMapCtrl != null; - copyMapCtrl.addArchObjectToMap(clone); - } + for (final MapSquare<GameObject> square : mapControl.getMapViewFrame().getView().getSelectedSquares()) { + final int posx = square.getMapX(); + final int posy = square.getMapY(); + for (final GameObject gameObject : square) { + // store a clone of the gameObject in the CopyBuffer + // (for multiparts, only the heads get copied into the buffer) + // arches that don't match the view settings are ignored! + if ((mode == Mode.DO_CUT || mode == Mode.DO_COPY) && gameObject.isHead() && !gameObject.isInContainer() && (mainControl.getTileEdit() == 0 || mainControl.isTileEdit(gameObject.getEditType()))) { + // copy this gameObject + final GameObject clone = gameObject.createClone(posx - selRec.x, posy - selRec.y); + assert copyMapCtrl != null; + copyMapCtrl.addArchObjectToMap(clone); + } + // delete the gameObject if we have a "cut" or "clear" command + // again, arches that don't match the view settings are ignored + if ((mode == Mode.DO_CLEAR || mode == Mode.DO_CUT) && (mainControl.getTileEdit() == 0 || mainControl.isTileEdit(gameObject.getEditType()))) { + // store next arch in tmp - // delete the gameObject if we have a "cut" or "clear" command - // again, arches that don't match the view settings are ignored - if ((mode == Mode.DO_CLEAR || mode == Mode.DO_CUT) && (mainControl.getTileEdit() == 0 || mainControl.isTileEdit(gameObject.getEditType()))) { - // store next arch in tmp - - // delete gameObject (without redrawing the map) - // For CUT we don't delete multi tails of multis which are left or - // above the head (we would miss to copy them otherwise). - if (mode == Mode.DO_CLEAR || (gameObject.getMultiX() >= 0 && gameObject.getMultiY() >= 0)) { - gameObjectsToDelete.add(gameObject.getHead()); - } + // delete gameObject (without redrawing the map) + // For CUT we don't delete multi tails of multis which are left or + // above the head (we would miss to copy them otherwise). + if (mode == Mode.DO_CLEAR || (gameObject.getMultiX() >= 0 && gameObject.getMultiY() >= 0)) { + gameObjectsToDelete.add(gameObject.getHead()); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-17 00:38:22
|
Revision: 1122 http://svn.sourceforge.net/gridarta/?rev=1122&view=rev Author: akirschbaum Date: 2006-12-16 16:38:22 -0800 (Sat, 16 Dec 2006) Log Message: ----------- Unify CopyBuffer implementation. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CopyBuffer.java trunk/daimonin/src/daieditor/CopyBuffer.java Modified: trunk/crossfire/src/cfeditor/CopyBuffer.java =================================================================== --- trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-17 00:09:44 UTC (rev 1121) +++ trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-17 00:38:22 UTC (rev 1122) @@ -34,6 +34,7 @@ import java.util.HashSet; import net.sf.gridarta.Size2D; import net.sf.gridarta.MainControl; +import net.sf.gridarta.map.MapSquare; import org.apache.log4j.Logger; import org.jetbrains.annotations.Nullable; @@ -75,10 +76,6 @@ /** The dummy MapArchObject of {@link #copyMap}. */ private final MapArchObject mapArch; - private int bufWidth; // buffer's width (counted in tiles) - - private int bufHeight; // buffer's height (counted in tiles) - /** * Create the copy buffer. * @param mainControl main control @@ -87,9 +84,6 @@ this.mainControl = mainControl; // link main control in mapArch = new MapArchObject(); - bufWidth = 1; - bufHeight = 1; - mapArch.setMapSize(new Size2D(bufWidth, bufHeight)); mapArch.setFileName("cb"); mapArch.setMapName("cb"); } @@ -140,16 +134,17 @@ // Prepare the buffer (if it's a cut or copy) if (mode == Mode.DO_CUT || mode == Mode.DO_COPY) { final boolean wasEmpty = copyMap == null; + if (!wasEmpty) { + // recycle and resize buffer + copyMap.clearMap(); // free old map (/buffer) object + } - // recycle and resize buffer - bufWidth = Math.abs(selRec.width) + 1; // new width - bufHeight = Math.abs(selRec.height) + 1; // new height - mapArch.setMapSize(new Size2D(bufWidth, bufHeight)); - copyMap = new DefaultMapModel(mainControl, copyMapCtrl, null, mapArch); // new MapModel + mapArch.setMapSize(new Size2D(selRec.width + 1, selRec.height + 1)); copyMapCtrl = new MapControl(mainControl, null, mapArch, false, null); // new MapControl + copyMap = copyMapCtrl.getMapModel(); if (wasEmpty) { - mainControl.getMainView().refreshMenus(); // "Paste" enabled + mainControl.getMainView().refreshMenus(); // "Paste" enabled // XXX: sucks - no MVC } } @@ -209,35 +204,29 @@ // cycle through all tile coordinates which are highlighted: mapControl.getMapModel().beginTransaction("Paste"); // TODO: I18N/L10N final Point pos = new Point(); - final Point sourcePos = new Point(); - for (pos.x = startp.x; Math.abs(pos.x - startp.x) < bufWidth; pos.x++) { - for (pos.y = startp.y; Math.abs(pos.y - startp.y) < bufHeight; pos.y++) { - // paste the archs if on the map: - if (mapControl.isPointValid(pos)) { - sourcePos.x = pos.x - startp.x; - sourcePos.y = pos.y - startp.y; - for (final GameObject gameObject : copyMapCtrl.getMapModel().getMapSquare(sourcePos)) { - if (!gameObject.isMulti()) { - // read arch from buffer and stick in on the map - final GameObject clone = gameObject.createClone(pos.x, pos.y); - mapControl.addArchObjectToMap(clone); - } + assert copyMap != null; + for (final MapSquare<GameObject> square : copyMap) { + pos.setLocation(startp.x + square.getMapX(), startp.y + square.getMapY()); + // paste the archs if on the map: + if (mapControl.isPointValid(pos)) { + for (final GameObject gameObject : square) { + if (!gameObject.isMulti()) { + // read gameObject from buffer and stick in on the map + final GameObject clone = gameObject.createClone(pos.x, pos.y); + mapControl.addArchObjectToMap(clone); } } } } - // now we loop through the tiles again and paste all multis found - for (pos.x = startp.x; Math.abs(pos.x - startp.x) < bufWidth; pos.x++) { - for (pos.y = startp.y; Math.abs(pos.y - startp.y) < bufHeight; pos.y++) { - // paste the archs if on the map: - if (mapControl.isPointValid(pos)) { - sourcePos.x = pos.x - startp.x; - sourcePos.y = pos.y - startp.y; - for (final GameObject gameObject : copyMapCtrl.getMapModel().getMapSquare(sourcePos)) { - if (gameObject.isMulti()) { - addArchToMap(mapControl, gameObject, pos, true, false); - } + assert copyMapCtrl != null; + for (final MapSquare<GameObject> square : copyMapCtrl.getMapModel()) { + pos.setLocation(startp); + pos.translate(square.getMapX(), square.getMapY()); + if (mapControl.isPointValid(pos)) { // paste the archs if on the map: + for (final GameObject gameObject : square) { + if (gameObject.isMulti()) { + addArchToMap(mapControl, gameObject, pos, true, false); } } } Modified: trunk/daimonin/src/daieditor/CopyBuffer.java =================================================================== --- trunk/daimonin/src/daieditor/CopyBuffer.java 2006-12-17 00:09:44 UTC (rev 1121) +++ trunk/daimonin/src/daieditor/CopyBuffer.java 2006-12-17 00:38:22 UTC (rev 1122) @@ -134,18 +134,16 @@ // Prepare the buffer (if it's a cut or copy) if (mode == Mode.DO_CUT || mode == Mode.DO_COPY) { - final boolean wasEmpty; - if (copyMap != null) { + final boolean wasEmpty = copyMap == null; + if (!wasEmpty) { // recycle and resize buffer copyMap.clearMap(); // free old map (/buffer) object - wasEmpty = false; - } else { - wasEmpty = true; } mapArch.setMapSize(new Size2D(selRec.width + 1, selRec.height + 1)); copyMapCtrl = new MapControl(mainControl, null, mapArch, false, false); // new MapControl copyMap = copyMapCtrl.getMapModel(); + if (wasEmpty) { mainControl.getMainView().refreshMenus(); // "Paste" enabled // XXX: sucks - no MVC } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-17 00:09:43
|
Revision: 1121 http://svn.sourceforge.net/gridarta/?rev=1121&view=rev Author: akirschbaum Date: 2006-12-16 16:09:44 -0800 (Sat, 16 Dec 2006) Log Message: ----------- Unify comments. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CopyBuffer.java trunk/daimonin/src/daieditor/CopyBuffer.java Modified: trunk/crossfire/src/cfeditor/CopyBuffer.java =================================================================== --- trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-17 00:06:13 UTC (rev 1120) +++ trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-17 00:09:44 UTC (rev 1121) @@ -330,11 +330,11 @@ * Add an archetype to the destination map. Inserts a new object instance * for default archetypes, and a clone for non-default archetypes. * If <var>allowDouble</var> is <code>false</code> and <var>gameObject</var> is an {@link net.sf.gridarta.gameobject.Archetype}, the object will only be inserted if there wasn't already an object with the same Archetype. - * @param mapControl MapControl of the destination map. - * @param gameObject GameObject to add. - * @param pos Position of MapSquare to add GameObject to. - * @param allowDouble <code>true</code> if insertion of multiple instances of the same Archetype should be allowed, otherwise <code>false</code> - * @param fillBelow <code>true</code> if insertion should happen below other objects on the same MapSquare, <code>false</code> to insert above other objects. + * @param mapControl MapControl of the map the object should be added to. + * @param gameObject GameObject to add. + * @param pos position to add GameObject at + * @param allowDouble <code>true</code> for allowing similar GameObjects on the same square, <code>false</code> to disallow + * @param fillBelow <code>true</code> if the GameObject should be added below all others, <code>false</code> for above */ private void addArchToMap(final MapControl mapControl, final GameObject gameObject, final Point pos, final boolean allowDouble, final boolean fillBelow) { if (gameObject.isArchetype()) { Modified: trunk/daimonin/src/daieditor/CopyBuffer.java =================================================================== --- trunk/daimonin/src/daieditor/CopyBuffer.java 2006-12-17 00:06:13 UTC (rev 1120) +++ trunk/daimonin/src/daieditor/CopyBuffer.java 2006-12-17 00:09:44 UTC (rev 1121) @@ -458,11 +458,12 @@ /** * Add an archetype to the destination map. Inserts a new object instance * for default archetypes, and a clone for non-default archetypes. - * @param mapControl MapControl of the map the object should be added to. - * @param gameObject GameObject to add. - * @param pos Position to add GameObject at. - * @param allowDouble <code>true</code> for allowing similar GameObjects on the same square, <code>false</code> to disallow. - * @param fillBelow <code>true</code> if the GameObject should be added below all others, <code>false</code> for above. + * If <var>allowDouble</var> is <code>false</code> and <var>gameObject</var> is an {@link net.sf.gridarta.gameobject.Archetype}, the object will only be inserted if there wasn't already an object with the same Archetype. + * @param mapControl MapControl of the map the object should be added to. + * @param gameObject GameObject to add. + * @param pos position to add GameObject at + * @param allowDouble <code>true</code> for allowing similar GameObjects on the same square, <code>false</code> to disallow + * @param fillBelow <code>true</code> if the GameObject should be added below all others, <code>false</code> for above */ private void addArchToMap(final MapControl mapControl, final GameObject gameObject, final Point pos, final boolean allowDouble, final boolean fillBelow) { if (gameObject.isArchetype()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-17 00:06:12
|
Revision: 1120 http://svn.sourceforge.net/gridarta/?rev=1120&view=rev Author: akirschbaum Date: 2006-12-16 16:06:13 -0800 (Sat, 16 Dec 2006) Log Message: ----------- Add assert statement. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CopyBuffer.java Modified: trunk/crossfire/src/cfeditor/CopyBuffer.java =================================================================== --- trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-17 00:04:01 UTC (rev 1119) +++ trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-17 00:06:13 UTC (rev 1120) @@ -135,9 +135,7 @@ */ private void copyNCut(final MapControl mapControl, final Mode mode) { final Rectangle selRec = mapControl.getMapGrid().getSelectedRec(); - if (selRec == null) { - return; - } + assert selRec != null; // Prepare the buffer (if it's a cut or copy) if (mode == Mode.DO_CUT || mode == Mode.DO_COPY) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-17 00:04:03
|
Revision: 1119 http://svn.sourceforge.net/gridarta/?rev=1119&view=rev Author: akirschbaum Date: 2006-12-16 16:04:01 -0800 (Sat, 16 Dec 2006) Log Message: ----------- Make paste menu entry work. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CopyBuffer.java Modified: trunk/crossfire/src/cfeditor/CopyBuffer.java =================================================================== --- trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-17 00:01:21 UTC (rev 1118) +++ trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-17 00:04:01 UTC (rev 1119) @@ -92,8 +92,6 @@ mapArch.setMapSize(new Size2D(bufWidth, bufHeight)); mapArch.setFileName("cb"); mapArch.setMapName("cb"); - - copyMap = new DefaultMapModel(this.mainControl, copyMapCtrl, null, mapArch); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-17 00:01:21
|
Revision: 1118 http://svn.sourceforge.net/gridarta/?rev=1118&view=rev Author: akirschbaum Date: 2006-12-16 16:01:21 -0800 (Sat, 16 Dec 2006) Log Message: ----------- Properly enable/disable cursor menu entries. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/CMapViewBasic.java trunk/daimonin/src/daieditor/gui/map/MapCursorControl.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-16 22:46:32 UTC (rev 1117) +++ trunk/crossfire/ChangeLog 2006-12-17 00:01:21 UTC (rev 1118) @@ -1,3 +1,7 @@ +2006-12-17 Andreas Kirschbaum + + * Properly enable/disable cursor menu entries. + 2006-12-16 Andreas Kirschbaum * Implement non-rectangular selections. For now, it does not take Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-16 22:46:32 UTC (rev 1117) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-17 00:01:21 UTC (rev 1118) @@ -785,11 +785,12 @@ level.levelCloseNotify(); mainView.removeLevelView(level.getMapViewFrame()); levels.remove(level); - currentMap = null; if (levels.size() > 0) { // get next open map we can find and set it to currentMap - currentMap = levels.get(levels.size() - 1); + setCurrentLevel(levels.get(levels.size() - 1)); + } else { + setCurrentLevel(null); } } refreshMenusAndToolbars(); @@ -1427,6 +1428,7 @@ public void setCurrentLevel(final MapControl map) { currentMap = map; refreshMenusAndToolbars(); + mapCursorControl.refreshMenus(); //CMainStatusbar.getInstance().setLevelInfo(level); } Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2006-12-16 22:46:32 UTC (rev 1117) +++ trunk/crossfire/src/cfeditor/CMainView.java 2006-12-17 00:01:21 UTC (rev 1118) @@ -824,19 +824,12 @@ private final String[] directionsMap = {"enterNorthMap", "enterEastMap", "enterSouthMap", "enterWestMap", "enterUpperMap", "enterLowerMap"}; - private final String[] directionsGo = {"goNorth", "goEast", "goSouth", "goWest", "goNorthEast", "goSouthEast", "goSouthWest", "goNorthWest"}; - private void initActions() { ACTION_FACTORY.createActions(true, mainControl, "createNew", "open", "options", "exit", "gc", "onlineHelp", "about"); ACTION_FACTORY.createActions(true, mainControl.getScriptController().getView(), "editPlugins", "savePlugins", "exportPluginAs", "importPlugin"); ACTION_FACTORY.createActions(true, mainControl, directionsMap); ACTION_FACTORY.createActions(true, this, "resetView"); ACTION_FACTORY.createToggles(true, mainControl, "autoJoin"); - ACTION_FACTORY.createActions(true, mainControl.getMapCursorControl(), directionsGo); - ACTION_FACTORY.createActions(true, mainControl.getMapCursorControl(), "selectTile", "startStopDrag", "addToSelection", "subFromSelection", "releaseDrag"); - ACTION_FACTORY.createActions(true, mainControl.getMapCursorControl(), "insertArch", "deleteArch"); - ACTION_FACTORY.createActions(true, mainControl.getMapCursorControl(), "selectArchAbove", "selectArchBelow"); - ACTION_FACTORY.createAction(true, "archAttributes", mainControl.getMapCursorControl()); ACTION_FACTORY.createToggles(true, this, "lockAllPickmaps"); aTileShow.setEnabled(false); // not yet implemented @@ -945,9 +938,6 @@ final String mtp = mapState ? mainControl.getCurrentMap().getMapArch().getTilePath(direction) : null; ACTION_FACTORY.getAction(directionsMap[direction]).setEnabled(mtp != null && mtp.length() > 0); } - for (int direction = 0; direction < directionsGo.length; direction++) { - ACTION_FACTORY.getAction(directionsGo[direction]).setEnabled(selState); - } aClear.setEnabled(selState); aCut.setEnabled(selState); aCopy.setEnabled(selState); Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-16 22:46:32 UTC (rev 1117) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 00:01:21 UTC (rev 1118) @@ -128,6 +128,7 @@ if (!mapControl.isPickmap()) { mapCursor.addMapCursorListener(mainControl.getMainView().getMapTileList()); mapCursor.addMapCursorListener(mainControl.getMainView().getStatusBar()); + mapCursor.addMapCursorListener(mainControl.getMapCursorControl()); } this.mainControl = mainControl; frame = fi; Modified: trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java 2006-12-16 22:46:32 UTC (rev 1117) +++ trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java 2006-12-17 00:01:21 UTC (rev 1118) @@ -28,25 +28,61 @@ import cfeditor.gameobject.GameObject; import cfeditor.map.MapControl; import java.awt.Point; +import javax.swing.Action; import net.sf.gridarta.gui.map.MapCursor; +import net.sf.gridarta.gui.map.MapCursorEvent; +import net.sf.gridarta.gui.map.MapCursorListener; import net.sf.gridarta.gui.map.MapGrid; +import net.sf.japi.swing.ActionFactory; +import org.jetbrains.annotations.NotNull; /** * This class processes events from the cursor menu. * Moving the cursor, selecting map tiles/arches, inserting/deleting arches and open arch property dialog is supported. * @author <a href="mailto:dlv...@gm...">Daniel Viegas</a> + * @author Andreas Kirschbaum */ -public class MapCursorControl { +public class MapCursorControl implements MapCursorListener { + /** Action Factory to create Actions. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); + /** The MainControl. */ private final CMainControl mainControl; + /** Directions for cursor movement. */ + private final String[] directionsGo = {"goNorth", "goEast", "goSouth", "goWest", "goNorthEast", "goSouthEast", "goSouthWest", "goNorthWest"}; + + private final Action aSelectTile = ACTION_FACTORY.createAction(true, "selectTile", this); + + private final Action aStartStopDrag = ACTION_FACTORY.createAction(true, "startStopDrag", this); + + private final Action aAddToSelection = ACTION_FACTORY.createAction(true, "addToSelection", this); + + private final Action aSubFromSelection = ACTION_FACTORY.createAction(true, "subFromSelection", this); + + private final Action aReleaseDrag = ACTION_FACTORY.createAction(true, "releaseDrag", this); + + private final Action aInsertArch = ACTION_FACTORY.createAction(true, "insertArch", this); + + private final Action aDeleteArch = ACTION_FACTORY.createAction(true, "deleteArch", this); + + private final Action aSelectArchAbove = ACTION_FACTORY.createAction(true, "selectArchAbove", this); + + private final Action aSelectArchBelow = ACTION_FACTORY.createAction(true, "selectArchBelow", this); + + private final Action aArchAttributes = ACTION_FACTORY.createAction(true, "archAttributes", this); + /** * Create a MapCursorControl. * @param mainControl MainControl to use (used for getting the current map etc.) */ public MapCursorControl(final CMainControl mainControl) { this.mainControl = mainControl; + + ACTION_FACTORY.createActions(true, this, directionsGo); + + refreshMenus(); } /** @@ -210,4 +246,39 @@ assert mapCursor != null; return mapCursor; } + + /** {@inheritDoc} */ + public void mapCursorChangedPos(@NotNull MapCursorEvent e) { + // ignore + } + + /** {@inheritDoc} */ + public void mapCursorChangedMode(@NotNull MapCursorEvent e) { + refreshMenus(); + } + + /** + * Enable/disable menu entries based on the current cursor state. + */ + public void refreshMenus() { + final MapControl mapControl = mainControl.getCurrentMap(); + final MapCursor mapCursor = mapControl != null ? mapControl.getMapCursor() : null; + + final boolean hasCursor = mapCursor != null && mapCursor.isActive(); + + for (int direction = 0; direction < directionsGo.length; direction++) { + ACTION_FACTORY.getAction(directionsGo[direction]).setEnabled(hasCursor); + } + aSelectTile.setEnabled(hasCursor); + aStartStopDrag.setEnabled(hasCursor); + aAddToSelection.setEnabled(hasCursor); + aSubFromSelection.setEnabled(hasCursor); + aReleaseDrag.setEnabled(hasCursor); + aInsertArch.setEnabled(hasCursor); + aDeleteArch.setEnabled(hasCursor); + aSelectArchAbove.setEnabled(hasCursor); + aSelectArchBelow.setEnabled(hasCursor); + aArchAttributes.setEnabled(hasCursor); + } + } // class MapCursorControl Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-12-16 22:46:32 UTC (rev 1117) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-12-17 00:01:21 UTC (rev 1118) @@ -997,9 +997,9 @@ if (levels.size() > 0) { // get next open map we can find and set it to currentMap - currentMap = levels.get(levels.size() - 1); + setCurrentLevel(levels.get(levels.size() - 1)); } else { - currentMap = null; + setCurrentLevel(null); } } refreshMenusAndToolbars(); @@ -1676,6 +1676,7 @@ public void setCurrentLevel(final MapControl map) { currentMap = map; refreshMenusAndToolbars(); + mapCursorControl.refreshMenus(); //CMainStatusbar.getInstance().setLevelInfo(level); } Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2006-12-16 22:46:32 UTC (rev 1117) +++ trunk/daimonin/src/daieditor/CMainView.java 2006-12-17 00:01:21 UTC (rev 1118) @@ -727,16 +727,9 @@ private final String[] directionsMap = {"enterNorthMap", "enterEastMap", "enterSouthMap", "enterWestMap", "enterNorthEastMap", "enterSouthEastMap", "enterSouthWestMap", "enterNorthWestMap"}; - private final String[] directionsGo = {"goNorth", "goEast", "goSouth", "goWest", "goNorthEast", "goSouthEast", "goSouthWest", "goNorthWest"}; - private void initActions() { ACTION_FACTORY.createActions(true, mainControl, "createNew", "open", "options", "exit", "newScript", "editScript", "controlServer", "controlClient", "validateMap", "cleanCompletelyBlockedSquares", "zoom", "gc", "prevWindow", "nextWindow", "onlineHelp", "tod", "about", "update"); ACTION_FACTORY.createActions(true, mainControl, directionsMap); - ACTION_FACTORY.createActions(true, mainControl.getMapCursorControl(), directionsGo); - ACTION_FACTORY.createActions(true, mainControl.getMapCursorControl(), "selectTile", "startStopDrag", "addToSelection", "subFromSelection", "releaseDrag"); - ACTION_FACTORY.createActions(true, mainControl.getMapCursorControl(), "insertArch", "deleteArch"); - ACTION_FACTORY.createActions(true, mainControl.getMapCursorControl(), "selectArchAbove", "selectArchBelow"); - ACTION_FACTORY.createAction(true, "archAttributes", mainControl.getMapCursorControl()); ACTION_FACTORY.createToggles(true, mainControl, "drawDouble", "gridVisible"); ACTION_FACTORY.createToggles(true, this, "lockAllPickmaps"); } @@ -838,7 +831,6 @@ for (int direction = 0; direction < 8; direction++) { final String mtp = mapState ? mainControl.getCurrentMap().getMapArch().getTilePath(direction) : null; ACTION_FACTORY.getAction(directionsMap[direction]).setEnabled(mtp != null && mtp.length() > 0); - ACTION_FACTORY.getAction(directionsGo[direction]).setEnabled(selState); } aClear.setEnabled(selState); aCut.setEnabled(selState); Modified: trunk/daimonin/src/daieditor/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-12-16 22:46:32 UTC (rev 1117) +++ trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-12-17 00:01:21 UTC (rev 1118) @@ -125,6 +125,7 @@ if (!mapControl.isPickmap()) { mapCursor.addMapCursorListener(mainControl.getMainView().getMapTileList()); mapCursor.addMapCursorListener(mainControl.getMainView().getStatusBar()); + mapCursor.addMapCursorListener(mainControl.getMapCursorControl()); } this.mainControl = mainControl; Modified: trunk/daimonin/src/daieditor/gui/map/MapCursorControl.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/MapCursorControl.java 2006-12-16 22:46:32 UTC (rev 1117) +++ trunk/daimonin/src/daieditor/gui/map/MapCursorControl.java 2006-12-17 00:01:21 UTC (rev 1118) @@ -28,25 +28,61 @@ import daieditor.gameobject.GameObject; import daieditor.map.MapControl; import java.awt.Point; +import javax.swing.Action; import net.sf.gridarta.gui.map.MapCursor; +import net.sf.gridarta.gui.map.MapCursorEvent; +import net.sf.gridarta.gui.map.MapCursorListener; import net.sf.gridarta.gui.map.MapGrid; +import net.sf.japi.swing.ActionFactory; +import org.jetbrains.annotations.NotNull; /** * This class processes events from the cursor menu. * Moving the cursor, selecting map tiles/arches, inserting/deleting arches and open arch property dialog is supported. * @author <a href="mailto:dlv...@gm...">Daniel Viegas</a> + * @author Andreas Kirschbaum */ -public class MapCursorControl { +public class MapCursorControl implements MapCursorListener { + /** Action Factory to create Actions. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); + /** The MainControl. */ private final CMainControl mainControl; + /** Directions for cursor movement. */ + private final String[] directionsGo = {"goNorth", "goEast", "goSouth", "goWest", "goNorthEast", "goSouthEast", "goSouthWest", "goNorthWest"}; + + private final Action aSelectTile = ACTION_FACTORY.createAction(true, "selectTile", this); + + private final Action aStartStopDrag = ACTION_FACTORY.createAction(true, "startStopDrag", this); + + private final Action aAddToSelection = ACTION_FACTORY.createAction(true, "addToSelection", this); + + private final Action aSubFromSelection = ACTION_FACTORY.createAction(true, "subFromSelection", this); + + private final Action aReleaseDrag = ACTION_FACTORY.createAction(true, "releaseDrag", this); + + private final Action aInsertArch = ACTION_FACTORY.createAction(true, "insertArch", this); + + private final Action aDeleteArch = ACTION_FACTORY.createAction(true, "deleteArch", this); + + private final Action aSelectArchAbove = ACTION_FACTORY.createAction(true, "selectArchAbove", this); + + private final Action aSelectArchBelow = ACTION_FACTORY.createAction(true, "selectArchBelow", this); + + private final Action aArchAttributes = ACTION_FACTORY.createAction(true, "archAttributes", this); + /** * Create a MapCursorControl. * @param mainControl MainControl to use (used for getting the current map etc.) */ public MapCursorControl(final CMainControl mainControl) { this.mainControl = mainControl; + + ACTION_FACTORY.createActions(true, this, directionsGo); + + refreshMenus(); } /** @@ -209,4 +245,39 @@ assert mapCursor != null; return mapCursor; } + + /** {@inheritDoc} */ + public void mapCursorChangedPos(@NotNull MapCursorEvent e) { + // ignore + } + + /** {@inheritDoc} */ + public void mapCursorChangedMode(@NotNull MapCursorEvent e) { + refreshMenus(); + } + + /** + * Enable/disable menu entries based on the current cursor state. + */ + public void refreshMenus() { + final MapControl mapControl = mainControl.getCurrentMap(); + final MapCursor mapCursor = mapControl != null ? mapControl.getMapCursor() : null; + + final boolean hasCursor = mapCursor != null && mapCursor.isActive(); + + for (int direction = 0; direction < directionsGo.length; direction++) { + ACTION_FACTORY.getAction(directionsGo[direction]).setEnabled(hasCursor); + } + aSelectTile.setEnabled(hasCursor); + aStartStopDrag.setEnabled(hasCursor); + aAddToSelection.setEnabled(hasCursor); + aSubFromSelection.setEnabled(hasCursor); + aReleaseDrag.setEnabled(hasCursor); + aInsertArch.setEnabled(hasCursor); + aDeleteArch.setEnabled(hasCursor); + aSelectArchAbove.setEnabled(hasCursor); + aSelectArchBelow.setEnabled(hasCursor); + aArchAttributes.setEnabled(hasCursor); + } + } // class MapCursorControl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <der...@us...> - 2006-12-16 22:46:33
|
Revision: 1117 http://svn.sourceforge.net/gridarta/?rev=1117&view=rev Author: derdanny Date: 2006-12-16 14:46:32 -0800 (Sat, 16 Dec 2006) Log Message: ----------- Fixed javadoc. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java trunk/daimonin/src/daieditor/gui/map/LevelRenderer.java Modified: trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java 2006-12-16 22:38:19 UTC (rev 1116) +++ trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java 2006-12-16 22:46:32 UTC (rev 1117) @@ -27,7 +27,7 @@ import org.jetbrains.annotations.Nullable; /** - * A lavel renderer, mainly used as central point to iso and flat renderer. + * A level renderer, mainly used as central point to iso and flat renderer. * * @author tchize */ @@ -47,7 +47,7 @@ * Returns the map location at the given point or null if no map location * is at the point. * @param point The coordinates in the renderer view. - * @param retPoint if <cod>(retPoint != null)</code> this point will be returned otherwise a new point will be created + * @param retPoint if <code>(retPoint != null)</code> this point will be returned otherwise a new point will be created * @return The map location. */ @Nullable public abstract Point getTileLocationAt(@NotNull final Point point, @Nullable final Point retPoint); Modified: trunk/daimonin/src/daieditor/gui/map/LevelRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/LevelRenderer.java 2006-12-16 22:38:19 UTC (rev 1116) +++ trunk/daimonin/src/daieditor/gui/map/LevelRenderer.java 2006-12-16 22:46:32 UTC (rev 1117) @@ -28,7 +28,7 @@ import org.jetbrains.annotations.Nullable; /** - * A lavel renderer, mainly used as central point to iso and flat renderer. + * A level renderer, mainly used as central point to iso and flat renderer. * * @author tchize */ @@ -44,7 +44,7 @@ * Returns the map location at the given point or null if no map location * is at the point. * @param point The coordinates in the renderer view. - * @param retPoint if <cod>(retPoint != null)</code> this point will be returned otherwise a new point will be created + * @param retPoint if <code>(retPoint != null)</code> this point will be returned otherwise a new point will be created * @return The map location. */ @Nullable public abstract Point getTileLocationAt(@NotNull final Point point, @Nullable final Point retPoint); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-16 22:38:19
|
Revision: 1116 http://svn.sourceforge.net/gridarta/?rev=1116&view=rev Author: akirschbaum Date: 2006-12-16 14:38:19 -0800 (Sat, 16 Dec 2006) Log Message: ----------- Replace redundant variable. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CopyBuffer.java Modified: trunk/crossfire/src/cfeditor/CopyBuffer.java =================================================================== --- trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-16 21:30:26 UTC (rev 1115) +++ trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-16 22:38:19 UTC (rev 1116) @@ -72,8 +72,6 @@ /** MapControl for {@link #copyMap}. */ @Nullable private MapControl copyMapCtrl; - private boolean empty; // Is the CopyBuffer empty? - /** The dummy MapArchObject of {@link #copyMap}. */ private final MapArchObject mapArch; @@ -86,7 +84,6 @@ * @param mainControl main control */ public CopyBuffer(final CMainControl mainControl) { - empty = true; // Buffer is empty this.mainControl = mainControl; // link main control in mapArch = new MapArchObject(); @@ -105,7 +102,7 @@ * <code>false</code> */ public boolean isEmpty() { - return empty; + return copyMap == null; } /** @@ -146,19 +143,18 @@ // Prepare the buffer (if it's a cut or copy) if (mode == Mode.DO_CUT || mode == Mode.DO_COPY) { - if (empty) { - empty = false; // from now on the buffer is never empty again - mainControl.getMainView().refreshMenus(); // "Paste" enabled - } + final boolean wasEmpty = copyMap == null; // recycle and resize buffer bufWidth = Math.abs(selRec.width) + 1; // new width bufHeight = Math.abs(selRec.height) + 1; // new height mapArch.setMapSize(new Size2D(bufWidth, bufHeight)); - copyMap = null; // free objects (at least that is the plan and theory) - copyMapCtrl = null; copyMap = new DefaultMapModel(mainControl, copyMapCtrl, null, mapArch); // new MapModel copyMapCtrl = new MapControl(mainControl, null, mapArch, false, null); // new MapControl + + if (wasEmpty) { + mainControl.getMainView().refreshMenus(); // "Paste" enabled + } } // cycle through all tile coordinates which are highlighted: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-16 21:30:29
|
Revision: 1115 http://svn.sourceforge.net/gridarta/?rev=1115&view=rev Author: akirschbaum Date: 2006-12-16 13:30:26 -0800 (Sat, 16 Dec 2006) Log Message: ----------- Unify map cursor and non-rectangular selection. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/resource/system/seltile.png trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/CMapTileList.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/CopyBuffer.java trunk/crossfire/src/cfeditor/IGUIConstants.java trunk/crossfire/src/cfeditor/MapViewIFrame.java trunk/crossfire/src/cfeditor/ReplaceDialog.java trunk/crossfire/src/cfeditor/action.properties trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/crossfire/src/cfeditor/map/MapControl.java trunk/crossfire/src/cfeditor/map/MapModel.java trunk/crossfire/src/cfeditor/messages.properties trunk/crossfire/src/cfeditor/messages_de.properties Added Paths: ----------- trunk/crossfire/resource/system/cursor.png trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-16 21:22:20 UTC (rev 1114) +++ trunk/crossfire/ChangeLog 2006-12-16 21:30:26 UTC (rev 1115) @@ -1,3 +1,13 @@ +2006-12-16 Andreas Kirschbaum + + * Implement non-rectangular selections. For now, it does not take + effect on any operation. + + * Implement map cursor. It affects flood filling, enter exit and + pasting. + + * Allow archetype selection by cursor in archetype panel. + 2006-12-15 Andreas Kirschbaum * Invert sorting order of archetype panels. Added: trunk/crossfire/resource/system/cursor.png =================================================================== (Binary files differ) Property changes on: trunk/crossfire/resource/system/cursor.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/crossfire/resource/system/seltile.png =================================================================== (Binary files differ) Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-16 21:22:20 UTC (rev 1114) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-16 21:30:26 UTC (rev 1115) @@ -29,6 +29,7 @@ import cfeditor.gameobject.GameObject; import cfeditor.gameobject.anim.AnimationObjects; import cfeditor.gameobject.face.FaceObjects; +import cfeditor.gui.map.MapCursorControl; import cfeditor.gui.map.MapPropertiesDialog; import cfeditor.gui.prefs.GUIPrefs; import cfeditor.gui.prefs.ResPrefs; @@ -113,6 +114,8 @@ private static ImageIcon mapGridIcon; + private static ImageIcon mapCursorIcon; + private static ImageIcon unknownTileIcon; private static ImageIcon nofaceTileIcon; @@ -176,11 +179,14 @@ /** Pickmaps cannot be edited while lockedPickmaps is true. */ private boolean lockAllPickmaps = false; + private final MapCursorControl mapCursorControl; + /** Constructs the main controller and its model and view. */ public CMainControl() { instance = this; archetypeSet = new ArchetypeSet(this); scriptControl = new CScriptController(this); + mapCursorControl = new MapCursorControl(this); mainView = new CMainView(); } @@ -1232,7 +1238,7 @@ public void enterExit() { GameObject exit = getMainView().getMapTileSelection(); if (exit == null || !CFArchTypeList.isExitType(exit)) { - exit = currentMap.getMapModel().getExit(currentMap.getMapViewFrame().getHighlightStart()); + exit = currentMap.getMapModel().getExit(currentMap.getMapViewFrame().getView().getCursorPosition()); } if (exit == null) { // no exit found @@ -1654,6 +1660,10 @@ return mapGridIcon; } + public static ImageIcon getMapCursorIcon() { + return mapCursorIcon; + } + public static ImageIcon getUnknownTileIcon() { return unknownTileIcon; } @@ -1677,6 +1687,7 @@ private static void loadDefTiles() { mapGridIcon = CGUIUtils.getSysIcon(IGUIConstants.TILE_GRID_TILE); mapSelIcon = CGUIUtils.getSysIcon(IGUIConstants.TILE_SEL_TILE); + mapCursorIcon = CGUIUtils.getSysIcon(IGUIConstants.TILE_CURSOR); unknownTileIcon = CGUIUtils.getSysIcon(IGUIConstants.TILE_UNKNOWN); nofaceTileIcon = CGUIUtils.getSysIcon(IGUIConstants.TILE_NOFACE); noarchTileIcon = CGUIUtils.getSysIcon(IGUIConstants.TILE_NOARCH); @@ -1796,6 +1807,10 @@ return null; } + public MapCursorControl getMapCursorControl() { + return mapCursorControl; + } + /** * Runs the garbage collection. */ Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2006-12-16 21:22:20 UTC (rev 1114) +++ trunk/crossfire/src/cfeditor/CMainView.java 2006-12-16 21:30:26 UTC (rev 1115) @@ -32,6 +32,7 @@ import java.awt.Component; import java.awt.Dimension; import java.awt.Rectangle; +import java.awt.Point; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.WindowAdapter; @@ -339,8 +340,9 @@ if (pmap != null && pmap.getMapViewFrame().isHighlight()) { // now try to get the topmost object GameObject arch = null; - if (pmap.isPointValid(pmap.getMapViewFrame().getHighlightStart())) { - arch = pmap.getMapModel().getMapSquare(pmap.getMapViewFrame().getHighlightStart()).getFirst(); + final Point cursor = pmap.getMapViewFrame().getView().getCursorPosition(); + if (pmap.isPointValid(cursor)) { + arch = pmap.getMapModel().getMapSquare(cursor).getFirst(); } if (arch != null) { // so here we return the arch from the pickmap @@ -822,12 +824,19 @@ private final String[] directionsMap = {"enterNorthMap", "enterEastMap", "enterSouthMap", "enterWestMap", "enterUpperMap", "enterLowerMap"}; + private final String[] directionsGo = {"goNorth", "goEast", "goSouth", "goWest", "goNorthEast", "goSouthEast", "goSouthWest", "goNorthWest"}; + private void initActions() { ACTION_FACTORY.createActions(true, mainControl, "createNew", "open", "options", "exit", "gc", "onlineHelp", "about"); ACTION_FACTORY.createActions(true, mainControl.getScriptController().getView(), "editPlugins", "savePlugins", "exportPluginAs", "importPlugin"); ACTION_FACTORY.createActions(true, mainControl, directionsMap); ACTION_FACTORY.createActions(true, this, "resetView"); ACTION_FACTORY.createToggles(true, mainControl, "autoJoin"); + ACTION_FACTORY.createActions(true, mainControl.getMapCursorControl(), directionsGo); + ACTION_FACTORY.createActions(true, mainControl.getMapCursorControl(), "selectTile", "startStopDrag", "addToSelection", "subFromSelection", "releaseDrag"); + ACTION_FACTORY.createActions(true, mainControl.getMapCursorControl(), "insertArch", "deleteArch"); + ACTION_FACTORY.createActions(true, mainControl.getMapCursorControl(), "selectArchAbove", "selectArchBelow"); + ACTION_FACTORY.createAction(true, "archAttributes", mainControl.getMapCursorControl()); ACTION_FACTORY.createToggles(true, this, "lockAllPickmaps"); aTileShow.setEnabled(false); // not yet implemented @@ -932,10 +941,13 @@ //aTileShow.setEnabled(mapState); aMapProperties.setEnabled(mapState); aReplace.setEnabled(mapState); - for (int direction = 0; direction < IGUIConstants.DIRECTIONS; direction++) { + for (int direction = 0; direction < directionsMap.length; direction++) { final String mtp = mapState ? mainControl.getCurrentMap().getMapArch().getTilePath(direction) : null; ACTION_FACTORY.getAction(directionsMap[direction]).setEnabled(mtp != null && mtp.length() > 0); } + for (int direction = 0; direction < directionsGo.length; direction++) { + ACTION_FACTORY.getAction(directionsGo[direction]).setEnabled(selState); + } aClear.setEnabled(selState); aCut.setEnabled(selState); aCopy.setEnabled(selState); @@ -969,6 +981,10 @@ MenuManager.getMenuManager().addMenuLocation(currentmapLocation); } + public CMapTileList getMapTileList() { + return mapTileList; + } + private final class LookAndFeelAction extends AbstractAction { private final String className; Modified: trunk/crossfire/src/cfeditor/CMapTileList.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapTileList.java 2006-12-16 21:22:20 UTC (rev 1114) +++ trunk/crossfire/src/cfeditor/CMapTileList.java 2006-12-16 21:30:26 UTC (rev 1115) @@ -53,6 +53,10 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import net.sf.gridarta.gameobject.GameObjectContainer; +import net.sf.gridarta.gui.map.MapCursor; +import net.sf.gridarta.gui.map.MapCursorEvent; +import net.sf.gridarta.gui.map.MapCursorListener; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -61,7 +65,7 @@ * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -public final class CMapTileList extends JPanel { +public final class CMapTileList extends JPanel implements MapCursorListener { /** Serial Version UID. */ private static final long serialVersionUID = 1L; @@ -213,6 +217,17 @@ }); } + public void selectArchBelow() { + list.setSelectedIndex(list.getSelectedIndex() + 1); + } + + public void selectArchAbove() { + final int index = list.getSelectedIndex(); + if (index > 0) { + list.setSelectedIndex(index - 1); + } + } + /** * Determine the list index for a given mouse event. This function differs * from <code>list.locationTopIndex(e.getPoint())</code> in that it always @@ -309,7 +324,7 @@ } listCounter = 0; - currentSquare = mapControl.getMapModel().getMouseRightPos(); + currentSquare = mapControl.getMapCursor().getLocation(); int postSelect = -1; boolean foundSIndex = false; int sIndex = 0; @@ -375,6 +390,22 @@ return selListCounter; } + /** {@inheritDoc} */ + public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { + if (e.getSource().isActive()) { + // Position changed + setMapTileList(mainControl.getCurrentMap(), null); + } else { + // Cursor was disabled + setMapTileList(null, null); + } + } + + /** {@inheritDoc} */ + public void mapCursorChangedMode(@NotNull final MapCursorEvent e) { + // A mode change can be ignored + } + /** CellRenderer for rendering ArchObjects on a certain map tile in a list. */ private final class MyCellRenderer extends DefaultListCellRenderer { Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-16 21:22:20 UTC (rev 1114) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-16 21:30:26 UTC (rev 1115) @@ -45,8 +45,14 @@ import javax.swing.ScrollPaneConstants; import net.sf.gridarta.EditOperation; import net.sf.gridarta.Size2D; +import net.sf.gridarta.gui.map.MapCursor; +import net.sf.gridarta.gui.map.MapCursorEvent; +import net.sf.gridarta.gui.map.MapCursorListener; import net.sf.gridarta.gui.map.MapGrid; +import net.sf.gridarta.map.MapModelEvent; +import net.sf.gridarta.map.MapModelListener; import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -69,7 +75,7 @@ * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -public final class CMapViewBasic extends JScrollPane { +public final class CMapViewBasic extends JScrollPane implements MapModelListener, MapCursorListener { private static final Logger log = Logger.getLogger(CMapViewBasic.class); @@ -92,15 +98,10 @@ private boolean gridVisible = false; - // this is needed to check the diamond tile areas and convert rectangles to diamond - private final Point mapMousePos = new Point(); + private MapCursor mapCursor; private final Point mapMouseRightPos = new Point(); // coordinates of selected tile on the map - private final Point mapMouseRightOff = new Point(); // offset from the selected tile while left-click draging - - private boolean highlightOn; // Is map-tile selection highlighted? true/false - private final boolean[] needMpanelUpdate; // indicates that the mapArchPanel needs private MapGrid mapGrid; @@ -120,21 +121,23 @@ //super("Map ["+control.getMapFileName()+"]", true, true, true, true); super(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); this.mapControl = mapControl; + final MapModel mapModel = mapControl.getMapModel(); + mapGrid = new MapGrid(mapModel.getMapSize()); + mapCursor = new MapCursor(mapGrid); + mapCursor.addMapCursorListener(this); + if (!mapControl.isPickmap()) { + mapCursor.addMapCursorListener(mainControl.getMainView().getMapTileList()); + mapCursor.addMapCursorListener(mainControl.getMainView().getStatusBar()); + } this.mainControl = mainControl; - mapGrid = new MapGrid(mapControl.getMapModel().getMapSize()); frame = fi; - highlightOn = false; needMpanelUpdate = new boolean[3]; needMpanelUpdate[0] = false; needMpanelUpdate[1] = false; needMpanelUpdate[2] = false; - mapMousePos.x = -1; - mapMousePos.y = -1; mapMouseRightPos.x = -1; mapMouseRightPos.y = -1; - mapMouseRightOff.x = 0; - mapMouseRightOff.y = 0; if (isPickmap()) { setBackground(IGUIConstants.BG_COLOR); @@ -143,6 +146,7 @@ setViewportView(renderer); getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); + mapModel.addMapModelListener(this); refreshDataFromModel(); // set the pixel increment scrolling for clicking once on a scrollbar arrow @@ -161,6 +165,8 @@ } renderer.updateLookAndFeel(); mapGrid.addMapGridListener(renderer); + renderer.setFocusable(true); + setFocusable(true); } public boolean isChanged() { @@ -171,10 +177,26 @@ changed = state; } - public Point getMapMouseRightPos() { - return mapMouseRightPos; + /** + * Get MapGrid of this view. + * @return MapGrid of this view. + */ + public MapGrid getMapGrid() { + return mapGrid; } + /** + * Get MapCursor of this view. + * @return MapCursor of this view. + */ + public MapCursor getMapCursor() { + return mapCursor; + } + + @Nullable public Point getCursorPosition() { + return mapCursor.getLocation(); + } + public boolean isPickmap() { return mapControl.isPickmap(); } @@ -193,17 +215,17 @@ } /** - * Returns whether there is a highlighted area in this MapView. + * Returns whether there is a highlighted area in this mapview. * @return <code>true</code> if there is a highlighted area, otherwise <code>false</code>. */ public boolean isHighlight() { - return highlightOn; + return mapCursor.isActive(); } /** Turn the highlight off. */ public void unHighlight() { - if (highlightOn) { - highlightOn = false; + if (mapCursor.isActive()) { + mapCursor.deactivate(); mainControl.getMainView().refreshMenus(); } @@ -240,23 +262,16 @@ } /** - * Returns the starting coordinates of the highlighted tile-selection. - * @return The starting coordinates of the highlighted tile-selection. + * This method returns the bounding rectangle of the selection + * There may be non-selected tiles in that rectangle + * This method is mainly useful for creating a submap for copy/paste operations. + * @return selected Rectangle */ - public Point getHighlightStart() { - return mapMouseRightPos; + public Rectangle getSelectionRec() { + return mapGrid.getSelectedRec(); } /** - * Returns the ending coordinates of the highlighted tile-selection. - * @return The ending coordinates of the highlighted tile-selection. - * @todo fix naming or comment: The method name suggests ending is relative to start, while the original description suggests its absolute. - */ - public Point getHighlightOffset() { - return mapMouseRightOff; - } - - /** * Highlight the tile at given coordinates (just as * if it had been selected with leftclick). Besides, the mapview is * always centered on the coordinates as far as possible. @@ -266,8 +281,6 @@ // set the highlighted spot: mapMouseRightPos.x = point.x; mapMouseRightPos.y = point.y; - mapMouseRightOff.x = 0; - mapMouseRightOff.y = 0; // set scroll position accordingly to center on target final Rectangle scrollto = new Rectangle((point.x + 1) * 32 + 16 - getViewport().getViewRect().width / 2, @@ -289,16 +302,15 @@ getViewport().setViewPosition(scrollto.getLocation()); //getViewport().scrollRectToVisible(scrollto); - if (!highlightOn) { - highlightOn = true; - mainControl.getMainView().refreshMenus(); - } - // repaint map to display selection mapControl.repaint(); mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), null); } + public void setCursorPosition(final Point cursorPosition) { + mapCursor.setLocation(cursorPosition); + } + /** * Convert the map into a png file. * @param file the file to write to @@ -426,15 +438,6 @@ return mapSize; } - public Point getMapMousePos() { - return mapMousePos; - } - - public void setMapMousePos(final Point point) { - mapMousePos.x = point.x; - mapMousePos.y = point.y; - } - /** The mouse listener for the view. */ public final class CListener extends MouseAdapter implements MouseMotionListener { @@ -444,16 +447,12 @@ private Rectangle previewRect = null; - private Point[] needRedraw = null; // array of tile coords which need to be redrawn - /** {@inheritDoc} */ @Override public void mousePressed(final MouseEvent e) { + requestFocus(); changedFlagNotify(); // set flag: map has changed final Point clickPoint = e.getPoint(); final Point mapLoc = renderer.getTileLocationAt(clickPoint, null); - needRedraw = null; - Point[] preRedraw = null; // array of tile coords which need to be redrawn - boolean needFullRepaint = false; // true if full repaint of map needed previewRect = null; if (mapLoc != null) { @@ -462,58 +461,60 @@ return; } - if (highlightOn) { - // if we had a selected rect, we must remove it: - if (Math.abs(mapMouseRightOff.x + 1) * Math.abs(mapMouseRightOff.y + 1) <= 16) { - // the rect is relatively small, so we remove it per-tile - preRedraw = calcRectRedraw(mapMouseRightPos.x, mapMouseRightPos.y, - mapMouseRightPos.x + mapMouseRightOff.x, - mapMouseRightPos.y + mapMouseRightOff.y); - paintTileArray(preRedraw); - needRedraw = null; - } else { - // the rect is big, we redraw the whole map later - needFullRepaint = true; - } - } - // right mouse button: insert arch if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) { + mapCursor.setLocation(mapLoc); insertObject(mapLoc); } else if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0) { - if (e.isShiftDown()) { - insertObject(mapLoc); - } else if (e.isControlDown()) { - deleteObject(mapLoc); - } else { + final boolean selChange = mapCursor.isActive(); + // Throw away old selection if CTRL is not pressed + if (!e.isControlDown()) { + mapCursor.deactivate(); + } + mapCursor.setLocation(mapLoc); + mapCursor.dragStart(); + if (mapCursor.isActive() && mapControl.isPickmap()) { + // an arch of a pickmap was selected + CMainControl.getInstance().showArchPanelQuickObject(mapControl.getMapModel().getMapSquare(mapLoc).getFirst()); + } + // Change edit menu if there was a selection before and has gone or the other way around + if (!(selChange == mapCursor.isActive())) { + CMainControl.getInstance().getMainView().refreshMenus(); + } + + if (!e.isShiftDown() && !e.isControlDown()) { selectTile(mapLoc); } } else { // middle mouse button: delete arch // (I intenionally used "else" here. BUTTON2_MASK seems not to work for some systems) + mapCursor.setLocation(mapLoc); deleteObject(mapLoc); } } else { + mapCursor.setLocation(mapLoc); mainControl.getMainView().setMapTileList(null, null); // for secure... } /* UndoAndRedo.getInstance(mapControl).add(new CPaintOp(previewRect, aOrigData, (short)mapControl.getSelectedTile())); */ endFill(); - - // finally redraw the map: - if (!needFullRepaint) { - // redraw only tiles that need an update - paintTileArray(preRedraw); - paintTileArray(needRedraw); - } else { - //repaint(); // redraw full map - renderer.modelChanged(); - } } /** {@inheritDoc} */ @Override public void mouseReleased(final MouseEvent event) { + final Point clickPoint = event.getPoint(); + final Point mapLoc = renderer.getTileLocationAt(clickPoint, null); + if (!mapCursor.isOnGrid(mapLoc)) { + mapCursor.dragRelease(); + } else if (event.isShiftDown()) { + mapCursor.dragSelect(MapGrid.SelectionMode.FLIP); + } else if (event.isControlDown()) { + mapCursor.dragSelect(MapGrid.SelectionMode.SUB); + } else { + mapCursor.dragSelect(MapGrid.SelectionMode.ADD); + } + final int buttonNr; // Number of released mouse button if (event.getModifiers() == InputEvent.BUTTON1_MASK) { @@ -546,7 +547,6 @@ /** {@inheritDoc} */ public void mouseDragged(final MouseEvent event) { changedFlagNotify(); - Point[] needRedraw = null; // array of tile coords which need to be redrawn final Point dragPoint = event.getPoint(); // Mouse pointer Point temp = renderer.getTileLocationAt(dragPoint, null); // tile under Mouse pointer @@ -554,65 +554,45 @@ temp = new Point(-1, -1); } - if (event.getModifiers() == InputEvent.BUTTON1_MASK) { + if ((event.getModifiers() & InputEvent.BUTTON1_MASK) != 0) { // Left Mouse Button: Selected area gets highlighted - // Update offset (from starting-dragpoint) only when mouse moved - // over new tile and mouse is still on the map - if (temp.x != -1 && temp.y != -1 && (mapMouseRightOff.x != temp.x - mapMouseRightPos.x || mapMouseRightOff.y != temp.y - mapMouseRightPos.y)) { - // update offset and redraw mapview - mapMouseRightOff.x = temp.x - mapMouseRightPos.x; - mapMouseRightOff.y = temp.y - mapMouseRightPos.y; + mapCursor.dragTo(temp); + } else if ((event.getModifiers() & InputEvent.BUTTON3_MASK) != 0) { + mapCursor.setLocation(temp); - renderer.modelChanged(); - } - } else if (event.getModifiers() == InputEvent.BUTTON3_MASK) { // Right Mouse Button: Arches get inserted all the way - if (temp.x != mapMouseRightPos.x || mapMouseRightPos.y != temp.y) { - mapMouseRightPos.x = temp.x; - mapMouseRightPos.y = temp.y; - - if (temp.x == -1 || temp.y == -1) { - mainControl.getMainView().setMapTileList(null, null); - } else { - needRedraw = mapControl.insertSelArchToMap(temp, false); - needMpanelUpdate[2] = true; // when dragging is done, update map panel - } + if (temp.x == -1 || temp.y == -1) { + mainControl.getMainView().setMapTileList(null, null); + } else { + mapControl.insertSelArchToMap(temp, false); } } else { + mapCursor.setLocation(temp); + // Middle Mouse Button: Arches get deleted all the way - if (temp.x != mapMouseRightPos.x || mapMouseRightPos.y != temp.y) { - mapMouseRightPos.x = temp.x; - mapMouseRightPos.y = temp.y; + if (temp.x == -1 || temp.y == -1) { + mainControl.getMainView().setMapTileList(null, null); + } else { + // delete the topmost arch (matching the view settings) + // on that square and redraw the map + GameObject tmpArch = null; + final Iterator<GameObject> it = mapControl.getMapModel().getMapSquare(temp).reverse().iterator(); + for (final GameObject gameObject : mapControl.getMapModel().getMapSquare(temp).reverse()) { + tmpArch = gameObject; - if (temp.x == -1 || temp.y == -1) { - mainControl.getMainView().setMapTileList(null, null); - } else { - // delete the topmost arch (matching the view settings) - // on that square and redraw the map - GameObject tmpArch = null; - final Iterator<GameObject> it = mapControl.getMapModel().getMapSquare(temp).reverse().iterator(); - for (final GameObject gameObject : mapControl.getMapModel().getMapSquare(temp).reverse()) { - tmpArch = gameObject; - - // now search backwards for matching view settings - if (mainControl.getTileEdit() == 0 || mainControl.isTileEdit(tmpArch.getEditType())) { - break; - } + // now search backwards for matching view settings + if (mainControl.getTileEdit() == 0 || mainControl.isTileEdit(tmpArch.getEditType())) { + break; } - if (tmpArch != null) { - needRedraw = mapControl.calcArchRedraw(tmpArch); // get redraw info - mapControl.deleteMapArch(tmpArch, temp, false, MapModel.JOIN_ENABLE); - } - - needMpanelUpdate[1] = true; // when dragging is done, update map panel } + if (tmpArch != null) { + mapControl.calcArchRedraw(tmpArch); // get redraw info + mapControl.deleteMapArch(tmpArch, temp, false, MapModel.JOIN_ENABLE); + } } } - - // finally redraw all map-squares that need an update - paintTileArray(needRedraw); } private void insertObject(final Point mapLoc) { @@ -623,22 +603,14 @@ previewRect.height = 1; startMapLoc = mapLoc; - if (highlightOn && !mapControl.isPickmap()) { - highlightOn = false; // no longer highlighting tiles - mainControl.getMainView().refreshMenus(); - } - if (mapLoc.x != -1 && mapLoc.y != -1) { if (mapControl.isPickmap()) { // insert on pickmap - needRedraw = insertMapArchToPickmap(mapLoc); + insertMapArchToPickmap(mapLoc); } else { // insert on normal map - mapMouseRightPos.x = mapLoc.x; - mapMouseRightPos.y = mapLoc.y; + mapControl.insertSelArchToMap(mapLoc, true); - needRedraw = mapControl.insertSelArchToMap(mapLoc, true); - // get name of inserted arch (this is display in status bar while dragging) @Nullable final GameObject insArch = mainControl.getArchPanelHighlight(); final String insertArchName; @@ -662,56 +634,22 @@ } private void selectTile(final Point mapLoc) { - // left mouse button: select tiles - mapMouseRightPos.x = mapLoc.x; // position of selected tile - mapMouseRightPos.y = mapLoc.y; - mapMouseRightOff.x = 0; // dragging offset - mapMouseRightOff.y = 0; - if (mapLoc.x == -1 || mapLoc.y == -1) { if (!mapControl.isPickmap()) { mainControl.getMainView().setMapTileList(null, null); - - if (highlightOn) { - highlightOn = false; - mainControl.getMainView().refreshMenus(); - } } } else { if (!mapControl.isPickmap()) { mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), null); } - if (!highlightOn) { - highlightOn = true; // highlight the selected area - mainControl.getMainView().refreshMenus(); - } - // paint the highlight-icon renderer.setHighlightTile(/*((JComponent)renderer).getGraphics(), */mapLoc); - - if (mapControl.isPickmap()) { - final GameObject arch = mapControl.getBottomArchObject(mapLoc); - if (arch != null) { - // an arch of a pickmap was selected - mainControl.showArchPanelQuickObject(arch); - } - } } } private void deleteObject(final Point mapLoc) { - if (highlightOn && !mapControl.isPickmap()) { - highlightOn = false; // no longer highlighting tiles - mainControl.getMainView().refreshMenus(); - } - if (mapLoc.x != -1 && mapLoc.y != -1) { - if (!mapControl.isPickmap()) { - mapMouseRightPos.x = mapLoc.x; - mapMouseRightPos.y = mapLoc.y; - } - // delete the topmost arch (matching the view settings) on that square // and redraw the map GameObject tmpArch = null; @@ -723,7 +661,7 @@ } } if (tmpArch != null) { - needRedraw = mapControl.calcArchRedraw(tmpArch); // get redraw info + mapControl.calcArchRedraw(tmpArch); // get redraw info mapControl.deleteMapArch(tmpArch, mapLoc, false, MapModel.JOIN_ENABLE); // update mapArch panel @@ -735,14 +673,10 @@ /** * This method is only called for pickmaps. Take the currently * highlighted arch on the map (if any) and insert it on this pickmap. - * Redraw info is stored to 'needRedraw', no views get redrawn/updated - * here. * @param pos tile-coordinates in pickmap * @return array of coordinates for tiles that need to be redrawn */ - private Point[] insertMapArchToPickmap(final Point pos) { - Point[] needRedraw = null; // returned array of points which need redraw - + private void insertMapArchToPickmap(final Point pos) { final MapControl currentMap = mainControl.getCurrentMap(); // insertion is only allowed for valid *empty* squares if (currentMap != null && mapControl.isPickmap() && mapControl.isPointValid(pos) && !mapControl.containsArchObject(pos)) { @@ -753,7 +687,7 @@ // insert single tile from pickmap newarch = newarch.createClone(pos.x, pos.y); mapControl.addArchObjectToMap(newarch); - needRedraw = mapControl.calcArchRedraw(newarch); + mapControl.calcArchRedraw(newarch); } else { // insert multi tile from pickmap: newarch = newarch.getHead(); @@ -782,14 +716,12 @@ newdef.resetMsgText(); newdef.addMsgText(newarch.getMsgText()); - needRedraw = mapControl.calcArchRedraw(newdef); + mapControl.calcArchRedraw(newdef); } } } } } - - return needRedraw; } void endFill() { @@ -803,6 +735,24 @@ } } + /** {@inheritDoc} */ + public void mapSizeChanged(final MapModelEvent e) { + mapGrid.resize(e.getMapModel().getMapSize()); + refreshDataFromModel(); + } + + /** {@inheritDoc} */ + public void mapSquaresChanged(final MapModelEvent e) { + modelChanged(); + // TODO: only repaint a specific region + } + + /** {@inheritDoc} */ + public void mapObjectsChanged(final MapModelEvent e) { + modelChanged(); + // TODO: only repaint a specific region + } + public final class CPaintOp implements EditOperation { final Rectangle fillRect; @@ -853,4 +803,18 @@ } } + /** {@inheritDoc} */ + public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { + final MapCursor mapCursor = e.getSource(); + if (mapCursor.isActive()) { + final Rectangle rec = renderer.getTileBounds(mapCursor.getLocation()); + renderer.scrollRectToVisible(rec); + } + } + + /** {@inheritDoc} */ + public void mapCursorChangedMode(@NotNull final MapCursorEvent e) { + // Ignore mode change events + } + } // class CMapViewBasic Modified: trunk/crossfire/src/cfeditor/CopyBuffer.java =================================================================== --- trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-16 21:22:20 UTC (rev 1114) +++ trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-16 21:30:26 UTC (rev 1115) @@ -139,26 +139,11 @@ * @param mode defines if we have a cut, copy or paste action */ private void copyNCut(final MapControl mapControl, final Mode mode) { - final Point startp = mapControl.getMapViewFrame().getHighlightStart(); // start of highlighted rect - final Point offset = mapControl.getMapViewFrame().getHighlightOffset(); // offset of rect from startp - - if (!mapControl.getMapViewFrame().isHighlight()) { - return; // should actually never happen + final Rectangle selRec = mapControl.getMapGrid().getSelectedRec(); + if (selRec == null) { + return; } - // convert negative 'offset' into positive by flipping 'startp' - if (offset.x < 0) { - startp.x += offset.x; - offset.x = Math.abs(offset.x); - } - if (offset.y < 0) { - startp.y += offset.y; - offset.y = Math.abs(offset.y); - } - - final Rectangle selRec = new Rectangle(startp.x, startp.y, offset.x, offset.y); - assert selRec != null; - // Prepare the buffer (if it's a cut or copy) if (mode == Mode.DO_CUT || mode == Mode.DO_COPY) { if (empty) { @@ -167,8 +152,8 @@ } // recycle and resize buffer - bufWidth = Math.abs(offset.x) + 1; // new width - bufHeight = Math.abs(offset.y) + 1; // new height + bufWidth = Math.abs(selRec.width) + 1; // new width + bufHeight = Math.abs(selRec.height) + 1; // new height mapArch.setMapSize(new Size2D(bufWidth, bufHeight)); copyMap = null; // free objects (at least that is the plan and theory) copyMapCtrl = null; @@ -180,8 +165,8 @@ final Point pos = new Point(); mapControl.getMapModel().beginTransaction("Cut / Clear"); // TODO: I18N/L10N final HashSet<GameObject> gameObjectsToDelete = new HashSet<GameObject>(); - for (pos.x = startp.x; pos.x - startp.x <= offset.x; pos.x++) { - for (pos.y = startp.y; pos.y - startp.y <= offset.y; pos.y++) { + for (pos.x = selRec.x; pos.x - selRec.x <= selRec.width; pos.x++) { + for (pos.y = selRec.y; pos.y - selRec.y <= selRec.height; pos.y++) { // do the copying for one tile position: for (final GameObject gameObject : mapControl.getMapModel().getMapSquare(pos)) { // store a clone of the gameObject in the CopyBuffer @@ -189,7 +174,7 @@ // arches that don't match the view settings are ignored! if ((mode == Mode.DO_CUT || mode == Mode.DO_COPY) && gameObject.isHead() && !gameObject.isInContainer() && (mainControl.getTileEdit() == 0 || mainControl.isTileEdit(gameObject.getEditType()))) { // copy this gameObject - final GameObject clone = gameObject.createClone(pos.x - startp.x, pos.y - startp.y); + final GameObject clone = gameObject.createClone(pos.x - selRec.x, pos.y - selRec.y); assert copyMapCtrl != null; copyMapCtrl.addArchObjectToMap(clone); } @@ -223,14 +208,12 @@ /** * Excecuting the Paste command. * @param mapControl MapControl of the active map we paste on + * @todo paste only subregions when a region is selected */ public void paste(final MapControl mapControl) { - final Point startp = mapControl.getMapViewFrame().getHighlightStart(); // start of highlighted rect + final Point startp = mapControl.getMapCursor().getLocation(); + assert startp != null; - if (!mapControl.getMapViewFrame().isHighlight()) { - return; // should actually never happen - } - // cycle through all tile coordinates which are highlighted: mapControl.getMapModel().beginTransaction("Paste"); // TODO: I18N/L10N final Point pos = new Point(); @@ -283,8 +266,8 @@ * @todo the fill density is ignored for floodfill */ public void fill(final MapControl mapControl, final boolean fillBelow, final int density) { - final Point startp = mapControl.getMapViewFrame().getHighlightStart(); // start of highlighted rect - final Point offset = mapControl.getMapViewFrame().getHighlightOffset(); // offset of rect from startp + final Rectangle selRec = mapControl.getMapGrid().getSelectedRec();; + final Point cursor = mapControl.getMapViewFrame().getView().getCursorPosition(); final Point pos = new Point(); if (!mapControl.getMapViewFrame().isHighlight()) { @@ -295,31 +278,20 @@ return; } - // If offset is zero and map-spot empty, a floodfill is done + // If selection is empty and map-spot empty, a floodfill is done final GameObject arch; - if (offset.x == 0 && offset.y == 0 && !mapControl.containsArchObject(startp)) { + if ((selRec == null || (selRec.x == 0 && selRec.height == 0)) && !mapControl.containsArchObject(cursor)) { arch = mainControl.getArchPanelHighlight(); if (arch != null) { - floodfill(mapControl, startp.x, startp.y, arch); + floodfill(mapControl, cursor.x, cursor.y, arch); } } else { - // Rectangular fill: - // convert negative 'offset' into positive by flipping 'startp' - if (offset.x < 0) { - startp.x += offset.x; - offset.x = Math.abs(offset.x); - } - if (offset.y < 0) { - startp.y += offset.y; - offset.y = Math.abs(offset.y); - } - // get the arch to fill with arch = mainControl.getArchPanelHighlight(); // cycle through all tile coordinates which are highlighted: - for (pos.x = startp.x; pos.x - startp.x <= offset.x; pos.x++) { - for (pos.y = startp.y; pos.y - startp.y <= offset.y; pos.y++) { + for (pos.x = selRec.x; pos.x - selRec.x <= selRec.width; pos.x++) { + for (pos.y = selRec.y; pos.y - selRec.y <= selRec.height; pos.y++) { if (density != -1 && density != 100 && density < MainControl.rnd.nextInt(100) + 1) { continue; } Modified: trunk/crossfire/src/cfeditor/IGUIConstants.java =================================================================== --- trunk/crossfire/src/cfeditor/IGUIConstants.java 2006-12-16 21:22:20 UTC (rev 1114) +++ trunk/crossfire/src/cfeditor/IGUIConstants.java 2006-12-16 21:30:26 UTC (rev 1115) @@ -214,6 +214,8 @@ String TILE_SEL_TILE = "seltile.png"; + String TILE_CURSOR = "cursor.png"; + String TILE_UNKNOWN = "unknown.png"; String TILE_NOFACE = "noface.png"; @@ -243,6 +245,14 @@ int BOTTOM = 5; + int NORTH_EAST = 4; + + int SOUTH_EAST = 5; + + int SOUTH_WEST = 6; + + int NORTH_WEST = 7; + int DIRECTIONS = 6; } // interface IGUIConstants Modified: trunk/crossfire/src/cfeditor/MapViewIFrame.java =================================================================== --- trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-16 21:22:20 UTC (rev 1114) +++ trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-16 21:30:26 UTC (rev 1115) @@ -111,10 +111,6 @@ // following a bunch of wrapper methods which just pass access // to the basic mapview object 'view': - public Point getMapMouseRightPos() { - return view.getMapMouseRightPos(); - } - public JViewport getViewPort() { return view.getViewport(); } @@ -159,14 +155,6 @@ view.closeNotify(); } - public Point getHighlightStart() { - return view.getHighlightStart(); - } - - public Point getHighlightOffset() { - return view.getHighlightOffset(); - } - public void setHotspot(final Point point) { view.setHotspot(point); } @@ -226,6 +214,10 @@ view.freeMap(); } + public CMapViewBasic getView() { + return view; + } + /** Action class for selecting this window. */ public final class WindowAction extends AbstractAction { Modified: trunk/crossfire/src/cfeditor/ReplaceDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/ReplaceDialog.java 2006-12-16 21:22:20 UTC (rev 1114) +++ trunk/crossfire/src/cfeditor/ReplaceDialog.java 2006-12-16 21:30:26 UTC (rev 1115) @@ -28,6 +28,7 @@ import cfeditor.map.MapControl; import java.awt.FlowLayout; import java.awt.Point; +import java.awt.Rectangle; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.ArrayList; @@ -294,20 +295,11 @@ final Size2D mapSize = mapControl.getMapSize(); offset = new Point(mapSize.getWidth() - 1, mapSize.getHeight() - 1); } else { - startp = mapControl.getMapViewFrame().getHighlightStart(); // start of highlighted rect - offset = mapControl.getMapViewFrame().getHighlightOffset(); // offset of rect from startp + final Rectangle selRec = mapControl.getMapGrid().getSelectedRec(); + startp = new Point(selRec.x, selRec.y); + offset = new Point(selRec.width, selRec.height); } - // convert negative 'offset' into positive by flipping 'startp' - if (offset.x < 0) { - startp.x += offset.x; - offset.x = Math.abs(offset.x); - } - if (offset.y < 0) { - startp.y += offset.y; - offset.y = Math.abs(offset.y); - } - // cycle through all tile coordinates between startpoint and offset: final Point pos = new Point(); int replaceCount = 0; Modified: trunk/crossfire/src/cfeditor/action.properties =================================================================== --- trunk/crossfire/src/cfeditor/action.properties 2006-12-16 21:22:20 UTC (rev 1114) +++ trunk/crossfire/src/cfeditor/action.properties 2006-12-16 21:30:26 UTC (rev 1115) @@ -7,11 +7,12 @@ ######## # Menus -main.menubar=file edit map pickmaps resources tools analyze view plugins window help +main.menubar=file edit map cursor pickmaps resources tools analyze view plugins window help file.menu=createNew open close - save saveAs revert createImg - options - exit edit.menu=clear cut copy paste - replace fillAbove fillBelow randFillAbove randFillBelow map.menu=autoJoin - gridVisible enterExit enterNorthMap enterEastMap enterSouthMap enterWestMap enterUpperMap enterLowerMap tileShow - mapProperties +cursor.menu=moveCursor - selectTile startStopDrag addToSelection subFromSelection releaseDrag - insertArch deleteArch - selectArchAbove selectArchBelow - archAttributes pickmaps.menu=lockAllPickmaps - addNewPickmap closePickmap - openPickmapMap - savePickmap revertPickmap resources.menu=collectArches collectSpells - viewTreasurelists tools.menu=gc @@ -21,11 +22,12 @@ window.menu=closeAll help.menu=onlineHelp about -mapwindow.menubar=mapwindowFile mapwindowEdit mapwindowMap mapwindowView +mapwindow.menubar=mapwindowFile mapwindowEdit mapwindowMap mapwindowCursor mapwindowView mapwindowFile.menu=save saveAs createImg - revert - close mapwindowEdit.menu=clear cut copy paste - replace fillAbove fillBelow randFillAbove randFillBelow mapwindowMap.menu=autoJoin - gridVisible enterExit enterNorthMap enterEastMap enterSouthMap enterWestMap enterUpperMap enterLowerMap tileShow - mapProperties +mapwindowCursor.menu=moveCursor - selectTile startStopDrag addToSelection subFromSelection releaseDrag - insertArch deleteArch - selectArchAbove selectArchBelow - archAttributes mapwindowView.menu=showMonster showExit showBackground showDoor showWall showEquipment showTreasure showConnected resetView ####### @@ -72,6 +74,10 @@ mapProperties.icon=general/Properties16 + +moveCursor.menu=goNorth goEast goSouth goWest goNorthEast goSouthEast goSouthWest goNorthWest + + addNewPickmap.icon=general/New16 closePickmap.icon=EmptySmallIcon Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-16 21:22:20 UTC (rev 1114) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-16 21:30:26 UTC (rev 1115) @@ -59,7 +59,7 @@ /** * The component that does the actual rendering of tiles in the palette. * Flat version. - * @author unknown (probably Ragnor) +b * @author unknown (probably Ragnor) */ public final class DefaultLevelRenderer extends LevelRenderer implements MapGridListener { @@ -132,6 +132,8 @@ } tmpIcon = new ImageIcon(); + setFocusable(true); + borderOffset = !pickmap ? 32 : 0; renderTransform = new AffineTransform(1.0f, 0.0f, 0.0f, 1.0f, (float) borderOffset, (float) borderOffset); highLightMask = new Color[]{ @@ -209,7 +211,22 @@ } } + private final Rectangle tmpRec = new Rectangle(); + /** + * Get coordinates, length and width of map tile. + * @param p Map coordinates + * @return Boundary rectangle of tile + */ + public Rectangle getTileBounds(final Point p) { + tmpRec.x = borderOffset + p.x * 32; + tmpRec.y = borderOffset + p.y * 32; + tmpRec.width = 32; + tmpRec.height = 32; + return tmpRec; + } + + /** * Paints this component. * @param grfx The graphics context to paint to. * @param isSnapshot true when this drawing is for a @@ -394,63 +411,16 @@ * @param grfx graphics context to draw in */ public void paintHighlightTile(final Graphics grfx, final Point point) { - // if tile is highlighted, draw the highlight icon: - if (mapViewBasic.isHighlight() && mapViewBasic.getMapMouseRightPos().y != -1 && mapViewBasic.getMapMouseRightPos().x != -1) { - // get rect. coords of highlighted area: top(left) and bot(tomright) corner - final int topx = Math.min(mapViewBasic.getMapMouseRightPos().x, mapViewBasic.getMapMouseRightPos().x + mapViewBasic.getHighlightOffset().x); - final int topy = Math.min(mapViewBasic.getMapMouseRightPos().y, mapViewBasic.getMapMouseRightPos().y + mapViewBasic.getHighlightOffset().y); - final int botx = Math.max(mapViewBasic.getMapMouseRightPos().x, mapViewBasic.getMapMouseRightPos().x + mapViewBasic.getHighlightOffset().x); - final int boty = Math.max(mapViewBasic.getMapMouseRightPos().y, mapViewBasic.getMapMouseRightPos().y + mapViewBasic.getHighlightOffset().y); - - // Highlight the selected square - if (point.x >= topx && point.x <= botx && point.y >= topy && point.y <= boty) { - CMainControl.getMapSelIcon().paintIcon(this, grfx, point.x * 32, point.y * 32); - } + final int gridFlags = mapGrid.getFlags(point.x, point.y); + if ((gridFlags & MapGrid.GRID_FLAG_SELECTING) != 0) { + CMainControl.getMapSelIcon().paintIcon(this, grfx, point.x * 32, point.y * 32); } - } - - /** - * Paints the highlighted (selected) area on the map. - * - * @param grfx graphics context of mapview - */ - public void paintHighlightArea(final Graphics grfx) { - final int signX, signY; // sign = "direction" of the dragging offset - - if (mapViewBasic.getHighlightOffset().x > 0) { - signX = 1; - } else if (mapViewBasic.getHighlightOffset().x < 0) { - signX = -1; - } else { - signX = 0; + if ((gridFlags & MapGrid.GRID_FLAG_SELECTION) != 0) { + CMainControl.getMapSelIcon().paintIcon(this, grfx, point.x * 32, point.y * 32); } - - if (mapViewBasic.getHighlightOffset().y > 0) { - signY = 1; - } else if (mapViewBasic.getHighlightOffset().y < 0) { - signY = -1; - } else { - signY = 0; + if ((gridFlags & MapGrid.GRID_FLAG_CURSOR) != 0) { + CMainControl.getMapCursorIcon().paintIcon(this, grfx, point.x * 32, point.y * 32); } - - // Highlight all tiles that are in the rectangle between drag-start and mouse - for (int posx = mapViewBasic.getMapMouseRightPos().x; Math.abs(posx - mapViewBasic.getMapMouseRightPos().x) - <= Math.abs(mapViewBasic.getHighlightOffset().x); posx += signX) { - for (int posy = mapViewBasic.getMapMouseRightPos().y; Math.abs(posy - mapViewBasic.getMapMouseRightPos().y) - <= Math.abs(mapViewBasic.getHighlightOffset().y); posy += signY) { - // Draw the Icon: - - // Rectangular view - CMainControl.getMapSelIcon().paintIcon(this, grfx, posx * 32 + borderOffset, posy * 32 + borderOffset); - - if (signY == 0) { - break; - } - } - if (signX == 0) { - break; - } - } } /** @@ -459,9 +429,21 @@ * @param grfx Graphics for painting */ private void paintSelection(final Graphics2D grfx) { - if (mapViewBasic.isHighlight() && mapViewBasic.getMapMouseRightPos().y != -1 && mapViewBasic.getMapMouseRightPos().x != -1) { - // Highlight the selected area - paintHighlightArea(grfx); + for (int y = 0; y < mapSize.getHeight(); y++) { + for (int x = 0; x < mapSize.getWidth(); x++) { + if (grfx.hitClip(x * 32 + borderOffset, y * 32 + borderOffset, 32, 32)) { + final int gridFlags = mapGrid.getFlags(x, y); + if ((gridFlags & MapGrid.GRID_FLAG_SELECTION) != 0) { + CMainControl.getMapSelIcon().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); + } + if ((gridFlags & MapGrid.GRID_FLAG_SELECTING) != 0) { + CMainControl.getMapSelIcon().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); + } + if ((gridFlags & MapGrid.GRID_FLAG_CURSOR) != 0) { + CMainControl.getMapCursorIcon().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); + } + } + } } } @@ -497,16 +479,17 @@ renderTransform.inverseTransform(point, point); } catch (final NoninvertibleTransformException e) { } - mapViewBasic.setMapMousePos(new Point(-1, -1)); final Size2D mapSize = mapViewBasic.getMapControl().getMapSize(); + final int xm, ym; if (point.x >= 0 && point.x < mapSize.getWidth() * 32 && point.y >= 0 && point.y < mapSize.getHeight() * 32) { - mapViewBasic.setMapMousePos(new Point(point.x / 32, point.y / 32)); + xm = point.x / 32; + ym = point.y / 32; + } else { + xm = -1; + ym = -1; } - final int xm = mapViewBasic.getMapMousePos().x; - final int ym = mapViewBasic.getMapMousePos().y; - if (xm < 0 || xm >= mapSize.getWidth() || ym < 0 || ym >= mapSize.getHeight()) { return null; } @@ -520,13 +503,13 @@ /** {@inheritDoc} */ public void mapGridChanged(@NotNull final MapGridEvent e) { - repaint(); + modelChanged(); } /** {@inheritDoc} */ public void mapGridResized(@NotNull final MapGridEvent e) { mapSize = e.getSource().getSize(); - repaint(); + modelChanged(); } @Override public boolean resizeBackBuffer() { Added: trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java (rev 0) +++ trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java 2006-12-16 21:30:26 UTC (rev 1115) @@ -0,0 +1,213 @@ +/* + * Daimonin Java Editor. + * Copyright (C) 2006 Daniel Viegas + * + * 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + */ + +package cfeditor.gui.map; + +import cfeditor.CMainControl; +import cfeditor.CMainView; +import cfeditor.CMapTileList; +import cfeditor.IGUIConstants; +import cfeditor.gameobject.GameObject; +import cfeditor.map.MapControl; +import java.awt.Point; +import net.sf.gridarta.gui.map.MapCursor; +import net.sf.gridarta.gui.map.MapGrid; + +/** + * This class processes events from the cursor menu. + * Moving the cursor, selecting map tiles/arches, inserting/deleting arches and open arch property dialog is supported. + * @author <a href="mailto:dlv...@gm...">Daniel Viegas</a> + */ +public class MapCursorControl { + + /** The MainControl. */ + private final CMainControl mainControl; + + /** + * Create a MapCursorControl. + * @param mainControl MainControl to use (used for getting the current map etc.) + */ + public MapCursorControl(final CMainControl mainControl) { + this.mainControl = mainControl; + } + + /** + * Move cursor to specified direction. + * @param dir Constants in #IGUIConstants + */ + public void goTo(final int dir) { + final MapCursor mapCursor = getMapCursor(); + if (mapCursor.isActive()) { + mapCursor.goTo(dir); + } else { + mapCursor.setLocation(new Point(0, 0)); + } + } + + public void goNorth() { + goTo(IGUIConstants.NORTH); + } + + public void goSouth() { + goTo(IGUIConstants.SOUTH); + } + + public void goEast() { + goTo(IGUIConstants.EAST); + } + + public void goWest() { + goTo(IGUIConstants.WEST); + } + + public void goNorthEast() { + goTo(IGUIConstants.NORTH_EAST); + } + + public void goNorthWest() { + goTo(IGUIConstants.NORTH_WEST); + } + + public void goSouthEast() { + goTo(IGUIConstants.SOUTH_EAST); + } + + public void goSouthWest() { + goTo(IGUIConstants.SOUTH_WEST); + } + + public void selectTile() { + selectTile(MapGrid.SelectionMode.FLIP); + } + + public void addToSelection() { + selectTile(MapGrid.SelectionMode.ADD); + } + + public void subFromSelection() { + selectTile(MapGrid.SelectionMode.SUB); + } + + public void insertArch() { + final MapControl mapControl = mainControl.getCurrentMap(); + assert mapControl != null; + final MapCursor mapCursor = mapControl.getMapCursor(); + assert mapCursor != null; + if (mapCursor.isActive()) { + mapControl.insertSelArchToMap(mapCursor.getLocation(), true); + mainControl.getMain... [truncated message content] |
From: <aki...@us...> - 2006-12-16 21:22:20
|
Revision: 1114 http://svn.sourceforge.net/gridarta/?rev=1114&view=rev Author: akirschbaum Date: 2006-12-16 13:22:20 -0800 (Sat, 16 Dec 2006) Log Message: ----------- Fix messages. Modified Paths: -------------- trunk/daimonin/src/daieditor/messages.properties Modified: trunk/daimonin/src/daieditor/messages.properties =================================================================== --- trunk/daimonin/src/daieditor/messages.properties 2006-12-16 19:24:03 UTC (rev 1113) +++ trunk/daimonin/src/daieditor/messages.properties 2006-12-16 21:22:20 UTC (rev 1114) @@ -377,6 +377,7 @@ mapProperties.mnemonic=M mapProperties.accel=ctrl pressed M + ####### # Cursor @@ -424,21 +425,22 @@ releaseDrag.text=Release Selection releaseDrag.accel=BACK_SPACE -insertArch.text=Insert Arch +insertArch.text=Insert Object insertArch.accel=NUMPAD0 -deleteArch.text=Delete Arch +deleteArch.text=Delete Object deleteArch.accel=DECIMAL -selectArchAbove.text=Select Arch above +selectArchAbove.text=Select Object above selectArchAbove.accel=DIVIDE -selectArchBelow.text=Select Arch below +selectArchBelow.text=Select Object below selectArchBelow.accel=MULTIPLY -archAttributes.text=Arch Attributes +archAttributes.text=Object Attributes archAttributes.accel=ENTER + ########### # Pickmaps This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-16 19:24:03
|
Revision: 1113 http://svn.sourceforge.net/gridarta/?rev=1113&view=rev Author: akirschbaum Date: 2006-12-16 11:24:03 -0800 (Sat, 16 Dec 2006) Log Message: ----------- Fix comments. Modified Paths: -------------- trunk/daimonin/src/daieditor/CMapViewBasic.java Modified: trunk/daimonin/src/daieditor/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-12-16 19:21:11 UTC (rev 1112) +++ trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-12-16 19:24:03 UTC (rev 1113) @@ -155,14 +155,16 @@ setFocusable(true); } - /** Get MapGrid of this view. + /** + * Get MapGrid of this view. * @return MapGrid of this view. */ public MapGrid getMapGrid() { return mapGrid; } - /** Get MapCursor of this view. + /** + * Get MapCursor of this view. * @return MapCursor of this view. */ public MapCursor getMapCursor() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-16 19:21:11
|
Revision: 1112 http://svn.sourceforge.net/gridarta/?rev=1112&view=rev Author: akirschbaum Date: 2006-12-16 11:21:11 -0800 (Sat, 16 Dec 2006) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/daimonin/src/daieditor/CMapViewBasic.java Modified: trunk/daimonin/src/daieditor/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-12-16 13:32:37 UTC (rev 1111) +++ trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-12-16 19:21:11 UTC (rev 1112) @@ -169,10 +169,6 @@ return mapCursor; } - public Point getMapMouseRightPos() { - return mapCursor.getLocation(); - } - public boolean isPickmap() { return mapControl.isPickmap(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-16 13:32:36
|
Revision: 1111 http://svn.sourceforge.net/gridarta/?rev=1111&view=rev Author: akirschbaum Date: 2006-12-16 05:32:37 -0800 (Sat, 16 Dec 2006) Log Message: ----------- Add comments. Modified Paths: -------------- trunk/daimonin/src/daieditor/CMapViewBasic.java Modified: trunk/daimonin/src/daieditor/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-12-16 13:29:52 UTC (rev 1110) +++ trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-12-16 13:32:37 UTC (rev 1111) @@ -442,6 +442,7 @@ //} // class CPaintOp + /** {@inheritDoc} */ public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { final MapCursor mapCursor = e.getSource(); if (mapCursor.isActive()) { @@ -450,6 +451,7 @@ } } + /** {@inheritDoc} */ public void mapCursorChangedMode(@NotNull final MapCursorEvent e) { // Ignore mode change events } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-16 13:29:52
|
Revision: 1110 http://svn.sourceforge.net/gridarta/?rev=1110&view=rev Author: akirschbaum Date: 2006-12-16 05:29:52 -0800 (Sat, 16 Dec 2006) Log Message: ----------- Move code into separate functions. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-16 11:52:00 UTC (rev 1109) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-16 13:29:52 UTC (rev 1110) @@ -284,27 +284,10 @@ archlist.getFace(node.getFaceNr()).paintIcon(this, grfx, node.getMapX() * 32 + borderOffset, node.getMapY() * 32 + borderOffset); } - // grid lines - if (mapViewBasic.isGridVisible() && !isSnapshot) { - for (int x = 0; x <= mapGrid.getSize().getWidth(); x++) { - grfx.drawLine( - x * 32 + borderOffset, - borderOffset, - x * 32 + borderOffset, - mapGrid.getSize().getHeight() * 32 + borderOffset); - } - for (int y = 0; y <= mapGrid.getSize().getHeight(); y++) { - grfx.drawLine( - borderOffset, - y * 32 + borderOffset, - mapGrid.getSize().getWidth() * 32 + borderOffset, - y * 32 + borderOffset); - } + if (!isSnapshot) { + paintGrid(grfx); + paintSelection(grfx); } - if (mapViewBasic.isHighlight() && mapViewBasic.getMapMouseRightPos().y != -1 && mapViewBasic.getMapMouseRightPos().x != -1 && !isSnapshot) { - // Highlight the selected area - paintHighlightArea(grfx); - } } /** @@ -470,6 +453,44 @@ } } + /** + * Paints the selection. + * It's recommended to paint the complete selection after the map itself, otherwise map elements actually might hide selections. + * @param grfx Graphics for painting + */ + private void paintSelection(final Graphics2D grfx) { + if (mapViewBasic.isHighlight() && mapViewBasic.getMapMouseRightPos().y != -1 && mapViewBasic.getMapMouseRightPos().x != -1) { + // Highlight the selected area + paintHighlightArea(grfx); + } + } + + /** + * Paints the grid if desired. + * The grid is not painted if <code><var>gridVisibility</var></code> is <code>false</code>. + * It's recommended to paint the complete grid after the map itself, otherwise map elements actually might hide parts of the grid. + * @param grfx Graphics for painting + */ + private void paintGrid(final Graphics grfx) { + // grid lines + if (mapViewBasic.isGridVisible()) { + for (int x = 0; x <= mapGrid.getSize().getWidth(); x++) { + grfx.drawLine( + x * 32 + borderOffset, + borderOffset, + x * 32 + borderOffset, + mapGrid.getSize().getHeight() * 32 + borderOffset); + } + for (int y = 0; y <= mapGrid.getSize().getHeight(); y++) { + grfx.drawLine( + borderOffset, + y * 32 + borderOffset, + mapGrid.getSize().getWidth() * 32 + borderOffset, + y * 32 + borderOffset); + } + } + } + /** {@inheritDoc} */ @Override @Nullable public Point getTileLocationAt(@NotNull final Point point, @Nullable final Point retPoint) { try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |