Expose full gameplay rules, difficulty, HUD, and control options
This commit is contained in:
1 parent
6c24f715a0
commit
cd63921ea4
15 files changed
+564
-164
No files matched your search
@@ -71,11 +71,13 @@ bool AudioEngine::init(const Vfs& vfs, const GameConfig& cfg, bool open_device)
|
|||||||
|
|
||||||
// Optional external SoundFont (.sf2)
|
// Optional external SoundFont (.sf2)
|
||||||
has_custom_sf_ = false;
|
has_custom_sf_ = false;
|
||||||
|
loaded_custom_sf_path_.clear();
|
||||||
if (!cfg.custom_soundfont_path.empty()) {
|
if (!cfg.custom_soundfont_path.empty()) {
|
||||||
std::vector<uint8_t> sf_bytes;
|
std::vector<uint8_t> sf_bytes;
|
||||||
if (Vfs::read_raw_file(cfg.custom_soundfont_path, sf_bytes) &&
|
if (Vfs::read_raw_file(cfg.custom_soundfont_path, sf_bytes) &&
|
||||||
custom_sf_bank_.load_from_bytes(sf_bytes.data(), sf_bytes.size())) {
|
custom_sf_bank_.load_from_bytes(sf_bytes.data(), sf_bytes.size())) {
|
||||||
has_custom_sf_ = true;
|
has_custom_sf_ = true;
|
||||||
|
loaded_custom_sf_path_ = cfg.custom_soundfont_path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,6 +161,30 @@ void AudioEngine::apply_config(const GameConfig& cfg, bool window_focused) {
|
|||||||
music_vol_.store(cfg.music_volume, std::memory_order_relaxed);
|
music_vol_.store(cfg.music_volume, std::memory_order_relaxed);
|
||||||
muted_.store(cfg.mute_on_focus_loss && !window_focused, std::memory_order_relaxed);
|
muted_.store(cfg.mute_on_focus_loss && !window_focused, std::memory_order_relaxed);
|
||||||
|
|
||||||
|
if (cfg.custom_soundfont_path != loaded_custom_sf_path_) {
|
||||||
|
assets::SoundFontBank next_sf;
|
||||||
|
bool ok = false;
|
||||||
|
if (!cfg.custom_soundfont_path.empty()) {
|
||||||
|
std::vector<uint8_t> sf_bytes;
|
||||||
|
if (Vfs::read_raw_file(cfg.custom_soundfont_path, sf_bytes) &&
|
||||||
|
next_sf.load_from_bytes(sf_bytes.data(), sf_bytes.size())) {
|
||||||
|
ok = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (dev_id_ != 0) SDL_LockAudioDevice(dev_id_);
|
||||||
|
if (ok) {
|
||||||
|
custom_sf_bank_ = std::move(next_sf);
|
||||||
|
has_custom_sf_ = true;
|
||||||
|
} else {
|
||||||
|
custom_sf_bank_ = assets::SoundFontBank{};
|
||||||
|
has_custom_sf_ = false;
|
||||||
|
}
|
||||||
|
loaded_custom_sf_path_ = cfg.custom_soundfont_path;
|
||||||
|
sf_synth_.reset();
|
||||||
|
sf_synth_.set_soundfont(has_custom_sf_ ? &custom_sf_bank_ : &sf_bank_);
|
||||||
|
if (dev_id_ != 0) SDL_UnlockAudioDevice(dev_id_);
|
||||||
|
}
|
||||||
|
|
||||||
if (cfg.music_backend != requested_backend_) {
|
if (cfg.music_backend != requested_backend_) {
|
||||||
requested_backend_ = cfg.music_backend;
|
requested_backend_ = cfg.music_backend;
|
||||||
AudioCommand cmd;
|
AudioCommand cmd;
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ private:
|
|||||||
assets::OplTimbreBank opl_bank_;
|
assets::OplTimbreBank opl_bank_;
|
||||||
assets::SoundFontBank sf_bank_;
|
assets::SoundFontBank sf_bank_;
|
||||||
assets::SoundFontBank custom_sf_bank_;
|
assets::SoundFontBank custom_sf_bank_;
|
||||||
|
std::string loaded_custom_sf_path_;
|
||||||
bool has_custom_sf_ = false;
|
bool has_custom_sf_ = false;
|
||||||
|
|
||||||
// Pre-parsed sequences for 2 banks (Adlib .XMI and AWE32 .WTB) x 5 songs
|
// Pre-parsed sequences for 2 banks (Adlib .XMI and AWE32 .WTB) x 5 songs
|
||||||
|
|||||||
+35
-13
@@ -42,6 +42,20 @@ bool parse_bool(const std::string& v, bool def) {
|
|||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string sanitize_pilot_name(const std::string& raw, const char* fallback) {
|
||||||
|
std::string clean;
|
||||||
|
for (char raw_ch : trim(raw)) {
|
||||||
|
char c = static_cast<char>(std::toupper(static_cast<unsigned char>(raw_ch)));
|
||||||
|
if ((c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') ||
|
||||||
|
c == ' ' || c == '-' || c == '_' || c == '.') {
|
||||||
|
clean.push_back(c);
|
||||||
|
if (clean.size() >= 12) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
clean = trim(clean);
|
||||||
|
return clean.empty() ? std::string(fallback) : clean;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
bool GameConfig::load(const std::filesystem::path& path) {
|
bool GameConfig::load(const std::filesystem::path& path) {
|
||||||
@@ -115,24 +129,22 @@ bool GameConfig::load(const std::filesystem::path& path) {
|
|||||||
if (auto* v = get("keys.p2_fire_minigun")) keys.p2_fire_minigun = parse_int(*v, keys.p2_fire_minigun);
|
if (auto* v = get("keys.p2_fire_minigun")) keys.p2_fire_minigun = parse_int(*v, keys.p2_fire_minigun);
|
||||||
if (auto* v = get("keys.p2_fire_missile")) keys.p2_fire_missile = parse_int(*v, keys.p2_fire_missile);
|
if (auto* v = get("keys.p2_fire_missile")) keys.p2_fire_missile = parse_int(*v, keys.p2_fire_missile);
|
||||||
|
|
||||||
if (auto* v = get("game.player_name")) {
|
if (auto* v = get("game.player_name")) player_name = sanitize_pilot_name(*v, "PLAYER");
|
||||||
std::string clean;
|
if (auto* v = get("game.player2_name")) player2_name = sanitize_pilot_name(*v, "PLAYER 2");
|
||||||
for (char raw : trim(*v)) {
|
|
||||||
char c = static_cast<char>(std::toupper(static_cast<unsigned char>(raw)));
|
|
||||||
if ((c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') ||
|
|
||||||
c == ' ' || c == '-' || c == '_' || c == '.') {
|
|
||||||
clean.push_back(c);
|
|
||||||
if (clean.size() >= 12) break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
clean = trim(clean);
|
|
||||||
player_name = clean.empty() ? "PLAYER" : clean;
|
|
||||||
}
|
|
||||||
if (auto* v = get("game.language")) language = static_cast<Language>(std::clamp(parse_int(*v, 0), 0, 3));
|
if (auto* v = get("game.language")) language = static_cast<Language>(std::clamp(parse_int(*v, 0), 0, 3));
|
||||||
if (auto* v = get("game.preferred_vehicle")) preferred_vehicle = std::clamp(parse_int(*v, 0), 0, 5);
|
if (auto* v = get("game.preferred_vehicle")) preferred_vehicle = std::clamp(parse_int(*v, 0), 0, 5);
|
||||||
if (auto* v = get("game.preferred_team")) preferred_team = std::clamp(parse_int(*v, 7), 0, 7);
|
if (auto* v = get("game.preferred_team")) preferred_team = std::clamp(parse_int(*v, 7), 0, 7);
|
||||||
if (auto* v = get("game.default_laps")) default_laps = std::clamp(parse_int(*v, 3), 1, 20);
|
if (auto* v = get("game.default_laps")) default_laps = std::clamp(parse_int(*v, 3), 1, 20);
|
||||||
if (auto* v = get("game.difficulty")) difficulty = std::clamp(parse_int(*v, 1), 0, 2);
|
if (auto* v = get("game.difficulty")) difficulty = std::clamp(parse_int(*v, 1), 0, 2);
|
||||||
|
if (auto* v = get("game.deathmatch_kill_limit")) deathmatch_kill_limit = std::clamp(parse_int(*v, 5), 3, 20);
|
||||||
|
if (auto* v = get("game.default_camera")) default_camera = std::clamp(parse_int(*v, 0), 0, 2);
|
||||||
|
if (auto* v = get("game.show_hud")) show_hud = parse_bool(*v, show_hud);
|
||||||
|
if (auto* v = get("game.show_minimap")) show_minimap = parse_bool(*v, show_minimap);
|
||||||
|
if (auto* v = get("game.fuel_enabled")) fuel_enabled = parse_bool(*v, fuel_enabled);
|
||||||
|
if (auto* v = get("game.damage_enabled")) damage_enabled = parse_bool(*v, damage_enabled);
|
||||||
|
if (auto* v = get("game.weapons_enabled")) weapons_enabled = parse_bool(*v, weapons_enabled);
|
||||||
|
if (auto* v = get("game.pickups_enabled")) pickups_enabled = parse_bool(*v, pickups_enabled);
|
||||||
|
if (auto* v = get("game.track_morphing_enabled")) track_morphing_enabled = parse_bool(*v, track_morphing_enabled);
|
||||||
if (auto* v = get("game.skip_intro")) skip_intro = parse_bool(*v, skip_intro);
|
if (auto* v = get("game.skip_intro")) skip_intro = parse_bool(*v, skip_intro);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -197,11 +209,21 @@ bool GameConfig::save(const std::filesystem::path& path) const {
|
|||||||
|
|
||||||
<< "[game]\n"
|
<< "[game]\n"
|
||||||
<< "player_name=" << player_name << "\n"
|
<< "player_name=" << player_name << "\n"
|
||||||
|
<< "player2_name=" << player2_name << "\n"
|
||||||
<< "language=" << static_cast<int>(language) << "\n"
|
<< "language=" << static_cast<int>(language) << "\n"
|
||||||
<< "preferred_vehicle=" << preferred_vehicle << "\n"
|
<< "preferred_vehicle=" << preferred_vehicle << "\n"
|
||||||
<< "preferred_team=" << preferred_team << "\n"
|
<< "preferred_team=" << preferred_team << "\n"
|
||||||
<< "default_laps=" << default_laps << "\n"
|
<< "default_laps=" << default_laps << "\n"
|
||||||
<< "difficulty=" << difficulty << "\n"
|
<< "difficulty=" << difficulty << "\n"
|
||||||
|
<< "deathmatch_kill_limit=" << deathmatch_kill_limit << "\n"
|
||||||
|
<< "default_camera=" << default_camera << "\n"
|
||||||
|
<< "show_hud=" << (show_hud ? 1 : 0) << "\n"
|
||||||
|
<< "show_minimap=" << (show_minimap ? 1 : 0) << "\n"
|
||||||
|
<< "fuel_enabled=" << (fuel_enabled ? 1 : 0) << "\n"
|
||||||
|
<< "damage_enabled=" << (damage_enabled ? 1 : 0) << "\n"
|
||||||
|
<< "weapons_enabled=" << (weapons_enabled ? 1 : 0) << "\n"
|
||||||
|
<< "pickups_enabled=" << (pickups_enabled ? 1 : 0) << "\n"
|
||||||
|
<< "track_morphing_enabled=" << (track_morphing_enabled ? 1 : 0) << "\n"
|
||||||
<< "skip_intro=" << (skip_intro ? 1 : 0) << "\n";
|
<< "skip_intro=" << (skip_intro ? 1 : 0) << "\n";
|
||||||
|
|
||||||
return ofs.good();
|
return ofs.good();
|
||||||
|
|||||||
+11
-1
@@ -79,13 +79,23 @@ struct GameConfig {
|
|||||||
int p2_gamepad_index = 1;
|
int p2_gamepad_index = 1;
|
||||||
KeyBindings keys{};
|
KeyBindings keys{};
|
||||||
|
|
||||||
// Game
|
// Game & Rules
|
||||||
std::string player_name = "PLAYER";
|
std::string player_name = "PLAYER";
|
||||||
|
std::string player2_name = "PLAYER 2";
|
||||||
Language language = Language::English;
|
Language language = Language::English;
|
||||||
int preferred_vehicle = 0;
|
int preferred_vehicle = 0;
|
||||||
int preferred_team = 7; // Bullfrog
|
int preferred_team = 7; // Bullfrog
|
||||||
int default_laps = 3;
|
int default_laps = 3;
|
||||||
int difficulty = 1; // 0=Easy, 1=Medium, 2=Hard
|
int difficulty = 1; // 0=Easy, 1=Medium, 2=Hard
|
||||||
|
int deathmatch_kill_limit = 5;
|
||||||
|
int default_camera = 0; // 0=Chase, 1=Close Chase, 2=Cockpit
|
||||||
|
bool show_hud = true;
|
||||||
|
bool show_minimap = true;
|
||||||
|
bool fuel_enabled = true;
|
||||||
|
bool damage_enabled = true;
|
||||||
|
bool weapons_enabled = true;
|
||||||
|
bool pickups_enabled = true;
|
||||||
|
bool track_morphing_enabled = true;
|
||||||
bool skip_intro = false;
|
bool skip_intro = false;
|
||||||
|
|
||||||
bool load(const std::filesystem::path& path);
|
bool load(const std::filesystem::path& path);
|
||||||
|
|||||||
+352
-120
@@ -5,8 +5,10 @@
|
|||||||
#include "sim/vehicle_defs.hpp"
|
#include "sim/vehicle_defs.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <cctype>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
namespace top_octane::game {
|
namespace top_octane::game {
|
||||||
|
|
||||||
@@ -63,6 +65,12 @@ const char* lang_label(Language l) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* camera_label(int cam) {
|
||||||
|
if (cam == 1) return "CLOSE CHASE";
|
||||||
|
if (cam == 2) return "COCKPIT";
|
||||||
|
return "CHASE";
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
bool GameApp::init(const LaunchOptions& opts) {
|
bool GameApp::init(const LaunchOptions& opts) {
|
||||||
@@ -81,6 +89,35 @@ bool GameApp::init(const LaunchOptions& opts) {
|
|||||||
p1_team_ = cfg_.preferred_team;
|
p1_team_ = cfg_.preferred_team;
|
||||||
selected_laps_ = cfg_.default_laps;
|
selected_laps_ = cfg_.default_laps;
|
||||||
selected_difficulty_ = cfg_.difficulty;
|
selected_difficulty_ = cfg_.difficulty;
|
||||||
|
cam_mode_ = cfg_.default_camera;
|
||||||
|
hud_visible_ = cfg_.show_hud;
|
||||||
|
|
||||||
|
// Discover optional external SoundFont (.sf2/.sbk) files under pref_dir
|
||||||
|
available_soundfonts_.clear();
|
||||||
|
available_soundfonts_.push_back("");
|
||||||
|
auto scan_sf_dir = [&](const std::filesystem::path& dir) {
|
||||||
|
std::error_code ec;
|
||||||
|
if (!std::filesystem::exists(dir, ec) || !std::filesystem::is_directory(dir, ec)) return;
|
||||||
|
for (const auto& ent : std::filesystem::directory_iterator(dir, ec)) {
|
||||||
|
if (!ent.is_regular_file(ec)) continue;
|
||||||
|
std::string ext = ent.path().extension().string();
|
||||||
|
for (char& ch : ext) ch = static_cast<char>(std::tolower(static_cast<unsigned char>(ch)));
|
||||||
|
if (ext == ".sf2" || ext == ".sbk") {
|
||||||
|
std::string p = ent.path().string();
|
||||||
|
if (std::find(available_soundfonts_.begin(), available_soundfonts_.end(), p) ==
|
||||||
|
available_soundfonts_.end()) {
|
||||||
|
available_soundfonts_.push_back(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
scan_sf_dir(vfs_.pref_dir() / "soundfonts");
|
||||||
|
scan_sf_dir(vfs_.pref_dir());
|
||||||
|
if (!cfg_.custom_soundfont_path.empty() &&
|
||||||
|
std::find(available_soundfonts_.begin(), available_soundfonts_.end(),
|
||||||
|
cfg_.custom_soundfont_path) == available_soundfonts_.end()) {
|
||||||
|
available_soundfonts_.push_back(cfg_.custom_soundfont_path);
|
||||||
|
}
|
||||||
|
|
||||||
hiscores_.load(vfs_.pref_dir() / "hiscores.dat");
|
hiscores_.load(vfs_.pref_dir() / "hiscores.dat");
|
||||||
|
|
||||||
@@ -216,16 +253,16 @@ void GameApp::ensure_music(audio::MusicTrackId track, bool loop, bool force_rest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameApp::begin_name_edit() {
|
void GameApp::begin_name_edit(int target) {
|
||||||
editing_player_name_ = true;
|
editing_name_target_ = (target == 2) ? 2 : 1;
|
||||||
name_edit_buf_ = cfg_.player_name;
|
name_edit_buf_ = (editing_name_target_ == 2) ? cfg_.player2_name : cfg_.player_name;
|
||||||
input_.start_text_input();
|
input_.start_text_input();
|
||||||
audio_.play_sfx("SELECT.WAV", 0.38f);
|
audio_.play_sfx("SELECT.WAV", 0.38f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameApp::cancel_name_edit() {
|
void GameApp::cancel_name_edit() {
|
||||||
if (editing_player_name_) {
|
if (editing_name_target_ != 0) {
|
||||||
editing_player_name_ = false;
|
editing_name_target_ = 0;
|
||||||
input_.stop_text_input();
|
input_.stop_text_input();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -247,20 +284,22 @@ void GameApp::update_name_edit() {
|
|||||||
size_t b = name_edit_buf_.size();
|
size_t b = name_edit_buf_.size();
|
||||||
while (b > a && name_edit_buf_[b - 1] == ' ') --b;
|
while (b > a && name_edit_buf_[b - 1] == ' ') --b;
|
||||||
std::string cleaned = name_edit_buf_.substr(a, b - a);
|
std::string cleaned = name_edit_buf_.substr(a, b - a);
|
||||||
|
std::string& dst = (editing_name_target_ == 2) ? cfg_.player2_name : cfg_.player_name;
|
||||||
|
const char* fallback = (editing_name_target_ == 2) ? "PLAYER 2" : "PLAYER";
|
||||||
if (!cleaned.empty()) {
|
if (!cleaned.empty()) {
|
||||||
cfg_.player_name = cleaned;
|
dst = cleaned;
|
||||||
} else if (cfg_.player_name.empty()) {
|
} else if (dst.empty()) {
|
||||||
cfg_.player_name = "PLAYER";
|
dst = fallback;
|
||||||
}
|
}
|
||||||
if (champ_.active && !champ_.drivers.empty()) {
|
if (editing_name_target_ == 1 && champ_.active && !champ_.drivers.empty()) {
|
||||||
champ_.player_name = cfg_.player_name;
|
champ_.player_name = cfg_.player_name;
|
||||||
champ_.drivers[0].name = cfg_.player_name;
|
champ_.drivers[0].name = cfg_.player_name;
|
||||||
}
|
}
|
||||||
cfg_.save(vfs_.pref_dir() / "config.ini");
|
cfg_.save(vfs_.pref_dir() / "config.ini");
|
||||||
|
status_toast_ = std::string(editing_name_target_ == 2 ? "P2 NAME: " : "PILOT NAME: ") + dst;
|
||||||
|
status_toast_timer_ = 2.0f;
|
||||||
cancel_name_edit();
|
cancel_name_edit();
|
||||||
audio_.play_sfx("SELECT.WAV", 0.38f);
|
audio_.play_sfx("SELECT.WAV", 0.38f);
|
||||||
status_toast_ = "PILOT NAME: " + cfg_.player_name;
|
|
||||||
status_toast_timer_ = 2.0f;
|
|
||||||
} else if (input_.text_cancel_pressed()) {
|
} else if (input_.text_cancel_pressed()) {
|
||||||
cancel_name_edit();
|
cancel_name_edit();
|
||||||
audio_.play_sfx("CHANGE.WAV", 0.32f);
|
audio_.play_sfx("CHANGE.WAV", 0.32f);
|
||||||
@@ -336,14 +375,23 @@ void GameApp::start_race_session() {
|
|||||||
setup.mode = selected_mode_;
|
setup.mode = selected_mode_;
|
||||||
setup.track_number = selected_track_;
|
setup.track_number = selected_track_;
|
||||||
setup.total_laps = (selected_mode_ == sim::GameMode::Championship) ? 3 : selected_laps_;
|
setup.total_laps = (selected_mode_ == sim::GameMode::Championship) ? 3 : selected_laps_;
|
||||||
setup.difficulty = selected_difficulty_;
|
setup.difficulty = (selected_mode_ == sim::GameMode::Championship) ? champ_.difficulty : selected_difficulty_;
|
||||||
setup.num_ai = selected_opponents_;
|
setup.num_ai = selected_opponents_;
|
||||||
setup.p1_vehicle = (selected_mode_ == sim::GameMode::Championship) ? champ_.player_vehicle : p1_veh_;
|
setup.p1_vehicle = (selected_mode_ == sim::GameMode::Championship) ? champ_.player_vehicle : p1_veh_;
|
||||||
setup.p1_team = (selected_mode_ == sim::GameMode::Championship) ? champ_.player_team : p1_team_;
|
setup.p1_team = (selected_mode_ == sim::GameMode::Championship) ? champ_.player_team : p1_team_;
|
||||||
setup.p1_name = cfg_.player_name;
|
setup.p1_name = cfg_.player_name;
|
||||||
setup.p2_vehicle = p2_veh_;
|
setup.p2_vehicle = p2_veh_;
|
||||||
setup.p2_team = p2_team_;
|
setup.p2_team = p2_team_;
|
||||||
setup.p2_name = "PLAYER 2";
|
setup.p2_name = cfg_.player2_name;
|
||||||
|
setup.deathmatch_kill_limit = cfg_.deathmatch_kill_limit;
|
||||||
|
setup.fuel_enabled = cfg_.fuel_enabled;
|
||||||
|
setup.damage_enabled = cfg_.damage_enabled;
|
||||||
|
setup.weapons_enabled = cfg_.weapons_enabled;
|
||||||
|
setup.pickups_enabled = cfg_.pickups_enabled;
|
||||||
|
setup.track_morphing_enabled = cfg_.track_morphing_enabled;
|
||||||
|
|
||||||
|
cam_mode_ = cfg_.default_camera;
|
||||||
|
hud_visible_ = cfg_.show_hud;
|
||||||
|
|
||||||
sim::CloneRecording existing_clone;
|
sim::CloneRecording existing_clone;
|
||||||
const sim::CloneRecording* clone_ptr = nullptr;
|
const sim::CloneRecording* clone_ptr = nullptr;
|
||||||
@@ -438,6 +486,9 @@ void GameApp::update_racing_step(float dt) {
|
|||||||
if (p1.cycle_camera_pressed) {
|
if (p1.cycle_camera_pressed) {
|
||||||
cam_mode_ = (cam_mode_ + 1) % 3;
|
cam_mode_ = (cam_mode_ + 1) % 3;
|
||||||
}
|
}
|
||||||
|
if (p1.toggle_hud_pressed) {
|
||||||
|
hud_visible_ = !hud_visible_;
|
||||||
|
}
|
||||||
|
|
||||||
race_sim_.step(p1, p2, dt);
|
race_sim_.step(p1, p2, dt);
|
||||||
handle_sim_events();
|
handle_sim_events();
|
||||||
@@ -561,10 +612,15 @@ void GameApp::update_menu(float dt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (state_ == ScreenState::ChampionshipMenu) {
|
if (state_ == ScreenState::ChampionshipMenu) {
|
||||||
constexpr int kItems = 5;
|
constexpr int kItems = 6;
|
||||||
if (m.up) { menu_cursor_ = (menu_cursor_ + kItems - 1) % kItems; audio_.play_sfx("CHANGE.WAV", 0.32f); }
|
if (m.up) { menu_cursor_ = (menu_cursor_ + kItems - 1) % kItems; audio_.play_sfx("CHANGE.WAV", 0.32f); }
|
||||||
if (m.down) { menu_cursor_ = (menu_cursor_ + 1) % kItems; audio_.play_sfx("CHANGE.WAV", 0.32f); }
|
if (m.down) { menu_cursor_ = (menu_cursor_ + 1) % kItems; audio_.play_sfx("CHANGE.WAV", 0.32f); }
|
||||||
if (menu_cursor_ == 2 || menu_cursor_ == 3) {
|
if (menu_cursor_ == 1 && (m.left || m.right)) {
|
||||||
|
int dir = m.right ? 1 : -1;
|
||||||
|
selected_difficulty_ = (selected_difficulty_ + dir + 3) % 3;
|
||||||
|
cfg_.difficulty = selected_difficulty_;
|
||||||
|
audio_.play_sfx("CHANGE.WAV", 0.32f);
|
||||||
|
} else if (menu_cursor_ == 3 || menu_cursor_ == 4) {
|
||||||
if (m.left) { champ_slot_cursor_ = (champ_slot_cursor_ + 3) % 4; audio_.play_sfx("CHANGE.WAV", 0.32f); }
|
if (m.left) { champ_slot_cursor_ = (champ_slot_cursor_ + 3) % 4; audio_.play_sfx("CHANGE.WAV", 0.32f); }
|
||||||
if (m.right) { champ_slot_cursor_ = (champ_slot_cursor_ + 1) % 4; audio_.play_sfx("CHANGE.WAV", 0.32f); }
|
if (m.right) { champ_slot_cursor_ = (champ_slot_cursor_ + 1) % 4; audio_.play_sfx("CHANGE.WAV", 0.32f); }
|
||||||
}
|
}
|
||||||
@@ -574,24 +630,26 @@ void GameApp::update_menu(float dt) {
|
|||||||
champ_.start_new(cfg_.player_name, p1_veh_, p1_team_, selected_difficulty_);
|
champ_.start_new(cfg_.player_name, p1_veh_, p1_team_, selected_difficulty_);
|
||||||
selected_track_ = 1;
|
selected_track_ = 1;
|
||||||
enter_state(ScreenState::VehicleSelect);
|
enter_state(ScreenState::VehicleSelect);
|
||||||
} else if (menu_cursor_ == 1) {
|
} else if (menu_cursor_ == 2) {
|
||||||
if (!champ_.active || champ_.is_complete()) {
|
if (!champ_.active || champ_.is_complete()) {
|
||||||
champ_.start_new(cfg_.player_name, p1_veh_, p1_team_, selected_difficulty_);
|
champ_.start_new(cfg_.player_name, p1_veh_, p1_team_, selected_difficulty_);
|
||||||
}
|
}
|
||||||
selected_track_ = std::clamp(champ_.current_track, 1, 6);
|
selected_track_ = std::clamp(champ_.current_track, 1, 6);
|
||||||
start_race_session();
|
start_race_session();
|
||||||
} else if (menu_cursor_ == 2) {
|
} else if (menu_cursor_ == 3) {
|
||||||
if (champ_.load_slot(vfs_.pref_dir(), champ_slot_cursor_)) {
|
if (champ_.load_slot(vfs_.pref_dir(), champ_slot_cursor_)) {
|
||||||
selected_track_ = std::clamp(champ_.current_track, 1, 6);
|
selected_track_ = std::clamp(champ_.current_track, 1, 6);
|
||||||
|
selected_difficulty_ = std::clamp(champ_.difficulty, 0, 2);
|
||||||
|
cfg_.difficulty = selected_difficulty_;
|
||||||
status_toast_ = "LOADED SLOT " + std::to_string(champ_slot_cursor_ + 1);
|
status_toast_ = "LOADED SLOT " + std::to_string(champ_slot_cursor_ + 1);
|
||||||
status_toast_timer_ = 2.0f;
|
status_toast_timer_ = 2.0f;
|
||||||
}
|
}
|
||||||
} else if (menu_cursor_ == 3) {
|
} else if (menu_cursor_ == 4) {
|
||||||
if (champ_.save_slot(vfs_.pref_dir(), champ_slot_cursor_)) {
|
if (champ_.save_slot(vfs_.pref_dir(), champ_slot_cursor_)) {
|
||||||
status_toast_ = "SAVED SLOT " + std::to_string(champ_slot_cursor_ + 1);
|
status_toast_ = "SAVED SLOT " + std::to_string(champ_slot_cursor_ + 1);
|
||||||
status_toast_timer_ = 2.0f;
|
status_toast_timer_ = 2.0f;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (menu_cursor_ == 5) {
|
||||||
enter_state(ScreenState::MainMenu);
|
enter_state(ScreenState::MainMenu);
|
||||||
}
|
}
|
||||||
} else if (m.back) {
|
} else if (m.back) {
|
||||||
@@ -601,16 +659,27 @@ void GameApp::update_menu(float dt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (state_ == ScreenState::TrackSelect) {
|
if (state_ == ScreenState::TrackSelect) {
|
||||||
constexpr int kRows = 5; // Track, Laps, Difficulty, Opponents, Proceed
|
constexpr int kRows = 5; // Track, Laps/Kill Limit, Difficulty, Opponents, Proceed
|
||||||
if (m.up) { menu_cursor_ = (menu_cursor_ + kRows - 1) % kRows; audio_.play_sfx("CHANGE.WAV", 0.32f); }
|
if (m.up) { menu_cursor_ = (menu_cursor_ + kRows - 1) % kRows; audio_.play_sfx("CHANGE.WAV", 0.32f); }
|
||||||
if (m.down) { menu_cursor_ = (menu_cursor_ + 1) % kRows; audio_.play_sfx("CHANGE.WAV", 0.32f); }
|
if (m.down) { menu_cursor_ = (menu_cursor_ + 1) % kRows; audio_.play_sfx("CHANGE.WAV", 0.32f); }
|
||||||
int dir = m.right ? 1 : (m.left ? -1 : 0);
|
int dir = m.right ? 1 : (m.left ? -1 : 0);
|
||||||
if (dir != 0) {
|
if (dir != 0) {
|
||||||
audio_.play_sfx("CHANGE.WAV", 0.32f);
|
audio_.play_sfx("CHANGE.WAV", 0.32f);
|
||||||
if (menu_cursor_ == 0) selected_track_ = ((selected_track_ - 1 + dir + 6) % 6) + 1;
|
if (menu_cursor_ == 0) {
|
||||||
else if (menu_cursor_ == 1) selected_laps_ = std::clamp(selected_laps_ + dir, 1, 20);
|
selected_track_ = ((selected_track_ - 1 + dir + 6) % 6) + 1;
|
||||||
else if (menu_cursor_ == 2) selected_difficulty_ = (selected_difficulty_ + dir + 3) % 3;
|
} else if (menu_cursor_ == 1) {
|
||||||
else if (menu_cursor_ == 3) selected_opponents_ = std::clamp(selected_opponents_ + dir, 0, 7);
|
if (selected_mode_ == sim::GameMode::DeathMatch) {
|
||||||
|
cfg_.deathmatch_kill_limit = std::clamp(cfg_.deathmatch_kill_limit + dir, 3, 20);
|
||||||
|
} else {
|
||||||
|
selected_laps_ = std::clamp(selected_laps_ + dir, 1, 20);
|
||||||
|
cfg_.default_laps = selected_laps_;
|
||||||
|
}
|
||||||
|
} else if (menu_cursor_ == 2) {
|
||||||
|
selected_difficulty_ = (selected_difficulty_ + dir + 3) % 3;
|
||||||
|
cfg_.difficulty = selected_difficulty_;
|
||||||
|
} else if (menu_cursor_ == 3 && selected_mode_ != sim::GameMode::CloneRace) {
|
||||||
|
selected_opponents_ = std::clamp(selected_opponents_ + dir, 0, 7);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (m.confirm && (menu_cursor_ == 4 || menu_cursor_ == 0)) {
|
if (m.confirm && (menu_cursor_ == 4 || menu_cursor_ == 0)) {
|
||||||
audio_.play_sfx("SELECT.WAV", 0.38f);
|
audio_.play_sfx("SELECT.WAV", 0.38f);
|
||||||
@@ -622,11 +691,12 @@ void GameApp::update_menu(float dt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (state_ == ScreenState::VehicleSelect) {
|
if (state_ == ScreenState::VehicleSelect) {
|
||||||
if (editing_player_name_) {
|
if (editing_name_target_ != 0) {
|
||||||
update_name_edit();
|
update_name_edit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int max_rows = (selected_mode_ == sim::GameMode::SplitScreen) ? 6 : 4;
|
bool is_split = (selected_mode_ == sim::GameMode::SplitScreen);
|
||||||
|
int max_rows = is_split ? 7 : 4;
|
||||||
if (m.up) { menu_cursor_ = (menu_cursor_ + max_rows - 1) % max_rows; audio_.play_sfx("CHANGE.WAV", 0.32f); }
|
if (m.up) { menu_cursor_ = (menu_cursor_ + max_rows - 1) % max_rows; audio_.play_sfx("CHANGE.WAV", 0.32f); }
|
||||||
if (m.down) { menu_cursor_ = (menu_cursor_ + 1) % max_rows; audio_.play_sfx("CHANGE.WAV", 0.32f); }
|
if (m.down) { menu_cursor_ = (menu_cursor_ + 1) % max_rows; audio_.play_sfx("CHANGE.WAV", 0.32f); }
|
||||||
int dir = m.right ? 1 : (m.left ? -1 : 0);
|
int dir = m.right ? 1 : (m.left ? -1 : 0);
|
||||||
@@ -634,11 +704,13 @@ void GameApp::update_menu(float dt) {
|
|||||||
audio_.play_sfx("CHANGE.WAV", 0.32f);
|
audio_.play_sfx("CHANGE.WAV", 0.32f);
|
||||||
if (menu_cursor_ == 1) p1_veh_ = (p1_veh_ + dir + 6) % 6;
|
if (menu_cursor_ == 1) p1_veh_ = (p1_veh_ + dir + 6) % 6;
|
||||||
else if (menu_cursor_ == 2) p1_team_ = (p1_team_ + dir + 8) % 8;
|
else if (menu_cursor_ == 2) p1_team_ = (p1_team_ + dir + 8) % 8;
|
||||||
else if (selected_mode_ == sim::GameMode::SplitScreen && menu_cursor_ == 3) p2_veh_ = (p2_veh_ + dir + 6) % 6;
|
else if (is_split && menu_cursor_ == 4) p2_veh_ = (p2_veh_ + dir + 6) % 6;
|
||||||
else if (selected_mode_ == sim::GameMode::SplitScreen && menu_cursor_ == 4) p2_team_ = (p2_team_ + dir + 8) % 8;
|
else if (is_split && menu_cursor_ == 5) p2_team_ = (p2_team_ + dir + 8) % 8;
|
||||||
}
|
}
|
||||||
if (menu_cursor_ == 0 && m.confirm) {
|
if (menu_cursor_ == 0 && m.confirm) {
|
||||||
begin_name_edit();
|
begin_name_edit(1);
|
||||||
|
} else if (is_split && menu_cursor_ == 3 && m.confirm) {
|
||||||
|
begin_name_edit(2);
|
||||||
} else if (m.confirm && (menu_cursor_ == max_rows - 1 || menu_cursor_ == 1)) {
|
} else if (m.confirm && (menu_cursor_ == max_rows - 1 || menu_cursor_ == 1)) {
|
||||||
audio_.play_sfx("SELECT.WAV", 0.38f);
|
audio_.play_sfx("SELECT.WAV", 0.38f);
|
||||||
if (selected_mode_ == sim::GameMode::Championship) {
|
if (selected_mode_ == sim::GameMode::Championship) {
|
||||||
@@ -672,19 +744,23 @@ void GameApp::update_menu(float dt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (state_ == ScreenState::Options) {
|
if (state_ == ScreenState::Options) {
|
||||||
if (editing_player_name_) {
|
if (editing_name_target_ != 0) {
|
||||||
update_name_edit();
|
update_name_edit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (rebind_slot_ >= 0) {
|
if (rebind_slot_ >= 0) {
|
||||||
int new_sc = 0;
|
int new_sc = 0;
|
||||||
if (input_.consume_rebound_scancode(new_sc)) {
|
if (input_.consume_rebound_scancode(new_sc)) {
|
||||||
int* targets[9] = {
|
int* targets[17] = {
|
||||||
&cfg_.keys.steer_left, &cfg_.keys.steer_right, &cfg_.keys.accelerate,
|
&cfg_.keys.steer_left, &cfg_.keys.steer_right, &cfg_.keys.accelerate,
|
||||||
&cfg_.keys.brake, &cfg_.keys.boost, &cfg_.keys.fire_minigun,
|
&cfg_.keys.brake, &cfg_.keys.boost, &cfg_.keys.fire_minigun,
|
||||||
&cfg_.keys.fire_missile, &cfg_.keys.autopilot, &cfg_.keys.camera_view
|
&cfg_.keys.fire_missile, &cfg_.keys.autopilot, &cfg_.keys.camera_view,
|
||||||
|
&cfg_.keys.hud_toggle,
|
||||||
|
&cfg_.keys.p2_steer_left, &cfg_.keys.p2_steer_right, &cfg_.keys.p2_accelerate,
|
||||||
|
&cfg_.keys.p2_brake, &cfg_.keys.p2_boost, &cfg_.keys.p2_fire_minigun,
|
||||||
|
&cfg_.keys.p2_fire_missile
|
||||||
};
|
};
|
||||||
if (rebind_slot_ < 9) *targets[rebind_slot_] = new_sc;
|
if (rebind_slot_ < 17) *targets[rebind_slot_] = new_sc;
|
||||||
rebind_slot_ = -1;
|
rebind_slot_ = -1;
|
||||||
audio_.play_sfx("SELECT.WAV", 0.38f);
|
audio_.play_sfx("SELECT.WAV", 0.38f);
|
||||||
cfg_.save(vfs_.pref_dir() / "config.ini");
|
cfg_.save(vfs_.pref_dir() / "config.ini");
|
||||||
@@ -694,15 +770,15 @@ void GameApp::update_menu(float dt) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tab switching with Left/Right on row 0
|
constexpr int kNumTabs = 7;
|
||||||
int row_counts[4] = {7, 5, 13, 5};
|
const int row_counts[kNumTabs] = {10, 7, 11, 8, 8, 8, 9};
|
||||||
int rows = row_counts[static_cast<int>(opt_tab_)];
|
int rows = row_counts[static_cast<int>(opt_tab_)];
|
||||||
if (m.up) { menu_cursor_ = (menu_cursor_ + rows - 1) % rows; audio_.play_sfx("CHANGE.WAV", 0.32f); }
|
if (m.up) { menu_cursor_ = (menu_cursor_ + rows - 1) % rows; audio_.play_sfx("CHANGE.WAV", 0.32f); }
|
||||||
if (m.down) { menu_cursor_ = (menu_cursor_ + 1) % rows; audio_.play_sfx("CHANGE.WAV", 0.32f); }
|
if (m.down) { menu_cursor_ = (menu_cursor_ + 1) % rows; audio_.play_sfx("CHANGE.WAV", 0.32f); }
|
||||||
|
|
||||||
int dir = m.right ? 1 : (m.left ? -1 : 0);
|
int dir = m.right ? 1 : (m.left ? -1 : 0);
|
||||||
if (menu_cursor_ == 0 && dir != 0) {
|
if (menu_cursor_ == 0 && dir != 0) {
|
||||||
opt_tab_ = static_cast<OptionsTab>((static_cast<int>(opt_tab_) + dir + 4) % 4);
|
opt_tab_ = static_cast<OptionsTab>((static_cast<int>(opt_tab_) + dir + kNumTabs) % kNumTabs);
|
||||||
audio_.play_sfx("CHANGE.WAV", 0.32f);
|
audio_.play_sfx("CHANGE.WAV", 0.32f);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -725,16 +801,30 @@ void GameApp::update_menu(float dt) {
|
|||||||
} else if (menu_cursor_ == 3) {
|
} else if (menu_cursor_ == 3) {
|
||||||
cfg_.vsync = !cfg_.vsync;
|
cfg_.vsync = !cfg_.vsync;
|
||||||
apply_video_settings();
|
apply_video_settings();
|
||||||
} else if (menu_cursor_ == 4 && dir != 0) {
|
} else if (menu_cursor_ == 4) {
|
||||||
|
static constexpr int kMsaa[4] = {0, 2, 4, 8};
|
||||||
|
int cur = 2;
|
||||||
|
for (int i = 0; i < 4; ++i) {
|
||||||
|
if (cfg_.msaa_samples == kMsaa[i]) cur = i;
|
||||||
|
}
|
||||||
|
cur = (cur + (dir != 0 ? dir : 1) + 4) % 4;
|
||||||
|
cfg_.msaa_samples = kMsaa[cur];
|
||||||
|
status_toast_ = "MSAA APPLIES ON NEXT LAUNCH";
|
||||||
|
status_toast_timer_ = 2.0f;
|
||||||
|
} else if (menu_cursor_ == 5 && dir != 0) {
|
||||||
|
cfg_.fov_deg = std::clamp(cfg_.fov_deg + dir * 5.0f, 50.0f, 105.0f);
|
||||||
|
} else if (menu_cursor_ == 6 && dir != 0) {
|
||||||
cfg_.draw_distance = std::clamp(cfg_.draw_distance + dir * 10.0f, 30.0f, 150.0f);
|
cfg_.draw_distance = std::clamp(cfg_.draw_distance + dir * 10.0f, 30.0f, 150.0f);
|
||||||
} else if (menu_cursor_ == 5) {
|
} else if (menu_cursor_ == 7) {
|
||||||
cfg_.texture_filter = (cfg_.texture_filter == TextureFilterMode::Linear)
|
cfg_.texture_filter = (cfg_.texture_filter == TextureFilterMode::Linear)
|
||||||
? TextureFilterMode::Nearest
|
? TextureFilterMode::Nearest
|
||||||
: TextureFilterMode::Linear;
|
: TextureFilterMode::Linear;
|
||||||
} else if (menu_cursor_ == 6) {
|
} else if (menu_cursor_ == 8) {
|
||||||
if (!cfg_.classic_mode) { cfg_.classic_mode = true; cfg_.classic_hires = false; }
|
if (!cfg_.classic_mode) { cfg_.classic_mode = true; cfg_.classic_hires = false; }
|
||||||
else if (!cfg_.classic_hires) { cfg_.classic_hires = true; }
|
else if (!cfg_.classic_hires) { cfg_.classic_hires = true; }
|
||||||
else { cfg_.classic_mode = false; }
|
else { cfg_.classic_mode = false; }
|
||||||
|
} else if (menu_cursor_ == 9) {
|
||||||
|
cfg_.classic_scanlines = !cfg_.classic_scanlines;
|
||||||
}
|
}
|
||||||
} else if (opt_tab_ == OptionsTab::Audio && (dir != 0 || m.confirm)) {
|
} else if (opt_tab_ == OptionsTab::Audio && (dir != 0 || m.confirm)) {
|
||||||
audio_.play_sfx("CHANGE.WAV", 0.32f);
|
audio_.play_sfx("CHANGE.WAV", 0.32f);
|
||||||
@@ -747,35 +837,95 @@ void GameApp::update_menu(float dt) {
|
|||||||
cfg_.sfx_volume = std::clamp(cfg_.sfx_volume + dir * 0.1f, 0.0f, 1.0f);
|
cfg_.sfx_volume = std::clamp(cfg_.sfx_volume + dir * 0.1f, 0.0f, 1.0f);
|
||||||
} else if (menu_cursor_ == 4 && dir != 0) {
|
} else if (menu_cursor_ == 4 && dir != 0) {
|
||||||
cfg_.music_volume = std::clamp(cfg_.music_volume + dir * 0.1f, 0.0f, 1.0f);
|
cfg_.music_volume = std::clamp(cfg_.music_volume + dir * 0.1f, 0.0f, 1.0f);
|
||||||
|
} else if (menu_cursor_ == 5) {
|
||||||
|
cfg_.mute_on_focus_loss = !cfg_.mute_on_focus_loss;
|
||||||
|
} else if (menu_cursor_ == 6 && available_soundfonts_.size() > 1) {
|
||||||
|
auto it = std::find(available_soundfonts_.begin(), available_soundfonts_.end(),
|
||||||
|
cfg_.custom_soundfont_path);
|
||||||
|
int idx = (it == available_soundfonts_.end())
|
||||||
|
? 0
|
||||||
|
: static_cast<int>(it - available_soundfonts_.begin());
|
||||||
|
int n = static_cast<int>(available_soundfonts_.size());
|
||||||
|
idx = (idx + (dir != 0 ? dir : 1) + n) % n;
|
||||||
|
cfg_.custom_soundfont_path = available_soundfonts_[idx];
|
||||||
}
|
}
|
||||||
audio_.apply_config(cfg_, window_focused_);
|
audio_.apply_config(cfg_, window_focused_);
|
||||||
} else if (opt_tab_ == OptionsTab::Controls) {
|
} else if (opt_tab_ == OptionsTab::ControlsP1) {
|
||||||
if (menu_cursor_ >= 1 && menu_cursor_ <= 9 && m.confirm) {
|
if (menu_cursor_ >= 1 && menu_cursor_ <= 10 && m.confirm) {
|
||||||
rebind_slot_ = menu_cursor_ - 1;
|
rebind_slot_ = menu_cursor_ - 1;
|
||||||
input_.start_rebind();
|
input_.start_rebind();
|
||||||
audio_.play_sfx("SELECT.WAV", 0.38f);
|
audio_.play_sfx("SELECT.WAV", 0.38f);
|
||||||
} else if (menu_cursor_ == 10 && dir != 0) {
|
}
|
||||||
|
} else if (opt_tab_ == OptionsTab::ControlsP2) {
|
||||||
|
if (menu_cursor_ >= 1 && menu_cursor_ <= 7 && m.confirm) {
|
||||||
|
rebind_slot_ = 10 + (menu_cursor_ - 1);
|
||||||
|
input_.start_rebind();
|
||||||
|
audio_.play_sfx("SELECT.WAV", 0.38f);
|
||||||
|
}
|
||||||
|
} else if (opt_tab_ == OptionsTab::InputPad && (dir != 0 || m.confirm)) {
|
||||||
|
audio_.play_sfx("CHANGE.WAV", 0.32f);
|
||||||
|
if (menu_cursor_ == 1) {
|
||||||
|
int step = (dir != 0) ? dir : 1;
|
||||||
|
cfg_.p1_gamepad_index = ((cfg_.p1_gamepad_index + 1 + step + 5) % 5) - 1;
|
||||||
|
} else if (menu_cursor_ == 2) {
|
||||||
|
int step = (dir != 0) ? dir : 1;
|
||||||
|
cfg_.p2_gamepad_index = ((cfg_.p2_gamepad_index + 1 + step + 5) % 5) - 1;
|
||||||
|
} else if (menu_cursor_ == 3 && dir != 0) {
|
||||||
cfg_.gamepad_deadzone = std::clamp(cfg_.gamepad_deadzone + dir * 0.02f, 0.0f, 0.4f);
|
cfg_.gamepad_deadzone = std::clamp(cfg_.gamepad_deadzone + dir * 0.02f, 0.0f, 0.4f);
|
||||||
} else if (menu_cursor_ == 11 && (dir != 0 || m.confirm)) {
|
} else if (menu_cursor_ == 4 && dir != 0) {
|
||||||
|
cfg_.steering_sensitivity = std::clamp(cfg_.steering_sensitivity + dir * 0.1f, 0.25f, 3.0f);
|
||||||
|
} else if (menu_cursor_ == 5 && dir != 0) {
|
||||||
|
cfg_.steering_curve = std::clamp(cfg_.steering_curve + dir * 0.1f, 0.5f, 3.0f);
|
||||||
|
} else if (menu_cursor_ == 6) {
|
||||||
cfg_.rumble_enabled = !cfg_.rumble_enabled;
|
cfg_.rumble_enabled = !cfg_.rumble_enabled;
|
||||||
} else if (menu_cursor_ == 12 && (dir != 0 || m.confirm)) {
|
} else if (menu_cursor_ == 7) {
|
||||||
cfg_.mouse_steering = !cfg_.mouse_steering;
|
cfg_.mouse_steering = !cfg_.mouse_steering;
|
||||||
}
|
}
|
||||||
} else if (opt_tab_ == OptionsTab::Game) {
|
} else if (opt_tab_ == OptionsTab::Game) {
|
||||||
if (menu_cursor_ == 1 && m.confirm) {
|
if (menu_cursor_ == 1 && m.confirm) {
|
||||||
begin_name_edit();
|
begin_name_edit(1);
|
||||||
|
return;
|
||||||
|
} else if (menu_cursor_ == 2 && m.confirm) {
|
||||||
|
begin_name_edit(2);
|
||||||
return;
|
return;
|
||||||
} else if (dir != 0 || m.confirm) {
|
} else if (dir != 0 || m.confirm) {
|
||||||
audio_.play_sfx("CHANGE.WAV", 0.32f);
|
audio_.play_sfx("CHANGE.WAV", 0.32f);
|
||||||
if (menu_cursor_ == 2) {
|
if (menu_cursor_ == 3) {
|
||||||
int l = (static_cast<int>(cfg_.language) + (dir != 0 ? dir : 1) + 4) % 4;
|
int l = (static_cast<int>(cfg_.language) + (dir != 0 ? dir : 1) + 4) % 4;
|
||||||
cfg_.language = static_cast<Language>(l);
|
cfg_.language = static_cast<Language>(l);
|
||||||
} else if (menu_cursor_ == 3) {
|
|
||||||
cfg_.skip_intro = !cfg_.skip_intro;
|
|
||||||
} else if (menu_cursor_ == 4) {
|
} else if (menu_cursor_ == 4) {
|
||||||
cfg_.classic_scanlines = !cfg_.classic_scanlines;
|
cfg_.default_camera = (cfg_.default_camera + (dir != 0 ? dir : 1) + 3) % 3;
|
||||||
|
cam_mode_ = cfg_.default_camera;
|
||||||
|
} else if (menu_cursor_ == 5) {
|
||||||
|
cfg_.show_hud = !cfg_.show_hud;
|
||||||
|
hud_visible_ = cfg_.show_hud;
|
||||||
|
} else if (menu_cursor_ == 6) {
|
||||||
|
cfg_.show_minimap = !cfg_.show_minimap;
|
||||||
|
} else if (menu_cursor_ == 7) {
|
||||||
|
cfg_.skip_intro = !cfg_.skip_intro;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (opt_tab_ == OptionsTab::Rules && (dir != 0 || m.confirm)) {
|
||||||
|
audio_.play_sfx("CHANGE.WAV", 0.32f);
|
||||||
|
if (menu_cursor_ == 1) {
|
||||||
|
cfg_.difficulty = (cfg_.difficulty + (dir != 0 ? dir : 1) + 3) % 3;
|
||||||
|
selected_difficulty_ = cfg_.difficulty;
|
||||||
|
} else if (menu_cursor_ == 2 && dir != 0) {
|
||||||
|
cfg_.default_laps = std::clamp(cfg_.default_laps + dir, 1, 20);
|
||||||
|
selected_laps_ = cfg_.default_laps;
|
||||||
|
} else if (menu_cursor_ == 3 && dir != 0) {
|
||||||
|
cfg_.deathmatch_kill_limit = std::clamp(cfg_.deathmatch_kill_limit + dir, 3, 20);
|
||||||
|
} else if (menu_cursor_ == 4) {
|
||||||
|
cfg_.fuel_enabled = !cfg_.fuel_enabled;
|
||||||
|
} else if (menu_cursor_ == 5) {
|
||||||
|
cfg_.damage_enabled = !cfg_.damage_enabled;
|
||||||
|
} else if (menu_cursor_ == 6) {
|
||||||
|
cfg_.weapons_enabled = !cfg_.weapons_enabled;
|
||||||
|
} else if (menu_cursor_ == 7) {
|
||||||
|
cfg_.pickups_enabled = !cfg_.pickups_enabled;
|
||||||
|
} else if (menu_cursor_ == 8) {
|
||||||
|
cfg_.track_morphing_enabled = !cfg_.track_morphing_enabled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m.back) {
|
if (m.back) {
|
||||||
@@ -1001,8 +1151,19 @@ void GameApp::render_frame(float alpha) {
|
|||||||
int vh = (split_count == 2) ? (win_h_ / 2) : win_h_;
|
int vh = (split_count == 2) ? (win_h_ / 2) : win_h_;
|
||||||
int vy = (split_count == 2 && vp == 0) ? 0 : (split_count == 2 ? vh : 0);
|
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 gl_vy = (split_count == 2 && vp == 0) ? (win_h_ - vh) : 0;
|
||||||
// Draw HUD inside screen coordinates [0..win_w_] x [vy..vy+vh]
|
if (hud_visible_) {
|
||||||
render_hud_viewport(race_sim_.crafts()[vp], cams[vp], 0, gl_vy, win_w_, vh, vp == 0);
|
// 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,
|
||||||
|
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);
|
||||||
|
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);
|
||||||
|
}
|
||||||
if (split_count == 2 && vp == 0) {
|
if (split_count == 2 && vp == 0) {
|
||||||
ui_ren_.draw_rect(0, static_cast<float>(vh - 2), static_cast<float>(win_w_), 4.0f,
|
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));
|
Vec4(0.1f, 0.1f, 0.15f, 1.0f));
|
||||||
@@ -1032,8 +1193,8 @@ void GameApp::render_frame(float alpha) {
|
|||||||
int pv_h = win_h_ * 46 / 100;
|
int pv_h = win_h_ * 46 / 100;
|
||||||
int pv_x = win_w_ * 52 / 100;
|
int pv_x = win_w_ * 52 / 100;
|
||||||
int pv_y = win_h_ * 26 / 100;
|
int pv_y = win_h_ * 26 / 100;
|
||||||
int veh = (selected_mode_ == sim::GameMode::SplitScreen && menu_cursor_ >= 3 && menu_cursor_ <= 4) ? p2_veh_ : p1_veh_;
|
int veh = (selected_mode_ == sim::GameMode::SplitScreen && menu_cursor_ >= 3 && menu_cursor_ <= 5) ? p2_veh_ : p1_veh_;
|
||||||
int team = (selected_mode_ == sim::GameMode::SplitScreen && menu_cursor_ >= 3 && menu_cursor_ <= 4) ? p2_team_ : p1_team_;
|
int team = (selected_mode_ == sim::GameMode::SplitScreen && menu_cursor_ >= 3 && menu_cursor_ <= 5) ? p2_team_ : p1_team_;
|
||||||
float pv_scale = sim::kVehicleSpecs[std::clamp(veh, 0, 5)].visual_scale * 1.45f;
|
float pv_scale = sim::kVehicleSpecs[std::clamp(veh, 0, 5)].visual_scale * 1.45f;
|
||||||
world_ren_.render_model_preview(sim::model_key_for(veh, team),
|
world_ren_.render_model_preview(sim::model_key_for(veh, team),
|
||||||
static_cast<float>(ui_time_) * 0.9f,
|
static_cast<float>(ui_time_) * 0.9f,
|
||||||
@@ -1258,8 +1419,9 @@ void GameApp::render_menus() {
|
|||||||
ui_ren_.draw_text_centered(cx, 78.0f, 2.4f, str.championship, Vec4(0.4f, 0.85f, 1, 1));
|
ui_ren_.draw_text_centered(cx, 78.0f, 2.4f, str.championship, Vec4(0.4f, 0.85f, 1, 1));
|
||||||
ui_ren_.draw_text_centered(cx, 114.0f, 1.75f, "PILOT: " + cfg_.player_name,
|
ui_ren_.draw_text_centered(cx, 114.0f, 1.75f, "PILOT: " + cfg_.player_name,
|
||||||
Vec4(0.45f, 0.95f, 0.65f, 1.0f));
|
Vec4(0.45f, 0.95f, 0.65f, 1.0f));
|
||||||
std::string items[5] = {
|
std::string items[6] = {
|
||||||
"NEW CHAMPIONSHIP",
|
"NEW CHAMPIONSHIP",
|
||||||
|
std::string(str.difficulty) + ": < " + diff_label(selected_difficulty_) + " >",
|
||||||
champ_.active && !champ_.is_complete()
|
champ_.active && !champ_.is_complete()
|
||||||
? ("CONTINUE CHAMPIONSHIP (TRACK " + std::to_string(champ_.current_track) + "/6)")
|
? ("CONTINUE CHAMPIONSHIP (TRACK " + std::to_string(champ_.current_track) + "/6)")
|
||||||
: "CONTINUE CHAMPIONSHIP (NONE)",
|
: "CONTINUE CHAMPIONSHIP (NONE)",
|
||||||
@@ -1268,14 +1430,14 @@ void GameApp::render_menus() {
|
|||||||
"SAVE SLOT " + std::to_string(champ_slot_cursor_ + 1),
|
"SAVE SLOT " + std::to_string(champ_slot_cursor_ + 1),
|
||||||
"BACK TO MAIN MENU"
|
"BACK TO MAIN MENU"
|
||||||
};
|
};
|
||||||
for (int i = 0; i < 5; ++i) {
|
for (int i = 0; i < 6; ++i) {
|
||||||
bool sel = (i == menu_cursor_);
|
bool sel = (i == menu_cursor_);
|
||||||
ui_ren_.draw_text_centered_fit(cx, 170.0f + i * 48.0f, static_cast<float>(win_w_) - 80.0f,
|
ui_ren_.draw_text_centered_fit(cx, 165.0f + i * 44.0f, static_cast<float>(win_w_) - 80.0f,
|
||||||
2.15f, items[i],
|
2.1f, items[i],
|
||||||
sel ? Vec4(1, 0.9f, 0.2f, 1) : Vec4(0.85f, 0.9f, 1, 1));
|
sel ? Vec4(1, 0.9f, 0.2f, 1) : Vec4(0.85f, 0.9f, 1, 1));
|
||||||
}
|
}
|
||||||
if (status_toast_timer_ > 0.0f) {
|
if (status_toast_timer_ > 0.0f) {
|
||||||
ui_ren_.draw_text_centered(cx, 450, 2.0f, status_toast_, Vec4(0.3f, 1.0f, 0.5f, 1));
|
ui_ren_.draw_text_centered(cx, 465, 2.0f, status_toast_, Vec4(0.3f, 1.0f, 0.5f, 1));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1308,11 +1470,17 @@ void GameApp::render_menus() {
|
|||||||
"1. AMAZON DELTA TURNPIKE", "2. TRANS-ASIA INTERSTATE", "3. SHANGHAI DRAGON",
|
"1. AMAZON DELTA TURNPIKE", "2. TRANS-ASIA INTERSTATE", "3. SHANGHAI DRAGON",
|
||||||
"4. NEW CHERNOBYL CENTRAL", "5. SLAM CANYON", "6. THRAK CITY"
|
"4. NEW CHERNOBYL CENTRAL", "5. SLAM CANYON", "6. THRAK CITY"
|
||||||
};
|
};
|
||||||
|
std::string row1 = (selected_mode_ == sim::GameMode::DeathMatch)
|
||||||
|
? ("KILL LIMIT: < " + std::to_string(cfg_.deathmatch_kill_limit) + " >")
|
||||||
|
: (std::string(str.laps) + ": < " + std::to_string(selected_laps_) + " >");
|
||||||
|
std::string row3 = (selected_mode_ == sim::GameMode::CloneRace)
|
||||||
|
? (std::string(str.opponents) + ": CLONE GHOST")
|
||||||
|
: (std::string(str.opponents) + ": < " + std::to_string(selected_opponents_) + " >");
|
||||||
std::string rows[5] = {
|
std::string rows[5] = {
|
||||||
std::string("TRACK: ") + tnames[selected_track_ - 1],
|
std::string("TRACK: ") + tnames[selected_track_ - 1],
|
||||||
std::string(str.laps) + ": " + std::to_string(selected_laps_),
|
row1,
|
||||||
std::string(str.difficulty) + ": " + diff_label(selected_difficulty_),
|
std::string(str.difficulty) + ": < " + diff_label(selected_difficulty_) + " >",
|
||||||
std::string(str.opponents) + ": " + std::to_string(selected_opponents_),
|
row3,
|
||||||
"NEXT: SELECT VEHICLE >>"
|
"NEXT: SELECT VEHICLE >>"
|
||||||
};
|
};
|
||||||
for (int i = 0; i < 5; ++i) {
|
for (int i = 0; i < 5; ++i) {
|
||||||
@@ -1334,54 +1502,61 @@ void GameApp::render_menus() {
|
|||||||
ui_ren_.draw_text_centered(cx, 82.0f, 2.5f, str.select_car, Vec4(0.4f, 0.85f, 1, 1));
|
ui_ren_.draw_text_centered(cx, 82.0f, 2.5f, str.select_car, Vec4(0.4f, 0.85f, 1, 1));
|
||||||
const float left_x = std::max(36.0f, cx - 480.0f);
|
const float left_x = std::max(36.0f, cx - 480.0f);
|
||||||
const float max_w = std::max(220.0f, static_cast<float>(win_w_) * 0.50f - left_x - 16.0f);
|
const float max_w = std::max(220.0f, static_cast<float>(win_w_) * 0.50f - left_x - 16.0f);
|
||||||
|
bool is_split = (selected_mode_ == sim::GameMode::SplitScreen);
|
||||||
|
|
||||||
if (editing_player_name_) {
|
auto draw_pilot_row = [&](float ry, const char* prefix, const std::string& cur_val,
|
||||||
ui_ren_.draw_rect(left_x - 6.0f, 142.0f, max_w + 12.0f, 30.0f, Vec4(0.16f, 0.34f, 0.68f, 0.85f));
|
int target_id, bool sel) {
|
||||||
ui_ren_.draw_rect_outline(left_x - 6.0f, 142.0f, max_w + 12.0f, 30.0f, 2.0f,
|
if (editing_name_target_ == target_id) {
|
||||||
Vec4(1.0f, 0.88f, 0.2f, 1.0f));
|
ui_ren_.draw_rect(left_x - 6.0f, ry - 6.0f, max_w + 12.0f, 28.0f, Vec4(0.16f, 0.34f, 0.68f, 0.85f));
|
||||||
ui_ren_.draw_text_fit(left_x, 148.0f, max_w, 1.85f, "PILOT NAME: " + edit_display,
|
ui_ren_.draw_rect_outline(left_x - 6.0f, ry - 6.0f, max_w + 12.0f, 28.0f, 2.0f,
|
||||||
Vec4(1.0f, 0.96f, 0.3f, 1.0f));
|
Vec4(1.0f, 0.88f, 0.2f, 1.0f));
|
||||||
} else {
|
ui_ren_.draw_text_fit(left_x, ry, max_w, 1.8f, std::string(prefix) + edit_display,
|
||||||
std::string pline = "PILOT NAME: " + cfg_.player_name + (menu_cursor_ == 0 ? " [ENTER EDIT]" : "");
|
Vec4(1.0f, 0.96f, 0.3f, 1.0f));
|
||||||
ui_ren_.draw_text_fit(left_x, 148.0f, max_w, 1.85f, pline,
|
} else {
|
||||||
menu_cursor_ == 0 ? Vec4(1, 0.92f, 0.2f, 1) : Vec4(0.45f, 0.95f, 0.65f, 1));
|
std::string pline = std::string(prefix) + cur_val + (sel ? " [ENTER EDIT]" : "");
|
||||||
}
|
ui_ren_.draw_text_fit(left_x, ry, max_w, 1.8f, pline,
|
||||||
|
sel ? Vec4(1, 0.92f, 0.2f, 1) : Vec4(0.45f, 0.95f, 0.65f, 1));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
draw_pilot_row(142.0f, is_split ? "P1 NAME: " : "PILOT NAME: ", cfg_.player_name, 1, menu_cursor_ == 0);
|
||||||
|
|
||||||
const auto& sp = sim::kVehicleSpecs[p1_veh_];
|
const auto& sp = sim::kVehicleSpecs[p1_veh_];
|
||||||
ui_ren_.draw_text_fit(left_x, 190.0f, max_w, 2.0f,
|
ui_ren_.draw_text_fit(left_x, 180.0f, max_w, 1.95f,
|
||||||
std::string("P1 VEHICLE: < ") + sp.name + " >",
|
std::string("P1 VEHICLE: < ") + sp.name + " >",
|
||||||
menu_cursor_ == 1 ? Vec4(1, 0.92f, 0.2f, 1) : Vec4(0.85f, 0.9f, 1, 1));
|
menu_cursor_ == 1 ? Vec4(1, 0.92f, 0.2f, 1) : Vec4(0.85f, 0.9f, 1, 1));
|
||||||
ui_ren_.draw_text_fit(left_x, 228.0f, max_w, 1.9f,
|
ui_ren_.draw_text_fit(left_x, 214.0f, max_w, 1.85f,
|
||||||
std::string("P1 TEAM: < ") + sim::kTeamNames[p1_team_] + " >",
|
std::string("P1 TEAM: < ") + sim::kTeamNames[p1_team_] + " >",
|
||||||
menu_cursor_ == 2 ? Vec4(1, 0.92f, 0.2f, 1) : Vec4(0.85f, 0.9f, 1, 1));
|
menu_cursor_ == 2 ? Vec4(1, 0.92f, 0.2f, 1) : Vec4(0.85f, 0.9f, 1, 1));
|
||||||
|
|
||||||
auto draw_stat = [&](float y, const char* lbl, int val) {
|
auto draw_stat = [&](float y, const char* lbl, int val) {
|
||||||
ui_ren_.draw_text_fit(left_x, y, 180.0f, 1.7f, lbl, Vec4(0.8f, 0.9f, 1, 1));
|
ui_ren_.draw_text_fit(left_x, y, 180.0f, 1.65f, lbl, Vec4(0.8f, 0.9f, 1, 1));
|
||||||
for (int b = 0; b < 10; ++b) {
|
for (int b = 0; b < 10; ++b) {
|
||||||
Vec4 col = (b < val) ? Vec4(0.25f, 0.9f, 1.0f, 1.0f) : Vec4(0.15f, 0.2f, 0.3f, 0.8f);
|
Vec4 col = (b < val) ? Vec4(0.25f, 0.9f, 1.0f, 1.0f) : Vec4(0.15f, 0.2f, 0.3f, 0.8f);
|
||||||
ui_ren_.draw_rect(left_x + 190.0f + b * 22.0f, y, 18.0f, 14.0f, col);
|
ui_ren_.draw_rect(left_x + 190.0f + b * 22.0f, y, 18.0f, 13.0f, col);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
draw_stat(274, str.weight, sp.stat_weight);
|
draw_stat(254, str.weight, sp.stat_weight);
|
||||||
draw_stat(302, str.armour, sp.stat_armour);
|
draw_stat(278, str.armour, sp.stat_armour);
|
||||||
draw_stat(330, str.speed, sp.stat_speed);
|
draw_stat(302, str.speed, sp.stat_speed);
|
||||||
draw_stat(358, str.firepower, sp.stat_firepower);
|
draw_stat(326, str.firepower, sp.stat_firepower);
|
||||||
|
|
||||||
int start_row = 3;
|
int start_row = 3;
|
||||||
if (selected_mode_ == sim::GameMode::SplitScreen) {
|
if (is_split) {
|
||||||
const auto& sp2 = sim::kVehicleSpecs[p2_veh_];
|
const auto& sp2 = sim::kVehicleSpecs[p2_veh_];
|
||||||
ui_ren_.draw_text_fit(left_x, 398.0f, max_w, 1.9f,
|
draw_pilot_row(364.0f, "P2 NAME: ", cfg_.player2_name, 2, menu_cursor_ == 3);
|
||||||
|
ui_ren_.draw_text_fit(left_x, 398.0f, max_w, 1.85f,
|
||||||
std::string("P2 VEHICLE: < ") + sp2.name + " >",
|
std::string("P2 VEHICLE: < ") + sp2.name + " >",
|
||||||
menu_cursor_ == 3 ? Vec4(1, 0.92f, 0.2f, 1) : Vec4(0.85f, 0.9f, 1, 1));
|
|
||||||
ui_ren_.draw_text_fit(left_x, 434.0f, max_w, 1.9f,
|
|
||||||
std::string("P2 TEAM: < ") + sim::kTeamNames[p2_team_] + " >",
|
|
||||||
menu_cursor_ == 4 ? Vec4(1, 0.92f, 0.2f, 1) : Vec4(0.85f, 0.9f, 1, 1));
|
menu_cursor_ == 4 ? Vec4(1, 0.92f, 0.2f, 1) : Vec4(0.85f, 0.9f, 1, 1));
|
||||||
start_row = 5;
|
ui_ren_.draw_text_fit(left_x, 432.0f, max_w, 1.85f,
|
||||||
|
std::string("P2 TEAM: < ") + sim::kTeamNames[p2_team_] + " >",
|
||||||
|
menu_cursor_ == 5 ? Vec4(1, 0.92f, 0.2f, 1) : Vec4(0.85f, 0.9f, 1, 1));
|
||||||
|
start_row = 6;
|
||||||
}
|
}
|
||||||
ui_ren_.draw_text_fit(left_x, 492.0f, max_w, 2.3f, "START RACE >>",
|
ui_ren_.draw_text_fit(left_x, 488.0f, max_w, 2.25f, "START RACE >>",
|
||||||
menu_cursor_ == start_row ? Vec4(0.3f, 1.0f, 0.45f, 1) : Vec4(0.8f, 0.9f, 1, 1));
|
menu_cursor_ == start_row ? Vec4(0.3f, 1.0f, 0.45f, 1) : Vec4(0.8f, 0.9f, 1, 1));
|
||||||
|
|
||||||
if (editing_player_name_) {
|
if (editing_name_target_ != 0) {
|
||||||
ui_ren_.draw_text_centered_fit(cx, static_cast<float>(win_h_) - 32.0f,
|
ui_ren_.draw_text_centered_fit(cx, static_cast<float>(win_h_) - 32.0f,
|
||||||
static_cast<float>(win_w_) - 40.0f, 1.45f,
|
static_cast<float>(win_w_) - 40.0f, 1.45f,
|
||||||
"TYPE PILOT NAME BACKSPACE DELETE ENTER SAVE ESC CANCEL",
|
"TYPE PILOT NAME BACKSPACE DELETE ENTER SAVE ESC CANCEL",
|
||||||
@@ -1424,74 +1599,131 @@ void GameApp::render_menus() {
|
|||||||
|
|
||||||
if (state_ == ScreenState::Options) {
|
if (state_ == ScreenState::Options) {
|
||||||
ui_ren_.draw_text_centered(cx, 82.0f, 2.5f, str.options, Vec4(0.4f, 0.85f, 1, 1));
|
ui_ren_.draw_text_centered(cx, 82.0f, 2.5f, str.options, Vec4(0.4f, 0.85f, 1, 1));
|
||||||
const char* tabs[] = {"VIDEO", "AUDIO", "CONTROLS", "GAME"};
|
const char* tabs[7] = {"VIDEO", "AUDIO", "CONTROLS P1", "CONTROLS P2", "INPUT / PAD", "GAME", "RULES"};
|
||||||
std::string tab_str = std::string("CATEGORY: < ") + tabs[static_cast<int>(opt_tab_)] + " >";
|
std::string tab_str = std::string("CATEGORY: < ") + tabs[static_cast<int>(opt_tab_)] + " >";
|
||||||
ui_ren_.draw_text_centered(cx, 138.0f, 2.1f, tab_str,
|
ui_ren_.draw_text_centered(cx, 138.0f, 2.05f, tab_str,
|
||||||
menu_cursor_ == 0 ? Vec4(1, 0.92f, 0.2f, 1) : Vec4(0.5f, 0.85f, 1, 1));
|
menu_cursor_ == 0 ? Vec4(1, 0.92f, 0.2f, 1) : Vec4(0.5f, 0.85f, 1, 1));
|
||||||
|
|
||||||
|
auto on_off = [](bool b) -> const char* { return b ? "ON" : "OFF"; };
|
||||||
std::vector<std::string> rows;
|
std::vector<std::string> rows;
|
||||||
|
int edit_row_idx = -1;
|
||||||
|
|
||||||
if (opt_tab_ == OptionsTab::Video) {
|
if (opt_tab_ == OptionsTab::Video) {
|
||||||
rows.push_back("RESOLUTION: " + std::to_string(cfg_.window_width) + "X" + std::to_string(cfg_.window_height));
|
rows.push_back("RESOLUTION: " + std::to_string(cfg_.window_width) + "X" + std::to_string(cfg_.window_height));
|
||||||
rows.push_back(std::string("FULLSCREEN: ") + (cfg_.fullscreen ? "ON" : "OFF"));
|
rows.push_back(std::string("FULLSCREEN: ") + on_off(cfg_.fullscreen));
|
||||||
rows.push_back(std::string("VSYNC: ") + (cfg_.vsync ? "ON" : "OFF"));
|
rows.push_back(std::string("VSYNC: ") + on_off(cfg_.vsync));
|
||||||
|
rows.push_back(std::string("MSAA: ") + (cfg_.msaa_samples >= 2 ? (std::to_string(cfg_.msaa_samples) + "X") : "OFF"));
|
||||||
|
rows.push_back("FIELD OF VIEW: " + std::to_string(static_cast<int>(cfg_.fov_deg)) + " DEG");
|
||||||
rows.push_back("DRAW DISTANCE: " + std::to_string(static_cast<int>(cfg_.draw_distance)) + " TILES");
|
rows.push_back("DRAW DISTANCE: " + std::to_string(static_cast<int>(cfg_.draw_distance)) + " TILES");
|
||||||
rows.push_back(std::string("TEXTURE FILTER: ") + (cfg_.texture_filter == TextureFilterMode::Linear ? "LINEAR" : "NEAREST"));
|
rows.push_back(std::string("TEXTURE FILTER: ") + (cfg_.texture_filter == TextureFilterMode::Linear ? "LINEAR" : "NEAREST"));
|
||||||
std::string cm = !cfg_.classic_mode ? "MODERN OPENGL" : (cfg_.classic_hires ? "CLASSIC 640X480" : "CLASSIC 320X200");
|
std::string cm = !cfg_.classic_mode ? "MODERN OPENGL" : (cfg_.classic_hires ? "CLASSIC 640X480" : "CLASSIC 320X200");
|
||||||
rows.push_back("RENDER MODE: " + cm);
|
rows.push_back("RENDER MODE: " + cm);
|
||||||
|
rows.push_back(std::string("CLASSIC SCANLINES: ") + on_off(cfg_.classic_scanlines));
|
||||||
} else if (opt_tab_ == OptionsTab::Audio) {
|
} else if (opt_tab_ == OptionsTab::Audio) {
|
||||||
rows.push_back(std::string("MUSIC BACKEND: ") + backend_label(cfg_.music_backend));
|
rows.push_back(std::string("MUSIC BACKEND: ") + backend_label(cfg_.music_backend));
|
||||||
rows.push_back("MASTER VOLUME: " + std::to_string(static_cast<int>(cfg_.master_volume * 100)) + "%");
|
rows.push_back("MASTER VOLUME: " + std::to_string(static_cast<int>(std::round(cfg_.master_volume * 100.0f))) + "%");
|
||||||
rows.push_back("SFX VOLUME: " + std::to_string(static_cast<int>(cfg_.sfx_volume * 100)) + "%");
|
rows.push_back("SFX VOLUME: " + std::to_string(static_cast<int>(std::round(cfg_.sfx_volume * 100.0f))) + "%");
|
||||||
rows.push_back("MUSIC VOLUME: " + std::to_string(static_cast<int>(cfg_.music_volume * 100)) + "%");
|
rows.push_back("MUSIC VOLUME: " + std::to_string(static_cast<int>(std::round(cfg_.music_volume * 100.0f))) + "%");
|
||||||
} else if (opt_tab_ == OptionsTab::Controls) {
|
rows.push_back(std::string("MUTE ON FOCUS LOSS: ") + on_off(cfg_.mute_on_focus_loss));
|
||||||
const char* klabels[9] = {"STEER LEFT", "STEER RIGHT", "ACCELERATE", "BRAKE", "BOOST",
|
std::string sf_lbl = cfg_.custom_soundfont_path.empty()
|
||||||
"FIRE MINIGUN", "FIRE MISSILE", "AUTO PILOT", "CAMERA VIEW"};
|
? "BUILT-IN (BULLFROG.SBK)"
|
||||||
int kvals[9] = {cfg_.keys.steer_left, cfg_.keys.steer_right, cfg_.keys.accelerate,
|
: std::filesystem::path(cfg_.custom_soundfont_path).filename().string();
|
||||||
cfg_.keys.brake, cfg_.keys.boost, cfg_.keys.fire_minigun,
|
rows.push_back("SOUNDFONT: " + sf_lbl);
|
||||||
cfg_.keys.fire_missile, cfg_.keys.autopilot, cfg_.keys.camera_view};
|
} else if (opt_tab_ == OptionsTab::ControlsP1) {
|
||||||
for (int i = 0; i < 9; ++i) {
|
const char* klabels[10] = {"STEER LEFT", "STEER RIGHT", "ACCELERATE", "BRAKE", "BOOST",
|
||||||
|
"FIRE MINIGUN", "FIRE MISSILE", "AUTO PILOT", "CAMERA VIEW", "HUD TOGGLE"};
|
||||||
|
int kvals[10] = {cfg_.keys.steer_left, cfg_.keys.steer_right, cfg_.keys.accelerate,
|
||||||
|
cfg_.keys.brake, cfg_.keys.boost, cfg_.keys.fire_minigun,
|
||||||
|
cfg_.keys.fire_missile, cfg_.keys.autopilot, cfg_.keys.camera_view,
|
||||||
|
cfg_.keys.hud_toggle};
|
||||||
|
for (int i = 0; i < 10; ++i) {
|
||||||
std::string kname = (rebind_slot_ == i) ? "[PRESS KEY...]" : InputManager::scancode_name(kvals[i]);
|
std::string kname = (rebind_slot_ == i) ? "[PRESS KEY...]" : InputManager::scancode_name(kvals[i]);
|
||||||
rows.push_back(std::string(klabels[i]) + ": " + kname);
|
rows.push_back(std::string(klabels[i]) + ": " + kname);
|
||||||
}
|
}
|
||||||
rows.push_back("GAMEPAD DEADZONE: " + std::to_string(static_cast<int>(cfg_.gamepad_deadzone * 100)) + "%");
|
} else if (opt_tab_ == OptionsTab::ControlsP2) {
|
||||||
rows.push_back(std::string("RUMBLE HAPTICS: ") + (cfg_.rumble_enabled ? "ON" : "OFF"));
|
const char* klabels[7] = {"P2 STEER LEFT", "P2 STEER RIGHT", "P2 ACCELERATE", "P2 BRAKE",
|
||||||
rows.push_back(std::string("MOUSE STEERING: ") + (cfg_.mouse_steering ? "ON" : "OFF"));
|
"P2 BOOST", "P2 FIRE MINIGUN", "P2 FIRE MISSILE"};
|
||||||
} else {
|
int kvals[7] = {cfg_.keys.p2_steer_left, cfg_.keys.p2_steer_right, cfg_.keys.p2_accelerate,
|
||||||
if (editing_player_name_) {
|
cfg_.keys.p2_brake, cfg_.keys.p2_boost, cfg_.keys.p2_fire_minigun,
|
||||||
rows.push_back("PLAYER NAME: " + edit_display);
|
cfg_.keys.p2_fire_missile};
|
||||||
|
for (int i = 0; i < 7; ++i) {
|
||||||
|
std::string kname = (rebind_slot_ == 10 + i) ? "[PRESS KEY...]" : InputManager::scancode_name(kvals[i]);
|
||||||
|
rows.push_back(std::string(klabels[i]) + ": " + kname);
|
||||||
|
}
|
||||||
|
} else if (opt_tab_ == OptionsTab::InputPad) {
|
||||||
|
auto pad_desc = [&](int slot) -> std::string {
|
||||||
|
if (slot < 0) return "KEYBOARD ONLY";
|
||||||
|
std::string gn = input_.gamepad_name(slot);
|
||||||
|
if (gn == "None") return "SLOT " + std::to_string(slot + 1) + " [EMPTY]";
|
||||||
|
if (gn.size() > 16) gn = gn.substr(0, 16);
|
||||||
|
return "SLOT " + std::to_string(slot + 1) + " [" + gn + "]";
|
||||||
|
};
|
||||||
|
rows.push_back("P1 GAMEPAD: " + pad_desc(cfg_.p1_gamepad_index));
|
||||||
|
rows.push_back("P2 GAMEPAD: " + pad_desc(cfg_.p2_gamepad_index));
|
||||||
|
rows.push_back("GAMEPAD DEADZONE: " + std::to_string(static_cast<int>(std::round(cfg_.gamepad_deadzone * 100.0f))) + "%");
|
||||||
|
rows.push_back("STEER SENSITIVITY: " + std::to_string(static_cast<int>(std::round(cfg_.steering_sensitivity * 100.0f))) + "%");
|
||||||
|
char curve_buf[24];
|
||||||
|
std::snprintf(curve_buf, sizeof(curve_buf), "%.2f", cfg_.steering_curve);
|
||||||
|
rows.push_back(std::string("STEER CURVE: ") + curve_buf);
|
||||||
|
rows.push_back(std::string("RUMBLE HAPTICS: ") + on_off(cfg_.rumble_enabled));
|
||||||
|
rows.push_back(std::string("MOUSE STEERING: ") + on_off(cfg_.mouse_steering));
|
||||||
|
} else if (opt_tab_ == OptionsTab::Game) {
|
||||||
|
if (editing_name_target_ == 1) {
|
||||||
|
rows.push_back("PLAYER 1 NAME: " + edit_display);
|
||||||
|
edit_row_idx = 0;
|
||||||
} else {
|
} else {
|
||||||
rows.push_back("PLAYER NAME: " + cfg_.player_name + " [ENTER EDIT]");
|
rows.push_back("PLAYER 1 NAME: " + cfg_.player_name + " [ENTER EDIT]");
|
||||||
|
}
|
||||||
|
if (editing_name_target_ == 2) {
|
||||||
|
rows.push_back("PLAYER 2 NAME: " + edit_display);
|
||||||
|
edit_row_idx = 1;
|
||||||
|
} else {
|
||||||
|
rows.push_back("PLAYER 2 NAME: " + cfg_.player2_name + " [ENTER EDIT]");
|
||||||
}
|
}
|
||||||
rows.push_back(std::string("LANGUAGE: ") + lang_label(cfg_.language));
|
rows.push_back(std::string("LANGUAGE: ") + lang_label(cfg_.language));
|
||||||
rows.push_back(std::string("SKIP INTRO: ") + (cfg_.skip_intro ? "ON" : "OFF"));
|
rows.push_back(std::string("DEFAULT CAMERA: ") + camera_label(cfg_.default_camera));
|
||||||
rows.push_back(std::string("CLASSIC SCANLINES: ") + (cfg_.classic_scanlines ? "ON" : "OFF"));
|
rows.push_back(std::string("SHOW HUD: ") + on_off(cfg_.show_hud));
|
||||||
|
rows.push_back(std::string("SHOW MINIMAP: ") + on_off(cfg_.show_minimap));
|
||||||
|
rows.push_back(std::string("SKIP INTRO: ") + on_off(cfg_.skip_intro));
|
||||||
|
} else {
|
||||||
|
rows.push_back(std::string("DIFFICULTY: < ") + diff_label(cfg_.difficulty) + " >");
|
||||||
|
rows.push_back("DEFAULT LAPS: " + std::to_string(cfg_.default_laps));
|
||||||
|
rows.push_back("DEATHMATCH KILLS: " + std::to_string(cfg_.deathmatch_kill_limit));
|
||||||
|
rows.push_back(std::string("FUEL CONSUMPTION: ") + on_off(cfg_.fuel_enabled));
|
||||||
|
rows.push_back(std::string("SHIELD DAMAGE: ") + on_off(cfg_.damage_enabled));
|
||||||
|
rows.push_back(std::string("WEAPONS / COMBAT: ") + on_off(cfg_.weapons_enabled));
|
||||||
|
rows.push_back(std::string("TRACK PICKUPS: ") + on_off(cfg_.pickups_enabled));
|
||||||
|
rows.push_back(std::string("TRACK MORPHING: ") + on_off(cfg_.track_morphing_enabled));
|
||||||
}
|
}
|
||||||
|
|
||||||
float step_y = (rows.size() > 7) ? 30.0f : 44.0f;
|
const float ry_start = 186.0f;
|
||||||
float opt_max_w = static_cast<float>(win_w_) - 64.0f;
|
const float avail_h = std::max(220.0f, static_cast<float>(win_h_) - 72.0f - ry_start);
|
||||||
|
const float step_y = std::min(44.0f, avail_h / static_cast<float>(std::max<size_t>(rows.size(), 1)));
|
||||||
|
const float font_sz = (step_y < 32.0f) ? 1.65f : 1.85f;
|
||||||
|
const float opt_max_w = static_cast<float>(win_w_) - 64.0f;
|
||||||
for (size_t i = 0; i < rows.size(); ++i) {
|
for (size_t i = 0; i < rows.size(); ++i) {
|
||||||
float ry = 190.0f + static_cast<float>(i) * step_y;
|
float ry = ry_start + static_cast<float>(i) * step_y;
|
||||||
bool sel = (static_cast<int>(i) + 1 == menu_cursor_);
|
bool sel = (static_cast<int>(i) + 1 == menu_cursor_);
|
||||||
if (editing_player_name_ && opt_tab_ == OptionsTab::Game && i == 0) {
|
if (static_cast<int>(i) == edit_row_idx) {
|
||||||
float bw = std::min(500.0f, opt_max_w);
|
float bw = std::min(500.0f, opt_max_w);
|
||||||
ui_ren_.draw_rect(cx - bw * 0.5f, ry - 6.0f, bw, 28.0f, Vec4(0.16f, 0.34f, 0.68f, 0.85f));
|
ui_ren_.draw_rect(cx - bw * 0.5f, ry - 6.0f, bw, 28.0f, Vec4(0.16f, 0.34f, 0.68f, 0.85f));
|
||||||
ui_ren_.draw_rect_outline(cx - bw * 0.5f, ry - 6.0f, bw, 28.0f, 2.0f,
|
ui_ren_.draw_rect_outline(cx - bw * 0.5f, ry - 6.0f, bw, 28.0f, 2.0f,
|
||||||
Vec4(1.0f, 0.88f, 0.2f, 1.0f));
|
Vec4(1.0f, 0.88f, 0.2f, 1.0f));
|
||||||
}
|
}
|
||||||
ui_ren_.draw_text_centered_fit(cx, ry, opt_max_w, 1.85f, rows[i],
|
ui_ren_.draw_text_centered_fit(cx, ry, opt_max_w, font_sz, rows[i],
|
||||||
sel ? Vec4(1, 0.92f, 0.2f, 1) : Vec4(0.85f, 0.9f, 1, 1));
|
sel ? Vec4(1, 0.92f, 0.2f, 1) : Vec4(0.85f, 0.9f, 1, 1));
|
||||||
}
|
}
|
||||||
if (status_toast_timer_ > 0.0f && !editing_player_name_) {
|
if (status_toast_timer_ > 0.0f && editing_name_target_ == 0) {
|
||||||
ui_ren_.draw_text_centered(cx, static_cast<float>(win_h_) - 64.0f, 1.8f,
|
ui_ren_.draw_text_centered(cx, static_cast<float>(win_h_) - 64.0f, 1.8f,
|
||||||
status_toast_, Vec4(0.3f, 1.0f, 0.5f, 1.0f));
|
status_toast_, Vec4(0.3f, 1.0f, 0.5f, 1.0f));
|
||||||
}
|
}
|
||||||
const char* footer = editing_player_name_
|
const char* footer = (editing_name_target_ != 0)
|
||||||
? "TYPE PLAYER NAME BACKSPACE DELETE ENTER SAVE ESC CANCEL"
|
? "TYPE PLAYER NAME BACKSPACE DELETE ENTER SAVE ESC CANCEL"
|
||||||
: "LEFT/RIGHT ADJUST ENTER EDIT/TOGGLE ESC SAVE & BACK";
|
: "LEFT/RIGHT ADJUST ENTER EDIT/TOGGLE ESC SAVE & BACK";
|
||||||
ui_ren_.draw_text_centered_fit(cx, static_cast<float>(win_h_) - 32.0f,
|
ui_ren_.draw_text_centered_fit(cx, static_cast<float>(win_h_) - 32.0f,
|
||||||
static_cast<float>(win_w_) - 40.0f, 1.45f, footer,
|
static_cast<float>(win_w_) - 40.0f, 1.45f, footer,
|
||||||
editing_player_name_ ? Vec4(1.0f, 0.9f, 0.35f, 1.0f)
|
(editing_name_target_ != 0) ? Vec4(1.0f, 0.9f, 0.35f, 1.0f)
|
||||||
: Vec4(0.6f, 0.72f, 0.88f, 1));
|
: Vec4(0.6f, 0.72f, 0.88f, 1));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,8 +55,11 @@ private:
|
|||||||
enum class OptionsTab {
|
enum class OptionsTab {
|
||||||
Video = 0,
|
Video = 0,
|
||||||
Audio,
|
Audio,
|
||||||
Controls,
|
ControlsP1,
|
||||||
|
ControlsP2,
|
||||||
|
InputPad,
|
||||||
Game,
|
Game,
|
||||||
|
Rules,
|
||||||
};
|
};
|
||||||
|
|
||||||
void enter_state(ScreenState s);
|
void enter_state(ScreenState s);
|
||||||
@@ -79,7 +82,7 @@ private:
|
|||||||
void toggle_fullscreen();
|
void toggle_fullscreen();
|
||||||
void save_all_user_data();
|
void save_all_user_data();
|
||||||
void ensure_music(audio::MusicTrackId track, bool loop = true, bool force_restart = false);
|
void ensure_music(audio::MusicTrackId track, bool loop = true, bool force_restart = false);
|
||||||
void begin_name_edit();
|
void begin_name_edit(int target);
|
||||||
void cancel_name_edit();
|
void cancel_name_edit();
|
||||||
void update_name_edit();
|
void update_name_edit();
|
||||||
|
|
||||||
@@ -140,11 +143,13 @@ private:
|
|||||||
bool intro_turbo_played_ = false;
|
bool intro_turbo_played_ = false;
|
||||||
bool intro_explode_played_ = false;
|
bool intro_explode_played_ = false;
|
||||||
|
|
||||||
// Music & player name editing state
|
// Music & player name / HUD / options state
|
||||||
int active_music_track_ = -1;
|
int active_music_track_ = -1;
|
||||||
bool in_race_session_ = false;
|
bool in_race_session_ = false;
|
||||||
bool editing_player_name_ = false;
|
bool hud_visible_ = true;
|
||||||
|
int editing_name_target_ = 0; // 0=none, 1=P1, 2=P2
|
||||||
std::string name_edit_buf_;
|
std::string name_edit_buf_;
|
||||||
|
std::vector<std::string> available_soundfonts_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace top_octane::game
|
} // namespace top_octane::game
|
||||||
@@ -278,6 +278,7 @@ CraftInput InputManager::craft_input(int player_idx, const GameConfig& cfg,
|
|||||||
out.fire_missile = key_down(kb.fire_missile);
|
out.fire_missile = key_down(kb.fire_missile);
|
||||||
out.toggle_autopilot_pressed = key_just(kb.autopilot);
|
out.toggle_autopilot_pressed = key_just(kb.autopilot);
|
||||||
out.cycle_camera_pressed = key_just(kb.camera_view);
|
out.cycle_camera_pressed = key_just(kb.camera_view);
|
||||||
|
out.toggle_hud_pressed = key_just(kb.hud_toggle);
|
||||||
|
|
||||||
// In 1P mode, support Arrow keys as ergonomic backup alongside WASD
|
// In 1P mode, support Arrow keys as ergonomic backup alongside WASD
|
||||||
if (allow_arrow_fallback) {
|
if (allow_arrow_fallback) {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ struct CraftInput {
|
|||||||
bool fire_missile = false;
|
bool fire_missile = false;
|
||||||
bool toggle_autopilot_pressed = false;
|
bool toggle_autopilot_pressed = false;
|
||||||
bool cycle_camera_pressed = false;
|
bool cycle_camera_pressed = false;
|
||||||
|
bool toggle_hud_pressed = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MenuInput {
|
struct MenuInput {
|
||||||
|
|||||||
+23
-13
@@ -167,7 +167,7 @@ void step_combat_and_world(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Trigger repair if fuel completely depleted and stopped
|
// Trigger repair if fuel completely depleted and stopped
|
||||||
if (c.fuel <= 0.05f && c.speed_horizontal() < 0.8f) {
|
if (setup.fuel_enabled && c.fuel <= 0.05f && c.speed_horizontal() < 0.8f) {
|
||||||
c.recovery_state = RecoveryState::CallingRepair;
|
c.recovery_state = RecoveryState::CallingRepair;
|
||||||
c.recovery_timer = 3.0f;
|
c.recovery_timer = 3.0f;
|
||||||
if (c.is_human) {
|
if (c.is_human) {
|
||||||
@@ -176,6 +176,12 @@ void step_combat_and_world(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!setup.weapons_enabled) {
|
||||||
|
c.lock_target_id = -1;
|
||||||
|
c.lock_progress = 0.0f;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Update missile lock-on cone
|
// Update missile lock-on cone
|
||||||
Vec3 fwd = c.forward_dir();
|
Vec3 fwd = c.forward_dir();
|
||||||
int best_tgt = -1;
|
int best_tgt = -1;
|
||||||
@@ -304,8 +310,6 @@ void step_combat_and_world(
|
|||||||
Vec3 d = victim.curr_pose.pos - pr.pos;
|
Vec3 d = victim.curr_pose.pos - pr.pos;
|
||||||
if (d.len_sq() < hit_r * hit_r) {
|
if (d.len_sq() < hit_r * hit_r) {
|
||||||
pr.active = false;
|
pr.active = false;
|
||||||
victim.shield -= pr.damage;
|
|
||||||
victim.armour_used += pr.damage;
|
|
||||||
if (pr.owner_id >= 0 && pr.owner_id < static_cast<int>(crafts.size())) {
|
if (pr.owner_id >= 0 && pr.owner_id < static_cast<int>(crafts.size())) {
|
||||||
crafts[pr.owner_id].shots_hit += 1;
|
crafts[pr.owner_id].shots_hit += 1;
|
||||||
}
|
}
|
||||||
@@ -319,17 +323,21 @@ void step_combat_and_world(
|
|||||||
victim.is_human ? victim.player_index : -1, "", 0.20f});
|
victim.is_human ? victim.player_index : -1, "", 0.20f});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (victim.shield <= 0.0f) {
|
if (setup.damage_enabled) {
|
||||||
if (pr.owner_id >= 0 && pr.owner_id < static_cast<int>(crafts.size())) {
|
victim.shield -= pr.damage;
|
||||||
crafts[pr.owner_id].kills += 1;
|
victim.armour_used += pr.damage;
|
||||||
if (setup.mode == GameMode::DeathMatch &&
|
if (victim.shield <= 0.0f) {
|
||||||
crafts[pr.owner_id].kills >= setup.deathmatch_kill_limit) {
|
if (pr.owner_id >= 0 && pr.owner_id < static_cast<int>(crafts.size())) {
|
||||||
out_race_over = true;
|
crafts[pr.owner_id].kills += 1;
|
||||||
out_winner_id = crafts[pr.owner_id].id;
|
if (setup.mode == GameMode::DeathMatch &&
|
||||||
|
crafts[pr.owner_id].kills >= setup.deathmatch_kill_limit) {
|
||||||
|
out_race_over = true;
|
||||||
|
out_winner_id = crafts[pr.owner_id].id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
apply_damage(victim, pr.owner_id, crafts, setup, particles, events,
|
||||||
|
out_race_over, out_winner_id);
|
||||||
}
|
}
|
||||||
apply_damage(victim, pr.owner_id, crafts, setup, particles, events,
|
|
||||||
out_race_over, out_winner_id);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -397,7 +405,9 @@ void step_combat_and_world(
|
|||||||
prop.alive = false;
|
prop.alive = false;
|
||||||
prop.respawn_timer = 25.0f;
|
prop.respawn_timer = 25.0f;
|
||||||
if (prop.model_key.rfind("BAREL", 0) == 0) {
|
if (prop.model_key.rfind("BAREL", 0) == 0) {
|
||||||
c.shield = std::max(5.0f, c.shield - 12.0f);
|
if (setup.damage_enabled) {
|
||||||
|
c.shield = std::max(5.0f, c.shield - 12.0f);
|
||||||
|
}
|
||||||
spawn_explosion(particles, prop.pos, 0.9f);
|
spawn_explosion(particles, prop.pos, 0.9f);
|
||||||
events.push_back({SimSoundCue::Explosion, prop.pos,
|
events.push_back({SimSoundCue::Explosion, prop.pos,
|
||||||
c.is_human ? c.player_index : -1, "", 0.45f});
|
c.is_human ? c.player_index : -1, "", 0.45f});
|
||||||
|
|||||||
+4
-3
@@ -198,7 +198,8 @@ bool resolve_world_collisions(CraftState& craft, const assets::LevelData& level,
|
|||||||
}
|
}
|
||||||
|
|
||||||
CraftStepFeedback step_craft_physics(CraftState& craft, const CraftInput& input,
|
CraftStepFeedback step_craft_physics(CraftState& craft, const CraftInput& input,
|
||||||
const assets::LevelData& level, float dt) {
|
const assets::LevelData& level, float dt,
|
||||||
|
bool fuel_enabled) {
|
||||||
CraftStepFeedback fb;
|
CraftStepFeedback fb;
|
||||||
craft.prev_pose = craft.curr_pose;
|
craft.prev_pose = craft.curr_pose;
|
||||||
|
|
||||||
@@ -231,7 +232,7 @@ CraftStepFeedback step_craft_physics(CraftState& craft, const CraftInput& input,
|
|||||||
Vec3 right(-fwd.z, 0.0f, fwd.x); // local -X is right side of craft
|
Vec3 right(-fwd.z, 0.0f, fwd.x); // local -X is right side of craft
|
||||||
|
|
||||||
// Fuel consumption & boost handling
|
// Fuel consumption & boost handling
|
||||||
bool has_fuel = craft.fuel > 0.05f;
|
bool has_fuel = !fuel_enabled || (craft.fuel > 0.05f);
|
||||||
if (!has_fuel) {
|
if (!has_fuel) {
|
||||||
fb.out_of_fuel = true;
|
fb.out_of_fuel = true;
|
||||||
}
|
}
|
||||||
@@ -253,7 +254,7 @@ CraftStepFeedback step_craft_physics(CraftState& craft, const CraftInput& input,
|
|||||||
|
|
||||||
// Fuel burn proportional to throttle + boost
|
// Fuel burn proportional to throttle + boost
|
||||||
float burn = (throttle * 0.48f + (fb.boosting ? 2.4f : 0.0f) + 0.06f) * dt;
|
float burn = (throttle * 0.48f + (fb.boosting ? 2.4f : 0.0f) + 0.06f) * dt;
|
||||||
if (has_fuel) {
|
if (fuel_enabled && has_fuel) {
|
||||||
float used = std::min(craft.fuel, burn);
|
float used = std::min(craft.fuel, burn);
|
||||||
craft.fuel -= used;
|
craft.fuel -= used;
|
||||||
craft.fuel_used += used;
|
craft.fuel_used += used;
|
||||||
|
|||||||
+2
-1
@@ -114,7 +114,8 @@ struct CraftStepFeedback {
|
|||||||
|
|
||||||
// Pure deterministic 60 Hz hover physics step for one active craft
|
// Pure deterministic 60 Hz hover physics step for one active craft
|
||||||
CraftStepFeedback step_craft_physics(CraftState& craft, const CraftInput& input,
|
CraftStepFeedback step_craft_physics(CraftState& craft, const CraftInput& input,
|
||||||
const assets::LevelData& level, float dt);
|
const assets::LevelData& level, float dt,
|
||||||
|
bool fuel_enabled = true);
|
||||||
|
|
||||||
// Resolves world boundary, column AABB, ceiling, and cliff collisions for one active craft
|
// Resolves world boundary, column AABB, ceiling, and cliff collisions for one active craft
|
||||||
bool resolve_world_collisions(CraftState& craft, const assets::LevelData& level,
|
bool resolve_world_collisions(CraftState& craft, const assets::LevelData& level,
|
||||||
|
|||||||
+12
-9
@@ -52,14 +52,16 @@ bool RaceSim::start_race(const assets::LevelData& level, const RaceSetup& setup,
|
|||||||
terrain_dirty_ = false;
|
terrain_dirty_ = false;
|
||||||
|
|
||||||
// Populate pickups (type 5) & props (type 3)
|
// Populate pickups (type 5) & props (type 3)
|
||||||
for (const auto& e : level_.pickups) {
|
if (setup_.pickups_enabled) {
|
||||||
PickupItem p;
|
for (const auto& e : level_.pickups) {
|
||||||
p.entity_id = e.id;
|
PickupItem p;
|
||||||
p.subtype = e.subtype;
|
p.entity_id = e.id;
|
||||||
float tx = e.tile_x() + 0.5f;
|
p.subtype = e.subtype;
|
||||||
float tz = e.tile_z() + 0.5f;
|
float tx = e.tile_x() + 0.5f;
|
||||||
p.pos = Vec3(tx, level_.sample_height_world(tx, tz) + 0.45f, tz);
|
float tz = e.tile_z() + 0.5f;
|
||||||
pickups_.push_back(p);
|
p.pos = Vec3(tx, level_.sample_height_world(tx, tz) + 0.45f, tz);
|
||||||
|
pickups_.push_back(p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (const auto& e : level_.props) {
|
for (const auto& e : level_.props) {
|
||||||
PropObject pr;
|
PropObject pr;
|
||||||
@@ -280,7 +282,7 @@ void RaceSim::step(const CraftInput& p1_input, const CraftInput& p2_input, float
|
|||||||
inputs[i] = in;
|
inputs[i] = in;
|
||||||
|
|
||||||
float prev_boost_timer = c.boost_timer;
|
float prev_boost_timer = c.boost_timer;
|
||||||
CraftStepFeedback fb = step_craft_physics(c, in, level_, dt);
|
CraftStepFeedback fb = step_craft_physics(c, in, level_, dt, setup_.fuel_enabled);
|
||||||
|
|
||||||
if (fb.collided_wall && fb.impact_speed > 3.8f) {
|
if (fb.collided_wall && fb.impact_speed > 3.8f) {
|
||||||
events_.push_back({SimSoundCue::Impact, c.curr_pose.pos, c.player_index, "",
|
events_.push_back({SimSoundCue::Impact, c.curr_pose.pos, c.player_index, "",
|
||||||
@@ -438,6 +440,7 @@ void RaceSim::update_recharge_pads(CraftState& c, float dt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RaceSim::update_triggers(CraftState& c) {
|
void RaceSim::update_triggers(CraftState& c) {
|
||||||
|
if (!setup_.track_morphing_enabled) return;
|
||||||
for (size_t i = 0; i < level_.triggers.size(); ++i) {
|
for (size_t i = 0; i < level_.triggers.size(); ++i) {
|
||||||
if (trigger_fired_[i]) continue;
|
if (trigger_fired_[i]) continue;
|
||||||
const auto& tr = level_.triggers[i];
|
const auto& tr = level_.triggers[i];
|
||||||
|
|||||||
@@ -109,6 +109,11 @@ struct RaceSetup {
|
|||||||
int p2_team = 1;
|
int p2_team = 1;
|
||||||
std::string p2_name = "PLAYER 2";
|
std::string p2_name = "PLAYER 2";
|
||||||
int deathmatch_kill_limit = 5;
|
int deathmatch_kill_limit = 5;
|
||||||
|
bool fuel_enabled = true;
|
||||||
|
bool damage_enabled = true;
|
||||||
|
bool weapons_enabled = true;
|
||||||
|
bool pickups_enabled = true;
|
||||||
|
bool track_morphing_enabled = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RaceSim {
|
class RaceSim {
|
||||||
|
|||||||
@@ -154,9 +154,29 @@ int main() {
|
|||||||
CHECK(c2.player_name == "PLAYER");
|
CHECK(c2.player_name == "PLAYER");
|
||||||
|
|
||||||
c1.player_name = "ABCDEFGHIJKLMNOP";
|
c1.player_name = "ABCDEFGHIJKLMNOP";
|
||||||
|
c1.player2_name = " p2_ace ";
|
||||||
|
c1.deathmatch_kill_limit = 12;
|
||||||
|
c1.default_camera = 2;
|
||||||
|
c1.show_hud = false;
|
||||||
|
c1.show_minimap = false;
|
||||||
|
c1.fuel_enabled = false;
|
||||||
|
c1.damage_enabled = false;
|
||||||
|
c1.weapons_enabled = false;
|
||||||
|
c1.pickups_enabled = false;
|
||||||
|
c1.track_morphing_enabled = false;
|
||||||
CHECK(c1.save(tmp_cfg));
|
CHECK(c1.save(tmp_cfg));
|
||||||
CHECK(c2.load(tmp_cfg));
|
CHECK(c2.load(tmp_cfg));
|
||||||
CHECK(c2.player_name == "ABCDEFGHIJKL");
|
CHECK(c2.player_name == "ABCDEFGHIJKL");
|
||||||
|
CHECK(c2.player2_name == "P2_ACE");
|
||||||
|
CHECK(c2.deathmatch_kill_limit == 12);
|
||||||
|
CHECK(c2.default_camera == 2);
|
||||||
|
CHECK(!c2.show_hud);
|
||||||
|
CHECK(!c2.show_minimap);
|
||||||
|
CHECK(!c2.fuel_enabled);
|
||||||
|
CHECK(!c2.damage_enabled);
|
||||||
|
CHECK(!c2.weapons_enabled);
|
||||||
|
CHECK(!c2.pickups_enabled);
|
||||||
|
CHECK(!c2.track_morphing_enabled);
|
||||||
std::error_code ec;
|
std::error_code ec;
|
||||||
std::filesystem::remove(tmp_cfg, ec);
|
std::filesystem::remove(tmp_cfg, ec);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,5 +136,67 @@ int main() {
|
|||||||
std::filesystem::remove_all(tmp_dir);
|
std::filesystem::remove_all(tmp_dir);
|
||||||
std::cout << "[PASS] Championship save/load, Highscores & Clone disk round-trip validated\n";
|
std::cout << "[PASS] Championship save/load, Highscores & Clone disk round-trip validated\n";
|
||||||
|
|
||||||
|
// 5. Gameplay Rule Toggles (fuel, weapons, damage, pickups, track morphing)
|
||||||
|
{
|
||||||
|
sim::RaceSetup r1;
|
||||||
|
r1.mode = sim::GameMode::SingleRace;
|
||||||
|
r1.track_number = 1;
|
||||||
|
r1.num_ai = 1;
|
||||||
|
r1.fuel_enabled = false;
|
||||||
|
r1.weapons_enabled = false;
|
||||||
|
r1.pickups_enabled = false;
|
||||||
|
r1.track_morphing_enabled = false;
|
||||||
|
|
||||||
|
sim::RaceSim ts1;
|
||||||
|
CHECK(ts1.start_race(lvl1, r1));
|
||||||
|
CHECK(ts1.pickups().empty());
|
||||||
|
float start_fuel = ts1.crafts()[0].fuel;
|
||||||
|
// Skip countdown
|
||||||
|
for (int t = 0; t < 200; ++t) ts1.step(CraftInput{}, CraftInput{}, dt);
|
||||||
|
CraftInput drive;
|
||||||
|
drive.throttle = 1.0f;
|
||||||
|
drive.boost = true;
|
||||||
|
drive.fire_minigun = true;
|
||||||
|
drive.fire_missile = true;
|
||||||
|
for (int t = 0; t < 120; ++t) {
|
||||||
|
ts1.step(drive, CraftInput{}, dt);
|
||||||
|
CHECK(ts1.projectiles().empty());
|
||||||
|
}
|
||||||
|
CHECK(ts1.crafts()[0].fuel == start_fuel);
|
||||||
|
if (!lvl1.triggers.empty()) {
|
||||||
|
const auto& tr = lvl1.triggers[0];
|
||||||
|
ts1.crafts_mut()[0].curr_pose.pos = Vec3(
|
||||||
|
tr.tile_x() + 0.5f, lvl1.sample_height_world(tr.tile_x() + 0.5f, tr.tile_z() + 0.5f),
|
||||||
|
tr.tile_z() + 0.5f);
|
||||||
|
ts1.step(CraftInput{}, CraftInput{}, dt);
|
||||||
|
int x0, z0, x1, z1;
|
||||||
|
CHECK(!ts1.consume_terrain_dirty(x0, z0, x1, z1));
|
||||||
|
}
|
||||||
|
|
||||||
|
// damage_enabled = false keeps target shields intact on direct hits
|
||||||
|
sim::RaceSetup r2;
|
||||||
|
r2.mode = sim::GameMode::DeathMatch;
|
||||||
|
r2.track_number = 1;
|
||||||
|
r2.num_ai = 1;
|
||||||
|
r2.damage_enabled = false;
|
||||||
|
sim::RaceSim ts2;
|
||||||
|
CHECK(ts2.start_race(lvl1, r2));
|
||||||
|
for (int t = 0; t < 200; ++t) ts2.step(CraftInput{}, CraftInput{}, dt);
|
||||||
|
auto& p1 = ts2.crafts_mut()[0];
|
||||||
|
auto& tgt = ts2.crafts_mut()[1];
|
||||||
|
Vec3 fwd = p1.forward_dir();
|
||||||
|
tgt.curr_pose.pos = p1.curr_pose.pos + fwd * 3.0f;
|
||||||
|
tgt.prev_pose = tgt.curr_pose;
|
||||||
|
float init_sh = tgt.shield;
|
||||||
|
for (int t = 0; t < 60; ++t) {
|
||||||
|
CraftInput fire;
|
||||||
|
fire.fire_minigun = true;
|
||||||
|
ts2.step(fire, CraftInput{}, dt);
|
||||||
|
}
|
||||||
|
CHECK(tgt.shield == init_sh);
|
||||||
|
CHECK(p1.kills == 0);
|
||||||
|
}
|
||||||
|
std::cout << "[PASS] Gameplay rule toggles (fuel, weapons, damage, pickups, morphing) validated\n";
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user