mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-02-02 11:51:25 +00:00
Allow DEFining music for which there is no CON music; Add 'music' OSD command.
The OSD command is invoked like "music E5L3" (case insensitively). git-svn-id: https://svn.eduke32.com/eduke32@4587 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
73a252a73e
commit
3dc5c9e144
3 changed files with 105 additions and 26 deletions
|
@ -8532,6 +8532,20 @@ int32_t G_StartRTS(int32_t i, int localp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void G_StartMusic(void)
|
||||||
|
{
|
||||||
|
const int32_t i = g_musicIndex;
|
||||||
|
Bassert(MapInfo[i].musicfn != NULL);
|
||||||
|
|
||||||
|
{
|
||||||
|
int32_t res = S_PlayMusic(MapInfo[i].musicfn, i);
|
||||||
|
|
||||||
|
Bsnprintf(ScriptQuotes[QUOTE_MUSIC], MAXQUOTELEN, "Playing %s",
|
||||||
|
res ? MapInfo[i].alt_musicfn : MapInfo[i].musicfn);
|
||||||
|
P_DoQuote(QUOTE_MUSIC, g_player[myconnectindex].ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void G_HandleLocalKeys(void)
|
void G_HandleLocalKeys(void)
|
||||||
{
|
{
|
||||||
int32_t i;
|
int32_t i;
|
||||||
|
@ -8751,7 +8765,6 @@ void G_HandleLocalKeys(void)
|
||||||
if (i == 5 && g_player[myconnectindex].ps->fta > 0 && g_player[myconnectindex].ps->ftq == QUOTE_MUSIC)
|
if (i == 5 && g_player[myconnectindex].ps->fta > 0 && g_player[myconnectindex].ps->ftq == QUOTE_MUSIC)
|
||||||
{
|
{
|
||||||
const int32_t maxi = VOLUMEALL ? MAXVOLUMES*MAXLEVELS : 6;
|
const int32_t maxi = VOLUMEALL ? MAXVOLUMES*MAXLEVELS : 6;
|
||||||
int32_t res;
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -8761,12 +8774,7 @@ void G_HandleLocalKeys(void)
|
||||||
}
|
}
|
||||||
while (MapInfo[g_musicIndex].musicfn == NULL);
|
while (MapInfo[g_musicIndex].musicfn == NULL);
|
||||||
|
|
||||||
i = g_musicIndex;
|
G_StartMusic();
|
||||||
res = S_PlayMusic(MapInfo[i].musicfn, i);
|
|
||||||
|
|
||||||
Bsnprintf(ScriptQuotes[QUOTE_MUSIC], MAXQUOTELEN, "Playing %s",
|
|
||||||
res ? MapInfo[i].alt_musicfn : MapInfo[i].musicfn);
|
|
||||||
P_DoQuote(QUOTE_MUSIC, g_player[myconnectindex].ps);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -9216,12 +9224,15 @@ static int32_t S_DefineSound(int32_t ID, const char *name)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns:
|
||||||
|
// 0: all OK
|
||||||
|
// -1: ID declaration was invalid:
|
||||||
|
// -2: map has no .musicfn (and hence will not be considered even if it has an .alt_musicfn)
|
||||||
static int32_t S_DefineMusic(const char *ID, const char *name)
|
static int32_t S_DefineMusic(const char *ID, const char *name)
|
||||||
{
|
{
|
||||||
int32_t sel = MAXVOLUMES * MAXLEVELS;
|
int32_t sel = MAXVOLUMES * MAXLEVELS;
|
||||||
|
|
||||||
if (!ID)
|
Bassert(ID != NULL);
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (!Bstrcmp(ID,"intro"))
|
if (!Bstrcmp(ID,"intro"))
|
||||||
{
|
{
|
||||||
|
@ -9239,25 +9250,34 @@ static int32_t S_DefineMusic(const char *ID, const char *name)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int32_t lev, ep;
|
sel = G_GetMusicIdx(ID);
|
||||||
char b1, b2;
|
if (sel < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
int32_t matches = sscanf(ID,"%c%d%c%d",&b1,&ep,&b2,&lev);
|
|
||||||
|
|
||||||
if (matches != 4 || Btoupper(b1) != 'E' || Btoupper(b2) != 'L' ||
|
|
||||||
(unsigned)--lev >= MAXLEVELS || (unsigned)--ep >= MAXVOLUMES)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
sel = (ep * MAXLEVELS) + lev;
|
|
||||||
ID = MapInfo[sel].musicfn;
|
ID = MapInfo[sel].musicfn;
|
||||||
}
|
}
|
||||||
|
|
||||||
MapInfo[sel].alt_musicfn = S_OggifyFilename(MapInfo[sel].alt_musicfn, name, ID);
|
{
|
||||||
// initprintf("%-15s | ",ID);
|
map_t *map = &MapInfo[sel];
|
||||||
// initprintf("%3d %2d %2d | %s\n",sel,ep,lev,MapInfo[sel].alt_musicfn);
|
const int special = (sel >= MAXVOLUMES*MAXLEVELS);
|
||||||
// S_PlayMusic(ID,sel);
|
|
||||||
|
|
||||||
return 0;
|
map->alt_musicfn = S_OggifyFilename(map->alt_musicfn, name, ID);
|
||||||
|
|
||||||
|
// If we are given a music file name for a proper level that has no
|
||||||
|
// primary music defined, set it up as both.
|
||||||
|
if (map->alt_musicfn == NULL && !special && ID == 0 && name)
|
||||||
|
{
|
||||||
|
map->musicfn = dup_filename(name);
|
||||||
|
map->alt_musicfn = dup_filename(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// initprintf("%-15s | ",ID);
|
||||||
|
// initprintf("%3d %2d %2d | %s\n",sel,ep,lev,MapInfo[sel].alt_musicfn);
|
||||||
|
// S_PlayMusic(ID,sel);
|
||||||
|
|
||||||
|
return map->musicfn || special ? 0 : -2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t parsedefinitions_game(scriptfile *script, int32_t preload);
|
static int32_t parsedefinitions_game(scriptfile *script, int32_t preload);
|
||||||
|
@ -9388,17 +9408,26 @@ static int32_t parsedefinitions_game(scriptfile *script, int32_t preload)
|
||||||
}
|
}
|
||||||
if (!preload)
|
if (!preload)
|
||||||
{
|
{
|
||||||
|
int32_t res;
|
||||||
|
|
||||||
if (ID==NULL)
|
if (ID==NULL)
|
||||||
{
|
{
|
||||||
initprintf("Error: missing ID for music definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr));
|
initprintf("Error: missing ID for music definition near line %s:%d\n",
|
||||||
|
script->filename, scriptfile_getlinum(script,tinttokptr));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (check_file_exist(fn))
|
if (check_file_exist(fn))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (S_DefineMusic(ID,fn))
|
res = S_DefineMusic(ID, fn);
|
||||||
initprintf("Error: invalid music ID on line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr));
|
|
||||||
|
if (res == -1)
|
||||||
|
initprintf("Error: invalid music ID on line %s:%d\n",
|
||||||
|
script->filename, scriptfile_getlinum(script,tinttokptr));
|
||||||
|
else if (res == -2)
|
||||||
|
initprintf("Error: %s has no primary (CON) music on line %s:%d\n",
|
||||||
|
ID, script->filename, scriptfile_getlinum(script,tinttokptr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -563,4 +563,22 @@ static inline void G_NewGame_EnterLevel(void)
|
||||||
G_BackToMenu();
|
G_BackToMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int32_t G_GetMusicIdx(const char *str)
|
||||||
|
{
|
||||||
|
int32_t lev, ep;
|
||||||
|
char b1, b2;
|
||||||
|
|
||||||
|
int32_t matches = sscanf(str, "%c%d%c%d", &b1,&ep, &b2,&lev);
|
||||||
|
|
||||||
|
if (matches != 4 || Btoupper(b1) != 'E' || Btoupper(b2) != 'L')
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if ((unsigned)--lev >= MAXLEVELS || (unsigned)--ep >= MAXVOLUMES)
|
||||||
|
return -2;
|
||||||
|
|
||||||
|
return (ep * MAXLEVELS) + lev;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern void G_StartMusic(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -384,6 +384,37 @@ static int32_t osdcmd_restartsound(const osdfuncparm_t *parm)
|
||||||
return OSDCMD_OK;
|
return OSDCMD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t osdcmd_music(const osdfuncparm_t *parm)
|
||||||
|
{
|
||||||
|
if (parm->numparms == 1)
|
||||||
|
{
|
||||||
|
int32_t sel = G_GetMusicIdx(parm->parms[0]);
|
||||||
|
|
||||||
|
if (sel == -1)
|
||||||
|
return OSDCMD_SHOWHELP;
|
||||||
|
|
||||||
|
if (sel == -2)
|
||||||
|
{
|
||||||
|
OSD_Printf("%s is not a valid episode/level number pair\n", parm->parms[0]);
|
||||||
|
return OSDCMD_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MapInfo[sel].musicfn != NULL)
|
||||||
|
{
|
||||||
|
g_musicIndex = sel;
|
||||||
|
G_StartMusic();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OSD_Printf("No music defined for %s\n", parm->parms[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return OSDCMD_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return OSDCMD_SHOWHELP;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t osdcmd_restartvid(const osdfuncparm_t *parm)
|
int32_t osdcmd_restartvid(const osdfuncparm_t *parm)
|
||||||
{
|
{
|
||||||
UNREFERENCED_PARAMETER(parm);
|
UNREFERENCED_PARAMETER(parm);
|
||||||
|
@ -1640,6 +1671,7 @@ int32_t registerosdcommands(void)
|
||||||
|
|
||||||
OSD_RegisterFunction("listplayers","listplayers: lists currently connected multiplayer clients", osdcmd_listplayers);
|
OSD_RegisterFunction("listplayers","listplayers: lists currently connected multiplayer clients", osdcmd_listplayers);
|
||||||
#endif
|
#endif
|
||||||
|
OSD_RegisterFunction("music","music E<ep>L<lev>: change music", osdcmd_music);
|
||||||
OSD_RegisterFunction("name","name: change your multiplayer nickname", osdcmd_name);
|
OSD_RegisterFunction("name","name: change your multiplayer nickname", osdcmd_name);
|
||||||
OSD_RegisterFunction("noclip","noclip: toggles clipping mode", osdcmd_noclip);
|
OSD_RegisterFunction("noclip","noclip: toggles clipping mode", osdcmd_noclip);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue