void HudGaugeWingmanStatus::renderBackground(int num_wings_to_draw)
{
	int sx, sy, bitmap;

	if((num_wings_to_draw < 1) || (num_wings_to_draw > 5)){
		Int3();
		return;
	}

	if((num_wings_to_draw > 2) && (grow_mode == GROW_LEFT)) {
		// make some room for the spacers
		sx = position[0] - (num_wings_to_draw - 2)*wing_width; 
	} else {
		sx = position[0];
	}
	sy = position[1];

	bitmap = Wingman_status_left.first_frame;

	if ( bitmap > -1 ) {
		renderBitmap(bitmap, sx, sy);
	}
	
	//Tell renderDots() where to start
	actual_origin[0] = sx;
	actual_origin[1] = sy;

	// write "wingmen" on gauge
	renderString(sx+header_offsets[0], sy+header_offsets[1], XSTR( "wingmen", 352));

	// bring us to the end of the left portion so we can draw the last or middle bits depending on how many wings we have to draw
	if ( grow_mode == GROW_DOWN ) {
		sy += left_frame_end_x;
	} else {
		sx += left_frame_end_x;
	}

	bitmap = Wingman_status_middle.first_frame;

	if ( grow_mode == GROW_DOWN ) {
		for ( int i = 0; i < num_wings_to_draw; i++ ) {
			renderBitmap(bitmap, sx, sy);
			sy += wing_width;
		}

		sy += right_frame_start_offset;
	} else {
		if(num_wings_to_draw > 2 && bitmap > 0) {
			for(int i = 0; i < num_wings_to_draw - 2; i++){
				renderBitmap(bitmap, sx, sy);
				sx += wing_width;
			}
		}

		sx += right_frame_start_offset;
	}

	bitmap = Wingman_status_right.first_frame;
	renderBitmap(bitmap, sx, sy);
}
void HudGaugeEscort::render(float frametime)
{
	int	i = 0;

	if ( !Show_escort_view ) {
		return;
	}

	if ( !Num_escort_ships ) {
		return;
	}

	// hud_set_default_color();
	setGaugeColor();

	// draw the top of the escort view
	renderBitmap(Escort_gauges[0].first_frame, position[0], position[1]);	
	renderString(position[0] + header_text_offsets[0], position[1] + header_text_offsets[1], header_text);

	int x = position[0] + list_start_offsets[0];
	int y = position[1] + list_start_offsets[1];

	//This is temporary
	Num_escort_ships--;
	i=0;

	if(Num_escort_ships)
	{
		for(; i < Num_escort_ships; i++)
		{
			if(i != 0)
			{
				x += entry_stagger_w;
				y += entry_h;
			}
			renderBitmap(Escort_gauges[1].first_frame, x, y);
			
			//Now we just show the ships info
			renderIcon(x, y, i);
		}

		//Increment for last entry
		x += entry_stagger_w;
		y += entry_h;
	}

	//Back to right #
	Num_escort_ships++;

	//Show the last escort entry
	renderBitmap(Escort_gauges[2].first_frame, x, y + bottom_bg_offset);
	renderIcon(x, y, i);
}
void HudGaugeThreatIndicator::renderLockThreat()
{
	int frame_offset, num_frames;

	//Let's find out how many frames our ani has, and adjust accordingly
	num_frames = lock_warn.num_frames;
	//We need at least two frames here
	Assert( num_frames >= 2 );

	if ( Player->threat_flags & (THREAT_LOCK | THREAT_ATTEMPT_LOCK) ) {
		if ( timestamp_elapsed(lock_warn_timer) ) {
			if ( Player->threat_flags & THREAT_LOCK )  {
				lock_warn_timer = timestamp(fl2i(THREAT_LOCK_FLASH/2.0f));
			} else {
				lock_warn_timer = timestamp(THREAT_LOCK_FLASH);
			}
			lock_warn_frame++;
			if ( lock_warn_frame > (num_frames - 1) ) { //The first frame being the default "off" setting, we need to cycle through all the other frames
				lock_warn_frame = 1;
			}
		}
		frame_offset = lock_warn_frame;
	} else {
		frame_offset = 0;
	}

	renderBitmap(lock_warn.first_frame+frame_offset, position[0] + Lock_warn_offsets[0], position[1] + Lock_warn_offsets[1]);
}
void HudGaugeReticle::render(float frametime)
{
	setGaugeColor(HUD_C_BRIGHT);

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

	if (firepoint_display) {
		fp.clear();
		getFirepointStatus();
		
		if (!fp.empty()) {
			int ax, ay;
			bm_get_info(crosshair.first_frame, &ax, &ay);
			int centerX = position[0] + (ax / 2);
			int centerY = position[1] + (ay / 2);

			for (SCP_vector<firepoint>::iterator fpi = fp.begin(); fpi != fp.end(); ++fpi) {
				if (fpi->active == 2)
					setGaugeColor(HUD_C_BRIGHT);
				else if (fpi->active == 1)
					setGaugeColor(HUD_C_NORMAL);
				else
					setGaugeColor(HUD_C_DIM);
			
				renderCircle((int) (centerX + (fpi->xy.x * firepoint_scale_x)), (int) (centerY + (fpi->xy.y * firepoint_scale_y)), firepoint_size);
			}
		}
	}
}
Beispiel #5
0
void HudGaugeRadarOrb::blitGauge()
{
    SPECMAP = -1;
    GLOWMAP = -1;

    renderBitmap(Radar_gauge.first_frame+1, position[0], position[1] );
}
void HudGaugeThreatIndicator::render(float frametime)
{
	setGaugeColor();
	renderBitmap(threat_arc.first_frame+1, position[0], position[1]);

	renderLaserThreat();
	renderLockThreat();
}
/**
 * Renders everything for a head animation
 * Also checks for when new head ani's need to start playing
 */
void HudGaugeTalkingHead::render(float frametime)
{
    if ( Head_frame.first_frame == -1 ) {
        return;
    }

    if(msg_id != -1 && head_anim != NULL) {
        if(!head_anim->done_playing) {
            // draw frame
            // hud_set_default_color();
            setGaugeColor();

            // clear
            setClip(position[0] + Anim_offsets[0], position[1] + Anim_offsets[1], Anim_size[0], Anim_size[1]);
            gr_clear();
            resetClip();

            renderBitmap(Head_frame.first_frame, position[0], position[1]);		// head ani border
            float scale_x = i2fl(Anim_size[0]) / i2fl(head_anim->width);
            float scale_y = i2fl(Anim_size[1]) / i2fl(head_anim->height);
            gr_set_screen_scale(fl2ir(base_w / scale_x), fl2ir(base_h / scale_y));
            setGaugeColor();
            generic_anim_render(head_anim,frametime, fl2ir((position[0] + Anim_offsets[0] + HUD_offset_x) / scale_x), fl2ir((position[1] + Anim_offsets[1] + HUD_offset_y) / scale_y));
            // draw title
            gr_set_screen_scale(base_w, base_h);
            renderString(position[0] + Header_offsets[0], position[1] + Header_offsets[1], XSTR("message", 217));
        } else {
            for (int j = 0; j < Num_messages_playing; ++j) {
                if (Playing_messages[j].id == msg_id) {
                    Playing_messages[j].play_anim = false;
                    break;  // only one head ani plays at a time
                }
            }
            msg_id = -1;    // allow repeated messages to display a new head ani
            head_anim = NULL; // Nothing to see here anymore, move along
        }
    }
    // check playing messages to see if we have any messages with talking animations that need to be created.
    for (int i = 0; i < Num_messages_playing; i++ ) {
        if(Playing_messages[i].play_anim && Playing_messages[i].id != msg_id ) {
            msg_id = Playing_messages[i].id;
            if (Playing_messages[i].anim_data)
                head_anim = Playing_messages[i].anim_data;
            else
                head_anim = NULL;

            return;
        }
    }
}
void HudGaugeThreatIndicator::renderLaserThreat()
{
	int frame_offset, num_frames;

	//Check how many frames the ani actually has
	num_frames = laser_warn.num_frames;
	//We need at least two frames here
	Assert( num_frames >= 2 );

	if ( Player->threat_flags & THREAT_DUMBFIRE ) {
		if ( timestamp_elapsed(laser_warn_timer) ) {
			laser_warn_timer = timestamp(THREAT_DUMBFIRE_FLASH);
			laser_warn_frame++;
			if ( laser_warn_frame > (num_frames - 1) ) { //The first frame being the default "off" setting, we need to cycle through all the other frames
				laser_warn_frame = 1;
			}
		}
		frame_offset = laser_warn_frame;
	} else {
		frame_offset = 0;
	}

	renderBitmap(laser_warn.first_frame + frame_offset, position[0] + Laser_warn_offsets[0], position[1] + Laser_warn_offsets[1]);	
}
// 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();
}
void HudGaugeShield::showShields(object *objp, int mode)
{
//	static int fod_model = -1;
	float			max_shield;
	int			hud_color_index, range;
	int			sx, sy, i;
	ship			*sp;
	ship_info	*sip;
	hud_frames	*sgp=NULL;

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

	// Goober5000 - don't show if primitive sensors
	if ( Ships[Player_obj->instance].flags[Ship::Ship_Flags::Primitive_sensors] )
		return;

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

//	bool digitus_improbus = (fod_model != -2 && strstr(sp->ship_name, "Sathanas") != NULL);
	if ( sip->shield_icon_index == 255 && !(sip->flags[Ship::Info_Flags::Generate_hud_icon]) /*&& !digitus_improbus*/) {
		return;
	}

	setGaugeColor();

	// load in shield frames if not already loaded
	if (sip->shield_icon_index != 255) {
		sgp = &Shield_gauges.at(sip->shield_icon_index);

		if ( (sgp->first_frame == -1) && (sip->shield_icon_index < Hud_shield_filenames.size()) ) {
			sgp->first_frame = bm_load_animation(Hud_shield_filenames.at(sip->shield_icon_index).c_str(), &sgp->num_frames);
			if (sgp->first_frame == -1) {
				if (!shield_ani_warning_displayed_already) {
					shield_ani_warning_displayed_already = true;
					Warning(LOCATION, "Could not load in the HUD shield ani: %s\n", Hud_shield_filenames.at(sip->shield_icon_index).c_str());
				}
				return;
			}
		}
	}

	sx = position[0];
	sy = position[1];

	sx += fl2i(HUD_offset_x);
	sy += fl2i(HUD_offset_y);

	// draw the ship first
	maybeFlashShield(SHIELD_HIT_PLAYER, Shield_hit_data[SHIELD_HIT_PLAYER].hull_hit_index);

	if(sip->shield_icon_index != 255)
	{
		renderBitmap(sgp->first_frame, sx, sy);
	}
	else
	{
		bool g3_yourself = !g3_in_frame();
		angles rot_angles = {-1.570796327f,0.0f,0.0f};
		matrix	object_orient;

		vm_angles_2_matrix(&object_orient, &rot_angles);

		gr_screen.clip_width = 112;
		gr_screen.clip_height = 93;

		//Fire it up
		if(g3_yourself)
			g3_start_frame(1);
		hud_save_restore_camera_data(1);
		setClip(sx, sy, 112, 93);

		//if(!digitus_improbus)
			g3_set_view_matrix( &sip->closeup_pos, &vmd_identity_matrix, sip->closeup_zoom * 2.5f);
		/*else
		{
			vec3d finger_vec = {0.0f, 0.0f, 176.0f};
			g3_set_view_matrix( &finger_vec, &vmd_identity_matrix, 1.0f);
		}*/

		gr_set_proj_matrix(0.5f*Proj_fov, gr_screen.clip_aspect, Min_draw_distance, Max_draw_distance);
		gr_set_view_matrix(&Eye_position, &Eye_matrix);

		//We're ready to show stuff
		//if(!digitus_improbus)
		{
			model_render_params render_info;

			render_info.set_flags(MR_NO_LIGHTING | MR_AUTOCENTER | MR_NO_FOGGING);
			render_info.set_replacement_textures(sp->ship_replacement_textures);
			render_info.set_detail_level_lock(1);
			render_info.set_object_number(OBJ_INDEX(objp));

			model_render_immediate( &render_info, sip->model_num, &object_orient, &vmd_zero_vector );
		}
		/*else
		{
			if(fod_model == -1)
			{
				fod_model = model_load(NOX("FoD.pof"), 0, NULL);
				if(fod_model == -1)
				{
					fod_model = -2;
					return;
				}
			}
			model_render(fod_model, &object_orient, &vmd_zero_vector, MR_NO_LIGHTING | MR_LOCK_DETAIL | MR_AUTOCENTER | MR_NO_FOGGING, -1, -1);
		}*/

		//We're done
		gr_end_view_matrix();
		gr_end_proj_matrix();
		if(g3_yourself)
			g3_end_frame();
		hud_save_restore_camera_data(0);

		resetClip();
	}

	if(!sip->max_shield_strength)
		return;

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

	coord2d shield_icon_coords[6];

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

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

		if ( !(sip->flags[Ship::Info_Flags::Model_point_shields]) ) {
			if ( objp->shield_quadrant[Quadrant_xlate[i]] < 0.1f )
				continue;
		} else {
			if ( objp->shield_quadrant[i] < 0.1f )
				continue;
		}

		range = MAX(HUD_COLOR_ALPHA_MAX, HUD_color_alpha + objp->n_quadrants);

		if ( !(sip->flags[Ship::Info_Flags::Model_point_shields]) )
			hud_color_index = fl2i( (objp->shield_quadrant[Quadrant_xlate[i]] / max_shield) * range);
		else
			hud_color_index = fl2i( (objp->shield_quadrant[i] / max_shield) * range);

		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;
		}

		int flash=0;
		flash = maybeFlashShield(mode, i);
		
				
		if ( !flash ) {
			// gr_set_color_fast(&HUD_color_defaults[hud_color_index]);
			setGaugeColor(hud_color_index);
			

			if(sip->shield_icon_index != 255)
			{
				int framenum = sgp->first_frame+i+1;
				if (framenum < sgp->first_frame+sgp->num_frames)
					renderBitmap(framenum, sx, sy);
			}
			else
			{
				//Ugh, draw four shield quadrants
				static const int TRI_EDGE = 6;
				static const int BAR_LENGTH = 112;
				static const int BAR_HEIGHT = 54;
				static const int BAR_WIDTH = 6;
				static const int SHIELD_OFFSET = BAR_WIDTH + TRI_EDGE + 3;

				switch(i)
				{
					//Top
					case 0:
						shield_icon_coords[0].x = sx;                     shield_icon_coords[0].y = sy+BAR_WIDTH+TRI_EDGE;
						shield_icon_coords[1].x = sx;                     shield_icon_coords[1].y = sy;
						shield_icon_coords[2].x = sx+TRI_EDGE;            shield_icon_coords[2].y = sy+BAR_WIDTH;
						shield_icon_coords[3].x = sx+BAR_LENGTH;          shield_icon_coords[3].y = sy;
						shield_icon_coords[4].x = sx+BAR_LENGTH-TRI_EDGE; shield_icon_coords[4].y = sy+BAR_WIDTH;
						shield_icon_coords[5].x = sx+BAR_LENGTH;          shield_icon_coords[5].y = sy+BAR_WIDTH+TRI_EDGE;
						renderShieldIcon(shield_icon_coords);
						break;
					//Left
					case 3:
						sy += SHIELD_OFFSET;
						shield_icon_coords[0].x = sx+BAR_WIDTH+TRI_EDGE; shield_icon_coords[0].y = sy+BAR_HEIGHT;
						shield_icon_coords[1].x = sx;                    shield_icon_coords[1].y = sy+BAR_HEIGHT;
						shield_icon_coords[2].x = sx+BAR_WIDTH;          shield_icon_coords[2].y = sy+BAR_HEIGHT-TRI_EDGE;
						shield_icon_coords[3].x = sx;                    shield_icon_coords[3].y = sy;
						shield_icon_coords[4].x = sx+BAR_WIDTH;          shield_icon_coords[4].y = sy+TRI_EDGE;
						shield_icon_coords[5].x = sx+BAR_WIDTH+TRI_EDGE; shield_icon_coords[5].y = sy;
						renderShieldIcon(shield_icon_coords);
						sy -= SHIELD_OFFSET + BAR_WIDTH + TRI_EDGE;
						break;
					//Right
					case 1:
						sx += BAR_LENGTH;
						sy += SHIELD_OFFSET;
						shield_icon_coords[0].x = sx-BAR_WIDTH-TRI_EDGE; shield_icon_coords[0].y = sy;
						shield_icon_coords[1].x = sx;                    shield_icon_coords[1].y = sy;
						shield_icon_coords[2].x = sx-BAR_WIDTH;          shield_icon_coords[2].y = sy+TRI_EDGE;
						shield_icon_coords[3].x = sx;                    shield_icon_coords[3].y = sy+BAR_HEIGHT;
						shield_icon_coords[4].x = sx-BAR_WIDTH;          shield_icon_coords[4].y = sy+BAR_HEIGHT-TRI_EDGE;
						shield_icon_coords[5].x = sx-BAR_WIDTH-TRI_EDGE; shield_icon_coords[5].y = sy+BAR_HEIGHT;
						renderShieldIcon(shield_icon_coords);
						sx -= BAR_LENGTH;
						sy -= SHIELD_OFFSET;
						break;
					//Bottom
					case 2:
						sy += BAR_HEIGHT + SHIELD_OFFSET*2 - BAR_WIDTH - TRI_EDGE;
						shield_icon_coords[0].x = sx+BAR_LENGTH;          shield_icon_coords[0].y = sy;
						shield_icon_coords[1].x = sx+BAR_LENGTH;          shield_icon_coords[1].y = sy+BAR_WIDTH+TRI_EDGE;
						shield_icon_coords[2].x = sx+BAR_LENGTH-TRI_EDGE; shield_icon_coords[2].y = sy+TRI_EDGE;
						shield_icon_coords[3].x = sx;                     shield_icon_coords[3].y = sy+BAR_WIDTH+TRI_EDGE;
						shield_icon_coords[4].x = sx+TRI_EDGE;            shield_icon_coords[4].y = sy+TRI_EDGE;
						shield_icon_coords[5].x = sx;                     shield_icon_coords[5].y = sy;
						renderShieldIcon(shield_icon_coords);
						sy -= BAR_HEIGHT + SHIELD_OFFSET*2 - BAR_WIDTH - TRI_EDGE;
						break;
					//Whoops?
					default:
						nprintf(("HUD", "Invalid shield quadrant %d specified!\n", i));
						break;
				}
			}
		}
	}

	// hud_set_default_color();
}
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);
}
Beispiel #12
0
void HudGaugeRadarStd::blitGauge()
{
	renderBitmap(Radar_gauge.first_frame+1, position[0], position[1] );
}
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));
	}
}
void HudGaugeWingmanStatus::renderDots(int wing_index, int screen_index, int num_wings_to_draw)
{
	int i, sx, sy, is_bright, bitmap = -1;

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

	if(num_wings_to_draw == 1) {
		sx = position[0] + single_wing_offsets[0];
		sy = position[1] + single_wing_offsets[1];
	} else if ( grow_mode == GROW_DOWN ) {
		sx = actual_origin[0] + multiple_wing_offsets[0]; // wing_width = 35
		sy = actual_origin[1] + multiple_wing_offsets[1] + screen_index*wing_width;
	} else {
		sx = actual_origin[0] + multiple_wing_offsets[0] + (screen_index - 1)*wing_width; // wing_width = 35
		sy = actual_origin[1] + multiple_wing_offsets[1];
	}
	
	// draw wingman dots
	for ( i = 0; i < MAX_SHIPS_PER_WING; i++ ) {

		if ( maybeFlashStatus(wing_index, i) ) {
			is_bright=1;
		} else {
			is_bright=0;
		}

		switch( HUD_wingman_status[wing_index].status[i] ) {

		case HUD_WINGMAN_STATUS_ALIVE:
			bitmap = Wingman_status_dots.first_frame;
			if ( HUD_wingman_status[wing_index].hull[i] > 0.5f ) {
				// use gauge color
				setGaugeColor(is_bright ? HUD_C_BRIGHT : HUD_C_NORMAL);
			} else {
				gr_set_color_fast(is_bright ? &Color_bright_red : &Color_red);
			}
			break;

		case HUD_WINGMAN_STATUS_DEAD:
			gr_set_color_fast(&Color_red);
			bitmap = Wingman_status_dots.first_frame+1;
			break;

		case HUD_WINGMAN_STATUS_NOT_HERE:
			setGaugeColor(is_bright ? HUD_C_BRIGHT : HUD_C_NORMAL);
			bitmap = Wingman_status_dots.first_frame+1;
			break;

		default:
			bitmap=-1;
			break;

		}	// end swtich

		if ( bitmap > -1 ) {
			renderBitmap(bitmap, sx + wingmate_offsets[i][0], sy + wingmate_offsets[i][1]);
		}
	}

	// draw wing name
	sx += wing_name_offsets[0];
	sy += wing_name_offsets[1];
	
	setGaugeColor();

	// Goober5000 - get the lowercase abbreviation
	char abbrev[4];
	abbrev[0] = (char) tolower(Squadron_wing_names[wing_index][0]);
	abbrev[1] = (char) tolower(Squadron_wing_names[wing_index][1]);
	abbrev[2] = (char) tolower(Squadron_wing_names[wing_index][2]);
	abbrev[3] = '\0';

	// Goober5000 - center it (round the offset rather than truncate it)
	int abbrev_width;
	gr_get_string_size(&abbrev_width, NULL, abbrev);
	renderString(sx - (int)((float)abbrev_width/2.0f+0.5f), sy, abbrev);
}
void HudGaugeWeaponLinking::render(float frametime)
{
	int			gauge_index=0, frame_offset=0;
	ship_weapon	*swp;

	setGaugeColor();

	if (arc.first_frame >= 0) {
		renderBitmap(arc.first_frame+1, position[0], position[1]);
	}

	swp = &Player_ship->weapons;

	switch( swp->num_primary_banks ) {
		case 0:
			gauge_index = -1;
			break;

		case 1:
			gauge_index = LINK_ONE_PRIMARY;
			if ( Player_ship->weapons.current_primary_bank == -1 ) {
				frame_offset = 0;	
			} else {
				frame_offset = 1;	
			}
			break;

		case 2:
			gauge_index = LINK_TWO_PRIMARY;
			if ( swp->current_primary_bank == -1 ) {
				frame_offset = 0;	
			} else {
				if ( Player_ship->flags[Ship::Ship_Flags::Primary_linked] ) {
					frame_offset = 3;
				} else {
					if ( swp->current_primary_bank == 0 ) {
						frame_offset = 1;
					} else {
						frame_offset = 2;
					}
				}
			}
			break;

		default:
			Int3();	// shouldn't happen (get Alan if it does)
			return;
			break;
	}
	
	if ( gauge_index != -1 ) {
		if (weapon_linking_modes[gauge_index].first_frame >= 0) {
			renderBitmap(weapon_linking_modes[gauge_index].first_frame+frame_offset, position[0] + Weapon_link_offsets[gauge_index][0], position[1] + Weapon_link_offsets[gauge_index][1]);
		}
	}

	int num_banks = swp->num_secondary_banks;
	if ( num_banks <= 0 ) {
		num_banks = Ship_info[Player_ship->ship_info_index].num_secondary_banks;
	}

	switch( num_banks ) {
		case 0:
			Int3();
			gauge_index = -1;
			break;

		case 1:
			gauge_index = LINK_ONE_SECONDARY;
			break;

		case 2:
			gauge_index = LINK_TWO_SECONDARY;
			break;

		case 3:
			gauge_index = LINK_THREE_SECONDARY;
			break;

		default:
			Int3();	// shouldn't happen (get Alan if it does)
			return;
			break;
	}
	
	if ( gauge_index != -1 ) {
		if ( swp->num_secondary_banks <= 0 ) {
			frame_offset = 0;
		} else {
			frame_offset = swp->current_secondary_bank+1;
		}
		if (weapon_linking_modes[gauge_index].first_frame >= 0) {
			renderBitmap(weapon_linking_modes[gauge_index].first_frame+frame_offset, position[0] + Weapon_link_offsets[gauge_index][0],  position[1] + Weapon_link_offsets[gauge_index][1]);
		}
	}
}
Beispiel #16
0
StaticTile::StaticTile(Bitmap* bitmap, Palette* palette) : Tile(bitmap, palette)
{
    pbitmap = new Bitmap(bitmap->getW(), bitmap->getH());
    renderBitmap();
}
Beispiel #17
0
void HudGaugeRadarStd::drawContactImage( int x, int y, int rad, int idx, int clr_idx, int size )
{
	// this we will move as ships.tbl option (or use for radar scaling etc etc)
	//int size = 24; 
	
	int w, h, old_bottom, old_bottom_unscaled, old_right, old_right_unscaled;
	float scalef, wf, hf, xf, yf;
	vec3d blip_scaler;

	if(bm_get_info(idx, &w, &h) < 0)
	{
		// Just if something goes terribly wrong
		drawContactCircle(x, y, rad);
		return;
	}

	// just to make sure the missing casts wont screw the math
	wf = (float) w;
	hf = (float) h;
	xf = (float) x;
	yf = (float) y;

	// make sure we use the larger dimension for the scaling
	// lets go case by case to make sure there are no probs
	if (size == -1)
		scalef = 1.0f;
	else if ((h == w) && (size == h))
		scalef = 1.0f;
	else if ( h > w)
		scalef = ((float) size) / hf;
	else
		scalef = ((float) size) / wf;

	Assert(scalef != 0);

	// animate the targeted icon - option 1 of highlighting the targets
	if ( rad == Radar_blip_radius_target ) {
		if (radar_target_id_flags & RTIF_PULSATE) {
			scalef *= 1.3f + (sinf(10 * f2fl(Missiontime)) * 0.3f);
		}
		if (radar_target_id_flags & RTIF_BLINK) {
			if (Missiontime & 8192)
				return;
		}
		if (radar_target_id_flags & RTIF_ENLARGE) {
			scalef *= 1.3f;
		}
	}

	// setup the scaler
	blip_scaler.xyz.x = scalef;
	blip_scaler.xyz.y = scalef;
	blip_scaler.xyz.z = 1.0f;
	
	old_bottom = gr_screen.clip_bottom;
	old_bottom_unscaled = gr_screen.clip_bottom_unscaled;
	gr_screen.clip_bottom = (int) (old_bottom/scalef);
	gr_screen.clip_bottom_unscaled = (int) (old_bottom_unscaled/scalef);

	old_right = gr_screen.clip_right;
	old_right_unscaled = gr_screen.clip_right_unscaled;
	gr_screen.clip_right = (int) (old_right/scalef);
	gr_screen.clip_right_unscaled = (int) (old_right_unscaled/scalef);

	// scale the drawing coordinates
	x = (int) ((xf / scalef) - wf/2.0f);
	y = (int) ((yf / scalef) - hf/2.0f);

	gr_push_scale_matrix(&blip_scaler);

	if ( idx >= 0 ) {
		gr_set_bitmap(idx,GR_ALPHABLEND_NONE,GR_BITBLT_MODE_NORMAL,1.0f);
		renderBitmap( x, y );
	}

	if ( clr_idx >= 0 ) {
		gr_set_screen_scale(base_w, base_h);
		gr_bitmap(x, y);
		gr_reset_screen_scale();
	}

	gr_pop_scale_matrix();

	gr_screen.clip_bottom = old_bottom;
	gr_screen.clip_bottom_unscaled = old_bottom_unscaled;

	gr_screen.clip_right = old_right;
	gr_screen.clip_right_unscaled = old_right_unscaled;
}