// WhisperDlg.cpp : ±¸Çö ÆÄÀÏÀÔ´Ï´Ù. // #include "stdafx.h" #include "MonitoringTool.h" #include "WhisperDlg.h" #include "ChattingPage.h" #include "GlobalFunc.h" #include "MonitoringToolSetup.h" #include "ChatServerEventHandler.h" #include #include // CWhisperDlg ´ëÈ­ »óÀÚÀÔ´Ï´Ù. IMPLEMENT_DYNAMIC(CWhisperDlg, CDialog) CWhisperDlg::CWhisperDlg(CWnd* pParent, WhisperDlgInfo stInfo) : CDialog(CWhisperDlg::IDD, pParent) , m_strWhisperTitle(_T("")) { m_pParent = pParent; CopyMemory(&m_stWhisperDlgInfo, &stInfo, sizeof(WhisperDlgInfo)); IsWhisperDlgSet = true; } CWhisperDlg::CWhisperDlg() : CDialog(CWhisperDlg::IDD) { IsWhisperDlgSet = false; } CWhisperDlg::~CWhisperDlg() { } void CWhisperDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_WHISPER_OUTPUT, m_ctrlWhisperOutput); DDX_Text(pDX, IDC_WHISPER_TITLE, m_strWhisperTitle); DDX_Control(pDX, IDC_SENDBYUID_CHK, m_ctrlSendByUIDChk); } BEGIN_MESSAGE_MAP(CWhisperDlg, CDialog) ON_WM_CLOSE() ON_BN_CLICKED(IDC_WHISPER_SEND, OnBnClickedWhisperSend) END_MESSAGE_MAP() // CWhisperDlg ¸Þ½ÃÁö 󸮱âÀÔ´Ï´Ù. BOOL CWhisperDlg::OnInitDialog() { CDialog::OnInitDialog(); SetDlgItemText(IDC_WHISPER_TITLE_STATIC, GetMyINIString("LOCAL_STRING", "STRING_021")); SetDlgItemText(IDC_WHISPER_TRGT_TYPE, GetMyINIString("LOCAL_STRING", "STRING_022")); SetDlgItemText(IDC_WHISPER_LOGINEDNAME_STATIC, GetMyINIString("LOCAL_STRING", "STRING_047")); SetDlgItemText(IDC_WHISPER_SEND, GetMyINIString("LOCAL_STRING", "STRING_017")); SetDlgItemText(IDC_PACKET_TIME, ""); bool IsEnable = false; char strRace[4][4] = {"N/A", "H", "A", "N/A"}; if (WhisperDlgInfo::WHISPER_TYPE_CLK == m_stWhisperDlgInfo.m_nDlgType) { m_strWhisperTitle.Format("[%s] (UID: %u / CID: %u / Race : %s) %s", m_stWhisperDlgInfo.m_szServerName, m_stWhisperDlgInfo.m_dwUID, m_stWhisperDlgInfo.m_dwCID, strRace[m_stWhisperDlgInfo.m_cRace], m_stWhisperDlgInfo.m_szCharName); SetWindowText(m_stWhisperDlgInfo.m_szCharName); IsEnable = false; } else if (WhisperDlgInfo::FINDUSER == m_stWhisperDlgInfo.m_nDlgType) { SetDlgItemText(IDC_WHISPER_TITLE, GetMyINIString("LOCAL_STRING", "STRING_023")); SetWindowText(GetMyINIString("LOCAL_STRING", "STRING_023")); IsEnable = true; } SetDlgItemText(IDC_WHIS_SENDER_EDIT, theApp.GetLoginedName()); GetDlgItem(IDC_WHISPER_TARGET)->EnableWindow(IsEnable); GetDlgItem(IDC_SENDBYUID_CHK)->EnableWindow(IsEnable); UpdateData(false); return TRUE; } void CWhisperDlg::OnBnClickedWhisperSend() { CString strServerName, strGMName, strMsg; strServerName.Format("%s", m_stWhisperDlgInfo.m_szServerName); // ¼­¹ö ±×·ì ¸í strGMName = theApp.GetLoginedName(); // GM¸í GetDlgItemText(IDC_WHISPER_INPUT, strMsg); // ¸Þ¼¼Áö bool IsSended = false; if (BST_UNCHECKED == ((CChattingPage*)m_pParent)->IsDlgButtonChecked(IDC_GMLOGINED_CHK)) { MessageBox(GetMyINIString("LOCAL_STRING", "STRING_046")); IsSended = false; } else { // ÀÏ¹Ý ´ëÈ­ ¸ðµå (¸®½ºÆ®¹Ú½º ´õºí Ŭ¸¯) if ((true == IsWhisperDlgSet) && (WhisperDlgInfo::WHISPER_TYPE_CLK == m_stWhisperDlgInfo.m_nDlgType)) { IsSended = ClientNet::CChatServerEventHandler::SendChatReqPkt( theApp.GetServerIndex(strServerName), PktChat::WHISPER, ChatToolPkt::TARGET_CHARNAME, 0, 0, strGMName, m_stWhisperDlgInfo.m_szCharName, strMsg); } // °èÁ¤¸íÀ¸·Î ´ëÈ­ ¸ðµå (Á÷Á¢ °èÁ¤Á¤º¸ ÀÔ·Â) else { CString strTarget; GetDlgItemText(IDC_WHISPER_TARGET, strTarget); char szKey[256]; CMonitoringToolSetup Setup = CMonitoringToolSetup::GetInstance(); unsigned int nMaxGroupNum = Setup.GetInt(_T("SERVER_GROUP_INFO"), _T("SERVER_GROUP_NUM")); for(int nIndex = 0; nIndex < (int)nMaxGroupNum; ++nIndex) { unsigned long dwDlgID = ((CChattingPage*)m_pParent)->GetAccountDlgID(); _snprintf(szKey, 256, "SERVER_GROUP_INDEX_%02d", nIndex); unsigned int nServerGroup = Setup.GetInt("SERVER_GROUP_INFO", szKey); if (BST_CHECKED != m_ctrlSendByUIDChk.GetCheck()) { IsSended = ClientNet::CChatServerEventHandler::SendChatReqPkt( nServerGroup, PktChat::WHISPER, ChatToolPkt::TARGET_ACCOUNTNAME, 0, dwDlgID, strGMName, strTarget, strMsg); // ·Î±×¸¦ ¸ð´ÏÅ͸µ Åø¿¡ ³²±â±â À§Çؼ­ ¸¸µç´Ù. //CMonitoringToolLog::GetInstance().WriteAdminLog(nServerGroup, PktChat::WHISPER, strGMName, strTarget, strMsg); } else { IsSended = ClientNet::CChatServerEventHandler::SendChatReqPkt( nServerGroup, PktChat::WHISPER, ChatToolPkt::TARGET_UID, (unsigned long)atoi(strTarget), dwDlgID, strGMName, _T(""), strMsg); // ·Î±×¸¦ ¸ð´ÏÅ͸µ Åø¿¡ ³²±â±â À§Çؼ­ ¸¸µç´Ù. //CMonitoringToolLog::GetInstance().WriteAdminLog(nServerGroup, PktChat::WHISPER, strGMName, strTarget, strMsg); } } } } if (true == IsSended) { SetDlgItemText(IDC_WHISPER_INPUT, _T("")); GetDlgItem(IDC_WHISPER_TARGET)->EnableWindow(false); GetDlgItem(IDC_SENDBYUID_CHK)->EnableWindow(false); } else { theApp.ReportResult(GetMyINIString("LOCAL_STRING", "STRING_026")); } } BOOL CWhisperDlg::PreTranslateMessage(MSG* pMsg) { if ((pMsg->message == WM_KEYDOWN) && (pMsg->wParam == VK_RETURN)) { if ((pMsg->hwnd == GetDlgItem(IDC_WHISPER_INPUT)->m_hWnd)) { OnBnClickedWhisperSend(); } } return CDialog::PreTranslateMessage(pMsg); } void CWhisperDlg::OnOK() { } void CWhisperDlg::OnClose() { DestroyWindow(); } void CWhisperDlg::OnCancel() { DestroyWindow(); } void CWhisperDlg::PostNcDestroy() { if(m_stWhisperDlgInfo.m_nDlgType == WhisperDlgInfo::WHISPER_TYPE_CLK) { CChattingPage::WhisperDlgMap::iterator pos1 = ((CChattingPage*)m_pParent)->m_WhisperDlgMap.find(m_stWhisperDlgInfo.m_dwUID); if (pos1 != ((CChattingPage*)m_pParent)->m_WhisperDlgMap.end()) { ((CChattingPage*)m_pParent)->m_WhisperDlgMap.erase(pos1); } } CChattingPage::WhisperDlgMap::iterator pos2 = ((CChattingPage*)m_pParent)->m_AccountDlgMap.find(m_stWhisperDlgInfo.m_dwDlgID); if (pos2 != ((CChattingPage*)m_pParent)->m_AccountDlgMap.end()) { ((CChattingPage*)m_pParent)->m_AccountDlgMap.erase(pos2); } delete this; } /// \brief äÆÃÆÐŶÀ» ÆÄ½ÌÇÏ¿© ´ëȭâ¿¡ Ç¥½Ã /// \param lpChatData äÆÃ ÆÐŶ void CWhisperDlg::ParseChatData(ChatToolPkt::ChatDataSend* lpChatData) { char strRecvMsg[UCHAR_MAX * 2]; CString strOutput; char szTime[32]; char szDate[32]; _tzset(); _tstrdate( szDate ); _tstrtime( szTime ); memcpy(strRecvMsg, reinterpret_cast(lpChatData + 1), lpChatData->m_cChatMsgLen); strRecvMsg[lpChatData->m_cChatMsgLen] = 0; strOutput.Format("[%s-%s] %s : %s", szDate, szTime, lpChatData->m_szSenderName, strRecvMsg); int nIndex = m_ctrlWhisperOutput.AddString(strOutput); // ÀÚµ¿ ½ºÅ©·Ñ int nMaxLine = 27; // 1´ë1 ´ëȭâ ¸®½ºÆ®¹Ú½º ÃÖ´ë ¶óÀμö if (nIndex >= nMaxLine) { m_ctrlWhisperOutput.SetTopIndex(nIndex); } strOutput.Format("Time : %s-%s", szDate, szTime); SetDlgItemText(IDC_PACKET_TIME, strOutput); } void CWhisperDlg::SetKeyUID(unsigned long dwUID, unsigned long dwCID) { m_stWhisperDlgInfo.m_dwUID = dwUID; m_stWhisperDlgInfo.m_dwCID = dwCID; if (NULL == ((CChattingPage*)m_pParent)->GetWhisperDlg(dwUID)) { ((CChattingPage*)m_pParent)->m_WhisperDlgMap.insert(CChattingPage::WhisperDlgMap::value_type(dwUID, this)); CChattingPage::WhisperDlgMap::iterator pos = ((CChattingPage*)m_pParent)->m_AccountDlgMap.find(m_stWhisperDlgInfo.m_dwDlgID); ((CChattingPage*)m_pParent)->m_AccountDlgMap.erase(pos); CString strTitle; strTitle.Format("%u", dwUID); SetWindowText(strTitle); } }