From 0df9be2383046afc8f61847a272e7e88503e3ce1 Mon Sep 17 00:00:00 2001 From: ben_singer Date: Sun, 24 Nov 2024 13:24:00 +0000 Subject: [PATCH 01/15] Added direct render mode --- .../Logic/Modes/DirectRenderMode_Tests.cs | 31 ++++++++++++++++ NetAF/Logic/Modes/DirectRenderMode.cs | 35 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 NetAF.Tests/Logic/Modes/DirectRenderMode_Tests.cs create mode 100644 NetAF/Logic/Modes/DirectRenderMode.cs diff --git a/NetAF.Tests/Logic/Modes/DirectRenderMode_Tests.cs b/NetAF.Tests/Logic/Modes/DirectRenderMode_Tests.cs new file mode 100644 index 00000000..7f5a3e05 --- /dev/null +++ b/NetAF.Tests/Logic/Modes/DirectRenderMode_Tests.cs @@ -0,0 +1,31 @@ +using NetAF.Logic; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NetAF.Assets.Characters; +using NetAF.Assets.Locations; +using NetAF.Utilities; +using NetAF.Logic.Modes; +using NetAF.Rendering.Frames; +using NetAF.Rendering.FrameBuilders; + +namespace NetAF.Tests.Logic.Modes +{ + [TestClass] + public class DirectRenderMode_Tests + { + [TestMethod] + public void GivenNew_WhenRender_ThenNoExceptionThrown() + { + Assertions.NoExceptionThrown(() => + { + RegionMaker regionMaker = new(string.Empty, string.Empty); + Room room = new(string.Empty, string.Empty); + regionMaker[0, 0, 0] = room; + OverworldMaker overworldMaker = new(string.Empty, string.Empty, regionMaker); + var game = Game.Create(new(string.Empty, string.Empty, string.Empty), string.Empty, AssetGenerator.Retained(overworldMaker.Make(), new PlayableCharacter(string.Empty, string.Empty)), GameEndConditions.NoEnd, TestGameConfiguration.Default).Invoke(); + var mode = new DirectRenderMode(new GridTextFrame(new GridStringBuilder(), 0, 0, NetAF.Rendering.FrameBuilders.Console.AnsiColor.Red)); + + mode.Render(game); + }); + } + } +} diff --git a/NetAF/Logic/Modes/DirectRenderMode.cs b/NetAF/Logic/Modes/DirectRenderMode.cs new file mode 100644 index 00000000..f087ec75 --- /dev/null +++ b/NetAF/Logic/Modes/DirectRenderMode.cs @@ -0,0 +1,35 @@ +using NetAF.Interpretation; +using NetAF.Rendering.Frames; + +namespace NetAF.Logic.Modes +{ + /// + /// Provides a display mode for direct rendering of a frame. + /// + /// The frame to render. + public sealed class DirectRenderMode(IFrame frame) : IGameMode + { + #region Implementation of IGameMode + + /// + /// Get the interpreter. + /// + public IInterpreter Interpreter { get; } + + /// + /// Get the type of mode this provides. + /// + public GameModeType Type { get; } = GameModeType.Information; + + /// + /// Render the current state of a game. + /// + /// The game. + public void Render(Game game) + { + game.Configuration.Adapter.RenderFrame(frame); + } + + #endregion + } +} From 879b90215665a22c3965b91615b6a3235175c4f7 Mon Sep 17 00:00:00 2001 From: ben_singer Date: Sun, 24 Nov 2024 13:54:46 +0000 Subject: [PATCH 02/15] Made a start with picture frame --- .../FrameBuilders/GridPictureBuilder.cs | 106 ++++++++++++ NetAF/Rendering/Frames/GridPictureFrame.cs | 163 ++++++++++++++++++ NetAF/Rendering/Frames/GridTextFrame.cs | 6 - 3 files changed, 269 insertions(+), 6 deletions(-) create mode 100644 NetAF/Rendering/FrameBuilders/GridPictureBuilder.cs create mode 100644 NetAF/Rendering/Frames/GridPictureFrame.cs diff --git a/NetAF/Rendering/FrameBuilders/GridPictureBuilder.cs b/NetAF/Rendering/FrameBuilders/GridPictureBuilder.cs new file mode 100644 index 00000000..48fa06f3 --- /dev/null +++ b/NetAF/Rendering/FrameBuilders/GridPictureBuilder.cs @@ -0,0 +1,106 @@ +using NetAF.Assets; +using NetAF.Rendering.FrameBuilders.Console; +using NetAF.Utilities; + +namespace NetAF.Rendering.FrameBuilders +{ + /// + /// Provides a class for building pictures in a grid. + /// + public class GridPictureBuilder + { + #region Fields + + private AnsiColor[,] foregroundColors; + private AnsiColor[,] backgroundColors; + private char[,] buffer; + + #endregion + + #region Properties + + /// + /// Get or set the line terminator. + /// + public char LineTerminator { get; set; } = StringUtilities.Newline; + + /// + /// Get the display size. + /// + public Size DisplaySize { get; private set; } + + #endregion + + #region Methods + + /// + /// Resize this builder. + /// + /// The new size. + public void Resize(Size displaySize) + { + DisplaySize = displaySize; + backgroundColors = new AnsiColor[displaySize.Width, displaySize.Height]; + foregroundColors = new AnsiColor[displaySize.Width, displaySize.Height]; + Flush(); + } + + /// + /// Get a character from the buffer. + /// + /// The x position of the character. + /// The y position of the character. + /// The character. + public char GetCharacter(int x, int y) + { + return buffer[x, y]; + } + + /// + /// Get a foreground color for a cell. + /// + /// The x position of the cell. + /// The y position of the cell. + /// The cell foreground color. + public AnsiColor GetCellForegroundColor(int x, int y) + { + return foregroundColors[x, y]; + } + + /// + /// Get a background color for a cell. + /// + /// The x position of the cell. + /// The y position of the cell. + /// The cell background color. + public AnsiColor GetCellBackgroundColor(int x, int y) + { + return foregroundColors[x, y]; + } + + /// + /// Flush the buffer. + /// + public void Flush() + { + buffer = new char[DisplaySize.Width, DisplaySize.Height]; + } + + /// + /// Set a cell. + /// + /// The x position of the cell. + /// The y position of the cell. + /// The character. + /// The foreground color of the cell. + /// The backgroundColor color of the cell. + public void SetCell(int x, int y, char character, AnsiColor foregroundColor, AnsiColor backgroundColor) + { + buffer[x, y] = character; + foregroundColors[x, y] = foregroundColor; + backgroundColors[x, y] = backgroundColor; + } + + #endregion + } +} diff --git a/NetAF/Rendering/Frames/GridPictureFrame.cs b/NetAF/Rendering/Frames/GridPictureFrame.cs new file mode 100644 index 00000000..fe5d5e4b --- /dev/null +++ b/NetAF/Rendering/Frames/GridPictureFrame.cs @@ -0,0 +1,163 @@ +using System; +using System.Text; +using NetAF.Rendering.FrameBuilders; +using NetAF.Rendering.FrameBuilders.Console; +using NetAF.Rendering.Presenters; +using NetAF.Utilities; + +namespace NetAF.Rendering.Frames +{ + /// + /// Provides a grid based frame for displaying a picture. + /// + /// The builder that creates the frame. + public sealed class GridPictureFrame(GridPictureBuilder builder) : IFrame + { + #region Constants + + /// + /// Get the value for the NO_COLOR environment variable. + /// + internal const string NO_COLOR = "NO_COLOR"; + + /// + /// Get the ANSI escape sequence to hide the cursor. + /// + private const string ANSI_HIDE_CURSOR = "\u001b[?25l"; + + #endregion + + #region StaticMethods + + /// + /// Determine if color is suppressed. If the NO_COLOR environment variable is present and set to anything other than '0' or 'false' this will return true. + /// + /// True if the NO_COLOR environment variable is present and set to anything other than '0' or 'false', else false. + internal static bool IsColorSuppressed() + { + var value = Environment.GetEnvironmentVariable(NO_COLOR)?.ToLower() ?? string.Empty; + + return value switch + { + "" or "0" or "false" => false, + _ => true, + }; + } + + /// + /// Get an ANSI escape sequence for a foreground color. + /// + /// The foreground color. + /// The ANSI escape sequence. + private static string GetAnsiForegroundEscapeSequence(AnsiColor color) + { + return $"\u001B[{(int)color}m"; + } + + /// + /// Get an ANSI escape sequence for a background color. + /// + /// The background color. + /// The ANSI escape sequence. + private static string GetAnsiBackgroundEscapeSequence(AnsiColor color) + { + return $"\u001B[{(int)color + 10}m"; + } + + #endregion + + #region Overrides of Object + + /// + /// Returns a string that represents the current object. + /// + /// A string that represents the current object. + public override string ToString() + { + StringBuilder stringBuilder = new(); + + for (var y = 0; y < builder.DisplaySize.Height; y++) + { + for (var x = 0; x < builder.DisplaySize.Width; x++) + { + stringBuilder.Append(builder.GetCharacter(x, y)); + } + + stringBuilder.Append(StringUtilities.Newline); + } + + return stringBuilder.ToString(); + } + + #endregion + + #region Implementation of IFrame + + /// + /// Get the cursor left position. + /// + public int CursorLeft { get; } = 0; + + /// + /// Get the cursor top position. + /// + public int CursorTop { get; } = 0; + + /// + /// Get or set if the cursor should be shown. + /// + public bool ShowCursor { get; set; } = false; + + /// + /// Render this frame on a presenter. + /// + /// The presenter. + public void Render(IFramePresenter presenter) + { + var suppressColor = IsColorSuppressed(); + + presenter.Write(ANSI_HIDE_CURSOR); + + AnsiColor lastBackground = AnsiColor.Black; + AnsiColor lastForeground = AnsiColor.White; + + for (var y = 0; y < builder.DisplaySize.Height; y++) + { + for (var x = 0; x < builder.DisplaySize.Width; x++) + { + var c = builder.GetCharacter(x, y); + + var backgroundColor = !suppressColor ? builder.GetCellBackgroundColor(x, y) : AnsiColor.Black; + + if (x == 0 && y == 0 || backgroundColor != lastBackground) + { + lastBackground = backgroundColor; + presenter.Write(GetAnsiBackgroundEscapeSequence(backgroundColor)); + } + + if (c != 0) + { + var foregroundColor = !suppressColor ? builder.GetCellForegroundColor(x, y) : AnsiColor.White; + + if (x == 0 && y == 0 || foregroundColor != lastForeground) + { + lastForeground = foregroundColor; + presenter.Write(GetAnsiForegroundEscapeSequence(foregroundColor)); + } + + presenter.Write(c); + } + else + { + presenter.Write(" "); + } + } + + if (y < builder.DisplaySize.Height - 1) + presenter.Write(builder.LineTerminator); + } + } + + #endregion + } +} \ No newline at end of file diff --git a/NetAF/Rendering/Frames/GridTextFrame.cs b/NetAF/Rendering/Frames/GridTextFrame.cs index 4baab640..5682570b 100644 --- a/NetAF/Rendering/Frames/GridTextFrame.cs +++ b/NetAF/Rendering/Frames/GridTextFrame.cs @@ -35,12 +35,6 @@ public sealed class GridTextFrame(GridStringBuilder builder, int cursorLeft, int #endregion - #region Fields - - private readonly GridStringBuilder builder = builder; - - #endregion - #region Properties /// From 7037dd22efdd7be8f0d69e2aadc37b57e2f0c71c Mon Sep 17 00:00:00 2001 From: ben_singer Date: Sun, 24 Nov 2024 17:40:58 +0000 Subject: [PATCH 03/15] Refactored Ansi color code --- .../FrameBuilders/Console/Ansi_Tests.cs | 100 ++++++++++++ .../FrameBuilders/SceneHelper_Tests.cs | 1 - .../Rendering/Frames/GridTextFrame_Tests.cs | 50 ------ NetAF/Rendering/FrameBuilders/Console/Ansi.cs | 126 +++++++++++++++ NetAF/Rendering/Frames/GridPictureFrame.cs | 149 +++++++++++------- NetAF/Rendering/Frames/GridTextFrame.cs | 71 +-------- 6 files changed, 326 insertions(+), 171 deletions(-) create mode 100644 NetAF.Tests/Rendering/FrameBuilders/Console/Ansi_Tests.cs create mode 100644 NetAF/Rendering/FrameBuilders/Console/Ansi.cs diff --git a/NetAF.Tests/Rendering/FrameBuilders/Console/Ansi_Tests.cs b/NetAF.Tests/Rendering/FrameBuilders/Console/Ansi_Tests.cs new file mode 100644 index 00000000..8964f68f --- /dev/null +++ b/NetAF.Tests/Rendering/FrameBuilders/Console/Ansi_Tests.cs @@ -0,0 +1,100 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NetAF.Rendering.FrameBuilders.Console; +using System; + +namespace NetAF.Tests.Rendering.FrameBuilders.Console +{ + [TestClass] + public class Ansi_Tests + { + [TestMethod] + public void GivenNoColorEnvironmentVariableSetToEmptyString_WhenIsColorSuppressed_ThenReturnFalse() + { + Environment.SetEnvironmentVariable(Ansi.NO_COLOR, ""); + + var result = Ansi.IsColorSuppressed(); + + Assert.IsFalse(result); + } + + [TestMethod] + public void GivenNoColorEnvironmentVariableSetTo0_WhenIsColorSuppressed_ThenReturnFalse() + { + Environment.SetEnvironmentVariable(Ansi.NO_COLOR, "0"); + + var result = Ansi.IsColorSuppressed(); + + Assert.IsFalse(result); + } + + [TestMethod] + public void GivenNoColorEnvironmentVariableSetToFalse_WhenIsColorSuppressed_ThenReturnFalse() + { + Environment.SetEnvironmentVariable(Ansi.NO_COLOR, "False"); + + var result = Ansi.IsColorSuppressed(); + + Assert.IsFalse(result); + } + + [TestMethod] + public void GivenNoColorEnvironmentVariableSetTo1_WhenIsColorSuppressed_ThenReturnTrue() + { + Environment.SetEnvironmentVariable(Ansi.NO_COLOR, "1"); + + var result = Ansi.IsColorSuppressed(); + + Assert.IsTrue(result); + } + + [TestMethod] + public void GivenNoColorEnvironmentVariableSetToTrue_WhenIsColorSuppressed_ThenReturnTrue() + { + Environment.SetEnvironmentVariable(Ansi.NO_COLOR, "True"); + + var result = Ansi.IsColorSuppressed(); + + Assert.IsTrue(result); + } + + [TestMethod] + public void GivenRed_WhenFindNearestAnsiColor_ThenReturnAnsiColorBrightRed() + { + var result = Ansi.FindNearestAnsiColor(255, 0, 0); + + Assert.AreEqual(AnsiColor.BrightRed, result); + } + + [TestMethod] + public void GivenGreen_WhenFindNearestAnsiColor_ThenReturnAnsiColorBrightGreen() + { + var result = Ansi.FindNearestAnsiColor(0, 255, 0); + + Assert.AreEqual(AnsiColor.BrightGreen, result); + } + + [TestMethod] + public void GivenBlue_WhenFindNearestAnsiColor_ThenReturnAnsiColorBrightBlue() + { + var result = Ansi.FindNearestAnsiColor(0, 0, 255); + + Assert.AreEqual(AnsiColor.BrightBlue, result); + } + + [TestMethod] + public void GivenWhite_WhenFindNearestAnsiColor_ThenReturnAnsiColorBrightWhite() + { + var result = Ansi.FindNearestAnsiColor(255, 255, 255); + + Assert.AreEqual(AnsiColor.BrightWhite, result); + } + + [TestMethod] + public void GivenBlack_WhenFindNearestAnsiColor_ThenReturnAnsiColorBlack() + { + var result = Ansi.FindNearestAnsiColor(0, 0, 0); + + Assert.AreEqual(AnsiColor.Black, result); + } + } +} diff --git a/NetAF.Tests/Rendering/FrameBuilders/SceneHelper_Tests.cs b/NetAF.Tests/Rendering/FrameBuilders/SceneHelper_Tests.cs index 59ee169b..248b44e5 100644 --- a/NetAF.Tests/Rendering/FrameBuilders/SceneHelper_Tests.cs +++ b/NetAF.Tests/Rendering/FrameBuilders/SceneHelper_Tests.cs @@ -3,7 +3,6 @@ using NetAF.Rendering.FrameBuilders; using NetAF.Utilities; using Microsoft.VisualStudio.TestTools.UnitTesting; -using NetAF.Logic; namespace NetAF.Tests.Rendering.FrameBuilders { diff --git a/NetAF.Tests/Rendering/Frames/GridTextFrame_Tests.cs b/NetAF.Tests/Rendering/Frames/GridTextFrame_Tests.cs index 067d0a82..a016dd99 100644 --- a/NetAF.Tests/Rendering/Frames/GridTextFrame_Tests.cs +++ b/NetAF.Tests/Rendering/Frames/GridTextFrame_Tests.cs @@ -12,56 +12,6 @@ namespace NetAF.Tests.Rendering.Frames [TestClass] public class GridTextFrame_Tests { - [TestMethod] - public void GivenNoColorEnvironmentVariableSetToEmptyString_WhenIsColorSuppressed_ThenReturnFalse() - { - Environment.SetEnvironmentVariable(GridTextFrame.NO_COLOR, ""); - - var result = GridTextFrame.IsColorSuppressed(); - - Assert.IsFalse(result); - } - - [TestMethod] - public void GivenNoColorEnvironmentVariableSetTo0_WhenIsColorSuppressed_ThenReturnFalse() - { - Environment.SetEnvironmentVariable(GridTextFrame.NO_COLOR, "0"); - - var result = GridTextFrame.IsColorSuppressed(); - - Assert.IsFalse(result); - } - - [TestMethod] - public void GivenNoColorEnvironmentVariableSetToFalse_WhenIsColorSuppressed_ThenReturnFalse() - { - Environment.SetEnvironmentVariable(GridTextFrame.NO_COLOR, "False"); - - var result = GridTextFrame.IsColorSuppressed(); - - Assert.IsFalse(result); - } - - [TestMethod] - public void GivenNoColorEnvironmentVariableSetTo1_WhenIsColorSuppressed_ThenReturnTrue() - { - Environment.SetEnvironmentVariable(GridTextFrame.NO_COLOR, "1"); - - var result = GridTextFrame.IsColorSuppressed(); - - Assert.IsTrue(result); - } - - [TestMethod] - public void GivenNoColorEnvironmentVariableSetToTrue_WhenIsColorSuppressed_ThenReturnTrue() - { - Environment.SetEnvironmentVariable(GridTextFrame.NO_COLOR, "True"); - - var result = GridTextFrame.IsColorSuppressed(); - - Assert.IsTrue(result); - } - [TestMethod] public void Given10x10GridWithBorder_WhenRender_ThenStreamContainsData() { diff --git a/NetAF/Rendering/FrameBuilders/Console/Ansi.cs b/NetAF/Rendering/FrameBuilders/Console/Ansi.cs new file mode 100644 index 00000000..5d9a082d --- /dev/null +++ b/NetAF/Rendering/FrameBuilders/Console/Ansi.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; + +namespace NetAF.Rendering.FrameBuilders.Console +{ + /// + /// Provides helper functions for ANSI colors. + /// + public static class Ansi + { + #region Constants + + /// + /// Get the value for the NO_COLOR environment variable. + /// + public const string NO_COLOR = "NO_COLOR"; + + /// + /// Get the ANSI escape sequence to hide the cursor. + /// + public const string ANSI_HIDE_CURSOR = "\u001b[?25l"; + + /// + /// Get the ANSI escape sequence to show the cursor. + /// + public const string ANSI_SHOW_CURSOR = "\u001b[?25h"; + + #endregion + + #region StaticProperties + + /// + /// Get a mapping between ANSI colors and their RGB values. + /// + private static readonly Dictionary AnsiColorMap = new() + { + { AnsiColor.Black, (0, 0, 0) }, + { AnsiColor.Red, (128, 0, 0) }, + { AnsiColor.Green, (0, 128, 0) }, + { AnsiColor.Yellow, (128, 128, 0) }, + { AnsiColor.Blue, (0, 0, 128) }, + { AnsiColor.Magenta, (128, 0, 128) }, + { AnsiColor.Cyan, (0, 128, 128) }, + { AnsiColor.White, (192, 192, 192) }, + { AnsiColor.BrightBlack, (128, 128, 128) }, + { AnsiColor.BrightRed, (255, 0, 0) }, + { AnsiColor.BrightGreen, (0, 255, 0) }, + { AnsiColor.BrightYellow, (255, 255, 0) }, + { AnsiColor.BrightBlue, (0, 0, 255) }, + { AnsiColor.BrightMagenta, (255, 0, 255) }, + { AnsiColor.BrightCyan, (0, 255, 255) }, + { AnsiColor.BrightWhite, (255, 255, 255) } + }; + + #endregion + + #region StaticMethods + + /// + /// Find the nearest AnsiColor to a RGB color using Euclidean distance. + /// + /// The value of the red channel. + /// The value of the green channel. + /// The value of the blue channel. + /// The nearest AnsiColor. + public static AnsiColor FindNearestAnsiColor(byte r, byte g, byte b) + { + var nearestColor = AnsiColor.Black; + var smallestDistance = double.MaxValue; + + foreach (var (ansiColor, rgb) in AnsiColorMap) + { + var distance = Math.Sqrt( + Math.Pow(r - rgb.R, 2) + + Math.Pow(g - rgb.G, 2) + + Math.Pow(b - rgb.B, 2) + ); + + if (distance < smallestDistance) + { + smallestDistance = distance; + nearestColor = ansiColor; + } + } + + return nearestColor; + } + + /// + /// Determine if color is suppressed. If the NO_COLOR environment variable is present and set to anything other than '0' or 'false' this will return true. + /// + /// True if the NO_COLOR environment variable is present and set to anything other than '0' or 'false', else false. + public static bool IsColorSuppressed() + { + var value = Environment.GetEnvironmentVariable(NO_COLOR)?.ToLower() ?? string.Empty; + + return value switch + { + "" or "0" or "false" => false, + _ => true, + }; + } + + /// + /// Get an ANSI escape sequence for a foreground color. + /// + /// The foreground color. + /// The ANSI escape sequence. + public static string GetAnsiForegroundEscapeSequence(AnsiColor color) + { + return $"\u001B[{(int)color}m"; + } + + /// + /// Get an ANSI escape sequence for a background color. + /// + /// The background color. + /// The ANSI escape sequence. + public static string GetAnsiBackgroundEscapeSequence(AnsiColor color) + { + return $"\u001B[{(int)color + 10}m"; + } + + #endregion + } +} diff --git a/NetAF/Rendering/Frames/GridPictureFrame.cs b/NetAF/Rendering/Frames/GridPictureFrame.cs index fe5d5e4b..fc75f95c 100644 --- a/NetAF/Rendering/Frames/GridPictureFrame.cs +++ b/NetAF/Rendering/Frames/GridPictureFrame.cs @@ -1,5 +1,4 @@ -using System; -using System.Text; +using System.Text; using NetAF.Rendering.FrameBuilders; using NetAF.Rendering.FrameBuilders.Console; using NetAF.Rendering.Presenters; @@ -13,55 +12,120 @@ namespace NetAF.Rendering.Frames /// The builder that creates the frame. public sealed class GridPictureFrame(GridPictureBuilder builder) : IFrame { - #region Constants + #region Methods /// - /// Get the value for the NO_COLOR environment variable. + /// Get the foreground color for a cell. /// - internal const string NO_COLOR = "NO_COLOR"; + /// The x position of the cell. + /// The x position of the cell. + /// Specify if color should be suppressed. + /// The color. + private AnsiColor GetForegroundColor(int x, int y, bool suppressColor) + { + return !suppressColor ? builder.GetCellForegroundColor(x, y) : AnsiColor.White; + } /// - /// Get the ANSI escape sequence to hide the cursor. + /// Get the background color for a cell. /// - private const string ANSI_HIDE_CURSOR = "\u001b[?25l"; + /// The x position of the cell. + /// The x position of the cell. + /// Specify if color should be suppressed. + /// The color. + private AnsiColor GetBackgroundColor(int x, int y, bool suppressColor) + { + return !suppressColor ? builder.GetCellBackgroundColor(x, y) : AnsiColor.White; + } - #endregion + /// + /// Render a single character. + /// + /// The presenter. + /// The x position of the cell. + /// The x position of the cell. + /// True if color should be suppressed, else false. + /// The last foreground color. + /// The last background color. + private void RenderCharacter(IFramePresenter presenter, int x, int y, bool suppressColor, ref AnsiColor lastForeground, ref AnsiColor lastBackground) + { + var c = builder.GetCharacter(x, y); + var backgroundColor = GetBackgroundColor(x, y, suppressColor); - #region StaticMethods + UpdateBackgroundColor(presenter, x, y, backgroundColor, ref lastBackground); + + if (c != 0) + { + var foregroundColor = GetForegroundColor(x, y, suppressColor); + UpdateForegroundColor(presenter, x, y, foregroundColor, ref lastForeground); + presenter.Write(c); + } + else + { + presenter.Write(" "); + } + } /// - /// Determine if color is suppressed. If the NO_COLOR environment variable is present and set to anything other than '0' or 'false' this will return true. + /// Update the background color, if required. /// - /// True if the NO_COLOR environment variable is present and set to anything other than '0' or 'false', else false. - internal static bool IsColorSuppressed() + /// The presenter. + /// The x position of the cell. + /// The x position of the cell. + /// The background color. + /// The last background color. + private void UpdateBackgroundColor(IFramePresenter presenter, int x, int y, AnsiColor backgroundColor, ref AnsiColor lastBackgroundColor) { - var value = Environment.GetEnvironmentVariable(NO_COLOR)?.ToLower() ?? string.Empty; + if (RequiresColorChange(x, y, lastBackgroundColor, backgroundColor)) + { + lastBackgroundColor = backgroundColor; + presenter.Write(Ansi.GetAnsiBackgroundEscapeSequence(backgroundColor)); + } + } - return value switch + /// + /// Update the foreground color, if required. + /// + /// The presenter. + /// The x position of the cell. + /// The x position of the cell. + /// The foreground color. + /// The last foreground color. + private void UpdateForegroundColor(IFramePresenter presenter, int x, int y, AnsiColor foregroundColor, ref AnsiColor lastForegroundColor) + { + if (RequiresColorChange(x, y, lastForegroundColor, foregroundColor)) { - "" or "0" or "false" => false, - _ => true, - }; + lastForegroundColor = foregroundColor; + presenter.Write(Ansi.GetAnsiForegroundEscapeSequence(foregroundColor)); + } } + #endregion + + #region StaticMethods + /// - /// Get an ANSI escape sequence for a foreground color. + /// Get if a cell is the first cell. /// - /// The foreground color. - /// The ANSI escape sequence. - private static string GetAnsiForegroundEscapeSequence(AnsiColor color) + /// The x position of the cell. + /// The x position of the cell. + /// True if the first cell, else false. + private static bool IsFirstCell(int x, int y) { - return $"\u001B[{(int)color}m"; + return x == 0 && y == 0; } /// - /// Get an ANSI escape sequence for a background color. + /// Get if a color change is required. /// - /// The background color. - /// The ANSI escape sequence. - private static string GetAnsiBackgroundEscapeSequence(AnsiColor color) + /// The x position of the cell. + /// The x position of the cell. + /// The current color. + /// The next color. + /// True if a color change is required, else false. + private static bool RequiresColorChange(int x, int y, AnsiColor current, AnsiColor next) { - return $"\u001B[{(int)color + 10}m"; + return IsFirstCell(x, y) || next != current; } #endregion @@ -114,9 +178,9 @@ public override string ToString() /// The presenter. public void Render(IFramePresenter presenter) { - var suppressColor = IsColorSuppressed(); + var suppressColor = Ansi.IsColorSuppressed(); - presenter.Write(ANSI_HIDE_CURSOR); + presenter.Write(Ansi.ANSI_HIDE_CURSOR); AnsiColor lastBackground = AnsiColor.Black; AnsiColor lastForeground = AnsiColor.White; @@ -125,32 +189,7 @@ public void Render(IFramePresenter presenter) { for (var x = 0; x < builder.DisplaySize.Width; x++) { - var c = builder.GetCharacter(x, y); - - var backgroundColor = !suppressColor ? builder.GetCellBackgroundColor(x, y) : AnsiColor.Black; - - if (x == 0 && y == 0 || backgroundColor != lastBackground) - { - lastBackground = backgroundColor; - presenter.Write(GetAnsiBackgroundEscapeSequence(backgroundColor)); - } - - if (c != 0) - { - var foregroundColor = !suppressColor ? builder.GetCellForegroundColor(x, y) : AnsiColor.White; - - if (x == 0 && y == 0 || foregroundColor != lastForeground) - { - lastForeground = foregroundColor; - presenter.Write(GetAnsiForegroundEscapeSequence(foregroundColor)); - } - - presenter.Write(c); - } - else - { - presenter.Write(" "); - } + RenderCharacter(presenter, x, y, suppressColor, ref lastForeground, ref lastBackground); } if (y < builder.DisplaySize.Height - 1) diff --git a/NetAF/Rendering/Frames/GridTextFrame.cs b/NetAF/Rendering/Frames/GridTextFrame.cs index 5682570b..27be567c 100644 --- a/NetAF/Rendering/Frames/GridTextFrame.cs +++ b/NetAF/Rendering/Frames/GridTextFrame.cs @@ -1,5 +1,4 @@ -using System; -using System.Text; +using System.Text; using NetAF.Rendering.FrameBuilders; using NetAF.Rendering.FrameBuilders.Console; using NetAF.Rendering.Presenters; @@ -16,25 +15,6 @@ namespace NetAF.Rendering.Frames /// The background color. public sealed class GridTextFrame(GridStringBuilder builder, int cursorLeft, int cursorTop, AnsiColor backgroundColor) : IFrame { - #region Constants - - /// - /// Get the value for the NO_COLOR environment variable. - /// - internal const string NO_COLOR = "NO_COLOR"; - - /// - /// Get the ANSI escape sequence to hide the cursor. - /// - private const string ANSI_HIDE_CURSOR = "\u001b[?25l"; - - /// - /// Get the ANSI escape sequence to show the cursor. - /// - private const string ANSI_SHOW_CURSOR = "\u001b[?25h"; - - #endregion - #region Properties /// @@ -44,45 +24,6 @@ public sealed class GridTextFrame(GridStringBuilder builder, int cursorLeft, int #endregion - #region StaticMethods - - /// - /// Determine if color is suppressed. If the NO_COLOR environment variable is present and set to anything other than '0' or 'false' this will return true. - /// - /// True if the NO_COLOR environment variable is present and set to anything other than '0' or 'false', else false. - internal static bool IsColorSuppressed() - { - var value = Environment.GetEnvironmentVariable(NO_COLOR)?.ToLower() ?? string.Empty; - - return value switch - { - "" or "0" or "false" => false, - _ => true, - }; - } - - /// - /// Get an ANSI escape sequence for a foreground color. - /// - /// The foreground color. - /// The ANSI escape sequence. - private static string GetAnsiForegroundEscapeSequence(AnsiColor color) - { - return $"\u001B[{(int)color}m"; - } - - /// - /// Get an ANSI escape sequence for a background color. - /// - /// The background color. - /// The ANSI escape sequence. - private static string GetAnsiBackgroundEscapeSequence(AnsiColor color) - { - return $"\u001B[{(int)color + 10}m"; - } - - #endregion - #region Overrides of Object /// @@ -131,12 +72,12 @@ public override string ToString() /// The presenter. public void Render(IFramePresenter presenter) { - var suppressColor = IsColorSuppressed(); + var suppressColor = Ansi.IsColorSuppressed(); if (!suppressColor) - presenter.Write(GetAnsiBackgroundEscapeSequence(BackgroundColor)); + presenter.Write(Ansi.GetAnsiBackgroundEscapeSequence(BackgroundColor)); - presenter.Write(ANSI_HIDE_CURSOR); + presenter.Write(Ansi.ANSI_HIDE_CURSOR); for (var y = 0; y < builder.DisplaySize.Height; y++) { @@ -148,7 +89,7 @@ public void Render(IFramePresenter presenter) { if (!suppressColor) { - presenter.Write(GetAnsiForegroundEscapeSequence(builder.GetCellColor(x, y))); + presenter.Write(Ansi.GetAnsiForegroundEscapeSequence(builder.GetCellColor(x, y))); } presenter.Write(c); @@ -163,7 +104,7 @@ public void Render(IFramePresenter presenter) presenter.Write(builder.LineTerminator); } - presenter.Write(ANSI_SHOW_CURSOR); + presenter.Write(Ansi.ANSI_SHOW_CURSOR); } #endregion From 7d401f1aa64f773bf5444192b889a71e509fb869 Mon Sep 17 00:00:00 2001 From: ben_singer Date: Sun, 24 Nov 2024 18:05:32 +0000 Subject: [PATCH 04/15] Added unit tests --- .../FrameBuilders/GridPictureBuilder_Tests.cs | 46 +++++++++++++++++++ .../Frames/GridPictureFrame_Tests.cs | 37 +++++++++++++++ .../FrameBuilders/GridPictureBuilder.cs | 6 +-- .../FrameBuilders/GridStringBuilder.cs | 2 +- 4 files changed, 87 insertions(+), 4 deletions(-) create mode 100644 NetAF.Tests/Rendering/FrameBuilders/GridPictureBuilder_Tests.cs create mode 100644 NetAF.Tests/Rendering/Frames/GridPictureFrame_Tests.cs diff --git a/NetAF.Tests/Rendering/FrameBuilders/GridPictureBuilder_Tests.cs b/NetAF.Tests/Rendering/FrameBuilders/GridPictureBuilder_Tests.cs new file mode 100644 index 00000000..5a617d92 --- /dev/null +++ b/NetAF.Tests/Rendering/FrameBuilders/GridPictureBuilder_Tests.cs @@ -0,0 +1,46 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NetAF.Rendering.FrameBuilders; +using NetAF.Rendering.FrameBuilders.Console; + +namespace NetAF.Tests.Rendering.FrameBuilders +{ + [TestClass] + public class GridPictureBuilder_Tests + { + [TestMethod] + public void GivenBlank_WhenSetCell_ThenCharacterSetCorrectly() + { + var builder = new GridPictureBuilder(); + builder.Resize(new(10, 10)); + + builder.SetCell(0, 0, 'C', AnsiColor.Red, AnsiColor.Green); + var result = builder.GetCharacter(0, 0); + + Assert.AreEqual('C', result); + } + + [TestMethod] + public void GivenBlank_WhenSetCell_ThenForegroundColorSetCorrectly() + { + var builder = new GridPictureBuilder(); + builder.Resize(new(10, 10)); + + builder.SetCell(0, 0, 'C', AnsiColor.Red, AnsiColor.Green); + var foreground = builder.GetCellForegroundColor(0, 0); + + Assert.AreEqual(AnsiColor.Red, foreground); + } + + [TestMethod] + public void GivenBlank_WhenSetCell_ThenBackgroundColorSetCorrectly() + { + var builder = new GridPictureBuilder(); + builder.Resize(new(10, 10)); + + builder.SetCell(0, 0, 'C', AnsiColor.Red, AnsiColor.Green); + var background = builder.GetCellBackgroundColor(0, 0); + + Assert.AreEqual(AnsiColor.Green, background); + } + } +} diff --git a/NetAF.Tests/Rendering/Frames/GridPictureFrame_Tests.cs b/NetAF.Tests/Rendering/Frames/GridPictureFrame_Tests.cs new file mode 100644 index 00000000..78870101 --- /dev/null +++ b/NetAF.Tests/Rendering/Frames/GridPictureFrame_Tests.cs @@ -0,0 +1,37 @@ +using System; +using System.IO; +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NetAF.Rendering.FrameBuilders; +using NetAF.Rendering.FrameBuilders.Console; +using NetAF.Rendering.Frames; +using NetAF.Rendering.Presenters; + +namespace NetAF.Tests.Rendering.Frames +{ + [TestClass] + public class GridPictureFrame_Tests + { + [TestMethod] + public void Given10x10GridWithBorder_WhenRender_ThenStreamContainsData() + { + var gridPictureBuilder = new GridPictureBuilder(); + gridPictureBuilder.Resize(new(10, 10)); + gridPictureBuilder.SetCell(0, 0, 'C', AnsiColor.Black, AnsiColor.Green); + gridPictureBuilder.SetCell(1, 0, 'D', AnsiColor.Green, AnsiColor.Black); + var frame = new GridPictureFrame(gridPictureBuilder); + byte[] data; + + using (var stream = new MemoryStream()) + { + using var writer = new StreamWriter(stream); + var presenter = new TextWriterPresenter(writer); + frame.Render(presenter); + writer.Flush(); + data = stream.ToArray(); + } + + Assert.IsTrue(Array.Exists(data, x => x != 0)); + } + } +} diff --git a/NetAF/Rendering/FrameBuilders/GridPictureBuilder.cs b/NetAF/Rendering/FrameBuilders/GridPictureBuilder.cs index 48fa06f3..a203bb5a 100644 --- a/NetAF/Rendering/FrameBuilders/GridPictureBuilder.cs +++ b/NetAF/Rendering/FrameBuilders/GridPictureBuilder.cs @@ -40,8 +40,6 @@ public class GridPictureBuilder public void Resize(Size displaySize) { DisplaySize = displaySize; - backgroundColors = new AnsiColor[displaySize.Width, displaySize.Height]; - foregroundColors = new AnsiColor[displaySize.Width, displaySize.Height]; Flush(); } @@ -75,7 +73,7 @@ public AnsiColor GetCellForegroundColor(int x, int y) /// The cell background color. public AnsiColor GetCellBackgroundColor(int x, int y) { - return foregroundColors[x, y]; + return backgroundColors[x, y]; } /// @@ -84,6 +82,8 @@ public AnsiColor GetCellBackgroundColor(int x, int y) public void Flush() { buffer = new char[DisplaySize.Width, DisplaySize.Height]; + backgroundColors = new AnsiColor[DisplaySize.Width, DisplaySize.Height]; + foregroundColors = new AnsiColor[DisplaySize.Width, DisplaySize.Height]; } /// diff --git a/NetAF/Rendering/FrameBuilders/GridStringBuilder.cs b/NetAF/Rendering/FrameBuilders/GridStringBuilder.cs index 40809d55..8f9d86be 100644 --- a/NetAF/Rendering/FrameBuilders/GridStringBuilder.cs +++ b/NetAF/Rendering/FrameBuilders/GridStringBuilder.cs @@ -57,7 +57,6 @@ public class GridStringBuilder(char leftBoundaryCharacter = (char)124, char righ public void Resize(Size displaySize) { DisplaySize = displaySize; - colors = new AnsiColor[displaySize.Width, displaySize.Height]; Flush(); } @@ -89,6 +88,7 @@ public AnsiColor GetCellColor(int x, int y) public void Flush() { buffer = new char[DisplaySize.Width, DisplaySize.Height]; + colors = new AnsiColor[DisplaySize.Width, DisplaySize.Height]; } /// From 95460bc6914a06b24925c09bc5ba4e9dcc5dc263 Mon Sep 17 00:00:00 2001 From: ben_singer Date: Sun, 24 Nov 2024 18:18:39 +0000 Subject: [PATCH 05/15] Basic picture frame working --- NetAF.Examples/Program.cs | 18 +++++++++ .../FrameBuilders/GridPictureBuilder_Tests.cs | 32 ++++++++++++--- .../Frames/GridPictureFrame_Tests.cs | 3 +- .../FrameBuilders/GridPictureBuilder.cs | 40 +++++++++++++++---- 4 files changed, 79 insertions(+), 14 deletions(-) diff --git a/NetAF.Examples/Program.cs b/NetAF.Examples/Program.cs index fec8f7a2..8ae639c0 100644 --- a/NetAF.Examples/Program.cs +++ b/NetAF.Examples/Program.cs @@ -14,6 +14,10 @@ using NetAF.Extensions; using NetAF.Logic; using NetAF.Logic.Configuration; +using NetAF.Logic.Modes; +using NetAF.Rendering.FrameBuilders.Console; +using NetAF.Rendering.FrameBuilders; +using NetAF.Rendering.Frames; namespace NetAF.Examples { @@ -96,6 +100,20 @@ static Overworld overworldCreator() return new(ReactionResult.Inform, $"Jumped to {x} {y} {z}."); }), + new(new("Picture", "Display a picture."), true, true, (g, a) => + { + var gridPictureBuilder = new GridPictureBuilder(AnsiColor.Black, AnsiColor.BrightWhite); + gridPictureBuilder.Resize(new(10, 10)); + gridPictureBuilder.SetCell(0, 0, 'C', AnsiColor.Cyan, AnsiColor.Magenta); + gridPictureBuilder.SetCell(1, 0, 'D', AnsiColor.Blue, AnsiColor.Red); + gridPictureBuilder.SetCell(2, 0, 'C', AnsiColor.Cyan, AnsiColor.Magenta); + gridPictureBuilder.SetCell(3, 0, 'D', AnsiColor.Blue, AnsiColor.Red); + gridPictureBuilder.SetCell(4, 0, 'C', AnsiColor.Cyan, AnsiColor.Magenta); + gridPictureBuilder.SetCell(5, 0, 'D', AnsiColor.Blue, AnsiColor.Red); + var frame = new GridPictureFrame(gridPictureBuilder); + g.ChangeMode(new DirectRenderMode(frame)); + return new(ReactionResult.GameModeChanged, string.Empty); + }), new Save(), new Load() ]; diff --git a/NetAF.Tests/Rendering/FrameBuilders/GridPictureBuilder_Tests.cs b/NetAF.Tests/Rendering/FrameBuilders/GridPictureBuilder_Tests.cs index 5a617d92..294f4e31 100644 --- a/NetAF.Tests/Rendering/FrameBuilders/GridPictureBuilder_Tests.cs +++ b/NetAF.Tests/Rendering/FrameBuilders/GridPictureBuilder_Tests.cs @@ -10,10 +10,10 @@ public class GridPictureBuilder_Tests [TestMethod] public void GivenBlank_WhenSetCell_ThenCharacterSetCorrectly() { - var builder = new GridPictureBuilder(); + var builder = new GridPictureBuilder(AnsiColor.Black, AnsiColor.White); builder.Resize(new(10, 10)); - builder.SetCell(0, 0, 'C', AnsiColor.Red, AnsiColor.Green); + builder.SetCell(0, 0, 'C', AnsiColor.Red); var result = builder.GetCharacter(0, 0); Assert.AreEqual('C', result); @@ -22,7 +22,7 @@ public void GivenBlank_WhenSetCell_ThenCharacterSetCorrectly() [TestMethod] public void GivenBlank_WhenSetCell_ThenForegroundColorSetCorrectly() { - var builder = new GridPictureBuilder(); + var builder = new GridPictureBuilder(AnsiColor.Black, AnsiColor.White); builder.Resize(new(10, 10)); builder.SetCell(0, 0, 'C', AnsiColor.Red, AnsiColor.Green); @@ -34,13 +34,35 @@ public void GivenBlank_WhenSetCell_ThenForegroundColorSetCorrectly() [TestMethod] public void GivenBlank_WhenSetCell_ThenBackgroundColorSetCorrectly() { - var builder = new GridPictureBuilder(); + var builder = new GridPictureBuilder(AnsiColor.Black, AnsiColor.White); builder.Resize(new(10, 10)); - builder.SetCell(0, 0, 'C', AnsiColor.Red, AnsiColor.Green); + builder.SetCell(0, 0, AnsiColor.Green); var background = builder.GetCellBackgroundColor(0, 0); Assert.AreEqual(AnsiColor.Green, background); } + + [TestMethod] + public void GivenBlank_WhenNotSer_ThenBackgroundColorSetCorrectly() + { + var builder = new GridPictureBuilder(AnsiColor.Black, AnsiColor.White); + builder.Resize(new(10, 10)); + + var background = builder.GetCellBackgroundColor(0, 0); + + Assert.AreEqual(AnsiColor.Black, background); + } + + [TestMethod] + public void GivenBlank_WhenNotSer_ThenForegroundColorSetCorrectly() + { + var builder = new GridPictureBuilder(AnsiColor.Black, AnsiColor.White); + builder.Resize(new(10, 10)); + + var foreground = builder.GetCellForegroundColor(0, 0); + + Assert.AreEqual(AnsiColor.White, foreground); + } } } diff --git a/NetAF.Tests/Rendering/Frames/GridPictureFrame_Tests.cs b/NetAF.Tests/Rendering/Frames/GridPictureFrame_Tests.cs index 78870101..f7dedf5d 100644 --- a/NetAF.Tests/Rendering/Frames/GridPictureFrame_Tests.cs +++ b/NetAF.Tests/Rendering/Frames/GridPictureFrame_Tests.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; using NetAF.Rendering.FrameBuilders; using NetAF.Rendering.FrameBuilders.Console; @@ -15,7 +14,7 @@ public class GridPictureFrame_Tests [TestMethod] public void Given10x10GridWithBorder_WhenRender_ThenStreamContainsData() { - var gridPictureBuilder = new GridPictureBuilder(); + var gridPictureBuilder = new GridPictureBuilder(AnsiColor.Black, AnsiColor.White); gridPictureBuilder.Resize(new(10, 10)); gridPictureBuilder.SetCell(0, 0, 'C', AnsiColor.Black, AnsiColor.Green); gridPictureBuilder.SetCell(1, 0, 'D', AnsiColor.Green, AnsiColor.Black); diff --git a/NetAF/Rendering/FrameBuilders/GridPictureBuilder.cs b/NetAF/Rendering/FrameBuilders/GridPictureBuilder.cs index a203bb5a..13624914 100644 --- a/NetAF/Rendering/FrameBuilders/GridPictureBuilder.cs +++ b/NetAF/Rendering/FrameBuilders/GridPictureBuilder.cs @@ -7,12 +7,14 @@ namespace NetAF.Rendering.FrameBuilders /// /// Provides a class for building pictures in a grid. /// - public class GridPictureBuilder + /// The background color. + /// The foreground color. + public class GridPictureBuilder(AnsiColor background, AnsiColor foreground) { #region Fields - private AnsiColor[,] foregroundColors; - private AnsiColor[,] backgroundColors; + private AnsiColor?[,] foregroundColors; + private AnsiColor?[,] backgroundColors; private char[,] buffer; #endregion @@ -62,7 +64,7 @@ public char GetCharacter(int x, int y) /// The cell foreground color. public AnsiColor GetCellForegroundColor(int x, int y) { - return foregroundColors[x, y]; + return foregroundColors[x, y] ?? foreground; } /// @@ -73,7 +75,7 @@ public AnsiColor GetCellForegroundColor(int x, int y) /// The cell background color. public AnsiColor GetCellBackgroundColor(int x, int y) { - return backgroundColors[x, y]; + return backgroundColors[x, y] ?? background; } /// @@ -82,8 +84,32 @@ public AnsiColor GetCellBackgroundColor(int x, int y) public void Flush() { buffer = new char[DisplaySize.Width, DisplaySize.Height]; - backgroundColors = new AnsiColor[DisplaySize.Width, DisplaySize.Height]; - foregroundColors = new AnsiColor[DisplaySize.Width, DisplaySize.Height]; + backgroundColors = new AnsiColor?[DisplaySize.Width, DisplaySize.Height]; + foregroundColors = new AnsiColor?[DisplaySize.Width, DisplaySize.Height]; + } + + /// + /// Set a cell. + /// + /// The x position of the cell. + /// The y position of the cell. + /// The backgroundColor color of the cell. + public void SetCell(int x, int y, AnsiColor backgroundColor) + { + backgroundColors[x, y] = backgroundColor; + } + + /// + /// Set a cell. + /// + /// The x position of the cell. + /// The y position of the cell. + /// The character. + /// The foreground color of the cell. + public void SetCell(int x, int y, char character, AnsiColor foregroundColor) + { + buffer[x, y] = character; + foregroundColors[x, y] = foregroundColor; } /// From 9cd8d3fe39ce0957c24bfecb5007d515427ec86f Mon Sep 17 00:00:00 2001 From: ben_singer Date: Mon, 25 Nov 2024 15:49:12 +0000 Subject: [PATCH 06/15] Grouped classes to more appropriate namespaces --- NetAF.Examples/Program.cs | 4 +--- NetAF.Tests/Logic/Modes/DirectRenderMode_Tests.cs | 5 ++--- .../Rendering/{FrameBuilders => }/Console/Ansi_Tests.cs | 4 ++-- .../FrameBuilders}/ConsoleAboutFrameBuilder_Tests.cs | 6 +++--- .../FrameBuilders}/ConsoleCommandListFrameBuilder_Tests.cs | 6 +++--- .../FrameBuilders}/ConsoleCompletionFrameBuilder_Tests.cs | 6 +++--- .../ConsoleConversationFrameBuilder_Tests.cs | 6 +++--- .../FrameBuilders}/ConsoleGameOverFrameBuilder_Tests.cs | 6 +++--- .../FrameBuilders}/ConsoleHelpFrameBuilder_Tests.cs | 6 +++--- .../FrameBuilders}/ConsoleReactionFrameBuilder_Tests.cs | 6 +++--- .../FrameBuilders}/ConsoleRegionMapBuilder_Tests.cs | 6 +++--- .../FrameBuilders}/ConsoleRegionMapFrameBuilder_Tests.cs | 6 +++--- .../FrameBuilders}/ConsoleRoomMapBuilder_Tests.cs | 6 +++--- .../FrameBuilders}/ConsoleSceneFrameBuilder_Tests.cs | 6 +++--- .../FrameBuilders}/ConsoleTitleFrameBuilder_Tests.cs | 6 +++--- .../{FrameBuilders => Console}/GridPictureBuilder_Tests.cs | 5 ++--- .../{Frames => Console}/GridPictureFrame_Tests.cs | 7 ++----- .../{FrameBuilders => Console}/GridStringBuilder_Tests.cs | 5 ++--- .../Rendering/{Frames => Console}/GridTextFrame_Tests.cs | 7 ++----- .../{Presenters => Console}/TextWriterPresenter_Tests.cs | 4 ++-- NetAF.Tests/TestConsoleAdapter.cs | 2 +- NetAF/Adapters/IIOAdapter.cs | 2 +- NetAF/Adapters/SystemConsoleAdapter.cs | 4 ++-- NetAF/Logic/Modes/DirectRenderMode.cs | 2 +- NetAF/Rendering/{FrameBuilders => }/Console/Ansi.cs | 2 +- NetAF/Rendering/{FrameBuilders => }/Console/AnsiColor.cs | 2 +- .../FrameBuilders}/ConsoleAboutFrameBuilder.cs | 4 ++-- .../FrameBuilders}/ConsoleCommandListFrameBuilder.cs | 4 ++-- .../FrameBuilders}/ConsoleCompletionFrameBuilder.cs | 4 ++-- .../FrameBuilders}/ConsoleConversationFrameBuilder.cs | 4 ++-- .../FrameBuilders}/ConsoleGameOverFrameBuilder.cs | 4 ++-- .../FrameBuilders}/ConsoleHelpFrameBuilder.cs | 4 ++-- .../FrameBuilders}/ConsoleReactionFrameBuilder.cs | 6 +++--- .../FrameBuilders}/ConsoleRegionMapBuilder.cs | 5 +++-- .../FrameBuilders}/ConsoleRegionMapFrameBuilder.cs | 4 ++-- .../FrameBuilders}/ConsoleRoomMapBuilder.cs | 3 ++- .../FrameBuilders}/ConsoleSceneFrameBuilder.cs | 4 ++-- .../FrameBuilders}/ConsoleTitleFrameBuilder.cs | 4 ++-- .../{FrameBuilders => Console}/GridPictureBuilder.cs | 3 +-- NetAF/Rendering/{Frames => Console}/GridPictureFrame.cs | 5 +---- .../{FrameBuilders => Console}/GridStringBuilder.cs | 3 +-- NetAF/Rendering/{Frames => Console}/GridTextFrame.cs | 5 +---- .../{Presenters => Console}/TextWriterPresenter.cs | 2 +- NetAF/Rendering/FrameBuilders/FrameBuilderCollections.cs | 3 ++- NetAF/Rendering/FrameBuilders/IAboutFrameBuilder.cs | 1 - NetAF/Rendering/FrameBuilders/ICommandListFrameBuilder.cs | 1 - NetAF/Rendering/FrameBuilders/ICompletionFrameBuilder.cs | 1 - NetAF/Rendering/FrameBuilders/IConversationFrameBuilder.cs | 1 - NetAF/Rendering/FrameBuilders/IGameOverFrameBuilder.cs | 1 - NetAF/Rendering/FrameBuilders/IHelpFrameBuilder.cs | 1 - NetAF/Rendering/FrameBuilders/IReactionFrameBuilder.cs | 1 - NetAF/Rendering/FrameBuilders/IRegionMapFrameBuilder.cs | 1 - NetAF/Rendering/FrameBuilders/ISceneFrameBuilder.cs | 1 - NetAF/Rendering/FrameBuilders/ITitleFrameBuilder.cs | 1 - NetAF/Rendering/{Frames => }/IFrame.cs | 4 +--- NetAF/Rendering/{Presenters => }/IFramePresenter.cs | 2 +- 56 files changed, 93 insertions(+), 121 deletions(-) rename NetAF.Tests/Rendering/{FrameBuilders => }/Console/Ansi_Tests.cs (96%) rename NetAF.Tests/Rendering/{FrameBuilders/Console => Console/FrameBuilders}/ConsoleAboutFrameBuilder_Tests.cs (84%) rename NetAF.Tests/Rendering/{FrameBuilders/Console => Console/FrameBuilders}/ConsoleCommandListFrameBuilder_Tests.cs (81%) rename NetAF.Tests/Rendering/{FrameBuilders/Console => Console/FrameBuilders}/ConsoleCompletionFrameBuilder_Tests.cs (80%) rename NetAF.Tests/Rendering/{FrameBuilders/Console => Console/FrameBuilders}/ConsoleConversationFrameBuilder_Tests.cs (95%) rename NetAF.Tests/Rendering/{FrameBuilders/Console => Console/FrameBuilders}/ConsoleGameOverFrameBuilder_Tests.cs (80%) rename NetAF.Tests/Rendering/{FrameBuilders/Console => Console/FrameBuilders}/ConsoleHelpFrameBuilder_Tests.cs (88%) rename NetAF.Tests/Rendering/{FrameBuilders/Console => Console/FrameBuilders}/ConsoleReactionFrameBuilder_Tests.cs (88%) rename NetAF.Tests/Rendering/{FrameBuilders/Console => Console/FrameBuilders}/ConsoleRegionMapBuilder_Tests.cs (87%) rename NetAF.Tests/Rendering/{FrameBuilders/Console => Console/FrameBuilders}/ConsoleRegionMapFrameBuilder_Tests.cs (94%) rename NetAF.Tests/Rendering/{FrameBuilders/Console => Console/FrameBuilders}/ConsoleRoomMapBuilder_Tests.cs (97%) rename NetAF.Tests/Rendering/{FrameBuilders/Console => Console/FrameBuilders}/ConsoleSceneFrameBuilder_Tests.cs (98%) rename NetAF.Tests/Rendering/{FrameBuilders/Console => Console/FrameBuilders}/ConsoleTitleFrameBuilder_Tests.cs (80%) rename NetAF.Tests/Rendering/{FrameBuilders => Console}/GridPictureBuilder_Tests.cs (94%) rename NetAF.Tests/Rendering/{Frames => Console}/GridPictureFrame_Tests.cs (85%) rename NetAF.Tests/Rendering/{FrameBuilders => Console}/GridStringBuilder_Tests.cs (96%) rename NetAF.Tests/Rendering/{Frames => Console}/GridTextFrame_Tests.cs (88%) rename NetAF.Tests/Rendering/{Presenters => Console}/TextWriterPresenter_Tests.cs (91%) rename NetAF/Rendering/{FrameBuilders => }/Console/Ansi.cs (98%) rename NetAF/Rendering/{FrameBuilders => }/Console/AnsiColor.cs (97%) rename NetAF/Rendering/{FrameBuilders/Console => Console/FrameBuilders}/ConsoleAboutFrameBuilder.cs (97%) rename NetAF/Rendering/{FrameBuilders/Console => Console/FrameBuilders}/ConsoleCommandListFrameBuilder.cs (97%) rename NetAF/Rendering/{FrameBuilders/Console => Console/FrameBuilders}/ConsoleCompletionFrameBuilder.cs (96%) rename NetAF/Rendering/{FrameBuilders/Console => Console/FrameBuilders}/ConsoleConversationFrameBuilder.cs (98%) rename NetAF/Rendering/{FrameBuilders/Console => Console/FrameBuilders}/ConsoleGameOverFrameBuilder.cs (96%) rename NetAF/Rendering/{FrameBuilders/Console => Console/FrameBuilders}/ConsoleHelpFrameBuilder.cs (97%) rename NetAF/Rendering/{FrameBuilders/Console => Console/FrameBuilders}/ConsoleReactionFrameBuilder.cs (96%) rename NetAF/Rendering/{FrameBuilders/Console => Console/FrameBuilders}/ConsoleRegionMapBuilder.cs (99%) rename NetAF/Rendering/{FrameBuilders/Console => Console/FrameBuilders}/ConsoleRegionMapFrameBuilder.cs (98%) rename NetAF/Rendering/{FrameBuilders/Console => Console/FrameBuilders}/ConsoleRoomMapBuilder.cs (99%) rename NetAF/Rendering/{FrameBuilders/Console => Console/FrameBuilders}/ConsoleSceneFrameBuilder.cs (98%) rename NetAF/Rendering/{FrameBuilders/Console => Console/FrameBuilders}/ConsoleTitleFrameBuilder.cs (96%) rename NetAF/Rendering/{FrameBuilders => Console}/GridPictureBuilder.cs (98%) rename NetAF/Rendering/{Frames => Console}/GridPictureFrame.cs (98%) rename NetAF/Rendering/{FrameBuilders => Console}/GridStringBuilder.cs (98%) rename NetAF/Rendering/{Frames => Console}/GridTextFrame.cs (95%) rename NetAF/Rendering/{Presenters => Console}/TextWriterPresenter.cs (97%) rename NetAF/Rendering/{Frames => }/IFrame.cs (91%) rename NetAF/Rendering/{Presenters => }/IFramePresenter.cs (92%) diff --git a/NetAF.Examples/Program.cs b/NetAF.Examples/Program.cs index 8ae639c0..11118dcc 100644 --- a/NetAF.Examples/Program.cs +++ b/NetAF.Examples/Program.cs @@ -15,9 +15,7 @@ using NetAF.Logic; using NetAF.Logic.Configuration; using NetAF.Logic.Modes; -using NetAF.Rendering.FrameBuilders.Console; -using NetAF.Rendering.FrameBuilders; -using NetAF.Rendering.Frames; +using NetAF.Rendering.Console; namespace NetAF.Examples { diff --git a/NetAF.Tests/Logic/Modes/DirectRenderMode_Tests.cs b/NetAF.Tests/Logic/Modes/DirectRenderMode_Tests.cs index 7f5a3e05..a032e171 100644 --- a/NetAF.Tests/Logic/Modes/DirectRenderMode_Tests.cs +++ b/NetAF.Tests/Logic/Modes/DirectRenderMode_Tests.cs @@ -4,8 +4,7 @@ using NetAF.Assets.Locations; using NetAF.Utilities; using NetAF.Logic.Modes; -using NetAF.Rendering.Frames; -using NetAF.Rendering.FrameBuilders; +using NetAF.Rendering.Console; namespace NetAF.Tests.Logic.Modes { @@ -22,7 +21,7 @@ public void GivenNew_WhenRender_ThenNoExceptionThrown() regionMaker[0, 0, 0] = room; OverworldMaker overworldMaker = new(string.Empty, string.Empty, regionMaker); var game = Game.Create(new(string.Empty, string.Empty, string.Empty), string.Empty, AssetGenerator.Retained(overworldMaker.Make(), new PlayableCharacter(string.Empty, string.Empty)), GameEndConditions.NoEnd, TestGameConfiguration.Default).Invoke(); - var mode = new DirectRenderMode(new GridTextFrame(new GridStringBuilder(), 0, 0, NetAF.Rendering.FrameBuilders.Console.AnsiColor.Red)); + var mode = new DirectRenderMode(new GridTextFrame(new GridStringBuilder(), 0, 0, AnsiColor.Red)); mode.Render(game); }); diff --git a/NetAF.Tests/Rendering/FrameBuilders/Console/Ansi_Tests.cs b/NetAF.Tests/Rendering/Console/Ansi_Tests.cs similarity index 96% rename from NetAF.Tests/Rendering/FrameBuilders/Console/Ansi_Tests.cs rename to NetAF.Tests/Rendering/Console/Ansi_Tests.cs index 8964f68f..875e390b 100644 --- a/NetAF.Tests/Rendering/FrameBuilders/Console/Ansi_Tests.cs +++ b/NetAF.Tests/Rendering/Console/Ansi_Tests.cs @@ -1,8 +1,8 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -using NetAF.Rendering.FrameBuilders.Console; +using NetAF.Rendering.Console; using System; -namespace NetAF.Tests.Rendering.FrameBuilders.Console +namespace NetAF.Tests.Rendering.Console { [TestClass] public class Ansi_Tests diff --git a/NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleAboutFrameBuilder_Tests.cs b/NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleAboutFrameBuilder_Tests.cs similarity index 84% rename from NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleAboutFrameBuilder_Tests.cs rename to NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleAboutFrameBuilder_Tests.cs index 15f05fef..f6089d12 100644 --- a/NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleAboutFrameBuilder_Tests.cs +++ b/NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleAboutFrameBuilder_Tests.cs @@ -1,10 +1,10 @@ using NetAF.Logic; using Microsoft.VisualStudio.TestTools.UnitTesting; -using NetAF.Rendering.FrameBuilders; -using NetAF.Rendering.FrameBuilders.Console; using NetAF.Assets; +using NetAF.Rendering.Console.FrameBuilders; +using NetAF.Rendering.Console; -namespace NetAF.Tests.Rendering.FrameBuilders.Console +namespace NetAF.Tests.Rendering.Console.FrameBuilders { [TestClass] public class ConsoleAboutFrameBuilder_Tests diff --git a/NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleCommandListFrameBuilder_Tests.cs b/NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleCommandListFrameBuilder_Tests.cs similarity index 81% rename from NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleCommandListFrameBuilder_Tests.cs rename to NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleCommandListFrameBuilder_Tests.cs index 8aca9833..e5cb54bd 100644 --- a/NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleCommandListFrameBuilder_Tests.cs +++ b/NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleCommandListFrameBuilder_Tests.cs @@ -1,10 +1,10 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NetAF.Assets; using NetAF.Commands.Scene; -using NetAF.Rendering.FrameBuilders; -using NetAF.Rendering.FrameBuilders.Console; +using NetAF.Rendering.Console; +using NetAF.Rendering.Console.FrameBuilders; -namespace NetAF.Tests.Rendering.FrameBuilders.Console +namespace NetAF.Tests.Rendering.Console.FrameBuilders { [TestClass] public class ConsoleCommandListFrameBuilder_Tests diff --git a/NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleCompletionFrameBuilder_Tests.cs b/NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleCompletionFrameBuilder_Tests.cs similarity index 80% rename from NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleCompletionFrameBuilder_Tests.cs rename to NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleCompletionFrameBuilder_Tests.cs index 489e8191..aac5214d 100644 --- a/NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleCompletionFrameBuilder_Tests.cs +++ b/NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleCompletionFrameBuilder_Tests.cs @@ -1,9 +1,9 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NetAF.Assets; -using NetAF.Rendering.FrameBuilders; -using NetAF.Rendering.FrameBuilders.Console; +using NetAF.Rendering.Console; +using NetAF.Rendering.Console.FrameBuilders; -namespace NetAF.Tests.Rendering.FrameBuilders.Console +namespace NetAF.Tests.Rendering.Console.FrameBuilders { [TestClass] public class ConsoleCompletionFrameBuilder_Tests diff --git a/NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleConversationFrameBuilder_Tests.cs b/NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleConversationFrameBuilder_Tests.cs similarity index 95% rename from NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleConversationFrameBuilder_Tests.cs rename to NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleConversationFrameBuilder_Tests.cs index 80a374f7..7900670a 100644 --- a/NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleConversationFrameBuilder_Tests.cs +++ b/NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleConversationFrameBuilder_Tests.cs @@ -1,12 +1,12 @@ using NetAF.Assets.Characters; using NetAF.Conversations; using Microsoft.VisualStudio.TestTools.UnitTesting; -using NetAF.Rendering.FrameBuilders.Console; -using NetAF.Rendering.FrameBuilders; using NetAF.Commands; using NetAF.Assets; +using NetAF.Rendering.Console.FrameBuilders; +using NetAF.Rendering.Console; -namespace NetAF.Tests.Rendering.FrameBuilders.Console +namespace NetAF.Tests.Rendering.Console.FrameBuilders { [TestClass] public class ConsoleConversationFrameBuilder_Tests diff --git a/NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleGameOverFrameBuilder_Tests.cs b/NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleGameOverFrameBuilder_Tests.cs similarity index 80% rename from NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleGameOverFrameBuilder_Tests.cs rename to NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleGameOverFrameBuilder_Tests.cs index 139e0841..9c23cb30 100644 --- a/NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleGameOverFrameBuilder_Tests.cs +++ b/NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleGameOverFrameBuilder_Tests.cs @@ -1,9 +1,9 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NetAF.Assets; -using NetAF.Rendering.FrameBuilders; -using NetAF.Rendering.FrameBuilders.Console; +using NetAF.Rendering.Console; +using NetAF.Rendering.Console.FrameBuilders; -namespace NetAF.Tests.Rendering.FrameBuilders.Console +namespace NetAF.Tests.Rendering.Console.FrameBuilders { [TestClass] public class ConsoleGameOverFrameBuilder_Tests diff --git a/NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleHelpFrameBuilder_Tests.cs b/NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleHelpFrameBuilder_Tests.cs similarity index 88% rename from NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleHelpFrameBuilder_Tests.cs rename to NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleHelpFrameBuilder_Tests.cs index 259fc3d3..c528a684 100644 --- a/NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleHelpFrameBuilder_Tests.cs +++ b/NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleHelpFrameBuilder_Tests.cs @@ -1,9 +1,9 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NetAF.Assets; -using NetAF.Rendering.FrameBuilders; -using NetAF.Rendering.FrameBuilders.Console; +using NetAF.Rendering.Console; +using NetAF.Rendering.Console.FrameBuilders; -namespace NetAF.Tests.Rendering.FrameBuilders.Console +namespace NetAF.Tests.Rendering.Console.FrameBuilders { [TestClass] public class ConsoleHelpFrameBuilder_Tests diff --git a/NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleReactionFrameBuilder_Tests.cs b/NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleReactionFrameBuilder_Tests.cs similarity index 88% rename from NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleReactionFrameBuilder_Tests.cs rename to NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleReactionFrameBuilder_Tests.cs index a14b6ec1..b0211d1f 100644 --- a/NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleReactionFrameBuilder_Tests.cs +++ b/NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleReactionFrameBuilder_Tests.cs @@ -1,9 +1,9 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NetAF.Assets; -using NetAF.Rendering.FrameBuilders; -using NetAF.Rendering.FrameBuilders.Console; +using NetAF.Rendering.Console; +using NetAF.Rendering.Console.FrameBuilders; -namespace NetAF.Tests.Rendering.FrameBuilders.Console +namespace NetAF.Tests.Rendering.Console.FrameBuilders { [TestClass] public class ConsoleReactionFrameBuilder_Tests diff --git a/NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleRegionMapBuilder_Tests.cs b/NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleRegionMapBuilder_Tests.cs similarity index 87% rename from NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleRegionMapBuilder_Tests.cs rename to NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleRegionMapBuilder_Tests.cs index 4ff2be15..784c62ca 100644 --- a/NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleRegionMapBuilder_Tests.cs +++ b/NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleRegionMapBuilder_Tests.cs @@ -1,10 +1,10 @@ using NetAF.Assets; using NetAF.Assets.Locations; using Microsoft.VisualStudio.TestTools.UnitTesting; -using NetAF.Rendering.FrameBuilders; -using NetAF.Rendering.FrameBuilders.Console; +using NetAF.Rendering.Console.FrameBuilders; +using NetAF.Rendering.Console; -namespace NetAF.Tests.Rendering.FrameBuilders.Console +namespace NetAF.Tests.Rendering.Console.FrameBuilders { [TestClass] public class ConsoleRegionMapBuilder_Tests diff --git a/NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleRegionMapFrameBuilder_Tests.cs b/NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleRegionMapFrameBuilder_Tests.cs similarity index 94% rename from NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleRegionMapFrameBuilder_Tests.cs rename to NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleRegionMapFrameBuilder_Tests.cs index 59d758fa..540aa338 100644 --- a/NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleRegionMapFrameBuilder_Tests.cs +++ b/NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleRegionMapFrameBuilder_Tests.cs @@ -1,12 +1,12 @@ using NetAF.Assets; using NetAF.Assets.Locations; using Microsoft.VisualStudio.TestTools.UnitTesting; -using NetAF.Rendering.FrameBuilders.Console; -using NetAF.Rendering.FrameBuilders; using NetAF.Logic.Modes; using NetAF.Commands.RegionMap; +using NetAF.Rendering.Console.FrameBuilders; +using NetAF.Rendering.Console; -namespace NetAF.Tests.Rendering.FrameBuilders.Console +namespace NetAF.Tests.Rendering.Console.FrameBuilders { [TestClass] public class ConsoleRegionMapFrameBuilder_Tests diff --git a/NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleRoomMapBuilder_Tests.cs b/NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleRoomMapBuilder_Tests.cs similarity index 97% rename from NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleRoomMapBuilder_Tests.cs rename to NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleRoomMapBuilder_Tests.cs index d8dd74f6..b48d8850 100644 --- a/NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleRoomMapBuilder_Tests.cs +++ b/NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleRoomMapBuilder_Tests.cs @@ -2,11 +2,11 @@ using NetAF.Rendering; using NetAF.Utilities; using Microsoft.VisualStudio.TestTools.UnitTesting; -using NetAF.Rendering.FrameBuilders.Console; -using NetAF.Rendering.FrameBuilders; using NetAF.Assets; +using NetAF.Rendering.Console.FrameBuilders; +using NetAF.Rendering.Console; -namespace NetAF.Tests.Rendering.FrameBuilders.Console +namespace NetAF.Tests.Rendering.Console.FrameBuilders { [TestClass] public class ConsoleRoomMapBuilder_Tests diff --git a/NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleSceneFrameBuilder_Tests.cs b/NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleSceneFrameBuilder_Tests.cs similarity index 98% rename from NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleSceneFrameBuilder_Tests.cs rename to NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleSceneFrameBuilder_Tests.cs index 036ce51e..c4779c16 100644 --- a/NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleSceneFrameBuilder_Tests.cs +++ b/NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleSceneFrameBuilder_Tests.cs @@ -3,12 +3,12 @@ using NetAF.Rendering; using NetAF.Utilities; using Microsoft.VisualStudio.TestTools.UnitTesting; -using NetAF.Rendering.FrameBuilders.Console; -using NetAF.Rendering.FrameBuilders; using NetAF.Commands; using NetAF.Assets; +using NetAF.Rendering.Console.FrameBuilders; +using NetAF.Rendering.Console; -namespace NetAF.Tests.Rendering.FrameBuilders.Console +namespace NetAF.Tests.Rendering.Console.FrameBuilders { [TestClass] public class ConsoleSceneFrameBuilder_Tests diff --git a/NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleTitleFrameBuilder_Tests.cs b/NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleTitleFrameBuilder_Tests.cs similarity index 80% rename from NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleTitleFrameBuilder_Tests.cs rename to NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleTitleFrameBuilder_Tests.cs index eecdebe6..1fcdb46c 100644 --- a/NetAF.Tests/Rendering/FrameBuilders/Console/ConsoleTitleFrameBuilder_Tests.cs +++ b/NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleTitleFrameBuilder_Tests.cs @@ -1,9 +1,9 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NetAF.Assets; -using NetAF.Rendering.FrameBuilders; -using NetAF.Rendering.FrameBuilders.Console; +using NetAF.Rendering.Console; +using NetAF.Rendering.Console.FrameBuilders; -namespace NetAF.Tests.Rendering.FrameBuilders.Console +namespace NetAF.Tests.Rendering.Console.FrameBuilders { [TestClass] public class ConsoleTitleFrameBuilder_Tests diff --git a/NetAF.Tests/Rendering/FrameBuilders/GridPictureBuilder_Tests.cs b/NetAF.Tests/Rendering/Console/GridPictureBuilder_Tests.cs similarity index 94% rename from NetAF.Tests/Rendering/FrameBuilders/GridPictureBuilder_Tests.cs rename to NetAF.Tests/Rendering/Console/GridPictureBuilder_Tests.cs index 294f4e31..2b7e9aff 100644 --- a/NetAF.Tests/Rendering/FrameBuilders/GridPictureBuilder_Tests.cs +++ b/NetAF.Tests/Rendering/Console/GridPictureBuilder_Tests.cs @@ -1,8 +1,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -using NetAF.Rendering.FrameBuilders; -using NetAF.Rendering.FrameBuilders.Console; +using NetAF.Rendering.Console; -namespace NetAF.Tests.Rendering.FrameBuilders +namespace NetAF.Tests.Rendering.Console { [TestClass] public class GridPictureBuilder_Tests diff --git a/NetAF.Tests/Rendering/Frames/GridPictureFrame_Tests.cs b/NetAF.Tests/Rendering/Console/GridPictureFrame_Tests.cs similarity index 85% rename from NetAF.Tests/Rendering/Frames/GridPictureFrame_Tests.cs rename to NetAF.Tests/Rendering/Console/GridPictureFrame_Tests.cs index f7dedf5d..ecc4b40f 100644 --- a/NetAF.Tests/Rendering/Frames/GridPictureFrame_Tests.cs +++ b/NetAF.Tests/Rendering/Console/GridPictureFrame_Tests.cs @@ -1,12 +1,9 @@ using System; using System.IO; using Microsoft.VisualStudio.TestTools.UnitTesting; -using NetAF.Rendering.FrameBuilders; -using NetAF.Rendering.FrameBuilders.Console; -using NetAF.Rendering.Frames; -using NetAF.Rendering.Presenters; +using NetAF.Rendering.Console; -namespace NetAF.Tests.Rendering.Frames +namespace NetAF.Tests.Rendering.Console { [TestClass] public class GridPictureFrame_Tests diff --git a/NetAF.Tests/Rendering/FrameBuilders/GridStringBuilder_Tests.cs b/NetAF.Tests/Rendering/Console/GridStringBuilder_Tests.cs similarity index 96% rename from NetAF.Tests/Rendering/FrameBuilders/GridStringBuilder_Tests.cs rename to NetAF.Tests/Rendering/Console/GridStringBuilder_Tests.cs index 7b25aec8..8fdbfb31 100644 --- a/NetAF.Tests/Rendering/FrameBuilders/GridStringBuilder_Tests.cs +++ b/NetAF.Tests/Rendering/Console/GridStringBuilder_Tests.cs @@ -1,8 +1,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -using NetAF.Rendering.FrameBuilders; -using NetAF.Rendering.FrameBuilders.Console; +using NetAF.Rendering.Console; -namespace NetAF.Tests.Rendering.FrameBuilders +namespace NetAF.Tests.Rendering.Console { [TestClass] public class GridStringBuilder_Tests diff --git a/NetAF.Tests/Rendering/Frames/GridTextFrame_Tests.cs b/NetAF.Tests/Rendering/Console/GridTextFrame_Tests.cs similarity index 88% rename from NetAF.Tests/Rendering/Frames/GridTextFrame_Tests.cs rename to NetAF.Tests/Rendering/Console/GridTextFrame_Tests.cs index a016dd99..f79a0712 100644 --- a/NetAF.Tests/Rendering/Frames/GridTextFrame_Tests.cs +++ b/NetAF.Tests/Rendering/Console/GridTextFrame_Tests.cs @@ -2,12 +2,9 @@ using System.IO; using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; -using NetAF.Rendering.FrameBuilders; -using NetAF.Rendering.FrameBuilders.Console; -using NetAF.Rendering.Frames; -using NetAF.Rendering.Presenters; +using NetAF.Rendering.Console; -namespace NetAF.Tests.Rendering.Frames +namespace NetAF.Tests.Rendering.Console { [TestClass] public class GridTextFrame_Tests diff --git a/NetAF.Tests/Rendering/Presenters/TextWriterPresenter_Tests.cs b/NetAF.Tests/Rendering/Console/TextWriterPresenter_Tests.cs similarity index 91% rename from NetAF.Tests/Rendering/Presenters/TextWriterPresenter_Tests.cs rename to NetAF.Tests/Rendering/Console/TextWriterPresenter_Tests.cs index 982dc0ca..f7f688a3 100644 --- a/NetAF.Tests/Rendering/Presenters/TextWriterPresenter_Tests.cs +++ b/NetAF.Tests/Rendering/Console/TextWriterPresenter_Tests.cs @@ -1,9 +1,9 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -using NetAF.Rendering.Presenters; +using NetAF.Rendering.Console; using System.IO; using System.Linq; -namespace NetAF.Tests.Rendering.Presenters +namespace NetAF.Tests.Rendering.Console { [TestClass] public class TextWriterPresenter_Tests diff --git a/NetAF.Tests/TestConsoleAdapter.cs b/NetAF.Tests/TestConsoleAdapter.cs index e67ed437..fe440afa 100644 --- a/NetAF.Tests/TestConsoleAdapter.cs +++ b/NetAF.Tests/TestConsoleAdapter.cs @@ -1,7 +1,7 @@ using System.IO; using NetAF.Adapters; using NetAF.Logic; -using NetAF.Rendering.Frames; +using NetAF.Rendering; namespace NetAF.Tests { diff --git a/NetAF/Adapters/IIOAdapter.cs b/NetAF/Adapters/IIOAdapter.cs index 72c0b215..0433e16e 100644 --- a/NetAF/Adapters/IIOAdapter.cs +++ b/NetAF/Adapters/IIOAdapter.cs @@ -1,5 +1,5 @@ using NetAF.Logic; -using NetAF.Rendering.Frames; +using NetAF.Rendering; namespace NetAF.Adapters { diff --git a/NetAF/Adapters/SystemConsoleAdapter.cs b/NetAF/Adapters/SystemConsoleAdapter.cs index 5151c692..9471c93d 100644 --- a/NetAF/Adapters/SystemConsoleAdapter.cs +++ b/NetAF/Adapters/SystemConsoleAdapter.cs @@ -1,7 +1,7 @@ using NetAF.Assets; using NetAF.Logic; -using NetAF.Rendering.Frames; -using NetAF.Rendering.Presenters; +using NetAF.Rendering; +using NetAF.Rendering.Console; using NetAF.Utilities; namespace NetAF.Adapters diff --git a/NetAF/Logic/Modes/DirectRenderMode.cs b/NetAF/Logic/Modes/DirectRenderMode.cs index f087ec75..2ac4ebff 100644 --- a/NetAF/Logic/Modes/DirectRenderMode.cs +++ b/NetAF/Logic/Modes/DirectRenderMode.cs @@ -1,5 +1,5 @@ using NetAF.Interpretation; -using NetAF.Rendering.Frames; +using NetAF.Rendering; namespace NetAF.Logic.Modes { diff --git a/NetAF/Rendering/FrameBuilders/Console/Ansi.cs b/NetAF/Rendering/Console/Ansi.cs similarity index 98% rename from NetAF/Rendering/FrameBuilders/Console/Ansi.cs rename to NetAF/Rendering/Console/Ansi.cs index 5d9a082d..c39234da 100644 --- a/NetAF/Rendering/FrameBuilders/Console/Ansi.cs +++ b/NetAF/Rendering/Console/Ansi.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace NetAF.Rendering.FrameBuilders.Console +namespace NetAF.Rendering.Console { /// /// Provides helper functions for ANSI colors. diff --git a/NetAF/Rendering/FrameBuilders/Console/AnsiColor.cs b/NetAF/Rendering/Console/AnsiColor.cs similarity index 97% rename from NetAF/Rendering/FrameBuilders/Console/AnsiColor.cs rename to NetAF/Rendering/Console/AnsiColor.cs index d84d4c1e..1f5e5b6a 100644 --- a/NetAF/Rendering/FrameBuilders/Console/AnsiColor.cs +++ b/NetAF/Rendering/Console/AnsiColor.cs @@ -1,4 +1,4 @@ -namespace NetAF.Rendering.FrameBuilders.Console +namespace NetAF.Rendering.Console { /// /// Enumeration of ANSI colors. diff --git a/NetAF/Rendering/FrameBuilders/Console/ConsoleAboutFrameBuilder.cs b/NetAF/Rendering/Console/FrameBuilders/ConsoleAboutFrameBuilder.cs similarity index 97% rename from NetAF/Rendering/FrameBuilders/Console/ConsoleAboutFrameBuilder.cs rename to NetAF/Rendering/Console/FrameBuilders/ConsoleAboutFrameBuilder.cs index 0793e71d..df0dcc7a 100644 --- a/NetAF/Rendering/FrameBuilders/Console/ConsoleAboutFrameBuilder.cs +++ b/NetAF/Rendering/Console/FrameBuilders/ConsoleAboutFrameBuilder.cs @@ -1,9 +1,9 @@ using NetAF.Assets; using NetAF.Extensions; using NetAF.Logic; -using NetAF.Rendering.Frames; +using NetAF.Rendering.FrameBuilders; -namespace NetAF.Rendering.FrameBuilders.Console +namespace NetAF.Rendering.Console.FrameBuilders { /// /// Provides a builder of console about frames. diff --git a/NetAF/Rendering/FrameBuilders/Console/ConsoleCommandListFrameBuilder.cs b/NetAF/Rendering/Console/FrameBuilders/ConsoleCommandListFrameBuilder.cs similarity index 97% rename from NetAF/Rendering/FrameBuilders/Console/ConsoleCommandListFrameBuilder.cs rename to NetAF/Rendering/Console/FrameBuilders/ConsoleCommandListFrameBuilder.cs index 087060c0..bbc9f7b0 100644 --- a/NetAF/Rendering/FrameBuilders/Console/ConsoleCommandListFrameBuilder.cs +++ b/NetAF/Rendering/Console/FrameBuilders/ConsoleCommandListFrameBuilder.cs @@ -2,9 +2,9 @@ using NetAF.Assets; using NetAF.Commands; using NetAF.Extensions; -using NetAF.Rendering.Frames; +using NetAF.Rendering.FrameBuilders; -namespace NetAF.Rendering.FrameBuilders.Console +namespace NetAF.Rendering.Console.FrameBuilders { /// /// Provides a builder of command list frames. diff --git a/NetAF/Rendering/FrameBuilders/Console/ConsoleCompletionFrameBuilder.cs b/NetAF/Rendering/Console/FrameBuilders/ConsoleCompletionFrameBuilder.cs similarity index 96% rename from NetAF/Rendering/FrameBuilders/Console/ConsoleCompletionFrameBuilder.cs rename to NetAF/Rendering/Console/FrameBuilders/ConsoleCompletionFrameBuilder.cs index 1147c39c..976fb035 100644 --- a/NetAF/Rendering/FrameBuilders/Console/ConsoleCompletionFrameBuilder.cs +++ b/NetAF/Rendering/Console/FrameBuilders/ConsoleCompletionFrameBuilder.cs @@ -1,8 +1,8 @@ using NetAF.Assets; using NetAF.Extensions; -using NetAF.Rendering.Frames; +using NetAF.Rendering.FrameBuilders; -namespace NetAF.Rendering.FrameBuilders.Console +namespace NetAF.Rendering.Console.FrameBuilders { /// /// Provides a builder of completion frames. diff --git a/NetAF/Rendering/FrameBuilders/Console/ConsoleConversationFrameBuilder.cs b/NetAF/Rendering/Console/FrameBuilders/ConsoleConversationFrameBuilder.cs similarity index 98% rename from NetAF/Rendering/FrameBuilders/Console/ConsoleConversationFrameBuilder.cs rename to NetAF/Rendering/Console/FrameBuilders/ConsoleConversationFrameBuilder.cs index fe928315..a0b27dcd 100644 --- a/NetAF/Rendering/FrameBuilders/Console/ConsoleConversationFrameBuilder.cs +++ b/NetAF/Rendering/Console/FrameBuilders/ConsoleConversationFrameBuilder.cs @@ -5,9 +5,9 @@ using NetAF.Assets.Characters; using NetAF.Commands; using NetAF.Conversations; -using NetAF.Rendering.Frames; +using NetAF.Rendering.FrameBuilders; -namespace NetAF.Rendering.FrameBuilders.Console +namespace NetAF.Rendering.Console.FrameBuilders { /// /// Provides a builder of conversation frames. diff --git a/NetAF/Rendering/FrameBuilders/Console/ConsoleGameOverFrameBuilder.cs b/NetAF/Rendering/Console/FrameBuilders/ConsoleGameOverFrameBuilder.cs similarity index 96% rename from NetAF/Rendering/FrameBuilders/Console/ConsoleGameOverFrameBuilder.cs rename to NetAF/Rendering/Console/FrameBuilders/ConsoleGameOverFrameBuilder.cs index 578d5bcb..0d77cd92 100644 --- a/NetAF/Rendering/FrameBuilders/Console/ConsoleGameOverFrameBuilder.cs +++ b/NetAF/Rendering/Console/FrameBuilders/ConsoleGameOverFrameBuilder.cs @@ -1,8 +1,8 @@ using NetAF.Assets; using NetAF.Extensions; -using NetAF.Rendering.Frames; +using NetAF.Rendering.FrameBuilders; -namespace NetAF.Rendering.FrameBuilders.Console +namespace NetAF.Rendering.Console.FrameBuilders { /// /// Provides a builder of game over frames. diff --git a/NetAF/Rendering/FrameBuilders/Console/ConsoleHelpFrameBuilder.cs b/NetAF/Rendering/Console/FrameBuilders/ConsoleHelpFrameBuilder.cs similarity index 97% rename from NetAF/Rendering/FrameBuilders/Console/ConsoleHelpFrameBuilder.cs rename to NetAF/Rendering/Console/FrameBuilders/ConsoleHelpFrameBuilder.cs index 2905f3ad..78158076 100644 --- a/NetAF/Rendering/FrameBuilders/Console/ConsoleHelpFrameBuilder.cs +++ b/NetAF/Rendering/Console/FrameBuilders/ConsoleHelpFrameBuilder.cs @@ -1,9 +1,9 @@ using NetAF.Assets; using NetAF.Commands; using NetAF.Extensions; -using NetAF.Rendering.Frames; +using NetAF.Rendering.FrameBuilders; -namespace NetAF.Rendering.FrameBuilders.Console +namespace NetAF.Rendering.Console.FrameBuilders { /// /// Provides a builder of help frames. diff --git a/NetAF/Rendering/FrameBuilders/Console/ConsoleReactionFrameBuilder.cs b/NetAF/Rendering/Console/FrameBuilders/ConsoleReactionFrameBuilder.cs similarity index 96% rename from NetAF/Rendering/FrameBuilders/Console/ConsoleReactionFrameBuilder.cs rename to NetAF/Rendering/Console/FrameBuilders/ConsoleReactionFrameBuilder.cs index 4cd9a1b9..34c7e75c 100644 --- a/NetAF/Rendering/FrameBuilders/Console/ConsoleReactionFrameBuilder.cs +++ b/NetAF/Rendering/Console/FrameBuilders/ConsoleReactionFrameBuilder.cs @@ -1,8 +1,8 @@ using NetAF.Assets; using NetAF.Extensions; -using NetAF.Rendering.Frames; +using NetAF.Rendering.FrameBuilders; -namespace NetAF.Rendering.FrameBuilders.Console +namespace NetAF.Rendering.Console.FrameBuilders { /// /// Provides a builder of reaction frames. @@ -74,7 +74,7 @@ public IFrame Build(string title, string message, bool isError, Size size) } gridStringBuilder.DrawWrapped(message.EnsureFinishedSentence(), leftMargin, lastY, availableWidth, isError ? ErrorMessageColor : MessageColor, out _, out _); - + return new GridTextFrame(gridStringBuilder, 0, 0, BackgroundColor) { ShowCursor = false }; } diff --git a/NetAF/Rendering/FrameBuilders/Console/ConsoleRegionMapBuilder.cs b/NetAF/Rendering/Console/FrameBuilders/ConsoleRegionMapBuilder.cs similarity index 99% rename from NetAF/Rendering/FrameBuilders/Console/ConsoleRegionMapBuilder.cs rename to NetAF/Rendering/Console/FrameBuilders/ConsoleRegionMapBuilder.cs index 4f7cdc2e..6969d487 100644 --- a/NetAF/Rendering/FrameBuilders/Console/ConsoleRegionMapBuilder.cs +++ b/NetAF/Rendering/Console/FrameBuilders/ConsoleRegionMapBuilder.cs @@ -3,8 +3,9 @@ using System.Linq; using NetAF.Assets; using NetAF.Assets.Locations; +using NetAF.Rendering.FrameBuilders; -namespace NetAF.Rendering.FrameBuilders.Console +namespace NetAF.Rendering.Console.FrameBuilders { /// /// Provides a builder for region maps. @@ -111,7 +112,7 @@ private void DrawCurrentFloorRoom(Room room, Point2D topLeft, bool isPlayerRoom, * | | * ^Ov| * |---| - */ + */ AnsiColor color = UnvisitedBoundaryColor; diff --git a/NetAF/Rendering/FrameBuilders/Console/ConsoleRegionMapFrameBuilder.cs b/NetAF/Rendering/Console/FrameBuilders/ConsoleRegionMapFrameBuilder.cs similarity index 98% rename from NetAF/Rendering/FrameBuilders/Console/ConsoleRegionMapFrameBuilder.cs rename to NetAF/Rendering/Console/FrameBuilders/ConsoleRegionMapFrameBuilder.cs index c8322e72..7415fef4 100644 --- a/NetAF/Rendering/FrameBuilders/Console/ConsoleRegionMapFrameBuilder.cs +++ b/NetAF/Rendering/Console/FrameBuilders/ConsoleRegionMapFrameBuilder.cs @@ -2,10 +2,10 @@ using NetAF.Assets.Locations; using NetAF.Commands; using NetAF.Extensions; -using NetAF.Rendering.Frames; +using NetAF.Rendering.FrameBuilders; using System.Linq; -namespace NetAF.Rendering.FrameBuilders.Console +namespace NetAF.Rendering.Console.FrameBuilders { /// /// Provides a builder of region map frames. diff --git a/NetAF/Rendering/FrameBuilders/Console/ConsoleRoomMapBuilder.cs b/NetAF/Rendering/Console/FrameBuilders/ConsoleRoomMapBuilder.cs similarity index 99% rename from NetAF/Rendering/FrameBuilders/Console/ConsoleRoomMapBuilder.cs rename to NetAF/Rendering/Console/FrameBuilders/ConsoleRoomMapBuilder.cs index 10370a40..36e7d928 100644 --- a/NetAF/Rendering/FrameBuilders/Console/ConsoleRoomMapBuilder.cs +++ b/NetAF/Rendering/Console/FrameBuilders/ConsoleRoomMapBuilder.cs @@ -3,8 +3,9 @@ using System.Linq; using NetAF.Assets; using NetAF.Assets.Locations; +using NetAF.Rendering.FrameBuilders; -namespace NetAF.Rendering.FrameBuilders.Console +namespace NetAF.Rendering.Console.FrameBuilders { /// /// Provides a room map builder. diff --git a/NetAF/Rendering/FrameBuilders/Console/ConsoleSceneFrameBuilder.cs b/NetAF/Rendering/Console/FrameBuilders/ConsoleSceneFrameBuilder.cs similarity index 98% rename from NetAF/Rendering/FrameBuilders/Console/ConsoleSceneFrameBuilder.cs rename to NetAF/Rendering/Console/FrameBuilders/ConsoleSceneFrameBuilder.cs index 883846fa..96cc5982 100644 --- a/NetAF/Rendering/FrameBuilders/Console/ConsoleSceneFrameBuilder.cs +++ b/NetAF/Rendering/Console/FrameBuilders/ConsoleSceneFrameBuilder.cs @@ -5,10 +5,10 @@ using NetAF.Assets.Locations; using NetAF.Commands; using NetAF.Extensions; -using NetAF.Rendering.Frames; +using NetAF.Rendering.FrameBuilders; using NetAF.Utilities; -namespace NetAF.Rendering.FrameBuilders.Console +namespace NetAF.Rendering.Console.FrameBuilders { /// /// Provides a builder for scene frames. diff --git a/NetAF/Rendering/FrameBuilders/Console/ConsoleTitleFrameBuilder.cs b/NetAF/Rendering/Console/FrameBuilders/ConsoleTitleFrameBuilder.cs similarity index 96% rename from NetAF/Rendering/FrameBuilders/Console/ConsoleTitleFrameBuilder.cs rename to NetAF/Rendering/Console/FrameBuilders/ConsoleTitleFrameBuilder.cs index 3a5fc3a4..599890c1 100644 --- a/NetAF/Rendering/FrameBuilders/Console/ConsoleTitleFrameBuilder.cs +++ b/NetAF/Rendering/Console/FrameBuilders/ConsoleTitleFrameBuilder.cs @@ -1,8 +1,8 @@ using NetAF.Assets; using NetAF.Extensions; -using NetAF.Rendering.Frames; +using NetAF.Rendering.FrameBuilders; -namespace NetAF.Rendering.FrameBuilders.Console +namespace NetAF.Rendering.Console.FrameBuilders { /// /// Provides a builder of title frames. diff --git a/NetAF/Rendering/FrameBuilders/GridPictureBuilder.cs b/NetAF/Rendering/Console/GridPictureBuilder.cs similarity index 98% rename from NetAF/Rendering/FrameBuilders/GridPictureBuilder.cs rename to NetAF/Rendering/Console/GridPictureBuilder.cs index 13624914..fd096fa4 100644 --- a/NetAF/Rendering/FrameBuilders/GridPictureBuilder.cs +++ b/NetAF/Rendering/Console/GridPictureBuilder.cs @@ -1,8 +1,7 @@ using NetAF.Assets; -using NetAF.Rendering.FrameBuilders.Console; using NetAF.Utilities; -namespace NetAF.Rendering.FrameBuilders +namespace NetAF.Rendering.Console { /// /// Provides a class for building pictures in a grid. diff --git a/NetAF/Rendering/Frames/GridPictureFrame.cs b/NetAF/Rendering/Console/GridPictureFrame.cs similarity index 98% rename from NetAF/Rendering/Frames/GridPictureFrame.cs rename to NetAF/Rendering/Console/GridPictureFrame.cs index fc75f95c..820b0ae2 100644 --- a/NetAF/Rendering/Frames/GridPictureFrame.cs +++ b/NetAF/Rendering/Console/GridPictureFrame.cs @@ -1,10 +1,7 @@ using System.Text; -using NetAF.Rendering.FrameBuilders; -using NetAF.Rendering.FrameBuilders.Console; -using NetAF.Rendering.Presenters; using NetAF.Utilities; -namespace NetAF.Rendering.Frames +namespace NetAF.Rendering.Console { /// /// Provides a grid based frame for displaying a picture. diff --git a/NetAF/Rendering/FrameBuilders/GridStringBuilder.cs b/NetAF/Rendering/Console/GridStringBuilder.cs similarity index 98% rename from NetAF/Rendering/FrameBuilders/GridStringBuilder.cs rename to NetAF/Rendering/Console/GridStringBuilder.cs index 8f9d86be..c706b06a 100644 --- a/NetAF/Rendering/FrameBuilders/GridStringBuilder.cs +++ b/NetAF/Rendering/Console/GridStringBuilder.cs @@ -1,8 +1,7 @@ using NetAF.Assets; -using NetAF.Rendering.FrameBuilders.Console; using NetAF.Utilities; -namespace NetAF.Rendering.FrameBuilders +namespace NetAF.Rendering.Console { /// /// Provides a class for building strings as part of a grid. diff --git a/NetAF/Rendering/Frames/GridTextFrame.cs b/NetAF/Rendering/Console/GridTextFrame.cs similarity index 95% rename from NetAF/Rendering/Frames/GridTextFrame.cs rename to NetAF/Rendering/Console/GridTextFrame.cs index 27be567c..a83ea674 100644 --- a/NetAF/Rendering/Frames/GridTextFrame.cs +++ b/NetAF/Rendering/Console/GridTextFrame.cs @@ -1,10 +1,7 @@ using System.Text; -using NetAF.Rendering.FrameBuilders; -using NetAF.Rendering.FrameBuilders.Console; -using NetAF.Rendering.Presenters; using NetAF.Utilities; -namespace NetAF.Rendering.Frames +namespace NetAF.Rendering.Console { /// /// Provides a grid based frame for displaying a command based interface. diff --git a/NetAF/Rendering/Presenters/TextWriterPresenter.cs b/NetAF/Rendering/Console/TextWriterPresenter.cs similarity index 97% rename from NetAF/Rendering/Presenters/TextWriterPresenter.cs rename to NetAF/Rendering/Console/TextWriterPresenter.cs index 1f68331f..91f464fd 100644 --- a/NetAF/Rendering/Presenters/TextWriterPresenter.cs +++ b/NetAF/Rendering/Console/TextWriterPresenter.cs @@ -1,6 +1,6 @@ using System.IO; -namespace NetAF.Rendering.Presenters +namespace NetAF.Rendering.Console { /// /// Represents a presenter for TextWriter. diff --git a/NetAF/Rendering/FrameBuilders/FrameBuilderCollections.cs b/NetAF/Rendering/FrameBuilders/FrameBuilderCollections.cs index acd2a180..d991c8e9 100644 --- a/NetAF/Rendering/FrameBuilders/FrameBuilderCollections.cs +++ b/NetAF/Rendering/FrameBuilders/FrameBuilderCollections.cs @@ -1,4 +1,5 @@ -using NetAF.Rendering.FrameBuilders.Console; +using NetAF.Rendering.Console; +using NetAF.Rendering.Console.FrameBuilders; namespace NetAF.Rendering.FrameBuilders { diff --git a/NetAF/Rendering/FrameBuilders/IAboutFrameBuilder.cs b/NetAF/Rendering/FrameBuilders/IAboutFrameBuilder.cs index 31907c39..11d8237c 100644 --- a/NetAF/Rendering/FrameBuilders/IAboutFrameBuilder.cs +++ b/NetAF/Rendering/FrameBuilders/IAboutFrameBuilder.cs @@ -1,6 +1,5 @@ using NetAF.Assets; using NetAF.Logic; -using NetAF.Rendering.Frames; namespace NetAF.Rendering.FrameBuilders { diff --git a/NetAF/Rendering/FrameBuilders/ICommandListFrameBuilder.cs b/NetAF/Rendering/FrameBuilders/ICommandListFrameBuilder.cs index 2271c515..21ba0b9a 100644 --- a/NetAF/Rendering/FrameBuilders/ICommandListFrameBuilder.cs +++ b/NetAF/Rendering/FrameBuilders/ICommandListFrameBuilder.cs @@ -1,6 +1,5 @@ using NetAF.Assets; using NetAF.Commands; -using NetAF.Rendering.Frames; namespace NetAF.Rendering.FrameBuilders { diff --git a/NetAF/Rendering/FrameBuilders/ICompletionFrameBuilder.cs b/NetAF/Rendering/FrameBuilders/ICompletionFrameBuilder.cs index 1328c18e..e9dce114 100644 --- a/NetAF/Rendering/FrameBuilders/ICompletionFrameBuilder.cs +++ b/NetAF/Rendering/FrameBuilders/ICompletionFrameBuilder.cs @@ -1,5 +1,4 @@ using NetAF.Assets; -using NetAF.Rendering.Frames; namespace NetAF.Rendering.FrameBuilders { diff --git a/NetAF/Rendering/FrameBuilders/IConversationFrameBuilder.cs b/NetAF/Rendering/FrameBuilders/IConversationFrameBuilder.cs index 80d68320..6284a9e1 100644 --- a/NetAF/Rendering/FrameBuilders/IConversationFrameBuilder.cs +++ b/NetAF/Rendering/FrameBuilders/IConversationFrameBuilder.cs @@ -1,7 +1,6 @@ using NetAF.Assets; using NetAF.Assets.Characters; using NetAF.Commands; -using NetAF.Rendering.Frames; namespace NetAF.Rendering.FrameBuilders { diff --git a/NetAF/Rendering/FrameBuilders/IGameOverFrameBuilder.cs b/NetAF/Rendering/FrameBuilders/IGameOverFrameBuilder.cs index a724c399..42392aac 100644 --- a/NetAF/Rendering/FrameBuilders/IGameOverFrameBuilder.cs +++ b/NetAF/Rendering/FrameBuilders/IGameOverFrameBuilder.cs @@ -1,5 +1,4 @@ using NetAF.Assets; -using NetAF.Rendering.Frames; namespace NetAF.Rendering.FrameBuilders { diff --git a/NetAF/Rendering/FrameBuilders/IHelpFrameBuilder.cs b/NetAF/Rendering/FrameBuilders/IHelpFrameBuilder.cs index 8c712cc2..b200e795 100644 --- a/NetAF/Rendering/FrameBuilders/IHelpFrameBuilder.cs +++ b/NetAF/Rendering/FrameBuilders/IHelpFrameBuilder.cs @@ -1,6 +1,5 @@ using NetAF.Assets; using NetAF.Commands; -using NetAF.Rendering.Frames; namespace NetAF.Rendering.FrameBuilders { diff --git a/NetAF/Rendering/FrameBuilders/IReactionFrameBuilder.cs b/NetAF/Rendering/FrameBuilders/IReactionFrameBuilder.cs index a0fb9a56..77e1d327 100644 --- a/NetAF/Rendering/FrameBuilders/IReactionFrameBuilder.cs +++ b/NetAF/Rendering/FrameBuilders/IReactionFrameBuilder.cs @@ -1,5 +1,4 @@ using NetAF.Assets; -using NetAF.Rendering.Frames; namespace NetAF.Rendering.FrameBuilders { diff --git a/NetAF/Rendering/FrameBuilders/IRegionMapFrameBuilder.cs b/NetAF/Rendering/FrameBuilders/IRegionMapFrameBuilder.cs index ffc4482c..8c52d0fe 100644 --- a/NetAF/Rendering/FrameBuilders/IRegionMapFrameBuilder.cs +++ b/NetAF/Rendering/FrameBuilders/IRegionMapFrameBuilder.cs @@ -1,7 +1,6 @@ using NetAF.Assets; using NetAF.Assets.Locations; using NetAF.Commands; -using NetAF.Rendering.Frames; namespace NetAF.Rendering.FrameBuilders { diff --git a/NetAF/Rendering/FrameBuilders/ISceneFrameBuilder.cs b/NetAF/Rendering/FrameBuilders/ISceneFrameBuilder.cs index 7ea7aca2..c51fa337 100644 --- a/NetAF/Rendering/FrameBuilders/ISceneFrameBuilder.cs +++ b/NetAF/Rendering/FrameBuilders/ISceneFrameBuilder.cs @@ -2,7 +2,6 @@ using NetAF.Assets.Characters; using NetAF.Assets.Locations; using NetAF.Commands; -using NetAF.Rendering.Frames; namespace NetAF.Rendering.FrameBuilders { diff --git a/NetAF/Rendering/FrameBuilders/ITitleFrameBuilder.cs b/NetAF/Rendering/FrameBuilders/ITitleFrameBuilder.cs index 8341779e..731fe272 100644 --- a/NetAF/Rendering/FrameBuilders/ITitleFrameBuilder.cs +++ b/NetAF/Rendering/FrameBuilders/ITitleFrameBuilder.cs @@ -1,5 +1,4 @@ using NetAF.Assets; -using NetAF.Rendering.Frames; namespace NetAF.Rendering.FrameBuilders { diff --git a/NetAF/Rendering/Frames/IFrame.cs b/NetAF/Rendering/IFrame.cs similarity index 91% rename from NetAF/Rendering/Frames/IFrame.cs rename to NetAF/Rendering/IFrame.cs index 3318ec12..0c2f2aab 100644 --- a/NetAF/Rendering/Frames/IFrame.cs +++ b/NetAF/Rendering/IFrame.cs @@ -1,6 +1,4 @@ -using NetAF.Rendering.Presenters; - -namespace NetAF.Rendering.Frames +namespace NetAF.Rendering { /// /// Represents any object that is a frame that can display a command based interface. diff --git a/NetAF/Rendering/Presenters/IFramePresenter.cs b/NetAF/Rendering/IFramePresenter.cs similarity index 92% rename from NetAF/Rendering/Presenters/IFramePresenter.cs rename to NetAF/Rendering/IFramePresenter.cs index 564e65b3..47a2ffe4 100644 --- a/NetAF/Rendering/Presenters/IFramePresenter.cs +++ b/NetAF/Rendering/IFramePresenter.cs @@ -1,4 +1,4 @@ -namespace NetAF.Rendering.Presenters +namespace NetAF.Rendering { /// /// Represents an object that can render a frame. From 8ef43cd2820006aa4fb8c4ecef50ede36f1129d6 Mon Sep 17 00:00:00 2001 From: ben_singer Date: Mon, 25 Nov 2024 17:51:22 +0000 Subject: [PATCH 07/15] Added basic example picture --- .../Assets/Regions/Hub/Rooms/Clearing.cs | 65 ++++++++++++++++++- NetAF.Examples/Program.cs | 16 ----- 2 files changed, 64 insertions(+), 17 deletions(-) diff --git a/NetAF.Examples/Assets/Regions/Hub/Rooms/Clearing.cs b/NetAF.Examples/Assets/Regions/Hub/Rooms/Clearing.cs index 8617669e..de1dc1f2 100644 --- a/NetAF.Examples/Assets/Regions/Hub/Rooms/Clearing.cs +++ b/NetAF.Examples/Assets/Regions/Hub/Rooms/Clearing.cs @@ -1,8 +1,11 @@ using NetAF.Assets; using NetAF.Assets.Characters; using NetAF.Assets.Locations; +using NetAF.Commands; using NetAF.Conversations; using NetAF.Conversations.Instructions; +using NetAF.Logic.Modes; +using NetAF.Rendering.Console; using NetAF.Rendering.FrameBuilders; using NetAF.Utilities; @@ -17,6 +20,59 @@ internal class Clearing : IAssetTemplate #endregion + #region StaticMethods + + private static GridPictureFrame GetView(Size size) + { + var gridPictureBuilder = new GridPictureBuilder(AnsiColor.Black, AnsiColor.BrightWhite); + gridPictureBuilder.Resize(size); + gridPictureBuilder.SetCell(40, 14, AnsiColor.Green); + gridPictureBuilder.SetCell(39, 15, AnsiColor.Green); + gridPictureBuilder.SetCell(40, 15, AnsiColor.Green); + gridPictureBuilder.SetCell(41, 15, AnsiColor.Green); + gridPictureBuilder.SetCell(38, 16, AnsiColor.Green); + gridPictureBuilder.SetCell(39, 16, AnsiColor.Green); + gridPictureBuilder.SetCell(40, 16, AnsiColor.Green); + gridPictureBuilder.SetCell(41, 16, AnsiColor.Green); + gridPictureBuilder.SetCell(42, 16, AnsiColor.Green); + gridPictureBuilder.SetCell(37, 17, AnsiColor.Green); + gridPictureBuilder.SetCell(38, 17, AnsiColor.Green); + gridPictureBuilder.SetCell(39, 17, AnsiColor.Green); + gridPictureBuilder.SetCell(40, 17, AnsiColor.Green); + gridPictureBuilder.SetCell(41, 17, AnsiColor.Green); + gridPictureBuilder.SetCell(42, 17, AnsiColor.Green); + gridPictureBuilder.SetCell(43, 17, AnsiColor.Green); + gridPictureBuilder.SetCell(36, 18, AnsiColor.Green); + gridPictureBuilder.SetCell(37, 18, AnsiColor.Green); + gridPictureBuilder.SetCell(38, 18, AnsiColor.Green); + gridPictureBuilder.SetCell(39, 18, AnsiColor.Green); + gridPictureBuilder.SetCell(40, 18, AnsiColor.Green); + gridPictureBuilder.SetCell(41, 18, AnsiColor.Green); + gridPictureBuilder.SetCell(42, 18, AnsiColor.Green); + gridPictureBuilder.SetCell(43, 18, AnsiColor.Green); + gridPictureBuilder.SetCell(44, 18, AnsiColor.Green); + gridPictureBuilder.SetCell(35, 19, AnsiColor.Green); + gridPictureBuilder.SetCell(36, 19, AnsiColor.Green); + gridPictureBuilder.SetCell(37, 19, AnsiColor.Green); + gridPictureBuilder.SetCell(38, 19, AnsiColor.Green); + gridPictureBuilder.SetCell(39, 19, AnsiColor.Green); + gridPictureBuilder.SetCell(40, 19, AnsiColor.Green); + gridPictureBuilder.SetCell(41, 19, AnsiColor.Green); + gridPictureBuilder.SetCell(42, 19, AnsiColor.Green); + gridPictureBuilder.SetCell(43, 19, AnsiColor.Green); + gridPictureBuilder.SetCell(44, 19, AnsiColor.Green); + gridPictureBuilder.SetCell(45, 19, AnsiColor.Green); + gridPictureBuilder.SetCell(40, 20, AnsiColor.Red); + gridPictureBuilder.SetCell(40, 21, AnsiColor.Red); + gridPictureBuilder.SetCell(40, 22, AnsiColor.Red); + gridPictureBuilder.SetCell(40, 23, AnsiColor.Red); + gridPictureBuilder.SetCell(40, 24, AnsiColor.Red); + gridPictureBuilder.SetCell(40, 25, AnsiColor.Red); + return new GridPictureFrame(gridPictureBuilder); + } + + #endregion + #region Implementation of IAssetTemplate /// @@ -25,7 +81,14 @@ internal class Clearing : IAssetTemplate /// The asset. public Room Instantiate() { - var room = new Room(Name, Description); + var room = new Room(Name, Description, commands: + [ + new(new("Look", "Look around."), true, true, (g, a) => + { + g.ChangeMode(new DirectRenderMode(GetView(g.Configuration.DisplaySize))); + return new(ReactionResult.GameModeChanged, string.Empty); + }) + ]); var conversation = new Conversation( new("Squarrrkkk!"), diff --git a/NetAF.Examples/Program.cs b/NetAF.Examples/Program.cs index 11118dcc..fec8f7a2 100644 --- a/NetAF.Examples/Program.cs +++ b/NetAF.Examples/Program.cs @@ -14,8 +14,6 @@ using NetAF.Extensions; using NetAF.Logic; using NetAF.Logic.Configuration; -using NetAF.Logic.Modes; -using NetAF.Rendering.Console; namespace NetAF.Examples { @@ -98,20 +96,6 @@ static Overworld overworldCreator() return new(ReactionResult.Inform, $"Jumped to {x} {y} {z}."); }), - new(new("Picture", "Display a picture."), true, true, (g, a) => - { - var gridPictureBuilder = new GridPictureBuilder(AnsiColor.Black, AnsiColor.BrightWhite); - gridPictureBuilder.Resize(new(10, 10)); - gridPictureBuilder.SetCell(0, 0, 'C', AnsiColor.Cyan, AnsiColor.Magenta); - gridPictureBuilder.SetCell(1, 0, 'D', AnsiColor.Blue, AnsiColor.Red); - gridPictureBuilder.SetCell(2, 0, 'C', AnsiColor.Cyan, AnsiColor.Magenta); - gridPictureBuilder.SetCell(3, 0, 'D', AnsiColor.Blue, AnsiColor.Red); - gridPictureBuilder.SetCell(4, 0, 'C', AnsiColor.Cyan, AnsiColor.Magenta); - gridPictureBuilder.SetCell(5, 0, 'D', AnsiColor.Blue, AnsiColor.Red); - var frame = new GridPictureFrame(gridPictureBuilder); - g.ChangeMode(new DirectRenderMode(frame)); - return new(ReactionResult.GameModeChanged, string.Empty); - }), new Save(), new Load() ]; From d5e7204a1470f707f8e47a792fae4239b6fef954 Mon Sep 17 00:00:00 2001 From: ben_singer Date: Mon, 25 Nov 2024 21:54:37 +0000 Subject: [PATCH 08/15] Many tweaks to get frames working --- .../Regions/Hub/Drawings/ClearingDrawing.cs | 58 +++++++++ .../Assets/Regions/Hub/Rooms/Clearing.cs | 58 +-------- NetAF/Assets/ExaminableObject.cs | 4 +- NetAF/Assets/Examination.cs | 18 +++ NetAF/Assets/ExaminationCallback.cs | 6 +- NetAF/Assets/ExaminationResult.cs | 18 --- NetAF/Assets/IExaminable.cs | 4 +- NetAF/Assets/Interaction.cs | 13 +- NetAF/Assets/Locations/Overworld.cs | 4 +- NetAF/Assets/Locations/Region.cs | 4 +- NetAF/Assets/Locations/Room.cs | 4 +- NetAF/Assets/Result.cs | 29 ----- .../FrameBuilders/ConsoleAboutFrameBuilder.cs | 2 +- .../ConsoleCommandListFrameBuilder.cs | 2 +- .../ConsoleCompletionFrameBuilder.cs | 2 +- .../ConsoleConversationFrameBuilder.cs | 2 +- .../ConsoleGameOverFrameBuilder.cs | 2 +- .../FrameBuilders/ConsoleHelpFrameBuilder.cs | 2 +- .../ConsoleReactionFrameBuilder.cs | 2 +- .../ConsoleRegionMapFrameBuilder.cs | 2 +- .../FrameBuilders/ConsoleSceneFrameBuilder.cs | 2 +- .../FrameBuilders/ConsoleTitleFrameBuilder.cs | 2 +- NetAF/Rendering/Console/GridPictureBuilder.cs | 117 +++++++++++++++++- NetAF/Rendering/Console/GridPictureFrame.cs | 30 +---- 24 files changed, 223 insertions(+), 164 deletions(-) create mode 100644 NetAF.Examples/Assets/Regions/Hub/Drawings/ClearingDrawing.cs create mode 100644 NetAF/Assets/Examination.cs delete mode 100644 NetAF/Assets/ExaminationResult.cs delete mode 100644 NetAF/Assets/Result.cs diff --git a/NetAF.Examples/Assets/Regions/Hub/Drawings/ClearingDrawing.cs b/NetAF.Examples/Assets/Regions/Hub/Drawings/ClearingDrawing.cs new file mode 100644 index 00000000..ceb9bc73 --- /dev/null +++ b/NetAF.Examples/Assets/Regions/Hub/Drawings/ClearingDrawing.cs @@ -0,0 +1,58 @@ +using NetAF.Assets; +using NetAF.Rendering.Console; +using NetAF.Utilities; + +namespace NetAF.Examples.Assets.Regions.Hub.Drawings +{ + internal class ClearingDrawing(Size size) : IAssetTemplate + { + private static void DrawSun(GridPictureBuilder builder) + { + builder.SetCell(8, 5, AnsiColor.BrightYellow); + builder.SetCell(4, 7, AnsiColor.BrightYellow); + builder.SetCell(5, 7, AnsiColor.BrightYellow); + builder.SetCell(11, 7, AnsiColor.BrightYellow); + builder.SetCell(12, 7, AnsiColor.BrightYellow); + builder.SetCell(8, 9, AnsiColor.BrightYellow); + builder.DrawRectangle(6, 6, 5, 3, AnsiColor.BrightYellow, AnsiColor.BrightYellow); + builder.DrawTexture(6, 6, 5, 3, ':', AnsiColor.Yellow); + } + + private static void DrawGrass(GridPictureBuilder builder) + { + builder.DrawRectangle(0, 25, 80, 25, AnsiColor.BrightGreen, AnsiColor.BrightGreen); + builder.DrawTexture(0, 25, 80, 25, '#', AnsiColor.Green); + } + + private static void DrawTree(GridPictureBuilder builder, int x, int y) + { + builder.SetCell(x + 5, y, AnsiColor.Green); + builder.DrawRectangle(x + 4, y + 1, 3, 1, AnsiColor.Green, AnsiColor.Green); + builder.DrawRectangle(x + 3, y + 2, 5, 1, AnsiColor.Green, AnsiColor.Green); + builder.DrawRectangle(x + 2, y + 3, 7, 1, AnsiColor.Green, AnsiColor.Green); + builder.DrawRectangle(x + 1, y + 4, 9, 1, AnsiColor.Green, AnsiColor.Green); + builder.DrawRectangle(x, y + 5, 11, 1, AnsiColor.Green, AnsiColor.Green); + builder.DrawRectangle(x + 5, y + 5, 1, 6, AnsiColor.Red, AnsiColor.Red); + } + + public GridPictureFrame Instantiate() + { + var builder = new GridPictureBuilder(AnsiColor.Blue, AnsiColor.BrightWhite); + builder.Resize(size); + DrawSun(builder); + DrawGrass(builder); + DrawTree(builder, 5, 15); + DrawTree(builder, 20, 15); + DrawTree(builder, 35, 15); + DrawTree(builder, 50, 15); + DrawTree(builder, 65, 15); + DrawTree(builder, 2, 16); + DrawTree(builder, 12, 18); + DrawTree(builder, 28, 17); + DrawTree(builder, 39, 16); + DrawTree(builder, 56, 18); + DrawTree(builder, 70, 17); + return new GridPictureFrame(builder); + } + } +} diff --git a/NetAF.Examples/Assets/Regions/Hub/Rooms/Clearing.cs b/NetAF.Examples/Assets/Regions/Hub/Rooms/Clearing.cs index de1dc1f2..259b32b6 100644 --- a/NetAF.Examples/Assets/Regions/Hub/Rooms/Clearing.cs +++ b/NetAF.Examples/Assets/Regions/Hub/Rooms/Clearing.cs @@ -4,8 +4,8 @@ using NetAF.Commands; using NetAF.Conversations; using NetAF.Conversations.Instructions; +using NetAF.Examples.Assets.Regions.Hub.Drawings; using NetAF.Logic.Modes; -using NetAF.Rendering.Console; using NetAF.Rendering.FrameBuilders; using NetAF.Utilities; @@ -20,59 +20,6 @@ internal class Clearing : IAssetTemplate #endregion - #region StaticMethods - - private static GridPictureFrame GetView(Size size) - { - var gridPictureBuilder = new GridPictureBuilder(AnsiColor.Black, AnsiColor.BrightWhite); - gridPictureBuilder.Resize(size); - gridPictureBuilder.SetCell(40, 14, AnsiColor.Green); - gridPictureBuilder.SetCell(39, 15, AnsiColor.Green); - gridPictureBuilder.SetCell(40, 15, AnsiColor.Green); - gridPictureBuilder.SetCell(41, 15, AnsiColor.Green); - gridPictureBuilder.SetCell(38, 16, AnsiColor.Green); - gridPictureBuilder.SetCell(39, 16, AnsiColor.Green); - gridPictureBuilder.SetCell(40, 16, AnsiColor.Green); - gridPictureBuilder.SetCell(41, 16, AnsiColor.Green); - gridPictureBuilder.SetCell(42, 16, AnsiColor.Green); - gridPictureBuilder.SetCell(37, 17, AnsiColor.Green); - gridPictureBuilder.SetCell(38, 17, AnsiColor.Green); - gridPictureBuilder.SetCell(39, 17, AnsiColor.Green); - gridPictureBuilder.SetCell(40, 17, AnsiColor.Green); - gridPictureBuilder.SetCell(41, 17, AnsiColor.Green); - gridPictureBuilder.SetCell(42, 17, AnsiColor.Green); - gridPictureBuilder.SetCell(43, 17, AnsiColor.Green); - gridPictureBuilder.SetCell(36, 18, AnsiColor.Green); - gridPictureBuilder.SetCell(37, 18, AnsiColor.Green); - gridPictureBuilder.SetCell(38, 18, AnsiColor.Green); - gridPictureBuilder.SetCell(39, 18, AnsiColor.Green); - gridPictureBuilder.SetCell(40, 18, AnsiColor.Green); - gridPictureBuilder.SetCell(41, 18, AnsiColor.Green); - gridPictureBuilder.SetCell(42, 18, AnsiColor.Green); - gridPictureBuilder.SetCell(43, 18, AnsiColor.Green); - gridPictureBuilder.SetCell(44, 18, AnsiColor.Green); - gridPictureBuilder.SetCell(35, 19, AnsiColor.Green); - gridPictureBuilder.SetCell(36, 19, AnsiColor.Green); - gridPictureBuilder.SetCell(37, 19, AnsiColor.Green); - gridPictureBuilder.SetCell(38, 19, AnsiColor.Green); - gridPictureBuilder.SetCell(39, 19, AnsiColor.Green); - gridPictureBuilder.SetCell(40, 19, AnsiColor.Green); - gridPictureBuilder.SetCell(41, 19, AnsiColor.Green); - gridPictureBuilder.SetCell(42, 19, AnsiColor.Green); - gridPictureBuilder.SetCell(43, 19, AnsiColor.Green); - gridPictureBuilder.SetCell(44, 19, AnsiColor.Green); - gridPictureBuilder.SetCell(45, 19, AnsiColor.Green); - gridPictureBuilder.SetCell(40, 20, AnsiColor.Red); - gridPictureBuilder.SetCell(40, 21, AnsiColor.Red); - gridPictureBuilder.SetCell(40, 22, AnsiColor.Red); - gridPictureBuilder.SetCell(40, 23, AnsiColor.Red); - gridPictureBuilder.SetCell(40, 24, AnsiColor.Red); - gridPictureBuilder.SetCell(40, 25, AnsiColor.Red); - return new GridPictureFrame(gridPictureBuilder); - } - - #endregion - #region Implementation of IAssetTemplate /// @@ -85,7 +32,8 @@ public Room Instantiate() [ new(new("Look", "Look around."), true, true, (g, a) => { - g.ChangeMode(new DirectRenderMode(GetView(g.Configuration.DisplaySize))); + var frame = new ClearingDrawing(g.Configuration.DisplaySize).Instantiate(); + g.ChangeMode(new DirectRenderMode(frame)); return new(ReactionResult.GameModeChanged, string.Empty); }) ]); diff --git a/NetAF/Assets/ExaminableObject.cs b/NetAF/Assets/ExaminableObject.cs index 5e8cd3e4..01e42a6e 100644 --- a/NetAF/Assets/ExaminableObject.cs +++ b/NetAF/Assets/ExaminableObject.cs @@ -86,8 +86,8 @@ public class ExaminableObject : IExaminable /// Examine this object. /// /// The scene this object is being examined from. - /// A ExaminationResult detailing the examination of this object. - public virtual ExaminationResult Examine(ExaminationScene scene) + /// The examination. + public virtual Examination Examine(ExaminationScene scene) { return Examination(new(this, scene)); } diff --git a/NetAF/Assets/Examination.cs b/NetAF/Assets/Examination.cs new file mode 100644 index 00000000..ded7ca1b --- /dev/null +++ b/NetAF/Assets/Examination.cs @@ -0,0 +1,18 @@ +namespace NetAF.Assets +{ + /// + /// Represents an examination. + /// + /// A description of the examination. + public sealed class Examination(string description) + { + #region Properties + + /// + /// Get the description of the examination. + /// + public string Description { get; } = description; + + #endregion + } +} \ No newline at end of file diff --git a/NetAF/Assets/ExaminationCallback.cs b/NetAF/Assets/ExaminationCallback.cs index b23a18d1..46bb71db 100644 --- a/NetAF/Assets/ExaminationCallback.cs +++ b/NetAF/Assets/ExaminationCallback.cs @@ -4,6 +4,6 @@ /// Represents the callback for examinations. /// /// The examination request. - /// A string representing the result of the examination. - public delegate ExaminationResult ExaminationCallback(ExaminationRequest request); -} + /// The examination. + public delegate Examination ExaminationCallback(ExaminationRequest request); +} \ No newline at end of file diff --git a/NetAF/Assets/ExaminationResult.cs b/NetAF/Assets/ExaminationResult.cs deleted file mode 100644 index 03d6a074..00000000 --- a/NetAF/Assets/ExaminationResult.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace NetAF.Assets -{ - /// - /// Represents the result of an examination. - /// - public class ExaminationResult : Result - { - #region Constructors - - /// - /// Initializes a new instance of the ExaminationResult class. - /// - /// A description of the result. - public ExaminationResult(string description) => Description = description; - - #endregion - } -} \ No newline at end of file diff --git a/NetAF/Assets/IExaminable.cs b/NetAF/Assets/IExaminable.cs index a3ab6713..6221b935 100644 --- a/NetAF/Assets/IExaminable.cs +++ b/NetAF/Assets/IExaminable.cs @@ -30,7 +30,7 @@ public interface IExaminable : IPlayerVisible, IRestoreFromObjectSerialization /// The scene this object is being examined from. - /// A ExaminationResult detailing the examination of this object. - ExaminationResult Examine(ExaminationScene scene); + /// The examination. + Examination Examine(ExaminationScene scene); } } \ No newline at end of file diff --git a/NetAF/Assets/Interaction.cs b/NetAF/Assets/Interaction.cs index 79374db0..d6ae1f0a 100644 --- a/NetAF/Assets/Interaction.cs +++ b/NetAF/Assets/Interaction.cs @@ -5,7 +5,7 @@ namespace NetAF.Assets /// /// Represents an interaction. /// - public sealed class Interaction : Result + public sealed class Interaction { #region Properties @@ -19,6 +19,11 @@ public sealed class Interaction : Result /// public Item Item { get; } + /// + /// Get the description of the interaction. + /// + public string Description { get; } + #endregion #region Constructors @@ -49,12 +54,12 @@ public Interaction(InteractionResult result, Item item) /// /// The result of the interaction. /// The item used in the interaction. - /// A description of the effect. - public Interaction(InteractionResult result, Item item, string descriptionOfEffect) + /// A description of the interaction. + public Interaction(InteractionResult result, Item item, string description) { Result = result; Item = item; - Description = descriptionOfEffect; + Description = description; } #endregion diff --git a/NetAF/Assets/Locations/Overworld.cs b/NetAF/Assets/Locations/Overworld.cs index f8b05d01..56efe9c6 100644 --- a/NetAF/Assets/Locations/Overworld.cs +++ b/NetAF/Assets/Locations/Overworld.cs @@ -130,8 +130,8 @@ public bool Move(Region region) /// Examine this object. /// /// The scene this object is being examined from. - /// A ExaminationResult detailing the examination of this object. - public override ExaminationResult Examine(ExaminationScene scene) + /// The examination. + public override Examination Examine(ExaminationScene scene) { return new(Description.GetDescription()); } diff --git a/NetAF/Assets/Locations/Region.cs b/NetAF/Assets/Locations/Region.cs index 3684e807..be6780fd 100644 --- a/NetAF/Assets/Locations/Region.cs +++ b/NetAF/Assets/Locations/Region.cs @@ -340,8 +340,8 @@ internal static void NextPosition(Point3D current, Direction direction, out Poin /// Examine this object. /// /// The scene this object is being examined from. - /// A ExaminationResult detailing the examination of this object. - public override ExaminationResult Examine(ExaminationScene scene) + /// The examination. + public override Examination Examine(ExaminationScene scene) { return new(Identifier + ": " + Description.GetDescription()); } diff --git a/NetAF/Assets/Locations/Room.cs b/NetAF/Assets/Locations/Room.cs index aecf44df..4bb89167 100644 --- a/NetAF/Assets/Locations/Room.cs +++ b/NetAF/Assets/Locations/Room.cs @@ -208,8 +208,8 @@ private Interaction InteractWithItem(Item item) /// Handle examination this Room. /// /// The scene this object is being examined from. - /// The result of this examination. - public override ExaminationResult Examine(ExaminationScene scene) + /// The examination. + public override Examination Examine(ExaminationScene scene) { if (!Array.Exists(Items, i => i.IsPlayerVisible)) return new("There is nothing to examine."); diff --git a/NetAF/Assets/Result.cs b/NetAF/Assets/Result.cs deleted file mode 100644 index de5a1d3e..00000000 --- a/NetAF/Assets/Result.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace NetAF.Assets -{ - /// - /// Represents a result. - /// - public abstract class Result - { - #region Properties - - /// - /// Get the description. - /// - public string Description { get; protected set; } - - #endregion - - #region Methods - - /// - /// Initializes a new instance of the Result class. - /// - protected Result() - { - Description = "There was no effect."; - } - - #endregion - } -} \ No newline at end of file diff --git a/NetAF/Rendering/Console/FrameBuilders/ConsoleAboutFrameBuilder.cs b/NetAF/Rendering/Console/FrameBuilders/ConsoleAboutFrameBuilder.cs index df0dcc7a..c64a7e6a 100644 --- a/NetAF/Rendering/Console/FrameBuilders/ConsoleAboutFrameBuilder.cs +++ b/NetAF/Rendering/Console/FrameBuilders/ConsoleAboutFrameBuilder.cs @@ -22,7 +22,7 @@ public sealed class ConsoleAboutFrameBuilder(GridStringBuilder gridStringBuilder /// /// Get or set the background color. /// - public AnsiColor BackgroundColor { get; set; } + public AnsiColor BackgroundColor { get; set; } = AnsiColor.Black; /// /// Get or set the border color. diff --git a/NetAF/Rendering/Console/FrameBuilders/ConsoleCommandListFrameBuilder.cs b/NetAF/Rendering/Console/FrameBuilders/ConsoleCommandListFrameBuilder.cs index bbc9f7b0..4bdccf04 100644 --- a/NetAF/Rendering/Console/FrameBuilders/ConsoleCommandListFrameBuilder.cs +++ b/NetAF/Rendering/Console/FrameBuilders/ConsoleCommandListFrameBuilder.cs @@ -17,7 +17,7 @@ public sealed class ConsoleCommandListFrameBuilder(GridStringBuilder gridStringB /// /// Get or set the background color. /// - public AnsiColor BackgroundColor { get; set; } + public AnsiColor BackgroundColor { get; set; } = AnsiColor.Black; /// /// Get or set the border color. diff --git a/NetAF/Rendering/Console/FrameBuilders/ConsoleCompletionFrameBuilder.cs b/NetAF/Rendering/Console/FrameBuilders/ConsoleCompletionFrameBuilder.cs index 976fb035..e983b80f 100644 --- a/NetAF/Rendering/Console/FrameBuilders/ConsoleCompletionFrameBuilder.cs +++ b/NetAF/Rendering/Console/FrameBuilders/ConsoleCompletionFrameBuilder.cs @@ -21,7 +21,7 @@ public sealed class ConsoleCompletionFrameBuilder(GridStringBuilder gridStringBu /// /// Get or set the background color. /// - public AnsiColor BackgroundColor { get; set; } + public AnsiColor BackgroundColor { get; set; } = AnsiColor.Black; /// /// Get or set the border color. diff --git a/NetAF/Rendering/Console/FrameBuilders/ConsoleConversationFrameBuilder.cs b/NetAF/Rendering/Console/FrameBuilders/ConsoleConversationFrameBuilder.cs index a0b27dcd..c5edfe00 100644 --- a/NetAF/Rendering/Console/FrameBuilders/ConsoleConversationFrameBuilder.cs +++ b/NetAF/Rendering/Console/FrameBuilders/ConsoleConversationFrameBuilder.cs @@ -26,7 +26,7 @@ public sealed class ConsoleConversationFrameBuilder(GridStringBuilder gridString /// /// Get or set the background color. /// - public AnsiColor BackgroundColor { get; set; } + public AnsiColor BackgroundColor { get; set; } = AnsiColor.Black; /// /// Get or set the border color. diff --git a/NetAF/Rendering/Console/FrameBuilders/ConsoleGameOverFrameBuilder.cs b/NetAF/Rendering/Console/FrameBuilders/ConsoleGameOverFrameBuilder.cs index 0d77cd92..038e09c9 100644 --- a/NetAF/Rendering/Console/FrameBuilders/ConsoleGameOverFrameBuilder.cs +++ b/NetAF/Rendering/Console/FrameBuilders/ConsoleGameOverFrameBuilder.cs @@ -21,7 +21,7 @@ public sealed class ConsoleGameOverFrameBuilder(GridStringBuilder gridStringBuil /// /// Get or set the background color. /// - public AnsiColor BackgroundColor { get; set; } + public AnsiColor BackgroundColor { get; set; } = AnsiColor.Black; /// /// Get or set the border color. diff --git a/NetAF/Rendering/Console/FrameBuilders/ConsoleHelpFrameBuilder.cs b/NetAF/Rendering/Console/FrameBuilders/ConsoleHelpFrameBuilder.cs index 78158076..3592f2a5 100644 --- a/NetAF/Rendering/Console/FrameBuilders/ConsoleHelpFrameBuilder.cs +++ b/NetAF/Rendering/Console/FrameBuilders/ConsoleHelpFrameBuilder.cs @@ -16,7 +16,7 @@ public sealed class ConsoleHelpFrameBuilder(GridStringBuilder gridStringBuilder) /// /// Get or set the background color. /// - public AnsiColor BackgroundColor { get; set; } + public AnsiColor BackgroundColor { get; set; } = AnsiColor.Black; /// /// Get or set the border color. diff --git a/NetAF/Rendering/Console/FrameBuilders/ConsoleReactionFrameBuilder.cs b/NetAF/Rendering/Console/FrameBuilders/ConsoleReactionFrameBuilder.cs index 34c7e75c..5b3d8005 100644 --- a/NetAF/Rendering/Console/FrameBuilders/ConsoleReactionFrameBuilder.cs +++ b/NetAF/Rendering/Console/FrameBuilders/ConsoleReactionFrameBuilder.cs @@ -21,7 +21,7 @@ public sealed class ConsoleReactionFrameBuilder(GridStringBuilder gridStringBuil /// /// Get or set the background color. /// - public AnsiColor BackgroundColor { get; set; } + public AnsiColor BackgroundColor { get; set; } = AnsiColor.Black; /// /// Get or set the border color. diff --git a/NetAF/Rendering/Console/FrameBuilders/ConsoleRegionMapFrameBuilder.cs b/NetAF/Rendering/Console/FrameBuilders/ConsoleRegionMapFrameBuilder.cs index 7415fef4..e67d4463 100644 --- a/NetAF/Rendering/Console/FrameBuilders/ConsoleRegionMapFrameBuilder.cs +++ b/NetAF/Rendering/Console/FrameBuilders/ConsoleRegionMapFrameBuilder.cs @@ -30,7 +30,7 @@ public sealed class ConsoleRegionMapFrameBuilder(GridStringBuilder gridStringBui /// /// Get or set the background color. /// - public AnsiColor BackgroundColor { get; set; } + public AnsiColor BackgroundColor { get; set; } = AnsiColor.Black; /// /// Get or set the border color. diff --git a/NetAF/Rendering/Console/FrameBuilders/ConsoleSceneFrameBuilder.cs b/NetAF/Rendering/Console/FrameBuilders/ConsoleSceneFrameBuilder.cs index 96cc5982..da9fea71 100644 --- a/NetAF/Rendering/Console/FrameBuilders/ConsoleSceneFrameBuilder.cs +++ b/NetAF/Rendering/Console/FrameBuilders/ConsoleSceneFrameBuilder.cs @@ -29,7 +29,7 @@ public sealed class ConsoleSceneFrameBuilder(GridStringBuilder gridStringBuilder /// /// Get or set the background color. /// - public AnsiColor BackgroundColor { get; set; } + public AnsiColor BackgroundColor { get; set; } = AnsiColor.Black; /// /// Get or set the border color. diff --git a/NetAF/Rendering/Console/FrameBuilders/ConsoleTitleFrameBuilder.cs b/NetAF/Rendering/Console/FrameBuilders/ConsoleTitleFrameBuilder.cs index 599890c1..7e776cfc 100644 --- a/NetAF/Rendering/Console/FrameBuilders/ConsoleTitleFrameBuilder.cs +++ b/NetAF/Rendering/Console/FrameBuilders/ConsoleTitleFrameBuilder.cs @@ -21,7 +21,7 @@ public sealed class ConsoleTitleFrameBuilder(GridStringBuilder gridStringBuilder /// /// Get or set the background color. /// - public AnsiColor BackgroundColor { get; set; } + public AnsiColor BackgroundColor { get; set; } = AnsiColor.Black; /// /// Get or set the border color. diff --git a/NetAF/Rendering/Console/GridPictureBuilder.cs b/NetAF/Rendering/Console/GridPictureBuilder.cs index fd096fa4..0bfe1e62 100644 --- a/NetAF/Rendering/Console/GridPictureBuilder.cs +++ b/NetAF/Rendering/Console/GridPictureBuilder.cs @@ -87,6 +87,53 @@ public void Flush() foregroundColors = new AnsiColor?[DisplaySize.Width, DisplaySize.Height]; } + /// + /// Safe set a cell background. + /// + /// The x position of the cell. + /// The y position of the cell. + /// The background color of the cell. + private void SafeSetCellBackground(int x, int y, AnsiColor backgroundColor) + { + if (IsCellSafe(x, y)) + backgroundColors[x, y] = backgroundColor; + } + + /// + /// Safe set a cell foreground. + /// + /// The x position of the cell. + /// The y position of the cell. + /// The foreground color of the cell. + private void SafeSetCellForeground(int x, int y, AnsiColor foregroundColor) + { + if (IsCellSafe(x, y)) + foregroundColors[x, y] = foregroundColor; + } + + /// + /// Safe set a cell character. + /// + /// The x position of the cell. + /// The y position of the cell. + /// The character. + private void SafeSetCellCharacter(int x, int y, char character) + { + if (IsCellSafe(x, y)) + buffer[x, y] = character; + } + + /// + /// Determine if a cell is safe. + /// + /// The x position of the cell. + /// The y position of the cell. + /// True if the cell if safe, else false. + private bool IsCellSafe(int x, int y) + { + return x >= 0 && x < DisplaySize.Width && y >= 0 && y < DisplaySize.Height; + } + /// /// Set a cell. /// @@ -95,7 +142,7 @@ public void Flush() /// The backgroundColor color of the cell. public void SetCell(int x, int y, AnsiColor backgroundColor) { - backgroundColors[x, y] = backgroundColor; + SafeSetCellBackground(x, y, backgroundColor); } /// @@ -107,8 +154,8 @@ public void SetCell(int x, int y, AnsiColor backgroundColor) /// The foreground color of the cell. public void SetCell(int x, int y, char character, AnsiColor foregroundColor) { - buffer[x, y] = character; - foregroundColors[x, y] = foregroundColor; + SafeSetCellCharacter(x, y, character); + SafeSetCellForeground(x, y, foregroundColor); } /// @@ -121,9 +168,67 @@ public void SetCell(int x, int y, char character, AnsiColor foregroundColor) /// The backgroundColor color of the cell. public void SetCell(int x, int y, char character, AnsiColor foregroundColor, AnsiColor backgroundColor) { - buffer[x, y] = character; - foregroundColors[x, y] = foregroundColor; - backgroundColors[x, y] = backgroundColor; + SafeSetCellCharacter(x, y, character); + SafeSetCellForeground(x, y, foregroundColor); + SafeSetCellBackground(x, y, backgroundColor); + } + + /// + /// Draw a rectangle. + /// + /// The left position of the rectangle. + /// The top position of the rectangle. + /// The width of the rectangle. + /// The height of the rectangle. + /// The border color of the cell. + /// The fill color of the cell. + public void DrawRectangle(int left, int top, int width, int height, AnsiColor borderColor, AnsiColor fillColor) + { + for (var x = left; x < left + width; x++) + { + SafeSetCellBackground(x, top, borderColor); + SafeSetCellBackground(x, top + height - 1, borderColor); + SafeSetCellCharacter(x, top, ' '); + SafeSetCellCharacter(x, top + height - 1, ' '); + } + + for (var y = top; y < top + height; y++) + { + SafeSetCellBackground(left, y, borderColor); + SafeSetCellBackground(left + width - 1, y, borderColor); + SafeSetCellCharacter(left, y, ' '); + SafeSetCellCharacter(left + width - 1, y, ' '); + } + + for (var y = top + 1; y < top + height - 1; y++) + { + for (var x = left + 1; x < left + width - 1; x++) + { + SafeSetCellBackground(x, y, fillColor); + SafeSetCellCharacter(x, y, ' '); + } + } + } + + /// + /// Draw a rectangle. + /// + /// The left position of the rectangle. + /// The top position of the rectangle. + /// The width of the rectangle. + /// The height of the rectangle. + /// The character to use for the texture. + /// The foregroundColor color of the texture. + public void DrawTexture(int left, int top, int width, int height, char character, AnsiColor foregroundColor) + { + for (var y = top; y < top + height; y++) + { + for (var x = left; x < left + width; x++) + { + SafeSetCellForeground(x, y, foregroundColor); + SafeSetCellCharacter(x, y, character); + } + } } #endregion diff --git a/NetAF/Rendering/Console/GridPictureFrame.cs b/NetAF/Rendering/Console/GridPictureFrame.cs index 820b0ae2..f10cdb9c 100644 --- a/NetAF/Rendering/Console/GridPictureFrame.cs +++ b/NetAF/Rendering/Console/GridPictureFrame.cs @@ -1,7 +1,4 @@ -using System.Text; -using NetAF.Utilities; - -namespace NetAF.Rendering.Console +namespace NetAF.Rendering.Console { /// /// Provides a grid based frame for displaying a picture. @@ -127,31 +124,6 @@ private static bool RequiresColorChange(int x, int y, AnsiColor current, AnsiCol #endregion - #region Overrides of Object - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() - { - StringBuilder stringBuilder = new(); - - for (var y = 0; y < builder.DisplaySize.Height; y++) - { - for (var x = 0; x < builder.DisplaySize.Width; x++) - { - stringBuilder.Append(builder.GetCharacter(x, y)); - } - - stringBuilder.Append(StringUtilities.Newline); - } - - return stringBuilder.ToString(); - } - - #endregion - #region Implementation of IFrame /// From 8cfbb0d6c9216e745ff2906fb6cf604166a339fa Mon Sep 17 00:00:00 2001 From: ben_singer Date: Tue, 26 Nov 2024 10:26:13 +0000 Subject: [PATCH 09/15] Added textures --- .../Regions/Hub/Drawings/ClearingDrawing.cs | 5 +- .../Extensions/StringExtensions_Tests.cs | 10 ++ .../Console/GridPictureBuilder_Tests.cs | 96 +++++++++++++-- .../Rendering/Console/Texture_Tests.cs | 109 +++++++++++++++++ NetAF/Extensions/StringExtensions.cs | 13 +- NetAF/Rendering/Console/GridPictureBuilder.cs | 55 +++++++-- NetAF/Rendering/Console/Texture.cs | 113 ++++++++++++++++++ 7 files changed, 383 insertions(+), 18 deletions(-) create mode 100644 NetAF.Tests/Rendering/Console/Texture_Tests.cs create mode 100644 NetAF/Rendering/Console/Texture.cs diff --git a/NetAF.Examples/Assets/Regions/Hub/Drawings/ClearingDrawing.cs b/NetAF.Examples/Assets/Regions/Hub/Drawings/ClearingDrawing.cs index ceb9bc73..b1a90e83 100644 --- a/NetAF.Examples/Assets/Regions/Hub/Drawings/ClearingDrawing.cs +++ b/NetAF.Examples/Assets/Regions/Hub/Drawings/ClearingDrawing.cs @@ -1,4 +1,5 @@ using NetAF.Assets; +using NetAF.Extensions; using NetAF.Rendering.Console; using NetAF.Utilities; @@ -15,13 +16,13 @@ private static void DrawSun(GridPictureBuilder builder) builder.SetCell(12, 7, AnsiColor.BrightYellow); builder.SetCell(8, 9, AnsiColor.BrightYellow); builder.DrawRectangle(6, 6, 5, 3, AnsiColor.BrightYellow, AnsiColor.BrightYellow); - builder.DrawTexture(6, 6, 5, 3, ':', AnsiColor.Yellow); + builder.DrawTexture(6, 6, 5, 3, ":".ToTexture(), AnsiColor.Yellow); } private static void DrawGrass(GridPictureBuilder builder) { builder.DrawRectangle(0, 25, 80, 25, AnsiColor.BrightGreen, AnsiColor.BrightGreen); - builder.DrawTexture(0, 25, 80, 25, '#', AnsiColor.Green); + builder.DrawTexture(0, 25, 80, 25, "#".ToTexture(), AnsiColor.Green); } private static void DrawTree(GridPictureBuilder builder, int x, int y) diff --git a/NetAF.Tests/Extensions/StringExtensions_Tests.cs b/NetAF.Tests/Extensions/StringExtensions_Tests.cs index 53f55abc..a778b741 100644 --- a/NetAF.Tests/Extensions/StringExtensions_Tests.cs +++ b/NetAF.Tests/Extensions/StringExtensions_Tests.cs @@ -458,5 +458,15 @@ public void GivenAA_WhenInsensitiveEquals_ThenReturnaA() Assert.AreEqual("aA", result); } + + [TestMethod] + public void GivenAA_WhenToTexture_ThenReturnATextureWithWidth2Height1() + { + var value = "AA"; + var result = value.ToTexture(); + + Assert.AreEqual(2, result.Width); + Assert.AreEqual(1, result.Height); + } } } diff --git a/NetAF.Tests/Rendering/Console/GridPictureBuilder_Tests.cs b/NetAF.Tests/Rendering/Console/GridPictureBuilder_Tests.cs index 2b7e9aff..cdb231e9 100644 --- a/NetAF.Tests/Rendering/Console/GridPictureBuilder_Tests.cs +++ b/NetAF.Tests/Rendering/Console/GridPictureBuilder_Tests.cs @@ -10,7 +10,7 @@ public class GridPictureBuilder_Tests public void GivenBlank_WhenSetCell_ThenCharacterSetCorrectly() { var builder = new GridPictureBuilder(AnsiColor.Black, AnsiColor.White); - builder.Resize(new(10, 10)); + builder.Resize(new(3, 3)); builder.SetCell(0, 0, 'C', AnsiColor.Red); var result = builder.GetCharacter(0, 0); @@ -22,7 +22,7 @@ public void GivenBlank_WhenSetCell_ThenCharacterSetCorrectly() public void GivenBlank_WhenSetCell_ThenForegroundColorSetCorrectly() { var builder = new GridPictureBuilder(AnsiColor.Black, AnsiColor.White); - builder.Resize(new(10, 10)); + builder.Resize(new(3, 3)); builder.SetCell(0, 0, 'C', AnsiColor.Red, AnsiColor.Green); var foreground = builder.GetCellForegroundColor(0, 0); @@ -34,7 +34,7 @@ public void GivenBlank_WhenSetCell_ThenForegroundColorSetCorrectly() public void GivenBlank_WhenSetCell_ThenBackgroundColorSetCorrectly() { var builder = new GridPictureBuilder(AnsiColor.Black, AnsiColor.White); - builder.Resize(new(10, 10)); + builder.Resize(new(3, 3)); builder.SetCell(0, 0, AnsiColor.Green); var background = builder.GetCellBackgroundColor(0, 0); @@ -43,10 +43,10 @@ public void GivenBlank_WhenSetCell_ThenBackgroundColorSetCorrectly() } [TestMethod] - public void GivenBlank_WhenNotSer_ThenBackgroundColorSetCorrectly() + public void GivenBlank_WhenNotSet_ThenBackgroundColorSetCorrectly() { var builder = new GridPictureBuilder(AnsiColor.Black, AnsiColor.White); - builder.Resize(new(10, 10)); + builder.Resize(new(3, 3)); var background = builder.GetCellBackgroundColor(0, 0); @@ -54,14 +54,96 @@ public void GivenBlank_WhenNotSer_ThenBackgroundColorSetCorrectly() } [TestMethod] - public void GivenBlank_WhenNotSer_ThenForegroundColorSetCorrectly() + public void GivenBlank_WhenNotSet_ThenForegroundColorSetCorrectly() { var builder = new GridPictureBuilder(AnsiColor.Black, AnsiColor.White); - builder.Resize(new(10, 10)); + builder.Resize(new(3, 3)); var foreground = builder.GetCellForegroundColor(0, 0); Assert.AreEqual(AnsiColor.White, foreground); } + + [TestMethod] + public void GivenBlank_WhenDrawRectangle3x3_ThenCellsSetCorrectly() + { + var builder = new GridPictureBuilder(AnsiColor.Black, AnsiColor.White); + builder.Resize(new(3, 3)); + + builder.DrawRectangle(0, 0, 3, 3, AnsiColor.Black, AnsiColor.Red); + + Assert.AreEqual(AnsiColor.Black, builder.GetCellBackgroundColor(0, 0)); + Assert.AreEqual(AnsiColor.Black, builder.GetCellBackgroundColor(1, 0)); + Assert.AreEqual(AnsiColor.Black, builder.GetCellBackgroundColor(2, 0)); + Assert.AreEqual(AnsiColor.Black, builder.GetCellBackgroundColor(0, 1)); + Assert.AreEqual(AnsiColor.Black, builder.GetCellBackgroundColor(2, 1)); + Assert.AreEqual(AnsiColor.Black, builder.GetCellBackgroundColor(0, 2)); + Assert.AreEqual(AnsiColor.Black, builder.GetCellBackgroundColor(1, 2)); + Assert.AreEqual(AnsiColor.Black, builder.GetCellBackgroundColor(2, 2)); + Assert.AreEqual(AnsiColor.Red, builder.GetCellBackgroundColor(1, 1)); + } + + [TestMethod] + public void GivenBlank_WhenDrawTexture3x3_ThenCellsSetCorrectly() + { + var builder = new GridPictureBuilder(AnsiColor.Black, AnsiColor.White); + builder.Resize(new(3, 3)); + Texture texture = new("ABC\nDEF\nGHI"); + + builder.DrawTexture(0, 0, 3, 3, texture, AnsiColor.Green); + + Assert.AreEqual('A', builder.GetCharacter(0, 0)); + Assert.AreEqual('B', builder.GetCharacter(1, 0)); + Assert.AreEqual('C', builder.GetCharacter(2, 0)); + Assert.AreEqual('D', builder.GetCharacter(0, 1)); + Assert.AreEqual('E', builder.GetCharacter(1, 1)); + Assert.AreEqual('F', builder.GetCharacter(2, 1)); + Assert.AreEqual('G', builder.GetCharacter(0, 2)); + Assert.AreEqual('H', builder.GetCharacter(1, 2)); + Assert.AreEqual('I', builder.GetCharacter(2, 2)); + + Assert.AreEqual(AnsiColor.Green, builder.GetCellForegroundColor(0, 0)); + Assert.AreEqual(AnsiColor.Green, builder.GetCellForegroundColor(1, 0)); + Assert.AreEqual(AnsiColor.Green, builder.GetCellForegroundColor(2, 0)); + Assert.AreEqual(AnsiColor.Green, builder.GetCellForegroundColor(0, 1)); + Assert.AreEqual(AnsiColor.Green, builder.GetCellForegroundColor(1, 1)); + Assert.AreEqual(AnsiColor.Green, builder.GetCellForegroundColor(2, 1)); + Assert.AreEqual(AnsiColor.Green, builder.GetCellForegroundColor(0, 2)); + Assert.AreEqual(AnsiColor.Green, builder.GetCellForegroundColor(1, 2)); + Assert.AreEqual(AnsiColor.Green, builder.GetCellForegroundColor(2, 2)); + } + + [TestMethod] + public void GivenBlank_WhenDrawTextureOverBackgroundColor3x3OverRed_ThenOnlyRedCellsModified() + { + var builder = new GridPictureBuilder(AnsiColor.Black, AnsiColor.White); + builder.Resize(new(3, 3)); + char unset = '\0'; + Texture texture = new("ABC\nDEF\nGHI"); + + builder.SetCell(1, 1, AnsiColor.Red); + + builder.DrawTextureOverBackgroundColor(0, 0, 3, 3, AnsiColor.Red, texture, AnsiColor.Green); + + Assert.AreEqual(unset, builder.GetCharacter(0, 0)); + Assert.AreEqual(unset, builder.GetCharacter(1, 0)); + Assert.AreEqual(unset, builder.GetCharacter(2, 0)); + Assert.AreEqual(unset, builder.GetCharacter(0, 1)); + Assert.AreEqual('E', builder.GetCharacter(1, 1)); + Assert.AreEqual(unset, builder.GetCharacter(2, 1)); + Assert.AreEqual(unset, builder.GetCharacter(0, 2)); + Assert.AreEqual(unset, builder.GetCharacter(1, 2)); + Assert.AreEqual(unset, builder.GetCharacter(2, 2)); + + Assert.AreEqual(AnsiColor.White, builder.GetCellForegroundColor(0, 0)); + Assert.AreEqual(AnsiColor.White, builder.GetCellForegroundColor(1, 0)); + Assert.AreEqual(AnsiColor.White, builder.GetCellForegroundColor(2, 0)); + Assert.AreEqual(AnsiColor.White, builder.GetCellForegroundColor(0, 1)); + Assert.AreEqual(AnsiColor.Green, builder.GetCellForegroundColor(1, 1)); + Assert.AreEqual(AnsiColor.White, builder.GetCellForegroundColor(2, 1)); + Assert.AreEqual(AnsiColor.White, builder.GetCellForegroundColor(0, 2)); + Assert.AreEqual(AnsiColor.White, builder.GetCellForegroundColor(1, 2)); + Assert.AreEqual(AnsiColor.White, builder.GetCellForegroundColor(2, 2)); + } } } diff --git a/NetAF.Tests/Rendering/Console/Texture_Tests.cs b/NetAF.Tests/Rendering/Console/Texture_Tests.cs new file mode 100644 index 00000000..456c126b --- /dev/null +++ b/NetAF.Tests/Rendering/Console/Texture_Tests.cs @@ -0,0 +1,109 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NetAF.Rendering.Console; +using NetAF.Utilities; + +namespace NetAF.Tests.Rendering.Console +{ + [TestClass] + public class Texture_Tests + { + [TestMethod] + public void GivenASingleCharacter_ThenWidth1Height1() + { + Texture t = new("A"); + + Assert.AreEqual(1, t.Width); + Assert.AreEqual(1, t.Height); + } + + [TestMethod] + public void GivenTwoCharacters_ThenWidth2Height1() + { + Texture t = new("AB"); + + Assert.AreEqual(2, t.Width); + Assert.AreEqual(1, t.Height); + } + + [TestMethod] + public void GivenTwoCharactersNewlineThenTwoCharacters_ThenWidth2Height2() + { + Texture t = new("AB\nCD"); + + Assert.AreEqual(2, t.Width); + Assert.AreEqual(2, t.Height); + } + + [TestMethod] + public void GivenX0Y0IsA_WhenGetX0Y0_ThenReturnA() + { + Texture t = new("AB\nCD"); + + var result = t[0, 0]; + + Assert.AreEqual('A', result); + } + + + [TestMethod] + public void GivenX1Y0IsB_WhenGetX1Y0_ThenReturnB() + { + Texture t = new("AB\nCD"); + + var result = t[1, 0]; + + Assert.AreEqual('B', result); + } + + [TestMethod] + public void GivenX0Y1IsC_WhenGetX0Y1_ThenReturnC() + { + Texture t = new("AB\nCD"); + + var result = t[0, 1]; + + Assert.AreEqual('C', result); + } + + [TestMethod] + public void GivenX1Y1IsD_WhenGetX1Y1_ThenReturnD() + { + Texture t = new("AB\nCD"); + + var result = t[1, 1]; + + Assert.AreEqual('D', result); + } + + [TestMethod] + public void GivenLopsidedWidth_WhenGetUnusedCell_ThenReturnSpace() + { + Texture t = new("AB\nC"); + + var result = t[1, 1]; + + Assert.AreEqual(' ', result); + } + + [TestMethod] + public void GivenW2H2_WhenGetOutOfBounds_ThenReturnSpace() + { + Texture t = new("AB\nCD"); + + var result = t[100, 100]; + + Assert.AreEqual(' ', result); + } + + [TestMethod] + public void GivenABNewlineCD_WhenToString_ThenReturnABNewlineCD() + { + var original = $"AB{StringUtilities.Newline}CD"; + Texture t = new(original); + + var result = t.ToString(); + + Assert.AreEqual(original, result); + } + } +} diff --git a/NetAF/Extensions/StringExtensions.cs b/NetAF/Extensions/StringExtensions.cs index a42968c5..1eab3c69 100644 --- a/NetAF/Extensions/StringExtensions.cs +++ b/NetAF/Extensions/StringExtensions.cs @@ -1,5 +1,6 @@ using System; using NetAF.Assets; +using NetAF.Rendering.Console; using NetAF.Utilities; namespace NetAF.Extensions @@ -234,7 +235,7 @@ public static string AddSentence(this string value, string other) /// /// The value. /// The modified string. - internal static string StartWithLower(this string value) + public static string StartWithLower(this string value) { if (string.IsNullOrEmpty(value)) return value; @@ -245,6 +246,16 @@ internal static string StartWithLower(this string value) return $"{value.Substring(0, 1).ToLower()}{value.Substring(1)}"; } + /// + /// Create a texture from this string. + /// + /// The value. + /// The texture. + public static Texture ToTexture(this string value) + { + return new(value); + } + #endregion } } \ No newline at end of file diff --git a/NetAF/Rendering/Console/GridPictureBuilder.cs b/NetAF/Rendering/Console/GridPictureBuilder.cs index 0bfe1e62..52504e39 100644 --- a/NetAF/Rendering/Console/GridPictureBuilder.cs +++ b/NetAF/Rendering/Console/GridPictureBuilder.cs @@ -211,26 +211,65 @@ public void DrawRectangle(int left, int top, int width, int height, AnsiColor bo } /// - /// Draw a rectangle. + /// Draw a texture. /// - /// The left position of the rectangle. - /// The top position of the rectangle. - /// The width of the rectangle. - /// The height of the rectangle. - /// The character to use for the texture. + /// The left position of the area to draw within. + /// The top position of the area to draw within. + /// The width of the area to draw within. + /// The height of the area to draw within. + /// The texture. /// The foregroundColor color of the texture. - public void DrawTexture(int left, int top, int width, int height, char character, AnsiColor foregroundColor) + public void DrawTexture(int left, int top, int width, int height, Texture texture, AnsiColor foregroundColor) { for (var y = top; y < top + height; y++) { for (var x = left; x < left + width; x++) { SafeSetCellForeground(x, y, foregroundColor); - SafeSetCellCharacter(x, y, character); + SafeSetCellCharacter(x, y, GetCharacterFromTexture(x, y, texture)); + } + } + } + + /// + /// Draw a texture over all cells where the background color matches the specified color. + /// + /// The left position of the area to draw within. + /// The top position of the area to draw within. + /// The width of the area to draw within. + /// The height of the area to draw within. + /// The background color. + /// The texture. + /// The foregroundColor color of the texture. + public void DrawTextureOverBackgroundColor(int left, int top, int width, int height, AnsiColor backgroundColor, Texture texture, AnsiColor foregroundColor) + { + for (var y = top; y < top + height; y++) + { + for (var x = left; x < left + width; x++) + { + if (GetCellBackgroundColor(x, y) == backgroundColor) + { + SafeSetCellForeground(x, y, foregroundColor); + SafeSetCellCharacter(x, y, GetCharacterFromTexture(x, y, texture)); + } } } } + /// + /// Get a character to use from a texture at a specified position within a region of interest. + /// + /// The x position within the region of interest. + /// The y position within the region of interest. + /// The texture. + /// The character from the texture to use at the specified position. + private static char GetCharacterFromTexture(int x, int y, Texture texture) + { + var textureX = x % texture.Width; + var textureY = y % texture.Height; + return texture[textureX, textureY]; + } + #endregion } } diff --git a/NetAF/Rendering/Console/Texture.cs b/NetAF/Rendering/Console/Texture.cs new file mode 100644 index 00000000..7a713be3 --- /dev/null +++ b/NetAF/Rendering/Console/Texture.cs @@ -0,0 +1,113 @@ +using NetAF.Utilities; +using System.Linq; +using System.Text; + +namespace NetAF.Rendering.Console +{ + /// + /// Provides texture made from a 2D array of characters. + /// + /// The texture as a string. The string will be split at newlines to create the 2D texture. + public class Texture(string texture) + { + #region Fields + + private char[,] kernel; + + #endregion + + #region Properties + + /// + /// Get a character from the texture. + /// + /// The x position of the character within the texture. + /// The y position of the character within the texture. + /// The character. If the specified position is outside of the kernel then ' ' will be returned. + public char this[int x, int y] => IsPositionInKernel(x, y) ? Kernel[x, y] : ' '; + + /// + /// Get the kernel, as a 2D array of characters. + /// + public char[,] Kernel + { + get + { + if (kernel == null) + CreateKernel(texture); + + return kernel; + } + } + + /// + /// Get the width of the texture. + /// + public int Width => Kernel.GetLength(0); + + /// + /// Get the height of the texture. + /// + public int Height => Kernel.GetLength(1); + + #endregion + + #region Methods + + /// + /// Get if a position is within the kernel. + /// + /// The x position. + /// The y position. + /// True if the position is within the kernel, else + private bool IsPositionInKernel(int x, int y) + { + return x >= 0 && x < Width && y >= 0 && y < Height; + } + + /// + /// Create the kernel. + /// + /// The texture to create the kernel from. The string will be split at newlines to create the 2D texture. + private void CreateKernel(string texture) + { + var lines = texture.Split(); + int width = lines.Max(x => x.Length); + int height = lines.Length; + kernel = new char[width, height]; + + for (var y = 0; y < height; y++) + for (var x = 0; x < width; x++) + kernel[x, y] = x < lines[y].Length ? lines[y][x] : ' '; + } + + #endregion + + #region Overrides of Object + + /// + /// Returns a string that represents the current object. + /// + /// A string that represents the current object. + public override string ToString() + { + StringBuilder builder = new(); + + for (var y = 0; y < Height; y++) + { + for (var x = 0; x < Width; x++) + { + if (IsPositionInKernel(x, y)) + builder.Append(this[x, y]); + } + + if (y < Height - 1) + builder.Append(StringUtilities.Newline); + } + + return builder.ToString(); + } + + #endregion + } +} From 2de6f9f39fcce09cd639ec9207ee0ccc1bc3faf8 Mon Sep 17 00:00:00 2001 From: ben_singer Date: Tue, 26 Nov 2024 13:41:50 +0000 Subject: [PATCH 10/15] Added imaging --- ...aringDrawing.cs => ClearingVisualFrame.cs} | 35 ++++++-- .../Assets/Regions/Hub/Rooms/Clearing.cs | 8 +- NetAF.Examples/NetAF.Examples.csproj | 1 + NetAF.Examples/Program.cs | 4 + NetAF.Imaging.Tests/GlobalUsings.cs | 1 + .../GridVisualBuilderHelper_Tests.cs | 28 +++++++ .../NetAF.Imaging.Tests.csproj | 38 +++++++++ NetAF.Imaging.Tests/Resources/FullBlack.bmp | Bin 0 -> 78 bytes NetAF.Imaging.Tests/Resources/FullWhite.bmp | Bin 0 -> 78 bytes NetAF.Imaging/GridVisualBuilderHelper.cs | 48 +++++++++++ NetAF.Imaging/NetAF.Imaging.csproj | 17 ++++ .../ConsoleVisualFrameBuilder_Tests.cs | 23 +++++ ...er_Tests.cs => GridVisualBuilder_Tests.cs} | 50 ++++++++--- ...rame_Tests.cs => GridVisualFrame_Tests.cs} | 6 +- NetAF.sln | 12 +++ NetAF/Rendering/Console/Ansi.cs | 24 ++++++ .../FrameBuilders/ConsoleAboutFrameBuilder.cs | 6 -- .../ConsoleCompletionFrameBuilder.cs | 6 -- .../ConsoleConversationFrameBuilder.cs | 6 -- .../ConsoleGameOverFrameBuilder.cs | 6 -- .../ConsoleReactionFrameBuilder.cs | 6 -- .../ConsoleRegionMapFrameBuilder.cs | 6 -- .../FrameBuilders/ConsoleSceneFrameBuilder.cs | 7 -- .../FrameBuilders/ConsoleTitleFrameBuilder.cs | 6 -- .../ConsoleVisualFrameBuilder.cs | 79 ++++++++++++++++++ ...PictureBuilder.cs => GridVisualBuilder.cs} | 49 ++++++++++- ...GridPictureFrame.cs => GridVisualFrame.cs} | 4 +- NetAF/Rendering/Console/Texture.cs | 2 +- .../FrameBuilders/IVisualFrameBuilder.cs | 20 +++++ 29 files changed, 420 insertions(+), 78 deletions(-) rename NetAF.Examples/Assets/Regions/Hub/Drawings/{ClearingDrawing.cs => ClearingVisualFrame.cs} (64%) create mode 100644 NetAF.Imaging.Tests/GlobalUsings.cs create mode 100644 NetAF.Imaging.Tests/GridVisualBuilderHelper_Tests.cs create mode 100644 NetAF.Imaging.Tests/NetAF.Imaging.Tests.csproj create mode 100644 NetAF.Imaging.Tests/Resources/FullBlack.bmp create mode 100644 NetAF.Imaging.Tests/Resources/FullWhite.bmp create mode 100644 NetAF.Imaging/GridVisualBuilderHelper.cs create mode 100644 NetAF.Imaging/NetAF.Imaging.csproj create mode 100644 NetAF.Tests/Rendering/Console/FrameBuilders/ConsoleVisualFrameBuilder_Tests.cs rename NetAF.Tests/Rendering/Console/{GridPictureBuilder_Tests.cs => GridVisualBuilder_Tests.cs} (75%) rename NetAF.Tests/Rendering/Console/{GridPictureFrame_Tests.cs => GridVisualFrame_Tests.cs} (82%) create mode 100644 NetAF/Rendering/Console/FrameBuilders/ConsoleVisualFrameBuilder.cs rename NetAF/Rendering/Console/{GridPictureBuilder.cs => GridVisualBuilder.cs} (81%) rename NetAF/Rendering/Console/{GridPictureFrame.cs => GridVisualFrame.cs} (97%) create mode 100644 NetAF/Rendering/FrameBuilders/IVisualFrameBuilder.cs diff --git a/NetAF.Examples/Assets/Regions/Hub/Drawings/ClearingDrawing.cs b/NetAF.Examples/Assets/Regions/Hub/Drawings/ClearingVisualFrame.cs similarity index 64% rename from NetAF.Examples/Assets/Regions/Hub/Drawings/ClearingDrawing.cs rename to NetAF.Examples/Assets/Regions/Hub/Drawings/ClearingVisualFrame.cs index b1a90e83..948818fc 100644 --- a/NetAF.Examples/Assets/Regions/Hub/Drawings/ClearingDrawing.cs +++ b/NetAF.Examples/Assets/Regions/Hub/Drawings/ClearingVisualFrame.cs @@ -1,13 +1,17 @@ using NetAF.Assets; using NetAF.Extensions; +using NetAF.Rendering; using NetAF.Rendering.Console; +using NetAF.Rendering.Console.FrameBuilders; using NetAF.Utilities; namespace NetAF.Examples.Assets.Regions.Hub.Drawings { - internal class ClearingDrawing(Size size) : IAssetTemplate + internal class ClearingVisualFrame(string name, Size size) : IAssetTemplate