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

📄 interfa2.cpp

📁 这是一个游戏程序源码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
			MESSAGE_TEXT.SetTextColor( RGB(255, 255, 255) ) ;
			MESSAGE_TEXT.MyTextOut( DD_GetBackBuffer(), MessageRect.left+430, MessageRect.top, message_jmNum );

			MESSAGE_TEXT.SetTextColor( RGB(255, 255, 255) );
			MESSAGE_TEXT.MyTextOut( DD_GetBackBuffer(), MessageRect.left+32, MessageRect.top, message_temp3 );
		}
		else
		{
			MESSAGE_TEXT.SetTextColor( RGB(255, 255, 255) );
			MESSAGE_TEXT.MyTextOut( DD_GetBackBuffer(), MessageRect.left, MessageRect.top, message_temp1 );
			MESSAGE_TEXT.SetTextColor( RGB(255, 255, 120) );
			MESSAGE_TEXT.MyTextOut( DD_GetBackBuffer(), MessageRect.left+16, MessageRect.top, message_temp2 );

			MESSAGE_TEXT.SetTextColor( RGB(255, 255, 255) );
			MESSAGE_TEXT.MyTextOut( DD_GetBackBuffer(), MessageRect.left+32, MessageRect.top, message_temp3 );
		}
	}
	else
		MESSAGE_TEXT.MyTextOut( DD_GetBackBuffer(), MessageRect.left, MessageRect.top, message );
	// to release the character surface
	MESSAGE_TEXT.EndText( );
	
	sBottom.Update();
}
else
{
	// TO UPDATE THE dialog rectangle BACKGROUND
	sInputName.Blit();

	MESSAGE_TEXT.SetTextColor( RGB(255, 255, 120) );
	MESSAGE_TEXT.MyTextOut( DD_GetBackBuffer(), posX, posY, message );
	// to release the character surface
	MESSAGE_TEXT.EndText( );

	// to show the dialog rectangle from back buffer to front buffer
	sInputName.Update();
}
	return;
}                              
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
//	to show the prompt string at the bottom of the interfac
//	this function will be used by Liu Gang and Li Haijun
void FACE_ShowMessage( HWND hwnd, LPCTSTR message, int posX /*= 30*/, int posY /*= 460*/ )
{
	RECT	MessageRect;
	class	CDDText MESSAGE_TEXT;		// the string attribute of MESSAGE_STRING

	if( (FACE_GetProgramState() == PROGRAM_STATE_MENU)&&
		( CurrentMenu == &Menu_NetWork_SetNet )
	)
	{
		// TO UPDATE THE MESSAGE BACKGROUND
		POINT	ptDest ;

		RECT	dSource ;

		ptDest.x = Net_EchoPrompt_Message.GetPosX() ;	//72 ;
		ptDest.y = Net_EchoPrompt_Message.GetPosY()-8 ;	//279 ;

		dSource.left = ptDest.x ;	//72 ;
		dSource.top = ptDest.y ;	//279 ;
		dSource.right = ptDest.x+266 ;		//440 ;
		dSource.bottom = ptDest.y+30 ;		//311 ;

		pAllBitmap[0]->Blit(&ptDest, &dSource);
	
		Net_EchoPrompt_Message.SetString( message ) ;
		Net_EchoPrompt_Message.Blit() ;
/*
		// to get a surface for you string
		MESSAGE_TEXT.BeginText( 76 );	// ( 640 - 30 ) / 16
		MESSAGE_TEXT.SetTextColor( RGB(255, 255, 255) );
		MESSAGE_TEXT.MyTextOut( DD_GetBackBuffer(), ptDest.x+2, ptDest.y+8, message );
		// to release the character surface
		MESSAGE_TEXT.EndText( );
*/		
		DDC_UpdateScreen( &dSource );
	}
	else
	{
		MessageRect.left = posX;
		MessageRect.top = posY;
		MessageRect.right = 640;
		MessageRect.bottom = 480;
		// TO UPDATE THE MESSAGE BACKGROUND
		sBottom.Blit();

		// to get a surface for you string
		MESSAGE_TEXT.BeginText( 76 );	// ( 640 - 30 ) / 16
		MESSAGE_TEXT.SetTextColor( RGB(255, 255, 255) );
		MESSAGE_TEXT.MyTextOut( DD_GetBackBuffer(), MessageRect.left, MessageRect.top, message );
		// to release the character surface
		MESSAGE_TEXT.EndText( );
		
		sBottom.Update();
	}

	return;
}                              
////////////////////////////////////////////////////////////////////////////
//	this function is to show you input letter from keybroad real time
//	as a echo of you input , so named echo_prompt
void FACE_Echo_prompt( HWND hwnd, int posX /*=30*/, int posY /*= 460*/ )
{
	if( ( FACE_GetProgramState() == PROGRAM_STATE_MENU )&&
		( CurrentMenu == &Menu_NetWork_InputName )
	)
	{
		FACE_Prompt( hwnd, DIALOG_BUF, 215, 339 ) ;
	}
	else if( ( FACE_GetProgramState() == PROGRAM_STATE_MENU )&&
		( CurrentMenu == &Menu_NetWork_SetNet )
	)
	{
		// to init the MESSAGE_PROMPT AND MESSAGE_STRING AND MESSAGE_BUF string
		strcpy(NETWORK_MESSAGE_STRING, MESSAGE_PROMPT) ;
		strcat(NETWORK_MESSAGE_STRING, NETWORK_MESSAGE_BUF) ;
		FACE_ShowMessage( hwnd, NETWORK_MESSAGE_STRING, posX, posY ) ;
	}
	else if( FACE_bMessageBox == TRUE )
	{
		// to init the MESSAGE_PROMPT AND MESSAGE_STRING AND MESSAGE_BUF string
		strcpy(MESSAGE_STRING, MESSAGE_PROMPT) ;
		strcat(MESSAGE_STRING, MESSAGE_BUF) ;
		FACE_ShowMessage( hwnd, MESSAGE_STRING, posX, posY ) ;
	}

	return;
} 

//////////////////////////////////////////////////////////////////////
//	This function is be used by  FACE_Prompt() , 
// to clear the message rectangle after echo-show the message string
void FACE_UpdateMessageRect()
{
	if( FACE_bMessageBox == FALSE )
		sBottom.Show();
}


////////////////////////////////////////////////////////////////////////
//
//
//		The following functions are used to send message and show them 
//
//			at the rectly rectangle areas
//
////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////
//	to send the message to the others and show it at my own 
//		network message rectangle display area
void	FACE_NetworkSendMessage()
{
	if( (NETWORK_MESSAGE_BUF[0] == '_')&&
		( strlen(NETWORK_MESSAGE_BUF) == 1 )
	)
		return ;

	char	temp[NETWORK_MAX_MESSAGE_LETTER+1] ;
	strcpy( temp, NETWORK_MESSAGE_BUF ) ;
	int ret = strlen( temp ) ;
	temp[ ret-1 ] = '\0' ;

	// to send the message to other players
	memset(DP_SendMessageBuff,0,BUFFER_MAX_BYTE);
	wsprintf((char *)DP_SendMessageBuff,"%d %s %s",DP_TALK,DP_NickName,temp);
	if(DP_NetworkInterface(DP_SEND_MESSAGE,NULL)!=OK)
		{
			////////////////////////////////////////////////////////////////
			//无法正常发送时,出错处理。
			#ifdef	NETWORK
			MessageBox(NULL,"Send Counter message error!!!","Error",MB_OK);
			#endif
		}
	// to show this message in your message display rectangle
	FACE_SetNetworkMessage( DP_NickName, temp ) ;
	// to erase the message that has been sended
	FACE_UpdateNetWorkMessageRect() ;
}

/////////////////////////////////////////////////////////////////
// to update the send message rectangle of the set network menu
void FACE_UpdateNetWorkMessageRect(void)
{
	if( CurrentMenu != &Menu_NetWork_SetNet )
		return ;
	// to init the NETWORK_MESSAGE_BUF and the NETWORK_MESSAGE_STRING and the other string
	FACE_NetWorkSetMessage() ;
	FACE_ShowMessage( NULL, MESSAGE_PROMPT ) ;
}
// to update the display message rectangle of the set network menu
void FACE_UpdateNetworkComMessageRect(void)
{

	class	CDDText MESSAGE_TEXT;		// the string attribute of MESSAGE_STRING

	if( ( FACE_GetProgramState() != PROGRAM_STATE_MENU )||
		( CurrentMenu != &Menu_NetWork_SetNet) )
		return ;

	// TO UPDATE THE MESSAGE BACKGROUND
	POINT	ptDest ;
	RECT	dSource ;

	ptDest.x = Net_Message_1.GetPosX()-4 ;	//72 ;
	ptDest.y = Net_Message_1.GetPosY()-4 ;	//191 ;

	dSource.left = ptDest.x ;	//72 ;
	dSource.top = ptDest.y ;	//191 ;
	dSource.right = ptDest.x+263 ;	//335 ;
	dSource.bottom = ptDest.y+87 ;	//278 ;

	pAllBitmap[0]->Blit(&ptDest, &dSource);

	Net_Message_1.Blit() ;
	Net_Message_2.Blit() ;
	Net_Message_3.Blit() ;
	Net_Message_4.Blit() ;

	DDC_UpdateScreen( &dSource );
}
///////////////////////////////////////////////////////////////////////
//	to init the four string that store the network message
void	FACE_InitNetworkMessage(void)
{
	Net_Message_1.m_bIsUse = FALSE ;
	Net_Message_2.m_bIsUse = FALSE ;
	Net_Message_3.m_bIsUse = FALSE ;
	Net_Message_4.m_bIsUse = FALSE ;
}
///////////////////////////////////////////////////////////////////////
//	to set the network message and show it
void	FACE_SetNetworkMessage(	LPCTSTR name, LPCTSTR message )
{
//	if( ( FACE_GetProgramState() != PROGRAM_STATE_MENU )||
//		( CurrentMenu != &Menu_NetWork_SetNet) )
	if( FACE_GetProgramState() != PROGRAM_STATE_MENU )
		return ;

	char	temp[NETWORK_MAX_MESSAGE_LETTER+1+2+MAX_NAME_LETTER] ;
	
	strcpy( temp, name ) ;
	strcat( temp, ": " ) ;
	strcat( temp, message ) ;

	if( Net_Message_1.m_bIsUse == FALSE )
	{
		Net_Message_1.SetString( temp ) ;
		Net_Message_1.m_bIsUse = TRUE ;
	}
	else if( Net_Message_2.m_bIsUse == FALSE )
	{
		Net_Message_2.SetString( temp ) ;
		Net_Message_2.m_bIsUse = TRUE ;
	}
	else if( Net_Message_3.m_bIsUse == FALSE )
	{
		Net_Message_3.SetString( temp ) ;
		Net_Message_3.m_bIsUse = TRUE ;
	}
	else if( Net_Message_4.m_bIsUse == FALSE )
	{
		Net_Message_4.SetString( temp ) ;
		Net_Message_4.m_bIsUse = TRUE ;
	}
	else
	{
		char	string[ NETWORK_MAX_MESSAGE_LETTER+1+2+MAX_NAME_LETTER ] ;

		Net_Message_2.GetString( string ) ;
		Net_Message_1.SetString( string ) ;

		Net_Message_3.GetString( string ) ;
		Net_Message_2.SetString( string ) ;

		Net_Message_4.GetString( string ) ;
		Net_Message_3.SetString( string ) ;

		Net_Message_4.SetString( temp ) ;
	}
	// to show the net work message that communicate from others and me
	FACE_UpdateNetworkComMessageRect() ;
}


///////////////////////////////////////////////////////////////////////
//	This function is be used by Liu Gang 
//	to show the prompt text of the game_AI
//	for example : to show " We are under Attack ! "
void	FACE_ShowPromptInfor( int InforId )
{
	int			iResult ;
	class		CDDText	mission_text;	// the text surface to blit to the back buffer
	CText_apply Text;			// the instance to open a pressed file for read the mission text
	char		mission[80] ;	// the string to store the input mission text	
	int			theMissionLine ;	// the line serial number of this mission in the mission.set

	// to go out if the bottom block is showing the message box
	if( FACE_bMessageBox == TRUE)
		return ;

	iResult = mission_text.BeginText( 80 );
//	if( ! iResult )
//		return FALSE;

	theMissionLine = InforId + 1 ;	// 1 --> the first line of prompt information is at 1st line in mission.set
									// and the Text_use function is base on zero	
	memset (mission, 0, sizeof(mission)) ;
	Text.Text_open ("set\\mission.ext") ;
	Text.Text_use (mission, theMissionLine) ;
	Text.Text_close ();

	FACE_Prompt( hwndGame, mission ) ;
}
//////////////////////////////////////////////////////////
// to initialation all CDDString instances and all strings
void FACE_InitAllStrings() 
{
	Net_Message_1.ToEmpty() ;
	Net_Message_2.ToEmpty() ;
	Net_Message_3.ToEmpty() ;
	Net_Message_4.ToEmpty() ;

	for( int i=0; i<MAX_TEXT;i++ )
		pAllString[ i ]->ToEmpty() ;

	Net_EchoPrompt_Message.ToEmpty() ;

	memset( NETWORK_MESSAGE_BUF, 0, sizeof(NETWORK_MESSAGE_BUF) ) ;
	memset( NETWORK_MESSAGE_PROMPT, 0, sizeof(NETWORK_MESSAGE_BUF) ) ;
	memset( NETWORK_MESSAGE_STRING, 0, sizeof(NETWORK_MESSAGE_STRING) ) ;

	memset( DIALOG_BUF, 0, sizeof(DIALOG_BUF) ) ;

	memset( MESSAGE_BUF, 0, sizeof(MESSAGE_BUF) ) ;
	memset( MESSAGE_PROMPT, 0, sizeof(MESSAGE_PROMPT) ) ;
	memset( MESSAGE_STRING, 0, sizeof(MESSAGE_STRING) ) ;
}

⌨️ 快捷键说明

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