// Draw the miniature shield icon that is drawn near the reticle
// this function is only used by multi_ingame_join_display_ship() in multi_ingame.cpp as of the new HudGauge implementation (Swifty)
void hud_shield_show_mini(object *objp, int x_force, int y_force, int x_hull_offset, int y_hull_offset)
{
	float			max_shield;
	int			hud_color_index, range, frame_offset;
	int			sx, sy, i;

	if ( objp->type != OBJ_SHIP ) {
		return;
	}

	hud_set_gauge_color(HUD_TARGET_MINI_ICON);

	if (!Shield_mini_loaded)
		return;

	sx = (x_force == -1) ? Shield_mini_coords[gr_screen.res][0]+fl2i(HUD_offset_x) : x_force;
	sy = (y_force == -1) ? Shield_mini_coords[gr_screen.res][1]+fl2i(HUD_offset_y) : y_force;

	// draw the ship first
	hud_shield_maybe_flash(HUD_TARGET_MINI_ICON, SHIELD_HIT_TARGET, Shield_hit_data[SHIELD_HIT_TARGET].hull_hit_index);
	hud_show_mini_ship_integrity(objp, x_force + x_hull_offset,y_force + y_hull_offset);

	// draw the four quadrants
	// Draw shield quadrants at one of NUM_SHIELD_LEVELS
	max_shield = get_max_shield_quad(objp);

	for ( i = 0; i < objp->n_quadrants; i++ ) {

		if ( objp->flags[Object::Object_Flags::No_shields] || i >= DEFAULT_SHIELD_SECTIONS) {
			break;
		}

		if (objp->shield_quadrant[Quadrant_xlate[i]] < 0.1f ) {
			continue;
		}

		if ( hud_shield_maybe_flash(HUD_TARGET_MINI_ICON, SHIELD_HIT_TARGET, i) ) {
			frame_offset = i+objp->n_quadrants;
		} else {
			frame_offset = i;
		}
				
		range = HUD_color_alpha;
		hud_color_index = fl2i( (objp->shield_quadrant[Quadrant_xlate[i]] / max_shield) * range + 0.5);
		Assert(hud_color_index >= 0 && hud_color_index <= range);
	
		if ( hud_color_index < 0 ) {
			hud_color_index = 0;
		}
		if ( hud_color_index >= HUD_NUM_COLOR_LEVELS ) {
			hud_color_index = HUD_NUM_COLOR_LEVELS - 1;
		}

		if ( hud_gauge_maybe_flash(HUD_TARGET_MINI_ICON) == 1) {
			// hud_set_bright_color();
			hud_set_gauge_color(HUD_TARGET_MINI_ICON, HUD_C_BRIGHT);
		} else {
			// gr_set_color_fast(&HUD_color_defaults[hud_color_index]);
			hud_set_gauge_color(HUD_TARGET_MINI_ICON, hud_color_index);
		}					 

		GR_AABITMAP(Shield_mini_gauge.first_frame + frame_offset, sx + HUD_nose_x, sy + HUD_nose_y);		
	}
	
	// hud_set_default_color();
}
Example #2
0
// -------------------------------------------------------------------------------------------------
// hud_show_ets() will display the charge rates for the three systems, and the reserve
// energy for shields and weapons.  hud_show_ets() is called once per frame.
//
void hud_show_ets()
{
	int i, j, index, y_start, y_end, clip_h, w, h, x, y;

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

	if (Ets_gauge.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;

	hud_set_gauge_color(HUD_ETS_GAUGE);

	// draw the letters for the gauges first, before any clipping occurs
	i = 0;
	for (j = 0; j < 3; j++)
	{
		if (j == 0 && !ship_has_energy_weapons(ship_p))
		{
			continue;
		}
		if (j == 1 && Player_obj->flags & OF_NO_SHIELDS)
		{
			continue;
		}
		if (j == 2 && !ship_has_engine_power(ship_p))
		{
			continue;
		}
		Assert(Ets_gauge_info != NULL);
		gr_printf(Ets_gauge_info[i].letter_coords[0], Ets_gauge_info[i].letter_coords[1], NOX("%c"),
			Ets_gauge_info[j].letter);
		i++;
	}

	// draw the three energy gauges
	i = 0;
	index = 0;
	for (j = 0; j < 3; j++)
	{
		switch (j)
		{
		case 0:
			index = ship_p->weapon_recharge_index;
			if (!ship_has_energy_weapons(ship_p))
			{
				continue;
			}
			break;
		case 1:
			index = ship_p->shield_recharge_index;
			if (Player_obj->flags & OF_NO_SHIELDS)
			{
				continue;
			}
			break;
		case 2:
			index = ship_p->engine_recharge_index;
			if (!ship_has_engine_power(ship_p))
			{
				continue;
			}
			break;
		}

		clip_h = fl2i((1 - Energy_levels[index]) * ETS_bar_h[gr_screen.res]);

		bm_get_info(Ets_gauge.first_frame, &w, &h);

		if (index < NUM_ENERGY_LEVELS - 1)
		{
			// some portion of dark needs to be drawn

			hud_set_gauge_color(HUD_ETS_GAUGE);

			// draw the top portion

			Assert(Ets_gauge_info != NULL);
			x = Ets_gauge_info[i].top_coords[0];
			y = Ets_gauge_info[i].top_coords[1];

			hud_aabitmap_ex(Ets_gauge.first_frame, x, y, w, clip_h, 0, 0);

			// draw the bottom portion
			Assert(Ets_gauge_info != NULL);
			x = Ets_gauge_info[i].bottom_coords[0];
			y = Ets_gauge_info[i].bottom_coords[1];

			y_start = y + (ETS_bar_h[gr_screen.res] - clip_h);
			y_end = y + ETS_bar_h[gr_screen.res];

			hud_aabitmap_ex(Ets_gauge.first_frame, x, y_start, w, y_end - y_start, 0, ETS_bar_h[gr_screen.res] -
				clip_h);
		}

		if (index > 0)
		{
			if (hud_gauge_maybe_flash(HUD_ETS_GAUGE) == 1)
			{
				hud_set_gauge_color(HUD_ETS_GAUGE, HUD_C_DIM);
				// hud_set_dim_color();
			}
			else
			{
				hud_set_gauge_color(HUD_ETS_GAUGE, HUD_C_BRIGHT);
				// hud_set_bright_color();
			}
			// some portion of recharge needs to be drawn

			// draw the top portion
			Assert(Ets_gauge_info != NULL);
			x = Ets_gauge_info[i].top_coords[0];
			y = Ets_gauge_info[i].top_coords[1];

			y_start = y + clip_h;
			y_end = y + ETS_bar_h[gr_screen.res];

			hud_aabitmap_ex(Ets_gauge.first_frame + 1, x, y_start, w, y_end - y_start, 0, clip_h);

			// draw the bottom portion
			Assert(Ets_gauge_info != NULL);
			x = Ets_gauge_info[i].bottom_coords[0];
			y = Ets_gauge_info[i].bottom_coords[1];

			hud_aabitmap_ex(Ets_gauge.first_frame + 2, x, y, w, ETS_bar_h[gr_screen.res] - clip_h, 0, 0);
		}
		i++;
	}

	// hud_set_default_color();
}
Example #3
0
// Draw the miniature shield icon that is drawn near the reticle
void hud_shield_show_mini(object* objp, int x_force, int y_force, int x_hull_offset, int y_hull_offset)
{
	float max_shield;
	int hud_color_index, range, frame_offset;
	int sx, sy, i;
	shield_hit_info* shi;

	shi = &Shield_hit_data[SHIELD_HIT_TARGET];

	if (objp->type != OBJ_SHIP)
	{
		return;
	}

	hud_set_gauge_color(HUD_TARGET_MINI_ICON);

	if (!Shield_mini_loaded)
	{
		hud_shield_mini_load();
	}

	sx = (x_force == -1) ? current_hud->Shield_mini_coords[0] + fl2i(HUD_offset_x) : x_force;
	sy = (y_force == -1) ? current_hud->Shield_mini_coords[1] + fl2i(HUD_offset_y) : y_force;

	// draw the ship first
	hud_shield_maybe_flash(HUD_TARGET_MINI_ICON, SHIELD_HIT_TARGET, HULL_HIT_OFFSET);
	hud_show_mini_ship_integrity(objp, x_force + x_hull_offset, y_force + y_hull_offset);

	// draw the four quadrants
	// Draw shield quadrants at one of NUM_SHIELD_LEVELS
	max_shield = get_max_shield_quad(objp);

	for (i = 0; i < MAX_SHIELD_SECTIONS; i++)
	{

		if (objp->flags & OF_NO_SHIELDS)
		{
			break;
		}

		if (objp->shield_quadrant[Quadrant_xlate[i]] < 0.1f)
		{
			continue;
		}

		if (hud_shield_maybe_flash(HUD_TARGET_MINI_ICON, SHIELD_HIT_TARGET, i))
		{
			frame_offset = i + MAX_SHIELD_SECTIONS;
		}
		else
		{
			frame_offset = i;
		}

		range = HUD_color_alpha;
		hud_color_index = fl2i((objp->shield_quadrant[Quadrant_xlate[i]] / max_shield) * range + 0.5);
		Assert(hud_color_index >= 0 && hud_color_index <= range);

		if (hud_color_index < 0)
		{
			hud_color_index = 0;
		}
		if (hud_color_index >= HUD_NUM_COLOR_LEVELS)
		{
			hud_color_index = HUD_NUM_COLOR_LEVELS - 1;
		}

		if (hud_gauge_maybe_flash(HUD_TARGET_MINI_ICON) == 1)
		{
			// hud_set_bright_color();
			hud_set_gauge_color(HUD_TARGET_MINI_ICON, HUD_C_BRIGHT);
		}
		else
		{
			// gr_set_color_fast(&HUD_color_defaults[hud_color_index]);
			hud_set_gauge_color(HUD_TARGET_MINI_ICON, hud_color_index);
		}

		hud_aabitmap(Shield_mini_gauge.first_frame + frame_offset, sx + HUD_nose_x, sy + HUD_nose_y);
	}

	// hud_set_default_color();
}
Example #4
0
// Draw the miniature shield icon that is drawn near the reticle
void hud_shield_show_mini(object *objp, int x_force, int y_force, int x_hull_offset, int y_hull_offset)
{
	float			max_shield;
	int			hud_color_index, range, frame_offset;
	int			sx, sy, i;
	ship			*sp;
	ship_info	*sip;
	shield_hit_info	*shi;

	shi = &Shield_hit_data[SHIELD_HIT_TARGET];

	if ( objp->type != OBJ_SHIP ) {
		return;
	}

	sp = &Ships[objp->instance];
	sip = &Ship_info[sp->ship_info_index];

	hud_set_gauge_color(HUD_TARGET_MINI_ICON);

	if (!Shield_mini_loaded)
		return;

	sx = (x_force == -1) ? Shield_mini_coords[gr_screen.res][0]+fl2i(HUD_offset_x) : x_force;
	sy = (y_force == -1) ? Shield_mini_coords[gr_screen.res][1]+fl2i(HUD_offset_y) : y_force;

	// draw the ship first
	hud_shield_maybe_flash(HUD_TARGET_MINI_ICON, SHIELD_HIT_TARGET, HULL_HIT_OFFSET);
	hud_show_mini_ship_integrity(objp,x_force + x_hull_offset,y_force + y_hull_offset);

	// draw the four quadrants
	// Draw shield quadrants at one of NUM_SHIELD_LEVELS
	max_shield = sip->shields/4.0f;

	for ( i = 0; i < 4; i++ ) {

		if ( objp->flags & OF_NO_SHIELDS ) {
			break;
		}

		if ( objp->shields[Quadrant_xlate[i]] < 0.1f ) {
			continue;
		}

		if ( hud_shield_maybe_flash(HUD_TARGET_MINI_ICON, SHIELD_HIT_TARGET, i) ) {
			frame_offset = i+4;
		} else {
			frame_offset = i;
		}
				
		range = HUD_color_alpha;
		hud_color_index = fl2i( (objp->shields[Quadrant_xlate[i]] / max_shield) * range + 0.5);
		Assert(hud_color_index >= 0 && hud_color_index <= range);
	
		if ( hud_color_index < 0 ) {
			hud_color_index = 0;
		}
		if ( hud_color_index >= HUD_NUM_COLOR_LEVELS ) {
			hud_color_index = HUD_NUM_COLOR_LEVELS - 1;
		}

		if ( hud_gauge_maybe_flash(HUD_TARGET_MINI_ICON) == 1) {
			// hud_set_bright_color();
			hud_set_gauge_color(HUD_TARGET_MINI_ICON, HUD_C_BRIGHT);
		} else {
			// gr_set_color_fast(&HUD_color_defaults[hud_color_index]);
			hud_set_gauge_color(HUD_TARGET_MINI_ICON, hud_color_index);
		}					 

		GR_AABITMAP(Shield_mini_gauge.first_frame + frame_offset, sx, sy);		
	}
	
	// hud_set_default_color();
}