Ejemplo n.º 1
0
        public BoxTool()
        {
            animSinglePoint = new AnimatedTextSurface("single", 1, 1, Settings.Config.ScreenFont);
            var _frameSinglePoint = animSinglePoint.CreateFrame();
            _frameSinglePoint[0].GlyphIndex = 42;

            frameEffect = new SadConsole.Effects.Fade()
            {
                UseCellBackground = true,
                FadeForeground = true,
                FadeDuration = 1f,
                AutoReverse = true
            };

            _settingsPanel = new BoxToolPanel();

            ControlPanels = new CustomPanel[] { _settingsPanel };

            //
            Brush = new SadConsole.Game.GameObject();
            Brush.Font = Settings.Config.ScreenFont;
            AnimatedTextSurface animation = new AnimatedTextSurface("single", 1, 1, Settings.Config.ScreenFont);
            animation.CreateFrame()[0].GlyphIndex = 42;
            Brush.Animations.Add(animation.Name, animation);
            Brush.Animation = animation;
        }
Ejemplo n.º 2
0
 public Player()
     : base(SadConsole.Engine.DefaultFont)
 {
     Animation = new AnimatedTextSurface("default", 1, 1, SadConsole.Engine.DefaultFont);
     var frame = Animation.CreateFrame();
     frame[0].GlyphIndex = 5;
     this.CurrentDirection = Direction.None;
     Health = 70;
 }
Ejemplo n.º 3
0
        public Hound()
            : base(SadConsole.Engine.DefaultFont)
        {
            AnimatedTextSurface anim = new AnimatedTextSurface("default", 1, 1, SadConsole.Engine.DefaultFont);
            var frame = anim.CreateFrame();
            frame[0].Foreground = Color.Red;
            frame[0].Background = Color.Black;
            frame[0].GlyphIndex = 72;

            Animation = anim;
        }
Ejemplo n.º 4
0
        public Player()
            : base(SadConsole.Engine.DefaultFont)
        {
            AnimatedTextSurface anim = new AnimatedTextSurface("default", 1, 1, SadConsole.Engine.DefaultFont);
            var frame = anim.CreateFrame();
            frame[0].Foreground = Color.Yellow;
            frame[0].Background = Color.Black;
            frame[0].GlyphIndex = 1;

            Animation = anim;
            anim.Start();
        }
Ejemplo n.º 5
0
 public Serialized(AnimatedTextSurface surface)
 {
     Frames            = surface.Frames.ToArray();
     Width             = surface.width;
     Height            = surface.height;
     AnimationDuration = surface.AnimationDuration;
     Name     = surface.Name;
     FontName = surface.font.Name;
     FontSize = surface.font.SizeMultiple;
     Repeat   = surface.Repeat;
     Center   = surface.Center;
 }
Ejemplo n.º 6
0
        public GameObjectConsole()
            : base(80, 25)
        {
            var animation = new AnimatedTextSurface("default", 1, 1, SadConsole.Engine.DefaultFont);
            var frame = animation.CreateFrame();
            frame.Cells[0].GlyphIndex = 1;

            player = new SadConsole.Game.GameObject(SadConsole.Engine.DefaultFont);
            player.Animation = animation;
            player.RepositionRects = true;
            player.Position = new Point(textSurface.Width / 2, textSurface.Height / 2);
            playerPreviousPosition = player.Position;

            // Setup this console to accept keyboard input.
            CanUseKeyboard = true;
            IsVisible = false;
        }
        public PreviewAnimationPopup(AnimatedTextSurface animation)
            : base(animation.Width + 2, animation.Height + 4)
        {
            textSurface.Font = Settings.Config.ScreenFont;
            this.animation = animation;

            CloseOnESC = true;
            entity = new GameObject(Settings.Config.ScreenFont);
            entity.Position = new Point(1, 1);
            entity.Animation = animation;
            animation.Restart();
            entity.Animation.Start();

            restartAnimation = new Button(animation.Width, 1);
            restartAnimation.Text = "Restart";
            restartAnimation.Position = new Point(1, textSurface.Height - 2);
            restartAnimation.ButtonClicked += (s, e) => this.animation.Restart();
            Add(restartAnimation);
        }
Ejemplo n.º 8
0
        public CircleTool()
        {
            frameEffect = new SadConsole.Effects.Fade()
            {
                UseCellBackground = true,
                FadeForeground = true,
                FadeDuration = 1f,
                AutoReverse = true
            };

            // Configure the animations
            Brush = new SadConsole.Game.GameObject();
            Brush.Font = Settings.Config.ScreenFont;
            AnimatedTextSurface animation = new AnimatedTextSurface("single", 1, 1, Settings.Config.ScreenFont);
            animation.CreateFrame()[0].GlyphIndex = 42;
            Brush.Animations.Add(animation.Name, animation);

            settingsPanel = new CircleToolPanel();
            ControlPanels = new CustomPanel[] { settingsPanel, CharacterPickPanel.SharedInstance };
            ResetCircle();
        }
Ejemplo n.º 9
0
            public static AnimatedTextSurface Get(Serialized serializedObject)
            {
                Font font;

                // Try to find font
                if (Engine.Fonts.ContainsKey(serializedObject.FontName))
                {
                    font = Engine.Fonts[serializedObject.FontName].GetFont(serializedObject.FontSize);
                }
                else
                {
                    font = Engine.DefaultFont;
                }

                var animationSurface = new AnimatedTextSurface(serializedObject.Name, serializedObject.Width, serializedObject.Height, font);

                animationSurface.Frames = new List <TextSurfaceBasic>(serializedObject.Frames);
                animationSurface.UpdateFrameReferences();
                animationSurface.AnimationDuration = serializedObject.AnimationDuration;
                animationSurface.Repeat            = serializedObject.Repeat;
                animationSurface.Center            = serializedObject.Center;
                return(animationSurface);
            }
Ejemplo n.º 10
0
        public void ProcessMouse(MouseInfo info, ITextSurface surface)
        {
            if (EditorConsoleManager.ToolsPane.IsMouseOver)
            {
                Brush.IsVisible = false;
                return;
            }
            else
                Brush.IsVisible = true;

            if (!firstPoint.HasValue)
            {
                Brush.Position = info.ConsoleLocation;
            }
            else
            {
                // Draw the line (erase old) to where the mouse is
                // create the animation frame
                AnimatedTextSurface animation = new AnimatedTextSurface("line", Math.Max(firstPoint.Value.X, info.ConsoleLocation.X) - Math.Min(firstPoint.Value.X, info.ConsoleLocation.X) + 1,
                                                                                Math.Max(firstPoint.Value.Y, info.ConsoleLocation.Y) - Math.Min(firstPoint.Value.Y, info.ConsoleLocation.Y) + 1,
                                                                                Settings.Config.ScreenFont);

                var frame = animation.CreateFrame();

                Point p1;

                if (firstPoint.Value.X > info.ConsoleLocation.X)
                {
                    if (firstPoint.Value.Y > info.ConsoleLocation.Y)
                        p1 = new Point(frame.Width - 1, frame.Height - 1);
                    else
                        p1 = new Point(frame.Width - 1, 0);
                }
                else
                {
                    if (firstPoint.Value.Y > info.ConsoleLocation.Y)
                        p1 = new Point(0, frame.Height - 1);
                    else
                        p1 = new Point(0, 0);
                }

                animation.Center = p1;

                boxShape = SadConsole.Shapes.Box.GetDefaultBox();

                if (_settingsPanel.UseCharacterBorder)
                    boxShape.LeftSideCharacter = boxShape.RightSideCharacter =
                    boxShape.TopLeftCharacter = boxShape.TopRightCharacter = boxShape.TopSideCharacter =
                    boxShape.BottomLeftCharacter = boxShape.BottomRightCharacter = boxShape.BottomSideCharacter =
                    _settingsPanel.BorderCharacter;

                boxShape.Foreground = _settingsPanel.LineForeColor;
                boxShape.FillColor = _settingsPanel.FillColor;
                boxShape.Fill = _settingsPanel.UseFill;
                boxShape.BorderBackground = _settingsPanel.LineBackColor;
                boxShape.Location = new Point(0, 0);
                boxShape.Width = frame.Width;
                boxShape.Height = frame.Height;
                boxShape.Draw(new SurfaceEditor(frame));

                Brush.Animation = animation;
            }

            // TODO: Make this work. They push DOWN on the mouse, start the line from there, if they "Click" then go to mode where they click a second time
            // If they don't click and hold it down longer than click, pretend a second click happened and draw the line.
            if (info.LeftClicked)
            {
                if (!firstPoint.HasValue)
                {
                    firstPoint = new Point(info.ConsoleLocation.X, info.ConsoleLocation.Y);
                }
                else
                {
                    secondPoint = new Point(info.ConsoleLocation.X, info.ConsoleLocation.Y);
                    Point p1 = new Point(Math.Min(firstPoint.Value.X, secondPoint.Value.X), Math.Min(firstPoint.Value.Y, secondPoint.Value.Y));
                    //Point p2 = new Point(Math.Max(_firstPoint.Value.X, _secondPoint.Value.X), Math.Max(_firstPoint.Value.Y, _secondPoint.Value.Y));

                    boxShape.Location = p1;
                    boxShape.Draw(new SurfaceEditor(surface));

                    firstPoint = null;
                    secondPoint = null;

                    Brush.Animation = Brush.Animations["single"];

                    //surface.ResyncAllCellEffects();
                }
            }
            else if (info.RightClicked)
            {
                if (firstPoint.HasValue && !secondPoint.HasValue)
                {
                    firstPoint = null;
                    secondPoint = null;

                    Brush.Animation = Brush.Animations["single"];
                }
            }
        }
Ejemplo n.º 11
0
        private void SetAnimationLine(Point mousePosition)
        {
            // Draw the line (erase old) to where the mouse is
            // create the animation frame
            AnimatedTextSurface animation = new AnimatedTextSurface("line", Math.Max(firstPoint.Value.X, mousePosition.X) - Math.Min(firstPoint.Value.X, mousePosition.X) + 1,
                                                                            Math.Max(firstPoint.Value.Y, mousePosition.Y) - Math.Min(firstPoint.Value.Y, mousePosition.Y) + 1,
                                                                            Settings.Config.ScreenFont);

            var frame = animation.CreateFrame();

            Point p1;
            Point p2;

            if (firstPoint.Value.X > mousePosition.X)
            {
                if (firstPoint.Value.Y > mousePosition.Y)
                {
                    p1 = new Point(frame.Width - 1, frame.Height - 1);
                    p2 = new Point(0, 0);
                }
                else
                {
                    p1 = new Point(frame.Width - 1, 0);
                    p2 = new Point(0, frame.Height - 1);
                }
            }
            else
            {
                if (firstPoint.Value.Y > mousePosition.Y)
                {
                    p1 = new Point(0, frame.Height - 1);
                    p2 = new Point(frame.Width - 1, 0);
                }
                else
                {
                    p1 = new Point(0, 0);
                    p2 = new Point(frame.Width - 1, frame.Height - 1);
                }
            }

            animation.Center = p1;

            //_lineStyle = new CellAppearance(
            //                    EditorConsoleManager.Instance.ToolPane.CommonCharacterPickerPanel.SettingForeground,
            //                    EditorConsoleManager.Instance.ToolPane.CommonCharacterPickerPanel.SettingBackground,
            //                    EditorConsoleManager.Instance.ToolPane.CommonCharacterPickerPanel.SettingCharacter);
            //_lineStyle.SpriteEffect = EditorConsoleManager.Instance.ToolPane.CommonCharacterPickerPanel.SettingMirrorEffect;
            //_lineStyle.CopyAppearanceTo(_lineCell);

            lineShape = new SadConsole.Shapes.Line();
            lineShape.CellAppearance = lineCell;
            lineShape.UseEndingCell = false;
            lineShape.UseStartingCell = false;
            lineShape.StartingLocation = p1;
            lineShape.EndingLocation = p2;
            lineShape.Draw(new SurfaceEditor(frame));

            settingsPanel.LineLength = frame.Width > frame.Height ? frame.Width : frame.Height;

            Brush.Animation = animation;
        }
Ejemplo n.º 12
0
        public void Resize(int width, int height)
        {
            //var oldSurface = (LayeredTextSurface)_consoleLayers.TextSurface;
            //var newSurface = new LayeredTextSurface(width, height, oldSurface.LayerCount);

            //for (int i = 0; i < oldSurface.LayerCount; i++)
            //{
            //    var oldLayer = oldSurface.GetLayer(i);
            //    var newLayer = newSurface.GetLayer(i);
            //    oldSurface.SetActiveLayer(i);
            //    newSurface.SetActiveLayer(i);
            //    oldSurface.Copy(newSurface);
            //    newLayer.Metadata = oldLayer.Metadata;
            //    newLayer.IsVisible = oldLayer.IsVisible;
            //}

            List<AnimatedTextSurface> newAnimations = new List<AnimatedTextSurface>(gameObject.Animations.Count);

            foreach (var oldAnimation in gameObject.Animations.Values)
            {
                var newAnimation = new AnimatedTextSurface(oldAnimation.Name, width, height, SadConsoleEditor.Settings.Config.ScreenFont);

                for (int i = 0; i < oldAnimation.Frames.Count; i++)
                {
                    oldAnimation.Frames[i].Copy(newAnimation.CreateFrame());
                }

                newAnimation.CurrentFrameIndex = 0;
                newAnimations.Add(newAnimation);
                newAnimation.AnimationDuration = oldAnimation.AnimationDuration;
                newAnimation.Center = oldAnimation.Center;
            }

            foreach (var animation in newAnimations)
            {
                gameObject.Animations[animation.Name] = animation;

                if (gameObject.Animation.Name == animation.Name)
                    gameObject.Animation = animation;

                if (selectedAnimation.Name == animation.Name)
                    selectedAnimation = animation;
            }

            // inform the outer box we've changed size
            //EditorConsoleManager.Instance.UpdateBox();

            SetEntity(gameObject);

            if (EditorConsoleManager.ActiveEditor == this)
            {
                EditorConsoleManager.CenterEditor();
                EditorConsoleManager.UpdateBorder(consoleWrapper.Position);
            }
        }
Ejemplo n.º 13
0
        public SelectionTool()
        {
            Brush = new LayeredGameObject();
            Brush.Font = Settings.Config.ScreenFont;

            var animation = new AnimatedTextSurface(AnimationSingle, 1, 1, Settings.Config.ScreenFont);
            animation.CreateFrame()[0].GlyphIndex = 42;
            animation.Frames[0][0].Background = Color.Black;
            Brush.Animations.Add(animation.Name, animation);

            animation = new AnimatedTextSurface(AnimationSelection, 1, 1, Settings.Config.ScreenFont);
            Brush.Animations.Add(animation.Name, animation);

            _frameEffect = new SadConsole.Effects.Fade()
            {
                UseCellBackground = true,
                FadeForeground = true,
                FadeDuration = 1f,
                AutoReverse = true
            };

            _panel = new SelectionToolPanel(LoadBrush, SaveBrush);
            _panel.StateChangedHandler = PanelStateChanged;
            _panel.State = SelectionToolPanel.CloneState.SelectingPoint1;

            _altPanel = new SelectionToolAltPanel();

            ControlPanels = new CustomPanel[] { _panel, _altPanel };

            _pulseAnimation = new SadConsole.Effects.Fade()
            {
                FadeBackground = true,
                UseCellBackground = false,
                DestinationBackground = Color.Transparent,
                FadeDuration = 2d,
                CloneOnApply = false,
                AutoReverse = true,
                Repeat = true,
            };
        }
Ejemplo n.º 14
0
        public void New(Color foreground, Color background, int width, int height)
        {
            Reset();

            var gameObject = new GameObject(SadConsoleEditor.Settings.Config.ScreenFont);

            AnimatedTextSurface animation = new AnimatedTextSurface("default", width, height, SadConsoleEditor.Settings.Config.ScreenFont);
            animation.DefaultForeground = foreground;
            animation.DefaultBackground = background;
            animation.CreateFrame();
            animation.AnimationDuration = 1;

            gameObject.Animations[animation.Name] = animation;
            gameObject.Animation = animation;
            gameObject.Name = "game object";

            SetEntity(gameObject);
        }
Ejemplo n.º 15
0
        void addNewAnimation_ButtonClicked(object sender, EventArgs e)
        {
            RenamePopup popup = new RenamePopup("", "Animation Name");
            popup.Closed += (o, e2) =>
            {

                if (popup.DialogResult)
                {
                    string newName = popup.NewName.Trim();
                    var keys = entity.Animations.Keys.Select(k => k.ToLower()).ToList();

                    if (keys.Contains(newName.ToLower()))
                    {
                        Window.Message("Name must be unique", "Close");
                    }
                    else if (string.IsNullOrEmpty(newName))
                    {
                        Window.Message("Name cannot be blank", "Close");
                    }
                    else
                    {
                        var previouslySelected = (AnimatedTextSurface)animations.SelectedItem;
                        var animation = new AnimatedTextSurface(newName, previouslySelected.Width, previouslySelected.Height, Settings.Config.ScreenFont);
                        animation.CreateFrame();
                        animation.AnimationDuration = 1;
                        entity.Animations[animation.Name] = animation;
                        RebuildListBox();
                        animations.SelectedItem = animation;
                    }
                }
            };
            popup.Show(true);
            popup.Center();
        }
Ejemplo n.º 16
0
        public void MouseMoveSurface(MouseInfo info, ITextSurface surface)
        {
            Brush.IsVisible = true;

            if (!firstPoint.HasValue)
            {
                Brush.Position = info.ConsoleLocation;

                settingsPanel.CircleWidth = 0;
                settingsPanel.CircleHeight = 0;
            }
            else
            {
                AnimatedTextSurface animation;
                // Draw the line (erase old) to where the mouse is
                // create the animation frame
                animation = new AnimatedTextSurface("line", Math.Max(firstPoint.Value.X, info.ConsoleLocation.X) - Math.Min(firstPoint.Value.X, info.ConsoleLocation.X) + 1,
                                                            Math.Max(firstPoint.Value.Y, info.ConsoleLocation.Y) - Math.Min(firstPoint.Value.Y, info.ConsoleLocation.Y) + 1,
                                                            Settings.Config.ScreenFont);

                var frame = animation.CreateFrame();

                Point p1;

                if (firstPoint.Value.X > info.ConsoleLocation.X)
                {
                    if (firstPoint.Value.Y > info.ConsoleLocation.Y)
                        p1 = new Point(frame.Width - 1, frame.Height - 1);
                    else
                        p1 = new Point(frame.Width - 1, 0);
                }
                else
                {
                    if (firstPoint.Value.Y > info.ConsoleLocation.Y)
                        p1 = new Point(0, frame.Height - 1);
                    else
                        p1 = new Point(0, 0);
                }

                settingsPanel.CircleWidth = frame.Width;
                settingsPanel.CircleHeight = frame.Height;

                animation.Center = p1;

                Settings.QuickEditor.TextSurface = frame;

                ellipseShape = new SadConsole.Shapes.Ellipse();
                ellipseShape.BorderAppearance = borderAppearance;
                ellipseShape.EndingPoint = new Point(frame.Width - 1, frame.Height - 1);
                ellipseShape.Draw(Settings.QuickEditor);

                Brush.Animation = animation;
            }

            // TODO: Make this work. They push DOWN on the mouse, start the line from there, if they "Click" then go to mode where they click a second time
            // If they don't click and hold it down longer than click, pretend a second click happened and draw the line.
            if (info.LeftClicked)
            {
                if (!firstPoint.HasValue)
                {
                    firstPoint = new Point(info.ConsoleLocation.X, info.ConsoleLocation.Y);
                    RefreshTool();
                }
                else
                {
                    secondPoint = new Point(info.ConsoleLocation.X, info.ConsoleLocation.Y);
                    Point p1 = new Point(Math.Min(firstPoint.Value.X, secondPoint.Value.X), Math.Min(firstPoint.Value.Y, secondPoint.Value.Y));
                    Point p2 = new Point(Math.Max(firstPoint.Value.X, secondPoint.Value.X), Math.Max(firstPoint.Value.Y, secondPoint.Value.Y));

                    Settings.QuickEditor.TextSurface = surface;

                    ellipseShape.StartingPoint = p1;
                    ellipseShape.EndingPoint = p2;
                    ellipseShape.Draw(Settings.QuickEditor);

                    Brush.Animation = Brush.Animations["single"];
                    Brush.Position = secondPoint.Value;

                    firstPoint = null;
                    secondPoint = null;

                    //surface.ResyncAllCellEffects();
                }
            }
            else if (info.RightClicked)
            {
                if (firstPoint.HasValue && !secondPoint.HasValue)
                {
                    firstPoint = null;
                    secondPoint = null;

                    settingsPanel.CircleWidth = 0;
                    settingsPanel.CircleHeight = 0;

                    Brush.Animation = Brush.Animations["single"];
                    Brush.Position = new Point(info.ConsoleLocation.X, info.ConsoleLocation.Y);
                }
            }
        }
Ejemplo n.º 17
0
        public Monster(String name, String inventoryName, int roomId, int x, int y, int character, int health, string description, string deadDescription)
            : base(SadConsole.Engine.DefaultFont)
        {
            this.IsAlive = true;
            this.Name = inventoryName;
            this.InventoryName = name;
            this.RoomId = roomId;
            position.X = x;
            position.Y = y;
            this.Character = character;
            this.Health = health;
            this.Description = description;
            this.DeadDescription = deadDescription;
            this.Value = 100;
            this.IsGuard = false;

            Animation = new AnimatedTextSurface("default", 1, 1, SadConsole.Engine.DefaultFont);
            var frame = Animation.CreateFrame();
            frame[0].GlyphIndex = character;
        }
Ejemplo n.º 18
0
        public void SetAnimation(AnimatedTextSurface animation)
        {
            currentAnimation = animation;

            selectedFrame = currentAnimation.Frames[0];

            EnableDisableControls(0);
            DrawFrameCount();

            frameChangeCallback(selectedFrame);
        }
Ejemplo n.º 19
0
        private void SelectedAnimationChanged(AnimatedTextSurface animation)
        {
            selectedAnimation = animation;

            consoleWrapper.TextSurface = textSurface = new LayeredTextSurface(animation.Width, animation.Height, Settings.Config.ScreenFont, 4);

            SyncSpecialLayerToAnimation();

            ((LayeredTextSurface)consoleWrapper.TextSurface).SetActiveLayer(0);

            // inform the outer box we've changed size
            if (EditorConsoleManager.ActiveEditor == this)
                EditorConsoleManager.UpdateBorder(consoleWrapper.Position);

            framesPanel.SetAnimation(animation);
            SelectedTool = selectedTool;
        }
Ejemplo n.º 20
0
            public static void Save(AnimatedTextSurface surface, string file)
            {
                var animation = new Serialized(surface);

                Serializer.Save(animation, file, new Type[] { typeof(List <TextSurfaceBasic>), typeof(Font) });
            }
Ejemplo n.º 21
0
        public void LoadBrush(TextSurface surface)
        {
            _panel.State = SelectionToolPanel.CloneState.Clone;

            // Copy data to new animation
            var cloneAnimation = new AnimatedTextSurface("clone", surface.Width, surface.Height, Settings.Config.ScreenFont);
            var frame = cloneAnimation.CreateFrame();
            surface.Copy(frame);

            cloneAnimation.Center = new Point(cloneAnimation.Width / 2, cloneAnimation.Height / 2);

            Brush.SelectedSurface.Animation = cloneAnimation;
            //Brush.Animation.Tint = new Color(0f, 0f, 0f, 0f);

            Brush.IsVisible = true;

            MakeBoxAnimation(surface.Width, surface.Height, cloneAnimation.Center);
        }
Ejemplo n.º 22
0
        public bool LoadZone(Zone zone)
        {
            var gameObject = new GameObject(Settings.Config.ScreenFont);
            var animation = new AnimatedTextSurface("default", 10, 10);
            var frame = animation.CreateFrame();
            frame.DefaultBackground = zone.DebugAppearance.Background;

            gameObject.Name = zone.Title;

            Settings.QuickEditor.TextSurface = frame;
            Settings.QuickEditor.Clear();
            Settings.QuickEditor.Print(0, 0, zone.Title, Color.DarkGray);

            gameObject.Animation = animation;
            gameObject.Position = new Point(zone.Area.Left, zone.Area.Top);
            gameObject.Update();

            var resizable = new ResizableObject<Zone>(ResizableObject.ObjectType.Zone, gameObject, zone);
            resizable.RenderOffset = consoleWrapper.Position - consoleWrapper.TextSurface.RenderArea.Location;
            Zones.Add(resizable);

            ZonesPanel.RebuildListBox();

            return true;
        }
Ejemplo n.º 23
0
        public void MouseMoveSurface(MouseInfo info, ITextSurface surface)
        {
            Brush.IsVisible = true;
            //_entity.SyncLayers();

            if (info.LeftClicked)
            {
                if (_panel.State == SelectionToolPanel.CloneState.SelectingPoint1)
                {
                    _panel.State = SelectionToolPanel.CloneState.SelectingPoint2;
                    Brush.Animation.Tint = new Color(0f, 0f, 0f, 0.5f);
                }

                else if (_panel.State == SelectionToolPanel.CloneState.SelectingPoint2)
                {
                    _secondPoint = new Point(info.ConsoleLocation.X, info.ConsoleLocation.Y);
                    _panel.State = SelectionToolPanel.CloneState.Selected;

                    // Copy data to new animation

                    AnimatedTextSurface cloneAnimation = new AnimatedTextSurface("clone", Brush.Width, Brush.Height, Settings.Config.ScreenFont);
                    var frame = cloneAnimation.CreateFrame();
                    Point topLeftPoint = new Point(Math.Min(_firstPoint.Value.X, _secondPoint.Value.X), Math.Min(_firstPoint.Value.Y, _secondPoint.Value.Y));
                    surface.Copy(topLeftPoint.X, topLeftPoint.Y, cloneAnimation.Width, cloneAnimation.Height, frame, 0, 0);

                    if (_altPanel.SkipEmptyCells && _altPanel.UseAltEmptyColor)
                    {
                        foreach (var cell in frame.Cells)
                        {
                            if (cell.GlyphIndex == 0 && cell.Background == _altPanel.AltEmptyColor)
                                cell.Background = Color.Transparent;
                        }
                    }

                    cloneAnimation.Center = Brush.Animation.Center;

                    Brush.SelectedSurface.Animation = cloneAnimation;
                    //Brush.Animations[cloneAnimation.Name] = cloneAnimation;
                    //Brush.Animation = cloneAnimation;
                    //Brush.Animation.Tint = new Color(0f, 0f, 0f, 0f);

                    //// Display the rect
                    //var topLayer = new GameObject(Settings.Config.ScreenFont);
                    //Brush.UnderAnimation = topLayer;
                    //topLayer.Animations[_tempAnimation.Name] = _tempAnimation;
                    //topLayer.Animation = _tempAnimation;
                    //topLayer.Animation.Tint = new Color(0f, 0f, 0f, 0.35f);
                    //topLayer.Position = Brush.Position;
                    ////_entity.SyncLayers();
                }

                else if (_panel.State == SelectionToolPanel.CloneState.Selected)
                {

                }
                else if (_panel.State == SelectionToolPanel.CloneState.Clone)
                {
                    //StampBrush(info.ConsoleLocation.X, info.ConsoleLocation.Y, surface);
                }
                else if (_panel.State == SelectionToolPanel.CloneState.Clear)
                {
                    // Erase selected area
                }
                else if (_panel.State == SelectionToolPanel.CloneState.Move)
                {
                    // Move the selected cells
                }

            }
            else
            {

                if (_panel.State == SelectionToolPanel.CloneState.SelectingPoint1)
                {
                    Brush.Position = info.ConsoleLocation;
                    _firstPoint = Brush.Position;

                    // State was reset and we didn't know about it
                    if (_previousState != _panel.State || Brush.Animation.Name != AnimationSingle)
                    {
                        Brush.Animation = Brush.Animations[AnimationSingle];
                        Brush.Animation.Tint = new Color(0f, 0f, 0f, 0f);
                    }
                }

                if (_panel.State == SelectionToolPanel.CloneState.SelectingPoint2)
                {
                    int width = Math.Max(_firstPoint.Value.X, info.ConsoleLocation.X) - Math.Min(_firstPoint.Value.X, info.ConsoleLocation.X) + 1;
                    int height = Math.Max(_firstPoint.Value.Y, info.ConsoleLocation.Y) - Math.Min(_firstPoint.Value.Y, info.ConsoleLocation.Y) + 1;

                    Point p1;

                    if (_firstPoint.Value.X > info.ConsoleLocation.X)
                    {
                        if (_firstPoint.Value.Y > info.ConsoleLocation.Y)
                            p1 = new Point(width - 1, height - 1);
                        else
                            p1 = new Point(width - 1, 0);
                    }
                    else
                    {
                        if (_firstPoint.Value.Y > info.ConsoleLocation.Y)
                            p1 = new Point(0, height - 1);
                        else
                            p1 = new Point(0, 0);
                    }

                    MakeBoxAnimation(width, height, p1);
                }

            }

            _previousState = _panel.State;
        }
Ejemplo n.º 24
0
        private void cloneSelectedAnimation_ButtonClicked(object sender, EventArgs e)
        {
            RenamePopup popup = new RenamePopup("clone");
            popup.Closed += (o, e2) =>
            {
                if (popup.DialogResult)
                {
                    var animation = (AnimatedTextSurface)animations.SelectedItem;
                    var newAnimation = new AnimatedTextSurface(popup.NewName, animation.Width, animation.Height, Settings.Config.ScreenFont);

                    foreach (var frame in animation.Frames)
                    {
                        var newFrame = newAnimation.CreateFrame();
                        frame.Copy(newFrame);
                    }

                    newAnimation.CurrentFrameIndex = 0;

                    entity.Animations[newAnimation.Name] = newAnimation;
                    RebuildListBox();
                }
            };
            popup.Show(true);
            popup.Center();
        }
Ejemplo n.º 25
0
        private void MakeBoxAnimation(int width, int height, Point center)
        {
            AnimatedTextSurface animation;

            if (Brush.Animations.ContainsKey(AnimationSelection))
            {
                animation = Brush.Animations[AnimationSelection];

                if (animation.Width == width && animation.Height == height && animation.Center == center)
                {
                    Brush.Animation = animation;
                    return;
                }
            }

            animation = new AnimatedTextSurface(AnimationSelection, width, height, Settings.Config.ScreenFont);
            Settings.QuickEditor.TextSurface = animation.CreateFrame();

            _boxShape = SadConsole.Shapes.Box.GetDefaultBox();
            _boxShape.Location = new Point(0, 0);
            _boxShape.Width = width;
            _boxShape.Height = height;
            _boxShape.Draw(Settings.QuickEditor);

            //frame.SetEffect(frame, _pulseAnimation);
            animation.Center = center;

            Brush.Animations[animation.Name] = animation;
            Brush.Animation = animation;
        }