Пример #1
0
//---------- Begin of function Help::disp_help ----------//
//!
//! <int>   centerX, centerY - the center position of the help area.
//! <char*> helpTitle  - title of the help
//! [char*] helpDetail - detail of the help.
//!
void Help::disp_help(int centerX, int centerY, char* helpTitle, char* helpDetail) {
    if( !config.context_sensitive_help )
	return;

    mouse.hide();

    //------ calculate the position of the help box ------//

    int winWidth, winHeight, dispHelpDetail=0;

    if( helpDetail && helpDetail[0] &&              // with detailed help
	config.context_sensitive_help ) {               // Detailed Help
	winWidth  = font_san.text_width(helpDetail, -1, MSG_WIN_WIDTH-X_MARGIN*2) + X_MARGIN*2;
	// text_width() must be called before calling text_height()
	winHeight = Y_MARGIN*2 + font_san.height() + 11 + font_san.text_height(MSG_LINE_SPACE);

	int titleWidth = font_san.text_width(helpTitle, -1, MSG_WIN_WIDTH-X_MARGIN*2) + X_MARGIN*2;
	if( winWidth < titleWidth )
	    winWidth = titleWidth;

	dispHelpDetail = 1;
    }
    else {                                          // Help title only
	winWidth  = font_san.text_width(helpTitle, -1, MSG_WIN_WIDTH-X_MARGIN*2) + X_MARGIN*2;
	winHeight = Y_MARGIN*2 + font_san.height() + 3;
    }

    //--- if the text is bigger than one text box can hold, use a scrollable text box ---//

    int x1, y1, x2, y2;

    if( winWidth * winHeight > HELP_SCR_BUF_SIZE ) {
	x1 = max( 2, centerX - HELP_SCR_BUF_WIDTH  / 2 );
	y1 = max( 2, centerY - HELP_SCR_BUF_HEIGHT / 2 );

	x2 = x1 + HELP_SCR_BUF_WIDTH - 1;
	y2 = y1 + HELP_SCR_BUF_HEIGHT - 1;
    }
    else {
	x1 = max( 2, centerX - winWidth  / 2 );
	y1 = max( 2, centerY - winHeight / 2 );

	x2 = x1 + winWidth - 1;
	y2 = y1 + winHeight - 1;
    }

    if( x2 >= VGA_WIDTH ) {
	x2 = VGA_WIDTH-10;
	x1 = x2-winWidth+1;
    }

    if( y2 >= VGA_HEIGHT ) {
	y2 = VGA_HEIGHT-3;
	y1 = y2-winHeight+1;
    }

    // ######## begin Gilbert 21/12 #######//

    // -------- hide short help --------//

    //	hide_short_help(&vga_front);	// ## chwg031199
    //	short_front_buf.rest_scr(&vga_front);  // ## chwg031199
    // ######## end Gilbert 21/12 #######//

    //------------- save the area --------------//

    // save the screen to the private buffer in Help
    long_save_buf.save_scr( x1, y1, x2, y2 , &vga_front);

    //------- Draw box (and arrow if specified object) ------//

    //	vga_front.bar( x1, y1, x2, y2, V_WHITE );

    //	vga_front.bar( x1, y1, x2, y1+1, HELP_BOX_COLOR );        // Top border
    //	vga_front.bar( x1, y2-1, x2, y2, HELP_BOX_COLOR );        // Bottom border
    //	vga_front.bar( x1, y1, x1+1, y2, HELP_BOX_COLOR );        // Left border
    //	vga_front.bar( x2-1, y1, x2, y2, HELP_BOX_COLOR );        // Right border

    //vga_front.rect( x1+2, y1+2, x2, y2, 3, V_BLACK );
    vga_front.bar( x1, y1, x2-3, y2-3, VgaBuf::color_up );
    vga_front.rect( x1, y1, x2-3, y2-3, 3, HELP_BOX_COLOR );
    //	vga_front.bar_alpha( x2-2, y1+2, x2, y2-3, 1, V_BLACK );
    //	vga_front.bar_alpha( x1+2, y2-2, x2, y2, 1, V_BLACK );

    vga.use_front();
    user_interface.darken( x2-2, y1+2, x2, y2-3);
    user_interface.darken( x1+2, y2-2, x2, y2);

    //--------- disp help detail -----------//

    font_san.put( x1+X_MARGIN, y1+Y_MARGIN, helpTitle );

    if( dispHelpDetail ) {
	int y = y1 + Y_MARGIN + font_san.height() + 4;

	// vga_front.bar( x1, y, x2, y+1, HELP_BOX_COLOR );  // line between description and help text
	// line between description and help text
	vga_front.bar( x1, y, x2-3, y+1, HELP_BOX_COLOR );

	font_san.put_paragraph( x1+X_MARGIN, y+4, x2-X_MARGIN+2, y2-Y_MARGIN, helpDetail, MSG_LINE_SPACE );
    }

    //	if( sys.debug_session )
    sys.blt_virtual_buf();

    //--- in a single player game, pause the game when a help message is disp_helplayed ---//

    while( should_disp() ) {
	sys.yield();
	music.yield();

	mouse.get_event();
    }

    long_save_buf.rest_scr();
    short_back_buf.rest_scr();                      // ## chwg031199

    // ###### begin Gilbert 21/12 #######//
    // ---------- show short help -------//

    //	disp_short_help(&vga_front);
    // ##### end Gilbert 21/12 #######//

    mouse.show();

    sys.blt_virtual_buf();
}
Пример #2
0
//----------- Begin of function Help::disp --------//
//
// Display help message on the given screen location.
//
void Help::disp()
{
	//---- first check if we should disp the help now ------//

	if( !should_disp() )
	{
		disp_short_help(&vga_back);  // check if we need the short one instead
		help_code[0] = NULL;	// reset it everytime after displaying, if the mouse is still on the button, help_code will be set again.
		custom_help_title[0] = NULL;
		return;
	}

	int i;
	HelpInfo* helpInfo = NULL;

	// ------ button help -------//

	if( help_code[0] )
	{
		//--------- locate the help and display it ----------//

		helpInfo = help_info_array + (i = first_help_by_help_code);
		for( ; i<last_help_by_help_code; i++, helpInfo++ )
		{
			if( helpInfo->help_code[0] == help_code[0] &&
				 strcmp( helpInfo->help_code, help_code )==0 )
			{
				break;
			}
		}

		if( i >= last_help_by_help_code )		// not found
			helpInfo = NULL;
	}

	//-------- custom help ---------//

	else if( custom_help_title[0] )
	{
	}

	//-------- other interface help ---------//

	else
	{
		//--------- locate the help and display it ----------//

		helpInfo = help_info_array + (i = first_help_by_area);
		for( ; i<last_help_by_area ; i++, helpInfo++ )
		{
			if( !helpInfo->help_code[0] && mouse.in_area( helpInfo->calc_x1(), helpInfo->area_y1,
				helpInfo->calc_x2(), helpInfo->area_y2) && 
				( (helpInfo->monster_human_interface == 1 && config.race_id < 0) ||
					(helpInfo->monster_human_interface == 2 && config.race_id > 0) ||
					(helpInfo->monster_human_interface == 0) ) )
			{
				break;
			}
		}

		if( i >= last_help_by_area )		// not found
			helpInfo = NULL;
	}

	//-------- button help ---------//

	if( help_code[0] && helpInfo )
	{
		disp_help( help_x, help_y,
			helpInfo->help_title, helpInfo->help_text_ptr );

//		help_code[0] = NULL;		// reset it everytime after displaying, if the mouse is still on the button, help_code will be set again.
	}

	//-------- custom help ---------//

	else if( custom_help_title[0] )
	{
		disp_help(help_x, help_y, custom_help_title, custom_help_detail);
//		custom_help_title[0] = NULL;
	}

	//-------- other interface help ---------//

	else if( helpInfo )
	{
		disp_help( (helpInfo->calc_x1()+helpInfo->calc_x2())/2,
					(helpInfo->area_y1+helpInfo->area_y2)/2,
					 helpInfo->help_title, helpInfo->help_text_ptr );
	}
}
Пример #3
0
//----------- Begin of function Help::disp --------//
//!
//! Display help message on the given screen location.
//!
void Help::disp() {
    //---- first check if we should disp the help now ------//

    if( !should_disp() ) {
	// display short help here  // begin ##chwg031199
	//		disp_short_help(&vga_front);
	///////////////////////////////// end ##chwg031199
	help_code[0] = NULL;                          // reset it everytime after displaying, if the mouse is still on the button, help_code will be set again.
	custom_help_title[0] = NULL;
	return;
    }

    int i;
    HelpInfo* helpInfo = NULL;

    // ------ button help -------//

    if( help_code[0] ) {
	//--------- locate the help and display it ----------//

	helpInfo = help_info_array + (i = first_help_by_help_code);
	for( ; i<last_help_by_help_code; i++, helpInfo++ ) {
	    if( helpInfo->help_code[0] == help_code[0] &&
		strcmp( helpInfo->help_code, help_code )==0 ) {
		break;
	    }
	}

	if( i >= last_help_by_help_code )             // not found
	    helpInfo = NULL;
    }

    //-------- custom help ---------//

    else if( custom_help_title[0] ) {
    }

    //-------- other interface help ---------//

    else {
	//--------- locate the help and display it ----------//

	//		switch( current_display_mode.mode_id )
	//		{
	//		case MODE_ID_800x600x16:
	helpInfo = help_info_array + (i = first_help_by_area);
	for( ; i<last_help_by_area ; i++, helpInfo++ ) {
	    if( !helpInfo->help_code[0] && mouse.in_area( helpInfo->area800x600_x1, helpInfo->area800x600_y1,
							  helpInfo->area800x600_x2, helpInfo->area800x600_y2)
		//					( (helpInfo->monster_human_interface == 1 && config.race_id < 0) ||
		//						(helpInfo->monster_human_interface == 2 && config.race_id > 0) ||
		//						(helpInfo->monster_human_interface == 0) )
		) {
		break;
	    }
	}
	/*			break;

				case MODE_ID_1024x768x16:
				helpInfo = help_info_array + (i = first_help_by_area);
				for( ; i<last_help_by_area ; i++, helpInfo++ )
				{
				if( !helpInfo->help_code[0] && mouse.in_area( helpInfo->area1024x768_x1, helpInfo->area1024x768_y1,
				helpInfo->area1024x768_x2, helpInfo->area1024x768_y2) &&
				( (helpInfo->monster_human_interface == 1 && config.race_id < 0) ||
				(helpInfo->monster_human_interface == 2 && config.race_id > 0) ||
				(helpInfo->monster_human_interface == 0) ) )
				{
				break;
				}
				}
				break;
				default:
				err_here();
				}
	*/
	if( i >= last_help_by_area )                  // not found
	    helpInfo = NULL;
    }

    //-------- button help ---------//

    if( help_code[0] && helpInfo ) {
	disp_help( help_x, help_y,
		   helpInfo->help_title, helpInfo->help_text_ptr );

	help_code[0] = NULL;                          // reset it everytime after displaying, if the mouse is still on the button, help_code will be set again.
    }

    //-------- custom help ---------//

    else if( custom_help_title[0] ) {
	disp_help(help_x, help_y, custom_help_title, custom_help_detail);
	custom_help_title[0] = NULL;
    }

    //-------- other interface help ---------//

    else if( helpInfo ) {
	/*		switch( current_display_mode.mode_id )
			{
			case MODE_ID_800x600x16:
	*/
	disp_help( (helpInfo->area800x600_x1+helpInfo->area800x600_x2)/2,
		   (helpInfo->area800x600_y1+helpInfo->area800x600_y2)/2,
		   helpInfo->help_title, helpInfo->help_text_ptr );
	/*			break;

				case MODE_ID_1024x768x16:
				disp_help( (helpInfo->area1024x768_x1+helpInfo->area1024x768_x2)/2,
				(helpInfo->area1024x768_y1+helpInfo->area1024x768_y2)/2,
				helpInfo->help_title, helpInfo->help_text_ptr );
				break;

				default:
				err_here();
				}
	*/
    }
}