public void UpdateStartingLocationTexts() { foreach (PlayerLocationIndicator indicator in startingLocationIndicators) { indicator.Players.Clear(); } foreach (PlayerInfo pInfo in players) { if (pInfo.StartingLocation > 0) { startingLocationIndicators[pInfo.StartingLocation - 1].Players.Add(pInfo); } } foreach (PlayerInfo aiInfo in aiPlayers) { if (aiInfo.StartingLocation > 0) { startingLocationIndicators[aiInfo.StartingLocation - 1].Players.Add(aiInfo); } } foreach (PlayerLocationIndicator indicator in startingLocationIndicators) { indicator.Refresh(); } contextMenu.ClearItems(); int id = 1; var playerList = players.Concat(aiPlayers).ToList(); for (int i = 0; i < playerList.Count; i++) { PlayerInfo pInfo = playerList[i]; string text = pInfo.Name; if (pInfo.TeamId > 0) { text = teamIds[pInfo.TeamId] + text; } int index = i; XNAContextMenuItem item = new XNAContextMenuItem() { Text = id + ". " + text, TextColor = pInfo.ColorId > 0 ? mpColors[pInfo.ColorId - 1].XnaColor : Color.White, SelectAction = () => ContextMenu_OptionSelected(index), }; contextMenu.AddItem(item); id++; } }
public void UpdateStartingLocationTexts() { foreach (PlayerLocationIndicator indicator in startingLocationIndicators) { indicator.Players.Clear(); } foreach (PlayerInfo pInfo in players) { if (pInfo.StartingLocation > 0) { startingLocationIndicators[pInfo.StartingLocation - 1].Players.Add(pInfo); } } foreach (PlayerInfo aiInfo in aiPlayers) { if (aiInfo.StartingLocation > 0) { startingLocationIndicators[aiInfo.StartingLocation - 1].Players.Add(aiInfo); } } foreach (PlayerLocationIndicator indicator in startingLocationIndicators) { indicator.Refresh(); } contextMenu.ClearItems(); int id = 1; foreach (PlayerInfo pInfo in players.Concat(aiPlayers)) { string text = pInfo.Name; if (pInfo.TeamId > 0) { text = teamIds[pInfo.TeamId] + text; } contextMenu.AddItem(id + ". " + text, pInfo.ColorId > 0 ? mpColors[pInfo.ColorId - 1].XnaColor : Color.White); id++; } }
public override void Initialize() { Name = "PrivateMessagingWindow"; ClientRectangle = new Rectangle(0, 0, 600, 600); BackgroundTexture = AssetLoader.LoadTextureUncached("privatemessagebg.png"); unknownGameIcon = AssetLoader.TextureFromImage(ClientCore.Properties.Resources.unknownicon); adminGameIcon = AssetLoader.TextureFromImage(ClientCore.Properties.Resources.cncneticon); personalMessageColor = AssetLoader.GetColorFromString(ClientConfiguration.Instance.SentPMColor); otherUserMessageColor = AssetLoader.GetColorFromString(ClientConfiguration.Instance.ReceivedPMColor); lblPrivateMessaging = new XNALabel(WindowManager); lblPrivateMessaging.Name = "lblPrivateMessaging"; lblPrivateMessaging.FontIndex = 1; lblPrivateMessaging.Text = "PRIVATE MESSAGING"; AddChild(lblPrivateMessaging); lblPrivateMessaging.CenterOnParent(); lblPrivateMessaging.ClientRectangle = new Rectangle( lblPrivateMessaging.X, 12, lblPrivateMessaging.Width, lblPrivateMessaging.Height); tabControl = new XNAClientTabControl(WindowManager); tabControl.Name = "tabControl"; tabControl.ClientRectangle = new Rectangle(60, 50, 0, 0); tabControl.ClickSound = new EnhancedSoundEffect("button.wav"); tabControl.FontIndex = 1; tabControl.AddTab("Messages", 160); tabControl.AddTab("Friend List", 160); tabControl.AddTab("All Players", 160); tabControl.SelectedIndexChanged += TabControl_SelectedIndexChanged; lblPlayers = new XNALabel(WindowManager); lblPlayers.Name = "lblPlayers"; lblPlayers.ClientRectangle = new Rectangle(12, tabControl.Bottom + 24, 0, 0); lblPlayers.FontIndex = 1; lblPlayers.Text = "PLAYERS:"; lbUserList = new XNAListBox(WindowManager); lbUserList.Name = "lbUserList"; lbUserList.ClientRectangle = new Rectangle(lblPlayers.X, lblPlayers.Bottom + 6, 150, Height - lblPlayers.Bottom - 18); lbUserList.RightClick += LbUserList_RightClick; lbUserList.SelectedIndexChanged += LbUserList_SelectedIndexChanged; lbUserList.BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1); lbUserList.PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED; lblMessages = new XNALabel(WindowManager); lblMessages.Name = "lblMessages"; lblMessages.ClientRectangle = new Rectangle(lbUserList.Right + 12, lblPlayers.Y, 0, 0); lblMessages.FontIndex = 1; lblMessages.Text = "MESSAGES:"; lbMessages = new ChatListBox(WindowManager); lbMessages.Name = "lbMessages"; lbMessages.ClientRectangle = new Rectangle(lblMessages.X, lbUserList.Y, Width - lblMessages.X - 12, lbUserList.Height - 25); lbMessages.BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1); lbMessages.PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED; tbMessageInput = new XNATextBox(WindowManager); tbMessageInput.Name = "tbMessageInput"; tbMessageInput.ClientRectangle = new Rectangle(lbMessages.X, lbMessages.Bottom + 6, lbMessages.Width, 19); tbMessageInput.EnterPressed += TbMessageInput_EnterPressed; tbMessageInput.MaximumTextLength = 200; tbMessageInput.Enabled = false; playerContextMenu = new XNAContextMenu(WindowManager); playerContextMenu.Name = "playerContextMenu"; playerContextMenu.ClientRectangle = new Rectangle(0, 0, 150, 2); playerContextMenu.Enabled = false; playerContextMenu.Visible = false; playerContextMenu.AddItem("Add Friend", PlayerContextMenu_ToggleFriend); notificationBox = new PrivateMessageNotificationBox(WindowManager); notificationBox.Enabled = false; notificationBox.Visible = false; notificationBox.LeftClick += NotificationBox_LeftClick; AddChild(tabControl); AddChild(lblPlayers); AddChild(lbUserList); AddChild(lblMessages); AddChild(lbMessages); AddChild(tbMessageInput); AddChild(playerContextMenu); WindowManager.AddAndInitializeControl(notificationBox); base.Initialize(); CenterOnParent(); tabControl.SelectedTab = 0; connectionManager.PrivateMessageReceived += ConnectionManager_PrivateMessageReceived; sndMessageSound = new EnhancedSoundEffect("message.wav"); sndPrivateMessageSound = new EnhancedSoundEffect("pm.wav"); sndMessageSound.Enabled = UserINISettings.Instance.MessageSound; GameProcessLogic.GameProcessExited += SharedUILogic_GameProcessExited; }