mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-03 08:03:50 +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 shutdown();
|
||||||
|
|
||||||
void playMusic(const std::string& mpqPath, bool loop = true);
|
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 stopMusic(float fadeMs = 2000.0f);
|
||||||
void crossfadeTo(const std::string& mpqPath, float fadeMs = 3000.0f);
|
void crossfadeTo(const std::string& mpqPath, float fadeMs = 3000.0f);
|
||||||
void update(float deltaTime);
|
void update(float deltaTime);
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,7 @@ public:
|
||||||
double getLastTerrainRenderMs() const { return lastTerrainRenderMs; }
|
double getLastTerrainRenderMs() const { return lastTerrainRenderMs; }
|
||||||
double getLastWMORenderMs() const { return lastWMORenderMs; }
|
double getLastWMORenderMs() const { return lastWMORenderMs; }
|
||||||
double getLastM2RenderMs() const { return lastM2RenderMs; }
|
double getLastM2RenderMs() const { return lastM2RenderMs; }
|
||||||
|
audio::MusicManager* getMusicManager() { return musicManager.get(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
core::Window* window = nullptr;
|
core::Window* window = nullptr;
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,8 @@ public:
|
||||||
*/
|
*/
|
||||||
bool isAuthenticating() const { return authenticating; }
|
bool isAuthenticating() const { return authenticating; }
|
||||||
|
|
||||||
|
void stopLoginMusic();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get status message
|
* Get status message
|
||||||
*/
|
*/
|
||||||
|
|
@ -88,6 +90,9 @@ private:
|
||||||
// Background video
|
// Background video
|
||||||
bool videoInitAttempted = false;
|
bool videoInitAttempted = false;
|
||||||
rendering::VideoPlayer backgroundVideo;
|
rendering::VideoPlayer backgroundVideo;
|
||||||
|
|
||||||
|
bool musicInitAttempted = false;
|
||||||
|
bool musicPlaying = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
}} // namespace wowee::ui
|
}} // 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 MusicManager::stopMusic(float fadeMs) {
|
||||||
(void)fadeMs; // ffplay doesn't support fade easily
|
(void)fadeMs; // ffplay doesn't support fade easily
|
||||||
stopCurrentProcess();
|
stopCurrentProcess();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
#include "ui/auth_screen.hpp"
|
#include "ui/auth_screen.hpp"
|
||||||
#include "auth/crypto.hpp"
|
#include "auth/crypto.hpp"
|
||||||
|
#include "core/application.hpp"
|
||||||
#include "core/logger.hpp"
|
#include "core/logger.hpp"
|
||||||
|
#include "rendering/renderer.hpp"
|
||||||
|
#include "pipeline/asset_manager.hpp"
|
||||||
|
#include "audio/music_manager.hpp"
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <fstream>
|
#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::SetNextWindowSize(ImVec2(500, 400), ImGuiCond_FirstUseEver);
|
||||||
ImGui::Begin("WoW 3.3.5a Authentication", nullptr, ImGuiWindowFlags_NoCollapse);
|
ImGui::Begin("WoW 3.3.5a Authentication", nullptr, ImGuiWindowFlags_NoCollapse);
|
||||||
|
|
||||||
|
|
@ -197,6 +218,17 @@ void AuthScreen::render(auth::AuthHandler& authHandler) {
|
||||||
ImGui::End();
|
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) {
|
void AuthScreen::attemptAuth(auth::AuthHandler& authHandler) {
|
||||||
// Validate inputs
|
// Validate inputs
|
||||||
if (strlen(username) == 0) {
|
if (strlen(username) == 0) {
|
||||||
|
|
|
||||||
|
|
@ -97,30 +97,35 @@ void UIManager::render(core::AppState appState, auth::AuthHandler* authHandler,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case core::AppState::REALM_SELECTION:
|
case core::AppState::REALM_SELECTION:
|
||||||
|
authScreen->stopLoginMusic();
|
||||||
if (authHandler) {
|
if (authHandler) {
|
||||||
realmScreen->render(*authHandler);
|
realmScreen->render(*authHandler);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case core::AppState::CHARACTER_CREATION:
|
case core::AppState::CHARACTER_CREATION:
|
||||||
|
authScreen->stopLoginMusic();
|
||||||
if (gameHandler) {
|
if (gameHandler) {
|
||||||
characterCreateScreen->render(*gameHandler);
|
characterCreateScreen->render(*gameHandler);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case core::AppState::CHARACTER_SELECTION:
|
case core::AppState::CHARACTER_SELECTION:
|
||||||
|
authScreen->stopLoginMusic();
|
||||||
if (gameHandler) {
|
if (gameHandler) {
|
||||||
characterScreen->render(*gameHandler);
|
characterScreen->render(*gameHandler);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case core::AppState::IN_GAME:
|
case core::AppState::IN_GAME:
|
||||||
|
authScreen->stopLoginMusic();
|
||||||
if (gameHandler) {
|
if (gameHandler) {
|
||||||
gameScreen->render(*gameHandler);
|
gameScreen->render(*gameHandler);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case core::AppState::DISCONNECTED:
|
case core::AppState::DISCONNECTED:
|
||||||
|
authScreen->stopLoginMusic();
|
||||||
// Show disconnected message
|
// Show disconnected message
|
||||||
ImGui::SetNextWindowSize(ImVec2(400, 150), ImGuiCond_Always);
|
ImGui::SetNextWindowSize(ImVec2(400, 150), ImGuiCond_Always);
|
||||||
ImGui::SetNextWindowPos(ImVec2(ImGui::GetIO().DisplaySize.x * 0.5f - 200,
|
ImGui::SetNextWindowPos(ImVec2(ImGui::GetIO().DisplaySize.x * 0.5f - 200,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue