Skip to content

Commit

Permalink
Merge pull request #269 from Thraka/develop
Browse files Browse the repository at this point in the history
Release for 9.1.0
  • Loading branch information
Thraka authored Jul 6, 2021
2 parents 14ff33f + 76a3b15 commit 6748733
Show file tree
Hide file tree
Showing 60 changed files with 963 additions and 351 deletions.
1 change: 1 addition & 0 deletions SadConsole.Host.MonoGame/Components/DrawImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace SadConsole.Components
/// <summary>
/// Draws an image on top of a console.
/// </summary>
[System.Diagnostics.DebuggerDisplay("Image")]
public class DrawImage : RenderComponent, IDisposable
{
private bool _hasFont;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace SadConsole.Renderers
/// <summary>
/// Draws a <see cref="SadConsole.UI.ControlHost"/>.
/// </summary>
[System.Diagnostics.DebuggerDisplay("Control host")]
public class ControlHostRenderStep : IRenderStep, IRenderStepTexture
{
private SadConsole.UI.ControlHost _controlsHost;
Expand Down
7 changes: 4 additions & 3 deletions SadConsole.Host.MonoGame/Renderers/CursorRenderStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace SadConsole.Renderers
/// <summary>
/// Renders a cursor.
/// </summary>
[System.Diagnostics.DebuggerDisplay("Cursor")]
public class CursorRenderStep : IRenderStep
{
private Components.Cursor _cursor;
Expand Down Expand Up @@ -55,14 +56,14 @@ public void Render(IRenderer renderer, IScreenSurface screenObject)
if (cursor.IsVisible && screenObject.Surface.IsValidCell(cursor.Position.X, cursor.Position.Y) && screenObject.Surface.View.Contains(cursor.Position))
{
GameHost.Instance.DrawCalls.Enqueue(
new DrawCalls.DrawCallGlyph(cursor.CursorRenderCell,
new DrawCalls.DrawCallGlyph(cursor.CursorRenderCellActiveState,
((Host.GameTexture)screenObject.Font.Image).Texture,
new XnaRectangle(screenObject.Font.GetRenderRect(cursor.Position.X - screenObject.Surface.ViewPosition.X,
cursor.Position.Y - screenObject.Surface.ViewPosition.Y,
screenObject.FontSize).Translate(screenObject.AbsolutePosition).Position.ToMonoPoint(),
screenObject.FontSize.ToMonoPoint()),
screenObject.Font.SolidGlyphRectangle.ToMonoRectangle(),
screenObject.Font.GetGlyphSourceRectangle(cursor.CursorRenderCell.Glyph).ToMonoRectangle()
screenObject.Font.GetGlyphSourceRectangle(cursor.CursorRenderCellActiveState.Glyph).ToMonoRectangle(),
screenObject.Font.SolidGlyphRectangle.ToMonoRectangle()
)
);
}
Expand Down
1 change: 1 addition & 0 deletions SadConsole.Host.MonoGame/Renderers/EntityLiteRenderStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace SadConsole.Renderers
/// <summary>
/// Draws the entities of a <see cref="Entities.Renderer"/>.
/// </summary>
[System.Diagnostics.DebuggerDisplay("Entity lite")]
public class EntityLiteRenderStep : IRenderStep, IRenderStepTexture
{
private Entities.Renderer _entityManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace SadConsole.Renderers
/// <summary>
/// A render step that draws the <see cref="ScreenSurfaceRenderer._backingTexture"/> texture.
/// </summary>
[System.Diagnostics.DebuggerDisplay("Output")]
public class OutputSurfaceRenderStep : IRenderStep
{
/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace SadConsole.Renderers
/// <remarks>
/// This renderer caches the entire drawing of the surface's cells, including the tint of the object.
/// </remarks>
[System.Diagnostics.DebuggerDisplay("Surface")]
public class ScreenSurfaceRenderer : IRenderer
{
private Host.GameTexture _renderTexture;
Expand Down
1 change: 1 addition & 0 deletions SadConsole.Host.MonoGame/Renderers/SurfaceRenderStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace SadConsole.Renderers
/// <summary>
/// Draws a <see cref="SadConsole.IScreenSurface"/> object.
/// </summary>
[System.Diagnostics.DebuggerDisplay("Surface")]
public class SurfaceRenderStep : IRenderStep, IRenderStepTexture
{
private Host.GameTexture _cachedTexture;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace SadConsole.Renderers
/// <summary>
/// Renders a tint on top of where the output texture is drawn.
/// </summary>
[System.Diagnostics.DebuggerDisplay("Tint")]
public class TintSurfaceRenderStep : IRenderStep
{
/// <inheritdoc/>
Expand Down
1 change: 1 addition & 0 deletions SadConsole.Host.MonoGame/Renderers/WindowRenderStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace SadConsole.Renderers
/// <summary>
/// Renders the dimmed background screen when a window is modal.
/// </summary>
[System.Diagnostics.DebuggerDisplay("Window")]
public class WindowRenderStep : IRenderStep
{
/// <inheritdoc/>
Expand Down
6 changes: 3 additions & 3 deletions SadConsole.Host.MonoGame/SadConsole.Host.MonoGame.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>netstandard2.1;netcoreapp3.1;net5.0</TargetFrameworks>
<RootNamespace>SadConsole.Host.MonoGame</RootNamespace>
<DocumentationFile>SadConsole.Host.MonoGame.xml</DocumentationFile>
<Version>9.0.1</Version>
<Version>9.1.0</Version>
<Version Condition="'$(Configuration)'=='Debug'">$(Version)-debug</Version>
<Authors>Thraka</Authors>
<Company>SadLogic</Company>
Expand All @@ -14,7 +14,6 @@
<Copyright>Copyright © 2020 Steve De George JR (Thraka)</Copyright>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>SadConsole.Host.MonoGame</PackageId>
<PackageReleaseNotes>Adjusted rendering system yet again.</PackageReleaseNotes>
<PackageIcon>nugeticon.png</PackageIcon>
<RepositoryUrl>https://github.com/SadConsole/SadConsole</RepositoryUrl>
<RepositoryType>git</RepositoryType>
Expand All @@ -26,6 +25,7 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<EmbedAllSources>true</EmbedAllSources>
<PackageTags>monogame;roguelike;cli;xna;game;development;console;ansi;ascii;textmode;sadconsole</PackageTags>
<PackageReleaseNotes>Fix bug with rendering cursors.</PackageReleaseNotes>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -34,7 +34,7 @@

<ItemGroup>
<ProjectReference Condition=" '$(UseProjectReferences)' == 'true' " Include="..\SadConsole\SadConsole.csproj" />
<PackageReference Condition=" '$(UseProjectReferences)' != 'true' " Include="SadConsole" Version="9.0.0" />
<PackageReference Condition=" '$(UseProjectReferences)' != 'true' " Include="SadConsole" Version="9.1.0" />
<PackageReference Include="TheSadRogue.Primitives" Version="1.0.0" />
<PackageReference Include="TheSadRogue.Primitives.MonoGame" Version="1.0.0" />
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641" />
Expand Down
2 changes: 1 addition & 1 deletion SadConsole.Host.SFML/Renderers/CursorRenderStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void Render(IRenderer renderer, IScreenSurface screenObject)
Point cursorPosition = screenObject.AbsoluteArea.Position + screenObject.Font.GetRenderRect(cursor.Position.X - screenObject.Surface.ViewPosition.X, cursor.Position.Y - screenObject.Surface.ViewPosition.Y, screenObject.FontSize).Position;

GameHost.Instance.DrawCalls.Enqueue(
new DrawCalls.DrawCallCell(cursor.CursorRenderCell,
new DrawCalls.DrawCallCell(cursor.CursorRenderCellActiveState,
new Rectangle(cursorPosition.X, cursorPosition.Y, screenObject.FontSize.X, screenObject.FontSize.Y).ToIntRect(),
screenObject.Font,
true
Expand Down
6 changes: 3 additions & 3 deletions SadConsole.Host.SFML/SadConsole.Host.SFML.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>netstandard2.1;netcoreapp3.1;net5.0</TargetFrameworks>
<RootNamespace>SadConsole.Host.SFML</RootNamespace>
<DocumentationFile>SadConsole.Host.SFML.xml</DocumentationFile>
<Version>9.0.1</Version>
<Version>9.1.0</Version>
<Version Condition="'$(Configuration)'=='Debug'">$(Version)-debug</Version>
<Authors>Thraka</Authors>
<Company>SadLogic</Company>
Expand All @@ -14,7 +14,6 @@
<Copyright>Copyright © 2020 Steve De George JR (Thraka)</Copyright>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>SadConsole.Host.SFML</PackageId>
<PackageReleaseNotes>Adjusted rendering system yet again.</PackageReleaseNotes>
<PackageIcon>nugeticon.png</PackageIcon>
<RepositoryUrl>https://github.com/SadConsole/SadConsole</RepositoryUrl>
<RepositoryType>git</RepositoryType>
Expand All @@ -26,6 +25,7 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<EmbedAllSources>true</EmbedAllSources>
<PackageTags>sfml;roguelike;cli;game;development;console;ansi;ascii;textmode;sadconsole</PackageTags>
<PackageReleaseNotes>Fix bug with rendering cursors.</PackageReleaseNotes>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -35,7 +35,7 @@

<ItemGroup>
<ProjectReference Condition=" '$(UseProjectReferences)' == 'true' " Include="..\SadConsole\SadConsole.csproj" />
<PackageReference Condition=" '$(UseProjectReferences)' != 'true' " Include="SadConsole" Version="9.0.0" />
<PackageReference Condition=" '$(UseProjectReferences)' != 'true' " Include="SadConsole" Version="9.1.0" />
<PackageReference Include="TheSadRogue.Primitives" Version="1.0.0" />
<PackageReference Include="TheSadRogue.Primitives.SFML" Version="1.0.0" />
<PackageReference Include="SFML.Net" Version="2.5.0" />
Expand Down
14 changes: 13 additions & 1 deletion SadConsole/ColoredGlyph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@ public class ColoredGlyph
private Mirror _mirror;
private int _glyph;
private bool _isDirty;
private CellDecorator[] _decorators = Array.Empty<CellDecorator>();

/// <summary>
/// Modifies the look of a cell with additional character.
/// </summary>
public CellDecorator[] Decorators { get; set; } = Array.Empty<CellDecorator>();
public CellDecorator[] Decorators
{
get => _decorators;
set { _decorators = value ?? Array.Empty<CellDecorator>(); IsDirty = true; }
}

/// <summary>
/// The foreground color of this cell.
Expand Down Expand Up @@ -207,6 +212,13 @@ public void Clear()
Decorators = Array.Empty<CellDecorator>();
}

/// <summary>
/// Copies the settings of this colored glyph into a new state object.
/// </summary>
/// <returns>The state of this colored glyph.</returns>
public ColoredGlyphState ToState() =>
new ColoredGlyphState(this);

/* TODO: Move this to extension methods in the actual Renderers library (monogame, gdi+, etc)
/// <summary>
/// Draws a single cell using the specified SpriteBatch.
Expand Down
96 changes: 96 additions & 0 deletions SadConsole/ColoredGlyphState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using SadRogue.Primitives;

namespace SadConsole
{
/// <summary>
/// A <see cref="ColoredGlyph"/> with state information.
/// </summary>
public readonly struct ColoredGlyphState
{
/// <summary>
/// A copy of the <see cref="ColoredGlyph.Decorators"/> property.
/// </summary>
public CellDecorator[] Decorators { get; }

/// <summary>
/// A copy of the <see cref="ColoredGlyph.Foreground"/> property.
/// </summary>
public Color Foreground { get; }

/// <summary>
/// A copy of the <see cref="ColoredGlyph.Background"/> property.
/// </summary>
public Color Background { get; }

/// <summary>
/// A copy of the <see cref="ColoredGlyph.Glyph"/> property.
/// </summary>
public int Glyph { get; }

/// <summary>
/// A copy of the <see cref="ColoredGlyph.Mirror"/> property.
/// </summary>
public Mirror Mirror { get; }

/// <summary>
/// A copy of the <see cref="ColoredGlyph.IsVisible"/> property.
/// </summary>
public bool IsVisible { get; }

/// <summary>
/// Creates a new state from a cell.
/// </summary>
/// <param name="cell">The colored glyph this state is a copy of.</param>
public ColoredGlyphState(ColoredGlyph cell)
{
Foreground = cell.Foreground;
Background = cell.Background;
Mirror = cell.Mirror;
Glyph = cell.Glyph;
IsVisible = cell.IsVisible;
Decorators = cell.Decorators.Length != 0 ? cell.Decorators.ToArray() : Array.Empty<CellDecorator>();
}

/// <summary>
/// Creates a new state.
/// </summary>
/// <param name="decorators">Decorators for the cell.</param>
/// <param name="foreground">Foreground color.</param>
/// <param name="background">Background color.</param>
/// <param name="glyph">The glyph index.</param>
/// <param name="mirror">The mirror effect.</param>
/// <param name="isVisible">The visiblity of the glyph.</param>
[JsonConstructor]
public ColoredGlyphState(CellDecorator[] decorators, Color foreground, Color background, int glyph, Mirror mirror, bool isVisible)
{
Decorators = decorators;
Foreground = foreground;
Background = background;
Glyph = glyph;
Mirror = mirror;
IsVisible = isVisible;
}

/// <summary>
/// Restores this state to the specified cell.
/// </summary>
public void RestoreState(ref ColoredGlyph cell)
{
cell.Foreground = Foreground;
cell.Background = Background;
cell.Mirror = Mirror;
cell.Glyph = Glyph;
cell.IsVisible = IsVisible;

if (Decorators == null)
cell.Decorators = Array.Empty<CellDecorator>();
else
cell.Decorators = Decorators.Length != 0 ? Decorators.ToArray() : Array.Empty<CellDecorator>();
}
}
}
Loading

0 comments on commit 6748733

Please sign in to comment.