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); } } }
void hud_show_mini_ship_integrity(object *objp, int x_force, int y_force) { char text_integrity[64]; int numeric_integrity; float p_target_integrity,initial_hull; int nx, ny; initial_hull = Ship_info[Ships[objp->instance].ship_info_index].initial_hull_strength; if ( initial_hull <= 0 ) { Int3(); // illegal initial hull strength p_target_integrity = 0.0f; } else { p_target_integrity = objp->hull_strength / initial_hull; if (p_target_integrity < 0){ p_target_integrity = 0.0f; } } numeric_integrity = fl2i(p_target_integrity*100 + 0.5f); if(numeric_integrity > 100){ numeric_integrity = 100; } // Assert(numeric_integrity <= 100); // base coords nx = (x_force == -1) ? Hud_mini_base[gr_screen.res][0] : x_force; ny = (y_force == -1) ? Hud_mini_base[gr_screen.res][1] : y_force; // 3 digit hull strength if ( numeric_integrity == 100 ) { nx += Hud_mini_3digit[gr_screen.res][2]; } // 2 digit hull strength else if ( numeric_integrity < 10 ) { nx += Hud_mini_1digit[gr_screen.res][2]; } // 1 digit hull strength else { nx += Hud_mini_2digit[gr_screen.res][2]; } if ( numeric_integrity == 0 ) { if ( p_target_integrity > 0 ) { numeric_integrity = 1; } } nx += fl2i( HUD_offset_x ); ny += fl2i( HUD_offset_y ); sprintf(text_integrity, "%d", numeric_integrity); if ( numeric_integrity < 100 ) { hud_num_make_mono(text_integrity); } gr_string(nx, ny, text_integrity); }
void hud_show_mini_ship_integrity(object* objp, int x_force, int y_force) { char text_integrity[64]; int numeric_integrity; float p_target_integrity; int final_pos[2]; p_target_integrity = get_hull_pct(objp); numeric_integrity = fl2i(p_target_integrity * 100 + 0.5f); if (numeric_integrity > 100) { numeric_integrity = 100; } // Assert(numeric_integrity <= 100); // 3 digit hull strength if (numeric_integrity == 100) { memcpy(final_pos, current_hud->Hud_mini_3digit, sizeof(final_pos)); } // 1 digit hull strength else if (numeric_integrity < 10) { memcpy(final_pos, current_hud->Hud_mini_1digit, sizeof(final_pos)); } // 2 digit hull strength else { memcpy(final_pos, current_hud->Hud_mini_2digit, sizeof(final_pos)); } if (numeric_integrity == 0) { if (p_target_integrity > 0) { numeric_integrity = 1; } } final_pos[0] += fl2i(HUD_offset_x); final_pos[1] += fl2i(HUD_offset_y); sprintf(text_integrity, "%d", numeric_integrity); if (numeric_integrity < 100) { hud_num_make_mono(text_integrity); } gr_string(final_pos[0] + HUD_nose_x, final_pos[1] + HUD_nose_y, text_integrity); }
void hud_show_mini_ship_integrity(object *objp, int x_force, int y_force) { char text_integrity[64]; int numeric_integrity; float p_target_integrity; int final_pos[2]; p_target_integrity = get_hull_pct(objp); numeric_integrity = fl2i(p_target_integrity*100 + 0.5f); if(numeric_integrity > 100){ numeric_integrity = 100; } // Assert(numeric_integrity <= 100); // 3 digit hull strength if ( numeric_integrity == 100 ) { final_pos[0] = x_force + Hud_mini_3digit[gr_screen.res][0] - Shield_mini_coords[gr_screen.res][0]; final_pos[1] = y_force + Hud_mini_3digit[gr_screen.res][1] - Shield_mini_coords[gr_screen.res][1]; } // 1 digit hull strength else if ( numeric_integrity < 10 ) { final_pos[0] = x_force + Hud_mini_1digit[gr_screen.res][0] - Shield_mini_coords[gr_screen.res][0]; final_pos[1] = y_force + Hud_mini_1digit[gr_screen.res][1] - Shield_mini_coords[gr_screen.res][1]; } // 2 digit hull strength else { final_pos[0] = x_force + Hud_mini_2digit[gr_screen.res][0] - Shield_mini_coords[gr_screen.res][0]; final_pos[1] = y_force + Hud_mini_2digit[gr_screen.res][1] - Shield_mini_coords[gr_screen.res][1]; } if ( numeric_integrity == 0 ) { if ( p_target_integrity > 0 ) { numeric_integrity = 1; } } sprintf(text_integrity, "%d", numeric_integrity); if ( numeric_integrity < 100 ) { hud_num_make_mono(text_integrity); } gr_string(final_pos[0], final_pos[1], text_integrity); }
void HudGaugeShieldMini::showIntegrity(float p_target_integrity) { char text_integrity[64]; int numeric_integrity; int final_pos[2]; numeric_integrity = fl2i(p_target_integrity*100 + 0.5f); if(numeric_integrity > 100){ numeric_integrity = 100; } // Assert(numeric_integrity <= 100); // 3 digit hull strength if ( numeric_integrity == 100 ) { memcpy(final_pos, Mini_3digit_offsets, sizeof(final_pos)); } // 1 digit hull strength else if ( numeric_integrity < 10 ) { memcpy(final_pos, Mini_1digit_offsets, sizeof(final_pos)); } // 2 digit hull strength else { memcpy(final_pos, Mini_2digit_offsets, sizeof(final_pos)); } if ( numeric_integrity == 0 ) { if ( p_target_integrity > 0 ) { numeric_integrity = 1; } } final_pos[0] += fl2i( HUD_offset_x ) + position[0]; final_pos[1] += fl2i( HUD_offset_y ) + position[1]; sprintf(text_integrity, "%d", numeric_integrity); if ( numeric_integrity < 100 ) { hud_num_make_mono(text_integrity, font_num); } renderString(final_pos[0], final_pos[1], text_integrity); }
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 show_stats_numbers(int stage, int sx, int sy, int dy,int add_mission) { char text[30]; float pct; sy += 2*dy; switch ( stage ) { case MISSION_STATS: // mission kills stats sprintf(text,"%d",Active_player->stats.m_kill_count_ok); gr_printf(sx,sy,text); // stats_underline_text(sx,sy,text); sy += 2*dy; // mission primary weapon stats sprintf(text,"%d",Active_player->stats.mp_shots_fired); gr_printf(sx,sy,text); sy += dy; sprintf(text,"%d",Active_player->stats.mp_shots_hit); gr_printf(sx,sy,text); sy += dy; sprintf(text,"%d",Active_player->stats.mp_bonehead_hits); gr_printf(sx,sy,text); sy += dy; if(Active_player->stats.mp_shots_fired>0) pct=(float)100.0*((float)Active_player->stats.mp_shots_hit/(float)Active_player->stats.mp_shots_fired); else pct=(float)0.0; sprintf(text,"%d",(int)pct); strcat(text," %%"); gr_printf(sx,sy,text); sy += dy; if(Active_player->stats.mp_bonehead_hits>0) pct=(float)100.0*((float)Active_player->stats.mp_bonehead_hits/(float)Active_player->stats.mp_shots_fired); else pct=(float)0.0; sprintf(text,"%d",(int)pct); strcat(text," %%"); gr_printf(sx,sy,text); sy += 2*dy; // mission secondary weapon stats sprintf(text,"%d",Active_player->stats.ms_shots_fired); gr_printf(sx,sy,text); sy += dy; sprintf(text,"%d",Active_player->stats.ms_shots_hit); gr_printf(sx,sy,text); sy += dy; sprintf(text,"%d",Active_player->stats.ms_bonehead_hits); gr_printf(sx,sy,text); sy += dy; if(Active_player->stats.ms_shots_fired>0) pct=(float)100.0*((float)Active_player->stats.ms_shots_hit/(float)Active_player->stats.ms_shots_fired); else pct=(float)0.0; sprintf(text,"%d",(int)pct); strcat(text," %%"); gr_printf(sx,sy,text); sy += dy; if(Active_player->stats.ms_bonehead_hits>0) pct=(float)100.0*((float)Active_player->stats.ms_bonehead_hits/(float)Active_player->stats.ms_shots_fired); else pct=(float)0.0; sprintf(text,"%d",(int)pct); strcat(text," %%"); gr_printf(sx,sy,text); sy += 2*dy; // mission assists and player rescues (respawns) sprintf(text,"%d",(int)Active_player->stats.m_assists); gr_printf(sx,sy,text); sy += 2*dy; if(Game_mode & GM_MULTIPLAYER){ sprintf(text,"%d",(int)Active_player->stats.m_player_deaths); gr_printf(sx,sy,text); sy += 2*dy; // mission score gr_printf(sx, sy, "%d", (int)Active_player->stats.m_score); } break; case ALL_TIME_STATS: scoring_struct add; // if we are passed mission_add (the stats for the current mission), copy it to "add", otherwise, // zero it out memset(&add,0,sizeof(scoring_struct)); if(add_mission){ add.kill_count_ok = Active_player->stats.m_kill_count_ok; add.p_shots_fired = Active_player->stats.mp_shots_fired; add.p_shots_hit = Active_player->stats.mp_shots_hit; add.p_bonehead_hits = Active_player->stats.mp_bonehead_hits; add.s_shots_fired = Active_player->stats.ms_shots_fired; add.s_shots_hit = Active_player->stats.ms_shots_hit; add.s_bonehead_hits = Active_player->stats.ms_bonehead_hits; } // mission kills stats sprintf(text,"%d",Active_player->stats.kill_count_ok + add.kill_count_ok); hud_num_make_mono(text); gr_printf(sx,sy,text); // stats_underline_text(sx,sy,text); sy += 2*dy; // alltime primary weapon stats sprintf(text,"%d",Active_player->stats.p_shots_fired + add.p_shots_fired); gr_printf(sx,sy,text); sy += dy; sprintf(text,"%d",Active_player->stats.p_shots_hit + add.p_shots_hit); gr_printf(sx,sy,text); sy += dy; sprintf(text,"%d",Active_player->stats.p_bonehead_hits + add.p_bonehead_hits); gr_printf(sx,sy,text); sy += dy; if((Active_player->stats.p_shots_fired + add.p_shots_fired)>0) pct=(float)100.0*((float)(Active_player->stats.p_shots_hit+add.p_shots_hit)/(float)(Active_player->stats.p_shots_fired + add.p_shots_fired)); else pct=(float)0.0; sprintf(text,"%d",(int)pct); strcat(text," %%"); gr_printf(sx,sy,text); sy += dy; if((Active_player->stats.p_bonehead_hits + add.p_bonehead_hits)>0) pct=(float)100.0*((float)(Active_player->stats.p_bonehead_hits+add.p_bonehead_hits)/(float)(Active_player->stats.p_shots_fired + add.p_shots_fired)); else pct=(float)0.0; sprintf(text,"%d",(int)pct); strcat(text," %%"); gr_printf(sx,sy,text); sy += 2*dy; // alltime secondary weapon stats sprintf(text,"%d",Active_player->stats.s_shots_fired + add.s_shots_fired); gr_printf(sx,sy,text); sy += dy; sprintf(text,"%d",Active_player->stats.s_shots_hit + add.s_shots_hit); gr_printf(sx,sy,text); sy += dy; sprintf(text,"%d",Active_player->stats.s_bonehead_hits + add.s_bonehead_hits); gr_printf(sx,sy,text); sy += dy; if((Active_player->stats.s_shots_fired+add.s_shots_fired)>0) pct=(float)100.0*((float)(Active_player->stats.s_shots_hit + add.s_shots_hit)/(float)(Active_player->stats.s_shots_fired + add.s_shots_fired)); else pct=(float)0.0; sprintf(text,"%d",(int)pct); strcat(text," %%"); gr_printf(sx,sy,text); sy += dy; if((Active_player->stats.s_bonehead_hits + add.s_bonehead_hits)>0) pct=(float)100.0*((float)(Active_player->stats.s_bonehead_hits+add.s_bonehead_hits)/(float)(Active_player->stats.s_shots_fired+add.s_shots_fired)); else pct=(float)0.0; sprintf(text,"%d",(int)pct); strcat(text," %%"); gr_printf(sx,sy,text); sy += 2*dy; // alltime assists sprintf(text,"%d",(int)Active_player->stats.assists + add.assists); gr_printf(sx,sy,text); sy += 2*dy; if (Game_mode & GM_MULTIPLAYER) { gr_printf(sx, sy, "%d", (int)Active_player->stats.score); } break; } // end switch }