Example #1
0
        public FileExplorer(IContainer Parent) : base(Parent)
        {
            Sprites["box"] = new Sprite(this.Viewport);
            PathContainer  = new Container(this);
            PathContainer.SetPosition(60, 11);

            GridContainer             = new Container(this);
            GridContainer.VAutoScroll = true;
            VScrollBar vs = new VScrollBar(this);

            GridContainer.SetVScrollBar(vs);
            GridContainer.SetPosition(18, 53);
            DirGrid = new Grid(GridContainer);

            SetSize(478, 325);
        }
Example #2
0
        public TilesetDisplay(IContainer Parent) : base(Parent)
        {
            SetBackgroundColor(9, 21, 34);
            MainContainer = new Container(this);
            MainContainer.SetPosition(2, 2);
            MainContainer.VAutoScroll = true;

            ScrollBar = new VScrollBar(this);
            ScrollBar.SetPosition(267, 2);
            MainContainer.SetVScrollBar(ScrollBar);

            TilesetBox = new PictureBox(MainContainer);
            TilesetBox.SetSize(256, 200);

            TilesetBox.Sprites["controls"] = new Sprite(TilesetBox.Viewport);

            SetSize(277, 200);
        }
        public MultilineTextBox(IContainer Parent) : base(Parent)
        {
            MainContainer = new Container(this);
            MainContainer.SetPosition(5, 5);
            MainContainer.VAutoScroll = true;
            VScrollBar vs = new VScrollBar(this);

            vs.ScrollStep = 5;
            MainContainer.SetVScrollBar(vs);
            TextArea = new MultilineTextArea(MainContainer);
            TextArea.OnSizeChanged += delegate(BaseEventArgs e)
            {
                if (TextArea.Size.Height < MainContainer.Size.Height)
                {
                    TextArea.SetHeight(MainContainer.Size.Height);
                }
            };
            Sprites["box"] = new Sprite(this.Viewport);
        }
Example #4
0
        public TilesPanel(IContainer Parent) : base(Parent)
        {
            Label Header = new Label(this);

            Header.SetText("Tiles");
            Header.SetFont(Font.Get("Fonts/Ubuntu-B", 16));
            Header.SetPosition(5, 5);

            Sprites["sep"]   = new Sprite(this.Viewport, new SolidBitmap(288, 2, new Color(10, 23, 37)));
            Sprites["sep"].Y = 50;

            Sprites["slider"]   = new Sprite(this.Viewport, new SolidBitmap(10, Size.Height - 34, new Color(10, 23, 37)));
            Sprites["slider"].Y = 53;

            this.OnWidgetSelected += WidgetSelected;

            CursorIM = new MouseInputManager(this);

            MainContainer = new Container(this);
            MainContainer.SetPosition(0, 53);
            MainContainer.VAutoScroll = true;

            VScrollBar vs = new VScrollBar(this);

            MainContainer.SetVScrollBar(vs);

            Cursor = new CursorWidget(MainContainer);
            Cursor.SetPosition(3, 8);
            Cursor.SetZIndex(1);

            MainStackPanel = new VStackPanel(MainContainer);
            MainStackPanel.SetWidth(264);
            MainStackPanel.SetPosition(8, 3);

            DrawToolsContainer = new Container(this);
            DrawToolsContainer.SetPosition(46, 22);
            DrawToolsContainer.SetSize(186, 28);
            DrawToolsContainer.Sprites["line1"]   = new Sprite(DrawToolsContainer.Viewport, new SolidBitmap(1, 26, new Color(28, 50, 73)));
            DrawToolsContainer.Sprites["line1"].X = 144;
            DrawToolsContainer.Sprites["line2"]   = new Sprite(DrawToolsContainer.Viewport, new SolidBitmap(1, 26, new Color(28, 50, 73)));
            DrawToolsContainer.Sprites["line2"].X = 185;

            PencilButton = new IconButton(DrawToolsContainer);
            PencilButton.SetIcon(15, 0);
            PencilButton.SetSelected(true);

            FillButton = new IconButton(DrawToolsContainer);
            FillButton.SetIcon(16, 0);
            FillButton.SetPosition(32, 0);

            EllipseButton = new IconButton(DrawToolsContainer);
            EllipseButton.SetIcon(17, 0);
            EllipseButton.SetPosition(64, 0);

            RectButton = new IconButton(DrawToolsContainer);
            RectButton.SetIcon(18, 0);
            RectButton.SetPosition(96, 0);

            SelectButton = new IconButton(DrawToolsContainer);
            SelectButton.SetIcon(19, 0);
            SelectButton.SetPosition(128, 0);
            SelectButton.OnSelection += delegate(BaseEventArgs e)
            {
                MapViewer.Cursor.SetVisible(false);
                Cursor.SetPosition(0, 0);
                Cursor.SetVisible(false);
            };
            SelectButton.OnDeselection += delegate(BaseEventArgs e)
            {
                UpdateCursor();
            };

            EraserButton = new IconButton(DrawToolsContainer);
            EraserButton.SetIcon(20, 0);
            EraserButton.SetPosition(160, 0);
            EraserButton.Toggleable   = true;
            EraserButton.OnSelection += delegate(BaseEventArgs e)
            {
                if (AutotileIndex != -1 || TilesetIndex != -1 || TileStartX != -1 || TileEndX != -1 || TileStartY != -1 || TileEndY != -1)
                {
                    SelectTile(null);
                }
            };
            EraserButton.OnDeselection += delegate(BaseEventArgs e)
            {
                if (AutotileIndex == -1 && TilesetIndex == -1 && TileStartX == -1 && TileEndX == -1 && TileStartY == -1 && TileEndY == -1 &&
                    !MapViewer.SelectionOnMap)
                {
                    SelectTile(0, 0, 0);
                }
                else
                {
                    UpdateCursor();
                }
            };

            SetSize(288, 200); // Dummy size so the sprites can be drawn properly
        }
Example #5
0
        public DatabaseDataList(IContainer Parent) : base(Parent)
        {
            Sprites["listbox"] = new Sprite(this.Viewport);

            Sprites["header"]   = new Sprite(this.Viewport);
            Sprites["header"].X = 10;
            Sprites["header"].Y = 10;

            ListContainer = new Container(this);
            ListContainer.SetPosition(3, 44);
            ListContainer.VAutoScroll = true;

            VScrollBar vslist = new VScrollBar(this);

            vslist.SetPosition(187, 41);
            ListContainer.SetVScrollBar(vslist);

            DataList = new ListDrawer(ListContainer);
            List <ListItem> Tilesets = new List <ListItem>();

            for (int i = 1; i < Game.Data.Tilesets.Count; i++)
            {
                Game.Tileset t = Game.Data.Tilesets[i];
                Tilesets.Add(new ListItem($"{Utilities.Digits(i, 3)}: {t?.Name}", t));
            }
            DataList.SetItems(Tilesets);
            DataList.OnSelectionChanged += delegate(BaseEventArgs e)
            {
                TilesetEditor.SetTileset(DataList.SelectedItem.Object as Game.Tileset, DataList.SelectedIndex + 1);
            };

            ChangeAmountButton = new Button(this);
            ChangeAmountButton.SetSize(154, 37);
            ChangeAmountButton.SetText("Change Amount...");
            ChangeAmountButton.OnClicked += delegate(BaseEventArgs e)
            {
                PopupWindow win = new PopupWindow();
                win.SetSize(270, 125);
                win.SetTitle("Set tileset capacity");
                Label label = new Label(win);
                label.SetText("Set the maximum available number of tilesets.");
                label.SetPosition(5, 35);
                Label label2 = new Label(win);
                label2.SetText("Capacity:");
                label2.SetPosition(75, 60);
                NumericBox num = new NumericBox(win);
                num.SetSize(66, 27);
                num.SetPosition(130, 55);
                num.SetValue(Editor.ProjectSettings.TilesetCapacity);
                num.MinValue = 1;
                Button CancelButton = new Button(win);
                CancelButton.SetText("Cancel");
                CancelButton.SetPosition(win.Size.Width - CancelButton.Size.Width - 5, win.Size.Height - CancelButton.Size.Height - 5);
                CancelButton.OnClicked += delegate(BaseEventArgs e) { win.Close(); };
                Button OKButton = new Button(win);
                OKButton.SetText("OK");
                OKButton.SetPosition(CancelButton.Position.X - OKButton.Size.Width, CancelButton.Position.Y);
                OKButton.OnClicked += delegate(BaseEventArgs e)
                {
                    int NewValue = num.Value;
                    if (NewValue == Editor.ProjectSettings.TilesetCapacity)
                    {
                        win.Close();
                        return;
                    }
                    else if (NewValue > Editor.ProjectSettings.TilesetCapacity)
                    {
                        int Extra = NewValue - Editor.ProjectSettings.TilesetCapacity;
                        for (int i = 0; i < Extra; i++)
                        {
                            Game.Data.Tilesets.Add(null);
                        }
                        Editor.ProjectSettings.TilesetCapacity = NewValue;
                        RefreshList();
                        win.Close();
                    }
                    else
                    {
                        int Lost         = Editor.ProjectSettings.TilesetCapacity - NewValue;
                        int DefinedCount = 0;
                        for (int i = Game.Data.Tilesets.Count - 1; i >= 0; i--)
                        {
                            if (i == NewValue)
                            {
                                break;
                            }
                            if (Game.Data.Tilesets[i] != null)
                            {
                                DefinedCount++;
                            }
                        }
                        if (DefinedCount > 0)
                        {
                            MessageBox box = new MessageBox("Warning",
                                                            $"By resizing the tileset capacity from {Editor.ProjectSettings.TilesetCapacity} to {NewValue}, {Lost} entries will be removed, " +
                                                            $"of which {DefinedCount} {(DefinedCount == 1 ? "is a" : "are")} defined tileset{(DefinedCount == 1 ? "" : "s")}.\n" +
                                                            "Would you like to proceed and delete these tilesets?", ButtonType.YesNoCancel, IconType.Warning);
                            box.OnButtonPressed += delegate(BaseEventArgs e)
                            {
                                if (box.Result == 0) // Yes -> resize tileset capacity and delete tilesets
                                {
                                    for (int i = Game.Data.Tilesets.Count - 1; i >= 0; i--)
                                    {
                                        if (i == NewValue)
                                        {
                                            break;
                                        }
                                        foreach (KeyValuePair <int, Game.Map> kvp in Game.Data.Maps)
                                        {
                                            if (kvp.Value.TilesetIDs.Contains(i))
                                            {
                                                kvp.Value.RemoveTileset(i);
                                            }
                                        }
                                        if (Game.Data.Tilesets[i] != null)
                                        {
                                            Game.Data.Tilesets[i].TilesetBitmap.Dispose();
                                            Game.Data.Tilesets[i].TilesetListBitmap.Dispose();
                                        }
                                        Game.Data.Tilesets[i] = null;
                                    }
                                    Game.Data.Tilesets.RemoveRange(NewValue + 1, Lost);
                                    Editor.ProjectSettings.TilesetCapacity = NewValue;
                                    RefreshList();
                                    win.Close();
                                }
                                else // No, cancel -> do nothing
                                {
                                    win.Close();
                                }
                            };
                        }
                        else
                        {
                            Game.Data.Tilesets.RemoveRange(NewValue + 1, Lost);
                            Editor.ProjectSettings.TilesetCapacity = NewValue;
                            RefreshList();
                            win.Close();
                        }
                    }
                };
                win.Center();
            };
        }
Example #6
0
        public ChooseGraphic(EventGraphic graphic)
        {
            this.OldGraphic  = graphic;
            this.GraphicData = graphic.Clone();
            SetTitle("Choose Graphic");
            MinimumSize = MaximumSize = new Size(735, 421);
            SetSize(MaximumSize);
            Center();

            Label GraphicLabel = new Label(this);

            GraphicLabel.SetFont(Font.Get("Fonts/Ubuntu-B", 16));
            GraphicLabel.SetText("Current Graphic");
            GraphicLabel.SetPosition(559, 35);

            Color outline = new Color(59, 91, 124);
            Color inline  = new Color(17, 27, 38);
            Color filler  = new Color(24, 38, 53);

            Sprites["gfxbox"]        = new Sprite(this.Viewport);
            Sprites["gfxbox"].X      = 542;
            Sprites["gfxbox"].Y      = 59;
            Sprites["gfxbox"].Bitmap = new Bitmap(177, 177);
            Sprites["gfxbox"].Bitmap.Unlock();
            Sprites["gfxbox"].Bitmap.DrawRect(0, 0, 177, 177, outline);
            Sprites["gfxbox"].Bitmap.DrawRect(1, 1, 175, 175, inline);
            Sprites["gfxbox"].Bitmap.FillRect(2, 2, 173, 173, filler);
            Sprites["gfxbox"].Bitmap.FillRect(163, 163, 13, 13, outline);
            Sprites["gfxbox"].Bitmap.DrawLine(162, 1, 162, 162, inline);
            Sprites["gfxbox"].Bitmap.DrawLine(163, 1, 163, 162, outline);
            Sprites["gfxbox"].Bitmap.DrawLine(164, 1, 164, 162, inline);
            Sprites["gfxbox"].Bitmap.DrawLine(165, 162, 174, 162, inline);
            Sprites["gfxbox"].Bitmap.DrawLine(1, 162, 162, 162, inline);
            Sprites["gfxbox"].Bitmap.DrawLine(1, 163, 162, 163, outline);
            Sprites["gfxbox"].Bitmap.DrawLine(1, 164, 162, 164, inline);
            Sprites["gfxbox"].Bitmap.DrawLine(162, 165, 162, 174, inline);
            Sprites["gfxbox"].Bitmap.Lock();

            Container GraphicContainer = new Container(this);

            GraphicContainer.SetPosition(544, 61);
            GraphicContainer.SetSize(160, 160);
            GraphicContainer.HAutoScroll = true;
            GraphicContainer.VAutoScroll = true;
            VScrollBar vs = new VScrollBar(this);

            vs.SetPosition(708, 62);
            vs.SetSize(10, 158);
            GraphicContainer.SetVScrollBar(vs);
            HScrollBar hs = new HScrollBar(this);

            hs.SetPosition(545, 225);
            hs.SetSize(158, 10);
            GraphicContainer.SetHScrollBar(hs);

            Graphic = new PictureBox(GraphicContainer);

            Cursor = new CursorWidget(GraphicContainer);
            Cursor.ConsiderInAutoScrollCalculation = false;

            Font f = Font.Get("Fonts/ProductSans-M", 12);

            TypeLabel = new Label(this);
            TypeLabel.SetPosition(547, 244);
            TypeLabel.SetFont(f);
            TypeLabel.SetText("Type: File");

            Label DirectionLabel = new Label(this);

            DirectionLabel.SetFont(f);
            DirectionLabel.SetText("Direction:");
            DirectionLabel.SetPosition(547, 269);
            DirectionBox = new DropdownBox(this);
            DirectionBox.SetPosition(609, 263);
            DirectionBox.SetSize(110, 25);
            DirectionBox.SetItems(new List <ListItem>()
            {
                new ListItem("Down"),
                new ListItem("Left"),
                new ListItem("Right"),
                new ListItem("Up")
            });
            DirectionBox.SetSelectedIndex(GraphicData.Direction / 2 - 1);
            DirectionBox.OnSelectionChanged += delegate(BaseEventArgs e)
            {
                GraphicData.Direction = (DirectionBox.SelectedIndex + 1) * 2;
                if (GraphicData.NumDirections == 1)
                {
                    GraphicData.NumDirections = 4;
                    NumDirectionsBox.SetSelectedIndex(1);
                }
                RedrawGraphic();
            };

            Label NumDirectionsLabel = new Label(this);

            NumDirectionsLabel.SetFont(f);
            NumDirectionsLabel.SetText("Number of Directions:");
            NumDirectionsLabel.SetPosition(547, 308);
            NumDirectionsBox = new DropdownBox(this);
            NumDirectionsBox.SetPosition(679, 304);
            NumDirectionsBox.SetSize(40, 25);
            NumDirectionsBox.SetItems(new List <ListItem>()
            {
                new ListItem("1"),
                new ListItem("4")
            });
            NumDirectionsBox.SetSelectedIndex(GraphicData.NumDirections == 1 ? 0 : 1);
            NumDirectionsBox.OnSelectionChanged += delegate(BaseEventArgs e)
            {
                GraphicData.NumDirections = NumDirectionsBox.SelectedIndex == 0 ? 1 : 4;
                RedrawGraphic();
            };

            Label NumFramesLabel = new Label(this);

            NumFramesLabel.SetFont(f);
            NumFramesLabel.SetText("Number of Frames:");
            NumFramesLabel.SetPosition(547, 348);
            NumFramesBox = new NumericBox(this);
            NumFramesBox.SetPosition(669, 343);
            NumFramesBox.SetSize(50, 27);
            NumFramesBox.MinValue = 1;
            NumFramesBox.MaxValue = 999;
            NumFramesBox.SetValue(GraphicData.NumFrames);
            NumFramesBox.OnValueChanged += delegate(BaseEventArgs e)
            {
                GraphicData.NumFrames = NumFramesBox.Value;
                RedrawGraphic();
            };

            FileExplorer = new FileExplorer(this);
            FileExplorer.SetPosition(1, 24);
            FileExplorer.SetSize(529, 396);
            FileExplorer.SetBaseDirectory(Data.ProjectPath);
            FileExplorer.SetFileExtensions("png");
            string dir = "";

            if (GraphicData.Param != null)
            {
                List <string> dirs = ((string)GraphicData.Param).Split('/').ToList();
                for (int i = 0; i < dirs.Count - 1; i++)
                {
                    dir += dirs[i];
                    if (i != dirs.Count - 2)
                    {
                        dir += "/";
                    }
                }
            }
            else
            {
                dir = "gfx/characters";
            }
            FileExplorer.SetDirectory(dir);
            FileExplorer.OnFileSelected += delegate(BaseEventArgs e)
            {
                string param = FileExplorer.SelectedFilename.Replace(Data.ProjectPath + "/", "").Replace(".png", "");
                if (param != (string)this.GraphicData.Param)
                {
                    this.GraphicData       = new EventGraphic();
                    this.GraphicData.Type  = ":file";
                    this.GraphicData.Param = param;
                    DirectionBox.SetSelectedIndex(0);
                    NumDirectionsBox.SetSelectedIndex(1);
                    NumFramesBox.SetValue(4);
                    RedrawGraphic();
                }
            };
            FileExplorer.SetSelectedFile((string)GraphicData.Param + ".png");

            CreateButton("Cancel", Cancel);
            Buttons[0].SetPosition(Size.Width - 99, Buttons[0].Position.Y);
            CreateButton("OK", OK);
            Buttons[1].SetPosition(Size.Width - 188, Buttons[1].Position.Y);

            RedrawGraphic();
        }
Example #7
0
        public LayerPanel(IContainer Parent) : base(Parent)
        {
            Label Header = new Label(this);

            Header.SetText("Layers");
            Header.SetFont(Font.Get("Fonts/Ubuntu-B", 16));
            Header.SetPosition(5, 5);

            Sprites["sep"]   = new Sprite(this.Viewport, new SolidBitmap(288, 2, new Color(10, 23, 37)));
            Sprites["sep"].Y = 30;

            Sprites["slider"]   = new Sprite(this.Viewport, new SolidBitmap(10, Size.Height - 34, new Color(10, 23, 37)));
            Sprites["slider"].Y = 33;

            this.OnWidgetSelected = WidgetSelected;

            layercontainer = new Container(this);
            layercontainer.SetPosition(1, 33);
            layercontainer.VAutoScroll = true;

            VScrollBar vs = new VScrollBar(this);

            layercontainer.SetVScrollBar(vs);

            layerwidget = new LayerWidget(layercontainer);

            this.SetContextMenuList(new List <IMenuItem>()
            {
                new MenuItem("New Layer")
                {
                    OnLeftClick = NewLayerEvent
                },
                new MenuItem("Rename Layer")
                {
                    Shortcut    = "F2",
                    OnLeftClick = RenameLayer
                },
                new MenuSeparator(),
                new MenuItem("Toggle Visibility")
                {
                    OnLeftClick = ToggleVisibilityLayer,
                    IsClickable = delegate(BoolEventArgs e) { e.Value = layerwidget.HoveringIndex >= 0; }
                },
                new MenuItem("Move Layer Up")
                {
                    OnLeftClick = MoveLayerUpEvent,
                    IsClickable = delegate(BoolEventArgs e) { e.Value = SelectedLayer < Map.Layers.Count - 1 && layerwidget.HoveringIndex >= 0; }
                },
                new MenuItem("Move Layer Down")
                {
                    OnLeftClick = MoveLayerDownEvent,
                    IsClickable = delegate(BoolEventArgs e) { e.Value = SelectedLayer > 0 && layerwidget.HoveringIndex >= 0; }
                },
                new MenuSeparator(),
                new MenuItem("Delete Layer")
                {
                    Shortcut    = "Del",
                    OnLeftClick = DeleteLayerEvent,
                    IsClickable = delegate(BoolEventArgs e) { e.Value = Map.Layers.Count > 1 && layerwidget.HoveringIndex >= 0; }
                }
            });

            RegisterShortcuts(new List <Shortcut>()
            {
                new Shortcut(this, new Key(Keycode.DELETE), DeleteLayerEvent),
                new Shortcut(this, new Key(Keycode.F2), RenameLayer)
            });

            SetSize(283, 200); // Dummy size so the sprites can be drawn properly
        }
        public TilesetPickerMap(Map Map)
        {
            SetTitle("Change Tilesets");
            MinimumSize = MaximumSize = new Size(506, 498);
            SetSize(MaximumSize);
            Center();

            OldIDs = new List <int>(Map.AutotileIDs);

            ColoredBox box1 = new ColoredBox(this);

            box1.SetOuterColor(59, 91, 124);
            box1.SetInnerColor(17, 27, 38);
            box1.SetPosition(200, 44);
            box1.SetSize(280, 409);

            ColoredBox box2 = new ColoredBox(this);

            box2.SetOuterColor(24, 38, 53);
            box2.SetPosition(201, 45);
            box2.SetSize(278, 407);

            TilesetContainer = new Container(this);
            TilesetContainer.SetPosition(203, 47);
            TilesetContainer.SetSize(274, 403);
            TilesetContainer.VAutoScroll = true;
            VScrollBar vs = new VScrollBar(this);

            vs.SetPosition(469, 47);
            vs.SetSize(10, 403);
            TilesetContainer.SetVScrollBar(vs);

            TilesetBox = new PictureBox(TilesetContainer);

            Font f = Font.Get("Fonts/Ubuntu-B", 14);

            Label labelavail = new Label(this);

            labelavail.SetText("Available");
            labelavail.SetPosition(16, 24);
            labelavail.SetFont(f);

            Label labelinuse = new Label(this);

            labelinuse.SetText("In-use");
            labelinuse.SetPosition(16, 250);
            labelinuse.SetFont(f);

            Label labelprev = new Label(this);

            labelprev.SetText("Preview");
            labelprev.SetPosition(192, 24);
            labelprev.SetFont(f);

            ActionButton = new Button(this);
            ActionButton.SetPosition(52, 225);
            ActionButton.SetSize(85, 30);
            ActionButton.OnClicked += ActionButtonClicked;

            Available = new ListBox(this);
            Available.SetPosition(25, 44);
            Available.SetSize(151, 179);
            Available.OnSelectionChanged += delegate(BaseEventArgs e)
            {
                if (Available.SelectedIndex != -1)
                {
                    InUse.SetSelectedIndex(-1);
                    SelectionChanged(e);
                }
            };
            Available.ListDrawer.SetContextMenuList(new List <IMenuItem>()
            {
                new MenuItem("Add Tileset")
                {
                    IsClickable = delegate(BoolEventArgs e)
                    {
                        e.Value = !(SelectedTileset is null);
                    },
                    OnLeftClick = ActionButtonClicked
                }
            });