mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 07:40:14 +00:00
Smooth login music start and lower auth-screen volume
Add configurable fade-in support to MusicManager playback paths and use it for auth/login intro tracks to avoid abrupt starts. Apply a login-only 20% music attenuation while the auth screen is active, then restore the previous music volume when leaving login so in-game volume remains unchanged.
This commit is contained in:
parent
3368dbb9ec
commit
44a947163d
4 changed files with 90 additions and 20 deletions
|
|
@ -211,6 +211,14 @@ void AuthScreen::render(auth::AuthHandler& authHandler) {
|
|||
if (renderer) {
|
||||
auto* music = renderer->getMusicManager();
|
||||
if (music) {
|
||||
if (!loginMusicVolumeAdjusted_) {
|
||||
savedMusicVolume_ = music->getVolume();
|
||||
int loginVolume = (savedMusicVolume_ * 80) / 100; // reduce auth music by 20%
|
||||
if (loginVolume < 0) loginVolume = 0;
|
||||
if (loginVolume > 100) loginVolume = 100;
|
||||
music->setVolume(loginVolume);
|
||||
loginMusicVolumeAdjusted_ = true;
|
||||
}
|
||||
music->update(ImGui::GetIO().DeltaTime);
|
||||
if (!music->isPlaying()) {
|
||||
static std::mt19937 rng(std::random_device{}());
|
||||
|
|
@ -253,7 +261,7 @@ void AuthScreen::render(auth::AuthHandler& authHandler) {
|
|||
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);
|
||||
music->playFilePath(path, true, 1800.0f);
|
||||
LOG_INFO("AuthScreen: Playing login intro track: ", path);
|
||||
musicPlaying = music->isPlaying();
|
||||
} else {
|
||||
|
|
@ -477,14 +485,19 @@ void AuthScreen::render(auth::AuthHandler& authHandler) {
|
|||
}
|
||||
|
||||
void AuthScreen::stopLoginMusic() {
|
||||
if (!musicPlaying) return;
|
||||
auto& app = core::Application::getInstance();
|
||||
auto* renderer = app.getRenderer();
|
||||
if (!renderer) return;
|
||||
auto* music = renderer->getMusicManager();
|
||||
if (!music) return;
|
||||
music->stopMusic(500.0f);
|
||||
musicPlaying = false;
|
||||
if (musicPlaying) {
|
||||
music->stopMusic(500.0f);
|
||||
musicPlaying = false;
|
||||
}
|
||||
if (loginMusicVolumeAdjusted_) {
|
||||
music->setVolume(savedMusicVolume_);
|
||||
loginMusicVolumeAdjusted_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
void AuthScreen::attemptAuth(auth::AuthHandler& authHandler) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue