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. |