Exemple #1
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();
        }
        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
                }
            });