Version 3 Release
It’s finally done! Version 3 of SadConsole brings a lot of structural changes and increases flexibility. Previously it was hard to implement new types of objects that hooked into the rendering system. And whenever I did create something extra, I always felt like I was trying to fit it around the system instead of the system being flexible enough to handle it. Not any more!
Version 3.0 has taken me 2 1/2 months, 113 commits to the code repository, and 192 files were edited.
Here is a class diagram of how the system is put together now. Click below after the picture for more about the changes.
The system is made up of three concepts (that work out to different types)
This represents the text data of a surface.
Takes in TextSurface data and draws it to the screen.
Provides a way to change a TextSurface, like the background or foreground of cells.
What about the classic SadConsole.Consoles.Console type? It’s there. This class is a
SurfaceEditor that has both a
TextSurfaceRenderer. The concept of a
Console comes together when you combine those three elements. The
Console still has all the other things: cursor, position, and input handling.
You can easily use a
TextSurfaceRenderer to render a
TextSurface directly, and you can use the
SurfaceEditor to change the data on the
TextSurface, all without the actual
This flexability allows us to create new types of data and rendering systems. For example, there is now a
CachedTextSurfaceRenderer that instead of rendering the
TextSurface on every render call, it renders once and keeps that output for every subsequent render call. You have to explicitly tell it to update itself. This is handy for UI elements, frames and borders, and text areas that never change once rendered. If a text surface is 10x10, that is about 200 renders calls every frame. With the
CachedTextSurfaceRenderer you take those 200 render calls once, and then every time after that a single render call is done. Very optimized.
Here are some common examples of using the new types.
By default, SadConsole handles all rendering and updates of a
Console type for you. Just add it to the
You can take any existing TextSurface and render it multiple times. A console draws it self once per frame, wherever
Console.Position points to on the screen, but we can also draw manually if we would like to duplicate the console.
Remember that the console is still in the
SadConsole.Engine.ConsoleRenderStackand will draw at position 1, 1.
Instead of using the console itself to render, you could also do it all by hand.
In the next blog post, I’ll show how to use the render multiple layers on a console using built in types.