Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ BackgroundColor

ConsoleColor System.ConsolePal.BackgroundColor
staticgetset

Definition at line 256 of file ConsolePal.cs.

257 {
258 get
259 {
260 bool succeeded;
261 global::Interop.Kernel32.CONSOLE_SCREEN_BUFFER_INFO bufferInfo = GetBufferInfo(throwOnNoConsole: false, out succeeded);
262 if (!succeeded)
263 {
264 return ConsoleColor.Black;
265 }
266 return ColorAttributeToConsoleColor((global::Interop.Kernel32.Color)(bufferInfo.wAttributes & 0xF0));
267 }
268 set
269 {
270 global::Interop.Kernel32.Color color = ConsoleColorToColorAttribute(value, isBackground: true);
271 bool succeeded;
272 global::Interop.Kernel32.CONSOLE_SCREEN_BUFFER_INFO bufferInfo = GetBufferInfo(throwOnNoConsole: false, out succeeded);
273 if (succeeded)
274 {
275 short wAttributes = bufferInfo.wAttributes;
276 wAttributes &= -241;
277 wAttributes = (short)((ushort)wAttributes | (ushort)color);
278 global::Interop.Kernel32.SetConsoleTextAttribute(OutputHandle, wAttributes);
279 }
280 }
281 }
static global::Interop.Kernel32.Color ConsoleColorToColorAttribute(ConsoleColor color, bool isBackground)
static ConsoleColor ColorAttributeToConsoleColor(global::Interop.Kernel32.Color c)
static IntPtr OutputHandle
static global::Interop.Kernel32.CONSOLE_SCREEN_BUFFER_INFO GetBufferInfo()