DlgOption.cpp
资源名称:ROA3.40.rar [点击查看]
上传用户:tianheyiqi
上传日期:2010-04-16
资源大小:282k
文件大小:9k
源码类别:
外挂编程
开发平台:
Visual C++
- // DlgOption.cpp : implementation file
- //
- #include "stdafx.h"
- #include "roa.h"
- #include "DlgOption.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CDlgOption dialog
- CDlgOption::CDlgOption(BOOL bInRoa, CWnd* pParent /*=NULL*/)
- : CDialog(CDlgOption::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CDlgOption)
- //}}AFX_DATA_INIT
- m_bShowAdvanced = false;
- m_bInRoa = bInRoa;
- }
- void CDlgOption::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CDlgOption)
- //}}AFX_DATA_MAP
- DDX_Radio(pDX, IDC_RAD_SERVER_OFFICAL, m_option.bTestServer);
- GetDlgItem(IDC_EDT_LAUNCHER_PARAM)->EnableWindow(m_option.bTestServer);
- if(m_option.bTestServer)
- SetDlgItemText(IDC_STATIC_ROEXE, _T("客户端启动程序: (请选择Sakexe.exe)"));
- else
- SetDlgItemText(IDC_STATIC_ROEXE, _T("客户端启动程序: (请选择RoClient.exe或SakClient.exe)"));
- DDX_Check(pDX, IDC_CHK_USEPARTYCHAT, m_option.bUsePartyChat);
- DDX_Check(pDX, IDC_CHK_AUTOPICK, m_option.bAutoPickup);
- GetDlgItem(IDC_CHK_MOVEPICKUP)->EnableWindow(m_option.bAutoPickup);
- DDX_Check(pDX, IDC_CHK_BOSSINFO, m_option.bBossInfo);
- DDX_Check(pDX, IDC_CHK_MOVEPICKUP, m_option.bMovePickup);
- DDX_Text(pDX, IDC_EDT_LAUNCHER, m_option.strLauncher);
- DDX_Text(pDX, IDC_EDT_LAUNCHER_PARAM, m_option.strLaunchParam);
- DDX_Check(pDX, IDC_CHK_NPC_AUTOCONTINUE, m_option.bNpcTalkContinue);
- DDX_Text(pDX, IDC_EDT_WELCOMEDELAY, m_option.nWelcomeDelay);
- DDX_Text(pDX, IDC_EDT_AUTOSEARCHDELAY, m_option.nAutoSearchDelay);
- DDX_Text(pDX, IDC_EDT_ATTACKPERSECOND, m_option.nAttackPerSecond);
- DDX_Text(pDX, IDC_EDT_PICKUPDISTANCE, m_option.nPickupDistance);
- DDX_Text(pDX, IDC_EDT_HPITEMS, m_option.strHPRecoverItems);
- DDX_Text(pDX, IDC_EDT_SPITEMS, m_option.strSPRecoverItems);
- DDX_Text(pDX, IDC_EDT_ITEMUSEINTERVAL, m_option.nItemUseInterval);
- }
- BEGIN_MESSAGE_MAP(CDlgOption, CDialog)
- //{{AFX_MSG_MAP(CDlgOption)
- ON_BN_CLICKED(IDC_CHK_AUTOPICK, OnChkAutopick)
- ON_BN_CLICKED(IDC_BTN_BROWSE, OnBtnBrowse)
- ON_BN_CLICKED(IDC_BTN_ADVANCEOPTION, OnBtnAdvanceoption)
- ON_BN_CLICKED(IDC_RAD_SERVER_TEST, OnRadServerTest)
- ON_BN_CLICKED(IDC_RAD_SERVER_OFFICAL, OnRadServerOffical)
- ON_BN_CLICKED(IDC_BTN_CANCEL, OnBtnCancel)
- ON_BN_CLICKED(IDC_BTN_RESTORE, OnBtnRestore)
- ON_EN_CHANGE(IDC_EDT_README, OnChangeEdtReadme)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CDlgOption message handlers
- BOOL CDlgOption::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: Add extra initialization here
- UpdateData(false);
- CString strTemp;
- strTemp = _T("Ragnarok Online Addin 3.40 by OUTMANrn");
- strTemp += _T("-----------------------------------------------rn");
- strTemp += _T("* 请勿用于官方服务器,如不同意请马上退出本程序rn");
- strTemp += _T("* 已全面支持Windows 98/ME/2000/XP/2003rn");
- strTemp += _T("* 更新信息请参照version.txtrn");
- strTemp += _T("-----------------------------------------------rn");
- strTemp += _T("* http://www.yxzone.comrn");
- GetDlgItem(IDC_EDT_README)->SetWindowText(strTemp);
- ShowAdvancedOption();
- GetDlgItem(IDC_BTN_RESTORE)->EnableWindow(!m_bInRoa);
- GetDlgItem(IDC_RAD_SERVER_OFFICAL)->EnableWindow(!m_bInRoa);
- GetDlgItem(IDC_RAD_SERVER_TEST)->EnableWindow(!m_bInRoa);
- GetDlgItem(IDC_STATIC_ROEXE)->EnableWindow(!m_bInRoa);
- GetDlgItem(IDC_EDT_LAUNCHER)->EnableWindow(!m_bInRoa);
- GetDlgItem(IDC_BTN_BROWSE)->EnableWindow(!m_bInRoa);
- GetDlgItem(IDC_EDT_LAUNCHER_PARAM)->EnableWindow(!m_bInRoa);
- GetDlgItem(IDC_STATIC_SFEXE)->EnableWindow(!m_bInRoa);
- GetDlgItem(IDC_BTN_CANCEL)->EnableWindow(!m_bInRoa);
- /* if(!m_bInRoa)
- {
- if(IDYES == MessageBox(_T("是否先恢复RO客户端?(从ROA3.31以下版本升级用户请先恢复RO客户端)"), _T("恢复客户端"), MB_YESNO | MB_ICONQUESTION))
- {
- OnBtnRestore();
- }
- }
- */
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CDlgOption::OnOK()
- {
- // TODO: Add extra validation here
- UpdateData(true);
- CDialog::OnOK();
- }
- void CDlgOption::OnChkAutopick()
- {
- // TODO: Add your control notification handler code here
- UpdateData(true);
- }
- void CDlgOption::OnBtnBrowse()
- {
- // TODO: Add your control notification handler code here
- static char BASED_CODE szFilter[] = "Executable Files (*.exe)|*.exe||";
- CFileDialog dlgFile(true, ".exe", "RoClient.exe", OFN_HIDEREADONLY, szFilter, this);
- char buffer[1024];
- GetCurrentDirectory(1024, buffer);
- if(IDOK == dlgFile.DoModal())
- {
- UpdateData(true);
- m_option.strLauncher = dlgFile.GetPathName();
- if(m_option.strLauncher.Right(4).CompareNoCase(_T(".exe")) != 0)
- {
- m_option.strLauncher += _T(".exe");
- }
- UpdateData(false);
- }
- SetCurrentDirectory(buffer);
- }
- void CDlgOption::ShowAdvancedOption()
- {
- WINDOWPLACEMENT wndpl;
- GetWindowPlacement(&wndpl);
- if(m_bShowAdvanced)
- {
- SetDlgItemText(IDC_BTN_ADVANCEOPTION, _T("高级选项<<<"));
- wndpl.rcNormalPosition.bottom = wndpl.rcNormalPosition.top + 495;
- }
- else
- {
- SetDlgItemText(IDC_BTN_ADVANCEOPTION, _T("高级选项>>>"));
- wndpl.rcNormalPosition.bottom = wndpl.rcNormalPosition.top + 388;
- }
- SetWindowPlacement(&wndpl);
- }
- void CDlgOption::OnBtnAdvanceoption()
- {
- // TODO: Add your control notification handler code here
- m_bShowAdvanced = !m_bShowAdvanced;
- ShowAdvancedOption();
- }
- void CDlgOption::OnRadServerTest()
- {
- // TODO: Add your control notification handler code here
- UpdateData(true);
- }
- void CDlgOption::OnRadServerOffical()
- {
- // TODO: Add your control notification handler code here
- UpdateData(true);
- }
- void CDlgOption::OnBtnCancel()
- {
- // TODO: Add your control notification handler code here
- CDialog::OnCancel();
- }
- int CDlgOption::RestoreFile(LPCTSTR lpszPath, LPCTSTR lpszRestore)
- {
- CString strRoaExec, strRoExec, strOutput = _T("");
- int nRet = -1;
- strRoExec.Format(_T("%s%s"), lpszPath, lpszRestore);
- if(utlGetFileSize(strRoExec) < 100000)
- {
- strRoaExec.Format(_T("%sROA%s"), lpszPath, lpszRestore);
- if(utlGetFileSize(strRoaExec) > 100000)
- {
- ::CopyFile(strRoaExec, strRoExec, false);
- ::DeleteFile(strRoaExec);
- strRoaExec.Format(_T("%s%s.dat"), lpszPath, lpszRestore);
- ::DeleteFile(strRoaExec);
- nRet = 1;
- }
- else
- {
- strRoaExec.Format(_T("%s%s.dat"), lpszPath, lpszRestore);
- if(utlGetFileSize(strRoaExec) > 100000)
- {
- ::CopyFile(strRoaExec, strRoExec, false);
- ::DeleteFile(strRoaExec);
- nRet = 2;
- }
- }
- }
- else
- {
- nRet = 0;
- }
- switch(nRet)
- {
- case -1:
- strOutput.Format(_T("无法恢复%s"), strRoExec);
- break;
- case 0:
- break;
- case 1:
- strOutput.Format(_T("从ROA3.30以上版本恢复%s"), strRoExec);
- break;
- case 2:
- strOutput.Format(_T("从ROA3.31以下版本恢复%s"), strRoExec);
- break;
- default:
- ASSERT(false);
- break;
- }
- if(!strOutput.IsEmpty())
- {
- MessageBox(strOutput, _T("恢复RO客户端"), MB_OK | MB_ICONINFORMATION);
- }
- return(nRet);
- }
- void CDlgOption::OnBtnRestore()
- {
- // TODO: Add your control notification handler code here
- int nRet = -1;
- CString strTemp, strRoFile, strRoPath, strError, strRoaFile, strRoaInject, strDInput, strDInputFake;
- CString strRoExec, strRoaExec;
- int nIndex;
- int nClientType = eUnknown;
- strTemp = m_option.strLauncher;
- do
- {
- // Get EXE Name
- nIndex = strTemp.ReverseFind(_T('\'));
- if(-1 == nIndex)
- {
- strError = "客户端启动程序定义错误,请检查并重新定义!";
- MessageBox(strError, _T("恢复RO客户端"), MB_OK | MB_ICONSTOP);
- break;
- }
- strRoFile = strTemp.Right(strTemp.GetLength() - nIndex -1);
- strRoPath = strTemp.Left(nIndex + 1);
- strRoaInject = strRoPath + _T("ROAInject.dll");
- ::DeleteFile(strRoaInject);
- strDInput = strRoPath + "dinput.dll";
- strDInputFake = strRoPath + "dinput.dl_";
- if(utlGetFileSize(strDInputFake) > 0)
- {
- ::CopyFile(strDInputFake, strDInput, false);
- ::DeleteFile(strDInputFake);
- }
- // Restore ragexe.exe
- if(RestoreFile(strRoPath, _T("ragexe.exe")) < 0)
- break;
- // Restore sakexe.exe
- if(RestoreFile(strRoPath, _T("sakexe.exe")) < 0)
- break;
- // // Restore sakexe.exe
- // if(RestoreFile(strRoPath, _T("Ragnarok.exe")) < 0)
- // break;
- nRet = 0;
- }while(0);
- if(0 == nRet)
- {
- MessageBox(_T("成功恢复RO客户端文件!"), _T("恢复RO客户端"), MB_OK | MB_ICONINFORMATION);
- }
- else
- {
- MessageBox(_T("恢复RO客户端文件失败,请重新安装RO客户端!"), _T("恢复RO客户端"), MB_OK | MB_ICONINFORMATION);
- }
- return;
- }
- void CDlgOption::OnChangeEdtReadme()
- {
- // TODO: If this is a RICHEDIT control, the control will not
- // send this notification unless you override the CDialog::OnInitDialog()
- // function and call CRichEditCtrl().SetEventMask()
- // with the ENM_CHANGE flag ORed into the mask.
- // TODO: Add your control notification handler code here
- }