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

◆ ForegroundColor

ConsoleColor System.ConsolePal.ForegroundColor
staticgetset

Definition at line 283 of file ConsolePal.cs.

284 {
285 get
286 {
287 bool succeeded;
288 global::Interop.Kernel32.CONSOLE_SCREEN_BUFFER_INFO bufferInfo = GetBufferInfo(throwOnNoConsole: false, out succeeded);
289 if (!succeeded)
290 {
291 return ConsoleColor.Gray;
292 }
293 return ColorAttributeToConsoleColor((global::Interop.Kernel32.Color)(bufferInfo.wAttributes & 0xF));
294 }
295 set
296 {
297 global::Interop.Kernel32.Color color = ConsoleColorToColorAttribute(value, isBackground: false);
298 bool succeeded;
299 global::Interop.Kernel32.CONSOLE_SCREEN_BUFFER_INFO bufferInfo = GetBufferInfo(throwOnNoConsole: false, out succeeded);
300 if (succeeded)
301 {
302 short wAttributes = bufferInfo.wAttributes;
303 wAttributes &= -16;
304 wAttributes = (short)((ushort)wAttributes | (ushort)color);
305 global::Interop.Kernel32.SetConsoleTextAttribute(OutputHandle, wAttributes);
306 }
307 }
308 }
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()