Esempio n. 1
0
    protected void OnBrushLoad(object o, EventArgs args)
    {
        try {
            if (tilemap == null)
            {
                ErrorDialog.ShowError("Brush: No tilemap selected",
                                      "You have to select a tilemap before you load a brush");
                return;
            }

            fileChooser.Title  = "Choose a Brush";
            fileChooser.Action = Gtk.FileChooserAction.Open;
            fileChooser.SetCurrentFolder(Settings.Instance.LastBrushDir);
            fileChooser.Filter = fileChooser.Filters[3];
            int result = fileChooser.Run();
            fileChooser.Hide();
            if (result != (int)Gtk.ResponseType.Ok)
            {
                return;
            }
            Settings.Instance.LastBrushDir = fileChooser.CurrentFolder;
            Settings.Instance.Save();
            string brushFile = fileChooser.Filename;

            TileBrushTool editor = new TileBrushTool(this, level.Tileset, brushFile);
            SetTool(editor);
        } catch (Exception e) {
            ErrorDialog.Exception(e);
        }
    }
Esempio n. 2
0
    protected void OnBrushSaveAs(object o, EventArgs args)
    {
        try {
            ITool editor = sectorSwitchNotebook.CurrentRenderer.Editor;
            if (!(editor is TileBrushTool))
            {
                ErrorDialog.ShowError("No brush editor active",
                                      "You need to open a brush before you can save changes to it");
                return;
            }
            TileBrushTool brushTool = (TileBrushTool)editor;

            fileChooser.Title  = "Choose a Brush";
            fileChooser.Action = Gtk.FileChooserAction.Save;
            fileChooser.SetCurrentFolder(Settings.Instance.LastBrushDir);
            fileChooser.Filter = fileChooser.Filters[3];
            int result = fileChooser.Run();
            fileChooser.Hide();
            if (result != (int)Gtk.ResponseType.Ok)
            {
                return;
            }
            Settings.Instance.LastBrushDir = fileChooser.CurrentFolder;
            Settings.Instance.Save();
            string brushFile = fileChooser.Filename;

            brushTool.Brush.saveToFile(brushFile);

            /*
             * try {
             *      LispSerializer serializer = new LispSerializer(typeof(Brush));
             *      serializer.Write(brushFile, brushEditor.Brush);
             * } catch(Exception e) {
             *      ErrorDialog.Exception("Couldn't save brush", e);
             * }
             */
        } catch (Exception e) {
            ErrorDialog.Exception(e);
        }
    }
Esempio n. 3
0
    protected void OnBrushLoad(object o, EventArgs args)
    {
        try {
            if (tilemap == null) {
                ErrorDialog.ShowError("Brush: No tilemap selected",
                                      "You have to select a tilemap before you load a brush");
                return;
            }

            fileChooser.Title = "Choose a Brush";
            fileChooser.Action = Gtk.FileChooserAction.Open;
            fileChooser.SetCurrentFolder(Settings.Instance.LastBrushDir);
            fileChooser.Filter = fileChooser.Filters[3];
            int result = fileChooser.Run();
            fileChooser.Hide();
            if(result != (int) Gtk.ResponseType.Ok)
                return;
            Settings.Instance.LastBrushDir = fileChooser.CurrentFolder;
            Settings.Instance.Save();
            string brushFile = fileChooser.Filename;

            TileBrushTool editor = new TileBrushTool(this, level.Tileset, brushFile);
            SetTool(editor);
        } catch(Exception e) {
            ErrorDialog.Exception(e);
        }
    }