예제 #1
0
    protected void OnToolboxSizeAllocated(object o, Gtk.SizeAllocatedArgs args)
    {
        Gtk.Frame fActive = (Gtk.Frame)o;
        Gtk.Frame fOther  = (o == fToolsRight)?fToolsLeft:fToolsRight;
        Settings.Instance.ToolboxOnRight = (fActive == fToolsRight);                    //recently touched frame becomes stored in preferences

        if (args.Allocation.Width < 5)
        {
            if (fOther.Visible)                         //ignore, if the other frame is already visible;
            {
                return;
            }
            fActive.Show();
            fOther.Show();
        }
        else
        {
            if (!fOther.Visible)                        //ignore, if the other frame is already hidden;
            {
                return;
            }
            fActive.WidthRequest = 1;
            fActive.Show();
            aTools.Reparent(fActive);
            fOther.Hide();
        }
    }
    void showWidgets(Constants.BellModes bellMode, Constants.EncoderVariablesCapture encoderMainVariable, EncoderRhythm encoderRhythm)
    {
        frame_best_and_worst.Hide();
        frame_conditions.Hide();
        hbox_jump_best_worst.Hide();
        hbox_run_best_worst.Hide();
        hbox_jump_conditions.Hide();
        hbox_run_conditions.Hide();
        frame_encoder_automatic_conditions.Hide();
        vbox_encoder_manual.Hide();
        notebook_encoder_conditions.Hide();
        vbox_encoder_stuff.Hide();

        notebook_main.GetNthPage(RHYTHMPAGE).Hide();
        notebook_main.ShowTabs = false;

        if (bellMode == Constants.BellModes.JUMPS)
        {
            frame_best_and_worst.Show();
            hbox_jump_best_worst.Show();
            hbox_jump_conditions.Show();
            frame_conditions.Show();
        }
        else if (bellMode == Constants.BellModes.RUNS)
        {
            frame_best_and_worst.Show();
            hbox_run_best_worst.Show();
            hbox_run_conditions.Show();
            frame_conditions.Show();
        }
        else             //encoder (grav and inertial)
        {
            vbox_encoder_stuff.Show();
            frame_encoder_automatic_conditions.Show();
            notebook_main.ShowTabs = true;

            vbox_encoder_manual.Show();
            if (checkbutton_encoder_show_manual_feedback.Active)
            {
                notebook_encoder_conditions.Show();
            }

            combo_encoder_main_variable.Active = UtilGtk.ComboMakeActive(combo_encoder_main_variable,
                                                                         Constants.GetEncoderVariablesCapture(encoderMainVariable));

            notebook_main.GetNthPage(RHYTHMPAGE).Show();
            encoder_rhythm_set_values(encoderRhythm);
        }

        label_test_sound_result.Text = "";
    }
예제 #3
0
    void showWidgets(Constants.BellModes bellMode)
    {
        frame_best_and_worst.Hide();
        frame_conditions.Hide();
        hbox_jump_best_worst.Hide();
        hbox_run_best_worst.Hide();
        hbox_jump_conditions.Hide();
        hbox_run_conditions.Hide();
        frame_encoder_automatic_conditions.Hide();
        vbox_encoder_manual.Hide();
        notebook_encoder_conditions.Hide();

        if (bellMode == Constants.BellModes.JUMPS)
        {
            frame_best_and_worst.Show();
            hbox_jump_best_worst.Show();
            hbox_jump_conditions.Show();
            frame_conditions.Show();
        }
        else if (bellMode == Constants.BellModes.RUNS)
        {
            frame_best_and_worst.Show();
            hbox_run_best_worst.Show();
            hbox_run_conditions.Show();
            frame_conditions.Show();
        }
        else                                             //encoder
        {
            notebook_encoder_conditions.CurrentPage = 3; //power
            frame_encoder_automatic_conditions.Show();
            vbox_encoder_manual.Show();
            if (checkbutton_encoder_show_manual_feedback.Active)
            {
                notebook_encoder_conditions.Show();
            }
        }
    }
예제 #4
0
    private Application(Options opts)
    {
        selection = new TileSelection();

        Glade.XML.CustomHandler = GladeCustomWidgetHandler;
        Glade.XML gxml = new Glade.XML("editor.glade", "MainWindow");
        gxml.Autoconnect(this);

        if (MainWindow == null)
        {
            throw new Exception("Couldn't resolve all widgets");
        }

        ((GameObjectListWidget)ToolGObjectsProps).SetGtkFrame(fGObjects);

        Tileset.LoadEditorImages = true;

        // Initialize status bar for PrintStatus()
        printStatusContextID = sbMain.GetContextId("PrintStatus");
        printStatusMessageID = sbMain.Push(printStatusContextID, "Welcome to Supertux-Editor.");

        MainWindow.DeleteEvent += OnDelete;

        MainWindow.SetSizeRequest(900, 675);
        MainWindowTitlePrefix = MainWindow.Title;
        UpdateTitlebar();
        UpdateRecentDocuments();
        MainWindow.Icon = EditorStock.WindowIcon;
        //HACK: not a typo, EditorStock adds icons to the stock only when called 2x or more..
        MainWindow.Icon = EditorStock.WindowIcon;
        MainWindow.ShowAll();

        // Manually set icons for Tools, automatic stock initialization is broken on some systems
        ToolSelect.StockId       = EditorStock.ToolSelect;
        ToolTiles.StockId        = EditorStock.ToolTiles;
        ToolObjects.StockId      = EditorStock.ToolObjects;
        ToolBrush.StockId        = EditorStock.ToolBrush;
        ToolFill.StockId         = EditorStock.ToolFill;
        ToolReplace.StockId      = EditorStock.ToolReplace;
        ToolPath.StockId         = EditorStock.ToolPath;
        ToolButtonCamera.StockId = EditorStock.Camera;

        // Hide some extra widgets (because MainWindow.ShowAll(); showed them all)
        fGObjects.Visible = false;
        if (Settings.Instance.ToolboxOnRight)
        {
            aTools.Reparent(fToolsRight);
            fToolsLeft.Hide();
        }
        else
        {
            aTools.Reparent(fToolsLeft);
            fToolsRight.Hide();
        }


        // Tool "Select" is selected by default - call its event handler
        OnToolSelect(null, null);

        //Setup drag destination for "files"
        Gtk.Drag.DestSet(MainWindow, Gtk.DestDefaults.All, target_table,
                         Gdk.DragAction.Default |
                         Gdk.DragAction.Copy |
                         Gdk.DragAction.Move |
                         Gdk.DragAction.Link |
                         Gdk.DragAction.Private |
                         Gdk.DragAction.Ask);
        MainWindow.DragDataReceived += OnDragDataReceived;

        fileChooser = new Gtk.FileChooserDialog("Choose a Level", MainWindow, Gtk.FileChooserAction.Open, new object[] {});
        if (!Directory.Exists(Settings.Instance.LastDirectoryName))             //noexistent (or null) LastDirectoryName, resetting to default
        {
            if (Settings.Instance.SupertuxData != null)
            {
                Settings.Instance.LastDirectoryName = System.IO.Path.Combine(Settings.Instance.SupertuxData, "levels") + System.IO.Path.DirectorySeparatorChar;
            }
            else
            {
                Settings.Instance.LastDirectoryName = Environment.ExpandEnvironmentVariables("%HOME%");
            }
        }
        fileChooser.SetCurrentFolder(Settings.Instance.LastDirectoryName);
        fileChooser.AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
        fileChooser.AddButton(Gtk.Stock.Ok, Gtk.ResponseType.Ok);
        fileChooser.DefaultResponse = Gtk.ResponseType.Ok;
        Gtk.FileFilter filter = new Gtk.FileFilter();
        filter.Name = "Supertux Levels and Worldmaps";
        filter.AddPattern("*.stl");
        filter.AddPattern("*.stwm");
        fileChooser.AddFilter(filter);
        Gtk.FileFilter levelfilter = new Gtk.FileFilter();
        levelfilter.Name = "Supertux Levels";
        levelfilter.AddPattern("*.stl");
        fileChooser.AddFilter(levelfilter);
        Gtk.FileFilter worldmapfilter = new Gtk.FileFilter();
        worldmapfilter.Name = "Supertux Worldmaps";
        worldmapfilter.AddPattern("*.stwm");
        fileChooser.AddFilter(worldmapfilter);
        Gtk.FileFilter brushfilter = new Gtk.FileFilter();
        brushfilter.Name = "Supertux-Editor Brushes";
        brushfilter.AddPattern("*.csv");
        fileChooser.AddFilter(brushfilter);
        Gtk.FileFilter all = new Gtk.FileFilter();
        all.Name = "All Files";
        all.AddPattern("*");
        fileChooser.AddFilter(all);
        if (Settings.Instance.SupertuxData != null)
        {
            try {
                fileChooser.AddShortcutFolder(System.IO.Path.Combine(Settings.Instance.SupertuxData, "levels"));
            } catch (Exception e) {
                LogManager.Log(LogLevel.Warning, "Couldn't add supertux level directory to File Chooser: " + e.Message);
            }
        }

        if (opts.FileNames.Count > 0)
        {
            Load(opts.FileNames[0]);
        }

        UndoManager.OnAddCommand += OnUndoManager;
        UndoManager.OnRedo       += OnUndoManager;
        UndoManager.OnUndo       += OnUndoManager;

        editorApplication = this;

        PrintStatus("Welcome to Supertux-Editor.");
    }