From 41da0b25000f93cf405d6bf18a1597e2616731bd Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 4 May 2017 16:06:32 -0400 Subject: [PATCH] fix bug with multiplayer ui --- ShiftOS.WinForms/Applications/Pong.Designer.cs | 1 + ShiftOS.WinForms/Applications/Pong.cs | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/ShiftOS.WinForms/Applications/Pong.Designer.cs b/ShiftOS.WinForms/Applications/Pong.Designer.cs index d0ff466..0254e94 100644 --- a/ShiftOS.WinForms/Applications/Pong.Designer.cs +++ b/ShiftOS.WinForms/Applications/Pong.Designer.cs @@ -193,6 +193,7 @@ namespace ShiftOS.WinForms.Applications this.pnlmultiplayerhandshake.Name = "pnlmultiplayerhandshake"; this.pnlmultiplayerhandshake.Size = new System.Drawing.Size(396, 231); this.pnlmultiplayerhandshake.TabIndex = 15; + this.pnlmultiplayerhandshake.Visible = false; // // lvotherplayers // diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index ad81197..3e93c34 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -374,6 +374,14 @@ namespace ShiftOS.WinForms.Applications LeaderX = pt.X; LeaderY = pt.Y; } + else if(msg.Name == "pong_mp_left") + { + this.Invoke(new Action(() => + { + AppearanceManager.Close(this); + })); + Infobox.Show("Opponent has closed Pong.", "The opponent has closed Pong, therefore the connection between you two has dropped."); + } else if (msg.Name == "pong_mp_youlose") { LoseMP(); @@ -408,6 +416,7 @@ namespace ShiftOS.WinForms.Applications else if (msg.Name == "pong_handshake_chosen") { IsLeader = false; + LeaveMatchmake(); OpponentGUID = msg.Contents; YouGUID = ServerManager.thisGuid.ToString(); SendFollowerGUID(); @@ -984,6 +993,7 @@ namespace ShiftOS.WinForms.Applications pnlfinalstats.Hide(); CenterPanels(); lblbeatai.Hide(); + ServerManager.MessageReceived += this.ServerMessageReceivedHandler; } public void OnSkinLoad() @@ -997,6 +1007,14 @@ namespace ShiftOS.WinForms.Applications public bool OnUnload() { + if(IsMultiplayerSession == true) + { + if(!string.IsNullOrWhiteSpace(OpponentGUID)) + ServerManager.Forward(OpponentGUID, "pong_mp_left", null); + } + LeaveMatchmake(); + ServerManager.MessageReceived -= this.ServerMessageReceivedHandler; + return true; }