📄 dlglogin.cpp
字号:
// DlgLogin.cpp : implementation file
//
#include "stdafx.h"
#include "MyShell.h"
#include "DlgLogin.h"
#include "allmsg.h"
#include "3dGameMap.h"
//#include "GamePlayerSet.h"
//#include "Hero.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#ifdef _SOUND_DISABLE
#define DXPlaySound //
#endif
//#define SHELL_91LOGIN
//#define BIG5
/////////////////////////////////////////////////////////////////////////////
// CDlgLogin dialog
CDlgLogin::CDlgLogin(CWnd* pParent /*=NULL*/)
: CDialog(CDlgLogin::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgLogin)
m_bLoad = false ;
m_bShow = false ;
m_nCurrentFocus = 1 ;
m_nCurLoginMode = 0;
m_nCurServerIn = -1;
m_nCurPage = 0;
m_nEffectPosX = 0;
m_nEffectPosY = 0;
//}}AFX_DATA_INIT
}
void CDlgLogin::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgLogin)
DDX_Control(pDX, IDC_SEVER_PRS5, m_PrsServer5);
DDX_Control(pDX, IDC_SEVER_PRS4, m_PrsServer4);
DDX_Control(pDX, IDC_SEVER_PRS3, m_PrsServer3);
DDX_Control(pDX, IDC_SEVER_PRS2, m_PrsServer2);
DDX_Control(pDX, IDC_SEVER_PRS1, m_PrsServer1);
DDX_Control(pDX, IDC_LOGIN_BTN_CANCEL, m_BtnCancel);
DDX_Control(pDX, IDC_BTN_RIGHTPAGE, m_BtnRightPage);
DDX_Control(pDX, IDC_BTN_LEFTPAGE, m_BtnLeftPage);
DDX_Control(pDX, IDC_BTN_BACK, m_BtnBack);
DDX_Control(pDX, IDC_LOGIN_SERVER5, m_BtnServer5);
DDX_Control(pDX, IDC_LOGIN_SERVER4, m_BtnServer4);
DDX_Control(pDX, IDC_LOGIN_SERVER3, m_BtnServer3);
DDX_Control(pDX, IDC_LOGIN_SERVER2, m_BtnServer2);
DDX_Control(pDX, IDC_LOGIN_SERVER1, m_BtnServer1);
DDX_Control(pDX, IDC_LOGIN_GROUP5, m_BtnGroup5);
DDX_Control(pDX, IDC_LOGIN_GROUP4, m_BtnGroup4);
DDX_Control(pDX, IDC_LOGIN_GROUP3, m_BtnGroup3);
DDX_Control(pDX, IDC_LOGIN_GROUP2, m_BtnGroup2);
DDX_Control(pDX, IDC_LOGIN_GROUP1, m_BtnGroup1);
DDX_Control(pDX, IDC_LOGIN_GROUPIMG, m_ImgGroupBk);
DDX_Control(pDX, IDC_LOGIN_EDTIMG, m_LoginEdtImg);
DDX_Control(pDX, IDC_LOGIN_EDT_ACCOUNT, m_LoginAccountEdt);
DDX_Control(pDX, IDC_LOGIN_EDT_PASSWORD, m_LoginPasswordEdt);
DDX_Control(pDX, IDC_LOGIN_BTN_OK, m_LoginOkBtn);
DDX_Control(pDX, IDC_LOGIN_BTN_EXIT, m_LoginExitBtn);
DDX_Control(pDX, IDC_LOGIN_BTN_RECORD, m_LoginRecordBtn ) ;
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgLogin, CDialog)
//{{AFX_MSG_MAP(CDlgLogin)
ON_WM_CTLCOLOR()
ON_BN_CLICKED(IDC_LOGIN_BTN_OK, OnLoginBtnOk)
ON_BN_CLICKED(IDC_LOGIN_BTN_EXIT, OnLoginBtnExit)
ON_BN_CLICKED(IDC_LOGIN_BTN_RECORD, OnLoginBtnRecord)
ON_EN_SETFOCUS(IDC_LOGIN_EDT_ACCOUNT, OnSetfocusLoginEdtAccount)
ON_EN_SETFOCUS(IDC_LOGIN_EDT_PASSWORD, OnSetfocusLoginEdtPassword)
ON_BN_CLICKED(IDC_LOGIN_SERVER1, OnLoginServer1)
ON_BN_CLICKED(IDC_LOGIN_GROUP1, OnLoginGroup1)
ON_BN_CLICKED(IDC_BTN_BACK, OnBtnBack)
ON_BN_CLICKED(IDC_LOGIN_BTN_CANCEL, OnLoginBtnCancel)
ON_WM_MOUSEMOVE()
ON_BN_CLICKED(IDC_LOGIN_GROUP2, OnLoginGroup2)
ON_BN_CLICKED(IDC_LOGIN_GROUP3, OnLoginGroup3)
ON_BN_CLICKED(IDC_LOGIN_GROUP4, OnLoginGroup4)
ON_BN_CLICKED(IDC_LOGIN_GROUP5, OnLoginGroup5)
ON_BN_CLICKED(IDC_LOGIN_SERVER2, OnLoginServer2)
ON_BN_CLICKED(IDC_LOGIN_SERVER3, OnLoginServer3)
ON_BN_CLICKED(IDC_LOGIN_SERVER4, OnLoginServer4)
ON_BN_CLICKED(IDC_LOGIN_SERVER5, OnLoginServer5)
ON_BN_CLICKED(IDC_BTN_LEFTPAGE, OnBtnLeftpage)
ON_BN_CLICKED(IDC_BTN_RIGHTPAGE, OnBtnRightpage)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgLogin message handler
BOOL CDlgLogin::OnInitDialog()
{
CDialog::OnInitDialog();
// Init the edit
if ( ! ( m_LoginPasswordEdt.Init ( 0, 0, false,NULL, 0x000000, 0xffffff ) ) )
return false ;
m_LoginPasswordEdt.SetLimitText ( 15 ) ;
m_LoginPasswordEdt.SetPasswordType ( ) ;
m_LoginPasswordEdt.SetOffset ( CPoint ( 4, 6 ) ) ;
#ifdef _DEBUG
m_LoginPasswordEdt.SetWindowText ( "abcd" ) ;
#endif
m_LoginAccountEdt.Init (0, 0, NULL, 0x000000, 0xffffff);
m_LoginAccountEdt.SetLimitText ( 15 ) ;
m_LoginAccountEdt.SetOffset ( CPoint ( 4, 6 ) ) ;
char strAccount[32] ;
if ( GetPrivateProfileString ( "Account", "AccountRecord", "", strAccount, 16, g_strSetupIni ) != 0 )
m_LoginAccountEdt.SetWindowText ( strAccount ) ;
m_LoginAccountEdt.SetSel(0,0);
// Init the image
m_LoginEdtImg.Init ( 0, 0, "Image120", BG_IMAGE ) ;
m_ImgGroupBk.Init ( 0, 0, "Image100", BG_IMAGE ) ;
// Init the button
m_LoginOkBtn.Init ( 0, 0, "Button13" ) ;
m_LoginExitBtn.Init ( 0, 0, "Button14" ) ;
m_LoginRecordBtn.Init ( 0, 0, "Button12" ) ;
m_BtnCancel.Init(0,0,"Button7");
// The groups
m_BtnGroup1.Init(0,0,"Sgroup1");
m_BtnGroup2.Init(0,0,"Sgroup2");
m_BtnGroup3.Init(0,0,"Sgroup3");
m_BtnGroup4.Init(0,0,"Sgroup4");
m_BtnGroup5.Init(0,0,"Sgroup5");
//the server
m_BtnServer1.Init(0,0,"Server1");
m_BtnServer2.Init(0,0,"Server2");
m_BtnServer3.Init(0,0,"Server3");
m_BtnServer4.Init(0,0,"Server4");
m_BtnServer5.Init(0,0,"Server5");
m_PrsServer1.Init(0,0,"Progress600",0,100,MY_PROGRESS_HLEFT);
m_PrsServer1.GetWindowRect(m_PrgServer[0]);
m_PrsServer2.Init(0,0,"Progress600",0,100,MY_PROGRESS_HLEFT);
m_PrsServer2.GetWindowRect(m_PrgServer[1]);
m_PrsServer3.Init(0,0,"Progress600",0,100,MY_PROGRESS_HLEFT);
m_PrsServer3.GetWindowRect(m_PrgServer[2]);
m_PrsServer4.Init(0,0,"Progress600",0,100,MY_PROGRESS_HLEFT);
m_PrsServer4.GetWindowRect(m_PrgServer[3]);
m_PrsServer5.Init(0,0,"Progress600",0,100,MY_PROGRESS_HLEFT);
m_PrsServer5.GetWindowRect(m_PrgServer[4]);
m_BtnBack.Init(0,0,"Button17");
m_BtnLeftPage.Init(0, 0, "Button18");
m_BtnLeftPage.GetWindowRect(m_PrgServer[5]);
m_BtnRightPage.Init(0, 0, "Button19");
m_BtnRightPage.GetWindowRect(m_PrgServer[6]);
// Init the static
int nGroupAmount = GetPrivateProfileInt ( "Header", "GroupAmount", 0, ".\\Server.dat" ) ;
if ( nGroupAmount == 0 )
{
this->MessageBox( g_objGameDataSet.GetStr ( 10012 ) ) ;//"server.dat损坏或者打开失败, 请重新安装。", "错误", MB_OK|MB_ICONERROR);
return false;
}
/*/ Set the default value
int nGroup = GetPrivateProfileInt ( "Group", "GroupRecord", -1, g_strSetupIni ) ;
if ( nGroup != -1 )
{
switch ( nGroup )
{
case 1:
CDlgLogin::OnLoginGroup1 () ;
break ;
case 2:
CDlgLogin::OnLoginGroup2 () ;
break ;
case 3:
CDlgLogin::OnLoginGroup3 () ;
break ;
}
}
else
CDlgLogin::OnLoginGroup1 () ;
int nServer = GetPrivateProfileInt ( "Server", "ServerRecord", -1, g_strSetupIni ) ;
if ( nServer != -1 )
{
sprintf ( m_strServer, "Ip%d", nServer ) ;
m_nCurrentFocus = nServer ;
}*/
m_bLoad = true ;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
HBRUSH CDlgLogin::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
pDC->SetBkMode ( TRANSPARENT ) ;
return g_StockBrush;
}
void CDlgLogin::Show()
{
if ( m_bLoad && m_bShow )
{
// Show the owner
CAni* ShowAni = g_objGameDataSet.GetDataAni ( ( char * )g_strControlAni,
"Image1",
EXIGENCE_IMMEDIATE ) ;
if ( ShowAni != NULL )
ShowAni->Show ( 0, 0, 0 );
else
return ;
//show effect cloud
// CMyPos pPos ={512,382};
// m_EffectExLogin.Process();
// m_EffectExLogin.Show(pPos);
if ( ShowAni != NULL )
ShowAni->Show ( 1, 0, 0 );
else
return ;
CMyPos pPos;
pPos.x = m_nEffectPosX;
pPos.y = m_nEffectPosY;
m_EffectExLoginN.Process();
m_EffectExLoginN.Show(pPos);
// Show the image
if ( ShowAni != NULL )
ShowAni->Show ( 2, 0, 0 );
else
return ;
if (m_nCurLoginMode == 0)
{
//the group btn
m_ImgGroupBk.Show(0,0);
m_BtnGroup1.Show(0,0);
m_BtnGroup2.Show(0,0);
m_BtnGroup3.Show(0,0);
m_BtnGroup4.Show(0,0);
m_BtnGroup5.Show(0,0);
m_BtnBack.Show(0,0);
m_BtnLeftPage.Show(0,0);
m_BtnRightPage.Show(0,0);
if (m_nCurServerIn == 5 || m_nCurServerIn == 6)
{
CMySize FontSize;
CMyBitmap::GetFontSize(FontSize);
CMyBitmap::ShowBlock(m_PrgServer[m_nCurServerIn].left - FontSize.iWidth*2,
m_PrgServer[m_nCurServerIn].top - FontSize.iHeight,
m_PrgServer[m_nCurServerIn].left + FontSize.iWidth*2,
m_PrgServer[m_nCurServerIn].top ,
0xc2000000);
CMyBitmap::ShowString(m_PrgServer[m_nCurServerIn].left - FontSize.iWidth*2,m_PrgServer[m_nCurServerIn].top- FontSize.iHeight,
0xffffff,g_objGameDataSet.GetStr(10032));
}
}
else if (m_nCurLoginMode == 1)
{
//the server btn
m_ImgGroupBk.Show(0,0);
m_BtnServer1.Show(0,0);
m_BtnServer2.Show(0,0);
m_BtnServer3.Show(0,0);
m_BtnServer4.Show(0,0);
m_BtnServer5.Show(0,0);
m_BtnBack.Show(0,0);
m_BtnLeftPage.Show(0,0);
m_BtnRightPage.Show(0,0);
if (m_nCurServerIn == 5 || m_nCurServerIn == 6)
{
CMySize FontSize;
CMyBitmap::GetFontSize(FontSize);
CMyBitmap::ShowBlock(m_PrgServer[m_nCurServerIn].left - FontSize.iWidth*2,
m_PrgServer[m_nCurServerIn].top - FontSize.iHeight,
m_PrgServer[m_nCurServerIn].left + FontSize.iWidth*2,
m_PrgServer[m_nCurServerIn].top,
0xc2000000);
CMyBitmap::ShowString(m_PrgServer[m_nCurServerIn].left - FontSize.iWidth*2,m_PrgServer[m_nCurServerIn].top - FontSize.iHeight,
0xffffff,g_objGameDataSet.GetStr(10033));
}
m_PrsServer1.ResetValue(0,100);
m_PrsServer2.ResetValue(0,100);
m_PrsServer3.ResetValue(0,100);
m_PrsServer4.ResetValue(0,100);
m_PrsServer5.ResetValue(0,100);
if (m_bServerActive[0])
m_PrsServer1.Show(0,0,50,50);
if (m_bServerActive[1])
m_PrsServer2.Show(0,0,50,50);
if (m_bServerActive[2])
m_PrsServer3.Show(0,0,50,50);
if (m_bServerActive[3])
m_PrsServer4.Show(0,0,50,50);
if (m_bServerActive[4])
m_PrsServer5.Show(0,0,50,50);
// if(m_nCurServerIn>=0 && m_bServerActive[m_nCurServerIn])
// ShowServerInfo(m_nCurServerIn);
}
else if (m_nCurLoginMode == 2)
{
/* static int nTime = TimeGet() ;
if ( TimeGet() - nTime >= 100 && nTime != 0 && ::GetForegroundWindow () == CDlgLogin::GetParent ()->m_hWnd )
{
if ( m_LoginAccountEdt.GetWindowTextLength () > 0 )
m_LoginPasswordEdt.SetFocus () ;
else
m_LoginAccountEdt.SetFocus () ;
nTime = 0 ;
}*/
m_LoginEdtImg.Show ( 0, 0 ) ;
// Show the edit
m_LoginAccountEdt.Show ( -1,-3 ) ;
m_LoginPasswordEdt.Show (-1, -3) ;
// Show the button
m_LoginOkBtn.Show ( 0, 0 ) ;
m_LoginRecordBtn.Show ( 0, 0 ) ;
m_BtnCancel.Show( 0, 0);
}
m_LoginExitBtn.Show ( 0, 0 ) ;
}
}
LRESULT CDlgLogin::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
switch ( message )
{
case WM_SHOWWINDOW:
m_bShow = wParam ;
if ( wParam )
{
// Init the dxinput when dialog show
// m_GameInputStr.Init ( AfxGetInstanceHandle(), this->GetParent()->GetParent()->m_hWnd, 16 ) ;
//Add 3deffect cloud
m_EffectExLogin.Add("other13");
m_EffectExLoginN.Add("other14");
}
else
{
m_GameInputStr.Destroy () ;
m_EffectExLogin.Clear();
m_EffectExLoginN.Clear();
}
break ;
case WM_COMMAND:
if ( wParam == 1 )
{
if (m_nCurLoginMode == 2)
CDlgLogin::OnLoginBtnOk () ;
return true ;
}
else if ( wParam == 2 )
{
CDlgLogin::OnLoginBtnExit () ;
return true ;
}
break ;
}
return CDialog::WindowProc(message, wParam, lParam);
}
bool CDlgLogin::LoginGame()
{
CString strAccount;
m_LoginAccountEdt.GetWindowText(strAccount);
if (strAccount.GetLength() <= 0)
{
this->MessageBox ( g_objGameDataSet.GetStr ( 10013 ), g_objGameDataSet.GetStr ( 10017 ), MB_OK|MB_ICONERROR ) ;
return false;
}
CString strPsw;
m_LoginPasswordEdt.GetWindowText(strPsw);
if (strPsw.GetLength() <= 0)
{
this->MessageBox ( g_objGameDataSet.GetStr ( 10014 ), g_objGameDataSet.GetStr ( 10017 ), MB_OK|MB_ICONERROR ) ;
return false;
}
#ifdef SHELL_91LOGIN
int nLoginType = 5;
#ifdef BIG5
strAccount += ".tw";
#endif
extern int GameLoginServerEx(unsigned long uType, const char* pszAccount, const char* pszPsw, const char* pszServerIP, const char* pszServerName);
GameLoginServerEx( nLoginType, (LPCTSTR )strAccount, LPCTSTR (strPsw), m_strServer, m_strName );
#else
extern int GameLoginServer(const char* pszAccount, const char* pszPsw, const char* pszServerIP, const char* pszServerName);
GameLoginServer((LPCTSTR )strAccount, LPCTSTR (strPsw), m_strServer, m_strName);
#endif
extern CHAR g_szServerName[256];
strcpy( g_szServerName, m_strName );
return true;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -