示例#1
0
//--------- Begin of static function disp_nation_chat ---------//
//
static void disp_nation_chat(int refreshFlag)
{
	int nationRecno = nation_filter(info.browse_nation_recno);

	//----- if the selected nation is the viewing nation ----//

	if( !(sys.debug_session || nation_array[nationRecno]->nation_type == NATION_REMOTE &&
		 info.viewing_nation_recno == nation_array.player_recno ) )
	{
		return;
	}

	//-------- display the chat get control -------//

	vga.d3_panel_down( REPORT_DET_X1, REPORT_DET_Y1, REPORT_DET_X2, REPORT_TALK_Y2 );

	font_san.put( REPORT_DET_X1+10, REPORT_DET_Y1+10,
					  "Please enter your chat message and press <Enter> to send." );

	// ###### begin Gilbert 15/10 #######//
	if( !init_get_chat )
	{
		get_chat.init( REPORT_DET_X1+10, REPORT_DET_Y1+30, REPORT_DET_X2-10,
			info.player_chat_str, CHAT_STR_LEN, &font_san, 0, 0 );
		get_chat.clear();
		init_get_chat = 1;
	}
	// ###### end Gilbert 15/10 #######//

	int vgaUseBack = vga.use_back_buf;

	vga.use_back();
	get_chat.paint(1);			// 1-paint cursor

	if( !vgaUseBack )
		vga.use_front();

	//-------- display receiver type buttons ---------//

	int y=REPORT_TALK_Y2-70;

	for( int i=1 ; i<=MAX_CHAT_RECEIVER_TYPE ; i++, y+=22 )
	{
		if( info.chat_receiver_type == i )
			vga.d3_panel_down( REPORT_DET_X1+10, y, REPORT_DET_X2-10, y+20 );
		else
			vga.d3_panel_up( REPORT_DET_X1+10, y, REPORT_DET_X2-10, y+20 );

		font_san.center_put( REPORT_DET_X1+10, y, REPORT_DET_X2-10, y+20, chat_receiver_str_array[i-1] );
	}
}
示例#2
0
//--------- Begin of static function detect_nation_chat ---------//
//
static void detect_nation_chat()
{
	int nationRecno = nation_filter(info.browse_nation_recno);

	//----- if the selected nation is the viewing nation ----//

	if( sys.debug_session || nation_array[nationRecno]->nation_type == NATION_REMOTE &&
		 info.viewing_nation_recno == nation_array.player_recno )
	{
		// ###### begin Gilbert 15/10 #######//
		if( !init_get_chat )
		{
			get_chat.init( REPORT_DET_X1+10, REPORT_DET_Y1+30, REPORT_DET_X2-10,
				info.player_chat_str, CHAT_STR_LEN, &font_san, 0, 0 );
			get_chat.clear();
			init_get_chat = 1;
		}
		// ###### end Gilbert 15/10 #######//

		for( int i=0 ; i<5 ; i++ )
		{
			int keyCode = get_chat.detect();

			if( !keyCode )
				break;

			//---- press <Enter> to send the chat message ----//

			if( keyCode == KEY_RETURN && info.player_chat_str[0] != '\0')
			{
				if( remote.is_enable() )
				{
					// packet structure : <to nation recno> <from nation recno> <char[CHAT_STR_LEN+1]>
					short *shortPtr = (short *)remote.new_send_queue_msg(MSG_CHAT, 2*sizeof(short) + strlen(info.player_chat_str)+1 );

					switch( info.chat_receiver_type )
					{
					case 1:		// selected
						shortPtr[0] = nationRecno;
						break;
					case 2:		// all allies
						shortPtr[0] = -1;
						break;
					case 3:		// all human
						shortPtr[0] = 0;
						break;
					}
					shortPtr[1] = info.viewing_nation_recno;

					strcpy(2*sizeof(short)+(char *)shortPtr, info.player_chat_str);
				}

				get_chat.clear();
				break;
			}

			mouse.get_event();
		}
	}

	//-------- detect receiver type buttons ---------//

	int y=REPORT_TALK_Y2-70;

	for( int i=1 ; i<=MAX_CHAT_RECEIVER_TYPE ; i++, y+=22 )
	{
		if( mouse.single_click( REPORT_DET_X1+10, y, REPORT_DET_X2-50, y+20 ) )
		{
			info.chat_receiver_type = i;
			return;
		}
	}
}
示例#3
0
文件: or_nat.cpp 项目: 112212/7k2
//--------- Begin of static function detect_nation_chat ---------//
//
static void detect_nation_chat()
{
/*	int nationRecno = info.nation_filter(info.browse_nation_recno);

	//----- if the selected nation is the viewing nation ----//

	if( sys.debug_session || nation_array[nationRecno]->nation_type == NATION_REMOTE &&
		 info.viewing_nation_recno == nation_array.player_recno )
	{
		// ###### begin Gilbert 22/2 #######//
		if( !init_get_chat || get_chat.x != REPORT_DET_X1+10 || get_chat.y != REPORT_DET_Y1+30 )		// re-init after resolution change
		{
			get_chat.init( REPORT_DET_X1+10, REPORT_DET_Y1+30, REPORT_DET_X2-10,
				info.player_chat_str, CHAT_STR_LEN, &font_san, 0, 0 );
			get_chat.clear();
			init_get_chat = 1;
		}
		// ###### end Gilbert 22/2 #######//

		for( int i=0 ; i<5 ; i++ )
		{
			int keyCode = get_chat.detect();

			if( !keyCode )
				break;

			//---- press <Enter> to send the chat message ----//

			if( keyCode == KEY_RETURN && info.player_chat_str[0] != '\0')
			{
				if( remote.is_enable() )
				{
					// packet structure : <to nation recno> <from nation recno> <char[CHAT_STR_LEN+1]>
					short *shortPtr = (short *)remote.new_send_queue_msg(MSG_CHAT, 2*sizeof(short) + strlen(info.player_chat_str)+1 );

					switch( info.chat_receiver_type )
					{
					case 1:		// selected
						shortPtr[0] = nationRecno;
						break;
					case 2:		// all allies
						shortPtr[0] = -1;
						break;
					case 3:		// all human
						shortPtr[0] = 0;
						break;
					}
					shortPtr[1] = info.viewing_nation_recno;

					strcpy(2*sizeof(short)+(char *)shortPtr, info.player_chat_str);
				}

				get_chat.clear();
				break;
			}

			mouse.get_event();
		}
	}

	//-------- detect receiver type buttons ---------//

	int y=REPORT_TALK_Y2-70;

	for( int i=1 ; i<=MAX_CHAT_RECEIVER_TYPE ; i++, y+=22 )
	{
		if( mouse.single_click( REPORT_DET_X1+10, y, REPORT_DET_X2-50, y+20 ) )
		{
			info.chat_receiver_type = i;
			return;
		}
	}
*/

	// init button

	if( !init_get_chat || get_chat.x != REPORT_DET_X1+10 || get_chat.y != REPORT_TALK_Y2 - 26 )		// re-init after resolution change
	{
		get_chat.init( REPORT_DET_X1 + 10, REPORT_TALK_Y2 - 26, REPORT_DET_X2-10,
			info.player_chat_str, CHAT_STR_LEN, &font_san, 0, 0 );
		get_chat.clear();

		init_get_chat = 1;
	}

	// detect receiver button 

	int x = RECIPIENT_BUTTON_X1;
	int y1 = RECIPIENT_BUTTON_Y1;
	int y2 = RECIPIENT_BUTTON_Y2;
	int i;

	if( mouse.single_click( x, y1, x+68, y2 ) )
		info.chat_receiver_type = CHAT_RECEIVER_ALL_HUMAN;
	x += 70;

	if( mouse.single_click( x, y1, x+68, y2 ) )
		info.chat_receiver_type = CHAT_RECEIVER_ALL_ALLY;
	x += 70;

	// draw nation color button
	int nc = info.nation_filter();
	int nationRecno;
	if( info.chat_receiver_type == CHAT_RECEIVER_CURRENT
		&& info.browse_nation_recno >= 1 && info.browse_nation_recno <= nc )
		nationRecno = info.nation_filter(info.browse_nation_recno);
	else
		nationRecno = 0;
	for( i = 1; i <= nc; ++i )
	{
		int n = info.nation_filter(i);
		if( nation_array[n]->is_remote() )
		{
			if( mouse.single_click( x, y1, x+24, y2 ) )
			{
				info.browse_nation_recno = i;
				info.chat_receiver_type = CHAT_RECEIVER_CURRENT;
			}
			x += 26;
		}
	}

	// draw hide nation button

	x = REPORT_DET_X2 - 200 - 8 ;
	if( mouse.single_click( x, y1, x+200-1, y2 ) )
		hide_nation_browse = !hide_nation_browse;

	// detect get, detect max 5 times

	for( i=0 ; i<5 ; i++ )
	{
		int keyCode = get_chat.detect();

		if( !keyCode )
			break;

		//---- press <Enter> to send the chat message ----//

		if( keyCode == KEY_RETURN && info.player_chat_str[0] != '\0')
		{
			if( remote.is_enable() )
			{
				// use new_msg instead of new_send_queue_msg, so chat message can send immediately
				// packet structure : <to nation recno> <from nation recno> <char[CHAT_STR_LEN+1]>
				// short *shortPtr = (short *)remote.new_send_queue_msg(MSG_CHAT, 2*sizeof(short) + strlen(info.player_chat_str)+1 );

				RemoteMsg *remoteMsg = remote.new_msg(MSG_CHAT, 2*sizeof(short) + strlen(info.player_chat_str)+1 );
				short *shortPtr = (short *)remoteMsg->data_buf;

				switch( info.chat_receiver_type )
				{
				case CHAT_RECEIVER_CURRENT:
					shortPtr[0] = nationRecno;
					break;
				case CHAT_RECEIVER_ALL_ALLY:
					shortPtr[0] = -1;
					break;
				case CHAT_RECEIVER_ALL_HUMAN:
					shortPtr[0] = 0;
					break;
				}
				shortPtr[1] = info.viewing_nation_recno;

				strcpy(2*sizeof(short)+(char *)shortPtr, info.player_chat_str);
		      remote.send_free_msg( remoteMsg );     // send out the message and free it after finishing sending
			}

			{
				// add a copy to sender
				int chatIndex = info.append_chat( NULL );
				if( chatIndex )
				{
					ChatInfo *chatInfo = &info.remote_chat_array[chatIndex-1];
					chatInfo->received_date = info.game_date;
					chatInfo->from_nation_recno = (char)info.viewing_nation_recno;
					strcpy( chatInfo->chat_str, info.player_chat_str );
				}
			}

			get_chat.clear();
			break;
		}

		mouse.get_event();
	}
}
示例#4
0
文件: or_nat.cpp 项目: 112212/7k2
//--------- Begin of static function disp_nation_chat ---------//
//
static void disp_nation_chat(int refreshFlag)
{
/*
	int nationRecno = info.nation_filter(info.browse_nation_recno);

	//----- if the selected nation is the viewing nation ----//

	if( !(sys.debug_session || nation_array[nationRecno]->nation_type == NATION_REMOTE &&
		 info.viewing_nation_recno == nation_array.player_recno ) )
	{
		return;
	}

	//-------- display the chat get control -------//

	vga_util.d3_panel_down( REPORT_DET_X1, REPORT_DET_Y1, REPORT_DET_X2, REPORT_TALK_Y2 );

	font_bld.put( REPORT_DET_X1+10, REPORT_DET_Y1+10,
					  // "Please enter your chat message and press <Enter> to send." );
		text_reports.str_chat_inst() );

	// ###### begin Gilbert 22/2 #######//
	if( !init_get_chat || get_chat.x != REPORT_DET_X1+10 || get_chat.y != REPORT_DET_Y1+30 )		// re-init after resolution change
	// ###### end Gilbert 22/2 #######//
	{
		get_chat.init( REPORT_DET_X1+10, REPORT_DET_Y1+30, REPORT_DET_X2-10,
			info.player_chat_str, CHAT_STR_LEN, &font_san, 0, 0 );
		get_chat.clear();

		button_hide_nation_browse.create_text( REPORT_DET_X2-100, REPORT_TALK_Y2-24,
			REPORT_DET_X2-8, REPORT_TALK_Y2-8, "Hide Kingdoms' Detail" );

		init_get_chat = 1;
	}

	int vgaUseBack = vga.use_back_buf;

	vga.use_back();
	get_chat.paint(1);			// 1-paint cursor

	if( !vgaUseBack )
		vga.use_front();

	//-------- display receiver type buttons ---------//

	int y=REPORT_TALK_Y2-70;

	for( int i=1 ; i<=MAX_CHAT_RECEIVER_TYPE ; i++, y+=22 )
	{
		if( info.chat_receiver_type == i )
			vga_util.d3_panel_down( REPORT_DET_X1+10, y, REPORT_DET_X2-10, y+20 );
		else
			vga_util.d3_panel_up( REPORT_DET_X1+10, y, REPORT_DET_X2-10, y+20 );

		// font_bld.center_put( REPORT_DET_X1+10, y, REPORT_DET_X2-10, y+20, chat_receiver_str_array[i-1] );
		font_bld.center_put( REPORT_DET_X1+10, y, REPORT_DET_X2-10, y+20, 
			text_reports.str_chat_recipient(i) );
	}
*/

	int vgaUseBack = vga.use_back_buf;
	vga.use_back();

	// init button

	if( !init_get_chat || get_chat.x != REPORT_DET_X1+10 || get_chat.y != REPORT_TALK_Y2 - 26 )		// re-init after resolution change
	{
		get_chat.init( REPORT_DET_X1 + 10, REPORT_TALK_Y2 - 26, REPORT_DET_X2-10,
			info.player_chat_str, CHAT_STR_LEN, &font_san, 0, 0 );
		get_chat.clear();

		init_get_chat = 1;
	}

	// disp frame
	vga_util.d3_panel_down( REPORT_DET_X1, REPORT_DET_Y1, REPORT_DET_X2, REPORT_TALK_Y2 );

	font_bld.put( REPORT_DET_X1+10, REPORT_TALK_Y2 - 66,
					  // "Please enter your chat message and press <Enter> to send." );
		text_reports.str_chat_inst() );

	// display receiver button 

	int x = RECIPIENT_BUTTON_X1;
	int y1 = RECIPIENT_BUTTON_Y1;
	int y2 = RECIPIENT_BUTTON_Y2;
	int i;

	if( info.chat_receiver_type == CHAT_RECEIVER_ALL_HUMAN )
	{
		vga_util.d3_panel_down( x, y1, x+68, y2 );
		font_bld.center_put( x, y1+2, x+68, y2-1, text_reports.str_chat_recipient(CHAT_RECEIVER_ALL_HUMAN) );
	}
	else
	{
		vga_util.d3_panel_up( x, y1, x+68, y2, 0, 1 );
		font_bld.center_put( x, y1+1, x+68, y2-2, text_reports.str_chat_recipient(CHAT_RECEIVER_ALL_HUMAN) );
	}
	x += 70;

	if( info.chat_receiver_type == CHAT_RECEIVER_ALL_ALLY )
	{
		vga_util.d3_panel_down( x, y1, x+68, y2 );
		font_bld.center_put( x, y1+2, x+68, y2-1, text_reports.str_chat_recipient(CHAT_RECEIVER_ALL_ALLY) );
	}
	else
	{
		vga_util.d3_panel_up( x, y1, x+68, y2, 0, 1 );
		font_bld.center_put( x, y1+1, x+68, y2-2, text_reports.str_chat_recipient(CHAT_RECEIVER_ALL_ALLY) );
	}
	x += 70;

	// draw nation color button
	int nc = info.nation_filter();
	int nationRecno;
	if( info.chat_receiver_type == CHAT_RECEIVER_CURRENT
		&& info.browse_nation_recno >= 1 && info.browse_nation_recno <= nc )
		nationRecno = info.nation_filter(info.browse_nation_recno);
	else
		nationRecno = 0;
	for( i = 1; i <= nc; ++i )
	{
		int n = info.nation_filter(i);
		if( nation_array[n]->is_remote() )
		{
			if( nationRecno == n )
			{
				vga_util.d3_panel_down( x, y1, x+24, y2 );
				vga.active_buf->bar( x+7, y1+7, x+18, y2-5, nation_array[n]->nation_color );
			}
			else
			{
				vga_util.d3_panel_up( x, y1, x+24, y2, 0 ,1 );
				vga.active_buf->bar( x+6, y1+6, x+17, y2-6, nation_array[n]->nation_color );
			}
			x += 26;
		}
	}

	// draw hide nation button

	x = REPORT_DET_X2 - 200 - 8 ;
	if( hide_nation_browse )
	{
		vga_util.d3_panel_down( x, y1, x+200-1, y2 );
		font_bld.center_put( x, y1+2, x+200-1, y2-1, text_reports.str_hide_nation_detail() );
	}
	else
	{
		vga_util.d3_panel_up( x, y1, x+200-1, y2, 0, 1 );
		font_bld.center_put( x, y1+1, x+200-1, y2-2, text_reports.str_hide_nation_detail() );
	}

	// draw get field

	get_chat.paint(1);			// 1-paint cursor

	// display message log, display news in reversed order, from down to up

	int chatMsgCount = info.chat_msg_filter();
	int msgY = REPORT_TALK_Y2 - 80;
	for( i = -1; i >= -chatMsgCount && msgY >= REPORT_DET_Y1+4 ; --i )
	{
		ChatInfo *chatInfo = &info.remote_chat_array[info.chat_msg_filter(i)-1];
		if( !nation_array.is_deleted( chatInfo->from_nation_recno ) )
		{
			nation_array[chatInfo->from_nation_recno]->disp_nation_color( REPORT_DET_X1+10, msgY+2 );
			font_cara_w.put( REPORT_DET_X1+25, msgY, chatInfo->chat_str, 0, REPORT_DET_X2-6 );
			msgY -= font_cara_w.max_font_height;
		}
	}

	if( !vgaUseBack )
		vga.use_front();
}