public GatheringEntry(Chatroom room) { this.mRoom = room; base.Height = 0x16; this.NameLink.Height = 0x16; this.NameLink.AutoSize = true; this.NameLink.Text = room.Description; this.NameLink.Location = DrawUtil.CenterV(this, this.NameLink); this.NameLink.VisitedLinkColor = Color.WhiteSmoke; this.NameLink.LinkColor = Color.WhiteSmoke; this.NameLink.Font = Program.Settings.Appearance.Text.MasterFont; this.NameLink.Click += new EventHandler(this.NameLink_Click); base.Controls.Add(this.NameLink); this.PopulationLabel.AutoSize = true; this.PopulationLabel.Height = 0x16; this.PopulationLabel.Font = Program.Settings.Appearance.Text.MasterFont; this.PopulationLabel.Location = new Point(this.NameLink.Width + 6, DrawUtil.CenterV(this, this.PopulationLabel).Y); base.Controls.Add(this.PopulationLabel); this.Population = this.Room.Population; }
public SkinGatheringDisplay() { EventHandler handler = null; this.ToolTip = new System.Windows.Forms.ToolTip(); this.mCurrentRoom = null; base.TextAlign = ContentAlignment.MiddleLeft; this.HorizontalScalingMode = ScalingModes.Stretch; base.Height = Program.Settings.Appearance.Chat.ChatroomListHeight; base.Width = Program.Settings.Appearance.Chat.ChatroomListWidth; if (handler == null) { handler = delegate (object s, EventArgs e) { if (this.Popup != null) { this.Popup(this, e); } }; } base.Menu.Popup += handler; this.BindToSettings(); }
public static bool Leave() { try { if (((Current != null) && !Current.Equals(None)) && (Lobby.GetLobby() != null)) { string currentName = CurrentName; bool flag = Current.IsDynamic && ((Current.Population - 1) < 1); EventLog.WriteLine("Leaving chatroom {0}", new object[] { Current }); Lobby.GetLobby().chatroomHelper.LeaveChatroom(); mCurrent = None; if (flag) { DataAccess.ExecuteQuery("ClearEmptyDynamicRooms", new object[0]); } if (LeftChat != null) { LeftChat(currentName); } } return true; } catch (Exception exception) { ErrorLog.WriteLine(exception); return false; } }
public static void JoinGame() { Leave(); mCurrent = Game; }
public static bool Join(string chatroom, out string error) { chatroom = chatroom.TrimEnd(" ".ToCharArray()); if (DataAccess.GetBool("IsPlayerBanned", new object[] { User.Current.Name, chatroom })) { error = string.Format(Loc.Get("<LOC>You have been banned from {0}!"), chatroom); return false; } if ((CurrentName != null) && (CurrentName.ToLower() == chatroom.ToLower())) { error = null; RoomOperator = null; return true; } if (chatroom.ToLower().StartsWith("clan") && ((User.Current.ClanName == null) || !chatroom.ToLower().EndsWith(User.Current.ClanName.ToLower()))) { error = Loc.Get("<LOC>Sorry, you cannot join or create a clan chat room unless you are a member of that clan."); EventLog.WriteLine(error, new object[0]); return false; } if (chatroom.ToLower() == None.Description.ToLower()) { error = null; return false; } MappedObjectList<Chatroom> objects = DataAccess.GetObjects<Chatroom>("GetRoomDetails", new object[] { chatroom }); Chatroom chatroom2 = null; if (objects.Count > 0) { chatroom2 = objects[0]; } if (((chatroom2 != null) && chatroom2.IsSecure) && !User.Current.IsAdmin) { string gameDescription = "Unknown"; bool flag = false; foreach (IGameInformation information in GPGnetSelectedGame.GameList) { if (information.GameID == chatroom2.GPGnetGameID) { gameDescription = information.GameDescription; if (information.CDKey != "") { flag = true; } } } if (!flag) { error = string.Format(Loc.Get("<LOC>Could not enter the chat room {0}. You must have an active CD key for {1} to enter this room."), chatroom, gameDescription); return false; } } if (InChatroom) { Leave(); } if (objects.Count > 0) { chatroom2.mIsPersistent = true; if (chatroom2.Population >= MaxRoomSize) { if (!chatroom2.HasDynamicRoot) { error = string.Format(Loc.Get("<LOC>Could not enter the chat room {0}. The chat room is full. Please try again later."), chatroom); return false; } try { DataAccess.ExecuteQuery("ClearEmptyDynamicRooms", new object[0]); MappedObjectList<Chatroom> list2 = DataAccess.GetObjects<Chatroom>("GetDynamicRooms", new object[] { chatroom2.DynamicRoot }); bool flag2 = false; List<int> list3 = new List<int>(); int item = 1; foreach (Chatroom chatroom3 in list2) { if (chatroom3.Population < MaxRoomSize) { chatroom = chatroom3.Description; flag2 = true; break; } list3.Add(item); item++; } if (!flag2) { int num2 = 1; while (num2 < (list3.Count + 2)) { if (!list3.Contains(num2)) { break; } num2++; } if ((MainChatNames == null) || (MainChatNames.Length < (num2 - 1))) { chatroom = string.Format("{0} {1}", chatroom2.DynamicRoot, num2); EventLog.WriteLine("Creating dynamic chatroom {0}", new object[] { chatroom }); if (!DataAccess.ExecuteQuery("CreateMainChatroom", new object[] { num2 })) { error = string.Format(Loc.Get("<LOC>Error creating chatroom {0}."), chatroom); ErrorLog.WriteLine(error, new object[0]); return false; } } else { try { for (int i = 0; i < item; i++) { if (!list3.Contains(i + 1)) { chatroom = MainChatNames[num2]; flag2 = true; break; } } if (flag2) { EventLog.WriteLine("Creating dynamic chatroom {0}", new object[] { chatroom }); if (!DataAccess.ExecuteQuery("CreateMainChatroom1", new object[] { chatroom })) { error = string.Format(Loc.Get("<LOC>Error creating chatroom {0}."), chatroom); ErrorLog.WriteLine(error, new object[0]); return false; } } else { chatroom = string.Format("{0} {1}", chatroom2.DynamicRoot, num2); error = string.Format(Loc.Get("<LOC>Error creating chatroom {0}."), chatroom); ErrorLog.WriteLine(error, new object[0]); return false; } } catch { chatroom = string.Format("{0} {1}", chatroom2.DynamicRoot, num2); EventLog.WriteLine("Creating dynamic chatroom {0}", new object[] { chatroom }); if (!DataAccess.ExecuteQuery("CreateMainChatroom", new object[] { num2 })) { error = string.Format(Loc.Get("<LOC>Error creating chatroom {0}."), chatroom); ErrorLog.WriteLine(error, new object[0]); return false; } } } if (!Create(chatroom, out error)) { ErrorLog.WriteLine(error, new object[0]); return false; } } if (!Lobby.GetLobby().chatroomHelper.JoinChatroom(chatroom)) { ErrorLog.WriteLine("Unable to join {0}.", new object[] { chatroom }); error = string.Format(Loc.Get("<LOC>Unable to join {0}."), chatroom); return false; } EventLog.WriteLine("Joined Chatroom {0}.", new object[] { chatroom }); EventLog.WriteLine("Entering Chatroom {0}.", new object[] { chatroom }); mCurrent = new Chatroom(chatroom, 1, true); error = string.Format(Loc.Get("<LOC>Sorry, that chat room is full. Redirecting you to {0}"), chatroom); RoomOperator = null; return true; } catch (Exception exception) { ErrorLog.WriteLine(exception); ErrorLog.WriteLine("Unable to join {0}", new object[] { chatroom }); error = string.Format(Loc.Get("<LOC>Unable to join {0}."), chatroom); return false; } } if (chatroom2.Population <= 0) { if (!Create(chatroom, out error)) { ErrorLog.WriteLine(error, new object[0]); return false; } if (!Lobby.GetLobby().chatroomHelper.JoinChatroom(chatroom)) { ErrorLog.WriteLine("Unable to join {0}", new object[] { chatroom }); error = string.Format(Loc.Get("<LOC>Unable to join {0}."), chatroom); return false; } EventLog.WriteLine("Joined Chatroom {0}", new object[] { chatroom }); mCurrent = chatroom2; error = null; RoomOperator = null; return true; } if (!Lobby.GetLobby().chatroomHelper.JoinChatroom(chatroom)) { ErrorLog.WriteLine("Unable to join {0}", new object[] { chatroom }); error = string.Format(Loc.Get("<LOC>Unable to join {0}."), chatroom); return false; } EventLog.WriteLine("Joined Chatroom {0}", new object[] { chatroom }); mCurrent = chatroom2; error = null; RoomOperator = null; return true; } if (!DataAccess.GetBool("CustomChannelExists", new object[] { chatroom }) && !Create(chatroom, out error)) { ErrorLog.WriteLine(error, new object[0]); return false; } if (!Lobby.GetLobby().chatroomHelper.JoinChatroom(chatroom)) { ErrorLog.WriteLine("Unable to join {0}", new object[] { chatroom }); error = string.Format(Loc.Get("<LOC>Unable to join {0}."), chatroom); return false; } EventLog.WriteLine("Joined Chatroom {0}", new object[] { chatroom }); mCurrent = new Chatroom(chatroom, 1, false); error = null; RoomOperator = null; return true; }
public void RefreshGatherings(Chatroom[] rooms, bool clearFirst) { EventHandler handler = null; EventHandler handler2 = null; EventHandler handler3 = null; bool flag = clearFirst || (this.RoomCount < 1); if (clearFirst) { base.Menu.MenuItems.Clear(); } for (int i = 0; i < rooms.Length; i++) { if (Chatroom.InChatroom && rooms[i].Equals(Chatroom.Current)) { rooms[i].Population = Chatroom.CurrentPopulation; } if (base.Menu.MenuItems.ContainsKey(rooms[i].Description)) { base.Menu.MenuItems[rooms[i].Description].Text = string.Format("{0} ({1})", rooms[i].Description, rooms[i].Population); if (Program.Settings.Chat.Appearance.ShowChatroomIcons) { (base.Menu.MenuItems[rooms[i].Description] as SkinMenuItem).Icon = this.GetPopulationImage(rooms[i].Population); } } else { SkinMenuItem item = new SkinMenuItem(string.Format("{0} ({1})", rooms[i].Description, rooms[i].Population)); item.Tag = rooms[i]; if (Program.Settings.Chat.Appearance.ShowChatroomIcons) { item.Icon = this.GetPopulationImage(rooms[i].Population); } item.SkinBasePath = @"Controls\Menus\DropDownItem"; item.Name = rooms[i].Description; if (handler == null) { handler = delegate (object s, EventArgs e) { if (this.GatheringSelected != null) { this.GatheringSelected(((s as MenuItem).Tag as Chatroom).Description); } }; } item.Click += handler; base.Menu.MenuItems.Add(item); } } if (flag && ConfigSettings.GetBool("ShowChannels", false)) { SkinMenuItem item2 = new SkinMenuItem(Loc.Get("<LOC>Select Channel...")); item2.SkinBasePath = @"Controls\Menus\DropDownItem"; if (handler2 == null) { handler2 = delegate (object s, EventArgs e) { this.MainForm.ShowDlgSelectChannel(); }; } item2.Click += handler2; base.Menu.MenuItems.Add(item2); SkinMenuItem item3 = new SkinMenuItem(Loc.Get("<LOC>Create Channel...")); item3.SkinBasePath = @"Controls\Menus\DropDownItem"; if (handler3 == null) { handler3 = delegate (object s, EventArgs e) { new DlgCreateChannel(this.MainForm).ShowDialog(); }; } item3.Click += handler3; base.Menu.MenuItems.Add(item3); } }
public void RefreshGatherings(Chatroom[] rooms, bool clearFirst) { if (clearFirst) { this.mFillPanel.Controls.Clear(); this.Entries.Clear(); } this.PopupPanel.Height = (0x16 * rooms.Length) + 4; if (this.PopupForm != null) { this.PopupForm.Height = (0x16 * rooms.Length) + 8; } for (int i = 0; i < rooms.Length; i++) { if (this.Entries.ContainsKey(rooms[i].Description)) { this.Entries[rooms[i].Description].Population = rooms[i].Population; } else { this.Entries[rooms[i].Description] = new GatheringEntry(rooms[i]); this.Entries[rooms[i].Description].Location = new Point(4, ((this.Entries.Count - 1) * 0x16) + 4); this.Entries[rooms[i].Description].GatheringClick += new StringEventHandler(this.GatheringDropDown_GatheringClick); this.mFillPanel.Controls.Add(this.Entries[rooms[i].Description]); } } this.mRoomCount = rooms.Length; }