/// <summary> /// Joins same battle as player /// </summary> public static void JoinPlayer(string name) { var client = Program.TasClient; if (!client.IsLoggedIn) return; User user; if (client.ExistingUsers.TryGetValue(name, out user) && user.IsInBattleRoom) { var bat = client.ExistingBattles.Values.FirstOrDefault(x => x.Users.ContainsKey(name)); if (bat != null) { string password = null; // this could possibly use braces, but I'm crazy if (bat.IsPassworded) using (var form = new AskBattlePasswordForm(bat.FounderName)) if (form.ShowDialog() == DialogResult.OK) password = form.Password; JoinBattle(bat.BattleID, password); } } }
protected override void OnMouseDown([NotNull] MouseEventArgs e) { if (e == null) throw new ArgumentNullException("e"); base.OnMouseDown(e); Battle battle = GetBattle(e.X, e.Y); if (e.Button == MouseButtons.Left) { if (battle != null) { if (battle.IsPassworded) { // hack dialog Program.FormMain using (var form = new AskBattlePasswordForm(battle.Founder.Name)) if (form.ShowDialog() == DialogResult.OK) ActionHandler.JoinBattle(battle.BattleID, form.Password); } else { ActionHandler.JoinBattle(battle.BattleID, null); } } else if (OpenGameButtonHitTest(e.X, e.Y)) ShowHostDialog(KnownGames.GetDefaultGame()); } else if (e.Button == MouseButtons.Right) { var cm = ContextMenus.GetBattleListContextMenu(battle); Program.ToolTip.Visible = false; try { cm.Show(Parent, e.Location); } catch (Exception ex) { Trace.TraceError("BattleListControl Error displaying tooltip: {0}", ex); } finally { Program.ToolTip.Visible = true; } } }
protected override void OnMouseDown([NotNull] MouseEventArgs e) { if (e == null) { throw new ArgumentNullException("e"); } base.OnMouseDown(e); Battle battle = GetBattle(e.X, e.Y); if (e.Button == MouseButtons.Left) { if (battle != null) { if (battle.IsPassworded) { // hack dialog Program.FormMain using (var form = new AskBattlePasswordForm(battle.Founder.Name)) if (form.ShowDialog() == DialogResult.OK) { ActionHandler.JoinBattle(battle.BattleID, form.Password); } } else { ActionHandler.JoinBattle(battle.BattleID, null); } } else if (OpenGameButtonHitTest(e.X, e.Y)) { ShowHostDialog(KnownGames.GetDefaultGame()); } } else if (e.Button == MouseButtons.Right) { var cm = ContextMenus.GetBattleListContextMenu(battle); Program.ToolTip.Visible = false; try { cm.Show(Parent, e.Location); } catch (Exception ex) { Trace.TraceError("BattleListControl Error displaying tooltip: {0}", ex); } finally { Program.ToolTip.Visible = true; } } }
protected override void OnMouseDown([NotNull] MouseEventArgs e) { if (e == null) { throw new ArgumentNullException("e"); } base.OnMouseDown(e); Battle battle = GetBattle(e.X, e.Y); if (e.Button == MouseButtons.Left) { if (battle != null) { if (battle.IsPassworded) { // hack dialog Program.FormMain using (var form = new AskBattlePasswordForm(battle.Founder.Name)) if (form.ShowDialog() == DialogResult.OK) { ActionHandler.JoinBattle(battle.BattleID, form.Password); } } else { ActionHandler.JoinBattle(battle.BattleID, null); } } else if (OpenGameButtonHitTest(e.X, e.Y)) { ShowHostDialog(KnownGames.GetDefaultGame()); } } else if (e.Button == MouseButtons.Right) { // todo - disable OnMouseMove while this is open to stop battle tooltips floating under it ContextMenus.GetBattleListContextMenu(battle).Show(Parent, e.Location); Program.ToolTip.Visible = false; } }