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 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.º 3
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.º 4
0
 public void UpdateCursor()
 {
     if (MapViewer.SelectionOnMap)
     {
         AutotileIndex = AutotileCombination = TilesetIndex = TileStartX = TileEndX = TileStartY = TileEndY = -1;
     }
     if (AutotileIndex == -1 && (TilesetIndex == -1 || TileStartX == -1 || TileEndX == -1 || TileStartY == -1 || TileEndY == -1) ||
         SelectButton.Selected)
     {
         Cursor.SetPosition(0, 0);
         Cursor.SetVisible(false);
         MainContainer.UpdateAutoScroll();
         return;
     }
     if (SelectButton.Selected)
     {
         SelectButton.SetSelected(false);
         PencilButton.SetSelected(true);
     }
     if (AutotileIndex != -1) // Autotile selected
     {
         object image = AutotileContainers[AutotileIndex];
         if (image is int) // Single autotile
         {
             CollapsibleContainer cc = SingleAutotileContainer;
             if (cc.Collapsed || EraserButton.Selected || MapViewer.SelectionOnMap)
             {
                 Cursor.SetVisible(false);
                 Cursor.SetPosition(0, 0);
                 MainContainer.UpdateAutoScroll();
             }
             else
             {
                 Cursor.SetVisible(true);
                 Cursor.SetPosition(1 + 33 * (((int)image) % 8), cc.Position.Y + 19 + 33 * (int)Math.Floor(((int)image) / 8d));
                 Cursor.SetSize(32 + 14, 32 + 14);
             }
         }
         else if (image is CollapsibleContainer) // Other autotile format
         {
             CollapsibleContainer cc = image as CollapsibleContainer;
             if (cc.Collapsed || EraserButton.Selected || MapViewer.SelectionOnMap)
             {
                 Cursor.SetVisible(false);
                 Cursor.SetPosition(0, 0);
                 MainContainer.UpdateAutoScroll();
             }
             else
             {
                 Cursor.SetVisible(true);
                 if (AutotileCombination != -1)
                 {
                     Cursor.SetPosition(67 + 33 * AutotileCombination, cc.Position.Y + 19 + 16);
                     Cursor.SetSize(32 + 14, 32 + 14);
                 }
                 else
                 {
                     Cursor.SetPosition(1, cc.Position.Y + 19);
                     Cursor.SetSize(64 + 14, 64 + 14);
                 }
             }
         }
         MapViewer.CursorOrigin = Location.TopLeft;
         MapViewer.TileDataList.Clear();
         MapViewer.CursorWidth    = 0;
         MapViewer.CursorHeight   = 0;
         MapViewer.SelectionOnMap = false;
         MapViewer.UpdateCursorPosition();
         int tileid = -1;
         if (AutotileCombination != -1)
         {
             tileid = (int)Data.Autotiles[MapData.AutotileIDs[AutotileIndex]].QuickIDs[AutotileCombination];
         }
         MapViewer.TileDataList = new List <TileData>()
         {
             new TileData()
             {
                 TileType = TileType.Autotile, Index = AutotileIndex, ID = tileid
             }
         };
     }
     else // Tileset selected
     {
         int      DiffX    = TileEndX - TileStartX;
         int      DiffY    = TileEndY - TileStartY;
         int      PosDiffX = 0;
         int      PosDiffY = 0;
         Location origin   = Location.BottomRight;
         // If the origin is bottom right instead of top left
         if (DiffX < 0)
         {
             DiffX    = -DiffX;
             PosDiffX = 33 * DiffX;
             origin   = Location.BottomLeft;
         }
         if (DiffY < 0)
         {
             DiffY    = -DiffY;
             PosDiffY = 33 * DiffY;
             if (origin == Location.BottomLeft)
             {
                 origin = Location.TopLeft;
             }
             else
             {
                 origin = Location.TopRight;
             }
         }
         MapViewer.CursorOrigin = origin;
         MapViewer.TileDataList.Clear();
         MapViewer.CursorWidth    = DiffX;
         MapViewer.CursorHeight   = DiffY;
         MapViewer.SelectionOnMap = false;
         MapViewer.UpdateCursorPosition();
         int sx = TileStartX < TileEndX ? TileStartX : TileEndX;
         int ex = TileStartX < TileEndX ? TileEndX : TileStartX;
         int sy = TileStartY < TileEndY ? TileStartY : TileEndY;
         int ey = TileStartY < TileEndY ? TileEndY : TileStartY;
         for (int y = sy; y <= ey; y++)
         {
             for (int x = sx; x <= ex; x++)
             {
                 int tileid = y * 8 + x;
                 MapViewer.TileDataList.Add(new TileData()
                 {
                     TileType = TileType.Tileset, Index = TilesetIndex, ID = tileid
                 });
             }
         }
         CollapsibleContainer cc = TilesetContainers[TilesetIndex];
         if (cc.Collapsed || EraserButton.Selected || MapViewer.SelectionOnMap)
         {
             Cursor.SetPosition(0, 0);
             Cursor.SetVisible(false);
             MainContainer.UpdateAutoScroll();
         }
         else
         {
             Cursor.SetVisible(true);
             Cursor.SetPosition(1 + TileStartX * 33 - PosDiffX, 19 + cc.Position.Y + TileStartY * 33 - PosDiffY);
             Cursor.SetSize(32 * (DiffX + 1) + DiffX + 14, 32 * (DiffY + 1) + DiffY + 14);
         }
     }
 }
Exemplo n.º 5
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));
 }