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

📄 interfa2.cpp

📁 网页游戏赤壁
💻 CPP
📖 第 1 页 / 共 4 页
字号:
			// to send message like button-cancle
				PostMessage( hwndGame, WM_COMMAND, BUTTON_MENU_MAIN_NETWORK_INPUTNAME_CANCEL, 0 );
				break;		
			case 0x13:	// Return
				// to send message like button-ok
				PostMessage( hwndGame, WM_COMMAND, BUTTON_MENU_MAIN_NETWORK_INPUTNAME_OK, 0 );
				break;		
			default:	// all other characters
				{
				// add the character to the text buffer.
					if( DIALOG_LETTER_X +1 == MAX_DIALOG_LETTER )
					{
	           			::MessageBeep (0) ;
						break;
					}
					if( wParam == 13 )		// Enter or Return
						return FALSE;
					DIALOG_BUF[DIALOG_LETTER_X + 1]	= DIALOG_BUF[DIALOG_LETTER_X];
					DIALOG_BUF[DIALOG_LETTER_X] = (char) wParam;
					DIALOG_LETTER_X++;
				// draw the character on the screen
					FACE_Echo_prompt(hwnd);
				}
				break;
			}
	}
	else if( FACE_bMessageBox == TRUE )
	{
		switch(wParam)
		{
			case 0x08:	// Backspace
			// move the caret back one space, and then process this like the DEL key
				if( MESSAGE_LETTER_X > 0 )
				{
					MESSAGE_BUF[MESSAGE_LETTER_X - 1] = MESSAGE_BUF[MESSAGE_LETTER_X];
					MESSAGE_BUF[MESSAGE_LETTER_X] = '\0';
					MESSAGE_LETTER_X--;
				// draw the character on the screen
					FACE_Echo_prompt(hwnd);
				}
				break;
			default:	// all other characters
				{
				// add the character to the text buffer.
					if( MESSAGE_LETTER_X +1 == MAX_MESSAGE_LETTER )
					{
	           			::MessageBeep (0) ;
						break;
					}
					if( wParam == 13 )		// Enter or Return
						return FALSE;
					MESSAGE_BUF[MESSAGE_LETTER_X + 1]	= MESSAGE_BUF[MESSAGE_LETTER_X];
					MESSAGE_BUF[MESSAGE_LETTER_X] = (char) wParam;
					MESSAGE_LETTER_X++;
				// draw the character on the screen
					FACE_Echo_prompt(hwnd);
				}
				break;
			}
	}
	else if( ( FACE_GetProgramState() == PROGRAM_STATE_MENU )&&
 			 ( CurrentMenu == &Menu_NetWork_SetNet )
		)
	{
		switch(wParam)
		{
			case 0x08:	// Backspace
			// move the caret back one space, and then process this like the DEL key
				if( NETWORK_MESSAGE_LETTER_X > 0 )
				{
					NETWORK_MESSAGE_BUF[NETWORK_MESSAGE_LETTER_X - 1] = NETWORK_MESSAGE_BUF[NETWORK_MESSAGE_LETTER_X];
					NETWORK_MESSAGE_BUF[NETWORK_MESSAGE_LETTER_X] = '\0';
					NETWORK_MESSAGE_LETTER_X--;
				// draw the character on the screen
					FACE_Echo_prompt(hwnd);
				}
				break;
			default:	// all other characters
				{
				// add the character to the text buffer.
					if( NETWORK_MESSAGE_LETTER_X +1 == NETWORK_MAX_MESSAGE_LETTER )
					{
	           			::MessageBeep (0) ;
						break;
					}
					if( wParam == 13 )		// Enter or Return
						return FALSE;
					NETWORK_MESSAGE_BUF[NETWORK_MESSAGE_LETTER_X + 1]	= NETWORK_MESSAGE_BUF[NETWORK_MESSAGE_LETTER_X];
					NETWORK_MESSAGE_BUF[NETWORK_MESSAGE_LETTER_X] = (char) wParam;
					NETWORK_MESSAGE_LETTER_X++;
				// draw the character on the screen
					FACE_Echo_prompt(hwnd);
				}
				break;
			}
	}

	return TRUE;
}
// to get the current input string from out of this file					
LPCTSTR	FACE_GetCurrentString()
{
	return	MESSAGE_BUF;
}
//////////////////////////////////////////////////////////////////////////////////////////
//     						prompt functions											//
//																						//
//		LPCTSTR	GetCurrentString()														//
//		void Prompt( HWND hwnd, LPCTSTR message, int posX = 30, int posY = 460 )			//
//		void echo_prompt( HWND hwnd, LPCTSTR message, int posX = 30, int posY = 460 )	//
//////////////////////////////////////////////////////////////////////////////////////////
//extern LPDIRECTDRAWSURFACE lpDDSFront;
////////////////////////////////////////
// to show message box
////////////////////////////////////////
void	FACE_SetMessage(void)
{
	if( FACE_bMessageBox == FALSE )
		return;

	memset( MESSAGE_PROMPT, 0, sizeof(MESSAGE_PROMPT) ) ;
	memset( MESSAGE_STRING, 0, sizeof(MESSAGE_STRING) ) ;
	memset( MESSAGE_BUF, 0, sizeof(MESSAGE_BUF) ) ;
	MESSAGE_BUF[0] = '_';
	MESSAGE_LETTER_X = 0;

	// to read the help text from the information file
	CText_apply Text;			// the instance to open a pressed file for read the mission text

	memset (MESSAGE_PROMPT, 0, sizeof(MESSAGE_PROMPT)) ;
	Text.Text_open ("set\\hz.ext") ;
	Text.Text_use (MESSAGE_PROMPT, 39) ;
	Text.Text_close ();

	return;
}
// to set the message for the set network menu
void	FACE_NetWorkSetMessage(void)
{
	if( CurrentMenu != &Menu_NetWork_SetNet )
		return;

	memset( MESSAGE_PROMPT, 0, sizeof(MESSAGE_PROMPT) );
	memset( NETWORK_MESSAGE_STRING, 0, sizeof(NETWORK_MESSAGE_STRING) );
	memset( NETWORK_MESSAGE_BUF, 0, sizeof(NETWORK_MESSAGE_BUF) );
	NETWORK_MESSAGE_BUF[0] = '_';
	NETWORK_MESSAGE_LETTER_X = 0;

	// to read the help text from the information file
	CText_apply Text;			// the instance to open a pressed file for read the mission text

	memset (MESSAGE_PROMPT, 0, sizeof(MESSAGE_PROMPT)) ;
	Text.Text_open ("set\\hz.ext") ;
	Text.Text_use (MESSAGE_PROMPT, 39) ;
	Text.Text_close ();

	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_Prompt( HWND hwnd, LPCTSTR message, int posX /*= 30*/, int posY /*= 460*/ )
{
	RECT	MessageRect;
	class	CDDText MESSAGE_TEXT;		// the string attribute of MESSAGE_STRING
	char	message_temp1[8];		// to place the '(' character temperary
	char	message_temp2[4];		// to place the 'A' capital character of a command
	char	message_temp3[256];		// to place the ').............'  string
	char	message_money[256];		// to place the word "钱"
	char	message_moneyNum[256];	// to place the number of money
	char	message_food[256];		// to place the word "粮"
	char	message_foodNum[256] ;	// to place the number of food
	char	message_wood[256];		// to place the word "木"
	char	message_woodNum[256] ;	// to place the number of wood
	char	message_iron[256];		// to place the word "铁"
	char	message_ironNum[256] ;	// to place the number of iron

	char	message_jm[256] ;		// to place the word "需计谋"
	char	message_jmNum[256] ;	// to place the number of 计谋

	int		ZyFlag = 0 ;			// to record how many '@' appear in message_temp3 to flag the  资源
	int		JmFlag = 0 ;			// to record how many '&' appear in message_temp3 to flag the  计谋

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

	// to get a surface for you string
	MESSAGE_TEXT.BeginText( 76 );	// ( 640 - 30 ) / 16

if( FACE_GetProgramState() != PROGRAM_STATE_MENU )
{
	memset(message_temp1, 0,sizeof(message_temp1)) ;
	memset(message_temp2, 0,sizeof(message_temp2)) ;
	memset(message_temp3, 0,sizeof(message_temp3)) ;

	MessageRect.left = posX;
	MessageRect.top = posY;
	MessageRect.right = 640;
	MessageRect.bottom = 480;
	// TO UPDATE THE MESSAGE BACKGROUND
	sBottom.Blit();

	// to judge whether this message is a command prompt
	if( message[0] == '(' )
	{
		message_temp1[0] = '(';
		message_temp1[1] = '\0';
		message_temp2[0] = message[1];
		message_temp2[1] = '\0';
		memmove( message_temp3, message+2, strlen(message)-1 );

		int	len = strlen(message_temp3) ;

		memset(message_moneyNum, 0,sizeof(message_moneyNum)) ;
		memset(message_foodNum, 0,sizeof(message_foodNum)) ;
		memset(message_woodNum, 0,sizeof(message_woodNum)) ;
		memset(message_ironNum, 0,sizeof(message_ironNum)) ;

		memset(message_jmNum, 0,sizeof(message_jmNum)) ;

		for( int i=0; i<len; i++ )
		{
			if( message_temp3[i] == '@' )
			{
				ZyFlag++ ;
				continue ;
			}

			if( ZyFlag )
			{
				char tempstring[2] ;
				tempstring[1] = '\0' ;

				tempstring[0] = message_temp3[i] ;

				if( ZyFlag == 1 )
					strcat(message_moneyNum, tempstring) ;
				else if( ZyFlag ==2 )
					strcat(message_foodNum, tempstring) ;
				else if( ZyFlag ==3 )
					strcat(message_woodNum, tempstring) ;
				else if( ZyFlag ==4 )
					strcat(message_ironNum, tempstring) ;
				else if( ZyFlag ==5 )
					break ;
			}
		}
		if( ! ZyFlag )
		{
			for( int k=0; k<len; k++ )
			{
				if( message_temp3[k] == '&' )
				{
					JmFlag++ ;
					continue ;
				}

				if( JmFlag )
				{
					char tempstring[2] ;
					tempstring[1] = '\0' ;

					tempstring[0] = message_temp3[k] ;

					if( JmFlag == 1 )
						strcat(message_jmNum, tempstring) ;
					else if( JmFlag ==2 )
						break ;
				}
			}
		}

		if(ZyFlag)
		{
			for( int j=0; j<len; j++)
			{
				if( message_temp3[j] == '@' )
				{
					message_temp3[j] = '\0' ;
					break;
				}
			}

			memset(message_money, 0,sizeof(message_money)) ;
			memset(message_food, 0,sizeof(message_food)) ;
			memset(message_wood, 0,sizeof(message_wood)) ;
			memset(message_iron, 0,sizeof(message_iron)) ;

			// to read the hz from the hz.ext information file
			CText_apply Text;			// the instance to open a pressed file for read the mission text
			Text.Text_open ("set\\hz.ext") ;
			Text.Text_use (message_money, 0) ;
			Text.Text_use (message_food, 1) ;
			Text.Text_use (message_wood, 2) ;
			Text.Text_use (message_iron, 3) ;
			Text.Text_close ();

			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, 120) );
			MESSAGE_TEXT.MyTextOut( DD_GetBackBuffer(), MessageRect.left+350, MessageRect.top, message_money );
			MESSAGE_TEXT.SetTextColor( RGB(255, 255, 255) ) ;
			MESSAGE_TEXT.MyTextOut( DD_GetBackBuffer(), MessageRect.left+374, MessageRect.top, message_moneyNum );
			MESSAGE_TEXT.SetTextColor( RGB(255, 255, 120) );
			MESSAGE_TEXT.MyTextOut( DD_GetBackBuffer(), MessageRect.left+414, MessageRect.top, message_food );
			MESSAGE_TEXT.SetTextColor( RGB(255, 255, 255) ) ;
			MESSAGE_TEXT.MyTextOut( DD_GetBackBuffer(), MessageRect.left+438, MessageRect.top, message_foodNum );
			MESSAGE_TEXT.SetTextColor( RGB(255, 255, 120) );
			MESSAGE_TEXT.MyTextOut( DD_GetBackBuffer(), MessageRect.left+475, MessageRect.top, message_wood );
			MESSAGE_TEXT.SetTextColor( RGB(255, 255, 255) ) ;
			MESSAGE_TEXT.MyTextOut( DD_GetBackBuffer(), MessageRect.left+502, MessageRect.top, message_woodNum );
			MESSAGE_TEXT.SetTextColor( RGB(255, 255, 120) );
			MESSAGE_TEXT.MyTextOut( DD_GetBackBuffer(), MessageRect.left+542, MessageRect.top, message_iron );
			MESSAGE_TEXT.SetTextColor( RGB(255, 255, 255) ) ;
			MESSAGE_TEXT.MyTextOut( DD_GetBackBuffer(), MessageRect.left+566, MessageRect.top, message_ironNum );

			MESSAGE_TEXT.SetTextColor( RGB(255, 255, 255) );
			MESSAGE_TEXT.MyTextOut( DD_GetBackBuffer(), MessageRect.left+32, MessageRect.top, message_temp3 );
		}
		else if(JmFlag)
		{
			for( int m=0; m<len; m++)
			{
				if( message_temp3[m] == '&' )
					message_temp3[m] = '\0' ;
			}
			memset(message_jm, 0,sizeof(message_jm)) ;

			// to read the hz from the hz.ext information file
			CText_apply Text;			// the instance to open a pressed file for read the mission text
			Text.Text_open ("set\\hz.ext") ;
			Text.Text_use (message_jm, 38) ;
			Text.Text_close ();

			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, 120) );
			MESSAGE_TEXT.MyTextOut( DD_GetBackBuffer(), MessageRect.left+365, MessageRect.top, message_jm );

⌨️ 快捷键说明

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