MainFrm.cpp
资源名称:ROA3.40.rar [点击查看]
上传用户:tianheyiqi
上传日期:2010-04-16
资源大小:282k
文件大小:8k
源码类别:
外挂编程
开发平台:
Visual C++
- // MainFrm.cpp : implementation of the CMainFrame class
- //
- #include "stdafx.h"
- #include "ROA.h"
- #include "MainFrm.h"
- #include "ROAView.h"
- #include "DlgOptLog.h"
- #include "DlgOptItemPriority.h"
- #include "DlgOption.h"
- #include "DlgOptEmotion.h"
- #include "DlgSettings.h"
- #include "DlgSetCmn.h"
- #include "DlgSetMvp.h"
- #include "DlgSetPvp.h"
- #include "DlgSetGvg.h"
- #include "DlgShortkey.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- extern CROAApp theApp;
- BOOL RoForeground()
- {
- HWND hwnd;
- hwnd=::GetForegroundWindow();
- char buffer[1024];
- ::GetWindowText(hwnd, buffer, 1024);
- return(strcmp(_T("仙境传说"), buffer) == 0);
- }
- void CMainFrame::OnKeyboard(WPARAM wParam, LPARAM lParam)
- {
- BOOL bKeyDown = !(lParam & 0x80000000);
- if(bConnected && dwAccountId && RoForeground() && bKeyDown && curFunc == NULL)
- {
- EnterCriticalSection(&csShortcutFuncs);
- BYTE vKey = wParam;
- BOOL bCtrlDown, bAltDown, bShiftDown;
- short keyState;
- keyState = GetAsyncKeyState(VK_CONTROL);
- bCtrlDown = !!(keyState & 0x8000);
- keyState = GetAsyncKeyState(VK_MENU);
- bAltDown = !!(keyState & 0x8000);
- keyState = GetAsyncKeyState(VK_SHIFT);
- bShiftDown = !!(keyState & 0x8000);
- switch(vKey)
- {
- case 'C':
- if(bCtrlDown && !bShiftDown && !bAltDown)
- {
- curFunc = ufShowCarts;
- curFuncPara = 0;
- }
- break;
- case 'W':
- if(bCtrlDown && !bShiftDown && !bAltDown)
- {
- curFunc = ufShowServerIp;
- curFuncPara = 0;
- }
- break;
- case VK_HOME:
- if(!bCtrlDown && !bShiftDown && !bAltDown)
- {
- curFunc = ufPopupRoaWindow;
- curFuncPara = eWindowOption;
- }
- break;
- case VK_TAB:
- if(!bCtrlDown && !bShiftDown && !bAltDown)
- {
- curFunc = UFENTRY[userfuncs[10]];
- }
- break;
- case 48:
- if(bCtrlDown && !bShiftDown && !bAltDown)
- {
- curFunc = UFENTRY[userfuncs[9]];
- }
- if(bCtrlDown && bShiftDown && !bAltDown)
- {
- curFunc = ufShowEmotion;
- curFuncPara = 0;
- }
- break;
- case 49:
- case 50:
- case 51:
- case 52:
- case 53:
- case 54:
- case 55:
- case 56:
- case 57:
- if(bCtrlDown && !bShiftDown && !bAltDown)
- {
- curFunc = UFENTRY[userfuncs[vKey-49]];
- curFuncPara = 2;
- }
- if(bCtrlDown && bShiftDown && !bAltDown)
- {
- curFunc = ufShowEmotion;
- curFuncPara = vKey - 48;
- }
- break;
- case 77:
- if(bCtrlDown && !bShiftDown && !bAltDown)
- curFunc = ufShowMonsters;
- break;
- case 73:
- if(bCtrlDown && !bShiftDown && !bAltDown)
- curFunc = ufShowInventory;
- break;
- case 80:
- if(bCtrlDown && !bShiftDown && !bAltDown)
- curFunc = ufShowPlayers;
- break;
- case 191:
- if(bCtrlDown && !bShiftDown && !bAltDown)
- curFunc = ufShowStatus;
- break;
- case 192:
- if(!bCtrlDown && !bShiftDown && !bAltDown)
- curFunc = UFENTRY[userfuncs[11]];
- break;
- case 219:
- if(bCtrlDown && !bShiftDown && !bAltDown)
- {
- curFunc = ufSpeedDown;
- }
- break;
- case 221:
- if(bCtrlDown && !bShiftDown && !bAltDown)
- {
- curFunc = ufSpeedUp;
- }
- break;
- }
- LeaveCriticalSection(&csShortcutFuncs);
- }
- return;
- }
- //////////////////////////////////////////////////////////////////////////////
- // CMainFrame
- IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
- BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
- //{{AFX_MSG_MAP(CMainFrame)
- ON_WM_CREATE()
- ON_COMMAND(IDD_OPT_LOG, OnOptLog)
- ON_WM_CLOSE()
- ON_COMMAND(IDD_OPT_ITEMPRIORITY, OnOptItempriority)
- ON_UPDATE_COMMAND_UI(IDD_MISC_SETTING, OnUpdateMiscSetting)
- ON_UPDATE_COMMAND_UI(ID_MNU_SETTINGS, OnUpdateMnuSettings)
- ON_COMMAND(ID_MNU_EMOTIONS, OnMnuEmotions)
- ON_UPDATE_COMMAND_UI(IDD_OPT_LOG, OnUpdateOptLog)
- ON_COMMAND(IDD_MNU_OPTION, OnMnuOption)
- ON_COMMAND(ID_MNU_SETTINGS, OnMnuSettings)
- ON_WM_SIZE()
- ON_WM_TIMER()
- ON_COMMAND_EX(ID_VIEW_MAP, OnBarCheck )
- ON_UPDATE_COMMAND_UI(ID_VIEW_MAP, OnUpdateControlBarMenu)
- ON_COMMAND_EX(ID_VIEW_YOUR_STATUS, OnBarCheck )
- ON_UPDATE_COMMAND_UI(ID_VIEW_YOUR_STATUS, OnUpdateControlBarMenu)
- ON_COMMAND_EX(IDD_VIEW_ENV, OnBarCheck )
- ON_UPDATE_COMMAND_UI(IDD_VIEW_ENV, OnUpdateControlBarMenu)
- ON_COMMAND_EX(IDD_VIEW_CHATLOG, OnBarCheck )
- ON_UPDATE_COMMAND_UI(IDD_VIEW_CHATLOG, OnUpdateControlBarMenu)
- ON_COMMAND_EX(ID_VIEW_MENUBAR, OnBarCheck )
- ON_UPDATE_COMMAND_UI(ID_VIEW_MENUBAR, OnUpdateControlBarMenu)
- ON_COMMAND(ID_MNU_SHORTKEY, OnMnuShortkey)
- //}}AFX_MSG_MAP
- ON_MESSAGE(WM_USER+2500, OnKeyboard)
- END_MESSAGE_MAP()
- static UINT indicators[] =
- {
- ID_SEPARATOR, // status line indicator
- ID_INDICATOR_CAPS,
- ID_INDICATOR_NUM,
- ID_INDICATOR_SCRL,
- };
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame construction/destruction
- CMainFrame::CMainFrame()
- {
- // TODO: add member initialization code here
- }
- CMainFrame::~CMainFrame()
- {
- }
- int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
- llFile = eLogNone;
- llDlg = eLogNone;
- llRo = eLogNone;
- SetWindowText(_T("天外仙境"));
- return 0;
- }
- BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
- {
- if( !CFrameWnd::PreCreateWindow(cs) )
- return FALSE;
- cs.lpszClass = AfxRegisterWndClass(0, NULL, NULL,
- AfxGetApp()->LoadIcon(IDR_MAINFRAME));
- cs.style &= ~FWS_ADDTOTITLE;
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame diagnostics
- #ifdef _DEBUG
- void CMainFrame::AssertValid() const
- {
- CFrameWnd::AssertValid();
- }
- void CMainFrame::Dump(CDumpContext& dc) const
- {
- CFrameWnd::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame message handlers
- void CMainFrame::OnOptLog()
- {
- // TODO: Add your command handler code here
- CDlgOptLog dlg;
- bIsModal = true;
- dlg.DoModal();
- bIsModal = false;
- }
- void CMainFrame::OnClose()
- {
- // TODO: Add your message handler code here and/or call default
- // if(IDYES == MessageBox("是否确定退出ROA?", "ROA", MB_YESNO|MB_ICONQUESTION))
- {
- if(pWorkingThread)
- {
- nThreadTerm = 1;
- utlLogout("与仙境传说客户端断开连接...", eLogCommon, false);
- if(pWorkingThread)
- WaitForSingleObject(pWorkingThread->m_hThread, INFINITE);
- }
- WSACleanup();
- fLog.Close();
- CFrameWnd::OnClose();
- }
- }
- void CMainFrame::OnOptItempriority()
- {
- // TODO: Add your command handler code here
- CDlgOptItemPriority dlg;
- bIsModal = true;
- dlg.DoModal();
- bIsModal = false;
- }
- void CMainFrame::OnUpdateMiscSetting(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->Enable(nConnState >= 4);
- }
- void CMainFrame::OnMnuOption()
- {
- // TODO: Add your command handler code here
- CDlgOption dlgOption(true);
- bIsModal = true;
- dlgOption.m_option = option;
- if(dlgOption.DoModal() == IDOK)
- {
- option = dlgOption.m_option;
- utlSaveOption(option);
- }
- utlParseHpSpItems();
- bIsModal = false;
- }
- void CMainFrame::OnMnuSettings()
- {
- // TODO: Add your command handler code here
- CDlgSettings dlgSetting(_T("战斗设定"));
- CDlgSetCmn dlgCmn;
- CDlgSetMvp dlgMvp;
- CDlgSetPvp dlgPvp;
- CDlgSetGvg dlgGvg;
- dlgCmn.m_settingcmn = settingcmn;
- dlgMvp.m_settingmvp = settingmvp;
- dlgSetting.AddPage(&dlgCmn);
- dlgSetting.AddPage(&dlgMvp);
- // dlgSetting.AddPage(&dlgPvp);
- // dlgSetting.AddPage(&dlgGvg);
- bIsModal = true;
- if(IDOK == dlgSetting.DoModal())
- {
- settingcmn = dlgCmn.m_settingcmn;
- settingmvp = dlgMvp.m_settingmvp;
- utlWriteUserProfile();
- }
- bIsModal = false;
- return;
- }
- void CMainFrame::OnUpdateMnuSettings(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->Enable(strlen(you.cName) > 0);
- }
- void CMainFrame::OnMnuEmotions()
- {
- // TODO: Add your command handler code here
- CDlgOptEmotion dlgEmotion;
- bIsModal = true;
- if(dlgEmotion.DoModal() == IDOK)
- {
- utlSaveOption(option);
- }
- bIsModal = false;
- }
- void CMainFrame::OnUpdateOptLog(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- #ifdef VIPMODE
- pCmdUI->Enable(true);
- #else
- pCmdUI->Enable(false);
- #endif
- }
- void CMainFrame::OnMnuShortkey()
- {
- // TODO: Add your command handler code here
- CDlgShortkey dlgKey;
- bIsModal = true;
- if(IDOK == dlgKey.DoModal())
- {
- utlWriteUserProfile();
- }
- bIsModal = false;
- }