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

📄 dlgfriend.cpp

📁 网络游戏魔域源代码 测试可以完整变异
💻 CPP
📖 第 1 页 / 共 2 页
字号:
			CFriend *pFriend = g_objHero.GetFriendByIndex( i ) ;
			if ( pFriend != NULL )
			{
				CDlgFriend::InsertFriendInfo( i - m_nCurIndex, pFriend ) ;
			}
		}
		break ;
	case 1:// sort by online
		{
			m_nOnlineAmount = 0 ;
			int nInsertNum = 0 ;
			for ( i = 0; i < g_objHero.GetFriendAmount(); i++ )// Search online
			{
				CFriend *pFriend = g_objHero.GetFriendByIndex( i ) ;
				if ( pFriend != NULL && pFriend->IsOnline() )
				{
					if ( m_nOnlineAmount >= m_nCurIndex )
					{
						CDlgFriend::InsertFriendInfo( m_nOnlineAmount - m_nCurIndex, pFriend ) ;
						nInsertNum++ ;
						if ( nInsertNum == 3 )// Test if insert over
						{
							return ;
						}
					}
					m_nOnlineAmount++ ;
				}
			}

			int nSortIndex = m_nOnlineAmount ;
			for ( i = 0; i < g_objHero.GetFriendAmount(); i++ )// Search offline
			{
				CFriend *pFriend = g_objHero.GetFriendByIndex( i ) ;
				if ( pFriend != NULL && !pFriend->IsOnline() )
				{
					if ( nSortIndex >= m_nCurIndex )
					{
						CDlgFriend::InsertFriendInfo( nSortIndex - m_nCurIndex, pFriend ) ;
						nInsertNum++ ;
						if ( nInsertNum == 3 )// Test if insert over
						{
							return ;
						}
					}
					nSortIndex++ ;
				}
			}
		}
		break ;
	default:
		break ;
	}	
}


void CDlgFriend::SetFriendState()
{
	
}

void CDlgFriend::OnFriendBtnResume() 
{
	
}

void CDlgFriend::OnBtnMsg1() 
{
	if ( m_StaName1.GetWindowTextLength() > 0 )
	{
		char *strName = new char[32] ;
		m_StaName1.GetWindowText( strName, 32 ) ;
		CDlgFriend::GetParent()->PostMessage( WM_MY_MESSAGE, ON_FRIEND_LEAVE, (LPARAM)strName ) ;
	}
}

void CDlgFriend::OnBtnMsg2() 
{
	if ( m_StaName2.GetWindowTextLength() > 0 )
	{
		char *strName = new char[32] ;
		m_StaName2.GetWindowText( strName, 32 ) ;
		CDlgFriend::GetParent()->PostMessage( WM_MY_MESSAGE, ON_FRIEND_LEAVE, (LPARAM)strName ) ;
	}
}

void CDlgFriend::OnBtnMsg3() 
{
	if ( m_StaName3.GetWindowTextLength() > 0 )
	{
		char *strName = new char[32] ;
		m_StaName3.GetWindowText( strName, 32 ) ;
		CDlgFriend::GetParent()->PostMessage( WM_MY_MESSAGE, ON_FRIEND_LEAVE, (LPARAM)strName ) ;
	}	
}

void CDlgFriend::OnBtnSort() 
{
	if ( m_BtnSortOnline.IsWindowEnabled() )
	{
		m_BtnSortOnline.EnableWindow( false ) ;
	}
	else
	{
		m_BtnSortOnline.EnableWindow() ;
	}

/*	if ( m_BtnSortName.IsWindowEnabled() )
	{
		m_BtnSortName.EnableWindow( false ) ;
	}
	else
	{
		m_BtnSortName.EnableWindow() ;
	}*/
}

void CDlgFriend::OnBtnRight() 
{
	if ( g_objHero.GetFriendAmount() > m_nCurIndex + 3 )
	{
		m_nCurIndex += 3 ;
		CDlgFriend::SetFriendList() ;
	}
}

void CDlgFriend::OnBtnLeft() 
{
	if ( m_nCurIndex > 0 )
	{
		m_nCurIndex -= 3 ;
		CDlgFriend::SetFriendList() ;
	}
}

void CDlgFriend::OnBtnDel1() 
{
	if ( m_StaName1.GetWindowTextLength() > 0 )
	{
		char strName[32] ;
		m_StaName1.GetWindowText( strName, 32 ) ;
		CFriend *pFriend = g_objHero.GetFriendByName( strName ) ;
		if ( pFriend != NULL )
		{
			g_objHero.BreakOffFriend( pFriend->GetID() ) ;
		}
	}
}

void CDlgFriend::OnBtnDel2() 
{
	if ( m_StaName2.GetWindowTextLength() > 0 )
	{
		char strName[32] ;
		m_StaName2.GetWindowText( strName, 32 ) ;
		CFriend *pFriend = g_objHero.GetFriendByName( strName ) ;
		if ( pFriend != NULL )
		{
			g_objHero.BreakOffFriend( pFriend->GetID() ) ;
		}
	}
}

void CDlgFriend::OnBtnDel3() 
{	
	if ( m_StaName3.GetWindowTextLength() > 0 )
	{
		char strName[32] ;
		m_StaName3.GetWindowText( strName, 32 ) ;
		CFriend *pFriend = g_objHero.GetFriendByName( strName ) ;
		if ( pFriend != NULL )
		{
			g_objHero.BreakOffFriend( pFriend->GetID() ) ;
		}
	}
}

void CDlgFriend::ClearFriendList()
{
	m_ImgHead1.RemoveImage() ;
	m_StaStirps1.SetWindowText( NULL ) ;
	m_StaSex1.SetWindowText( NULL ) ;
	m_StaPro1.SetWindowText( NULL ) ;
	m_StaName1.SetWindowText( NULL ) ;
	m_StaLev1.SetWindowText( NULL ) ;

	m_ImgHead2.RemoveImage() ;
	m_StaStirps2.SetWindowText( NULL ) ;
	m_StaSex2.SetWindowText( NULL ) ;
	m_StaPro2.SetWindowText( NULL ) ;
	m_StaName2.SetWindowText( NULL ) ;
	m_StaLev2.SetWindowText( NULL ) ;
	
	m_ImgHead3.RemoveImage() ;
	m_StaStirps3.SetWindowText( NULL ) ;
	m_StaSex3.SetWindowText( NULL ) ;
	m_StaPro3.SetWindowText( NULL ) ;
	m_StaName3.SetWindowText( NULL ) ;
	m_StaLev3.SetWindowText( NULL ) ;
}

void CDlgFriend::OnBtnSortonline() 
{
	m_btSortType = 1 ;
	CDlgFriend::SetFriendList() ;
}

void CDlgFriend::InsertFriendInfo(int nIndex, CFriend *pFriend)
{
	char strText[64] ;
	switch ( nIndex )
	{
	case 0:
		m_StaName1.SetWindowText( pFriend->GetName() ) ;

		if ( pFriend->IsOnline() )
		{
			if ( m_BtnMsg1.IsWindowEnabled() )
			{
				m_BtnMsg1.EnableWindow( false ) ;
			}

			m_ImgHead1.InsertImage( NULL, pFriend->GetFace(), pFriend->GetLook(), false ) ;
			
			sprintf ( strText, g_objGameDataSet.GetStr( 10520 + pFriend->GetRace() - 1 ) ) ;
			m_StaStirps1.SetWindowText( strText ) ;

			sprintf ( strText, g_objGameDataSet.GetStr( 10030 + pFriend->GetLook() % 2 ) ) ;
			m_StaSex1.SetWindowText( strText ) ;

			m_StaPro1.SetWindowText( pFriend->GetProfessionalName() ) ;
			
			itoa( pFriend->GetLevel(), strText, 10 ) ;
			m_StaLev1.SetWindowText( strText ) ;
		}
		else
		{
			if ( !m_BtnMsg1.IsWindowEnabled() )
			{
				m_BtnMsg1.EnableWindow() ;
			}			
		}	
		break ;
	case 1:
		m_StaName2.SetWindowText( pFriend->GetName() ) ;

		if ( pFriend->IsOnline() )
		{
			if ( m_BtnMsg2.IsWindowEnabled() )
			{
				m_BtnMsg2.EnableWindow( false ) ;
			}
			
			m_ImgHead2.InsertImage( NULL, pFriend->GetFace(), pFriend->GetLook(), false ) ;
			
			sprintf ( strText, g_objGameDataSet.GetStr( 10520 + pFriend->GetRace() - 1 ) ) ;
			m_StaStirps2.SetWindowText( strText ) ;

			sprintf ( strText, g_objGameDataSet.GetStr( 10030 + pFriend->GetLook() % 2 ) ) ;
			m_StaSex2.SetWindowText( strText ) ;

			m_StaPro2.SetWindowText( pFriend->GetProfessionalName() ) ;
			
			itoa( pFriend->GetLevel(), strText, 10 ) ;
			m_StaLev2.SetWindowText( strText ) ;
		}
		else
		{
			if ( !m_BtnMsg2.IsWindowEnabled() )
			{
				m_BtnMsg2.EnableWindow() ;
			}
		}
		break ;
	case 2:
		m_StaName3.SetWindowText( pFriend->GetName() ) ;
						
		if ( pFriend->IsOnline() )
		{
			if ( m_BtnMsg3.IsWindowEnabled() )
			{
				m_BtnMsg3.EnableWindow( false ) ;
			}

			m_ImgHead3.InsertImage( NULL, pFriend->GetFace(), pFriend->GetLook(), false ) ;
			
			sprintf ( strText, g_objGameDataSet.GetStr( 10520 + pFriend->GetRace() - 1 ) ) ;
			m_StaStirps3.SetWindowText( strText ) ;

			sprintf ( strText, g_objGameDataSet.GetStr( 10030 + pFriend->GetLook() % 2 ) ) ;
			m_StaSex3.SetWindowText( strText ) ;

			m_StaPro3.SetWindowText( pFriend->GetProfessionalName() ) ;
			
			itoa( pFriend->GetLevel(), strText, 10 ) ;
			m_StaLev3.SetWindowText( strText ) ;
		}
		else
		{
			if ( !m_BtnMsg3.IsWindowEnabled() )
			{
				m_BtnMsg3.EnableWindow() ;
			}
		}
		break ;
	default:
		break ;
	}
}

⌨️ 快捷键说明

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