mirror of
https://git.alee14.me/shiftos-archive/ShiftOS_TheReturn.git
synced 2025-01-22 18:02:16 +00:00
Console colors!
This commit is contained in:
parent
3f08cb807c
commit
251521835b
4 changed files with 59 additions and 6 deletions
|
@ -134,7 +134,7 @@ namespace ShiftOS.WinForms.Applications
|
|||
rtbterm.Text = "";
|
||||
TerminalBackend.PrefixEnabled = true;
|
||||
TerminalBackend.InStory = false;
|
||||
Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ");
|
||||
TerminalBackend.PrintPrompt();
|
||||
if (Shiftorium.UpgradeInstalled("wm_free_placement"))
|
||||
{
|
||||
this.ParentForm.Width = 640;
|
||||
|
@ -276,7 +276,7 @@ namespace ShiftOS.WinForms.Applications
|
|||
}
|
||||
if (TerminalBackend.PrefixEnabled)
|
||||
{
|
||||
Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ");
|
||||
TerminalBackend.PrintPrompt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
@ -56,16 +57,31 @@ namespace ShiftOS.WinForms.Controls
|
|||
{
|
||||
this.HideSelection = true;
|
||||
this.Select(this.TextLength, 0);
|
||||
this.SelectionFont = ConstructFont();
|
||||
this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor);
|
||||
this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor);
|
||||
this.AppendText(Localization.Parse(text));
|
||||
this.HideSelection = false;
|
||||
}
|
||||
|
||||
private Font ConstructFont()
|
||||
{
|
||||
FontStyle fs = FontStyle.Regular;
|
||||
if (ConsoleEx.Bold)
|
||||
fs = fs | FontStyle.Bold;
|
||||
if (ConsoleEx.Italic)
|
||||
fs = fs | FontStyle.Italic;
|
||||
if (ConsoleEx.Underline)
|
||||
fs = fs | FontStyle.Underline;
|
||||
|
||||
return new Font(this.Font, fs);
|
||||
}
|
||||
|
||||
public void WriteLine(string text)
|
||||
{
|
||||
this.HideSelection = true;
|
||||
this.Select(this.TextLength, 0);
|
||||
this.SelectionFont = ConstructFont();
|
||||
this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor);
|
||||
this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor);
|
||||
this.AppendText(Localization.Parse(text) + Environment.NewLine);
|
||||
|
|
|
@ -132,6 +132,7 @@ namespace ShiftOS.Engine
|
|||
{
|
||||
Console.WriteLine(acc);
|
||||
}
|
||||
TerminalBackend.PrintPrompt();
|
||||
}
|
||||
else if(msg.Name == "update_your_cp")
|
||||
{
|
||||
|
@ -154,11 +155,15 @@ namespace ShiftOS.Engine
|
|||
{
|
||||
var ex = JsonConvert.DeserializeObject<Exception>(msg.Contents);
|
||||
TerminalBackend.PrefixEnabled = true;
|
||||
ConsoleEx.ForegroundColor = ConsoleColor.Red;
|
||||
ConsoleEx.Bold = true;
|
||||
Console.Write($@"{{MUD_ERROR}}: ");
|
||||
ConsoleEx.Bold = false;
|
||||
ConsoleEx.Italic = true;
|
||||
ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow;
|
||||
Console.WriteLine($@"{{MUD_ERROR}}: {ex.Message}");
|
||||
ConsoleEx.ForegroundColor = ConsoleColor.White;
|
||||
Console.WriteLine(ex.Message);
|
||||
TerminalBackend.PrefixEnabled = true;
|
||||
Console.Write($"{SaveSystem.CurrentSave.Username}@{CurrentSave.SystemName}:~$ ");
|
||||
TerminalBackend.PrintPrompt();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -283,7 +283,39 @@ namespace ShiftOS.Engine
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static void PrintPrompt()
|
||||
{
|
||||
ConsoleEx.Italic = false;
|
||||
ConsoleEx.Underline = false;
|
||||
|
||||
ConsoleEx.ForegroundColor = ConsoleColor.Magenta;
|
||||
ConsoleEx.Bold = true;
|
||||
Console.Write(SaveSystem.CurrentSave.Username);
|
||||
ConsoleEx.Bold = false;
|
||||
ConsoleEx.ForegroundColor = ConsoleColor.Gray;
|
||||
Console.Write("@");
|
||||
ConsoleEx.Italic = true;
|
||||
ConsoleEx.Bold = true;
|
||||
ConsoleEx.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.Write(SaveSystem.CurrentSave.SystemName);
|
||||
ConsoleEx.Italic = false;
|
||||
ConsoleEx.Bold = false;
|
||||
ConsoleEx.ForegroundColor = ConsoleColor.Gray;
|
||||
Console.Write(":~");
|
||||
Console.ForegroundColor = ConsoleColor.White;
|
||||
ConsoleEx.Italic = true;
|
||||
if (KernelWatchdog.InKernelMode == true)
|
||||
Console.Write("#");
|
||||
else
|
||||
Console.Write("$");
|
||||
ConsoleEx.Italic = false;
|
||||
ConsoleEx.Bold = false;
|
||||
ConsoleEx.ForegroundColor = ConsoleColor.White;
|
||||
Console.Write(" ");
|
||||
}
|
||||
|
||||
|
||||
static TerminalBackend()
|
||||
{
|
||||
ServerMessageReceived onMessageReceived = (msg) =>
|
||||
|
|
Loading…
Reference in a new issue