private void MakeBoxAnimation(int width, int height, Point center) { AnimatedSurface 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 AnimatedSurface(AnimationSelection, width, height, SadConsoleEditor.Settings.Config.ScreenFont); SadConsoleEditor.Settings.QuickEditor.TextSurface = animation.CreateFrame(); _boxShape = SadConsole.Shapes.Box.GetDefaultBox(); _boxShape.Position = new Point(0, 0); _boxShape.Width = width; _boxShape.Height = height; _boxShape.Draw(SadConsoleEditor.Settings.QuickEditor); //frame.SetEffect(frame, _pulseAnimation); animation.Center = center; Brush.Animations[animation.Name] = animation; Brush.Animation = animation; }
public ScrollingConsole(int width, int height, int bufferHeight) { controlsContainer = new SadConsole.ControlsConsole(1, height); mainConsole = new SadConsole.Console(width - 1, bufferHeight); mainConsole.TextSurface.RenderArea = new Microsoft.Xna.Framework.Rectangle(0, 0, width - 1, height); mainConsole.VirtualCursor.IsVisible = false; scrollBar = SadConsole.Controls.ScrollBar.Create(System.Windows.Controls.Orientation.Vertical, height); scrollBar.IsEnabled = false; scrollBar.ValueChanged += ScrollBar_ValueChanged; controlsContainer.Add(scrollBar); controlsContainer.Position = new Microsoft.Xna.Framework.Point(1 + mainConsole.TextSurface.Width, Position.Y); Children.Add(mainConsole); Children.Add(controlsContainer); scrollingCounter = 0; borderSurface = new SadConsole.Surfaces.BasicSurface(width + 2, height + 2, mainConsole.TextSurface.Font); var editor = new SadConsole.Surfaces.SurfaceEditor(borderSurface); SadConsole.Shapes.Box box = SadConsole.Shapes.Box.Thick(); box.Width = borderSurface.Width; box.Height = borderSurface.Height; box.Draw(editor); renderer = new SurfaceRenderer(); renderer.Render(borderSurface); }
public BorderedConsole(int width, int height, string title) : base(width, height) { SadConsole.Shapes.Box box = SadConsole.Shapes.Box.GetDefaultBox(); box.Foreground = RagnaRogueColors.UIDarkGray; box.Width = width; box.Height = height; box.Draw(CellData); CellData.Print(3, 0, new ColoredString(title, new CellAppearance(Color.White, Color.Black))); }
public DungeonScreen(int screenX, int screenY, int screenWidth, int screenHeight, Font font) { Position = new Point(screenX, screenY); Width = screenWidth; Height = screenHeight; borderSurface = new SadConsole.Surfaces.BasicSurface(Width + 1, Height + 1, font); var editor = new SadConsole.Surfaces.SurfaceEditor(borderSurface); SadConsole.Shapes.Box box = SadConsole.Shapes.Box.Thick(); box.Width = borderSurface.Width; box.Height = borderSurface.Height; box.Draw(editor); renderer = new SurfaceRenderer(); renderer.Render(borderSurface); }
public BorderedConsole() : base(80, 25) { this.IsVisible = false; // Get the default box shape definition. Defines which characters to use for the box. SadConsole.Shapes.Box box = SadConsole.Shapes.Box.GetDefaultBox(); // Customize the box box.Foreground = Color.Blue; box.BorderBackground = Color.White; box.FillColor = Color.White; box.Fill = true; box.Width = textSurface.Width; box.Height = textSurface.Height; // Draw the box shape onto the CellSurface that this console is displaying. box.Draw(this); this.Print(3, 1, "Shapes are easily created with only a few lines of code"); // Get a circle SadConsole.Shapes.Circle circle = new SadConsole.Shapes.Circle(); circle.BorderAppearance = new CellAppearance(ColorHelper.YellowGreen, Color.White, 57); circle.Center = new Point(60, 13); circle.Radius = 10; circle.Draw(this); // Now time to make a line SadConsole.Shapes.Line line = new SadConsole.Shapes.Line(); line.StartingLocation = new Point(10, 10); line.EndingLocation = new Point(45, 18); line.UseEndingCell = false; line.UseStartingCell = false; line.CellAppearance = new Cell { Foreground = ColorHelper.Purple, Background = Color.White, GlyphIndex = 88 }; line.Draw(this); }
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"]; } } }
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; }
public StatusConsole(int screenX, int screenY, int screenWidth, int screenHeight) : base(screenWidth, screenHeight) { Position = new Point(screenX, screenY); Width = screenWidth; Height = screenHeight; var lines = new[] { @"_______", @"| |", @"| [H] |", @"|_____|", @"| |", @"=============", @"// | | \\", @"[LAL] | | [RAL]", @"// | [D] | \\", @"[LH] | | [RH]", @"| |", @"=======", @"// \\", @"// \\", @"[LLL] [RLL]", @"// \\", @"// \\", @"[LF] [RF]" }; var offsets = new[] { 10, 10, 10, 10, 12, 7, 6, 3, 4, 2, 10, 10, 9, 8, 5, 6, 5, 3 }; for (int i = 0; i < lines.Length; i++) { Print(offsets[i], i, lines[i]); } var btHead = new SadConsole.Controls.Button(5, 1) { Text = " H ", Position = new Point(11, 2) }; Add(btHead); var btLAL = new SadConsole.Controls.Button(5, 1) { Text = "LAL", Position = new Point(3, 7) }; Add(btLAL); var btRAL = new SadConsole.Controls.Button(5, 1) { Text = "RAL", Position = new Point(19, 7) }; Add(btRAL); var btDD = new SadConsole.Controls.Button(5, 1) { Text = " D ", Position = new Point(11, 8) }; Add(btDD); var btLH = new SadConsole.Controls.Button(4, 1) { Text = "LH", Position = new Point(2, 9) }; Add(btLH); var btRH = new SadConsole.Controls.Button(4, 1) { Text = "RH", Position = new Point(21, 9) }; Add(btRH); var btLLL = new SadConsole.Controls.Button(5, 1) { Text = "LLL", Position = new Point(5, 14) }; Add(btLLL); var btRLL = new SadConsole.Controls.Button(5, 1) { Text = "RLL", Position = new Point(16, 14) }; Add(btRLL); var btLF = new SadConsole.Controls.Button(4, 1) { Text = "LF", Position = new Point(3, 17) }; Add(btLF); var btRF = new SadConsole.Controls.Button(4, 1) { Text = "RF", Position = new Point(19, 17) }; Add(btRF); SadConsole.Controls.ProgressBar health = new SadConsole.Controls.ProgressBar(2, 10, System.Windows.VerticalAlignment.Top); health.Position = new Point(27, 0); health.SetForeground(0, 9, Color.Green); Add(health); borderSurface = new SadConsole.Surfaces.BasicSurface(Width + 2, Height + 2, base.textSurface.Font); var editor = new SadConsole.Surfaces.SurfaceEditor(borderSurface); SadConsole.Shapes.Box box = SadConsole.Shapes.Box.Thick(); box.Width = borderSurface.Width; box.Height = borderSurface.Height; box.Draw(editor); base.Renderer.Render(borderSurface); }
public override void Redraw() { base.Redraw(); int lineY = textSurface.Height - 10; int lineX = textSurface.Width - RideSideX; // Bar above color bars for (int x = 1; x < lineX; x++) { textSurface[x, lineY].GlyphIndex = 196; } textSurface[0, lineY].GlyphIndex = 199; textSurface[lineX, lineY].GlyphIndex = 217; // Long bar right of color picker for (int y = 1; y < lineY; y++) { textSurface[lineX, y].GlyphIndex = 179; } textSurface[lineX, lineY].GlyphIndex = 217; textSurface[lineX, 0].GlyphIndex = 209; // Bar above red input for (int x = lineX + 1; x < textSurface.Width - 1; x++) { textSurface[x, lineY - 5].GlyphIndex = 205;// 196; } //textSurface[lineX, lineY - 5].GlyphIndex = 195; //textSurface[textSurface.Width - 1, lineY - 5].GlyphIndex = 182; textSurface[lineX, lineY - 5].GlyphIndex = 198; textSurface[textSurface.Width - 1, lineY - 5].GlyphIndex = 185; Print(lineX + 2, lineY - 4, "Red", ColorAnsi.Red); Print(lineX + 2, lineY - 3, "Green", ColorAnsi.Green); Print(lineX + 2, lineY - 2, "Blue", ColorAnsi.BlueBright); Print(lineX + 2, lineY - 1, "Alpha", Color.Gray); // Preview area Print(lineX + 2, 1, "Selected Color"); SadConsole.Shapes.Box box = new SadConsole.Shapes.Box(); box.Fill = true; box.FillColor = SelectedColor; box.Width = 14; box.Height = 3; box.Location = new Point(lineX + 2, 2); box.TopLeftCharacter = box.TopRightCharacter = box.TopSideCharacter = 223; box.BottomLeftCharacter = box.BottomRightCharacter = box.BottomSideCharacter = 220; box.Foreground = Theme.FillStyle.Background; box.Draw(this); // Current selected gradient colors Print(lineX + 2, 5, SelectedColor.R.ToString().PadLeft(3, '0'), ColorAnsi.Red); Print(lineX + 2, 6, SelectedColor.G.ToString().PadLeft(3, '0'), ColorAnsi.Green); Print(lineX + 13, 5, SelectedColor.B.ToString().PadLeft(3, '0'), ColorAnsi.BlueBright); // Previous Colors Print(lineX + 2, 8, "Prior Colors"); }
public void ProcessMouse(MouseConsoleState info, ISurface surface, bool isInBounds) { if (cancelled) { // wait until left button is released... if (info.Mouse.LeftButtonDown) { return; } else { cancelled = false; } } if (info.Mouse.LeftButtonDown) { if (!firstPoint.HasValue) { firstPoint = info.ConsolePosition; return; } else { // Check for right click cancel. if (info.Mouse.RightButtonDown) { cancelled = true; firstPoint = null; return; } secondPoint = info.ConsolePosition; // Draw the line (erase old) to where the mouse is // create the animation frame AnimatedSurface animation = new AnimatedSurface("line", Math.Max(firstPoint.Value.X, secondPoint.X) - Math.Min(firstPoint.Value.X, secondPoint.X) + 1, Math.Max(firstPoint.Value.Y, secondPoint.Y) - Math.Min(firstPoint.Value.Y, secondPoint.Y) + 1, SadConsoleEditor.Settings.Config.ScreenFont); var frame = animation.CreateFrame(); Point p1; if (firstPoint.Value.X > secondPoint.X) { if (firstPoint.Value.Y > secondPoint.Y) { p1 = Point.Zero; } else { p1 = new Point(0, frame.Height - 1); } } else { if (firstPoint.Value.Y > secondPoint.Y) { p1 = new Point(frame.Width - 1, 0); } else { p1 = new Point(frame.Width - 1, frame.Height - 1); } } animation.Center = p1; SadConsoleEditor.Settings.QuickEditor.TextSurface = frame; 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.Position = new Point(0, 0); boxShape.Width = frame.Width; boxShape.Height = frame.Height; boxShape.Draw(SadConsoleEditor.Settings.QuickEditor); Brush.Animation = animation; } } else if (firstPoint.HasValue) { // We let go outside of bounds if (!isInBounds) { cancelled = true; return; } // Position the box shape and draw boxShape.Position = new Point(Math.Min(firstPoint.Value.X, secondPoint.X), Math.Min(firstPoint.Value.Y, secondPoint.Y)) + info.Console.TextSurface.RenderArea.Location; SadConsoleEditor.Settings.QuickEditor.TextSurface = surface; boxShape.Draw(SadConsoleEditor.Settings.QuickEditor); firstPoint = null; Brush.Animation = Brush.Animations["single"]; } }
public override void Redraw() { base.Redraw(); int lineY = TextSurface.Height - 10; int lineX = TextSurface.Width - RideSideX; // Bar above color bars for (int x = 1; x < lineX; x++) { textSurface[x, lineY].Glyph = 196; } textSurface[0, lineY].Glyph = 199; textSurface[lineX, lineY].Glyph = 217; // Long bar right of color picker for (int y = 1; y < lineY; y++) { textSurface[lineX, y].Glyph = 179; } textSurface[lineX, lineY].Glyph = 217; textSurface[lineX, 0].Glyph = 209; // Bar above red input for (int x = lineX + 1; x < TextSurface.Width - 1; x++) { textSurface[x, lineY - 5].Glyph = 205;// 196; } //BasicSurface[lineX, lineY - 5].Glyph = 195; //BasicSurface[TextSurface.Width - 1, lineY - 5].Glyph = 182; textSurface[lineX, lineY - 5].Glyph = 198; textSurface[TextSurface.Width - 1, lineY - 5].Glyph = 185; Print(lineX + 2, lineY - 4, "Red", ColorAnsi.Red); Print(lineX + 2, lineY - 3, "Green", ColorAnsi.Green); Print(lineX + 2, lineY - 2, "Blue", ColorAnsi.BlueBright); Print(lineX + 2, lineY - 1, "Alpha", Color.Gray); // Preview area Print(lineX + 2, 1, "Selected Color"); SadConsole.Shapes.Box box = new SadConsole.Shapes.Box(); box.Fill = true; box.FillColor = SelectedColor; box.Width = 14; box.Height = 3; box.Position = new Point(lineX + 2, 2); box.TopLeftCharacter = box.TopRightCharacter = box.TopSideCharacter = 223; box.BottomLeftCharacter = box.BottomRightCharacter = box.BottomSideCharacter = 220; box.Foreground = Theme.FillStyle.Background; box.Draw(this); // Current selected gradient colors Print(lineX + 2, 5, SelectedColor.R.ToString().PadLeft(3, '0'), ColorAnsi.Red); Print(lineX + 2, 6, SelectedColor.G.ToString().PadLeft(3, '0'), ColorAnsi.Green); Print(lineX + 13, 5, SelectedColor.B.ToString().PadLeft(3, '0'), ColorAnsi.BlueBright); // Previous Colors Print(lineX + 2, 8, "Prior Colors"); }