Add pitstop audio cue, original explosions/smoke, authentic HUD, and Modern lighting/shadows
This commit is contained in:
1 parent
3a377b0534
commit
197bfbc973
21 files changed
+1927
-246
No files matched your search
+485
-124
@@ -71,6 +71,64 @@ const char* camera_label(int cam) {
|
||||
return "CHASE";
|
||||
}
|
||||
|
||||
void append_charger_lights(const assets::LevelData& level, double time_s,
|
||||
std::vector<render::DynamicLight>& out) {
|
||||
float pulse = 0.88f + 0.12f * std::sin(static_cast<float>(time_s) * 3.8f);
|
||||
for (const auto& pad : level.pads) {
|
||||
Vec3 col(0.22f, 0.70f, 1.00f); // Fuel blue
|
||||
if (pad.type == assets::ChargerType::Shield) col = Vec3(0.15f, 1.00f, 0.48f);
|
||||
else if (pad.type == assets::ChargerType::Ammo) col = Vec3(1.00f, 0.82f, 0.20f);
|
||||
float y = level.sample_height_world(pad.cx, pad.cz) + 0.90f;
|
||||
float rad = std::max(pad.half_x, pad.half_z) + 3.4f;
|
||||
out.push_back({Vec3(pad.cx, y, pad.cz), rad, col, 0.72f * pulse});
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<render::DynamicLight> select_viewport_lights(
|
||||
const std::vector<render::DynamicLight>& candidates, const Vec3& focus, float max_dist) {
|
||||
struct Scored {
|
||||
float score = 0.0f;
|
||||
size_t idx = 0;
|
||||
};
|
||||
std::vector<Scored> ranked;
|
||||
ranked.reserve(candidates.size());
|
||||
for (size_t i = 0; i < candidates.size(); ++i) {
|
||||
const auto& l = candidates[i];
|
||||
float d2 = (l.pos - focus).len_sq();
|
||||
float lim = max_dist + l.radius;
|
||||
if (d2 > lim * lim) continue;
|
||||
ranked.push_back({l.intensity / (1.0f + 0.018f * d2), i});
|
||||
}
|
||||
constexpr size_t kMaxLights = 12;
|
||||
if (ranked.size() > kMaxLights) {
|
||||
std::partial_sort(ranked.begin(), ranked.begin() + kMaxLights, ranked.end(),
|
||||
[](const Scored& a, const Scored& b) { return a.score > b.score; });
|
||||
ranked.resize(kMaxLights);
|
||||
}
|
||||
std::vector<render::DynamicLight> out;
|
||||
out.reserve(ranked.size());
|
||||
for (const auto& s : ranked) {
|
||||
out.push_back(candidates[s.idx]);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
bool write_backbuffer_ppm(const std::string& path, int w, int h) {
|
||||
if (w <= 0 || h <= 0 || path.empty()) return false;
|
||||
std::vector<uint8_t> rgb(static_cast<size_t>(w) * static_cast<size_t>(h) * 3u);
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, rgb.data());
|
||||
std::FILE* f = std::fopen(path.c_str(), "wb");
|
||||
if (!f) return false;
|
||||
std::fprintf(f, "P6\n%d %d\n255\n", w, h);
|
||||
const size_t row_bytes = static_cast<size_t>(w) * 3u;
|
||||
for (int y = h - 1; y >= 0; --y) {
|
||||
std::fwrite(rgb.data() + static_cast<size_t>(y) * row_bytes, 1, row_bytes, f);
|
||||
}
|
||||
std::fclose(f);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool GameApp::init(const LaunchOptions& opts) {
|
||||
@@ -81,6 +139,7 @@ bool GameApp::init(const LaunchOptions& opts) {
|
||||
|
||||
cfg_.load(vfs_.pref_dir() / "config.ini");
|
||||
if (opts.force_classic) cfg_.classic_mode = true;
|
||||
if (opts.force_modern) cfg_.classic_mode = false;
|
||||
if (opts.force_fullscreen) cfg_.fullscreen = true;
|
||||
if (opts.force_backend >= 0 && opts.force_backend <= 2) {
|
||||
cfg_.music_backend = static_cast<MusicBackend>(opts.force_backend);
|
||||
@@ -205,7 +264,9 @@ bool GameApp::init(const LaunchOptions& opts) {
|
||||
|
||||
void GameApp::shutdown() {
|
||||
cancel_name_edit();
|
||||
save_all_user_data();
|
||||
if (opts_.smoke_test_frames == 0) {
|
||||
save_all_user_data();
|
||||
}
|
||||
audio_.shutdown();
|
||||
input_.shutdown();
|
||||
ui_ren_.shutdown();
|
||||
@@ -320,18 +381,21 @@ void GameApp::enter_state(ScreenState s) {
|
||||
intro_turbo_played_ = false;
|
||||
intro_explode_played_ = false;
|
||||
audio_.set_engine_state(false, 0.0f, false, 0.0f);
|
||||
audio_.set_pitstop_state(false, false, 1.0f);
|
||||
ensure_music(audio::MusicTrackId::TitleIntro, true, true);
|
||||
} else if (s == ScreenState::Title || s == ScreenState::MainMenu ||
|
||||
s == ScreenState::ChampionshipMenu || s == ScreenState::TrackSelect ||
|
||||
s == ScreenState::VehicleSelect || s == ScreenState::Highscores) {
|
||||
in_race_session_ = false;
|
||||
audio_.set_engine_state(false, 0.0f, false, 0.0f);
|
||||
audio_.set_pitstop_state(false, false, 1.0f);
|
||||
if (active_music_track_ != static_cast<int>(audio::MusicTrackId::TitleIntro)) {
|
||||
ensure_music(audio::MusicTrackId::Menu, true, false);
|
||||
}
|
||||
} else if (s == ScreenState::Options) {
|
||||
if (!in_race_session_) {
|
||||
audio_.set_engine_state(false, 0.0f, false, 0.0f);
|
||||
audio_.set_pitstop_state(false, false, 1.0f);
|
||||
if (active_music_track_ != static_cast<int>(audio::MusicTrackId::TitleIntro)) {
|
||||
ensure_music(audio::MusicTrackId::Menu, true, false);
|
||||
}
|
||||
@@ -339,6 +403,7 @@ void GameApp::enter_state(ScreenState s) {
|
||||
} else if (s == ScreenState::PostRace) {
|
||||
in_race_session_ = false;
|
||||
audio_.set_engine_state(false, 0.0f, false, 0.0f);
|
||||
audio_.set_pitstop_state(false, false, 1.0f);
|
||||
ensure_music(audio::MusicTrackId::Menu, true, false);
|
||||
}
|
||||
}
|
||||
@@ -407,6 +472,7 @@ void GameApp::start_race_session() {
|
||||
post_race_record_flags_ = 0;
|
||||
in_race_session_ = true;
|
||||
state_ = ScreenState::Racing;
|
||||
audio_.set_pitstop_state(false, false, 1.0f);
|
||||
|
||||
ensure_music(static_cast<audio::MusicTrackId>(1 + (selected_track_ - 1) % 4), true, true);
|
||||
}
|
||||
@@ -437,6 +503,7 @@ void GameApp::handle_sim_events() {
|
||||
}
|
||||
const char* wav = nullptr;
|
||||
float base_gain = 0.45f;
|
||||
float pitch = 1.0f;
|
||||
float cd_sec = 0.08f;
|
||||
switch (ev.sound) {
|
||||
case sim::SimSoundCue::StartBeep: wav = "START1.WAV"; base_gain = 0.50f; cd_sec = 0.15f; break;
|
||||
@@ -455,20 +522,21 @@ void GameApp::handle_sim_events() {
|
||||
case sim::SimSoundCue::Boost: wav = "BOOST.WAV"; base_gain = 0.44f; cd_sec = 0.45f; break;
|
||||
case sim::SimSoundCue::Pickup: wav = "PICKUP.WAV"; base_gain = 0.44f; cd_sec = 0.12f; break;
|
||||
case sim::SimSoundCue::Powerup: wav = "POWERUP.WAV"; base_gain = 0.52f; cd_sec = 0.15f; break;
|
||||
case sim::SimSoundCue::Refuel: wav = "REFUEL.WAV"; base_gain = 0.28f; cd_sec = 0.35f; break;
|
||||
case sim::SimSoundCue::Refuel: wav = "REFUEL.WAV"; base_gain = 0.42f; cd_sec = 0.35f; break;
|
||||
case sim::SimSoundCue::LockOn: wav = "LOCKON4.WAV"; base_gain = 0.38f; cd_sec = 0.35f; break;
|
||||
case sim::SimSoundCue::Warning: wav = "WARNING.WAV"; base_gain = 0.40f; cd_sec = 0.50f; break;
|
||||
case sim::SimSoundCue::Stunt180: wav = "STUNT180.WAV"; base_gain = 0.52f; cd_sec = 0.30f; break;
|
||||
case sim::SimSoundCue::Stunt360: wav = "STUNT360.WAV"; base_gain = 0.52f; cd_sec = 0.30f; break;
|
||||
case sim::SimSoundCue::Stunt720: wav = "STUNT720.WAV"; base_gain = 0.52f; cd_sec = 0.30f; break;
|
||||
case sim::SimSoundCue::SwitchTrigger: wav = "SWITCH.WAV"; base_gain = 0.45f; cd_sec = 0.30f; break;
|
||||
case sim::SimSoundCue::PitComplete: wav = "POWERUP.WAV"; base_gain = 0.46f; pitch = 1.15f; cd_sec = 0.25f; break;
|
||||
default: break;
|
||||
}
|
||||
if (wav) {
|
||||
if (ev.pos.len_sq() < 0.01f) {
|
||||
audio_.play_sfx(wav, base_gain, 1.0f, 0.0f, false, cd_sec);
|
||||
audio_.play_sfx(wav, base_gain, pitch, 0.0f, false, cd_sec);
|
||||
} else {
|
||||
audio_.play_sfx_3d(wav, ev.pos, listener_pos, listener_right, base_gain, 1.0f, cd_sec);
|
||||
audio_.play_sfx_3d(wav, ev.pos, listener_pos, listener_right, base_gain, pitch, cd_sec);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -512,9 +580,24 @@ void GameApp::update_racing_step(float dt) {
|
||||
audio_.set_engine_state(c0.recovery_state == sim::RecoveryState::Active,
|
||||
spd_ratio, c0.boost_timer > 0.05f, c0.scrape_intensity);
|
||||
}
|
||||
bool any_pit = false;
|
||||
bool any_charging = false;
|
||||
float fill_ratio = 1.0f;
|
||||
for (const auto& c : race_sim_.crafts()) {
|
||||
if (!c.is_human || c.recovery_state != sim::RecoveryState::Active) continue;
|
||||
if (c.on_pit_mask != 0) {
|
||||
any_pit = true;
|
||||
}
|
||||
if (c.active_recharge_mask != 0) {
|
||||
any_charging = true;
|
||||
fill_ratio = std::min(fill_ratio, c.pit_fill_ratio);
|
||||
}
|
||||
}
|
||||
audio_.set_pitstop_state(any_pit, any_charging, fill_ratio);
|
||||
|
||||
if (race_sim_.race_finished()) {
|
||||
audio_.set_engine_state(false, 0.0f, false, 0.0f);
|
||||
audio_.set_pitstop_state(false, false, 1.0f);
|
||||
post_race_record_flags_ = hiscores_.submit_race(selected_track_, race_sim_.crafts());
|
||||
if (selected_mode_ == sim::GameMode::CloneRace && !race_sim_.crafts().empty() &&
|
||||
race_sim_.crafts()[0].finished) {
|
||||
@@ -1022,6 +1105,7 @@ int GameApp::run() {
|
||||
if (state_ == ScreenState::Racing) {
|
||||
if (input_.menu_input().pause) {
|
||||
audio_.set_engine_state(false, 0.0f, false, 0.0f);
|
||||
audio_.set_pitstop_state(false, false, 1.0f);
|
||||
enter_state(ScreenState::Paused);
|
||||
} else {
|
||||
for (int s = 0; s < steps; ++s) {
|
||||
@@ -1036,6 +1120,13 @@ int GameApp::run() {
|
||||
}
|
||||
|
||||
render_frame(static_cast<float>(clock_.alpha()));
|
||||
if (!opts_.screenshot_path.empty() && smoke_left == 1) {
|
||||
if (write_backbuffer_ppm(opts_.screenshot_path, win_w_, win_h_)) {
|
||||
LOG_INFO("Saved screenshot to %s (%dx%d)", opts_.screenshot_path.c_str(), win_w_, win_h_);
|
||||
} else {
|
||||
LOG_WARN("Failed to write screenshot: %s", opts_.screenshot_path.c_str());
|
||||
}
|
||||
}
|
||||
SDL_GL_SwapWindow(window_);
|
||||
|
||||
if (smoke_left > 0) {
|
||||
@@ -1045,7 +1136,7 @@ int GameApp::run() {
|
||||
return 1;
|
||||
}
|
||||
// Exercise both Modern & Classic modes during automated smoke test
|
||||
if (smoke_left == opts_.smoke_test_frames / 2) {
|
||||
if (opts_.screenshot_path.empty() && smoke_left == opts_.smoke_test_frames / 2) {
|
||||
cfg_.classic_mode = !cfg_.classic_mode;
|
||||
}
|
||||
if (--smoke_left == 0) {
|
||||
@@ -1069,7 +1160,10 @@ void GameApp::render_frame(float alpha) {
|
||||
std::sin(viewer_pitch_),
|
||||
std::cos(viewer_yaw_) * std::cos(viewer_pitch_));
|
||||
cam.target = cam.eye + look;
|
||||
world_ren_.render_world_view(cam, {}, {}, 0, 1, cfg_);
|
||||
std::vector<render::DynamicLight> tv_all;
|
||||
append_charger_lights(viewer_level_, ui_time_, tv_all);
|
||||
auto tv_lights = select_viewport_lights(tv_all, cam.eye, cfg_.draw_distance);
|
||||
world_ren_.render_world_view(cam, {}, {}, 0, 1, cfg_, tv_lights, {});
|
||||
world_ren_.end_classic_world_pass(win_w_, win_h_, cfg_);
|
||||
|
||||
ui_ren_.begin(win_w_, win_h_);
|
||||
@@ -1085,6 +1179,10 @@ void GameApp::render_frame(float alpha) {
|
||||
std::vector<render::ModelInstance> models;
|
||||
models.reserve(race_sim_.crafts().size() + race_sim_.pickups().size() +
|
||||
race_sim_.props().size() + race_sim_.projectiles().size() + 4);
|
||||
std::vector<render::CraftShadow> craft_shadows;
|
||||
craft_shadows.reserve(race_sim_.crafts().size());
|
||||
std::vector<render::DynamicLight> all_lights;
|
||||
all_lights.reserve(race_sim_.level().pads.size() + race_sim_.crafts().size() + 16);
|
||||
|
||||
for (const auto& c : race_sim_.crafts()) {
|
||||
sim::CraftPose p = sim::interpolate_pose(c, alpha);
|
||||
@@ -1093,6 +1191,20 @@ void GameApp::render_frame(float alpha) {
|
||||
float vscale = sim::kVehicleSpecs[std::clamp(c.vehicle_idx, 0, 5)].visual_scale;
|
||||
models.push_back({sim::model_key_for(c.vehicle_idx, c.team_idx), p.pos,
|
||||
p.yaw, p.pitch, p.roll, vscale, tint});
|
||||
if (c.recovery_state == sim::RecoveryState::Active ||
|
||||
c.recovery_state == sim::RecoveryState::Repairing ||
|
||||
c.recovery_state == sim::RecoveryState::Destroyed) {
|
||||
craft_shadows.push_back({p.pos, 0.82f + 0.35f * vscale});
|
||||
}
|
||||
if (c.recovery_state == sim::RecoveryState::Active) {
|
||||
Vec3 fwd(std::sin(p.yaw), 0.0f, std::cos(p.yaw));
|
||||
Vec3 jet_pos = p.pos - fwd * 0.55f + Vec3(0.0f, 0.14f, 0.0f);
|
||||
if (c.boost_timer > 0.0f) {
|
||||
all_lights.push_back({jet_pos, 6.5f, Vec3(0.40f, 0.88f, 1.00f), 1.35f});
|
||||
} else if (c.speed_horizontal() > 2.5f) {
|
||||
all_lights.push_back({jet_pos, 3.8f, Vec3(0.28f, 0.68f, 1.00f), 0.45f});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (race_sim_.has_clone_ghost()) {
|
||||
sim::CraftPose gp = race_sim_.interpolated_clone_pose(alpha);
|
||||
@@ -1118,23 +1230,49 @@ void GameApp::render_frame(float alpha) {
|
||||
else if (pk.subtype <= 5) pcol = Vec4(0.3f, 0.7f, 1.0f, 1.0f); // shield
|
||||
else if (pk.subtype <= 9) pcol = Vec4(1.0f, 0.9f, 0.2f, 1.0f); // ammo
|
||||
else pcol = Vec4(1.0f, 0.35f, 0.9f, 1.0f); // weapon/booster upgrade
|
||||
models.push_back({"CONE0-0", pk.pos + Vec3(0, bob, 0), rot, 0.0f, 0.0f, 0.65f, pcol});
|
||||
Vec3 ppos = pk.pos + Vec3(0, bob, 0);
|
||||
models.push_back({"CONE0-0", ppos, rot, 0.0f, 0.0f, 0.65f, pcol});
|
||||
all_lights.push_back({ppos + Vec3(0.0f, 0.25f, 0.0f), 3.4f, Vec3(pcol.x, pcol.y, pcol.z), 0.46f});
|
||||
}
|
||||
for (const auto& pj : race_sim_.projectiles()) {
|
||||
if (!pj.active || !pj.is_missile) continue;
|
||||
models.push_back({"CONE0-1", pj.pos, pj.yaw, -kHalfPi, 0.0f, 0.5f, Vec4(1.0f, 0.3f, 0.2f, 1)});
|
||||
if (!pj.active) continue;
|
||||
if (pj.is_missile) {
|
||||
models.push_back({"CONE0-1", pj.pos, pj.yaw, -kHalfPi, 0.0f, 0.5f, Vec4(1.0f, 0.3f, 0.2f, 1)});
|
||||
all_lights.push_back({pj.pos, 5.8f, Vec3(1.0f, 0.44f, 0.14f), 1.15f});
|
||||
} else {
|
||||
all_lights.push_back({pj.pos, 2.8f, Vec3(1.0f, 0.85f, 0.32f), 0.55f});
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<render::ParticleQuad> parts;
|
||||
parts.reserve(race_sim_.particles().size() + race_sim_.pickups().size());
|
||||
parts.reserve(race_sim_.particles().size() + race_sim_.projectiles().size());
|
||||
std::vector<Vec3> fire_clusters;
|
||||
for (const auto& pb : race_sim_.particles()) {
|
||||
parts.push_back({pb.pos, pb.size, pb.color});
|
||||
bool additive = (pb.kind == sim::ParticleKind::AdditiveGlow ||
|
||||
pb.kind == sim::ParticleKind::Fireball);
|
||||
parts.push_back({pb.pos, pb.size, pb.color, static_cast<float>(pb.kind), pb.seed, additive});
|
||||
if (pb.kind == sim::ParticleKind::Fireball && pb.color.w > 0.15f) {
|
||||
bool merged = false;
|
||||
for (const auto& fp : fire_clusters) {
|
||||
if ((pb.pos - fp).len_sq() < 4.84f) {
|
||||
merged = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!merged) {
|
||||
fire_clusters.push_back(pb.pos);
|
||||
all_lights.push_back({pb.pos, 10.5f, Vec3(1.0f, 0.54f, 0.14f),
|
||||
1.65f * std::clamp(pb.color.w, 0.25f, 1.0f)});
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const auto& pj : race_sim_.projectiles()) {
|
||||
if (!pj.active || pj.is_missile) continue;
|
||||
parts.push_back({pj.pos, 0.28f, Vec4(1.0f, 0.9f, 0.35f, 1.0f)});
|
||||
parts.push_back({pj.pos, 0.28f, Vec4(1.0f, 0.9f, 0.35f, 1.0f), 0.0f, 0.0f, true});
|
||||
}
|
||||
append_charger_lights(race_sim_.level(), ui_time_, all_lights);
|
||||
|
||||
float draw_dist = cfg_.classic_mode ? 38.0f : cfg_.draw_distance;
|
||||
int split_count = (selected_mode_ == sim::GameMode::SplitScreen && race_sim_.crafts().size() >= 2) ? 2 : 1;
|
||||
std::array<render::RenderCamera, 2> cams{};
|
||||
for (int vp = 0; vp < split_count; ++vp) {
|
||||
@@ -1182,33 +1320,45 @@ void GameApp::render_frame(float alpha) {
|
||||
}
|
||||
float min_cam_y = race_sim_.level().sample_height_world(cams[vp].eye.x, cams[vp].eye.z) + 0.4f;
|
||||
if (cams[vp].eye.y < min_cam_y) cams[vp].eye.y = min_cam_y;
|
||||
world_ren_.render_world_view(cams[vp], models, parts, vp, split_count, cfg_);
|
||||
auto vp_lights = select_viewport_lights(all_lights, cams[vp].target, draw_dist);
|
||||
world_ren_.render_world_view(cams[vp], models, parts, vp, split_count, cfg_, vp_lights, craft_shadows);
|
||||
}
|
||||
world_ren_.end_classic_world_pass(win_w_, win_h_, cfg_);
|
||||
|
||||
// Compute screen-space 2D HUD viewport bounds (respects Classic 4:3 pillarbox!)
|
||||
int frame_x = 0, frame_y_gl = 0, frame_w = win_w_, frame_h = win_h_;
|
||||
if (cfg_.classic_mode) {
|
||||
float win_aspect = static_cast<float>(win_w_) / static_cast<float>(std::max(win_h_, 1));
|
||||
constexpr float kTargetAspect = 4.0f / 3.0f;
|
||||
if (win_aspect > kTargetAspect) {
|
||||
frame_w = static_cast<int>(static_cast<float>(win_h_) * kTargetAspect);
|
||||
frame_x = (win_w_ - frame_w) / 2;
|
||||
} else {
|
||||
frame_h = static_cast<int>(static_cast<float>(win_w_) / kTargetAspect);
|
||||
frame_y_gl = (win_h_ - frame_h) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
ui_ren_.begin(win_w_, win_h_);
|
||||
for (int vp = 0; vp < split_count; ++vp) {
|
||||
int vh = (split_count == 2) ? (win_h_ / 2) : win_h_;
|
||||
int vy = (split_count == 2 && vp == 0) ? 0 : (split_count == 2 ? vh : 0);
|
||||
int gl_vy = (split_count == 2 && vp == 0) ? (win_h_ - vh) : 0;
|
||||
int vh = (split_count == 2) ? (frame_h / 2) : frame_h;
|
||||
int gl_vy = (split_count == 2)
|
||||
? ((vp == 0) ? (frame_y_gl + frame_h - vh) : frame_y_gl)
|
||||
: frame_y_gl;
|
||||
if (hud_visible_) {
|
||||
// Draw HUD inside screen coordinates [0..win_w_] x [vy..vy+vh]
|
||||
render_hud_viewport(race_sim_.crafts()[vp], cams[vp], 0, gl_vy, win_w_, vh,
|
||||
render_hud_viewport(race_sim_.crafts()[vp], cams[vp], frame_x, gl_vy, frame_w, vh,
|
||||
vp == 0 && cfg_.show_minimap);
|
||||
} else if (race_sim_.countdown_active()) {
|
||||
float hs = std::clamp(static_cast<float>(vh) / 720.0f, 0.55f, 1.5f);
|
||||
} else if (race_sim_.countdown_active() || race_sim_.crafts()[vp].race_time < 0.85f) {
|
||||
float hs = std::clamp(static_cast<float>(vh) / 480.0f, 0.55f, 1.8f);
|
||||
int top_y = win_h_ - (gl_vy + vh);
|
||||
int c = static_cast<int>(std::ceil(race_sim_.countdown_timer()));
|
||||
ui_ren_.draw_text_centered(static_cast<float>(win_w_) * 0.5f,
|
||||
static_cast<float>(top_y) + static_cast<float>(vh) * 0.25f,
|
||||
4.8f * hs, std::to_string(c),
|
||||
Vec4(1.0f, 1.0f, 1.0f, 1.0f), true, render::UiFont::Panel);
|
||||
float cx = static_cast<float>(frame_x) + static_cast<float>(frame_w) * 0.5f;
|
||||
render_countdown_lights(cx, static_cast<float>(top_y) + 126.0f * hs, hs);
|
||||
}
|
||||
if (split_count == 2 && vp == 0) {
|
||||
ui_ren_.draw_rect(0, static_cast<float>(vh - 2), static_cast<float>(win_w_), 4.0f,
|
||||
Vec4(0.1f, 0.1f, 0.15f, 1.0f));
|
||||
int div_y = win_h_ - (frame_y_gl + vh);
|
||||
ui_ren_.draw_rect(static_cast<float>(frame_x), static_cast<float>(div_y - 2),
|
||||
static_cast<float>(frame_w), 4.0f, Vec4(0.1f, 0.1f, 0.15f, 1.0f));
|
||||
}
|
||||
(void)vy;
|
||||
}
|
||||
if (state_ == ScreenState::Paused) {
|
||||
render_menus();
|
||||
@@ -1246,122 +1396,300 @@ void GameApp::render_hud_viewport(const sim::CraftState& craft, const render::Re
|
||||
int vx, int vy, int vw, int vh, bool show_minimap) {
|
||||
const auto& str = get_strings(cfg_.language);
|
||||
int top_y = win_h_ - (vy + vh);
|
||||
float s = std::clamp(static_cast<float>(vh) / 720.0f, 0.55f, 1.5f);
|
||||
bool split_view = (selected_mode_ == sim::GameMode::SplitScreen && race_sim_.crafts().size() >= 2);
|
||||
float hs = std::min(static_cast<float>(vw) / 640.0f,
|
||||
static_cast<float>(vh) / (split_view ? 410.0f : 475.0f));
|
||||
hs = std::clamp(hs, 0.55f, 2.4f);
|
||||
float s = std::clamp(static_cast<float>(vh) / 720.0f, 0.55f, 1.6f);
|
||||
|
||||
// 1. Missile lock-on targeting diamond
|
||||
float ox = static_cast<float>(vx) + (static_cast<float>(vw) - 640.0f * hs) * 0.5f;
|
||||
float oy = static_cast<float>(top_y) + 2.0f * hs;
|
||||
|
||||
auto draw_panel = [&](int spr, float x640, float y480, const Vec4& tint = Vec4(1, 1, 1, 1)) {
|
||||
ui_ren_.draw_bank_sprite("panel", spr, ox + x640 * hs, oy + y480 * hs, hs, tint);
|
||||
};
|
||||
|
||||
// 1. Missile Lock-On Target Reticle (#258..#267)
|
||||
if (craft.lock_target_id >= 0 && craft.lock_target_id < static_cast<int>(race_sim_.crafts().size())) {
|
||||
const auto& tgt = race_sim_.crafts()[craft.lock_target_id];
|
||||
if (tgt.recovery_state == sim::RecoveryState::Active) {
|
||||
float aspect = static_cast<float>(vw) / static_cast<float>(std::max(vh, 1));
|
||||
if (split_view) aspect = std::max(aspect, 1.0f);
|
||||
float fov = cfg_.classic_mode ? 62.0f : cfg_.fov_deg;
|
||||
Mat4 vp_mat = Mat4::perspective(deg_to_rad(fov), aspect, cam.z_near, cam.z_far) *
|
||||
Mat4::look_at(cam.eye, cam.target, cam.up);
|
||||
float sx = 0, sy = 0;
|
||||
float sx = 0.0f, sy = 0.0f;
|
||||
if (project_world_to_screen(tgt.curr_pose.pos, vp_mat, vx, vy, vw, vh, win_h_, sx, sy)) {
|
||||
Vec4 rcol = (craft.lock_progress >= 1.0f) ? Vec4(1.0f, 0.2f, 0.15f, 0.95f)
|
||||
: Vec4(1.0f, 0.85f, 0.2f, 0.85f);
|
||||
float r = 24.0f * (1.5f - 0.5f * craft.lock_progress) * s;
|
||||
ui_ren_.draw_rect_outline(sx - r, sy - r, r * 2.0f, r * 2.0f, 2.0f, rcol);
|
||||
if (craft.lock_progress >= 1.0f) {
|
||||
ui_ren_.draw_text_centered(sx, sy - r - 18.0f * s, 1.5f * s, "LOCK", rcol);
|
||||
bool locked = (craft.lock_progress >= 1.0f);
|
||||
float pulse = locked ? (0.75f + 0.25f * std::sin(static_cast<float>(ui_time_) * 16.0f)) : 0.92f;
|
||||
Vec4 tint(1.0f, 1.0f, 1.0f, pulse);
|
||||
float rs = std::max(1.25f, hs * 1.15f);
|
||||
int box_spr = locked ? 259 : 258;
|
||||
ui_ren_.draw_bank_sprite("panel", box_spr, sx - 10.5f * rs, sy - 9.5f * rs, rs, tint);
|
||||
|
||||
float spread = (1.0f - craft.lock_progress) * 26.0f * rs + 11.5f * rs;
|
||||
ui_ren_.draw_bank_sprite("panel", locked ? 261 : 260, sx - 10.5f * rs, sy - spread - 4.0f * rs, rs, tint);
|
||||
ui_ren_.draw_bank_sprite("panel", locked ? 263 : 262, sx - 10.5f * rs, sy + spread, rs, tint);
|
||||
ui_ren_.draw_bank_sprite("panel", locked ? 265 : 264, sx - spread - 4.0f * rs, sy - 9.5f * rs, rs, tint);
|
||||
ui_ren_.draw_bank_sprite("panel", locked ? 267 : 266, sx + spread, sy - 9.5f * rs, rs, tint);
|
||||
|
||||
if (locked) {
|
||||
ui_ren_.draw_text_centered(sx, sy - spread - 20.0f * s, 1.15f * s, "LOCK",
|
||||
Vec4(1.0f, 0.25f, 0.18f, pulse), true, render::UiFont::Panel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Top-left Race Info (POS, LAP, TIME)
|
||||
float pad = 16.0f * s;
|
||||
float top_box_w = 300.0f * s;
|
||||
float top_box_h = 78.0f * s;
|
||||
ui_ren_.draw_rect(pad, top_y + pad, top_box_w, top_box_h, Vec4(0.02f, 0.04f, 0.1f, 0.68f));
|
||||
ui_ren_.draw_rect_outline(pad, top_y + pad, top_box_w, top_box_h, 2.0f, Vec4(0.25f, 0.65f, 1.0f, 0.8f));
|
||||
char line1[64], line2[64];
|
||||
if (selected_mode_ == sim::GameMode::DeathMatch) {
|
||||
std::snprintf(line1, sizeof(line1), "POS %d/%zu KILLS %d/%d",
|
||||
craft.placement, race_sim_.crafts().size(),
|
||||
craft.kills, race_sim_.setup().deathmatch_kill_limit);
|
||||
} else {
|
||||
std::snprintf(line1, sizeof(line1), "POS %d/%zu LAP %d/%d",
|
||||
craft.placement, race_sim_.crafts().size(),
|
||||
std::min(craft.lap, race_sim_.setup().total_laps),
|
||||
race_sim_.setup().total_laps);
|
||||
}
|
||||
std::snprintf(line2, sizeof(line2), "TIME %s", format_time(craft.race_time).c_str());
|
||||
ui_ren_.draw_text_fit(pad + 10.0f * s, top_y + pad + 10.0f * s, top_box_w - 20.0f * s,
|
||||
1.75f * s, line1, Vec4(1, 0.9f, 0.25f, 1));
|
||||
ui_ren_.draw_text_fit(pad + 10.0f * s, top_y + pad + 34.0f * s, top_box_w - 20.0f * s,
|
||||
1.55f * s, line2, Vec4(0.85f, 0.95f, 1, 1));
|
||||
if (craft.best_lap_time > 0.0f) {
|
||||
ui_ren_.draw_text_fit(pad + 10.0f * s, top_y + pad + 55.0f * s, top_box_w - 20.0f * s,
|
||||
1.40f * s, "BEST " + format_time(craft.best_lap_time), Vec4(0.4f, 1.0f, 0.6f, 1));
|
||||
}
|
||||
|
||||
// 3. Bottom-left Vehicle Resource Bars + Speedometer
|
||||
float hud_w = 330.0f * s;
|
||||
float hud_h = 108.0f * s;
|
||||
float hud_y = static_cast<float>(top_y + vh) - hud_h - pad;
|
||||
ui_ren_.draw_rect(pad, hud_y, hud_w, hud_h, Vec4(0.02f, 0.04f, 0.1f, 0.72f));
|
||||
ui_ren_.draw_rect_outline(pad, hud_y, hud_w, hud_h, 2.0f, Vec4(0.25f, 0.65f, 1.0f, 0.8f));
|
||||
|
||||
auto draw_bar = [&](float bx, float by, const char* lbl, float val, float maxv, const Vec4& col,
|
||||
bool charging) {
|
||||
Vec4 lbl_col = charging
|
||||
? ((static_cast<int>(craft.race_time * 10.0f) & 1) ? Vec4(1.0f, 1.0f, 1.0f, 1.0f)
|
||||
: Vec4(0.45f, 1.0f, 0.55f, 1.0f))
|
||||
: Vec4(0.85f, 0.9f, 1.0f, 1);
|
||||
ui_ren_.draw_text_fit(bx, by, 72.0f * s, 1.45f * s, lbl, lbl_col);
|
||||
float bar_x = bx + 78.0f * s;
|
||||
float bar_w = 215.0f * s;
|
||||
float bar_h = 12.0f * s;
|
||||
ui_ren_.draw_rect(bar_x, by, bar_w, bar_h, Vec4(0.12f, 0.12f, 0.18f, 0.9f));
|
||||
if (charging) {
|
||||
ui_ren_.draw_rect_outline(bar_x, by, bar_w, bar_h, 1.0f, Vec4(0.45f, 1.0f, 0.55f, 0.9f));
|
||||
// 2. Authentic Top Visor Curved Segmented Gauges (HIOCTANE.EXE PANEL0-1 tables)
|
||||
struct SegSpec {
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
int16_t spr;
|
||||
int thr;
|
||||
};
|
||||
auto draw_arc = [&](const SegSpec* segs, int count, int val_10000,
|
||||
const Vec4& lit_tint, float back_alpha) {
|
||||
Vec4 dim_tint(0.14f, 0.17f, 0.24f, back_alpha);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
draw_panel(segs[i].spr, static_cast<float>(segs[i].x), static_cast<float>(segs[i].y), dim_tint);
|
||||
}
|
||||
float frac = std::clamp(val / std::max(maxv, 1.0f), 0.0f, 1.0f);
|
||||
ui_ren_.draw_rect(bar_x + 1, by + 1, (bar_w - 2) * frac, bar_h - 2, col);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
if (val_10000 > segs[i].thr) {
|
||||
draw_panel(segs[i].spr, static_cast<float>(segs[i].x), static_cast<float>(segs[i].y), lit_tint);
|
||||
}
|
||||
}
|
||||
};
|
||||
draw_bar(pad + 10.0f * s, hud_y + 10.0f * s, "SHLD", craft.shield, craft.max_shield,
|
||||
Vec4(0.2f, 0.75f, 1.0f, 1), (craft.active_recharge_mask & 1u) != 0);
|
||||
draw_bar(pad + 10.0f * s, hud_y + 30.0f * s, "FUEL", craft.fuel, craft.max_fuel,
|
||||
Vec4(1.0f, 0.65f, 0.15f, 1), (craft.active_recharge_mask & 2u) != 0);
|
||||
draw_bar(pad + 10.0f * s, hud_y + 50.0f * s, "AMMO", craft.ammo, craft.max_ammo,
|
||||
Vec4(0.95f, 0.9f, 0.25f, 1), (craft.active_recharge_mask & 4u) != 0);
|
||||
|
||||
int kmh = static_cast<int>(craft.speed_horizontal() * 14.5f);
|
||||
char spd_buf[64];
|
||||
std::snprintf(spd_buf, sizeof(spd_buf), "%3d KPH G%d M%d B%d",
|
||||
kmh, craft.minigun_level, craft.missile_level, craft.booster_level);
|
||||
ui_ren_.draw_text_fit(pad + 10.0f * s, hud_y + 74.0f * s, hud_w - 20.0f * s,
|
||||
1.65f * s, spd_buf, Vec4(1, 1, 1, 1));
|
||||
static constexpr SegSpec kFuelArc[17] = {
|
||||
{514, 4, 17, 0}, {488, 4, 16, 384}, {464, 4, 15, 768}, {440, 4, 14, 1152},
|
||||
{414, 4, 13, 1536}, {390, 4, 12, 1920}, {366, 4, 11, 2304}, {342, 4, 10, 2688},
|
||||
{324, 4, 9, 3072}, {306, 4, 8, 3456}, {286, 4, 7, 3840}, {264, 4, 6, 4224},
|
||||
{240, 4, 5, 4608}, {216, 4, 4, 5376}, {182, 4, 3, 6528}, {136, 4, 2, 7680},
|
||||
{82, 4, 1, 8832},
|
||||
};
|
||||
static constexpr SegSpec kSpeedWaveDim[19] = {
|
||||
{120, 16, 18, 0}, {142, 16, 19, 526}, {162, 16, 20, 1052}, {186, 16, 21, 1578},
|
||||
{206, 16, 22, 2104}, {228, 16, 23, 2630}, {246, 16, 24, 3156}, {268, 16, 25, 3682},
|
||||
{288, 16, 26, 4208}, {306, 16, 27, 4734}, {324, 16, 28, 5260}, {342, 16, 29, 5786},
|
||||
{364, 16, 30, 6312}, {388, 16, 31, 6838}, {414, 16, 32, 7364}, {438, 16, 33, 7890},
|
||||
{462, 16, 34, 8416}, {484, 16, 35, 8942}, {508, 16, 36, 9468},
|
||||
};
|
||||
static constexpr SegSpec kSpeedWaveLit[19] = {
|
||||
{120, 16, 37, 0}, {142, 16, 38, 526}, {162, 16, 39, 1052}, {186, 16, 40, 1578},
|
||||
{206, 16, 41, 2104}, {228, 16, 42, 2630}, {246, 16, 43, 3156}, {268, 16, 44, 3682},
|
||||
{288, 16, 45, 4208}, {306, 16, 46, 4734}, {324, 16, 47, 5260}, {342, 16, 48, 5786},
|
||||
{364, 16, 49, 6312}, {388, 16, 50, 6838}, {414, 16, 51, 7364}, {438, 16, 52, 7890},
|
||||
{462, 16, 53, 8416}, {484, 16, 54, 8942}, {508, 16, 55, 9468},
|
||||
};
|
||||
static constexpr SegSpec kSpeedBar[16] = {
|
||||
{128, 26, 56, 0}, {148, 26, 57, 384}, {168, 26, 58, 768}, {188, 26, 59, 1152},
|
||||
{208, 26, 60, 1536}, {230, 26, 61, 1920}, {248, 26, 62, 2304}, {268, 26, 63, 2688},
|
||||
{288, 26, 64, 3072}, {306, 26, 65, 3456}, {324, 26, 66, 3840}, {342, 26, 67, 4608},
|
||||
{360, 26, 68, 5376}, {380, 26, 69, 6528}, {418, 26, 70, 7680}, {454, 26, 71, 8832},
|
||||
};
|
||||
static constexpr SegSpec kShieldArc[6] = {
|
||||
{4, 4, 72, 0}, {42, 4, 73, 1666}, {68, 4, 74, 3332},
|
||||
{76, 4, 75, 4998}, {96, 4, 76, 6664}, {114, 4, 77, 8330},
|
||||
};
|
||||
static constexpr SegSpec kAmmoArc[6] = {
|
||||
{596, 4, 91, 0}, {554, 4, 90, 1666}, {526, 4, 89, 3332},
|
||||
{506, 4, 88, 4998},{488, 4, 87, 6664}, {460, 4, 86, 8330},
|
||||
};
|
||||
static constexpr SegSpec kRightWingRed[16] = {
|
||||
{502, 28, 92, 0}, {518, 28, 93, 625}, {524, 28, 94, 1250}, {530, 28, 95, 1875},
|
||||
{536, 28, 96, 2500}, {542, 28, 97, 3125}, {548, 28, 98, 3750}, {554, 28, 99, 4375},
|
||||
{566, 28, 100, 5000},{578, 28, 101, 5625},{586, 28, 102, 6250}, {594, 28, 103, 6875},
|
||||
{602, 28, 104, 7500},{610, 28, 105, 8125},{618, 28, 106, 8750}, {626, 28, 107, 9375},
|
||||
};
|
||||
|
||||
// 4. Top-right Track Minimap
|
||||
if (show_minimap) {
|
||||
float mm_size = 138.0f * s;
|
||||
render_minimap(craft, static_cast<float>(vw) - mm_size - pad, static_cast<float>(top_y) + pad, mm_size);
|
||||
float shield_frac = cfg_.damage_enabled ? std::clamp(craft.shield / std::max(craft.max_shield, 1.0f), 0.0f, 1.0f) : 1.0f;
|
||||
float fuel_frac = cfg_.fuel_enabled ? std::clamp(craft.fuel / std::max(craft.max_fuel, 1.0f), 0.0f, 1.0f) : 1.0f;
|
||||
float ammo_frac = cfg_.weapons_enabled ? std::clamp(craft.ammo / std::max(craft.max_ammo, 1.0f), 0.0f, 1.0f) : 1.0f;
|
||||
|
||||
auto status_tint = [&](float frac, uint8_t bit_mask) -> Vec4 {
|
||||
if ((craft.active_recharge_mask & bit_mask) != 0) {
|
||||
float p = 0.80f + 0.20f * std::sin(static_cast<float>(ui_time_) * 12.0f);
|
||||
return Vec4(1.25f * p, 1.35f * p, 1.25f * p, 1.0f);
|
||||
}
|
||||
if (frac < 0.20f && frac > 0.0f) {
|
||||
float blink = 0.55f + 0.45f * std::sin(static_cast<float>(ui_time_) * 10.0f);
|
||||
return Vec4(1.0f, 0.72f, 0.72f, blink);
|
||||
}
|
||||
return Vec4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
};
|
||||
|
||||
// Draw Speed Wave + Fuel + Shield + Ammo + Speedometer + Right Boost/Lock Wing
|
||||
const auto& spec = sim::kVehicleSpecs[std::clamp(craft.vehicle_idx, 0, 5)];
|
||||
float boost_mult = 1.0f + 0.14f * static_cast<float>(craft.booster_level - 1);
|
||||
float max_ref_spd = spec.top_speed + spec.boost_bonus * boost_mult;
|
||||
float spd_frac = std::clamp(craft.speed_horizontal() / std::max(max_ref_spd, 1.0f), 0.0f, 1.0f);
|
||||
|
||||
draw_arc(kFuelArc, 17, static_cast<int>(fuel_frac * 10000.0f), status_tint(fuel_frac, 2u), 0.26f);
|
||||
draw_arc(kSpeedWaveDim, 19, static_cast<int>(spd_frac * 10000.0f), Vec4(1.0f, 1.0f, 1.0f, 0.95f), 0.22f);
|
||||
if (craft.boost_timer > 0.0f) {
|
||||
int wave_val = static_cast<int>(std::clamp(spd_frac + 0.25f, 0.35f, 1.0f) * 10000.0f);
|
||||
for (int i = 0; i < 19; ++i) {
|
||||
if (wave_val > kSpeedWaveLit[i].thr) {
|
||||
draw_panel(kSpeedWaveLit[i].spr, static_cast<float>(kSpeedWaveLit[i].x),
|
||||
static_cast<float>(kSpeedWaveLit[i].y), Vec4(1.0f, 1.0f, 1.0f, 0.98f));
|
||||
}
|
||||
}
|
||||
}
|
||||
draw_arc(kSpeedBar, 16, static_cast<int>(spd_frac * 10000.0f), Vec4(1.0f, 1.0f, 1.0f, 1.0f), 0.25f);
|
||||
draw_arc(kShieldArc, 6, static_cast<int>(shield_frac * 10000.0f), status_tint(shield_frac, 1u), 0.30f);
|
||||
draw_arc(kAmmoArc, 6, static_cast<int>(ammo_frac * 10000.0f), status_tint(ammo_frac, 4u), 0.30f);
|
||||
|
||||
// Right wing orange/red bar shows Missile Lock Charge (when locking) or Booster overdrive charge
|
||||
float right_frac = (craft.lock_target_id >= 0 && craft.lock_progress > 0.02f)
|
||||
? craft.lock_progress
|
||||
: (craft.boost_timer > 0.0f ? std::clamp(craft.boost_timer / 2.5f, 0.0f, 1.0f)
|
||||
: spd_frac * 0.7f);
|
||||
Vec4 right_tint = (craft.lock_progress >= 1.0f)
|
||||
? Vec4(1.3f, 0.9f, 0.9f, 0.7f + 0.3f * std::sin(static_cast<float>(ui_time_) * 16.0f))
|
||||
: Vec4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
draw_arc(kRightWingRed, 16, static_cast<int>(right_frac * 10000.0f), right_tint, 0.25f);
|
||||
|
||||
// 3. Giant Metallic Position Counter (#108..#117, #138 '/', #128..#137)
|
||||
int place = std::clamp(craft.placement, 0, 9);
|
||||
int total_c = std::clamp(static_cast<int>(race_sim_.crafts().size()), 1, 9);
|
||||
draw_panel(108 + place, 4.0f, 32.0f);
|
||||
draw_panel(138, 56.0f, 76.0f);
|
||||
draw_panel(128 + total_c, 86.0f, 76.0f);
|
||||
|
||||
// 4. Weapon & Booster Upgrade Bars (#268..#276)
|
||||
draw_panel(268, 148.0f, 70.0f);
|
||||
draw_panel(271, 264.0f, 70.0f);
|
||||
draw_panel(274, 362.0f, 70.0f);
|
||||
for (int p = 0; p < 3; ++p) {
|
||||
Vec4 gun_t = (craft.minigun_level > p) ? Vec4(1, 1, 1, 1) : Vec4(0.25f, 0.25f, 0.30f, 0.45f);
|
||||
Vec4 msl_t = (craft.missile_level > p) ? Vec4(1, 1, 1, 1) : Vec4(0.25f, 0.25f, 0.30f, 0.45f);
|
||||
Vec4 bst_t = (craft.booster_level > p) ? Vec4(1, 1, 1, 1) : Vec4(0.25f, 0.25f, 0.30f, 0.45f);
|
||||
draw_panel(270, 218.0f + p * 14.0f, 70.0f, gun_t);
|
||||
draw_panel(273, 316.0f + p * 14.0f, 70.0f, msl_t);
|
||||
draw_panel((p == 2) ? 276 : 275, 412.0f + p * 14.0f, 70.0f, bst_t);
|
||||
}
|
||||
|
||||
// 5. Center Warnings & Banners
|
||||
float cx = static_cast<float>(vw) * 0.5f;
|
||||
float cy = static_cast<float>(top_y) + static_cast<float>(vh) * 0.25f;
|
||||
if (race_sim_.countdown_active()) {
|
||||
int c = static_cast<int>(std::ceil(race_sim_.countdown_timer()));
|
||||
ui_ren_.draw_text_centered(cx, cy, 4.8f * s, std::to_string(c),
|
||||
Vec4(1.0f, 1.0f, 1.0f, 1.0f), true, render::UiFont::Panel);
|
||||
// 5. Lap Counter (or DeathMatch Kill Limit) under Left Wing (#227 + small red digits #139..#150)
|
||||
int cur_a = (selected_mode_ == sim::GameMode::DeathMatch)
|
||||
? std::clamp(craft.kills, 0, 99)
|
||||
: std::clamp(std::min(craft.lap, race_sim_.setup().total_laps), 1, 99);
|
||||
int max_b = (selected_mode_ == sim::GameMode::DeathMatch)
|
||||
? std::clamp(race_sim_.setup().deathmatch_kill_limit, 1, 99)
|
||||
: std::clamp(race_sim_.setup().total_laps, 1, 99);
|
||||
draw_panel(227, 128.0f, 94.0f);
|
||||
draw_panel(139 + (cur_a / 10) % 10, 178.0f, 96.0f);
|
||||
draw_panel(139 + (cur_a % 10), 192.0f, 96.0f);
|
||||
draw_panel(150, 204.0f, 96.0f);
|
||||
draw_panel(139 + (max_b / 10) % 10, 218.0f, 96.0f);
|
||||
draw_panel(139 + (max_b % 10), 232.0f, 96.0f);
|
||||
|
||||
// 6. Top-Right Red Skull & Kills Counter (#228 + medium red digits #118..#127)
|
||||
int kills_clamped = std::clamp(craft.kills, 0, 99);
|
||||
draw_panel(228, 554.0f, 68.0f);
|
||||
draw_panel(118 + (kills_clamped / 10) % 10, 586.0f, 68.0f);
|
||||
draw_panel(118 + (kills_clamped % 10), 612.0f, 68.0f);
|
||||
|
||||
// 7. Recharging Hazard Banner (#198/#199) or Low-Resource Alert below upgrade bars
|
||||
if (craft.active_recharge_mask != 0) {
|
||||
int stripe_spr = (static_cast<int>(ui_time_ * 6.0) & 1) ? 198 : 199;
|
||||
draw_panel(stripe_spr, 260.0f, 98.0f);
|
||||
draw_panel(stripe_spr == 198 ? 199 : 198, 492.0f, 98.0f);
|
||||
const char* rmsg = "RECHARGING";
|
||||
Vec4 rcol(0.35f, 1.0f, 0.55f, 1.0f);
|
||||
if (craft.active_recharge_mask & 1u) {
|
||||
rmsg = "SHIELD CHARGING";
|
||||
rcol = Vec4(0.35f, 1.0f, 0.55f, 1.0f);
|
||||
} else if (craft.active_recharge_mask & 2u) {
|
||||
rmsg = "FUEL CHARGING";
|
||||
rcol = Vec4(0.42f, 0.85f, 1.0f, 1.0f);
|
||||
} else if (craft.active_recharge_mask & 4u) {
|
||||
rmsg = "AMMO CHARGING";
|
||||
rcol = Vec4(1.0f, 0.90f, 0.25f, 1.0f);
|
||||
}
|
||||
ui_ren_.draw_text_centered_fit(ox + 401.0f * hs, oy + 99.0f * hs, 174.0f * hs, 1.15f * hs,
|
||||
rmsg, rcol, true, render::UiFont::Panel);
|
||||
} else if (cfg_.damage_enabled && shield_frac < 0.20f) {
|
||||
if ((static_cast<int>(ui_time_ * 6.0) & 1) == 0) {
|
||||
ui_ren_.draw_text_centered_fit(ox + 398.0f * hs, oy + 99.0f * hs, 220.0f * hs, 1.2f * hs,
|
||||
"SHIELD LOW", Vec4(1.0f, 0.28f, 0.25f, 1.0f), true, render::UiFont::Panel);
|
||||
}
|
||||
} else if (cfg_.fuel_enabled && fuel_frac < 0.18f) {
|
||||
if ((static_cast<int>(ui_time_ * 6.0) & 1) == 0) {
|
||||
ui_ren_.draw_text_centered_fit(ox + 398.0f * hs, oy + 99.0f * hs, 220.0f * hs, 1.2f * hs,
|
||||
"FUEL LOW", Vec4(1.0f, 0.65f, 0.2f, 1.0f), true, render::UiFont::Panel);
|
||||
}
|
||||
}
|
||||
|
||||
// 8. Bottom-Left Compact Telemetry Card (Speed KPH using #151..#160 silver digits + TIME / BEST)
|
||||
float pad = 14.0f * s;
|
||||
float card_w = (split_view ? 206.0f : 232.0f) * s;
|
||||
float card_h = (craft.best_lap_time > 0.0f) ? (80.0f * s) : (58.0f * s);
|
||||
float card_x = static_cast<float>(vx) + pad;
|
||||
float card_y = static_cast<float>(top_y + vh) - card_h - pad;
|
||||
ui_ren_.draw_rect(card_x, card_y, card_w, card_h, Vec4(0.02f, 0.04f, 0.10f, 0.64f));
|
||||
ui_ren_.draw_rect_outline(card_x, card_y, card_w, card_h, 2.0f, Vec4(0.28f, 0.68f, 1.0f, 0.78f));
|
||||
|
||||
int kmh = std::clamp(static_cast<int>(craft.speed_horizontal() * 14.5f), 0, 999);
|
||||
float ds = (split_view ? 0.85f : 1.0f) * s;
|
||||
ui_ren_.draw_bank_sprite("panel", 151 + (kmh / 100) % 10, card_x + 10.0f * s, card_y + 7.0f * s, ds);
|
||||
ui_ren_.draw_bank_sprite("panel", 151 + (kmh / 10) % 10, card_x + 25.0f * s, card_y + 7.0f * s, ds);
|
||||
ui_ren_.draw_bank_sprite("panel", 151 + (kmh % 10), card_x + 40.0f * s, card_y + 7.0f * s, ds);
|
||||
ui_ren_.draw_text_fit(card_x + 60.0f * s, card_y + 9.0f * s, card_w - 68.0f * s, 1.65f * s,
|
||||
"KPH", Vec4(0.75f, 0.90f, 1.0f, 1.0f), true, render::UiFont::MenuSmall);
|
||||
std::string time_str = (craft.race_time > 0.0f) ? format_time(craft.race_time) : "00:00.00";
|
||||
ui_ren_.draw_text_fit(card_x + 10.0f * s, card_y + 34.0f * s, card_w - 20.0f * s, 1.60f * s,
|
||||
"TIME " + time_str, Vec4(0.92f, 0.97f, 1.0f, 1.0f),
|
||||
true, render::UiFont::MenuSmall);
|
||||
if (craft.best_lap_time > 0.0f) {
|
||||
ui_ren_.draw_text_fit(card_x + 10.0f * s, card_y + 55.0f * s, card_w - 20.0f * s, 1.40f * s,
|
||||
"BEST " + format_time(craft.best_lap_time), Vec4(0.42f, 1.0f, 0.65f, 1.0f),
|
||||
true, render::UiFont::MenuSmall);
|
||||
}
|
||||
|
||||
// 9. Bottom-Right Minimap (kept completely clear of top visor gauges!)
|
||||
if (show_minimap) {
|
||||
float mm_size = (split_view ? 110.0f : 152.0f) * s;
|
||||
render_minimap(craft, static_cast<float>(vx + vw) - mm_size - pad,
|
||||
static_cast<float>(top_y + vh) - mm_size - pad, mm_size);
|
||||
}
|
||||
|
||||
// 10. Center Start Traffic Lights (#281..#286), Wrong-Way Warning & Banners
|
||||
float cx = static_cast<float>(vx) + static_cast<float>(vw) * 0.5f;
|
||||
float cy = oy + 126.0f * hs;
|
||||
if (race_sim_.countdown_active() || (!race_sim_.countdown_active() && craft.race_time < 0.85f)) {
|
||||
render_countdown_lights(cx, cy, hs);
|
||||
} else if (craft.wrong_way) {
|
||||
ui_ren_.draw_text_centered_fit(cx, cy, static_cast<float>(vw) * 0.8f, 2.8f * s,
|
||||
str.wrong_way, Vec4(1.0f, 0.2f, 0.2f, 1.0f));
|
||||
ui_ren_.draw_text_centered_fit(cx, cy + 28.0f * s, static_cast<float>(vw) * 0.75f, 2.6f * s,
|
||||
str.wrong_way, Vec4(1.0f, 0.22f, 0.20f, 1.0f), true, render::UiFont::MenuLarge);
|
||||
} else {
|
||||
int pi = (craft.player_index == 1) ? 1 : 0;
|
||||
if (hud_banner_timer_[pi] > 0.0f && !hud_banner_[pi].empty()) {
|
||||
ui_ren_.draw_text_centered_fit(cx, cy, static_cast<float>(vw) * 0.8f, 2.6f * s,
|
||||
hud_banner_[pi], Vec4(1.0f, 0.92f, 0.25f, 1.0f));
|
||||
ui_ren_.draw_text_centered_fit(cx, cy + 26.0f * s, static_cast<float>(vw) * 0.75f, 2.4f * s,
|
||||
hud_banner_[pi], Vec4(1.0f, 0.92f, 0.25f, 1.0f),
|
||||
true, render::UiFont::MenuLarge);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GameApp::render_countdown_lights(float cx, float ly, float hs) {
|
||||
float ct = race_sim_.countdown_timer();
|
||||
bool counting = race_sim_.countdown_active();
|
||||
ui_ren_.draw_bank_sprite("panel", (counting && ct > 1.0f) ? 282 : 281, cx - 102.0f * hs, ly, hs);
|
||||
ui_ren_.draw_bank_sprite("panel", (counting && ct <= 2.0f) ? 284 : 283, cx - 32.0f * hs, ly, hs);
|
||||
ui_ren_.draw_bank_sprite("panel", (!counting) ? 286 : 285, cx + 38.0f * hs, ly, hs);
|
||||
if (counting) {
|
||||
int c = std::clamp(static_cast<int>(std::ceil(ct)), 1, 9);
|
||||
ui_ren_.draw_bank_sprite("panel", 108 + c, cx - 25.0f * hs, ly + 36.0f * hs, hs);
|
||||
} else {
|
||||
ui_ren_.draw_text_centered(cx, ly + 42.0f * hs, 2.8f * hs, "GO!",
|
||||
Vec4(0.35f, 1.0f, 0.45f, 1.0f), true, render::UiFont::MenuLarge);
|
||||
}
|
||||
}
|
||||
|
||||
void GameApp::render_minimap(const sim::CraftState& focus, float mx, float my, float size) {
|
||||
ui_ren_.draw_rect(mx, my, size, size, Vec4(0.02f, 0.04f, 0.09f, 0.72f));
|
||||
ui_ren_.draw_rect_outline(mx, my, size, size, 2.0f, Vec4(0.25f, 0.65f, 1.0f, 0.8f));
|
||||
ui_ren_.draw_rect(mx, my, size, size, Vec4(0.02f, 0.04f, 0.09f, 0.70f));
|
||||
ui_ren_.draw_rect_outline(mx, my, size, size, 2.0f, Vec4(0.28f, 0.68f, 1.0f, 0.82f));
|
||||
|
||||
const auto& lvl = race_sim_.level();
|
||||
const auto& wps = lvl.main_waypoints;
|
||||
@@ -1373,7 +1701,7 @@ void GameApp::render_minimap(const sim::CraftState& focus, float mx, float my, f
|
||||
min_z = std::min(min_z, w.z); max_z = std::max(max_z, w.z);
|
||||
}
|
||||
float span = std::max({max_x - min_x, max_z - min_z, 10.0f});
|
||||
float pad = 12.0f;
|
||||
float pad = size * 0.10f;
|
||||
float scale = (size - 2.0f * pad) / span;
|
||||
float ox = mx + (size - (max_x - min_x) * scale) * 0.5f;
|
||||
float oy = my + (size - (max_z - min_z) * scale) * 0.5f;
|
||||
@@ -1382,20 +1710,53 @@ void GameApp::render_minimap(const sim::CraftState& focus, float mx, float my, f
|
||||
return Vec2(ox + (wx - min_x) * scale, oy + (wz - min_z) * scale);
|
||||
};
|
||||
|
||||
// Dark outer casing + bright slate track ribbon
|
||||
for (size_t i = 0; i < wps.size(); ++i) {
|
||||
Vec2 p0 = to_mm(wps[i].x, wps[i].z);
|
||||
Vec2 p1 = to_mm(wps[(i + 1) % wps.size()].x, wps[(i + 1) % wps.size()].z);
|
||||
ui_ren_.draw_line(p0.x, p0.y, p1.x, p1.y, 2.0f, Vec4(0.45f, 0.6f, 0.75f, 0.9f));
|
||||
ui_ren_.draw_line(p0.x, p0.y, p1.x, p1.y, 4.5f, Vec4(0.08f, 0.14f, 0.22f, 0.95f));
|
||||
}
|
||||
for (size_t i = 0; i < wps.size(); ++i) {
|
||||
Vec2 p0 = to_mm(wps[i].x, wps[i].z);
|
||||
Vec2 p1 = to_mm(wps[(i + 1) % wps.size()].x, wps[(i + 1) % wps.size()].z);
|
||||
ui_ren_.draw_line(p0.x, p0.y, p1.x, p1.y, 2.2f, Vec4(0.50f, 0.70f, 0.88f, 0.95f));
|
||||
}
|
||||
|
||||
for (const auto& c : race_sim_.crafts()) {
|
||||
Vec2 p = to_mm(c.curr_pose.pos.x, c.curr_pose.pos.z);
|
||||
Vec4 dot_col = (c.id == focus.id) ? Vec4(1.0f, 0.9f, 0.1f, 1.0f)
|
||||
: (c.is_human ? Vec4(0.2f, 1.0f, 0.4f, 1.0f)
|
||||
: Vec4(1.0f, 0.3f, 0.3f, 1.0f));
|
||||
float r = (c.id == focus.id) ? 3.5f : 2.5f;
|
||||
ui_ren_.draw_rect(p.x - r, p.y - r, r * 2.0f, r * 2.0f, dot_col);
|
||||
// Start/finish orthogonal tick
|
||||
Vec2 sf0 = to_mm(wps[0].x, wps[0].z);
|
||||
Vec2 sf1 = to_mm(wps[1].x, wps[1].z);
|
||||
Vec2 td = (sf1 - sf0).normalized();
|
||||
Vec2 perp(-td.y, td.x);
|
||||
ui_ren_.draw_line(sf0.x - perp.x * 5.0f, sf0.y - perp.y * 5.0f,
|
||||
sf0.x + perp.x * 5.0f, sf0.y + perp.y * 5.0f, 2.5f, Vec4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
|
||||
// Pitstop bay markers (Shield emerald, Fuel cyan, Ammo gold)
|
||||
for (const auto& cp : lvl.pads) {
|
||||
Vec2 mp = to_mm(cp.cx, cp.cz);
|
||||
Vec4 pc(0.25f, 0.72f, 1.0f, 0.95f);
|
||||
if (cp.type == assets::ChargerType::Shield) pc = Vec4(0.20f, 1.0f, 0.45f, 0.95f);
|
||||
else if (cp.type == assets::ChargerType::Ammo) pc = Vec4(1.0f, 0.85f, 0.22f, 0.95f);
|
||||
ui_ren_.draw_rect(mp.x - 2.5f, mp.y - 2.5f, 5.0f, 5.0f, pc);
|
||||
}
|
||||
|
||||
// Opponent craft markers
|
||||
for (const auto& c : race_sim_.crafts()) {
|
||||
if (c.id == focus.id) continue;
|
||||
Vec2 p = to_mm(c.curr_pose.pos.x, c.curr_pose.pos.z);
|
||||
Vec4 dot_col = c.is_human ? Vec4(0.2f, 1.0f, 0.4f, 1.0f) : Vec4(1.0f, 0.3f, 0.28f, 1.0f);
|
||||
ui_ren_.draw_rect(p.x - 2.5f, p.y - 2.5f, 5.0f, 5.0f, dot_col);
|
||||
}
|
||||
|
||||
// Focus craft directional heading chevron
|
||||
Vec2 fp = to_mm(focus.curr_pose.pos.x, focus.curr_pose.pos.z);
|
||||
Vec2 fwd(std::sin(focus.curr_pose.yaw), std::cos(focus.curr_pose.yaw));
|
||||
Vec2 side(-fwd.y, fwd.x);
|
||||
Vec2 tip = fp + fwd * 5.5f;
|
||||
Vec2 bl = fp - fwd * 3.5f + side * 4.0f;
|
||||
Vec2 br = fp - fwd * 3.5f - side * 4.0f;
|
||||
ui_ren_.draw_line(tip.x, tip.y, bl.x, bl.y, 2.2f, Vec4(1.0f, 0.92f, 0.15f, 1.0f));
|
||||
ui_ren_.draw_line(tip.x, tip.y, br.x, br.y, 2.2f, Vec4(1.0f, 0.92f, 0.15f, 1.0f));
|
||||
ui_ren_.draw_line(bl.x, bl.y, br.x, br.y, 2.0f, Vec4(1.0f, 0.72f, 0.10f, 1.0f));
|
||||
}
|
||||
|
||||
void GameApp::render_menus() {
|
||||
|
||||
Reference in new issue
Block a user