int hud_shield_maybe_flash(int gauge, int target_index, int shield_offset) { int flashed = 0; shield_hit_info *shi; shi = &Shield_hit_data[target_index]; if ( !timestamp_elapsed(shi->shield_hit_timers[shield_offset]) ) { if ( timestamp_elapsed(shi->shield_hit_next_flash[shield_offset]) ) { shi->shield_hit_next_flash[shield_offset] = timestamp(SHIELD_FLASH_INTERVAL_FAST); shi->shield_show_bright ^= (1<<shield_offset); // toggle between default and bright frames } if ( shi->shield_show_bright & (1<<shield_offset) ) { // hud_set_bright_color(); hud_set_gauge_color(gauge, HUD_C_BRIGHT); flashed = 1; } else { hud_set_gauge_color(gauge, HUD_C_NORMAL); // hud_set_default_color(); } } return flashed; }
void radar_draw_range() { char buf[32]; // hud_set_bright_color(); hud_set_gauge_color(HUD_RADAR, HUD_C_BRIGHT); switch ( HUD_config.rp_dist ) { case RR_SHORT: gr_printf(Radar_dist_coords[gr_screen.res][RR_SHORT][0], Radar_dist_coords[gr_screen.res][RR_SHORT][1], XSTR( "2k", 467)); break; case RR_LONG: gr_printf(Radar_dist_coords[gr_screen.res][RR_LONG][0], Radar_dist_coords[gr_screen.res][RR_LONG][1], XSTR( "10k", 468)); break; case RR_INFINITY: sprintf(buf, NOX("%c"), Lcl_special_chars); gr_printf(Radar_dist_coords[gr_screen.res][RR_INFINITY][0], Radar_dist_coords[gr_screen.res][RR_INFINITY][1], buf); break; default: Int3(); // can't happen (get Alan if it does) break; } hud_set_default_color(); }
// Set the color for the text to be displayed // Goober5000 - changed second parameter from "friendly" (true/false) to "team"; // also changed from hud color or red to team color int hud_escort_set_gauge_color(int index, int team) { int is_flashing = 0; int is_bright = 0; int seen_from_team = (Player_ship != NULL) ? Player_ship->team : -1; shield_hit_info* shi; shi = &Escort_ships[index].hit_info; // multiplayer dogfight if ((Game_mode & GM_MULTIPLAYER) && (Netgame.type_flags & NG_TYPE_DOGFIGHT)) { hud_set_gauge_color(HUD_ESCORT_VIEW); return 0; } // set flashing color if (!timestamp_elapsed(shi->shield_hit_timers[HULL_HIT_OFFSET])) { if (timestamp_elapsed(shi->shield_hit_next_flash[HULL_HIT_OFFSET])) { shi->shield_hit_next_flash[HULL_HIT_OFFSET] = timestamp(SHIELD_FLASH_INTERVAL); shi->shield_show_bright ^= (1 << HULL_HIT_OFFSET); // toggle between default and bright frames } is_flashing = 1; if (shi->shield_show_bright & (1 << HULL_HIT_OFFSET)) { is_bright = 1; } } // Goober5000 - now base this on team color gr_set_color_fast(iff_get_color_by_team_and_object(team, seen_from_team, is_bright, &Objects[Escort_ships[index].objnum])); // Goober5000 - an alternative; same as original but incorporating teams for non-friendlies /* if ((seen_from_team == team) || (seen_from_team < 0)) // :V: sez assume friendly if Player_ship is NULL hud_set_gauge_color(HUD_ESCORT_VIEW, is_bright ? HUD_C_BRIGHT : HUD_C_DIM); else gr_set_color_fast(iff_get_color_by_team(team, seen_from_team, is_bright)); */ // Goober5000 - original color logic /* if ((seen_from_team == team) || (seen_from_team < 0)) // :V: sez assume friendly if Player_ship is NULL hud_set_gauge_color(HUD_ESCORT_VIEW, is_bright ? HUD_C_BRIGHT : HUD_C_DIM); else gr_set_color_fast(is_bright ? &Color_bright_red : &Color_red); */ return is_flashing; }
// draw the shield icon and integrity for the escort ship void hud_escort_show_icon(int x, int y, int index) { #ifndef NEW_HUD if((Game_mode & GM_MULTIPLAYER) && (Netgame.type_flags & NG_TYPE_DOGFIGHT) && index <= 2) { hud_escort_show_icon_dogfight(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 hud_escort_set_gauge_color(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)) ) { emp_hud_string( x + current_hud->Escort_status[0], y + current_hud->Escort_status[1], EG_NULL, XSTR( "D", 284)); } // print out ship name strcpy(buf, sp->ship_name); gr_force_fit_string(buf, 255, 100); emp_hud_string( x + current_hud->Escort_name[0], y + current_hud->Escort_name[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; } } } emp_hud_printf( x+current_hud->Escort_integrity[0] + offset, y+current_hud->Escort_integrity[1], EG_NULL, "%d", screen_integrity); //Let's be nice. hud_set_gauge_color(HUD_ESCORT_VIEW); #endif }
// ---------------------------------------------------------------------- // hud_display_escort() // // Display the data on ships in the escort list void hud_display_escort() { int i = 0; if (!Show_escort_view) { return; } if (!Num_escort_ships) { return; } // hud_set_default_color(); hud_set_gauge_color(HUD_ESCORT_VIEW); // draw the top of the escort view hud_aabitmap(Escort_gauges[0].first_frame, current_hud->Escort_coords[0], current_hud->Escort_coords[1]); gr_string(current_hud->Escort_htext_coords[0], current_hud->Escort_htext_coords[1], current_hud->Escort_htext); int x = current_hud->Escort_coords[0] + current_hud->Escort_list[0]; int y = current_hud->Escort_coords[1] + current_hud->Escort_list[1]; //This is temporary Num_escort_ships--; i = 0; if (Num_escort_ships) { for (; i < Num_escort_ships; i++) { if (i != 0) { x += current_hud->Escort_entry[0]; y += current_hud->Escort_entry[1]; } hud_aabitmap(Escort_gauges[1].first_frame, x, y); //Now we just show the ships info hud_escort_show_icon(x, y, i); } //Increment for last entry x += current_hud->Escort_entry_last[0]; y += current_hud->Escort_entry_last[1]; } //Back to right # Num_escort_ships++; //Show the last escort entry hud_aabitmap(Escort_gauges[2].first_frame, x, y); hud_escort_show_icon(x, y, i); }
// multiplayer dogfight void hud_escort_show_icon_dogfight(int x, int y, int index) { #ifndef NEW_HUD int hull_integrity = 100; char buf[255]; int np_index; object *objp; ship_info *sip; int stat_shift = 40; // always use the standard color to avoid confusion hud_set_gauge_color(HUD_ESCORT_VIEW); // 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(buf, Net_players[np_index].m_player->callsign); gr_force_fit_string(buf, 255, 100 - stat_shift); emp_hud_string( x + current_hud->Escort_name[0], y + current_hud->Escort_name[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)){ sip = &Ship_info[Ships[objp->instance].ship_info_index]; } 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){ emp_hud_printf( x+current_hud->Escort_integrity[0] - stat_shift, y+current_hud->Escort_integrity[1], EG_NULL, "%d", Net_players[np_index].m_player->stats.m_kill_count_ok); } else { emp_hud_printf( x+current_hud->Escort_integrity[0] - stat_shift, y+current_hud->Escort_integrity[1], EG_NULL, "(%d%%) %d", hull_integrity, Net_players[np_index].m_player->stats.m_kill_count_ok); } #endif }
void radar_frame_render(float frametime) { float sensors_str; int ok_to_blit_radar; ok_to_blit_radar = 1; sensors_str = ship_get_subsystem_strength( Player_ship, SUBSYSTEM_SENSORS ); if ( ship_subsys_disrupted(Player_ship, SUBSYSTEM_SENSORS) ) { sensors_str = MIN_SENSOR_STR_TO_RADAR-1; } // note that on lowest skill level, there is no radar effects due to sensors damage if ( (Game_skill_level == 0) || (sensors_str > SENSOR_STR_RADAR_NO_EFFECTS) ) { Radar_static_playing = 0; Radar_static_next = 0; Radar_death_timer = 0; Radar_avail_prev_frame = 1; } else if ( sensors_str < MIN_SENSOR_STR_TO_RADAR ) { if ( Radar_avail_prev_frame ) { Radar_death_timer = timestamp(2000); Radar_static_next = 1; } Radar_avail_prev_frame = 0; } else { Radar_death_timer = 0; if ( Radar_static_next == 0 ) Radar_static_next = 1; } if ( timestamp_elapsed(Radar_death_timer) ) { ok_to_blit_radar = 0; } hud_set_gauge_color(HUD_RADAR); radar_blit_gauge(); radar_draw_range(); if ( timestamp_elapsed(Radar_static_next) ) { Radar_static_playing ^= 1; Radar_static_next = timestamp_rand(50, 750); } // if the emp effect is active, always draw the radar wackily if(emp_active_local()){ Radar_static_playing = 1; } if ( ok_to_blit_radar ) { if ( Radar_static_playing ) { radar_draw_blips_sorted(1); // passing 1 means to draw distorted if ( Radar_static_looping == -1 ) { Radar_static_looping = snd_play_looping(&Snds[SND_STATIC]); } } else { radar_draw_blips_sorted(); if ( Radar_static_looping != -1 ) { snd_stop(Radar_static_looping); Radar_static_looping = -1; } } } else { if ( Radar_static_looping != -1 ) { snd_stop(Radar_static_looping); Radar_static_looping = -1; } } }
// displays (renders) the training objectives list void training_obj_display() { char buf[256], *second_line; int i, t, x, y, z, height, end, offset, bx, by, y_count; color *c; if (!Training_obj_num_lines){ return; } if ( !hud_gauge_active(HUD_DIRECTIVES_VIEW) ) { // Always draw the directives display if this is a training mission if ( !(The_mission.game_type & MISSION_TYPE_TRAINING) ) { return; } } // don't ever display directives display in multiplayer missions // if ( Game_mode & GM_MULTIPLAYER ){ // return; // } height = gr_get_font_height(); offset = 0; end = Training_obj_num_lines; if (end > TRAINING_OBJ_DISPLAY_LINES) { end = TRAINING_OBJ_DISPLAY_LINES; offset = Training_obj_num_lines - end; } // draw top of objective display // hud_set_default_color(); hud_set_gauge_color(HUD_DIRECTIVES_VIEW); GR_AABITMAP(Directive_gauge[0].first_frame, Directive_coords[gr_screen.res][DIRECTIVE_COORDS_TOP][0]+fl2i(HUD_offset_x), Directive_coords[gr_screen.res][DIRECTIVE_COORDS_TOP][1]+fl2i(HUD_offset_y)); // gr_set_bitmap(Directive_gauge[0].first_frame); // gr_aabitmap(Directive_coords[DIRECTIVE_COORDS_TOP][0]+fl2i(HUD_offset_x), Directive_coords[DIRECTIVE_COORDS_TOP][1]+fl2i(HUD_offset_y)); // print out title emp_hud_printf(Directive_coords[gr_screen.res][DIRECTIVE_COORDS_TITLE][0]+fl2i(HUD_offset_x), Directive_coords[gr_screen.res][DIRECTIVE_COORDS_TITLE][1]+fl2i(HUD_offset_y), EG_OBJ_TITLE, XSTR( "Directives", 422)); // gr_printf(Directive_coords[DIRECTIVE_COORDS_TITLE][0]+fl2i(HUD_offset_x), Directive_coords[DIRECTIVE_COORDS_TITLE][1]+fl2i(HUD_offset_y), XSTR( "directives", 422)); bx = DIRECTIVE_X+fl2i(HUD_offset_x); by = Directive_coords[gr_screen.res][DIRECTIVE_COORDS_MIDDLE][1]+fl2i(HUD_offset_y); y_count = 0; for (i=0; i<end; i++) { x = DIRECTIVE_X + 5 + fl2i(HUD_offset_x); y = Training_obj_window_coords[gr_screen.res][1] + fl2i(HUD_offset_y) + y_count * height + height / 2 + 1; 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 // gr_set_color_fast(&Color_normal); c = &Color_bright_green; } else { strcpy(buf, Mission_events[z].objective_text); if (Mission_events[z].count){ sprintf(buf + strlen(buf), NOX(" [%d]"), Mission_events[z].count); } #ifndef NO_NETWORK // if this is a multiplayer tvt game, and this is event is not for my team, don't display it if((Game_mode & GM_MULTIPLAYER) && (Netgame.type_flags & NG_TYPE_TEAM) && (Net_player != NULL)){ if((Mission_events[z].team != -1) && (Net_player->p_info.team != Mission_events[z].team)){ continue; } } #endif switch (mission_get_event_status(z)) { case EVENT_CURRENT: // gr_set_color_fast(&Color_bright_white); c = &Color_bright_white; break; case EVENT_FAILED: // gr_set_color_fast(&Color_bright_red); c = &Color_bright_red; break; case EVENT_SATISFIED: // gr_set_color_fast(&Color_bright_blue); 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, 167); // blit the background frames // hud_set_default_color(); hud_set_gauge_color(HUD_DIRECTIVES_VIEW); GR_AABITMAP(Directive_gauge[1].first_frame, bx, by); // gr_set_bitmap(Directive_gauge[1].first_frame); // gr_aabitmap(bx, by); by += DIRECTIVE_H; if ( second_line ) { GR_AABITMAP(Directive_gauge[1].first_frame, bx, by); // gr_set_bitmap(Directive_gauge[1].first_frame); // gr_aabitmap(bx, by); by += DIRECTIVE_H; } // blit the text gr_set_color_fast(c); emp_hud_string(x, y, EG_OBJ1 + i, buf); // gr_printf(x, y, buf); y_count++; if ( second_line ) { y = Training_obj_window_coords[gr_screen.res][1] + fl2i(HUD_offset_y) + y_count * height + height / 2 + 1; emp_hud_string(x+12, y, EG_OBJ1 + i + 1, second_line); // gr_printf(x+12, y, second_line); y_count++; } } // draw the bottom of objective display // hud_set_default_color(); hud_set_gauge_color(HUD_DIRECTIVES_VIEW); GR_AABITMAP(Directive_gauge[2].first_frame, bx, by); // gr_set_bitmap(Directive_gauge[2].first_frame); // gr_aabitmap(bx, by); }
// 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(); }
// 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(); }
void hud_shield_show(object* objp) { KeepAspectRatio keep(true); // 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].flags2 & SF2_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->flags2 & SIF2_GENERATE_HUD_ICON)/*&& !digitus_improbus*/) { return; } if (objp == Player_obj) { hud_set_gauge_color(HUD_PLAYER_SHIELD_ICON); } else { hud_set_gauge_color(HUD_TARGET_SHIELD_ICON); } // load in shield frames if not already loaded if (sip->shield_icon_index != 255) { sgp = &Shield_gauges[sip->shield_icon_index]; if (sgp->first_frame == -1 && sip->shield_icon_index < Hud_shield_filename_count) { sgp->first_frame = bm_load_animation(Hud_shield_filenames[sip->shield_icon_index], &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[sip->shield_icon_index]); } return; } } } if (objp == Player_obj) { sx = current_hud->Player_shield_coords[0]; sy = current_hud->Player_shield_coords[1]; } else { sx = current_hud->Target_shield_coords[0]; sy = current_hud->Target_shield_coords[1]; } sx += fl2i(HUD_offset_x); sy += fl2i(HUD_offset_y); // draw the ship first if (objp == Player_obj) { hud_shield_maybe_flash(HUD_PLAYER_SHIELD_ICON, SHIELD_HIT_PLAYER, HULL_HIT_OFFSET); } else { hud_shield_maybe_flash(HUD_TARGET_SHIELD_ICON, SHIELD_HIT_TARGET, HULL_HIT_OFFSET); } if (sip->shield_icon_index != 255) { hud_aabitmap(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); HUD_set_clip(sx, sy, 112, 93); model_set_detail_level(1); //if(!digitus_improbus) g3_set_view_matrix(&sip->closeup_pos, &vmd_identity_matrix, sip->closeup_zoom * 3.25f); /*else { vec3d finger_vec = {0.0f, 0.0f, 176.0f}; g3_set_view_matrix( &finger_vec, &vmd_identity_matrix, 1.0f); }*/ if (!Cmdline_nohtl) { 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 ship_model_start(objp); //if(!digitus_improbus) { model_render(sip->model_num, &object_orient, &vmd_zero_vector, MR_NO_LIGHTING | MR_LOCK_DETAIL | MR_AUTOCENTER | MR_NO_FOGGING, -1, -1, sp->ship_replacement_textures); } /*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); }*/ ship_model_stop(objp); //We're done if (!Cmdline_nohtl) { gr_end_view_matrix(); gr_end_proj_matrix(); } if (g3_yourself) g3_end_frame(); hud_save_restore_camera_data(0); HUD_reset_clip(); } if (!sip->max_shield_strength) return; // draw the four quadrants // // Draw shield quadrants at one of NUM_SHIELD_LEVELS max_shield = get_max_shield_quad(objp); int j, x_val, y_val, mid_val; 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; } range = MAX(HUD_COLOR_ALPHA_MAX, HUD_color_alpha + 4); hud_color_index = fl2i((objp->shield_quadrant[Quadrant_xlate[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; if (objp == Player_obj) { flash = hud_shield_maybe_flash(HUD_PLAYER_SHIELD_ICON, SHIELD_HIT_PLAYER, i); } else { flash = hud_shield_maybe_flash(HUD_TARGET_SHIELD_ICON, SHIELD_HIT_TARGET, i); } if (!flash) { // gr_set_color_fast(&HUD_color_defaults[hud_color_index]); if (objp == Player_obj) { hud_set_gauge_color(HUD_PLAYER_SHIELD_ICON, hud_color_index); } else { hud_set_gauge_color(HUD_TARGET_SHIELD_ICON, hud_color_index); } if (sip->shield_icon_index != 255) { hud_aabitmap(sgp->first_frame + i + 1, sx, sy); } else { //Ugh, draw four shield quadrants switch (i) { //Top case 0: sy += 3; for (j = 0; j < 6; j++) { y_val = sy + 10; gr_gradient(sx + j, sy, sx + j, y_val - j); } mid_val = sy + 5; for (; j < 106; j++) { gr_gradient(sx + j, sy, sx + j, mid_val); } for (; j < 112; j++) { gr_gradient(sx + j, sy, sx + j, sy + (j - 101)); } y_val = sy - 1; sy -= 3; for (j = 0; j < 112; j++) gr_gradient(sx + j, y_val, sx + j, sy); break; //Left case 1: sx += 1; x_val = sx + 10; y_val = sy + 15; for (j = 0; j < 6; j++) { gr_gradient(sx, y_val + j, x_val - j, y_val + j); } mid_val = sx + 5; for (; j < 48; j++) { gr_gradient(sx, y_val + j, mid_val, y_val + j); } for (; j < 54; j++) { gr_gradient(sx, y_val + j, sx + (j - 43), y_val + j); } x_val = sx; sx -= 3; for (j = 0; j < 54; j++) gr_gradient(x_val, y_val + j, sx, y_val + j); sx += 2; break; //Right case 2: x_val = sx + 109; //-3 for border y_val = sy + 15; for (j = 0; j < 6; j++) { gr_gradient(x_val, y_val + j, x_val - (10 - j), y_val + j); } mid_val = x_val - 5; for (; j < 48; j++) { gr_gradient(x_val, y_val + j, mid_val, y_val + j); } for (; j < 54; j++) { gr_gradient(x_val, y_val + j, x_val - (j - 43), y_val + j); } mid_val = x_val; x_val += 3; for (j = 0; j < 54; j++) gr_gradient(mid_val, y_val + j, x_val, y_val + j); break; //Bottom case 3: y_val = sy + 80; //-3 for border for (j = 0; j < 6; j++) gr_gradient(sx + j, y_val, sx + j, y_val - (10 - j)); mid_val = y_val - 5; for (; j < 106; j++) gr_gradient(sx + j, y_val, sx + j, mid_val); for (; j < 112; j++) gr_gradient(sx + j, y_val, sx + j, y_val - (j - 101)); mid_val = y_val + 1; y_val += 3; for (j = 0; j < 112; j++) gr_gradient(sx + j, mid_val, sx + j, y_val); } } } } // hud_set_default_color(); }
// ------------------------------------------------------------------------------------------------- // 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(); }
// --------------------------------------------------------------------------------------- // hud_show_msg_window() will display the active HUD messages on the HUD. It will scroll // the messages up when a new message arrives. // void hud_show_msg_window() { int i, index; hud_set_default_color(); gr_set_font(FONT1); HUD_set_clip(MSG_WINDOW_X_START,MSG_WINDOW_Y_START, MSG_WINDOW_WIDTH, MSG_WINDOW_HEIGHT+2); if ( OLD_ACTIVE_BUFFER_LINES != ACTIVE_BUFFER_LINES ) { // the size of the message window has changed, the best thing to do is to put all // the blank out the current hud messages. There is no need to add them to the // scrollback buffer, since they are already there! for ( i=0; i < ACTIVE_BUFFER_LINES; i++ ) { if ( !timestamp_elapsed(HUD_active_msgs_list[i].total_life) ) { HUD_active_msgs_list[i].total_life = 1; Active_index=0; } } } OLD_ACTIVE_BUFFER_LINES = ACTIVE_BUFFER_LINES; // check if there is a message to display on the HUD, and if there is room to display it if ( Hud_list_start != Hud_list_end && !Scroll_needed) { Hud_list_start++; // if the pointer exceeds the array size, wrap around to element 1. element 0 is not used. if (Hud_list_start >= SCROLL_BUFFER_LINES) Hud_list_start = 1; HUD_active_msgs_list[Active_index].msg = HUD_pending[Hud_list_start]; HUD_active_msgs_list[Active_index].total_life = timestamp(HUD_MESSAGE_TOTAL_LIFE); for (i=Active_index+1; i < Active_index+ACTIVE_BUFFER_LINES; i++) { index = i % ACTIVE_BUFFER_LINES; // determine if there are any existing messages, if so need to scroll them up if ( !timestamp_elapsed(HUD_active_msgs_list[index].total_life) ) { HUD_active_msgs_list[index].target_y -= MSG_WINDOW_FONT_HEIGHT; Scroll_needed=1; } } if (Scroll_needed) { HUD_active_msgs_list[Active_index].y = (ACTIVE_BUFFER_LINES-1)*MSG_WINDOW_FONT_HEIGHT; HUD_active_msgs_list[Active_index].target_y = HUD_active_msgs_list[Active_index].y - MSG_WINDOW_FONT_HEIGHT; } else { HUD_active_msgs_list[Active_index].y = (ACTIVE_BUFFER_LINES-2)*MSG_WINDOW_FONT_HEIGHT; HUD_active_msgs_list[Active_index].target_y = HUD_active_msgs_list[Active_index].y; } Active_index++; if (Active_index >= ACTIVE_BUFFER_LINES) Active_index = 0; if (Hud_list_end == Hud_list_start) { // just printed the last msg Hud_list_start = Hud_list_end = 0; } } Scroll_in_progress=0; Scroll_needed = 0; for ( i=0; i < ACTIVE_BUFFER_LINES; i++ ) { if ( !timestamp_elapsed(HUD_active_msgs_list[i].total_life) ) { if (HUD_active_msgs_list[i].y > HUD_active_msgs_list[i].target_y) { Scroll_needed=1; if (timestamp_elapsed(Scroll_time_id) ){ HUD_active_msgs_list[i].y -= SCROLL_STEP_SIZE; if (HUD_active_msgs_list[i].y < HUD_active_msgs_list[i].target_y) HUD_active_msgs_list[i].y = HUD_active_msgs_list[i].target_y; Scroll_in_progress=1; } } if ( hud_gauge_active(HUD_MESSAGE_LINES) ) { if ( !(Player->flags & PLAYER_FLAGS_MSG_MODE) ) { // set the appropriate color if(HUD_active_msgs_list[i].msg.source){ hud_set_gauge_color(HUD_MESSAGE_LINES, HUD_C_BRIGHT); } else { hud_set_gauge_color(HUD_MESSAGE_LINES); } // print the message out gr_printf(MSG_WINDOW_X_START + HUD_active_msgs_list[i].msg.x - 2, HUD_active_msgs_list[i].y, "%s", HUD_active_msgs_list[i].msg.text); } } } } // end for if (Scroll_in_progress) Scroll_time_id = timestamp(SCROLL_TIME); HUD_reset_clip(); }
// 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(); }
// ------------------------------------------------------------------ // hud_shield_show() // // Show the players shield strength and integrity // void hud_shield_show(object *objp) { float max_shield; int hud_color_index, range; int sx, sy, i; ship *sp; ship_info *sip; hud_frames *sgp; if ( objp->type != OBJ_SHIP ) return; sp = &Ships[objp->instance]; sip = &Ship_info[sp->ship_info_index]; if ( sip->shield_icon_index == 255 ) { return; } if (objp == Player_obj) { hud_set_gauge_color(HUD_PLAYER_SHIELD_ICON); } else { hud_set_gauge_color(HUD_TARGET_SHIELD_ICON); } // load in shield frames if not already loaded Assert(sip->shield_icon_index >= 0 && sip->shield_icon_index < Hud_shield_filename_count); sgp = &Shield_gauges[sip->shield_icon_index]; if ( sgp->first_frame == -1 ) { sgp->first_frame = bm_load_animation(Hud_shield_filenames[sip->shield_icon_index], &sgp->num_frames); if ( sgp->first_frame == -1 ) { Warning(LOCATION, "Could not load in the HUD shield ani: %s\n", Hud_shield_filenames[sip->shield_icon_index]); return; } } if ( objp == Player_obj ) { sx = Player_shield_coords[gr_screen.res][0]; sy = Player_shield_coords[gr_screen.res][1]; } else { sx = Target_shield_coords[gr_screen.res][0]; sy = Target_shield_coords[gr_screen.res][1]; } sx += fl2i(HUD_offset_x); sy += fl2i(HUD_offset_y); // draw the ship first if ( objp == Player_obj ) { hud_shield_maybe_flash(HUD_PLAYER_SHIELD_ICON, SHIELD_HIT_PLAYER, HULL_HIT_OFFSET); } else { hud_shield_maybe_flash(HUD_TARGET_SHIELD_ICON, SHIELD_HIT_TARGET, HULL_HIT_OFFSET); } GR_AABITMAP(sgp->first_frame, sx, sy); // 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; } range = max(HUD_COLOR_ALPHA_MAX, HUD_color_alpha + 4); 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; } int flash=0; if ( objp == Player_obj ) { flash = hud_shield_maybe_flash(HUD_PLAYER_SHIELD_ICON, SHIELD_HIT_PLAYER, i); } else { flash = hud_shield_maybe_flash(HUD_TARGET_SHIELD_ICON, SHIELD_HIT_TARGET, i); } if ( !flash ) { // gr_set_color_fast(&HUD_color_defaults[hud_color_index]); if ( objp == Player_obj ) { hud_set_gauge_color(HUD_PLAYER_SHIELD_ICON, hud_color_index); } else { hud_set_gauge_color(HUD_TARGET_SHIELD_ICON, hud_color_index); } GR_AABITMAP(sgp->first_frame+i+1, sx, sy); } } // hud_set_default_color(); }
// ---------------------------------------------------------------------- // hud_display_escort() // // Display the data on ships in the escort list void hud_display_escort() { #ifndef NEW_HUD int i = 0; if ( !Show_escort_view ) { return; } if ( !Num_escort_ships ) { return; } // hud_set_default_color(); hud_set_gauge_color(HUD_ESCORT_VIEW); // draw the top of the escort view GR_AABITMAP(Escort_gauges[0].first_frame, current_hud->Escort_coords[0], current_hud->Escort_coords[1]); gr_string(current_hud->Escort_htext_coords[0], current_hud->Escort_htext_coords[1], current_hud->Escort_htext); int x = current_hud->Escort_coords[0] + current_hud->Escort_list[0]; int y = current_hud->Escort_coords[1] + current_hud->Escort_list[1]; //This is temporary Num_escort_ships--; i=0; if(Num_escort_ships) { for(; i < Num_escort_ships; i++) { if(i != 0) { x += current_hud->Escort_entry[0]; y += current_hud->Escort_entry[1]; } GR_AABITMAP(Escort_gauges[1].first_frame, x, y); //Now we just show the ships info hud_escort_show_icon(x, y, i); } //Increment for last entry x += current_hud->Escort_entry_last[0]; y += current_hud->Escort_entry_last[1]; } //Back to right # Num_escort_ships++; //Show the last escort entry GR_AABITMAP(Escort_gauges[2].first_frame, x, y); hud_escort_show_icon(x, y, i); /* if ( Num_escort_ships >= 2 ) { GR_AABITMAP(Escort_gauges[1].first_frame, Escort_coords[gr_screen.res][1][0], Escort_coords[gr_screen.res][1][1]); } if ( Num_escort_ships >= 3 ) { GR_AABITMAP(Escort_gauges[1].first_frame, Escort_coords[gr_screen.res][2][0], Escort_coords[gr_screen.res][2][1]); } // draw bottom of box GR_AABITMAP(Escort_gauges[2].first_frame, Escort_coords[gr_screen.res][3][0], Escort_coords[gr_screen.res][Num_escort_ships][1]); // multiplayer dogfight if((Game_mode & GM_MULTIPLAYER) && (Netgame.type_flags & NG_TYPE_DOGFIGHT)){ // draw the escort ship data for ( i = 0; i < Num_escort_ships; i++ ) { // oops. only show top 3 if(i > 2){ break; } // draw hud_escort_show_icon_dogfight(i); } } // everything else else { // draw the escort ship data for ( i = 0; i < Num_escort_ships; i++ ) { objp = &Objects[Escort_ships[i].objnum]; hud_escort_show_icon(i, objp); } }*/ #endif }