Move SetConsoleTitle to utils

This commit is contained in:
Lucas Nicodemus 2017-12-04 21:49:56 -07:00
parent 7c47fbb3f2
commit 17982bd766
2 changed files with 14 additions and 14 deletions

View file

@ -822,7 +822,7 @@ namespace TShockAPI
/// <param name="args">args - The EventArgs object.</param>
private void OnPostInit(EventArgs args)
{
SetConsoleTitle(false);
Utils.SetConsoleTitle(false);
//This is to prevent a bug where a CLI-defined password causes packets to be
//sent in an unexpected order, resulting in clients being unable to connect
@ -1179,17 +1179,7 @@ namespace TShockAPI
}
}
}
SetConsoleTitle(false);
}
/// <summary>SetConsoleTitle - Updates the console title with some pertinent information.</summary>
/// <param name="empty">empty - True/false if the server is empty; determines if we should use Utils.ActivePlayers() for player count or 0.</param>
private void SetConsoleTitle(bool empty)
{
Console.Title = string.Format("{0}{1}/{2} on {3} @ {4}:{5} (TShock for Terraria v{6})",
!string.IsNullOrWhiteSpace(Config.ServerName) ? Config.ServerName + " - " : "",
empty ? 0 : Utils.ActivePlayers(),
Config.MaxSlots, Main.worldName, Netplay.ServerIP.ToString(), Netplay.ListenPort, Version);
Utils.SetConsoleTitle(false);
}
/// <summary>OnHardUpdate - Fired when a hardmode tile update event happens.</summary>
@ -1435,7 +1425,7 @@ namespace TShockAPI
{
if (Config.SaveWorldOnLastPlayerExit)
SaveManager.Instance.SaveWorld();
SetConsoleTitle(true);
Utils.SetConsoleTitle(true);
}
}

View file

@ -1429,7 +1429,7 @@ namespace TShockAPI
}
/// <summary>FixChestStacks - Verifies that each stack in each chest is valid and not over the max stack count.</summary>
public void FixChestStacks()
internal void FixChestStacks()
{
if (TShock.Config.IgnoreChestStacksOnLoad)
return;
@ -1446,5 +1446,15 @@ namespace TShockAPI
}
}
}
/// <summary>SetConsoleTitle - Updates the console title with some pertinent information.</summary>
/// <param name="empty">empty - True/false if the server is empty; determines if we should use Utils.ActivePlayers() for player count or 0.</param>
internal void SetConsoleTitle(bool empty)
{
Console.Title = string.Format("{0}{1}/{2} on {3} @ {4}:{5} (TShock for Terraria v{6})",
!string.IsNullOrWhiteSpace(TShock.Config.ServerName) ? TShock.Config.ServerName + " - " : "",
empty ? 0 : ActivePlayers(),
TShock.Config.MaxSlots, Main.worldName, Netplay.ServerIP.ToString(), Netplay.ListenPort, TShock.VersionNum);
}
}
}