Esempio n. 1
0
/**
 * Draw one ETS bar to screen
 */
void HudGaugeEts::blitGauge(int index)
{
	int y_start, y_end, clip_h, w, h, x, y;

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

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

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

		setGaugeColor();

		// draw the top portion
		x = position[0] + Top_offsets[0];
		y = position[1] + Top_offsets[1];
		
		renderBitmapEx(Ets_bar.first_frame,x,y,w,clip_h,0,0);			

		// draw the bottom portion
		x = position[0] + Bottom_offsets[0];
		y = position[1] + Bottom_offsets[1];

		y_start = y + (ETS_bar_h - clip_h);
		y_end = y + ETS_bar_h;
		
		renderBitmapEx(Ets_bar.first_frame, x, y_start, w, y_end-y_start, 0, ETS_bar_h-clip_h);			
	}

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

		// draw the top portion
		x = position[0] + Top_offsets[0];
		y = position[1] + Top_offsets[1];

		y_start = y + clip_h;
		y_end = y + ETS_bar_h;
		
		renderBitmapEx(Ets_bar.first_frame+1, x, y_start, w, y_end-y_start, 0, clip_h);			

		// draw the bottom portion
		x = position[0] + Bottom_offsets[0];
		y = position[1] + Bottom_offsets[1];
		
		renderBitmapEx(Ets_bar.first_frame+2, x,y,w,ETS_bar_h-clip_h,0,0);			
	}
}
Esempio n. 2
0
// Draw the miniature shield icon that is drawn near the reticle
void HudGaugeShieldMini::showMiniShields(object *objp)
{
	float			max_shield;
	int			hud_color_index, range, frame_offset;
	int			sx, sy, i;

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

	setGaugeColor();

	sx = position[0]+fl2i(HUD_offset_x);
	sy = position[1]+fl2i(HUD_offset_y);

	// draw the ship first
	maybeFlashShield(SHIELD_HIT_TARGET, Shield_hit_data[SHIELD_HIT_TARGET].hull_hit_index);
	showIntegrity(get_hull_pct(objp));

	// 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] ) {
			break;
		}

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

		if ( maybeFlashShield(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 ( maybeFlashSexp() == 1) {
			// hud_set_bright_color();
			setGaugeColor(HUD_C_BRIGHT);
		} else {
			// gr_set_color_fast(&HUD_color_defaults[hud_color_index]);
			setGaugeColor(hud_color_index);
		}					 

		if (frame_offset < Shield_mini_gauge.num_frames)
			renderBitmap(Shield_mini_gauge.first_frame + frame_offset, sx, sy);		
	}
	
	// hud_set_default_color();
}