splitted OnAppBarUserResponse() and code that remaps tiles.
authorMiloš Klouček <m.kloucek.m@atlas.cz>
Sat, 16 Aug 2008 17:30:58 +0000 (17:30 +0000)
committerMiloš Klouček <m.kloucek.m@atlas.cz>
Sat, 16 Aug 2008 17:30:58 +0000 (17:30 +0000)
SVN-Revision: 5728

tools/tilemanager/Application.cs

index dfc1bed..4592200 100644 (file)
@@ -277,27 +277,36 @@ public class Application {
                 ShowException(exception);
                 return;
             }
-            foreach(Tile tile in Selection) {
-                if(tile.ID == -1)
-                    continue;
-
-                int oldid = tile.ID;
-                tile.ID = id++;
-                // remap in all tilegroups...
-                foreach(TileGroup tilegroup in tileset.TileGroups) {
-                    int idx = tilegroup.Tiles.IndexOf(oldid);
-                    if(idx >= 0) {
-                        tilegroup.Tiles[idx] = tile.ID;
-                    }
-                }
-            }
-            FillTileList();
-            SelectionChanged();
+            RemapTiles(id);
         } finally {
             AppBar.ClearPrompt();
         }
     }
 
+    protected void RemapTiles(int startID) {
+       if(Tiles == null)
+               return;
+
+       // remap tiles
+       int id = startID;
+       foreach(Tile tile in Selection) {
+               if(tile.ID == -1)
+                       continue;
+
+               int oldid = tile.ID;
+               tile.ID = id++;
+               // remap in all tilegroups...
+               foreach(TileGroup tilegroup in tileset.TileGroups) {
+                       int idx = tilegroup.Tiles.IndexOf(oldid);
+                       if(idx >= 0) {
+                               tilegroup.Tiles[idx] = tile.ID;
+                       }
+               }
+       }
+       FillTileList();
+       SelectionChanged();
+    }
+
     protected void OnDrawingAreaExpose(object o, ExposeEventArgs e) {
         if(pixbuf == null)
             return;