mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
Play tavern music file on login screen
This commit is contained in:
parent
8c3aa6542e
commit
205db7d3b6
7 changed files with 71 additions and 0 deletions
BIN
assets/20-taverns.mp3
Normal file
BIN
assets/20-taverns.mp3
Normal file
Binary file not shown.
|
|
@ -18,6 +18,7 @@ public:
|
|||
void shutdown();
|
||||
|
||||
void playMusic(const std::string& mpqPath, bool loop = true);
|
||||
void playFilePath(const std::string& filePath, bool loop = true);
|
||||
void stopMusic(float fadeMs = 2000.0f);
|
||||
void crossfadeTo(const std::string& mpqPath, float fadeMs = 3000.0f);
|
||||
void update(float deltaTime);
|
||||
|
|
|
|||
|
|
@ -130,6 +130,7 @@ public:
|
|||
double getLastTerrainRenderMs() const { return lastTerrainRenderMs; }
|
||||
double getLastWMORenderMs() const { return lastWMORenderMs; }
|
||||
double getLastM2RenderMs() const { return lastM2RenderMs; }
|
||||
audio::MusicManager* getMusicManager() { return musicManager.get(); }
|
||||
|
||||
private:
|
||||
core::Window* window = nullptr;
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ public:
|
|||
*/
|
||||
bool isAuthenticating() const { return authenticating; }
|
||||
|
||||
void stopLoginMusic();
|
||||
|
||||
/**
|
||||
* Get status message
|
||||
*/
|
||||
|
|
@ -88,6 +90,9 @@ private:
|
|||
// Background video
|
||||
bool videoInitAttempted = false;
|
||||
rendering::VideoPlayer backgroundVideo;
|
||||
|
||||
bool musicInitAttempted = false;
|
||||
bool musicPlaying = false;
|
||||
};
|
||||
|
||||
}} // namespace wowee::ui
|
||||
|
|
|
|||
|
|
@ -72,6 +72,33 @@ void MusicManager::playMusic(const std::string& mpqPath, bool loop) {
|
|||
}
|
||||
}
|
||||
|
||||
void MusicManager::playFilePath(const std::string& filePath, bool loop) {
|
||||
if (filePath.empty()) return;
|
||||
if (filePath == currentTrack && playing) return;
|
||||
|
||||
stopCurrentProcess();
|
||||
|
||||
std::vector<std::string> args;
|
||||
args.push_back("-nodisp");
|
||||
args.push_back("-autoexit");
|
||||
if (loop) {
|
||||
args.push_back("-loop");
|
||||
args.push_back("0");
|
||||
}
|
||||
args.push_back("-volume");
|
||||
args.push_back("30");
|
||||
args.push_back(filePath);
|
||||
|
||||
playerPid = platform::spawnProcess(args);
|
||||
if (playerPid != INVALID_PROCESS) {
|
||||
playing = true;
|
||||
currentTrack = filePath;
|
||||
LOG_INFO("Music: Playing file ", filePath);
|
||||
} else {
|
||||
LOG_ERROR("Music: Failed to spawn ffplay process");
|
||||
}
|
||||
}
|
||||
|
||||
void MusicManager::stopMusic(float fadeMs) {
|
||||
(void)fadeMs; // ffplay doesn't support fade easily
|
||||
stopCurrentProcess();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
#include "ui/auth_screen.hpp"
|
||||
#include "auth/crypto.hpp"
|
||||
#include "core/application.hpp"
|
||||
#include "core/logger.hpp"
|
||||
#include "rendering/renderer.hpp"
|
||||
#include "pipeline/asset_manager.hpp"
|
||||
#include "audio/music_manager.hpp"
|
||||
#include <imgui.h>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
|
|
@ -71,6 +75,23 @@ void AuthScreen::render(auth::AuthHandler& authHandler) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!musicInitAttempted) {
|
||||
musicInitAttempted = true;
|
||||
auto& app = core::Application::getInstance();
|
||||
auto* renderer = app.getRenderer();
|
||||
auto* assets = app.getAssetManager();
|
||||
if (renderer) {
|
||||
auto* music = renderer->getMusicManager();
|
||||
if (music && assets && assets->isInitialized() && !music->isInitialized()) {
|
||||
music->initialize(assets);
|
||||
}
|
||||
if (music && !musicPlaying) {
|
||||
music->playFilePath("assets/20-taverns.mp3", true);
|
||||
musicPlaying = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::SetNextWindowSize(ImVec2(500, 400), ImGuiCond_FirstUseEver);
|
||||
ImGui::Begin("WoW 3.3.5a Authentication", nullptr, ImGuiWindowFlags_NoCollapse);
|
||||
|
||||
|
|
@ -197,6 +218,17 @@ void AuthScreen::render(auth::AuthHandler& authHandler) {
|
|||
ImGui::End();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void AuthScreen::attemptAuth(auth::AuthHandler& authHandler) {
|
||||
// Validate inputs
|
||||
if (strlen(username) == 0) {
|
||||
|
|
|
|||
|
|
@ -97,30 +97,35 @@ void UIManager::render(core::AppState appState, auth::AuthHandler* authHandler,
|
|||
break;
|
||||
|
||||
case core::AppState::REALM_SELECTION:
|
||||
authScreen->stopLoginMusic();
|
||||
if (authHandler) {
|
||||
realmScreen->render(*authHandler);
|
||||
}
|
||||
break;
|
||||
|
||||
case core::AppState::CHARACTER_CREATION:
|
||||
authScreen->stopLoginMusic();
|
||||
if (gameHandler) {
|
||||
characterCreateScreen->render(*gameHandler);
|
||||
}
|
||||
break;
|
||||
|
||||
case core::AppState::CHARACTER_SELECTION:
|
||||
authScreen->stopLoginMusic();
|
||||
if (gameHandler) {
|
||||
characterScreen->render(*gameHandler);
|
||||
}
|
||||
break;
|
||||
|
||||
case core::AppState::IN_GAME:
|
||||
authScreen->stopLoginMusic();
|
||||
if (gameHandler) {
|
||||
gameScreen->render(*gameHandler);
|
||||
}
|
||||
break;
|
||||
|
||||
case core::AppState::DISCONNECTED:
|
||||
authScreen->stopLoginMusic();
|
||||
// Show disconnected message
|
||||
ImGui::SetNextWindowSize(ImVec2(400, 150), ImGuiCond_Always);
|
||||
ImGui::SetNextWindowPos(ImVec2(ImGui::GetIO().DisplaySize.x * 0.5f - 200,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue