Skip to content

Commit

Permalink
CDTracks: allow user.ini to replace CDTracks section entirely, remove…
Browse files Browse the repository at this point in the history
… non-music
  • Loading branch information
emoose committed Dec 10, 2024
1 parent cbe07fc commit ca60f48
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
13 changes: 1 addition & 12 deletions OutRun2006Tweaks.ini
Original file line number Diff line number Diff line change
Expand Up @@ -344,15 +344,4 @@ HideOnlineSigninText = false
25_Shiny_World_prototype.ogg = Shiny World (Prototype)
26_Night_Flight_prototype.ogg = Night Flight (Prototype)
27_Life_was_a_Bore_Instrumental.ogg = Life was a Bore (Instrumental)
28_Night_Flight_Instrumental.ogg = Night Flight (Instrumental)
Last_Wave.ogg = Last Wave
SEGA441.ogg = SEGA Intro
Beach_wave.ogg = Beach Waves
title_pattern1.ogg = C2C Title 1
title_01.ogg = C2C Opening Jingle
or2ed1.ogg = Ending 1
or2ed2.ogg = Ending 2
or2ed3a.ogg = Ending 3a
or2ed3b.ogg = Ending 3b
or2ed4.ogg = Ending 4
or2ed5.ogg = Ending 5
28_Night_Flight_Instrumental.ogg = Night Flight (Instrumental)
13 changes: 11 additions & 2 deletions src/hooks_audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ void CDSwitcher_ReadIni(const std::filesystem::path& iniPath)
Settings::CDSwitcherEnable = false;
}

std::vector<std::pair<std::string, std::string>> iniTracks;

std::ifstream file(iniPath);
if (file && file.is_open())
{
Expand All @@ -319,7 +321,7 @@ void CDSwitcher_ReadIni(const std::filesystem::path& iniPath)
{
std::string path = Util::trim(line.substr(0, delimiterPos));
std::string name = Util::trim(line.substr(delimiterPos + 1));
Settings::CDTracks.emplace_back(path, name);
iniTracks.emplace_back(path, name);
spdlog::info(" - CDTracks: Added track {} ({})", name, path);

// Check both paths that the CDSwitcher code looks in
Expand All @@ -336,12 +338,19 @@ void CDSwitcher_ReadIni(const std::filesystem::path& iniPath)
file.close();
}

if (iniTracks.size() <= 0)
return;

if (Settings::CDSwitcherShuffleTracks)
{
std::random_device rd;
std::mt19937 g(rd());

// Use std::shuffle to shuffle the vector
std::shuffle(Settings::CDTracks.begin(), Settings::CDTracks.end(), g);
std::shuffle(iniTracks.begin(), iniTracks.end(), g);
}

// replace old tracklist with the one from this INI
// (if user had specified tracks in user.ini they likely meant to replace the defaults)
Settings::CDTracks = iniTracks;
}

0 comments on commit ca60f48

Please sign in to comment.