Revert to CMD icon on exit

Else CMD would still have the player head as icon
This commit is contained in:
ORelio 2014-07-27 16:43:45 +02:00
parent cb1edcb3b1
commit 47a3cdc783
2 changed files with 27 additions and 7 deletions

View file

@ -27,12 +27,11 @@ namespace MinecraftClient
public static void setPlayerIconAsync(string playerName)
{
Thread t = new Thread(new ThreadStart(delegate
if (!Program.isUsingMono) //Windows Only
{
if (!Program.isUsingMono) //Windows Only
Thread t = new Thread(new ThreadStart(delegate
{
HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create("http://skins.minecraft.net/MinecraftSkins/" + playerName + ".png");
try
{
using (HttpWebResponse httpWebReponse = (HttpWebResponse)httpWebRequest.GetResponse())
@ -44,13 +43,33 @@ namespace MinecraftClient
}
catch (WebException) //Skin not found? Reset to default icon
{
SetConsoleIcon(Icon.ExtractAssociatedIcon(Application.ExecutablePath).Handle);
try
{
SetConsoleIcon(Icon.ExtractAssociatedIcon(Application.ExecutablePath).Handle);
}
catch { }
}
}
));
t.Name = "Player skin icon setter";
t.Start();
}
}
/// <summary>
/// Set the icon back to the default CMD icon
/// </summary>
public static void revertToCMDIcon()
{
if (!Program.isUsingMono) //Windows Only
{
try
{
SetConsoleIcon(Icon.ExtractAssociatedIcon(Environment.SystemDirectory + "\\cmd.exe").Handle);
}
catch { }
}
));
t.Name = "Player skin icon setter";
t.Start();
}
}
}

View file

@ -289,6 +289,7 @@ namespace MinecraftClient
private static void t_exit()
{
if (Client != null) { Client.Disconnect(); ConsoleIO.Reset(); }
if (Settings.playerHeadAsIcon) { ConsoleIcon.revertToCMDIcon(); }
Environment.Exit(0);
}