Merge branch 'streamer-music-mode' into 'master'

Add streamer safe music mode

Closes #1334

See merge request KartKrew/Kart!2327
This commit is contained in:
Oni 2024-05-01 01:06:17 +00:00
commit 637f936732
6 changed files with 29 additions and 2 deletions

View file

@ -318,6 +318,7 @@ void Captioning_OnChange(void);
consvar_t cv_closedcaptioning = Player("closedcaptioning", "Off").on_off().onchange(Captioning_OnChange); consvar_t cv_closedcaptioning = Player("closedcaptioning", "Off").on_off().onchange(Captioning_OnChange);
consvar_t cv_continuousmusic = Player("continuousmusic", "On").on_off(); consvar_t cv_continuousmusic = Player("continuousmusic", "On").on_off();
consvar_t cv_streamersafemusic = Player("streamersafemusic", "Off").on_off();
consvar_t cv_controlperkey = Player("controlperkey", "One").values({{1, "One"}, {2, "Several"}}); consvar_t cv_controlperkey = Player("controlperkey", "One").values({{1, "One"}, {2, "Several"}});
// actual general (maximum) sound & music volume, saved into the config // actual general (maximum) sound & music volume, saved into the config

View file

@ -292,6 +292,9 @@ menuitem_t OPTIONS_Sound[] =
{IT_STRING | IT_CVAR, "Continuous Attack Music", "Keep music playing seamlessly when retrying in Attack modes.", {IT_STRING | IT_CVAR, "Continuous Attack Music", "Keep music playing seamlessly when retrying in Attack modes.",
NULL, {.cvar = &cv_continuousmusic}, 0, 0}, NULL, {.cvar = &cv_continuousmusic}, 0, 0},
{IT_STRING | IT_CVAR, "Streamer-Safe Music", "Only play music safe for video platforms.",
NULL, {.cvar = &cv_streamersafemusic}, 0, 0},
{IT_SPACE | IT_DYBIGSPACE, NULL, NULL, {IT_SPACE | IT_DYBIGSPACE, NULL, NULL,
NULL, {NULL}, 0, 0}, NULL, {NULL}, 0, 0},

View file

@ -81,7 +81,12 @@ void TuneManager::tick()
{ {
if (load()) if (load())
{ {
I_PlaySong(tune->loop); musicdef_t* def = find_musicdef();
if (!cv_streamersafemusic.value || (def != nullptr && !def->contentidunsafe))
{
I_PlaySong(tune->loop);
}
I_FadeSongFromVolume( I_FadeSongFromVolume(
tune->use_level_volume ? level_volume_ : 100, tune->use_level_volume ? level_volume_ : 100,
0, 0,
@ -151,7 +156,11 @@ void TuneManager::pause_unpause() const
} }
else else
{ {
I_ResumeSong(); musicdef_t* def = find_musicdef();
if (!cv_streamersafemusic.value || (def != nullptr && !def->contentidunsafe))
{
I_ResumeSong();
}
} }
} }
} }
@ -168,6 +177,12 @@ bool TuneManager::load() const
return I_LoadSong(static_cast<char*>(W_CacheLumpNum(lumpnum, PU_MUSIC)), W_LumpLength(lumpnum)); return I_LoadSong(static_cast<char*>(W_CacheLumpNum(lumpnum, PU_MUSIC)), W_LumpLength(lumpnum));
} }
musicdef_t* TuneManager::find_musicdef() const
{
uint8_t index = 0;
return S_FindMusicDef(current_song_.c_str(), &index);
}
void TuneManager::adjust_volume() const void TuneManager::adjust_volume() const
{ {
UINT8 i; UINT8 i;

View file

@ -121,6 +121,7 @@ private:
} }
bool load() const; bool load() const;
musicdef_t* find_musicdef() const;
void adjust_volume() const; void adjust_volume() const;
bool resync(); bool resync();

View file

@ -2041,6 +2041,11 @@ ReadMusicDefFields
textline[0] = toupper(textline[0]); textline[0] = toupper(textline[0]);
def->important = (textline[0] == 'Y' || textline[0] == 'T' || textline[0] == '1'); def->important = (textline[0] == 'Y' || textline[0] == 'T' || textline[0] == '1');
} }
else if (!stricmp(stoken, "contentidunsafe"))
{
textline[0] = toupper(textline[0]);
def->contentidunsafe = (textline[0] == 'Y' || textline[0] == 'T' || textline[0] == '1');
}
else else
{ {
MusicDefError(CONS_WARNING, MusicDefError(CONS_WARNING,

View file

@ -43,6 +43,7 @@ extern consvar_t cv_gamedigimusic;
extern consvar_t cv_gamesounds; extern consvar_t cv_gamesounds;
extern consvar_t cv_bgaudio; extern consvar_t cv_bgaudio;
extern consvar_t cv_streamersafemusic;
typedef enum typedef enum
{ {
@ -171,6 +172,7 @@ struct musicdef_t
int volume; int volume;
int debug_volume; int debug_volume;
boolean important; boolean important;
boolean contentidunsafe;
musicdef_t *next; musicdef_t *next;
soundtestsequence_t sequence; soundtestsequence_t sequence;
}; };