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; } }); }
public SplashScreen() : base(80, 23) { Cursor.IsEnabled = false; IsVisible = false; // Setup the console text background pattern, which is hidden via colors // Print the text template on all of the console surface const string textTemplate = "sole SadCon"; var text = new System.Text.StringBuilder(Width * Height); for (int i = 0; i < Width * Height; i++) { text.Append(textTemplate); } Print(0, 0, text.ToString(), Color.Black, Color.Transparent); // Load the logo and convert to a console using (System.IO.Stream imageStream = Microsoft.Xna.Framework.TitleContainer.OpenStream("sad.png")) { using (var image = Texture2D.FromStream(Global.GraphicsDevice, imageStream)) { CellSurface logo = image.ToSurface(Global.FontDefault, false); _consoleImage = Console.FromSurface(logo, Global.FontDefault); _consoleImagePosition = new Point(Width / 2 - _consoleImage.Width / 2, -1); _consoleImage.Tint = Color.Black; } } // Animation for the logo text. var logoText = new ColorGradient(new[] { Color.Magenta, Color.Yellow }, new[] { 0.0f, 1f }) .ToColoredString("[| Powered by SadConsole |]"); logoText.SetEffect(new Fade() { DestinationForeground = Color.Blue, FadeForeground = true, FadeDuration = 1f, Repeat = false, RemoveOnFinished = true, Permanent = true, CloneOnApply = true }); // Configure the animation InstructionSet animation = new InstructionSet() .Wait(TimeSpan.FromSeconds(0.3d)) // Animation to move the angled gradient spotlight effect .Code(MoveGradient) // Clear the background text so new printing doesn't look bad .Code((console, delta) => { console.Fill(Color.Black, Color.Transparent, 0); return(true); }) // Draw the SadConsole text at the bottom .Instruct(new DrawString(logoText) { Position = new Point(26, Height - 1), TotalTimeToPrint = 1f }) // Fade in the logo .Instruct(new FadeTextSurfaceTint(_consoleImage, new ColorGradient(Color.Black, Color.Transparent), TimeSpan.FromSeconds(2))) // Blink SadConsole text at the bottom .Code(SetBlinkOnLogoText) // Delay so blinking effect is seen .Wait(TimeSpan.FromSeconds(2.5d)) // Fade out main console and logo console. .InstructConcurrent(new FadeTextSurfaceTint(_consoleImage, new ColorGradient(Color.Transparent, Color.Black), TimeSpan.FromSeconds(2)), new FadeTextSurfaceTint(this, new ColorGradient(Color.Transparent, Color.Black), TimeSpan.FromSeconds(1.0d))) // Animation has completed, call the callback this console uses to indicate it's complete .Code((con, delta) => { SplashCompleted?.Invoke(); return(true); }) ; animation.RemoveOnFinished = true; Components.Add(animation); }
public SplashScreen(int x, int y) : base(x, y) { IsVisible = false; // Load the logo Stream imageStream = TitleContainer.OpenStream("sad.png"); var image = Texture2D.FromStream(Global.GraphicsDevice, imageStream); imageStream.Dispose(); // Configure the logo _consoleImage = image.ToSurface(Global.FontDefault, false); _consoleImagePosition = new Point(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 { CodeCallback = (inst) => { _x += 1; if (_x > 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(Font.Size, new Point(_x, 12), 10, 45, new Rectangle(0, 0, Width, 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("[| Mogwaicoin Team 2018 |]"); logoText.SetEffect(new 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.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, 4, 0))); // Animation to blink SadConsole in the logo text _animation.Instructions.AddLast(new CodeInstruction() { CodeCallback = (i) => { Fade fadeEffect = new 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.Height - 1).ToIndex(this.Width) + 3 + index; cells.Add(Cells[point]); cellindexes.Add(point); } 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, 4000))); _animation.Instructions.AddLast(new CodeInstruction() { CodeCallback = (i) => { SplashCompleted?.Invoke(); i.IsFinished = true; } }); }
public SplashScreen() : base(80, 25) { IsVisible = false; // Setup the console text background string textTemplate = "sole SadCon"; System.Text.StringBuilder text = new System.Text.StringBuilder(2200); for (int i = 0; i < CellData.Width * CellData.Height; i++) { text.Append(textTemplate); } this.CellData.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 = new CellsRenderer(new CellSurface(image.Width, image.Height), this.Batch); _consoleImage.Position = new Point(CellData.Width / 2 - image.Width / 2, -1); image.DrawImageToSurface(_consoleImage.CellData, new Point(0,0), true); _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 > _cellData.Width + 50) { inst.IsFinished = true; } Color[] colors = new Color[] { Color.Black, Color.DarkBlue, Color.White, Color.DarkBlue, Color.Black }; float[] colorStops = new float[] { 0f, 0.2f, 0.5f, 0.8f, 1f }; Algorithms.GradientFill(CellSize, new Point(_x, 12), 10, 45, new Rectangle(0, 0, CellData.Width, CellData.Height), new ColorGradient(colors, colorStops), _cellData.SetForeground); }; _animation.Instructions.AddLast(moveGradientInstruction); // Animation to clear the SadConsole text. _animation.Instructions.AddLast(new CodeInstruction() { CodeCallback = (i) => { _cellData.Fill(Color.Black, Color.Transparent, 0, null); i.IsFinished = true; } }); // Animation for the logo text. var logoText = new ColorGradient(new Color[] { Color.Purple, 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.CellData.Height - 1), Text = logoText, TotalTimeToPrint = 1f, UseConsolesCursorToPrint = false }); // Animation for fading in the logo picture. _animation.Instructions.AddLast(new FadeCellRenderer(_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.Repeat = true; fadeEffect.FadeDuration = 0.7f; List<Cell> cells = new List<Cell>(); for (int index = 0; index < 10; index++) { var point = new Point(26, this.CellData.Height - 1).ToIndex(this.CellData.Width) + 14 + index; cells.Add(_cellData[point]); } _cellData.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 FadeCellRenderer(this, new ColorGradient(Color.Transparent, Color.Black), new TimeSpan(0, 0, 0, 0, 2000))); _animation.Instructions.AddLast(new CodeInstruction() { CodeCallback = (i) => { if (this.Parent != null) this.Parent.Remove(this); if (SplashCompleted != null) SplashCompleted(); } }); }
public SplashScreen() : base(80, 23) { Cursor.IsEnabled = false; IsVisible = false; // Setup the console text background pattern, which is hidden via colors // Print the text template on all of the console surface const string textTemplate = "sole SadCon"; var text = new System.Text.StringBuilder(Width * Height); for (int i = 0; i < Width * Height; i++) { text.Append(textTemplate); } this.Print(0, 0, text.ToString(), Color.Black, Color.Transparent); using ITexture sadImage = GameHost.Instance.GetTexture("Res/Images/sad.png"); var defaultFontSize = SadConsole.Game.Instance.DefaultFont.GetFontSize(SadConsole.Game.Instance.DefaultFontSize); var defaultFontSizeRatio = SadConsole.Game.Instance.DefaultFont.GetGlyphRatio(defaultFontSize); // Load the logo and convert to a console ICellSurface logo;// = sadImage.ToSurface(TextureConvertMode.Background, sadImage.Width / (int)(defaultFontSize.X * defaultFontSizeRatio.Y), sadImage.Height / (int)(defaultFontSize.Y * defaultFontSizeRatio.X)); if (defaultFontSizeRatio.X == 0 && defaultFontSizeRatio.Y == 0) { logo = sadImage.ToSurface(TextureConvertMode.Foreground, Width, Height - 1, foregroundStyle: TextureConvertForegroundStyle.Block); } else if (defaultFontSizeRatio.Y > defaultFontSizeRatio.X) { logo = sadImage.ToSurface(TextureConvertMode.Foreground, (int)((Height - 1) * defaultFontSizeRatio.Y), Height - 1, foregroundStyle: TextureConvertForegroundStyle.Block); } else { logo = sadImage.ToSurface(TextureConvertMode.Foreground, Width, (int)(Width * defaultFontSize.X), foregroundStyle: TextureConvertForegroundStyle.Block); } _consoleImage = new Console(logo); _consoleImage.Position = _consoleImagePosition = new Point(Width / 2 - _consoleImage.Width / 2, 0); _consoleImage.Tint = Color.Black; // Animation for the logo text. var logoText = new ColorGradient(new[] { Color.Magenta, Color.Yellow }, new[] { 0.0f, 1f }) .ToColoredString("[| Powered by SadConsole |]"); logoText.SetEffect(new Fade() { DestinationForeground = Color.Blue, FadeForeground = true, FadeDuration = 1f, Repeat = false, RemoveOnFinished = true, CloneOnAdd = true }); // Configure the animation InstructionSet animation = new InstructionSet() .Wait(TimeSpan.FromSeconds(0.3d)) // Animation to move the angled gradient spotlight effect .Code(MoveGradient) // Clear the background text so new printing doesn't look bad .Code((host, delta) => { ((IScreenSurface)host).Surface.Fill(Color.Black, Color.Transparent, 0); return(true); }) // Draw the SadConsole text at the bottom .Instruct(new DrawString(logoText) { Position = new Point(26, Height - 1), TotalTimeToPrint = 1f }) // Add the logo to the console children .Code((o, delta) => { Children.Add(_consoleImage); return(true); }) // Fade in the logo .Instruct(new FadeTextSurfaceTint(_consoleImage, new ColorGradient(Color.Black, Color.Transparent), TimeSpan.FromSeconds(2))) // Blink SadConsole text at the bottom .Code(SetBlinkOnLogoText) // Delay so blinking effect is seen .Wait(TimeSpan.FromSeconds(2.5d)) // Fade out main console and logo console. .InstructConcurrent(new FadeTextSurfaceTint(_consoleImage, new ColorGradient(Color.Transparent, Color.Black), TimeSpan.FromSeconds(2)), new FadeTextSurfaceTint(this, new ColorGradient(Color.Transparent, Color.Black), TimeSpan.FromSeconds(1.0d))) // Animation has completed, call the callback this console uses to indicate it's complete .Code((host, delta) => { SplashCompleted?.Invoke(); return(true); }) ; animation.RemoveOnFinished = true; SadComponents.Add(animation); }