mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-26 20:11:47 +00:00
Merge branch 'sealed-star-exit-fade' into 'master'
Sealed Star: fade out music near the finish line Closes #622 See merge request KartKrew/Kart!1842
This commit is contained in:
commit
a86f8a1508
9 changed files with 98 additions and 1 deletions
|
|
@ -10663,6 +10663,12 @@ void K_KartUpdatePosition(player_t *player)
|
||||||
player->topinfirst = 0;
|
player->topinfirst = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Special stages: fade out music near the finish line
|
||||||
|
if (P_IsLocalPlayer(player))
|
||||||
|
{
|
||||||
|
K_FadeOutSpecialMusic(player->distancetofinish);
|
||||||
|
}
|
||||||
|
|
||||||
player->position = position;
|
player->position = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
#include "z_zone.h"
|
#include "z_zone.h"
|
||||||
#include "k_waypoint.h"
|
#include "k_waypoint.h"
|
||||||
#include "k_objects.h"
|
#include "k_objects.h"
|
||||||
|
#include "music.h"
|
||||||
|
|
||||||
struct specialstageinfo specialstageinfo;
|
struct specialstageinfo specialstageinfo;
|
||||||
|
|
||||||
|
|
@ -127,6 +128,11 @@ void K_TickSpecialStage(void)
|
||||||
K_MoveExitBeam();
|
K_MoveExitBeam();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*--------------------------------------------------
|
||||||
|
mobj_t *K_GetPossibleSpecialTarget(void)
|
||||||
|
|
||||||
|
See header file for description.
|
||||||
|
--------------------------------------------------*/
|
||||||
mobj_t *K_GetPossibleSpecialTarget(void)
|
mobj_t *K_GetPossibleSpecialTarget(void)
|
||||||
{
|
{
|
||||||
if (specialstageinfo.valid == false)
|
if (specialstageinfo.valid == false)
|
||||||
|
|
@ -141,3 +147,20 @@ mobj_t *K_GetPossibleSpecialTarget(void)
|
||||||
|
|
||||||
return specialstageinfo.ufo;
|
return specialstageinfo.ufo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*--------------------------------------------------
|
||||||
|
void K_FadeOutSpecialMusic(UINT32 distance)
|
||||||
|
|
||||||
|
See header file for description.
|
||||||
|
--------------------------------------------------*/
|
||||||
|
void K_FadeOutSpecialMusic(UINT32 distance)
|
||||||
|
{
|
||||||
|
if (specialstageinfo.valid == false)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const UINT32 threshold = FixedMul(16000, mapobjectscale);
|
||||||
|
|
||||||
|
Music_LevelVolume(min(distance, threshold) * 100 / threshold);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,18 @@ void K_TickSpecialStage(void);
|
||||||
|
|
||||||
mobj_t *K_GetPossibleSpecialTarget(void);
|
mobj_t *K_GetPossibleSpecialTarget(void);
|
||||||
|
|
||||||
|
/*--------------------------------------------------
|
||||||
|
void K_FadeOutSpecialMusic(UINT32 distance)
|
||||||
|
|
||||||
|
Fade level music out at the end of a special stage.
|
||||||
|
|
||||||
|
Input Arguments:-
|
||||||
|
distance - Distance from the finish line.
|
||||||
|
|
||||||
|
--------------------------------------------------*/
|
||||||
|
|
||||||
|
void K_FadeOutSpecialMusic(UINT32 distance);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ void Music_Init(void)
|
||||||
tune.fade_out = 1500;
|
tune.fade_out = 1500;
|
||||||
tune.fade_out_inclusive = false;
|
tune.fade_out_inclusive = false;
|
||||||
tune.resume_fade_in = 750;
|
tune.resume_fade_in = 750;
|
||||||
|
tune.use_level_volume = true;
|
||||||
tune.sync = true;
|
tune.sync = true;
|
||||||
tune.credit = true;
|
tune.credit = true;
|
||||||
tune.vapes = true;
|
tune.vapes = true;
|
||||||
|
|
@ -417,3 +418,13 @@ void Music_BatchExempt(const char* id)
|
||||||
tune->resist_once = true;
|
tune->resist_once = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Music_LevelVolume(int volume)
|
||||||
|
{
|
||||||
|
g_tunes.level_volume(volume, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Music_ResetLevelVolume(void)
|
||||||
|
{
|
||||||
|
g_tunes.level_volume(100, true);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,14 @@ void Music_Loop(const char *id, boolean loop);
|
||||||
// as Music_StopAll.
|
// as Music_StopAll.
|
||||||
void Music_BatchExempt(const char *id);
|
void Music_BatchExempt(const char *id);
|
||||||
|
|
||||||
|
// Set the volume for level context. TODO: this should be
|
||||||
|
// done on a more selective basis, rather than globally.
|
||||||
|
void Music_LevelVolume(int volume);
|
||||||
|
|
||||||
|
// Reset volume back to normal. This will fade it as if the
|
||||||
|
// music is resuming after another tune ended.
|
||||||
|
void Music_ResetLevelVolume(void);
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Query properties.
|
// Query properties.
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,13 @@ void TuneManager::tick()
|
||||||
{
|
{
|
||||||
if (load())
|
if (load())
|
||||||
{
|
{
|
||||||
I_FadeInPlaySong(tune->resume ? tune->resume_fade_in : tune->fade_in, tune->loop);
|
I_PlaySong(tune->loop);
|
||||||
|
I_FadeSongFromVolume(
|
||||||
|
tune->use_level_volume ? level_volume_ : 100,
|
||||||
|
0,
|
||||||
|
tune->resume ? tune->resume_fade_in : tune->fade_in,
|
||||||
|
nullptr
|
||||||
|
);
|
||||||
seek(tune);
|
seek(tune);
|
||||||
|
|
||||||
adjust_volume();
|
adjust_volume();
|
||||||
|
|
@ -116,6 +122,19 @@ void TuneManager::tick()
|
||||||
tune->ending = true;
|
tune->ending = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (level_volume_ != old_level_volume_ && tune->use_level_volume && tune->can_fade_out)
|
||||||
|
{
|
||||||
|
if (volume_fade_)
|
||||||
|
{
|
||||||
|
I_FadeSong(level_volume_, tune->resume_fade_in, nullptr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
I_SetInternalMusicVolume(level_volume_);
|
||||||
|
}
|
||||||
|
old_level_volume_ = level_volume_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TuneManager::pause_unpause() const
|
void TuneManager::pause_unpause() const
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,15 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void level_volume(int vol, bool fade)
|
||||||
|
{
|
||||||
|
if (vol != old_level_volume_)
|
||||||
|
{
|
||||||
|
level_volume_ = vol;
|
||||||
|
volume_fade_ = fade;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unordered_map<std::string, Tune> map_;
|
std::unordered_map<std::string, Tune> map_;
|
||||||
std::string current_song_;
|
std::string current_song_;
|
||||||
|
|
@ -99,6 +108,10 @@ private:
|
||||||
|
|
||||||
bool gme_; // hack
|
bool gme_; // hack
|
||||||
|
|
||||||
|
int level_volume_ = 100;
|
||||||
|
int old_level_volume_ = 100;
|
||||||
|
bool volume_fade_ = false;
|
||||||
|
|
||||||
decltype(map_)::const_iterator current_iterator() const
|
decltype(map_)::const_iterator current_iterator() const
|
||||||
{
|
{
|
||||||
return std::max_element(
|
return std::max_element(
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,9 @@ public:
|
||||||
// resumes.
|
// resumes.
|
||||||
int resume_fade_in = 0;
|
int resume_fade_in = 0;
|
||||||
|
|
||||||
|
// Adjust volume based on level context.
|
||||||
|
bool use_level_volume = false;
|
||||||
|
|
||||||
// Sync this tune to game logic.
|
// Sync this tune to game logic.
|
||||||
bool sync = false;
|
bool sync = false;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8205,6 +8205,8 @@ void P_LoadLevelMusic(void)
|
||||||
tic_t level_music_start = starttime + (TICRATE/2);
|
tic_t level_music_start = starttime + (TICRATE/2);
|
||||||
Music_Seek("level", (std::max(leveltime, level_music_start) - level_music_start) * 1000UL / TICRATE);
|
Music_Seek("level", (std::max(leveltime, level_music_start) - level_music_start) * 1000UL / TICRATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Music_ResetLevelVolume();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Loads a level from a lump or external wad.
|
/** Loads a level from a lump or external wad.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue