Пример #1
0
void HudGaugeRadar::drawRange()
{
	char buf[32];

	// hud_set_bright_color();
	setGaugeColor(HUD_C_BRIGHT);

	switch ( HUD_config.rp_dist ) {

	case RR_SHORT:
		renderPrintf(position[0] + Radar_dist_offsets[RR_SHORT][0], position[1] + Radar_dist_offsets[RR_SHORT][1], XSTR( "2k", 467));
		break;

	case RR_LONG:
		renderPrintf(position[0] + Radar_dist_offsets[RR_LONG][0], position[1] + Radar_dist_offsets[RR_LONG][1], XSTR( "10k", 468));
		break;

	case RR_INFINITY:
		sprintf(buf, NOX("%c"), Lcl_special_chars);
		renderPrintf(position[0] + Radar_dist_offsets[RR_INFINITY][0], position[1] + Radar_dist_offsets[RR_INFINITY][1], buf);
		break;

	default:
		Int3();	// can't happen (get Alan if it does)
		break;
	}
}
Пример #2
0
/**
 * Render the ETS retail gauge to the screen (weapon+shield+engine)
 */
void HudGaugeEtsRetail::render(float frametime)
{
	int i;
	int initial_position;

	ship* ship_p = &Ships[Player_obj->instance];

	if ( Ets_bar.first_frame < 0 ) {
		return;
	}

	// if at least two gauges are not shown, don't show any
	i = 0;
	if (!ship_has_energy_weapons(ship_p)) i++;
	if (Player_obj->flags & OF_NO_SHIELDS) i++;
	if (!ship_has_engine_power(ship_p)) i++;
	if (i >= 2) return;

	setGaugeColor();

	// draw the letters for the gauges first, before any clipping occurs
	// skip letter for any missing gauges (max one, see check above)
	initial_position = 0;
	if (ship_has_energy_weapons(ship_p)) {
		Letter = Letters[0];
		position[0] = Gauge_positions[initial_position++];
		renderPrintf(position[0] + Letter_offsets[0], position[1] + Letter_offsets[1], NOX("%c"), Letter);
	}
	if (!(Player_obj->flags & OF_NO_SHIELDS)) {
		Letter = Letters[1];
		position[0] = Gauge_positions[initial_position++];
		renderPrintf(position[0] + Letter_offsets[0], position[1] + Letter_offsets[1], NOX("%c"), Letter);
	}
	if (ship_has_engine_power(ship_p)) {
		Letter = Letters[2];
		position[0] = Gauge_positions[initial_position++];
		renderPrintf(position[0] + Letter_offsets[0], position[1] + Letter_offsets[1], NOX("%c"), Letter);
	}

	// draw gauges, skipping any gauge that is missing
	initial_position = 0;
	if (ship_has_energy_weapons(ship_p)) {
		Letter = Letters[0];
		position[0] = Gauge_positions[initial_position++];
		blitGauge(ship_p->weapon_recharge_index);
	}
	if (!(Player_obj->flags & OF_NO_SHIELDS)) {
		Letter = Letters[1];
		position[0] = Gauge_positions[initial_position++];
		blitGauge(ship_p->shield_recharge_index);
	}
	if (ship_has_engine_power(ship_p)) {
		Letter = Letters[2];
		position[0] = Gauge_positions[initial_position++];
		blitGauge(ship_p->engine_recharge_index);
	}
}
Пример #3
0
void HudGaugeEtsWeapons::render(float frametime)
{
	int i;

	ship* ship_p = &Ships[Player_obj->instance];	

	if ( Ets_bar.first_frame < 0 ) {
		return;
	}

	// if at least two gauges are not shown, don't show any
	i = 0;
	if (!ship_has_energy_weapons(ship_p)) i++;
	if (Player_obj->flags & OF_NO_SHIELDS) i++;
	if (!ship_has_engine_power(ship_p)) i++;
	if (i >= 2) return;

	// no weapon energy, no weapon gauge
	if (!ship_has_energy_weapons(ship_p))
	{
		return;
	}

	setGaugeColor();

	// draw the letters for the gauge first, before any clipping occurs
	renderPrintf(position[0] + Letter_offsets[0], position[1] + Letter_offsets[1], NOX("%c"), Letter);

	// draw the gauges for the weapon system
	blitGauge(ship_p->weapon_recharge_index);
}
Пример #4
0
// multiplayer dogfight
void HudGaugeEscort::renderIconDogfight(int x, int y, int index)
{
	int			hull_integrity = 100;
	char			buf[255];	
	int			np_index;
	object		*objp;

	int stat_shift = 40;

	// always use the standard color to avoid confusion
	setGaugeColor();

	// netplayer index
	np_index = find_player_id(Escort_ships[index].np_id);
	if((np_index < 0) || (np_index >= MAX_PLAYERS) || (Net_players[np_index].m_player == NULL)){
		return;
	}
	
	// print out player name
	strcpy_s(buf, Net_players[np_index].m_player->callsign);
	font::force_fit_string(buf, 255, 100 - stat_shift);
	renderString( x + ship_name_offsets[0], y + ship_name_offsets[1], EG_ESCORT1 + index, buf);	

	// can we get the player object?
	objp = NULL;
	if((Net_players[np_index].m_player->objnum >= 0) && (Net_players[np_index].m_player->objnum < MAX_OBJECTS) && (Objects[Net_players[np_index].m_player->objnum].type == OBJ_SHIP)){
		objp = &Objects[Net_players[np_index].m_player->objnum];
		if((objp->instance >= 0) && (objp->instance < MAX_SHIPS) && (Ships[objp->instance].ship_info_index >= 0) && (Ships[objp->instance].ship_info_index < MAX_SHIPS)){
			//
		} else {
			return;
		}

		hull_integrity = (int)(((float)objp->hull_strength / (float)Ships[objp->instance].ship_max_hull_strength) * 100.0f);
		if(hull_integrity < 0){
			hull_integrity = 0;
		}
	}

	// show ship integrity
	if(objp == NULL){	
		renderPrintf( x+ship_integrity_offsets[0] - stat_shift, y+ship_integrity_offsets[1], EG_NULL, "%d", Net_players[np_index].m_player->stats.m_kill_count_ok);	
	} else {
		renderPrintf( x+ship_integrity_offsets[0] - stat_shift, y+ship_integrity_offsets[1], EG_NULL, "(%d%%) %d", hull_integrity, Net_players[np_index].m_player->stats.m_kill_count_ok);	
	}
}
void HudGaugeThrottle::renderMatchSpeedIcon(int x, int y)
{
	if (Match_speed_draw_background)
	{
		// One pixel boundary
		renderRect(x, y, Match_speed_icon_width + 2, gr_get_font_height() + 2);
		
		gr_set_color_fast(&Color_black);
		renderPrintf(x + 1, y + 1, "%c", Match_speed_icon);

		setGaugeColor();
	}
	else
	{
		renderPrintf(x, y, "%c", Match_speed_icon);
	}
}
void HudGaugeThrottle::renderThrottleSpeed(float current_speed, int y_end)
{
	char buf[32];
	int sx, sy, x_pos, y_pos, w, h;

	//setGaugeColor();
	sprintf(buf, "%d", fl2i(current_speed+0.5f));
	hud_num_make_mono(buf, font_num);
	gr_get_string_size(&w, &h, buf);

	if ( orbit ) {
		// y_end is the y-coordinate of the current throttle setting, calc x-coordinate for edge of 
		// circle (x^2 + y^2 = r^2)
		y_pos = position[1] + Orbit_center_offsets[1] - y_end;
		x_pos = (int)sqrt(double(orbit_radius * orbit_radius - y_pos * y_pos) );
		x_pos = position[0] + Orbit_center_offsets[0] - x_pos;

		// draw current speed at (x_pos, y_end);
		sx = x_pos - w - 2;
		sy = fl2i(y_end - h/2.0f + 1.5);
	} else {
		sx = position[0] + Orbit_center_offsets[0] - w;
		sy = position[1] + Orbit_center_offsets[1];
	}
	
	renderPrintf(sx, sy, buf);

	if ( object_get_gliding(Player_obj) ) { 
		if ( Use_custom_glide ) {
			renderString(position[0] + Glide_offsets[0], position[1] + Glide_offsets[1], "GLIDE");
		} else {
			int offset;
			if ( current_speed <= 9.5 ) {
				offset = -31;
			} else if ( current_speed <= 99.5 ) {
				offset = -22;
			} else {
				offset = -13;
			}

			renderString(sx+offset, sy + h, "GLIDE");
		}
	} else if ( Players[Player_num].flags & PLAYER_FLAGS_MATCH_TARGET ) {
		if ( Use_custom_match_speed ) {
			renderMatchSpeedIcon(position[0] + Match_speed_offsets[0], position[1] + Match_speed_offsets[1]);
		} else {
			int offset;
			if ( current_speed <= 9.5 ) {
				offset = 0;
			} else {
				offset = 3;
			}

			renderMatchSpeedIcon(sx+offset, sy + h);
		}
	}
}
// draw the shield icon and integrity for the escort ship
void HudGaugeEscort::renderIcon(int x, int y, int index)
{
	if(MULTI_DOGFIGHT && index <= 2)
	{
		renderIconDogfight(x, y, index);
		return;
	}

	float	shields, integrity;
	int		screen_integrity, offset;
	char	buf[255];

	object	*objp	= &Objects[Escort_ships[index].objnum];
	ship	*sp		= &Ships[objp->instance];

	// determine if its "friendly" or not	
	// Goober5000 - changed in favor of just passing the team
	setGaugeColorEscort(index, sp->team);
	/*
	if(Player_ship != NULL){
		hud_escort_set_gauge_color(index, (sp->team == Player_ship->team) ? 1 : 0);
	} else {
		hud_escort_set_gauge_color(index, 1);
	}
	*/

	// draw a 'D' if a ship is disabled
	if ( (sp->flags & SF_DISABLED) || (ship_subsys_disrupted(sp, SUBSYSTEM_ENGINE)) ) {		
		renderString( x + ship_status_offsets[0], y + ship_status_offsets[1], EG_NULL, XSTR( "D", 284));				
	}

	// print out ship name
	strcpy_s(buf, sp->ship_name);
	gr_force_fit_string(buf, 255, ship_name_max_width);	
    end_string_at_first_hash_symbol(buf);
	
	renderString( x + ship_name_offsets[0], y + ship_name_offsets[1], EG_ESCORT1 + index, buf);	

	// show ship integrity
	hud_get_target_strength(objp, &shields, &integrity);
	screen_integrity = fl2i(integrity*100 + 0.5f);
	offset = 0;
	if ( screen_integrity < 100 ) {
		offset = 2;
		if ( screen_integrity == 0 ) {
			if ( integrity > 0 ) {
				screen_integrity = 1;
			}
		}
	}
	renderPrintf( x+ship_integrity_offsets[0] + offset, y+ship_integrity_offsets[1], EG_NULL, "%d", screen_integrity);

	//Let's be nice.
	setGaugeColor();
}
Пример #8
0
void HudGaugeRadar::drawRange()
{
	// hud_set_bright_color();
	setGaugeColor(HUD_C_BRIGHT);

	switch ( HUD_config.rp_dist ) {

	case RR_SHORT:
		renderPrintf(position[0] + Radar_dist_offsets[RR_SHORT][0], position[1] + Radar_dist_offsets[RR_SHORT][1], XSTR( "2k", 467));
		break;

	case RR_LONG:
		renderPrintf(position[0] + Radar_dist_offsets[RR_LONG][0], position[1] + Radar_dist_offsets[RR_LONG][1], XSTR( "10k", 468));
		break;

	case RR_INFINITY:
		renderPrintf(position[0] + Radar_dist_offsets[RR_INFINITY][0], position[1] + Radar_dist_offsets[RR_INFINITY][1], "%c", Radar_infinity_icon);
		break;

	default:
		Int3();	// can't happen (get Alan if it does)
		break;
	}
}
Пример #9
0
/**
 * HudGaugeMessages::render() will display the active HUD messages on the HUD.  It will scroll
 * the messages up when a new message arrives.
 */
void HudGaugeMessages::render(float frametime)
{
    hud_set_default_color();

    // dependant on max_width, max_lines, and line_height
    setClip(position[0], position[1], Window_width, Window_height+2);

    for ( SCP_vector<Hud_display_info>::iterator m = active_messages.begin(); m != active_messages.end(); ++m) {
        if ( !timestamp_elapsed(m->total_life) ) {
            if ( !(Player->flags & PLAYER_FLAGS_MSG_MODE) || !Hidden_by_comms_menu) {
                // set the appropriate color
                if ( m->msg.source ) {
                    setGaugeColor(HUD_C_BRIGHT);
                } else {
                    setGaugeColor();
                }

                // print the message out
                renderPrintf(m->msg.x, m->y, "%s", m->msg.text.c_str());
            }
        }
    }
}
void HudGaugeDirectives::render(float frametime)
{
	char buf[256], *second_line;
	int i, t, x, y, z, end, offset, bx, by, y_count;
	color *c;

	if (!Training_obj_num_lines){
		return;
	}

	offset = 0;
	end = Training_obj_num_lines;
	if (end > Max_directives) {
		end = Max_directives;
		offset = Training_obj_num_lines - end;
	}

	// draw top of objective display
	setGaugeColor();

	renderBitmap(directives_top.first_frame, position[0], position[1]);

	// print out title
	renderPrintf(position[0] + header_offsets[0], position[1] + header_offsets[1], EG_OBJ_TITLE, XSTR( "directives", 422));

	bx = position[0];
	by = position[1] + middle_frame_offset_y;

	y_count = 0;
	for (i=0; i<end; i++) {
		x = position[0] + text_start_offsets[0];
		y = position[1] + text_start_offsets[1] + y_count * text_h;
		z = TRAINING_OBJ_LINES_MASK(i + offset);

		c = &Color_normal;
		if (Training_obj_lines[i + offset] & TRAINING_OBJ_LINES_KEY) {
			message_translate_tokens(buf, Mission_events[z].objective_key_text);  // remap keys
			c = &Color_bright_green;
		} else {
			strcpy_s(buf, Mission_events[z].objective_text);
			if (Mission_events[z].count){
				sprintf(buf + strlen(buf), NOX(" [%d]"), Mission_events[z].count);
			}

			// if this is a multiplayer tvt game, and this is event is not for my team, don't display it
			if((MULTI_TEAM) && (Net_player != NULL)){
				if((Mission_events[z].team != -1) && (Net_player->p_info.team != Mission_events[z].team)){
					continue;
				}
			}

			switch (mission_get_event_status(z)) {
			case EVENT_CURRENT:
				c = &Color_bright_white;
				break;

			case EVENT_FAILED:
				c = &Color_bright_red;
				break;

			case EVENT_SATISFIED:
				t = Mission_events[z].satisfied_time;
				if (t + i2f(2) > Missiontime) {
					if (Missiontime % fl2f(.4f) < fl2f(.2f)){
						c = &Color_bright_blue;
					} else {
						c = &Color_bright_white;
					}
				} else {
					c = &Color_bright_blue;
				}
				break;
			}
		}

		// maybe split the directives line
		second_line = split_str_once(buf, max_line_width);
		Assert( second_line != buf );

		// blit the background frames
		setGaugeColor();

		renderBitmap(directives_middle.first_frame, bx, by);
		
		by += text_h;

		if ( second_line ) {
			renderBitmap(directives_middle.first_frame, bx, by);
			
			by += text_h;
		}

		// blit the text
		gr_set_color_fast(c);
		
		renderString(x, y, EG_OBJ1 + i, buf);
		
		y_count++;

		if ( second_line ) {
			y = position[1] + text_start_offsets[1] + y_count * text_h;
			
			renderString(x+12, y, EG_OBJ1 + i + 1, second_line);
			
			y_count++;
		}
	}

	// draw the bottom of objective display
	setGaugeColor();

	renderBitmap(directives_bottom.first_frame, bx, by + bottom_bg_offset);
}
/**
 * Displays (renders) the training message to the screen
 */
void HudGaugeTrainingMessages::render(float frametime)
{
	const char *str;
	char buf[256];
	int i, z, x, y, height, mode, count;

	if (Training_failure){
		return;
	}

	if (timestamp_elapsed(Training_message_timestamp) || !strlen(Training_buf)){
		return;
	}

	if (Training_num_lines <= 0){
		return;
	}

	gr_set_screen_scale(base_w, base_h);
	height = gr_get_font_height();
	gr_set_shader(&Training_msg_glass);
	gr_shade(position[0], position[1], TRAINING_MESSAGE_WINDOW_WIDTH, Training_num_lines * height + height);
	gr_reset_screen_scale();

	gr_set_color_fast(&Color_bright_blue);
	mode = count = 0;
	for (i=0; i<Training_num_lines; i++) {  // loop through all lines of message
		str = Training_lines[i];
		z = 0;
		x = position[0] + (TRAINING_MESSAGE_WINDOW_WIDTH - TRAINING_LINE_WIDTH) / 2;
		y = position[1] + i * height + height / 2 + 1;

		while ((str - Training_lines[i]) < Training_line_lengths[i]) {  // loop through each character of each line
			if ((count < MAX_TRAINING_MESSAGE_MODS) && (str == Training_message_mods[count].pos)) {
				buf[z] = 0;
				renderPrintf(x, y, buf);
				gr_get_string_size(&z, NULL, buf);
				x += z;
				z = 0;

				mode = Training_message_mods[count++].mode;
				switch (mode) {
					case TMMOD_NORMAL:
						gr_set_color_fast(&Color_bright_blue);
						break;

					case TMMOD_BOLD:
						gr_set_color_fast(&Color_white);
						break;
				}
			}

			buf[z++] = *str++;
		}

		if (z) {
			buf[z] = 0;
			renderPrintf(x, y, "%s", buf);
		}
	}
}
void HudGaugeThrottle::render(float frametime)
{
	float	desired_speed, max_speed, current_speed, absolute_speed, absolute_displayed_speed, max_displayed_speed, percent_max, percent_aburn_max;
	int	desired_y_pos, y_end;

	ship_info	*sip;
	sip = &Ship_info[Player_ship->ship_info_index];

	current_speed = Player_obj->phys_info.fspeed;
	if ( current_speed < 0.0f){
		current_speed = 0.0f;
	}

	max_speed = Ships[Player_obj->instance].current_max_speed;
	if ( max_speed <= 0 ) {
		max_speed = sip->max_vel.xyz.z;
	}

	absolute_speed = Player_obj->phys_info.speed;

	// scale by distance modifier from hud_guages.tbl for display purposes
	absolute_displayed_speed = absolute_speed * Hud_speed_multiplier;
	max_displayed_speed = max_speed * Hud_speed_multiplier;

	desired_speed = Player->ci.forward * max_speed;
	if ( desired_speed < 0.0f ){		// so ships that go backwards don't force the indicators below where they can go
		desired_speed = 0.0f;
	}

	desired_y_pos = position[1] + Bottom_offset_y - fl2i(throttle_h*desired_speed/max_speed+0.5f) - 1;

	if (max_speed <= 0) {
		percent_max = 0.0f;
	} else {
		percent_max = current_speed / max_speed;
	}

	percent_aburn_max = 0.0f;
	if ( percent_max > 1 ) {
		percent_max = 1.0f;
		percent_aburn_max = (current_speed - max_speed) / (sip->afterburner_max_vel.xyz.z - max_speed);
		if ( percent_aburn_max > 1.0f ) {
			percent_aburn_max = 1.0f;
		}
		if ( percent_aburn_max < 0 ) {
			percent_aburn_max = 0.0f;
		}
	}

	y_end = position[1] + Bottom_offset_y - fl2i(throttle_h*percent_max+0.5f);
	if ( percent_aburn_max > 0 ) {
		y_end -= fl2i(percent_aburn_max * throttle_aburn_h + 0.5f);
	}

	if ( Player_obj->phys_info.flags & PF_AFTERBURNER_ON ) {
		// default value is 240 when afterburner is on. 
		//I'm assuming that this value is basically Bottom_offset_y - throttle_aburn_h - throttle_h
		desired_y_pos = position[1] + Bottom_offset_y - throttle_aburn_h - throttle_h; 
	}

	setGaugeColor();
	
	if(Show_background) {
		renderThrottleBackground(y_end);
	} else {
		renderBitmap(throttle_frames.first_frame, position[0], position[1]);			
	}

	// draw throttle speed number
	//hud_render_throttle_speed(current_speed, y_end);
	// Absolute speed, not forward speed, for hud speed reticle - fixes the guage for sliding -- kazan
	renderThrottleSpeed(absolute_displayed_speed, y_end);

	// draw target speed if necessary
	if ( Show_target_speed ) {
		char buf[32];
		int w, h;

		if ( Show_percent ) {
			if ( Player_obj->phys_info.flags & PF_AFTERBURNER_ON ) {
				strcpy_s(buf, "A/B");
			} else {
				sprintf(buf, XSTR( "%d%%", 326), fl2i( (desired_speed/max_speed)*100 + 0.5f ));
			}
		} else {
			sprintf(buf, "%d", fl2i(desired_speed * Hud_speed_multiplier + 0.5f));
		}

		hud_num_make_mono(buf, font_num);
		gr_get_string_size(&w, &h, buf);

		renderString(position[0] + Target_speed_offsets[0] - w, position[1] + Target_speed_offsets[1], buf);
	}

	// draw the "desired speed" bar on the throttle
	renderThrottleLine(desired_y_pos);

	// draw left arc (the bright portion of the throttle gauge)
	renderThrottleForeground(y_end);

	if ( Show_max_speed ) {
		renderPrintf(position[0] + Max_speed_offsets[0], position[1] + Max_speed_offsets[1], "%d",fl2i(max_displayed_speed+0.5f));
	}
	
	if ( Show_min_speed ) {
		renderPrintf(position[0] + Zero_speed_offsets[0], position[1] + Zero_speed_offsets[1], XSTR( "0", 292));
	}
}