mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-26 12:21:39 +00:00
Implement installer music. (#463)
This commit is contained in:
parent
98daa27c14
commit
0128377ad9
6 changed files with 52 additions and 4 deletions
|
|
@ -553,6 +553,7 @@ BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/images/ga
|
||||||
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/images/game_icon_night.bmp" DEST_FILE "${RESOURCES_OUTPUT_PATH}/images/game_icon_night.bmp" ARRAY_NAME "g_game_icon_night")
|
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/images/game_icon_night.bmp" DEST_FILE "${RESOURCES_OUTPUT_PATH}/images/game_icon_night.bmp" ARRAY_NAME "g_game_icon_night")
|
||||||
|
|
||||||
## Audio ##
|
## Audio ##
|
||||||
|
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/music/installer.ogg" DEST_FILE "${RESOURCES_OUTPUT_PATH}/music/installer.ogg" ARRAY_NAME "g_installer_music")
|
||||||
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/sounds/sys_worldmap_cursor.ogg" DEST_FILE "${RESOURCES_OUTPUT_PATH}/sounds/sys_worldmap_cursor.ogg" ARRAY_NAME "g_sys_worldmap_cursor")
|
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/sounds/sys_worldmap_cursor.ogg" DEST_FILE "${RESOURCES_OUTPUT_PATH}/sounds/sys_worldmap_cursor.ogg" ARRAY_NAME "g_sys_worldmap_cursor")
|
||||||
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/sounds/sys_worldmap_finaldecide.ogg" DEST_FILE "${RESOURCES_OUTPUT_PATH}/sounds/sys_worldmap_finaldecide.ogg" ARRAY_NAME "g_sys_worldmap_finaldecide")
|
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/sounds/sys_worldmap_finaldecide.ogg" DEST_FILE "${RESOURCES_OUTPUT_PATH}/sounds/sys_worldmap_finaldecide.ogg" ARRAY_NAME "g_sys_worldmap_finaldecide")
|
||||||
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/sounds/sys_actstg_pausecansel.ogg" DEST_FILE "${RESOURCES_OUTPUT_PATH}/sounds/sys_actstg_pausecansel.ogg" ARRAY_NAME "g_sys_actstg_pausecansel")
|
BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/sounds/sys_actstg_pausecansel.ogg" DEST_FILE "${RESOURCES_OUTPUT_PATH}/sounds/sys_actstg_pausecansel.ogg" ARRAY_NAME "g_sys_actstg_pausecansel")
|
||||||
|
|
|
||||||
|
|
@ -86,8 +86,8 @@
|
||||||
#include "SWA/Inspire/InspireTextureAnimationInfo.h"
|
#include "SWA/Inspire/InspireTextureAnimationInfo.h"
|
||||||
#include "SWA/Inspire/InspireTextureOverlay.h"
|
#include "SWA/Inspire/InspireTextureOverlay.h"
|
||||||
#include "SWA/Inspire/InspireTextureOverlayInfo.h"
|
#include "SWA/Inspire/InspireTextureOverlayInfo.h"
|
||||||
#include "SWA/Message/MsgRequestHelp.h"
|
|
||||||
#include "SWA/Menu/MenuWindowBase.h"
|
#include "SWA/Menu/MenuWindowBase.h"
|
||||||
|
#include "SWA/Message/MsgRequestHelp.h"
|
||||||
#include "SWA/Movie/MovieDisplayer.h"
|
#include "SWA/Movie/MovieDisplayer.h"
|
||||||
#include "SWA/Movie/MovieManager.h"
|
#include "SWA/Movie/MovieManager.h"
|
||||||
#include "SWA/Object/Common/DashPanel/ObjDashPanel.h"
|
#include "SWA/Object/Common/DashPanel/ObjDashPanel.h"
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#include <apu/embedded_player.h>
|
#include <apu/embedded_player.h>
|
||||||
#include <user/config.h>
|
#include <user/config.h>
|
||||||
|
|
||||||
|
#include <res/music/installer.ogg.h>
|
||||||
#include <res/sounds/sys_worldmap_cursor.ogg.h>
|
#include <res/sounds/sys_worldmap_cursor.ogg.h>
|
||||||
#include <res/sounds/sys_worldmap_finaldecide.ogg.h>
|
#include <res/sounds/sys_worldmap_finaldecide.ogg.h>
|
||||||
#include <res/sounds/sys_actstg_pausecansel.ogg.h>
|
#include <res/sounds/sys_actstg_pausecansel.ogg.h>
|
||||||
|
|
@ -87,13 +88,17 @@ static void PlayEmbeddedSound(EmbeddedSound s)
|
||||||
data.chunk = Mix_LoadWAV_RW(SDL_RWFromConstMem(soundData, soundDataSize), 1);
|
data.chunk = Mix_LoadWAV_RW(SDL_RWFromConstMem(soundData, soundDataSize), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Mix_VolumeChunk(data.chunk, Config::MasterVolume * Config::EffectsVolume * MIX_MAX_VOLUME);
|
||||||
Mix_PlayChannel(g_channelIndex % MIX_CHANNELS, data.chunk, 0);
|
Mix_PlayChannel(g_channelIndex % MIX_CHANNELS, data.chunk, 0);
|
||||||
++g_channelIndex;
|
++g_channelIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Mix_Music* g_installerMusic;
|
||||||
|
|
||||||
void EmbeddedPlayer::Init()
|
void EmbeddedPlayer::Init()
|
||||||
{
|
{
|
||||||
Mix_OpenAudio(XAUDIO_SAMPLES_HZ, AUDIO_F32SYS, 2, 256);
|
Mix_OpenAudio(XAUDIO_SAMPLES_HZ, AUDIO_F32SYS, 2, 2048);
|
||||||
|
g_installerMusic = Mix_LoadMUS_RW(SDL_RWFromConstMem(g_installer_music, sizeof(g_installer_music)), 1);
|
||||||
|
|
||||||
s_isActive = true;
|
s_isActive = true;
|
||||||
}
|
}
|
||||||
|
|
@ -111,6 +116,21 @@ void EmbeddedPlayer::Play(const char *name)
|
||||||
PlayEmbeddedSound(it->second);
|
PlayEmbeddedSound(it->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EmbeddedPlayer::PlayMusic()
|
||||||
|
{
|
||||||
|
if (!Mix_PlayingMusic())
|
||||||
|
{
|
||||||
|
Mix_PlayMusic(g_installerMusic, INT_MAX);
|
||||||
|
Mix_VolumeMusic(Config::MasterVolume * Config::MusicVolume * MUSIC_VOLUME * MIX_MAX_VOLUME);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmbeddedPlayer::FadeOutMusic()
|
||||||
|
{
|
||||||
|
if (Mix_PlayingMusic())
|
||||||
|
Mix_FadeOutMusic(1000);
|
||||||
|
}
|
||||||
|
|
||||||
void EmbeddedPlayer::Shutdown()
|
void EmbeddedPlayer::Shutdown()
|
||||||
{
|
{
|
||||||
for (EmbeddedSoundData &data : g_embeddedSoundData)
|
for (EmbeddedSoundData &data : g_embeddedSoundData)
|
||||||
|
|
@ -119,6 +139,9 @@ void EmbeddedPlayer::Shutdown()
|
||||||
Mix_FreeChunk(data.chunk);
|
Mix_FreeChunk(data.chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Mix_HaltMusic();
|
||||||
|
Mix_FreeMusic(g_installerMusic);
|
||||||
|
|
||||||
Mix_CloseAudio();
|
Mix_CloseAudio();
|
||||||
Mix_Quit();
|
Mix_Quit();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,14 @@
|
||||||
|
|
||||||
struct EmbeddedPlayer
|
struct EmbeddedPlayer
|
||||||
{
|
{
|
||||||
inline static bool s_isActive = false;
|
// Arbitrarily picked volume to match the mixing in the original game.
|
||||||
|
static constexpr float MUSIC_VOLUME = 0.25f;
|
||||||
|
|
||||||
|
static inline bool s_isActive = false;
|
||||||
|
|
||||||
static void Init();
|
static void Init();
|
||||||
static void Play(const char *name);
|
static void Play(const char *name);
|
||||||
|
static void PlayMusic();
|
||||||
|
static void FadeOutMusic();
|
||||||
static void Shutdown();
|
static void Shutdown();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1721,6 +1721,24 @@ static void PickerCheckResults()
|
||||||
g_currentPickerVisible = false;
|
g_currentPickerVisible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool g_fadingOutMusic;
|
||||||
|
|
||||||
|
static void ProcessMusic()
|
||||||
|
{
|
||||||
|
if (g_isDisappearing)
|
||||||
|
{
|
||||||
|
if (!g_fadingOutMusic)
|
||||||
|
{
|
||||||
|
EmbeddedPlayer::FadeOutMusic();
|
||||||
|
g_fadingOutMusic = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EmbeddedPlayer::PlayMusic();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void InstallerWizard::Init()
|
void InstallerWizard::Init()
|
||||||
{
|
{
|
||||||
auto &io = ImGui::GetIO();
|
auto &io = ImGui::GetIO();
|
||||||
|
|
@ -1850,6 +1868,7 @@ bool InstallerWizard::Run(std::filesystem::path installPath, bool skipGame)
|
||||||
while (s_isVisible)
|
while (s_isVisible)
|
||||||
{
|
{
|
||||||
Video::WaitOnSwapChain();
|
Video::WaitOnSwapChain();
|
||||||
|
ProcessMusic();
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
SDL_FlushEvents(SDL_FIRSTEVENT, SDL_LASTEVENT);
|
SDL_FlushEvents(SDL_FIRSTEVENT, SDL_LASTEVENT);
|
||||||
GameWindow::Update();
|
GameWindow::Update();
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 1375ed71841dd391be609f9380ec456f2679463b
|
Subproject commit c6d50cced704fea609fbe93323d506c211fe8402
|
||||||
Loading…
Add table
Reference in a new issue