public void ProcessMouse(MouseConsoleState info, ISurface surface, bool isInBounds)
        {
            if (info.IsOnConsole && info.Mouse.LeftClicked)
            {
                var cell   = surface.GetCell(info.ConsolePosition.X, info.ConsolePosition.Y);
                var editor = MainScreen.Instance.ActiveEditor as Editors.GameObjectEditor;

                if (editor != null)
                {
                    editor.SetAnimationCenter(new Point(info.ConsolePosition.X, info.ConsolePosition.Y));
                }
            }
        }
Esempio n. 2
0
        private void StampBrush(int consoleLocationX, int consoleLocationY, ISurface surface)
        {
            int destinationX = consoleLocationX - Brush.Animation.Center.X;
            int destinationY = consoleLocationY - Brush.Animation.Center.Y;
            int destX        = destinationX;
            int destY        = destinationY;

            for (int curx = 0; curx < Brush.SelectedSurface.Animation.Width; curx++)
            {
                for (int cury = 0; cury < Brush.SelectedSurface.Animation.Height; cury++)
                {
                    if (Brush.SelectedSurface.Animation.CurrentFrame.IsValidCell(curx, cury))
                    {
                        var sourceCell = Brush.SelectedSurface.Animation.CurrentFrame.GetCell(curx, cury);

                        // Not working, breakpoint here to remind me.
                        if (_altPanel.SkipEmptyCells && sourceCell.Glyph == 0 && (sourceCell.Background == Color.Transparent || (_altPanel.UseAltEmptyColor && sourceCell.Background == _altPanel.AltEmptyColor)))
                        {
                            destY++;
                            continue;
                        }

                        if (surface.IsValidCell(destX + surface.RenderArea.Location.X, destY + surface.RenderArea.Location.Y))
                        {
                            var desCell = surface.GetCell(destX + surface.RenderArea.Location.X, destY + surface.RenderArea.Location.Y);
                            sourceCell.CopyAppearanceTo(desCell);
                            //TODO: effects
                            //surface.SetEffect(desCell, sourceCell.Effect);
                        }
                    }
                    destY++;
                }
                destY = destinationY;
                destX++;
            }

            surface.IsDirty = true;
        }
Esempio n. 3
0
        public void ProcessMouse(MouseConsoleState info, ISurface surface, bool isInBounds)
        {
            if (info.Mouse.LeftClicked && info.IsOnConsole)
            {
                Cell cellToMatch     = new Cell();
                Cell currentFillCell = new Cell();

                info.Cell.CopyAppearanceTo(cellToMatch);

                currentFillCell.Glyph      = CharacterPickPanel.SharedInstance.SettingCharacter;
                currentFillCell.Foreground = CharacterPickPanel.SharedInstance.SettingForeground;
                currentFillCell.Background = CharacterPickPanel.SharedInstance.SettingBackground;
                currentFillCell.Mirror     = CharacterPickPanel.SharedInstance.SettingMirrorEffect;

                Func <Cell, bool> isTargetCell = (c) =>
                {
                    if (c.Glyph == 0 && cellToMatch.Glyph == 0)
                    {
                        return(c.Background == cellToMatch.Background);
                    }

                    return(c.Foreground == cellToMatch.Foreground &&
                           c.Background == cellToMatch.Background &&
                           c.Glyph == cellToMatch.Glyph &&
                           c.Mirror == cellToMatch.Mirror);
                };

                Action <Cell> fillCell = (c) =>
                {
                    currentFillCell.CopyAppearanceTo(c);
                    //console.TextSurface.SetEffect(c, _currentFillCell.Effect);
                };

                System.Collections.Generic.List <Cell> cells = new System.Collections.Generic.List <Cell>(surface.Cells);

                Func <Cell, SadConsole.Algorithms.NodeConnections <Cell> > getConnectedCells = (c) =>
                {
                    Algorithms.NodeConnections <Cell> connections = new Algorithms.NodeConnections <Cell>();

                    Point position = BasicSurface.GetPointFromIndex(cells.IndexOf(c), surface.Width);

                    connections.West  = surface.IsValidCell(position.X - 1, position.Y) ? surface.GetCell(position.X - 1, position.Y) : null;
                    connections.East  = surface.IsValidCell(position.X + 1, position.Y) ? surface.GetCell(position.X + 1, position.Y) : null;
                    connections.North = surface.IsValidCell(position.X, position.Y - 1) ? surface.GetCell(position.X, position.Y - 1) : null;
                    connections.South = surface.IsValidCell(position.X, position.Y + 1) ? surface.GetCell(position.X, position.Y + 1) : null;

                    return(connections);
                };

                if (!isTargetCell(currentFillCell))
                {
                    SadConsole.Algorithms.FloodFill <Cell>(info.Cell, isTargetCell, fillCell, getConnectedCells);
                }

                info.Console.TextSurface.IsDirty = true;
            }

            if (info.Mouse.RightButtonDown && info.IsOnConsole)
            {
                var cell = info.Cell;

                CharacterPickPanel.SharedInstance.SettingCharacter    = cell.Glyph;
                CharacterPickPanel.SharedInstance.SettingForeground   = cell.Foreground;
                CharacterPickPanel.SharedInstance.SettingBackground   = cell.Background;
                CharacterPickPanel.SharedInstance.SettingMirrorEffect = cell.Mirror;
            }
        }