TODO update
[supertux.git] / contrib / tilemanager / Application.cs
index 49fa912..ec842e2 100644 (file)
@@ -26,7 +26,7 @@ public class Application {
     [Glade.Widget]
     private Gtk.Entry DataEntry;
     [Glade.Widget]
-    private Gtk.Entry AnimSpeedEntry;
+    private Gtk.Entry AnimFpsEntry;
     [Glade.Widget]                 
     private Gtk.Entry IDEntry;
     [Glade.Widget]
@@ -61,12 +61,16 @@ public class Application {
 
         Application app = new Application();
 
+        /* that's no proper commandlineparsing, but who'll notice... */
+        if(args.Length == 1)
+            app.LoadTileSet(args[0]);
+
         kit.Run();
         return 0;
     }
 
     public Application() {
-        Glade.XML gxml = new Glade.XML("tiler.glade", null, null);
+        Glade.XML gxml = new Glade.XML(null, "tiler.glade", null, null);
         gxml.Autoconnect(this);
 
         if(MainWindow == null || DrawingArea == null || AppBar == null)
@@ -101,6 +105,10 @@ public class Application {
         string file = selection.Filename;
         selection.Destroy();
 
+        LoadTileSet(file);
+    }
+
+    private void LoadTileSet(string file) {
         try {
             tileset = new TileSet();
             tileset.Parse(file);
@@ -277,6 +285,9 @@ public class Application {
     }
 
     private void OnDrawingAreaButtonPress(object o, ButtonPressEventArgs e) {
+        if(SelectionArray == null)
+            return;
+
         selecting = true;
         
         for(int i = 0; i < SelectionArray.Length; ++i)
@@ -331,8 +342,8 @@ public class Application {
                     tile.ID = Int32.Parse(IDEntry.Text);
                 if(sender == DataEntry)
                     tile.Data = Int32.Parse(DataEntry.Text);
-                if(sender == AnimSpeedEntry)
-                    tile.AnimSpeed = Int32.Parse(AnimSpeedEntry.Text);
+                if(sender == AnimFpsEntry)
+                    tile.AnimFps = Single.Parse(AnimFpsEntry.Text);
             } catch(Exception exception) {
                 // ignore parse errors for now...
             }
@@ -369,7 +380,7 @@ public class Application {
                 SlopeCheckButton.Active = tile.Slope;
                 DontUseCheckButton.Active = tile.ID == -1;
                 DataEntry.Text = tile.Data.ToString();
-                AnimSpeedEntry.Text = tile.AnimSpeed.ToString();
+                AnimFpsEntry.Text = tile.AnimFps.ToString();
                 IDEntry.Text = tile.ID.ToString();
                 IDEntry.Editable = true;
                 first = false;
@@ -452,7 +463,6 @@ public class Application {
     }
 
     private void OnTileListCursorChanged(object sender, EventArgs e) {
-        Console.WriteLine("Cursor changed.");
         TreeModel model;
         TreePath[] selectpaths =
             TileList.Selection.GetSelectedRows(out model);