Inheritance: CellEffectBase
Example #1
0
        public CharacterViewer()
            : base(27, 20)
        {
            //DefaultShowLocation = StartupLocation.CenterScreen;
            //Fill(Color.White, Color.Black, 0, null);
            Title          = (char)198 + "Character" + (char)198;
            TitleAlignment = HorizontalAlignment.Left;
            //SetTitle(" Characters ", HorizontalAlignment.Center, Color.Blue, Color.LightGray);
            CloseOnEscKey       = true;
            UsePixelPositioning = true;

            // CHARACTER SCROLL
            _charScrollBar = new ScrollBar(Orientation.Vertical, 16)
            {
                Position = new Point(17, 1),
                Name     = "ScrollBar",
                Maximum  = Font.Rows - 16,
                Value    = 0
            };
            _charScrollBar.ValueChanged += new EventHandler(_charScrollBar_ValueChanged);
            _charScrollBar.IsEnabled     = Font.Rows > 16;

            // Add all controls
            Add(_charScrollBar);

            _closeButton = new Button(6, 1)
            {
                Text = "Ok", Position = new Point(19, 1)
            }; Add(_closeButton); _closeButton.Click += (sender, e) => { DialogResult = true; Hide(); };

            // Effects
            highlightedEffect = new Recolor
            {
                Foreground = Color.Blue,
                Background = Color.DarkGray
            };

            unhighlightEffect = new SadConsole.Effects.Fade()
            {
                FadeBackground        = true,
                FadeForeground        = true,
                DestinationForeground = new ColorGradient(highlightedEffect.Foreground, Color.White),
                DestinationBackground = new ColorGradient(highlightedEffect.Background, Color.Black),
                FadeDuration          = 0.3d,
                RemoveOnFinished      = true,
                UseCellBackground     = false,
                UseCellForeground     = false,
                CloneOnApply          = true,
                Permanent             = true
            };

            Theme = SadConsole.Themes.Library.Default.WindowTheme.Clone();
            Theme.BorderLineStyle = CellSurface.ConnectedLineThick;

            // The frame will have been drawn by the base class, so redraw and our close button will be put on top of it
            //Invalidate();
        }
Example #2
0
        public CharacterViewer()
            : base(27, 20)
        {
            //DefaultShowLocation = StartupLocation.CenterScreen;
            //Fill(Color.White, Color.Black, 0, null);
            Title          = (char)198 + "Character" + (char)198;
            TitleAlignment = System.Windows.HorizontalAlignment.Left;
            //SetTitle(" Characters ", System.Windows.HorizontalAlignment.Center, Color.Blue, Color.LightGray);
            CloseOnESC          = true;
            UsePixelPositioning = true;

            // CHARACTER SCROLL
            _charScrollBar               = ScrollBar.Create(System.Windows.Controls.Orientation.Vertical, 16);
            _charScrollBar.Position      = new Point(17, 1);
            _charScrollBar.Name          = "ScrollBar";
            _charScrollBar.Maximum       = textSurface.Font.Rows - 16;
            _charScrollBar.Value         = 0;
            _charScrollBar.ValueChanged += new EventHandler(_charScrollBar_ValueChanged);
            _charScrollBar.IsEnabled     = textSurface.Font.Rows > 16;

            // Add all controls
            this.Add(_charScrollBar);

            _closeButton = new Button(6)
            {
                Text = "Ok", Position = new Point(19, 1)
            }; Add(_closeButton); _closeButton.Click += (sender, e) => { DialogResult = true; Hide(); };

            // Effects
            highlightedEffect            = new Recolor();
            highlightedEffect.Foreground = Color.Blue;
            highlightedEffect.Background = Color.DarkGray;

            unhighlightEffect = new SadConsole.Effects.Fade()
            {
                FadeBackground        = true,
                FadeForeground        = true,
                DestinationForeground = new ColorGradient(highlightedEffect.Foreground, Color.White),
                DestinationBackground = new ColorGradient(highlightedEffect.Background, Color.Black),
                FadeDuration          = 0.3d,
                RemoveOnFinished      = true,
                UseCellBackground     = false,
                UseCellForeground     = false,
                CloneOnApply          = true,
                Permanent             = true
            };

            // The frame will have been drawn by the base class, so redraw and our close button will be put on top of it
            Redraw();
        }
Example #3
0
        public SplashScreen()
            : base(80, 25)
        {
            IsVisible      = false;
            effectsManager = new EffectsManager(this.TextSurface);
            // Setup the console text background
            string textTemplate = "sole SadCon";

            System.Text.StringBuilder text = new System.Text.StringBuilder(2200);

            for (int i = 0; i < TextSurface.Width * TextSurface.Height; i++)
            {
                text.Append(textTemplate);
            }
            Print(0, 0, text.ToString(), Color.Black, Color.Transparent);

            // Load the logo
#if MONOGAME
            System.IO.Stream imageStream = System.IO.File.OpenRead("sad.png");
            var image = Texture2D.FromStream(Engine.Device, imageStream);
            imageStream.Dispose();
#elif SFML
            var image = new Texture("sad.png");
#endif
            // Configure the logo
            _consoleImage         = image.ToSurface(Engine.DefaultFont, false);
            _consoleImagePosition = new Point(TextSurface.Width / 2 - _consoleImage.Width / 2, -1);
            _consoleImage.Tint    = Color.Black;

            // Configure the animations
            _animation = new InstructionSet();
            _animation.Instructions.AddLast(new Wait()
            {
                Duration = 0.3f
            });

            // Animation to move the angled gradient spotlight effect.
            var moveGradientInstruction = new CodeInstruction();
            moveGradientInstruction.CodeCallback = (inst) =>
            {
                _x += 1;

                if (_x > TextSurface.Width + 50)
                {
                    inst.IsFinished = true;
                }

                Color[] colors     = new Color[] { Color.Black, Color.Blue, Color.White, Color.Blue, Color.Black };
                float[] colorStops = new float[] { 0f, 0.2f, 0.5f, 0.8f, 1f };

                Algorithms.GradientFill(TextSurface.Font.Size, new Point(_x, 12), 10, 45, new Rectangle(0, 0, TextSurface.Width, TextSurface.Height), new ColorGradient(colors, colorStops), SetForeground);
            };
            _animation.Instructions.AddLast(moveGradientInstruction);

            // Animation to clear the SadConsole text.
            _animation.Instructions.AddLast(new CodeInstruction()
            {
                CodeCallback = (i) => { Fill(Color.Black, Color.Transparent, 0, null); i.IsFinished = true; }
            });

            // Animation for the logo text.
            var logoText = new ColorGradient(new Color[] { Color.Magenta, Color.Yellow }, new float[] { 0.0f, 1f }).ToColoredString("[| Powered by SadConsole |]");
            logoText.SetEffect(new SadConsole.Effects.Fade()
            {
                DestinationForeground = Color.Blue, FadeForeground = true, FadeDuration = 1f, Repeat = false, RemoveOnFinished = true, Permanent = true, CloneOnApply = true
            });
            _animation.Instructions.AddLast(new DrawString(this)
            {
                Position = new Point(26, this.TextSurface.Height - 1), Text = logoText, TotalTimeToPrint = 1f
            });

            // Animation for fading in the logo picture.
            _animation.Instructions.AddLast(new FadeTextSurfaceTint(_consoleImage, new ColorGradient(Color.Black, Color.Transparent), new TimeSpan(0, 0, 0, 0, 2000)));

            // Animation to blink SadConsole in the logo text
            _animation.Instructions.AddLast(new CodeInstruction()
            {
                CodeCallback = (i) =>
                {
                    SadConsole.Effects.Fade fadeEffect = new SadConsole.Effects.Fade();
                    fadeEffect.AutoReverse             = true;
                    fadeEffect.DestinationForeground   = new ColorGradient(Color.Blue, Color.Yellow);
                    fadeEffect.FadeForeground          = true;
                    fadeEffect.UseCellForeground       = false;
                    fadeEffect.Repeat           = true;
                    fadeEffect.FadeDuration     = 0.7f;
                    fadeEffect.RemoveOnFinished = true;

                    List <Cell> cells = new List <Cell>();
                    for (int index = 0; index < 10; index++)
                    {
                        var point = new Point(26, this.TextSurface.Height - 1).ToIndex(this.TextSurface.Width) + 14 + index;
                        cells.Add(textSurface.Cells[point]);
                        cellindexes.Add(point);
                    }

                    effectsManager.SetEffect(cells, fadeEffect);
                    i.IsFinished = true;
                }
            });

            // Animation to delay, keeping the logo and all on there for 2 seconds, then destroy itself.
            _animation.Instructions.AddLast(new Wait()
            {
                Duration = 2.5f
            });
            _animation.Instructions.AddLast(new FadeTextSurfaceTint(_consoleImage, new ColorGradient(Color.Transparent, Color.Black), new TimeSpan(0, 0, 0, 0, 2000)));
            _animation.Instructions.AddLast(new CodeInstruction()
            {
                CodeCallback = (i) =>
                {
                    SplashCompleted?.Invoke();

                    i.IsFinished = true;
                }
            });
        }
Example #4
0
        public CharacterViewer()
            : base(27, 20)
        {
            //DefaultShowLocation = StartupLocation.CenterScreen;
            //Fill(Color.White, Color.Black, 0, null);
            Title          = (char)198 + "Character" + (char)198;
            TitleAlignment = HorizontalAlignment.Left;
            //SetTitle(" Characters ", HorizontalAlignment.Center, Color.Blue, Color.LightGray);
            CloseOnEscKey       = true;
            UsePixelPositioning = true;

            // CHARACTER SCROLL
            _charScrollBar = new ScrollBar(Orientation.Vertical, 16)
            {
                Position = new Point(17, 1),
                Name     = "ScrollBar",
                Maximum  = Font.Rows - 16,
                Value    = 0
            };
            _charScrollBar.ValueChanged += new EventHandler(_charScrollBar_ValueChanged);
            _charScrollBar.IsEnabled     = Font.Rows > 16;

            // Add all controls
            Add(_charScrollBar);

            _closeButton = new Button(6, 1)
            {
                Text = "Ok", Position = new Point(19, 1)
            }; Add(_closeButton); _closeButton.Click += (sender, e) => { DialogResult = true; Hide(); };

            // Effects
            highlightedEffect = new Recolor
            {
                Foreground = Color.Blue,
                Background = Color.DarkGray
            };

            unhighlightEffect = new SadConsole.Effects.Fade()
            {
                FadeBackground        = true,
                FadeForeground        = true,
                DestinationForeground = new ColorGradient(highlightedEffect.Foreground, Color.White),
                DestinationBackground = new ColorGradient(highlightedEffect.Background, Color.Black),
                FadeDuration          = 0.3d,
                RemoveOnFinished      = true,
                UseCellBackground     = false,
                UseCellForeground     = false,
                CloneOnApply          = true,
                Permanent             = true
            };

            Theme = SadConsole.Themes.Library.Default.WindowTheme.Clone();
            Theme.BorderLineStyle = CellSurface.ConnectedLineThick;

            // The frame will have been drawn by the base class, so redraw and our close button will be put on top of it
            //Invalidate();


            // Get the existing colors object
            var colors = SadConsole.Themes.Colors.CreateAnsi();

            // Use a common background color
            var backgroundColor = Color.Black;

            // Assign the background color to both the hosts (console) and controls
            colors.ControlHostBack = backgroundColor;
            colors.ControlBack     = backgroundColor;

            // Build other colors used by themes based on the background color
            colors.ControlBackLight = (backgroundColor * 1.3f).FillAlpha();
            colors.ControlBackDark  = (backgroundColor * 0.7f).FillAlpha();

            // When a control is selected, a color indicates it. this is either some other color or a lighter color
            // the colors object also defines a palette of colors, we'll use this.
            colors.ControlBackSelected = colors.GrayDark;

            // Build the colors into theme objects for control appearance states
            colors.RebuildAppearances();

            _characterSurface          = new DrawingSurface(16, 16);
            _characterSurface.Position = new Point(1, 1);
            _characterSurface.OnDraw   = (ds) =>
            {
                ds.Surface.Effects.UpdateEffects(Global.GameTimeElapsedUpdate);

                if (hasDrawn)
                {
                    return;
                }

                ds.Surface.Fill(Foreground, Background, 0);

                int charIndex = fontRowOffset * 16;
                for (int y = 0; y < 16; y++)
                {
                    for (int x = 0; x < 16; x++)
                    {
                        ds.Surface.SetGlyph(x, y, charIndex);
                        charIndex++;
                    }
                }
                hasDrawn = true;
            };
            _characterSurface.MouseMove          += _characterSurface_MouseMove;
            _characterSurface.MouseButtonClicked += _characterSurface_MouseButtonClicked;
            _characterSurface.MouseExit          += _characterSurface_MouseExit;
            Add(_characterSurface);

            ThemeColors = colors;
            IsDirty     = true;
        }
Example #5
0
        public SplashScreen()
            : base(80, 25)
        {
            IsVisible = false;
            effectsManager = new EffectsManager(this.TextSurface);
            // Setup the console text background
            string textTemplate = "sole SadCon";
            System.Text.StringBuilder text = new System.Text.StringBuilder(2200);

            for (int i = 0; i < TextSurface.Width * TextSurface.Height; i++)
            {
                text.Append(textTemplate);
            }
            Print(0, 0, text.ToString(), Color.Black, Color.Transparent);

            // Load the logo
            System.IO.Stream imageStream = System.IO.File.OpenRead("sad.png");
            var image = Texture2D.FromStream(Engine.Device, imageStream);
            imageStream.Dispose();

            // Configure the logo
            _consoleImage = image.ToSurface(Engine.DefaultFont, false);
            _consoleImagePosition = new Point(TextSurface.Width / 2 - _consoleImage.Width / 2, -1);
            _consoleImage.Tint = Color.Black;

            // Configure the animations
            _animation = new InstructionSet();
            _animation.Instructions.AddLast(new Wait() { Duration = 0.3f });

            // Animation to move the angled gradient spotlight effect.
            var moveGradientInstruction = new CodeInstruction();
            moveGradientInstruction.CodeCallback = (inst) =>
            {
                _x += 1;

                if (_x > TextSurface.Width + 50)
                {
                    inst.IsFinished = true;
                }

                Color[] colors = new Color[] { Color.Black, Color.Blue, Color.White, Color.Blue, Color.Black };
                float[] colorStops = new float[] { 0f, 0.2f, 0.5f, 0.8f, 1f };

                Algorithms.GradientFill(TextSurface.Font.Size, new Point(_x, 12), 10, 45, new Rectangle(0, 0, TextSurface.Width, TextSurface.Height), new ColorGradient(colors, colorStops), SetForeground);
            };
            _animation.Instructions.AddLast(moveGradientInstruction);

            // Animation to clear the SadConsole text.
            _animation.Instructions.AddLast(new CodeInstruction() { CodeCallback = (i) => { Fill(Color.Black, Color.Transparent, 0, null); i.IsFinished = true; } });

            // Animation for the logo text.
            var logoText = new ColorGradient(new Color[] { Color.Magenta, Color.Yellow }, new float[] { 0.0f, 1f }).ToColoredString("[| Powered by SadConsole |]");
            logoText.SetEffect(new SadConsole.Effects.Fade() { DestinationForeground = Color.Blue, FadeForeground = true, FadeDuration = 1f, Repeat = false, RemoveOnFinished = true, Permanent = true, CloneOnApply = true });
            _animation.Instructions.AddLast(new DrawString(this) { Position = new Point(26, this.TextSurface.Height - 1), Text = logoText, TotalTimeToPrint = 1f });

            // Animation for fading in the logo picture.
            _animation.Instructions.AddLast(new FadeTextSurfaceTint(_consoleImage, new ColorGradient(Color.Black, Color.Transparent), new TimeSpan(0, 0, 0, 0, 2000)));

            // Animation to blink SadConsole in the logo text
            _animation.Instructions.AddLast(new CodeInstruction()
            {
                CodeCallback = (i) =>
                {
                    SadConsole.Effects.Fade fadeEffect = new SadConsole.Effects.Fade();
                    fadeEffect.AutoReverse = true;
                    fadeEffect.DestinationForeground = new ColorGradient(Color.Blue, Color.Yellow);
                    fadeEffect.FadeForeground = true;
                    fadeEffect.UseCellForeground = false;
                    fadeEffect.Repeat = true;
                    fadeEffect.FadeDuration = 0.7f;
                    fadeEffect.RemoveOnFinished = true;

                    List<Cell> cells = new List<Cell>();
                    for (int index = 0; index < 10; index++)
                    {
                        var point = new Point(26, this.TextSurface.Height - 1).ToIndex(this.TextSurface.Width) + 14 + index;
                        cells.Add(textSurface.Cells[point]);
                        cellindexes.Add(point);
                    }

                    effectsManager.SetEffect(cells, fadeEffect);
                    i.IsFinished = true;
                }
            });

            // Animation to delay, keeping the logo and all on there for 2 seconds, then destroy itself.
            _animation.Instructions.AddLast(new Wait() { Duration = 2.5f });
            _animation.Instructions.AddLast(new FadeTextSurfaceTint(_consoleImage, new ColorGradient(Color.Transparent, Color.Black), new TimeSpan(0, 0, 0, 0, 2000)));
            _animation.Instructions.AddLast(new CodeInstruction()
            {
                CodeCallback = (i) =>
                {
                    SplashCompleted?.Invoke();

                    i.IsFinished = true;
                }
            });
        }