Exemplo n.º 1
0
        protected override void OnCurrentSelectionChanged(EventArgs e)
        {
            var listSelection = ConvertSelection(CurrentSelection);

            gfxTileRenderer.CurrentSelection = listSelection;
            if (Palette != null)
            {
                Gfx.CurrentSelection = listSelection;
            }

            base.OnCurrentSelectionChanged(e);

            IListSelection ConvertSelection(ITileMapSelection selection)
            {
                if (selection is null)
                {
                    return(null);
                }

                var indexes = selection.Select(
                    p => TileMap1D.GetTileIndex(p, selection.GridWidth));

                return(new EnumerableIndexListSelection(indexes));
            }
        }
Exemplo n.º 2
0
        protected override void OnTileMapChanged(EventArgs e)
        {
            if (TileMap != paletteEditorControl.TileMap)
            {
                TileMap = paletteEditorControl.TileMap;
                return;
            }

            base.OnTileMapChanged(e);
        }
Exemplo n.º 3
0
        private ITileMapSelection ChooseSelection()
        {
            ITileMapSelection result = null;

            if (DesignControl.AltKeyHeld)
            {
                var firstIndex = TileMap1D.GetTileIndex(
                    FirstGridTile,
                    TileMap.GridWidth);

                var activeIndex = TileMap1D.GetTileIndex(
                    ActiveGridTile,
                    TileMap.GridWidth);

                var originIndex = Min(firstIndex, activeIndex);
                var endIndex    = Max(firstIndex, activeIndex);
                var count       = endIndex - originIndex + 1;
                result = new LinearTileMapSelection(
                    firstIndex < activeIndex ? FirstGridTile : ActiveGridTile,
                    count,
                    TileMap.GridWidth);
            }
            else
            {
                var origin = new Point(
                    Min(FirstGridTile.X, ActiveGridTile.X),
                    Min(FirstGridTile.Y, ActiveGridTile.Y));

                var end = new Point(
                    Max(FirstGridTile.X, ActiveGridTile.X),
                    Max(FirstGridTile.Y, ActiveGridTile.Y));

                var size = new Size(
                    end.X + 1 - origin.X,
                    end.Y + 1 - origin.Y);
                result = new BoxTileMapSelection(
                    origin,
                    size,
                    TileMap.GridWidth);
            }

            if (DesignControl.ControlKeyHeld && CurrentSelection != null)
            {
                result = new EnumerableTileMapSelection(
                    CurrentSelection.Union(result),
                    TileMap.GridWidth);
            }

            return(result);
        }
Exemplo n.º 4
0
 private Point GetPoint(int index)
 {
     return(TileMap1D.GetTile(index, GridWidth, MinIndex));
 }
Exemplo n.º 5
0
 private int GetIndex(Point point)
 {
     return(TileMap1D.GetTileIndex(point, GridWidth, MinIndex));
 }