Made console change text color depending on messages

This commit is contained in:
Twitchy 2011-07-08 23:38:02 +12:00
parent 16a90f3240
commit 1d5ac77255
4 changed files with 14 additions and 1 deletions

View file

@ -70,14 +70,18 @@ namespace TShockAPI
Tools.Broadcast("Server map saving, potential lag spike"); Tools.Broadcast("Server map saving, potential lag spike");
WorldGen.saveWorld(); WorldGen.saveWorld();
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("World backed up"); Console.WriteLine("World backed up");
Console.ForegroundColor = ConsoleColor.Gray;
Log.Info(string.Format("World backed up ({0})", Main.worldPathName)); Log.Info(string.Format("World backed up ({0})", Main.worldPathName));
Main.worldPathName = worldname; Main.worldPathName = worldname;
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Backup failed"); Console.WriteLine("Backup failed");
Console.ForegroundColor = ConsoleColor.Gray;
Log.Error("Backup failed"); Log.Error("Backup failed");
Log.Error(ex.ToString()); Log.Error(ex.ToString());
} }

View file

@ -86,7 +86,9 @@ namespace TShockAPI
/// <param name="message">The message to be written.</param> /// <param name="message">The message to be written.</param>
public static void ConsoleError(String message) public static void ConsoleError(String message)
{ {
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(message); Console.WriteLine(message);
Console.ForegroundColor = ConsoleColor.Gray;
Write(message, LogLevel.Error); Write(message, LogLevel.Error);
} }
@ -114,7 +116,9 @@ namespace TShockAPI
/// <param name="message">The message to be written.</param> /// <param name="message">The message to be written.</param>
public static void ConsoleInfo(String message) public static void ConsoleInfo(String message)
{ {
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine(message); Console.WriteLine(message);
Console.ForegroundColor = ConsoleColor.Gray;
Write(message, LogLevel.Info); Write(message, LogLevel.Info);
} }

View file

@ -280,7 +280,9 @@ namespace TShockAPI
public override void SendMessage(string msg, byte red, byte green, byte blue) public override void SendMessage(string msg, byte red, byte green, byte blue)
{ {
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine(msg); Console.WriteLine(msg);
Console.ForegroundColor = ConsoleColor.Gray;
} }
public void SetBloodMoon(bool bloodMoon) public void SetBloodMoon(bool bloodMoon)

View file

@ -45,6 +45,7 @@ namespace TShockAPI
public static TSPlayer[] Players = new TSPlayer[Main.maxPlayers]; public static TSPlayer[] Players = new TSPlayer[Main.maxPlayers];
public static BanManager Bans; public static BanManager Bans;
public static WarpManager Warps; public static WarpManager Warps;
public static RegionManager Regions;
public static BackupManager Backups; public static BackupManager Backups;
public static ConfigFile Config { get; set; } public static ConfigFile Config { get; set; }
@ -112,6 +113,7 @@ namespace TShockAPI
Bans = new BanManager(DB); Bans = new BanManager(DB);
Warps = new WarpManager(DB); Warps = new WarpManager(DB);
Regions = new RegionManager(DB);
Log.ConsoleInfo(string.Format("TShock Version {0} ({1}) now running.", Version, VersionCodename)); Log.ConsoleInfo(string.Format("TShock Version {0} ({1}) now running.", Version, VersionCodename));
@ -128,7 +130,6 @@ namespace TShockAPI
GetDataHandlers.InitGetDataHandler(); GetDataHandlers.InitGetDataHandler();
Commands.InitCommands(); Commands.InitCommands();
RegionManager.ReadAllSettings();
ItemManager.LoadBans(); ItemManager.LoadBans();
Log.ConsoleInfo("AutoSave " + (TShock.Config.AutoSave ? "Enabled" : "Disabled")); Log.ConsoleInfo("AutoSave " + (TShock.Config.AutoSave ? "Enabled" : "Disabled"));
@ -209,8 +210,10 @@ namespace TShockAPI
{ {
var r = new Random((int)DateTime.Now.ToBinary()); var r = new Random((int)DateTime.Now.ToBinary());
AuthToken = r.Next(100000, 10000000); AuthToken = r.Next(100000, 10000000);
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("TShock Notice: To become SuperAdmin, join the game and type /auth " + AuthToken); Console.WriteLine("TShock Notice: To become SuperAdmin, join the game and type /auth " + AuthToken);
Console.WriteLine("This token will only display ONCE. This only works ONCE. If you don't use it and the server goes down, delete auth.lck."); Console.WriteLine("This token will only display ONCE. This only works ONCE. If you don't use it and the server goes down, delete auth.lck.");
Console.ForegroundColor = ConsoleColor.Gray;
FileTools.CreateFile(Path.Combine(SavePath, "auth.lck")); FileTools.CreateFile(Path.Combine(SavePath, "auth.lck"));
} }
} }