From fdbfa0e294c58cdf270a003c7aac0d35109a6e93 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Milo=C5=A1=20Klou=C4=8Dek?= Date: Mon, 27 Oct 2008 14:16:44 +0000 Subject: [PATCH] Added menu item to let user decide, if he wants to use new not-yet-fully-supported 0.3.x format SVN-Revision: 5812 --- tools/tilemanager/Application.cs | 18 ++++++++++++++---- tools/tilemanager/TileSet.cs | 14 +++++--------- tools/tilemanager/tiler.glade | 17 ++++++++++++++++- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/tools/tilemanager/Application.cs b/tools/tilemanager/Application.cs index 22fbf8d8b..bbb738732 100644 --- a/tools/tilemanager/Application.cs +++ b/tools/tilemanager/Application.cs @@ -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) { diff --git a/tools/tilemanager/TileSet.cs b/tools/tilemanager/TileSet.cs index 930013572..ad10cdf7c 100644 --- a/tools/tilemanager/TileSet.cs +++ b/tools/tilemanager/TileSet.cs @@ -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; /// Whether version of tileset file is too new - 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: " + diff --git a/tools/tilemanager/tiler.glade b/tools/tilemanager/tiler.glade index 9fcb68751..5f54f842c 100644 --- a/tools/tilemanager/tiler.glade +++ b/tools/tilemanager/tiler.glade @@ -110,7 +110,7 @@ - + True @@ -142,6 +142,21 @@ True + + + + True + + + + + + True + Use 0.3.x syntax + True + False + + -- 2.11.0