public static void Blit(char[,] inBuffer, int x, int y, AdvConsoleColor foreColor = AdvConsoleColor.None, AdvConsoleColor backColor = AdvConsoleColor.None) { int width = inBuffer.GetLength(1); int height = inBuffer.GetLength(0); for (int ly = 0; ly < height; ly++) { for (int lx = 0; lx < width; lx++) { if ((x + lx) > consoleWidth - 1 || (y + ly) > consoleHeight - 1) continue; int bufferIndex = ((x + lx) + ((y * consoleWidth) + (ly * consoleWidth))); if (bufferIndex >= 0 && bufferIndex < backBuffer.Length) { SetCharacter(bufferIndex, inBuffer[ly, lx], foreColor, backColor); } } } }
public static void WriteList(string[] text, int x, int y, bool horizontal, AdvConsoleColor foreColor, AdvConsoleColor backColor) { int lineX = x; int lineY = y; //int lastLineLength = 0; for (int s = 0; s < (text.Length); s++) { char[,] line = ConstructStringBuffer(text[s]); Blit(line, lineX, lineY, foreColor, backColor); if (horizontal) lineX += text[s].Length; else lineY += 1 + line.GetUpperBound(0); } }
public static void Blit(char[,] inBuffer, Point position, AdvConsoleColor foreColor, AdvConsoleColor backColor) { Blit(inBuffer, position.X, position.Y, foreColor, backColor); }
public static void Write(string text, int x, int y, AdvConsoleColor foreColor, AdvConsoleColor backColor = AdvConsoleColor.None) { Blit(ConstructStringBuffer(text), x, y, foreColor, backColor); }
public static void WriteList(string[] text, Point position, bool horizontal, AdvConsoleColor foreColor, AdvConsoleColor backColor) { WriteList(text, position.X, position.Y, horizontal, foreColor, backColor); }
/// <summary> /// Sets the info for a character at the specified index in the buffer /// </summary> /// <param name="index">Index of the buffer</param> /// <param name="character">Character to write</param> /// <param name="foreColor">Foreground Color</param> /// <param name="backColor">Background Color</param> public static void SetCharacter(int index, char character, AdvConsoleColor foreColor, AdvConsoleColor backColor) { backBuffer[index].Char.UnicodeChar = character; byte foreCol = (byte)foreColor; byte backCol = (byte)backColor; if (backColor == AdvConsoleColor.None) { byte fc = (byte)(backBuffer[index].Attributes % 16); backCol = (byte)((backBuffer[index].Attributes - fc) / 16); } if (foreColor == AdvConsoleColor.None) { foreCol = (byte)(backBuffer[index].Attributes % 16); } backBuffer[index].Attributes = (byte)((byte)(foreCol) + (byte)((int)backCol * 16)); }
public static void Write(string text, Point position, AdvConsoleColor foreColor, AdvConsoleColor backColor = AdvConsoleColor.None) { Write(text, position.X, position.Y, foreColor, backColor); }
public static void Outline(Rectangle area, char topCharacter, char sideCharacter, char topLeftCharacter, char topRightCharacter, char bottomLeftCharacter, char bottomRightCharacter, AdvConsoleColor foreColor, AdvConsoleColor backColor = AdvConsoleColor.None) { Outline(area.X, area.Y, area.Width, area.Height, topCharacter, sideCharacter, topLeftCharacter, topRightCharacter, bottomLeftCharacter, bottomRightCharacter, foreColor, backColor); }
public static void Outline(int x, int y, int width, int height, char topCharacter, char sideCharacter, char topLeftCharacter, char topRightCharacter, char bottomLeftCharacter, char bottomRightCharacter, AdvConsoleColor foreColor, AdvConsoleColor backColor = AdvConsoleColor.None) { for (int ly = 0; ly < height; ly++) { for (int lx = 0; lx < width; lx++) { if ((lx > 0 && lx < (width - 1)) && (ly > 0 && ly < (height - 1))) continue; int bufferIndex = ((x + lx) + ((y * consoleWidth) + (ly * consoleWidth))); if (bufferIndex < backBuffer.Length) { if (ly <= 0 || ly >= (height - 1)) { char character; if (lx >= (width - 1) && ly <= 0) character = topRightCharacter; else if (lx >= (width - 1) && ly >= (height - 1)) character = bottomRightCharacter; else if (lx <= 0 && ly <= 0) character = topLeftCharacter; else if (lx <= 0 && ly >= (height - 1)) character = bottomLeftCharacter; else character = topCharacter; SetCharacter(bufferIndex, character, foreColor, backColor); } else if (lx <= 0 || lx >= (width - 1)) { SetCharacter(bufferIndex, sideCharacter, foreColor, backColor); } } } } }
public static void Outline(int x, int y, int width, int height, char topCharacter, char sideCharacter, AdvConsoleColor foreColor, AdvConsoleColor backColor = AdvConsoleColor.None) { Outline(x, y, width, height, topCharacter, sideCharacter, topCharacter, sideCharacter, topCharacter, sideCharacter, foreColor, backColor); }
public static void Outline(Rectangle area, char character, AdvConsoleColor foreColor, AdvConsoleColor backColor = AdvConsoleColor.None) { Outline(area.X, area.Y, area.Width, area.Height, character, foreColor, backColor); }
public static void Fill(int x, int y, int width, int height, char character, AdvConsoleColor foreColor = AdvConsoleColor.None, AdvConsoleColor backColor = AdvConsoleColor.None) { for (int ly = 0; ly < height; ly++) { for (int lx = 0; lx < width; lx++) { int bufferIndex = ((x + lx) + ((y * consoleWidth) + (ly * consoleWidth))); if (bufferIndex < backBuffer.Length) { SetCharacter(bufferIndex, character, foreColor, backColor); } } } }
public static void Fill(Rectangle area, char character, AdvConsoleColor foreColor, AdvConsoleColor backColor) { Fill(area.X, area.Y, area.Width, area.Height, character, foreColor, backColor); }
/// <summary> /// Removes text from the entire screen and sets the background color /// </summary> /// <param name="backColor">Background Color</param> public static void ClearScreen(AdvConsoleColor backColor) { for (int i = 0; i < backBuffer.Count(); i++) { backBuffer[i].Char.UnicodeChar = ('\0'); backBuffer[i].Attributes = (byte)((int)backColor * 16); } }