Reconnect to MUD after unexpected loss

This commit is contained in:
Michael 2017-04-02 18:29:42 -04:00
parent 2ea24d407c
commit 2612721346
2 changed files with 29 additions and 3 deletions

View file

@ -40,7 +40,7 @@ namespace ShiftOS.WinForms
{
get
{
return Desktop.Size.Height - ((Shiftorium.UpgradeInstalled("desktop_panel") == true) ? SkinEngine.LoadedSkin.DesktopPanelHeight : 0);
return Desktop.Size.Height - ((Shiftorium.UpgradeInstalled("desktop") == true) ? SkinEngine.LoadedSkin.DesktopPanelHeight : 0);
}
}
@ -48,7 +48,7 @@ namespace ShiftOS.WinForms
{
get
{
if (!Shiftorium.UpgradeInstalled("desktop_panel"))
if (!Shiftorium.UpgradeInstalled("desktop"))
return 0;
return ((SkinEngine.LoadedSkin.DesktopPanelPosition == 0) ? SkinEngine.LoadedSkin.DesktopPanelHeight : 0);
}
@ -64,6 +64,14 @@ namespace ShiftOS.WinForms
Desktop.InvokeOnWorkerThread(act);
}
public WinformsWindowManager()
{
Shiftorium.Installed += () =>
{
SetupWindows();
};
}
public override void Maximize(IWindowBorder form)
{
try

View file

@ -51,9 +51,11 @@ namespace ShiftOS.Engine
public static Guid thisGuid { get; private set; }
private static NetObjectClient client { get; set; }
private static bool UserDisconnect = false;
public static void Disconnect()
{
UserDisconnect = true;
if (client != null)
{
client.Disconnect();
@ -117,7 +119,23 @@ namespace ShiftOS.Engine
public static void Initiate(string mud_address, int port)
{
client = new NetObjectClient();
client.OnDisconnected += (o, a) =>
{
if (!UserDisconnect)
{
TerminalBackend.PrefixEnabled = true;
ConsoleEx.ForegroundColor = ConsoleColor.Red;
ConsoleEx.Bold = true;
Console.Write($@"Disconnected from MUD: ");
ConsoleEx.Bold = false;
ConsoleEx.Italic = true;
ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine("You have been disconnected from the multi-user domain for an unknown reason. Your save data is preserved within the kernel and you will be reconnected shortly.");
TerminalBackend.PrefixEnabled = true;
TerminalBackend.PrintPrompt();
Initiate(mud_address, port);
}
};
client.OnReceived += (o, a) =>
{
var msg = a.Data.Object as ServerMessage;