示例#1
0
 public void CloseSpecialItemMenu()
 {
     if (Settings.Paradise)
     {
         // NOTE: No possibility to undo yet.
         _paraSpecialItemInterface = null;
     }
     else
     {
         editor.AddToUndoHistory();
         _physicalMapLogic.OverrideGridData(editor.MapGrid);
         _physicalMapLogic     = null;
         _specialItemInterface = null;
     }
 }
示例#2
0
        void LoadInterface()
        {
            // ===== MAIN MENU =====
            var grid = new Grid
            {
                RowSpacing    = 10,
                ColumnSpacing = 20
            };

            grid.ColumnsProportions.Add(new Proportion(ProportionType.Auto));
            grid.HorizontalAlignment = HorizontalAlignment.Center;
            grid.RowsProportions.Add(new Proportion(ProportionType.Auto));
            grid.VerticalAlignment = VerticalAlignment.Center;

            var labelType = new Label
            {
                Id         = "labelType",
                Text       = "Choose the element to modify:",
                GridColumn = 0,
                GridRow    = 0,
            };

            grid.Widgets.Add(labelType);

            var comboType = new ComboBox
            {
                GridColumn = 1,
                GridRow    = 0,
                Width      = 150
            };

            comboType.Items.Add(new ListItem("Walls", Color.White));
            comboType.Items.Add(new ListItem("Ground", Color.White));
            if (Settings.Paradise)
            {
                comboType.Items.Add(new ListItem("Ground 2", Color.White));
            }
            comboType.Items.Add(new ListItem("Background", Color.White));
            comboType.Items.Add(new ListItem("MiniMap", Color.White));
            grid.Widgets.Add(comboType);

            var labelMap = new Label
            {
                Id         = "labelMap",
                Text       = "Choose the map to modify:",
                GridColumn = 0,
                GridRow    = 1,
            };

            grid.Widgets.Add(labelMap);

            var comboMap = new ComboBox
            {
                GridColumn = 1,
                GridRow    = 1,
                Width      = 150
            };

            foreach (string name in Levels.AllLevels)
            {
                comboMap.Items.Add(new ListItem(name, Color.White));
            }
            grid.Widgets.Add(comboMap);

            var buttonEdit = new TextButton
            {
                GridColumn  = 2,
                GridRow     = 0,
                GridRowSpan = 2,
                Text        = "Edit map",
                Width       = 150,
                Height      = 60
            };

            buttonEdit.Click += (s, a) =>
            {
                if (comboMap.SelectedIndex == null || comboType.SelectedIndex == null)
                {
                    PleaseSelectMapMsg();
                }
                else
                {
                    mode = IndexToSelectedMode(comboType.SelectedIndex);
                    map  = comboMap.SelectedItem.Text;
                    if (!LoadGrid())
                    {
                        mode = Mode.Menu;
                    }
                }
            };

            grid.Widgets.Add(buttonEdit);

            // Edit times
            var buttonEditTimesF = new TextButton
            {
                GridColumn = 3,
                GridRow    = 0,
                Text       = "Edit times (in frame)",
                Width      = 150,
                Height     = 25
            };

            buttonEditTimesF.Click += (s, a) =>
            {
                _timesEditor = new TimesEditor(this, false);
            };
            grid.Widgets.Add(buttonEditTimesF);

            var buttonEditTimesS = new TextButton
            {
                GridColumn = 3,
                GridRow    = 1,
                Text       = "Edit times",
                Width      = 150,
                Height     = 25
            };

            buttonEditTimesS.Click += (s, a) =>
            {
                _timesEditor = new TimesEditor(this, true);
            };
            grid.Widgets.Add(buttonEditTimesS);

            // Edit overworld data (Paradise only for now)
            if (Settings.Paradise)
            {
                var buttonEditOverworld = new TextButton
                {
                    GridColumn = 3,
                    GridRow    = 2,
                    Text       = "Edit overworld",
                    Width      = 150,
                    Height     = 25
                };

                buttonEditOverworld.Click += (s, a) =>
                {
                    _overworldEditor = new OverworldEditor(this);
                };
                grid.Widgets.Add(buttonEditOverworld);
            }

            // Reset
            var buttonReset = new TextButton
            {
                GridColumn = 4,
                GridRow    = 0,
                Text       = "Reset this map",
                Width      = 150,
                Height     = 25
            };

            buttonReset.Click += (s, a) =>
            {
                if (comboMap.SelectedIndex == null || comboType.SelectedIndex == null)
                {
                    PleaseSelectMapMsg();
                }
                else
                {
                    var messageBox = Dialog.CreateMessageBox("Confirmation", "Are you sure ? This level will be reset.");
                    messageBox.Closed += (s, a) =>
                    {
                        if (messageBox.Result)
                        {
                            Task.Factory.StartNew(() => {
                                try
                                {
                                    mode = Mode.Loading;
                                    File.Delete(Levels.GetLevelPath(comboMap.SelectedItem.Text,
                                                                    MapType(IndexToSelectedMode(comboType.SelectedIndex))));
                                    Settings.RunExtractor("");
                                    mode = Mode.Menu;
                                }
                                catch { Exit(); }
                            });
                        }
                    };
                    messageBox.ShowModal(_mainMenuDesktop);
                }
            };
            grid.Widgets.Add(buttonReset);

            var buttonResetAll = new TextButton
            {
                GridColumn = 4,
                GridRow    = 1,
                Text       = "Reset ALL maps",
                Width      = 150,
                Height     = 25
            };

            buttonResetAll.Click += (s, a) =>
            {
                var messageBox = Dialog.CreateMessageBox("Confirmation", "Are you sure ? ALL levels will be reset.");
                messageBox.Closed += (s, a) =>
                {
                    if (messageBox.Result)
                    {
                        Task.Factory.StartNew(() => {
                            try
                            {
                                mode = Mode.Loading;
                                Levels.DeleteAllLevels();
                                Settings.RunExtractor("");
                                reloadAtNextFrame = true;
                            }
                            catch { Exit(); }
                        });
                    }
                };
                messageBox.ShowModal(_mainMenuDesktop);
            };
            grid.Widgets.Add(buttonResetAll);
            // Build
            var buttonBuild = new TextButton
            {
                GridColumn  = 2,
                GridRow     = 2,
                GridRowSpan = 1,
                Text        = "Build",
                Width       = 150,
                Height      = 25
            };

            buttonBuild.Click += (s, a) =>
            {
                Task.Factory.StartNew(() => {
                    try
                    {
                        mode = Mode.Loading;
                        Settings.RunExtractor("");
                        mode = Mode.Menu;
                    }
                    catch { Exit(); }
                });
            };
            grid.Widgets.Add(buttonBuild);

            var buttonBuildAndRun = new TextButton
            {
                GridColumn  = 2,
                GridRow     = 3,
                GridRowSpan = 1,
                Text        = "Build and run",
                Width       = 150,
                Height      = 25
            };

            buttonBuildAndRun.Click += (s, a) =>
            {
                Task.Factory.StartNew(() => {
                    try
                    {
                        mode = Mode.Loading;
                        Settings.RunExtractor("");
                        mode = Mode.Menu;
                        Settings.RunEmulator();
                    }
                    catch { Exit(); }
                });
            };
            grid.Widgets.Add(buttonBuildAndRun);

            _mainMenuDesktop      = new Desktop();
            _mainMenuDesktop.Root = grid;

            // ===== LATERAL MENU =====
            Panel panel = new Panel()
            {
                Left       = 0,
                Padding    = new Thickness(10, 10, 10, 10),
                Width      = LATERAL_PANEL_WIDTH,
                Background = new SolidBrush(Color.Transparent),
            };

            var lateral = new Grid
            {
                RowSpacing    = 10,
                ColumnSpacing = 10
            };

            lateral.ColumnsProportions.Add(new Proportion(ProportionType.Auto));
            lateral.HorizontalAlignment = HorizontalAlignment.Left;
            lateral.RowsProportions.Add(new Proportion(ProportionType.Part));
            lateral.VerticalAlignment = VerticalAlignment.Top;

            var buttonSave = new TextButton
            {
                GridColumn = 0,
                GridRow    = 0,
                Text       = "Save",
                Width      = 40,
                Height     = 30
            };

            buttonSave.Click += (s, a) =>
            {
                SaveGrid();
                _inventories.Save();
            };
            lateral.Widgets.Add(buttonSave);

            var buttonSaveQuit = new TextButton
            {
                GridColumn     = 1,
                GridRow        = 0,
                Text           = "Save + quit",
                Width          = 90,
                Height         = 30,
                GridColumnSpan = 2
            };

            buttonSaveQuit.Click += (s, a) =>
            {
                SaveGrid();
                QuitEditor();
            };
            lateral.Widgets.Add(buttonSaveQuit);

            var buttonQuit = new TextButton
            {
                GridColumn = 3,
                GridRow    = 0,
                Text       = "Quit",
                Width      = 40,
                Height     = 30
            };

            buttonQuit.Click += (s, a) =>
            {
                QuitEditor();
            };
            lateral.Widgets.Add(buttonQuit);

            var buttonWP = new TextButton
            {
                GridColumn = 0,
                GridRow    = 1,
                Text       = "W+",
                Width      = 40,
                Height     = 30
            };

            buttonWP.Click += (s, a) =>
            {
                editor.IncreaseWidth();
            };
            lateral.Widgets.Add(buttonWP);
            var buttonWM = new TextButton
            {
                GridColumn = 1,
                GridRow    = 1,
                Text       = "W-",
                Width      = 40,
                Height     = 30
            };

            buttonWM.Click += (s, a) =>
            {
                editor.DecreaseWidth();
            };
            lateral.Widgets.Add(buttonWM);
            var buttonHP = new TextButton
            {
                GridColumn = 2,
                GridRow    = 1,
                Text       = "H+",
                Width      = 40,
                Height     = 30
            };

            buttonHP.Click += (s, a) =>
            {
                editor.IncreaseHeight();
            };
            lateral.Widgets.Add(buttonHP);
            var buttonHM = new TextButton
            {
                GridColumn = 3,
                GridRow    = 1,
                Text       = "H-",
                Width      = 40,
                Height     = 30
            };

            buttonHM.Click += (s, a) =>
            {
                editor.DecreaseHeight();
            };
            lateral.Widgets.Add(buttonHM);

            var buttonOP = new TextButton
            {
                GridColumn     = 0,
                GridRow        = 2,
                Text           = "Overlay +",
                Width          = 90,
                Height         = 30,
                GridColumnSpan = 2
            };

            buttonOP.Click += (s, a) =>
            {
                List <GridEditor.OverlayGrid> overlays = new List <GridEditor.OverlayGrid>();
                overlays.AddRange(editor.Underlays);
                overlays.AddRange(editor.Overlays);
                overlays.Reverse();
                foreach (GridEditor.OverlayGrid overlay in overlays)
                {
                    if (!overlay.enabled)
                    {
                        overlay.enabled = true;
                        break;
                    }
                }
            };
            lateral.Widgets.Add(buttonOP);
            var buttonOM = new TextButton
            {
                GridColumn     = 2,
                GridRow        = 2,
                Text           = "Overlay -",
                Width          = 90,
                Height         = 30,
                GridColumnSpan = 2
            };

            buttonOM.Click += (s, a) =>
            {
                List <GridEditor.OverlayGrid> overlays = new List <GridEditor.OverlayGrid>();
                overlays.AddRange(editor.Underlays);
                overlays.AddRange(editor.Overlays);
                foreach (GridEditor.OverlayGrid overlay in overlays)
                {
                    if (overlay.enabled)
                    {
                        overlay.enabled = false;
                        break;
                    }
                }
            };
            lateral.Widgets.Add(buttonOM);

            var buttonGOn = new TextButton
            {
                GridColumn     = 0,
                GridRow        = 3,
                Text           = "Grid On",
                Width          = 90,
                Height         = 30,
                GridColumnSpan = 2
            };

            buttonGOn.Click += (s, a) =>
            {
                editor.GridEnabled = true;
            };
            lateral.Widgets.Add(buttonGOn);
            var buttonGOff = new TextButton
            {
                GridColumn     = 2,
                GridRow        = 3,
                Text           = "Grid Off",
                Width          = 90,
                Height         = 30,
                GridColumnSpan = 2
            };

            buttonGOff.Click += (s, a) =>
            {
                editor.GridEnabled = false;
            };
            lateral.Widgets.Add(buttonGOff);

            var buttonSpecial = new TextButton
            {
                GridColumn     = 0,
                GridRow        = 4,
                Text           = "Special Objects",
                Width          = 180,
                Height         = 30,
                GridColumnSpan = 4
            };

            buttonSpecial.Click += (s, a) =>
            {
                if (mode == Mode.Physical)
                {
                    if (Settings.Paradise)
                    {
                        _paraSpecialItemInterface = new ParadiseSpecialItems(this, _paraPhysicalMapLogic);
                    }
                    else
                    {
                        _physicalMapLogic     = new PhysicalMapLogic(editor.MapGrid);
                        _specialItemInterface = new SpecialItems(this, _physicalMapLogic);
                    }
                }
                else
                {
                    var messageBox = Dialog.CreateMessageBox("Error", "Special items can only be edited in Wall edition mode.");
                    messageBox.ShowModal(_lateralMenuDesktop);
                }
            };
            lateral.Widgets.Add(buttonSpecial);

            var buttonHelp = new TextButton
            {
                GridColumn     = 0,
                GridRow        = 5,
                Text           = "Help",
                Width          = 180,
                Height         = 30,
                GridColumnSpan = 4
            };

            buttonHelp.Click += (s, a) =>
            {
                var messageBox = Dialog.CreateMessageBox("Commands",
                                                         "Move: CTRL+LeftClick or Arrows\n" +
                                                         "Zoom: CTRL+Wheel or CTRL+[+/-]\n" +
                                                         "Next / Previous palette: Wheel\n" +
                                                         "Make a selection: ALT+LeftClick\n" +
                                                         "Brush size: ALT+Wheel or ALT+[+/-]\n" +
                                                         "Flip selection: SHIFT+Wheel or SHIFT+Arrows\n" +
                                                         "Force palette of selection: SHIFT+Space\n" +
                                                         "Open/Close inventory: Space\n" +
                                                         "Open/Close custom inventory: Enter\n" +
                                                         "Undo / Redo: CTRL+Z / CTRL+Y"
                                                         );
                messageBox.ShowModal(_lateralMenuDesktop);
            };
            lateral.Widgets.Add(buttonHelp);

            var buttonSBR = new TextButton
            {
                GridColumn     = 0,
                GridRow        = 17,
                Text           = "Save, build and run",
                Width          = 180,
                Height         = 30,
                GridColumnSpan = 4
            };

            buttonSBR.Click += (s, a) =>
            {
                SaveGrid();
                _inventories.Save();
                Task.Factory.StartNew(() => {
                    try
                    {
                        Mode mode_bkp = mode;
                        mode          = Mode.Loading;
                        Settings.RunExtractor("");
                        mode = mode_bkp;
                        Settings.RunEmulator();
                    }
                    catch { Exit(); }
                });
            };
            lateral.Widgets.Add(buttonSBR);

            panel.Widgets.Add(lateral);
            _lateralMenuDesktop      = new Desktop();
            _lateralMenuDesktop.Root = panel;

            mode = Mode.Menu;
        }