Beispiel #1
0
        public void MouseMoveSurface(MouseInfo info, ITextSurface surface)
        {
            Brush.Position = info.ConsoleLocation;
            Brush.IsVisible = true;

            if (info.LeftButtonDown)
            {
                var cell = surface.GetCell(info.ConsoleLocation.X, info.ConsoleLocation.Y);

                if (!settingsPanel.IgnoreForeground)
                    cell.Foreground = CharacterPickPanel.SharedInstance.SettingForeground;

                if (!settingsPanel.IgnoreBackground)
                    cell.Background = CharacterPickPanel.SharedInstance.SettingBackground;
            }
            else if (info.RightButtonDown)
            {
                var cell = surface.GetCell(info.ConsoleLocation.X, info.ConsoleLocation.Y);

                if (!settingsPanel.IgnoreForeground)
                    CharacterPickPanel.SharedInstance.SettingForeground = cell.Foreground;

                if (!settingsPanel.IgnoreBackground)
                    CharacterPickPanel.SharedInstance.SettingBackground = cell.Background;
            }
        }
Beispiel #2
0
        public void MouseMoveSurface(MouseInfo info, ITextSurface surface)
        {
            Brush.IsVisible = true;
            Brush.Position = info.ConsoleLocation;

            if (info.LeftButtonDown)
            {
                var cell = surface.GetCell(info.ConsoleLocation.X, info.ConsoleLocation.Y);
                cell.GlyphIndex = CharacterPickPanel.SharedInstance.SettingCharacter;
                cell.Foreground = CharacterPickPanel.SharedInstance.SettingForeground;
                cell.Background = CharacterPickPanel.SharedInstance.SettingBackground;
                cell.SpriteEffect = CharacterPickPanel.SharedInstance.SettingMirrorEffect;
            }

            if (info.RightButtonDown)
            {
                var cell = surface.GetCell(info.ConsoleLocation.X, info.ConsoleLocation.Y);

                CharacterPickPanel.SharedInstance.SettingCharacter = cell.GlyphIndex;
                CharacterPickPanel.SharedInstance.SettingForeground = cell.Foreground;
                CharacterPickPanel.SharedInstance.SettingBackground = cell.Background;
                CharacterPickPanel.SharedInstance.SettingMirrorEffect = cell.SpriteEffect;
            }
        }
        public void MouseMoveSurface(MouseInfo info, ITextSurface surface)
        {
            Brush.Position = info.ConsoleLocation;
            Brush.IsVisible = true;

            if (info.LeftClicked)
            {
                var cell = surface.GetCell(info.ConsoleLocation.X, info.ConsoleLocation.Y);
                var editor = EditorConsoleManager.ActiveEditor as Editors.GameObjectEditor;

                if (editor != null)
                {
                    editor.SetAnimationCenter(new Point(info.ConsoleLocation.X, info.ConsoleLocation.Y));
                }
            }
        }
        private void StampBrush(int consoleLocationX, int consoleLocationY, ITextSurface 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.GlyphIndex == 0 && (sourceCell.Background == Color.Transparent || (_altPanel.UseAltEmptyColor && sourceCell.Background == _altPanel.AltEmptyColor)))
                        {
                            destY++;
                            continue;
                        }

                        if (surface.IsValidCell(destX, destY))
                        {
                            var desCell = surface.GetCell(destX, destY);
                            sourceCell.CopyAppearanceTo(desCell);
                            //TODO: effects
                            //surface.SetEffect(desCell, sourceCell.Effect);
                        }
                    }
                    destY++;
                }
                destY = destinationY;
                destX++;
            }
        }
Beispiel #5
0
        public void MouseMoveSurface(MouseInfo info, ITextSurface surface)
        {
            Brush.Position = info.ConsoleLocation;
            Brush.IsVisible = true;

            if (info.LeftClicked)
            {
                Cell cellToMatch = new Cell();
                Cell currentFillCell = new Cell();

                surface.GetCell(info.ConsoleLocation.X, info.ConsoleLocation.Y).Copy(cellToMatch);
                cellToMatch.Effect = surface.GetCell(info.ConsoleLocation.X, info.ConsoleLocation.Y).Effect;

                currentFillCell.GlyphIndex = CharacterPickPanel.SharedInstance.SettingCharacter;
                currentFillCell.Foreground = CharacterPickPanel.SharedInstance.SettingForeground;
                currentFillCell.Background = CharacterPickPanel.SharedInstance.SettingBackground;
                currentFillCell.SpriteEffect = CharacterPickPanel.SharedInstance.SettingMirrorEffect;

                Func<Cell, bool> isTargetCell = (c) =>
                {
                    bool effect = c.Effect == null && cellToMatch.Effect == null;

                    if (c.Effect != null && cellToMatch.Effect != null)
                        effect = c.Effect == cellToMatch.Effect;

                    if (c.GlyphIndex == 0 && cellToMatch.GlyphIndex == 0)
                        return c.Background == cellToMatch.Background;

                    return c.Foreground == cellToMatch.Foreground &&
                           c.Background == cellToMatch.Background &&
                           c.GlyphIndex == cellToMatch.GlyphIndex &&
                           c.SpriteEffect == cellToMatch.SpriteEffect &&
                           effect;
                };

                Action<Cell> fillCell = (c) =>
                {
                    currentFillCell.Copy(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 = TextSurface.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>(surface.GetCell(info.ConsoleLocation.X, info.ConsoleLocation.Y), isTargetCell, fillCell, getConnectedCells);
            }

            if (info.RightButtonDown)
            {
                var cell = surface.GetCell(info.ConsoleLocation.X, info.ConsoleLocation.Y);

                CharacterPickPanel.SharedInstance.SettingCharacter = cell.GlyphIndex;
                CharacterPickPanel.SharedInstance.SettingForeground = cell.Foreground;
                CharacterPickPanel.SharedInstance.SettingBackground = cell.Background;
                CharacterPickPanel.SharedInstance.SettingMirrorEffect = cell.SpriteEffect;
            }
        }