mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-02 07:43:51 +00:00
Randomize login intro music using new Wowee tracks
This commit is contained in:
parent
6dfc6c6360
commit
28e32392fc
4 changed files with 30 additions and 7 deletions
Binary file not shown.
BIN
assets/Raise the Mug, Sound the Warcry.mp3
Executable file
BIN
assets/Raise the Mug, Sound the Warcry.mp3
Executable file
Binary file not shown.
BIN
assets/Wanderwewill.mp3
Executable file
BIN
assets/Wanderwewill.mp3
Executable file
Binary file not shown.
|
|
@ -14,6 +14,8 @@
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
#include <array>
|
||||||
|
#include <random>
|
||||||
|
|
||||||
namespace wowee { namespace ui {
|
namespace wowee { namespace ui {
|
||||||
|
|
||||||
|
|
@ -97,15 +99,36 @@ void AuthScreen::render(auth::AuthHandler& authHandler) {
|
||||||
if (music) {
|
if (music) {
|
||||||
music->update(ImGui::GetIO().DeltaTime);
|
music->update(ImGui::GetIO().DeltaTime);
|
||||||
if (!music->isPlaying()) {
|
if (!music->isPlaying()) {
|
||||||
std::string path = "/home/k/Desktop/wowee/assets/20-taverns.mp3";
|
static std::mt19937 rng(std::random_device{}());
|
||||||
if (!std::filesystem::exists(path)) {
|
static const std::array<const char*, 2> kLoginTracks = {
|
||||||
path = "assets/20-taverns.mp3";
|
"Raise the Mug, Sound the Warcry.mp3",
|
||||||
if (!std::filesystem::exists(path)) {
|
"Wanderwewill.mp3"
|
||||||
path = (std::filesystem::current_path() / "assets/20-taverns.mp3").string();
|
};
|
||||||
|
|
||||||
|
std::vector<std::string> availableTracks;
|
||||||
|
availableTracks.reserve(kLoginTracks.size());
|
||||||
|
for (const char* track : kLoginTracks) {
|
||||||
|
std::filesystem::path localPath = std::filesystem::path("assets") / track;
|
||||||
|
if (std::filesystem::exists(localPath)) {
|
||||||
|
availableTracks.push_back(localPath.string());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::filesystem::path cwdPath = std::filesystem::current_path() / "assets" / track;
|
||||||
|
if (std::filesystem::exists(cwdPath)) {
|
||||||
|
availableTracks.push_back(cwdPath.string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
music->playFilePath(path, true);
|
|
||||||
musicPlaying = music->isPlaying();
|
if (!availableTracks.empty()) {
|
||||||
|
std::uniform_int_distribution<size_t> pick(0, availableTracks.size() - 1);
|
||||||
|
const std::string& path = availableTracks[pick(rng)];
|
||||||
|
music->playFilePath(path, true);
|
||||||
|
LOG_INFO("AuthScreen: Playing login intro track: ", path);
|
||||||
|
musicPlaying = music->isPlaying();
|
||||||
|
} else {
|
||||||
|
LOG_WARNING("AuthScreen: No login intro tracks found in assets/");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue