private void tsbtnMessageSelectedPlayer_Click(object sender, EventArgs e) { string playerName = lbConnectedPlayers.SelectedItem.ToString(); if (m_privateMsgForms.ContainsKey(playerName)) { m_privateMsgForms[playerName].Focus(); } else { Chat_PrivateMsg pmForm = new Chat_PrivateMsg(); pmForm.Text = playerName; pmForm.m_network = m_network; pmForm.m_closeDelegate = OnPrivateMsgClosed; m_privateMsgForms.Add(playerName, pmForm); pmForm.Show(); } }
private void OnNetworkUpdate(Object sender, EventArgs e) { DateTime now = DateTime.Now; NetQueue<F3_ChatLine> messages = m_network.GetMessages(); if (messages.Count > 0) { F3_ChatLine message; while (messages.TryDequeue(out message)) { lbChat.Items.Add(message); lbChat.TopIndex = lbChat.Items.Count - 1; } if (m_bIsPlayerListDirty) { UpdatePlayerList(); m_bIsPlayerListDirty = false; } } NetQueue<NetCommand> commands = m_network.GetCommands(); if (commands.Count > 0) { NetCommand cmd; while (commands.TryDequeue(out cmd)) { if (cmd.GetCommandID() == NetCommandIDs.eCMD_SHUTDOWN) { pShutdown.Visible = true; tsbtnDisconnect.Enabled = false; m_bIsServerShuttingDown = true; m_shutdownSequence.LaunchShutdownSequence(); } if (cmd.GetCommandID() == NetCommandIDs.eCMD_PM_GM) { F3_ChatLine line = (F3_ChatLine)cmd.GetUserData(); string playerName = m_network.FindPlayerByUUID(line.m_senderUUID).GetPlayerName(); if (m_privateMsgForms.ContainsKey(playerName)) { m_privateMsgForms[playerName].OnMsgReceived(line.GetFormatedLine()); } else { //Popup Custom View for chat Chat_PrivateMsg pmForm = new Chat_PrivateMsg(); pmForm.Text = playerName; pmForm.m_network = m_network; pmForm.m_closeDelegate = OnPrivateMsgClosed; pmForm.OnMsgReceived(line.GetFormatedLine()); m_privateMsgForms.Add(playerName, pmForm); pmForm.Show(); } } } } //check autosave if (m_bAutoSaveEnabled) { if (m_lastDate.Day != now.Day) { //We just entered a new day... save logs. SaveLogs(); m_lastDate = now; } } lblTime.Text = now.Hour.ToString("D2") + ":" + now.Minute.ToString("D2") + ":" + now.Second.ToString("D2"); if (m_bIsServerShuttingDown) { TimeSpan t = TimeSpan.FromMilliseconds(m_shutdownSequence.GetRemainingTime()); lblShutDownTime.Text = string.Format("{0:D2}m:{1:D2}s", t.Minutes, t.Seconds); } }