Added menu item to let user decide, if he wants to use new not-yet-fully-supported...
authorMiloš Klouček <m.kloucek.m@atlas.cz>
Mon, 27 Oct 2008 14:16:44 +0000 (14:16 +0000)
committerMiloš Klouček <m.kloucek.m@atlas.cz>
Mon, 27 Oct 2008 14:16:44 +0000 (14:16 +0000)
SVN-Revision: 5812

tools/tilemanager/Application.cs
tools/tilemanager/TileSet.cs
tools/tilemanager/tiler.glade

index 22fbf8d..bbb7387 100644 (file)
@@ -10,6 +10,8 @@ public class Application {
     [Glade.Widget]
     private Gtk.Window MainWindow;
     [Glade.Widget]
+    private Gtk.CheckMenuItem useNewSyntax;
+    [Glade.Widget]
     private Gtk.DrawingArea DrawingArea;
     [Glade.Widget]
     private Gtk.CheckButton SolidCheckButton;
@@ -133,6 +135,11 @@ public class Application {
         SelectionChanged();
         FillTileGroupComboBox();
         FillTileList();
+
+       useNewSyntax.Active = tileset.IsNew;
+       if (tileset.IsNew)
+               Console.WriteLine("Warning: new syntax of 0.3.x files \"More tiles in one image\" isn't currently supported for WRITING");
+
     }
 
     protected void OnImportImage(object o, EventArgs e) {
@@ -237,11 +244,14 @@ public class Application {
     }
 
     protected void OnSave(object o, EventArgs e) {
-       if (tileset.TooNew)
-               Console.WriteLine(
-               "Sorry, the file you are editing is too new, there will be huge data loss if you save this.");
-       else
+       if (tileset.IsNew && useNewSyntax.Active) {
+               MessageDialog dialog = new MessageDialog(MainWindow, DialogFlags.Modal | DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Ok,
+                                                               "Sorry, the file you are editing is too new and 0.3.x syntax is not supported yet.");
+               dialog.Run();
+               dialog.Destroy();
+       } else {
                tileset.Write(tilesetfile);
+       }
     }
 
     protected void OnQuit(object o, EventArgs e) {
index 9300135..ad10cdf 100644 (file)
@@ -49,12 +49,12 @@ public class TileSet {
     public const int TILE_WIDTH = 32;
     public const int TILE_HEIGHT = 32;
 
-    private bool tooNew = false;
+    private bool isNew = false;
 
     /// <summary>Whether version of tileset file is too new</summary>
-    public bool TooNew {
+    public bool IsNew {
        get {
-               return tooNew;
+               return isNew;
        }
     }
 
@@ -104,7 +104,7 @@ public class TileSet {
     }
 
     public void ParseTiles(Lisp.Parser parser) {
-       tooNew = false;
+       isNew = false;
         int d = parser.Depth;
         while(parser.Parse() && parser.Depth >= d) {
             if(parser.Depth == d && parser.Type != Parser.LispType.START_LIST) {
@@ -135,11 +135,7 @@ public class TileSet {
                         break;
                     case "tiles":
                        ParseMoreTiles(parser);
-                       tooNew = true;
-                       Console.WriteLine(
-                               "Warning: new syntax of \"More tiles in one image\" file isn't currently supported");
-                       Console.WriteLine(
-                               "And this means: YOU WON'T BE ABLE TO SAVE YOUR CHANGES !!!");
+                       isNew = true;
                         break;
                    default:
                         throw new Exception("Unexpected listentry: " +
index 9fcb687..5f54f84 100644 (file)
                  </child>
 
                  <child>
-                   <widget class="GtkSeparatorMenuItem" id="trennlinie1">
+                   <widget class="GtkSeparatorMenuItem" id="separator1">
                      <property name="visible">True</property>
                    </widget>
                  </child>
                      <property name="use_underline">True</property>
                    </widget>
                  </child>
+
+                 <child>
+                   <widget class="GtkSeparatorMenuItem" id="separator2">
+                     <property name="visible">True</property>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkCheckMenuItem" id="useNewSyntax">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">Use 0.3.x syntax</property>
+                     <property name="use_underline">True</property>
+                     <property name="active">False</property>
+                   </widget>
+                 </child>
                </widget>
              </child>
            </widget>