From 10231492a6cd1dcb457c62fbdbaecad84b0702d2 Mon Sep 17 00:00:00 2001 From: lionarius Date: Tue, 7 Jan 2025 21:02:48 +0300 Subject: [PATCH] . --- DoomDeathmatch/src/Script/UI/Align.cs | 2 +- Engine/Engine.csproj | 1 - Engine/src/Graphics/IPresenter.cs | 6 +++--- PresenterConsole/src/AsciiPixel.cs | 2 +- PresenterConsole/src/ConsoleFastOutput.cs | 8 ++++++-- PresenterConsole/src/ConsolePresenter.cs | 3 ++- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/DoomDeathmatch/src/Script/UI/Align.cs b/DoomDeathmatch/src/Script/UI/Align.cs index 800d360..ac510ac 100644 --- a/DoomDeathmatch/src/Script/UI/Align.cs +++ b/DoomDeathmatch/src/Script/UI/Align.cs @@ -19,4 +19,4 @@ public enum Align /// Align content to the right. /// Right -} +} \ No newline at end of file diff --git a/Engine/Engine.csproj b/Engine/Engine.csproj index bbbded8..73950f4 100644 --- a/Engine/Engine.csproj +++ b/Engine/Engine.csproj @@ -43,7 +43,6 @@ True ShaderResource.resx - diff --git a/Engine/src/Graphics/IPresenter.cs b/Engine/src/Graphics/IPresenter.cs index b05c827..b9dd68a 100644 --- a/Engine/src/Graphics/IPresenter.cs +++ b/Engine/src/Graphics/IPresenter.cs @@ -15,17 +15,17 @@ public interface IPresenter : IUpdate, IRender public event Action OnResize; /// - /// Gets the current width of the presenter. + /// The current width of the presenter. /// public int Width { get; } /// - /// Gets the current height of the presenter. + /// The current height of the presenter. /// public int Height { get; } /// - /// Gets a value indicating whether the presenter is exiting. + /// Indicates whether the presenter is exiting. /// public bool IsExiting { get; } diff --git a/PresenterConsole/src/AsciiPixel.cs b/PresenterConsole/src/AsciiPixel.cs index 378cd68..7646455 100644 --- a/PresenterConsole/src/AsciiPixel.cs +++ b/PresenterConsole/src/AsciiPixel.cs @@ -12,7 +12,7 @@ public struct AsciiPixel : IPixel public SizedInternalFormat SizedInternalFormat => SizedInternalFormat.Rg8; public byte Luminance => R; - public byte Color => G; + public byte NormalizedColorIndex => G; public byte R; public byte G; diff --git a/PresenterConsole/src/ConsoleFastOutput.cs b/PresenterConsole/src/ConsoleFastOutput.cs index f447055..c3d3920 100644 --- a/PresenterConsole/src/ConsoleFastOutput.cs +++ b/PresenterConsole/src/ConsoleFastOutput.cs @@ -16,7 +16,6 @@ public sealed class ConsoleFastOutput : IDisposable private int _height; private int _width; - public ConsoleFastOutput(int parWidth, int parHeight) { ArgumentOutOfRangeException.ThrowIfNegativeOrZero(parWidth); @@ -30,7 +29,11 @@ public sealed class ConsoleFastOutput : IDisposable throw new InvalidOperationException("Failed to open console handle"); } - Resize(parWidth, parHeight); + _width = parWidth; + _height = parHeight; + + _buffer = new WindowsFFI.CharInfo[_width * _height]; + _bufferSize = new WindowsFFI.Coord((short)_width, (short)_height); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -38,6 +41,7 @@ public sealed class ConsoleFastOutput : IDisposable { var index = parX + (parY * _width); ref var charInfo = ref _buffer[index]; + charInfo.Char.UnicodeChar = parCharacter; charInfo.Attributes = (short)((ushort)parForeground | ((ushort)parBackground << 4)); } diff --git a/PresenterConsole/src/ConsolePresenter.cs b/PresenterConsole/src/ConsolePresenter.cs index 3e0d61f..88e13a3 100644 --- a/PresenterConsole/src/ConsolePresenter.cs +++ b/PresenterConsole/src/ConsolePresenter.cs @@ -128,7 +128,8 @@ public class ConsolePresenter : IPresenter { var pixel = parImage[y, x]; var lightnessIndex = (byte)(pixel.Luminance / 255.0f * (LIGHTMAP.Length - 1)); - var colorIndex = (ConsoleColor)(pixel.Color / 255.0f * 15.0f); + var colorIndex = (ConsoleColor)(pixel.NormalizedColorIndex / 255.0f * 15.0f); + _consoleOutput.WriteChar(LIGHTMAP[lightnessIndex], 2 * x, y, 0, colorIndex); _consoleOutput.WriteChar(LIGHTMAP[lightnessIndex], (2 * x) + 1, y, 0, colorIndex); }