Improved console input/output

This commit is contained in:
ORelio 2013-07-27 18:44:54 +02:00
parent b40ad6ee16
commit ea2774068b
2 changed files with 26 additions and 32 deletions

View file

@ -460,25 +460,20 @@ namespace MinecraftClient
}
private void printstring(string str, bool acceptnewlines)
{
if (str != "")
if (!String.IsNullOrEmpty(str))
{
char prev = ' ';
foreach (char c in str)
if (!acceptnewlines) { str = str.Replace('\n', ' '); }
string[] subs = str.Split(new char[] { '§' });
if (subs[0].Length > 0) { ConsoleIO.Write(subs[0]); }
for (int i = 1; i < subs.Length; i++)
{
if (c == '§')
if (subs[i].Length > 0)
{
prev = c;
continue;
}
else if (prev == '§')
{
setcolor(c);
prev = c;
}
else
{
if (c == '\n' && !acceptnewlines) { continue; }
else ConsoleIO.Write(c);
setcolor(subs[i][0]);
if (subs[i].Length > 1)
{
ConsoleIO.Write(subs[i].Substring(1, subs[i].Length - 1));
}
}
}
ConsoleIO.Write('\n');