Exemplo n.º 1
0
        public AutotilePickerMap()
        {
            SetTitle("Individual Tile Combinations");
            MinimumSize = MaximumSize = new Size(313, 285);
            SetSize(MaximumSize);
            Center();

            RectSprite bg1 = new RectSprite(this.Viewport);

            bg1.SetOuterColor(59, 91, 124);
            bg1.SetSize(278, 210);
            bg1.X          = 19;
            bg1.Y          = 34;
            Sprites["bg1"] = bg1;
            RectSprite bg2 = new RectSprite(this.Viewport);

            bg2.SetSize(276, 208);
            bg2.X = 20;
            bg2.Y = 35;
            bg2.SetOuterColor(17, 27, 38);
            bg2.SetInnerColor(24, 38, 53);
            Sprites["bg2"] = bg2;

            CreateButton("Cancel", delegate(BaseEventArgs e)
            {
                SelectedTileID = -1;
                Close();
            });

            CreateButton("OK", delegate(BaseEventArgs e)
            {
                Close();
            });

            Sprites["tiles"]   = new Sprite(this.Viewport);
            Sprites["tiles"].X = 23;
            Sprites["tiles"].Y = 38;

            Cursor = new CursorWidget(this);
            Cursor.SetPosition(Sprites["tiles"].X - 7, Sprites["tiles"].Y - 7);
            Cursor.SetSize(32 + 14, 32 + 14);
        }
Exemplo n.º 2
0
 public override void MouseDown(MouseEventArgs e)
 {
     base.MouseDown(e);
     if (WidgetIM.Hovering)
     {
         int rx = e.X - Viewport.X;
         int ry = e.Y - Viewport.Y;
         if (rx < Sprites["tiles"].X || ry < Sprites["tiles"].Y || rx >= Sprites["tiles"].X + Sprites["tiles"].Bitmap.Width ||
             ry >= Sprites["tiles"].Y + Sprites["tiles"].Bitmap.Height)
         {
             return;
         }
         rx -= Sprites["tiles"].X;
         ry -= Sprites["tiles"].Y;
         int TileX = (int)Math.Floor(rx / 34d);
         int TileY = (int)Math.Floor(ry / 34d);
         Cursor.SetPosition(Sprites["tiles"].X + TileX * 34 - 7, Sprites["tiles"].Y + TileY * 34 - 7);
         SelectedTileID = TileX + TileY * 8;
     }
 }
Exemplo n.º 3
0
        public void UpdateCursorPosition()
        {
            int offsetx = 0;
            int offsety = 0;

            if (CursorOrigin == Location.TopRight || CursorOrigin == Location.BottomRight)
            {
                offsetx = (int)Math.Round(32 * CursorWidth * ZoomFactor);
            }
            if (CursorOrigin == Location.BottomLeft || CursorOrigin == Location.BottomRight)
            {
                offsety = (int)Math.Round(32 * CursorHeight * ZoomFactor);
            }
            Cursor.SetPosition(
                MapWidget.Position.X + (int)Math.Round(32 * MapTileX * ZoomFactor) - offsetx - 7,
                MapWidget.Position.Y + (int)Math.Round(32 * MapTileY * ZoomFactor) - offsety - 7
                );
            Cursor.SetSize(
                (int)Math.Round(32 * ZoomFactor) * (CursorWidth + 1) + 14,
                (int)Math.Round(32 * ZoomFactor) * (CursorHeight + 1) + 14
                );
        }
Exemplo n.º 4
0
        public void RedrawGraphic()
        {
            if (FileExplorer.SelectedIsFolder)
            {
                return;
            }
            Graphic.Sprite.Bitmap?.Dispose();
            Graphic.Sprite.Bitmap = new Bitmap(FileExplorer.SelectedFilename);
            int x = 0;
            int y = 0;
            int w = Graphic.Sprite.Bitmap.Width / GraphicData.NumFrames;
            int h = Graphic.Sprite.Bitmap.Height / GraphicData.NumDirections;

            if (GraphicData.NumDirections == 4)
            {
                y = h * (GraphicData.Direction / 2 - 1);
            }
            if (GraphicData.NumDirections == 8)
            {
                y = h * (GraphicData.Direction - 1);
            }
            Cursor.SetPosition(x - 7, y - 7);
            Cursor.SetSize(w + 14, h + 14);
        }
Exemplo n.º 5
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
        }
Exemplo n.º 6
0
        public void SetMap(Map Map)
        {
            this.MapData = Map;
            Cursor.SetPosition(21, 39);
            AutotileIndex       = -1;
            AutotileCombination = -1;
            TilesetIndex        = 0;
            TileStartX          = 0;
            TileStartY          = 0;
            TileEndX            = 0;
            TileEndY            = 0;
            for (int i = 0; i < this.AutotileContainers.Count; i++)
            {
                if (this.AutotileContainers[i] is CollapsibleContainer)
                {
                    (this.AutotileContainers[i] as CollapsibleContainer).Dispose();
                }
            }
            this.AutotileContainers.Clear();
            if (SingleAutotileContainer is CollapsibleContainer)
            {
                SingleAutotileContainer.Dispose();
            }
            SingleAutotileContainer = null;
            Bitmap singles = null;

            SingleAutotileCount = MapData.AutotileIDs.FindAll(id => Data.Autotiles[id].Format == AutotileFormat.Single).Count;
            if (SingleAutotileCount > 0)
            {
                SingleAutotileContainer = new CollapsibleContainer(MainStackPanel);
                SingleAutotileContainer.SetText("Single Autotiles");
                SingleAutotileContainer.SetMargin(0, 0, 0, 8);
                SingleAutotileContainer.OnCollapsedChanged += delegate(BaseEventArgs e) { UpdateCursor(); };
                singles = new Bitmap(263, 33 + 33 * (int)Math.Floor(SingleAutotileCount / 8d));
                singles.Unlock();
                SingleAutotileContainer.SetSize(MainContainer.Size.Width - 13, singles.Height + 23);
                PictureBox image = new PictureBox(SingleAutotileContainer);
                image.SetPosition(0, 23);
                image.Sprite.Bitmap = singles;
                image.SetSize(image.Sprite.Bitmap.Width, image.Sprite.Bitmap.Height);
            }
            int SingleIndex = 0;

            for (int i = 0; i < MapData.AutotileIDs.Count; i++)
            {
                int      autotileid = MapData.AutotileIDs[i];
                Autotile autotile   = Data.Autotiles[autotileid];
                if (autotile.Format == AutotileFormat.Single)
                {
                    int x = 33 * (SingleIndex % 8);
                    int y = 33 * (int)Math.Floor(SingleIndex / 8d);
                    singles.Build(x, y, autotile.AutotileBitmap, new Rect(0, 0, 32, 32));
                    AutotileContainers.Add(SingleIndex);
                    SingleIndex++;
                    continue;
                }
                CollapsibleContainer c = new CollapsibleContainer(MainStackPanel);
                c.SetText(autotile.Name);
                c.SetMargin(0, 0, 0, 8);
                c.OnCollapsedChanged += delegate(BaseEventArgs e) { UpdateCursor(); };
                c.SetSize(MainContainer.Size.Width - 13, 87);
                c.ObjectData = i;
                AutotileContainers.Add(c);
                PictureBox image = new PictureBox(c);
                image.SetPosition(0, 23);
                AutotileFormat f   = autotile.Format;
                Bitmap         bmp = new Bitmap(263, 64);
                bmp.Unlock();
                for (int j = 0; j < 4; j++)
                {
                    // Constructs a bitmap with the four corner autotile pieces.
                    int x = 0,
                        y = 0;
                    if (j == 0)
                    {
                        y = 32;
                    }
                    else if (j == 1)
                    {
                        x = (f == AutotileFormat.RMVX ? 32 : 64); y = 32;
                    }
                    else if (j == 2)
                    {
                        y = (f == AutotileFormat.RMVX ? 64 : 96);
                    }
                    else if (j == 3)
                    {
                        x = (f == AutotileFormat.RMVX ? 32 : 64); y = (f == AutotileFormat.RMVX ? 64 : 96);
                    }
                    bmp.Build(32 * (j % 2), 32 * (int)Math.Floor(j / 2d), autotile.AutotileBitmap, new Rect(x, y, 32, 32));
                }
                image.Sprite.Bitmap = bmp;
                image.SetSize(image.Sprite.Bitmap.Width, image.Sprite.Bitmap.Height);
                DrawQuickAutotiles(i);
                bmp.Lock();
            }
            if (singles != null)
            {
                singles.Lock();
            }
            for (int i = 0; i < this.TilesetContainers.Count; i++)
            {
                this.TilesetContainers[i].Dispose();
            }
            this.TilesetContainers.Clear();
            this.TilesetImages.Clear();
            for (int i = 0; i < MapData.TilesetIDs.Count; i++)
            {
                int     tilesetid      = MapData.TilesetIDs[i];
                Tileset tileset        = Data.Tilesets[tilesetid];
                CollapsibleContainer c = new CollapsibleContainer(MainStackPanel);
                c.SetText(tileset.Name);
                c.SetMargin(0, 0, 0, 8);
                c.OnCollapsedChanged += delegate(BaseEventArgs e) { UpdateCursor(); };
                c.SetSize(MainContainer.Size.Width - 13, tileset.TilesetListBitmap.Height + 23);
                TilesetContainers.Add(c);
                PictureBox image = new PictureBox(c);
                image.SetPosition(0, 23);
                image.Sprite.Bitmap        = tileset.TilesetListBitmap;
                image.Sprite.DestroyBitmap = false;
                image.SetSize(image.Sprite.Bitmap.Width, image.Sprite.Bitmap.Height);
                TilesetImages.Add(image);
            }
        }
Exemplo n.º 7
0
 public void UpdateCursorPosition()
 {
     Cursor.SetPosition(MapWidget.Position.X + (int)Math.Round(MapTileX * 32 * ZoomFactor) - 7, MapWidget.Position.Y + (int)Math.Round(MapTileY * 32 * ZoomFactor) - 7);
     Cursor.SetSize((int)Math.Round(14 + MapTileWidth * 32 * ZoomFactor), (int)Math.Round(14 + MapTileHeight * 32 * ZoomFactor));
 }