⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dlglogin.cpp

📁 网络游戏魔域源代码 测试可以完整变异
💻 CPP
📖 第 1 页 / 共 2 页
字号:
void CDlgLogin::OnLoginBtnOk() 
{
	DXPlaySound ( "Sound/Dlg_ok.wav" ) ;
	
	if(CDlgLogin::LoginGame())
		CDlgLogin::ShowWindow ( SW_HIDE ) ;
}

void CDlgLogin::OnLoginBtnExit() 
{
	DXPlaySound ( "Sound/game_exit.wav" ) ;	
		WPARAM wParam = ON_EXIT ;
	CDlgLogin::GetParent ()->PostMessage ( WM_MY_MESSAGE, wParam ) ;	
}

/*void CDlgLogin::OnBtnHelp() 
{
	CDlgLogin::GetParent ()->PostMessage ( WM_MY_MESSAGE, ON_HELPDLG_SHOW, DLG_LOGIN ) ;		
}*/

void CDlgLogin::OnLoginBtnRecord() 
{
	DXPlaySound ( "Sound/Dlg_ok.wav" ) ;	
	if ( CDlgLogin::MessageBox ( CMyShellApp::StringChange ( g_objGameDataSet.GetStr ( 10015 ) ), g_objGameDataSet.GetStr ( 10016 ), MB_YESNO ) == IDYES )
//	if ( CDlgLogin::MessageBox ( "\t您确定要纪录吗?\n在网吧这将影响到您帐号的安全性", "纪录确定", MB_YESNO ) == IDYES )
	{
		char strAccount[32] ;
		m_LoginAccountEdt.GetWindowText ( strAccount, 16 ) ;
		if ( strAccount[0] != 0 )
			WritePrivateProfileString ( "Account", "AccountRecord", strAccount, g_strSetupIni ) ;
	}
}

/*void CDlgLogin::OnLoginBtnNet() 
{
	// TODO: Add your control notification handler code here
	DXPlaySound ( "Sound/BtnClick.wav" ) ;

//	::ShellExecute(m_hWnd, NULL, g_objGameDataSet.GetStr ( 10367 ), NULL, NULL, SW_SHOW );
}*/

void CDlgLogin::OnSetfocusLoginEdtAccount() 
{
	char strText[32] = "" ;
	m_LoginAccountEdt.GetWindowText ( strText, 16 ) ;
	if ( strText != NULL )
		m_GameInputStr.SetStr ( strText ) ;
}

void CDlgLogin::OnSetfocusLoginEdtPassword() 
{
	char strText[32] = "" ;
	m_LoginPasswordEdt.GetWindowText ( strText, 16 ) ;
	if ( strText != NULL )
		m_GameInputStr.SetStr ( strText ) ;
}

void CDlgLogin::ReInit()
{
	m_LoginEdtImg.Init ( 0, 0, "Image120", BG_IMAGE ) ;

	m_LoginPasswordEdt.Init ( 0, 0, NULL, 0x000000, 0xffffff ) ;
	m_LoginAccountEdt.Init ( 0, 0, NULL, 0x000000, 0xffffff  ) ;
	m_LoginOkBtn.Init ( 0, 0, "Button13" ) ;
	m_LoginExitBtn.Init ( 0, 0, "Button14" ) ;
	m_LoginRecordBtn.Init ( 0, 0, "Button12" ) ;
	m_b1024 = true ;
}


void CDlgLogin::OnLoginGroup1() 
{
	DXPlaySound ( "Sound/Dlg_ok.wav" ) ;	
	CDlgLogin::ResetServerStatus();
	CDlgLogin::LoginGroup(1);
	CDlgLogin::SetCurLoginMode(1);
}

void CDlgLogin::OnLoginServer1() 
{
	DXPlaySound ( "Sound/Dlg_ok.wav" ) ;	
	CDlgLogin::LoginServer(1);
}

void CDlgLogin::MoveAllPicAndWord()
{
	// Set the static null
	// remove the pics
}

void CDlgLogin::InsertServer(int nIndex, char *strPicID, char *strText, int nSerSta)
{
	m_bServerActive[nIndex-1] = TRUE;
	switch(nIndex)
	{
	case 1:
		m_BtnServer1.EnableWindow(true);
		m_BtnServer1.ChangeImage("Server1");
		break;
	case 2:
		m_BtnServer2.EnableWindow(true);
		m_BtnServer2.ChangeImage("Server2");
		break;
	case 3:
		m_BtnServer3.EnableWindow(true);
		m_BtnServer3.ChangeImage("Server3");
		break;
	case 4:
		m_BtnServer4.EnableWindow(true);
		m_BtnServer4.ChangeImage("Server4");
		break;
	case 5:
		m_BtnServer5.EnableWindow(true);
		m_BtnServer5.ChangeImage("Server5");
		break;
	default:
		break;
	}
}

void CDlgLogin::SetCurLoginMode(int nMode)
{
	DXSetSoundVolume(75);
	m_nCurLoginMode = nMode;
	
	BOOL bFlagGroup = false;
	BOOL bFlagServer = false;
	BOOL bFlagLogin = false;
	if (m_nCurLoginMode == 0)
	{
		bFlagGroup = true;
		m_BtnBack.EnableWindow(true);
		m_BtnLeftPage.EnableWindow(true);
		m_BtnRightPage.EnableWindow(true);
	}
	else if (m_nCurLoginMode == 1)
	{
		bFlagServer = true;
		m_BtnBack.EnableWindow(true);
		m_BtnLeftPage.EnableWindow(true);
		m_BtnRightPage.EnableWindow(true);
	}
	else if (m_nCurLoginMode == 2)
	{
		bFlagLogin = true;
		m_BtnBack.EnableWindow(false);
		m_BtnLeftPage.EnableWindow(false);
		m_BtnRightPage.EnableWindow(false);
		m_LoginAccountEdt.SetFocus();
		m_LoginAccountEdt.SetSel(0,0);		
	}
	
	m_LoginExitBtn.EnableWindow(true);

	CDlgLogin::SetGroupStatus(bFlagGroup);

	m_BtnServer1.EnableWindow(bFlagServer);
	m_BtnServer2.EnableWindow(bFlagServer);
	m_BtnServer3.EnableWindow(bFlagServer);
	m_BtnServer4.EnableWindow(bFlagServer);
	m_BtnServer5.EnableWindow(bFlagServer);
	m_PrsServer1.EnableWindow(bFlagServer);
	m_PrsServer2.EnableWindow(bFlagServer);
	m_PrsServer3.EnableWindow(bFlagServer);
	m_PrsServer4.EnableWindow(bFlagServer);
	m_PrsServer5.EnableWindow(bFlagServer);
	
	m_LoginAccountEdt.EnableWindow(bFlagLogin);
	m_LoginPasswordEdt.EnableWindow(bFlagLogin);
	m_LoginOkBtn.EnableWindow(bFlagLogin);
	m_LoginRecordBtn.EnableWindow(bFlagLogin);
	m_BtnCancel.EnableWindow(bFlagLogin);
	if (m_LoginAccountEdt.IsWindowEnabled())
		m_LoginAccountEdt.SetFocus();
}

void CDlgLogin::OnBtnBack() 
{
	// TODO: Add your control notification handler code here
	DXPlaySound ( "Sound/Dlg_ok.wav" ) ;	
	if(m_nCurLoginMode == 1)
		CDlgLogin::SetCurLoginMode(0);
	else if (m_nCurLoginMode == 0) 
	{
		CDlgLogin::GetParent()->PostMessage(WM_MY_MESSAGE,ON_BACK_PLAY);
	}
}

void CDlgLogin::OnLoginBtnCancel() 
{
	// TODO: Add your control notification handler code here
	DXPlaySound ( "Sound/Dlg_Ok.wav" ) ;	
	if(m_nCurLoginMode == 2)
		CDlgLogin::SetCurLoginMode(1);
}

void CDlgLogin::ShowServerInfo(int nServerIndex)
{
	char strInfo[64]="";
//	sprintf(strInfo,"Server%d",nServerIndex+1); 
	CMyBitmap::ShowBlock(m_PrgServer[nServerIndex].left+30,
		m_PrgServer[nServerIndex].top+10,
		m_PrgServer[nServerIndex].left + 120,
		m_PrgServer[nServerIndex].top + 36,
		0xc2ffffff);
	
	CMyBitmap::ShowString(m_PrgServer[nServerIndex].left,m_PrgServer[nServerIndex].top,
		0x000000,strInfo);
}

void CDlgLogin::OnMouseMove(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	if (m_nCurLoginMode == 1 || m_nCurLoginMode == 0)
	{
		for(int i=0;i<7;i++)
		{
			if (m_PrgServer[i].PtInRect(point))
			{
				m_nCurServerIn = i;
				CDialog::OnMouseMove(nFlags, point);
				return;
			}
			else 
				m_nCurServerIn = -1;
		}
	}
	CDialog::OnMouseMove(nFlags, point);	
}

void CDlgLogin::ResetServerStatus()
{
	for(int i=0;i<5;i++)
	{
		m_bServerActive[i] = false;
		m_BtnServer1.EnableWindow(false);
		m_BtnServer1.ChangeImage("ServerNone");
		m_BtnServer2.EnableWindow(false);
		m_BtnServer2.ChangeImage("ServerNone");
		m_BtnServer3.EnableWindow(false);
		m_BtnServer3.ChangeImage("ServerNone");
		m_BtnServer4.EnableWindow(false);
		m_BtnServer4.ChangeImage("ServerNone");
		m_BtnServer5.EnableWindow(false);
		m_BtnServer5.ChangeImage("ServerNone");
	}
}

void CDlgLogin::OnLoginGroup2() 
{
	// TODO: Add your control notification handler code here
	DXPlaySound ( "Sound/Dlg_ok.wav" ) ;	
	CDlgLogin::ResetServerStatus();
	CDlgLogin::LoginGroup(2);
	CDlgLogin::SetCurLoginMode(1);
}

void CDlgLogin::OnLoginGroup3() 
{
	// TODO: Add your control notification handler code here
	DXPlaySound ( "Sound/Dlg_ok.wav" ) ;	
	CDlgLogin::ResetServerStatus();
	CDlgLogin::LoginGroup(3);
	CDlgLogin::SetCurLoginMode(1);	
}

void CDlgLogin::OnLoginGroup4() 
{
	// TODO: Add your control notification handler code here
	DXPlaySound ( "Sound/Dlg_ok.wav" ) ;	
	CDlgLogin::ResetServerStatus();
	CDlgLogin::LoginGroup(4);
	CDlgLogin::SetCurLoginMode(1);	
}

void CDlgLogin::OnLoginGroup5() 
{
	// TODO: Add your control notification handler code here
	DXPlaySound ( "Sound/Dlg_ok.wav" ) ;	
	CDlgLogin::ResetServerStatus();
	CDlgLogin::LoginGroup(5);
	CDlgLogin::SetCurLoginMode(1);	
}

void CDlgLogin::OnLoginServer2() 
{
	// TODO: Add your control notification handler code here
	DXPlaySound ( "Sound/Dlg_ok.wav" ) ;	
	CDlgLogin::LoginServer(2);	
}

void CDlgLogin::OnLoginServer3() 
{
	// TODO: Add your control notification handler code here
	DXPlaySound ( "Sound/Dlg_ok.wav" ) ;	
	CDlgLogin::LoginServer(3);	
}

void CDlgLogin::OnLoginServer4() 
{
	// TODO: Add your control notification handler code here
	DXPlaySound ( "Sound/Dlg_ok.wav" ) ;	
	CDlgLogin::LoginServer(4);	
}

void CDlgLogin::OnLoginServer5() 
{
	// TODO: Add your control notification handler code here
	DXPlaySound ( "Sound/Dlg_ok.wav" ) ;	
	CDlgLogin::LoginServer(5);	
}

void CDlgLogin::LoginGroup(int nIndex)
{
	CDlgLogin::ResetServerStatus();

	sprintf ( m_strGroup, "Group%d",nIndex ) ;
	strcpy ( m_strServer, "Ip1" ) ;

	int nServerAmount = GetPrivateProfileInt ( m_strGroup, "ServerAmount", 0, ".\\Server.dat" ) ;
	if ( nServerAmount == 0 )
	{
		this->MessageBox("server.dat损坏或者打开失败, 请重新安装。", "错误", MB_OK|MB_ICONERROR);
		return ;	
	}
	
	char strPicID[16] ;
	char strText[32] ;
	char strKey[16] ;
	int nSerSta ;
	m_SerSta.FlashStatus () ;
	for ( int i = 1; i <= nServerAmount; i++ )
	{
		sprintf ( strKey, "Pic%d", i ) ;
		GetPrivateProfileString ( m_strGroup, strKey, "", strPicID, 16, ".\\Server.dat" ) ;
		sprintf ( strKey, "Server%d", i ) ;
		GetPrivateProfileString ( m_strGroup, strKey, "", strText, 16, ".\\Server.dat" ) ;
		nSerSta = 0;//m_SerSta.GetServerStatus ( strText ) ;
		CDlgLogin::InsertServer ( i, strPicID, strText, nSerSta ) ;
	}
	CDlgLogin::SetCurLoginMode(1);
}

void CDlgLogin::LoginServer(int nIndex)
{
	if (m_bServerActive[nIndex+m_nCurPage-1])
	{
		char strKey[16];
		sprintf(strKey,"Ip%d",nIndex+m_nCurPage);
		GetPrivateProfileString ( m_strGroup, strKey, "", m_strServer, 16, ".\\Server.dat" ) ;
		sprintf(strKey,"Server%d",nIndex+m_nCurPage);
		GetPrivateProfileString ( m_strGroup, strKey, "", m_strName, 16, ".\\Server.dat" ) ;
		CDlgLogin::SetCurLoginMode(2);
	}
}

void CDlgLogin::SetGroupStatus(BOOL bGroup)
{
	m_BtnGroup1.EnableWindow(false);
	m_BtnGroup1.ChangeImage("ServerNone");
	m_BtnGroup2.EnableWindow(false);
	m_BtnGroup2.ChangeImage("ServerNone");
	m_BtnGroup3.EnableWindow(false);
	m_BtnGroup3.ChangeImage("ServerNone");
	m_BtnGroup4.EnableWindow(false);
	m_BtnGroup4.ChangeImage("ServerNone");
	m_BtnGroup5.EnableWindow(false);
	m_BtnGroup5.ChangeImage("ServerNone");
	if (bGroup)
	{
		int nGroupAmount = GetPrivateProfileInt ( "Header", "GroupAmount", 0, ".\\Server.dat" ) ;
		if ( nGroupAmount <= 0 )
		{
			this->MessageBox((char*)g_objGameDataSet.GetStr(10012), g_objGameDataSet.GetStr ( 10017 ), MB_OK|MB_ICONERROR);
			return ;	
		}
		else
		{
			for(int i=0;i<nGroupAmount;i++)
			{
				switch(i)
				{
				case 0:
					m_BtnGroup1.EnableWindow(true);
					m_BtnGroup1.ChangeImage("Sgroup1");
					break;
				case 1:
					m_BtnGroup2.EnableWindow(true);
					m_BtnGroup2.ChangeImage("Sgroup2");
					break;
				case 2:
					m_BtnGroup3.EnableWindow(true);
					m_BtnGroup3.ChangeImage("Sgroup3");
					break;
				case 3:
					m_BtnGroup4.EnableWindow(true);
					m_BtnGroup4.ChangeImage("Sgroup4");
					break;
				case 4:
					m_BtnGroup5.EnableWindow(true);
					m_BtnGroup5.ChangeImage("Sgroup5");
					break;
				default:
					 break;
				}
			}
		}
	}
}

void CDlgLogin::SetEffectPos(int x, int y)
{
	m_nEffectPosX = x;
	m_nEffectPosY = y;
}

void CDlgLogin::OnBtnLeftpage() 
{
	// TODO: Add your control notification handler code here
	DXPlaySound ( "Sound/up_Page.wav" ) ;	
}

void CDlgLogin::OnBtnRightpage() 
{
	// TODO: Add your control notification handler code here
	DXPlaySound ( "Sound/up_Page.wav" ) ;	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -