mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-26 14:30:48 +00:00
Fix shuffle playback and it's menu integration.
This commit is contained in:
parent
2406597356
commit
4a602227d1
3 changed files with 27 additions and 27 deletions
|
@ -1199,29 +1199,22 @@ CDShuffleFunc(void *unused)
|
|||
Cvar_SetValue("cd_shuffle", s_options_cdshuffle_box.curvalue);
|
||||
|
||||
#ifdef OGG
|
||||
cvar_t *ogg;
|
||||
ogg = Cvar_Get("ogg_enable", "1", CVAR_ARCHIVE);
|
||||
cvar_t *ogg_enable= Cvar_Get("ogg_enable", "1", CVAR_ARCHIVE);
|
||||
int track = (int)strtol(cl.configstrings[CS_CDTRACK], (char **)NULL, 10);
|
||||
|
||||
if (s_options_cdshuffle_box.curvalue)
|
||||
{
|
||||
Cvar_Set("ogg_sequence", "random");
|
||||
|
||||
if (ogg->value)
|
||||
{
|
||||
OGG_PlayTrack(-1);
|
||||
}
|
||||
Cvar_Set("cd_shuffle", "1");
|
||||
}
|
||||
else
|
||||
{
|
||||
Cvar_Set("ogg_sequence", "loop");
|
||||
|
||||
if (ogg->value)
|
||||
{
|
||||
int track = (int)strtol(cl.configstrings[CS_CDTRACK], (char **)NULL, 10);
|
||||
OGG_PlayTrack(track);
|
||||
}
|
||||
Cvar_Set("cd_shuffle", "0");
|
||||
}
|
||||
|
||||
if (ogg_enable->value)
|
||||
{
|
||||
OGG_PlayTrack(track);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1249,6 +1242,7 @@ EnableOGGMusic(void *unused)
|
|||
CDAudio_Stop();
|
||||
#endif
|
||||
OGG_Init();
|
||||
OGG_InitTrackList();
|
||||
OGG_Stop();
|
||||
|
||||
int track = (int)strtol(cl.configstrings[CS_CDTRACK], (char **)NULL, 10);
|
||||
|
|
|
@ -39,6 +39,7 @@ typedef enum
|
|||
STOP
|
||||
} ogg_status_t;
|
||||
|
||||
void OGG_InitTrackList(void);
|
||||
void OGG_Init(void);
|
||||
void OGG_PlayTrack(int track);
|
||||
void OGG_Read(void);
|
||||
|
|
|
@ -41,16 +41,17 @@
|
|||
#include "header/local.h"
|
||||
#include "header/vorbis.h"
|
||||
|
||||
static char ovBuf[4096]; /* Buffer for sound. */
|
||||
static cvar_t *ogg_ignoretrack0; /* Toggle track 0 playing */
|
||||
static cvar_t *ogg_volume; /* Music volume. */
|
||||
static int ogg_curfile; /* Index of currently played file. */
|
||||
static int ogg_numbufs; /* Number of buffers for OpenAL */
|
||||
static int ovSection; /* Position in Ogg Vorbis file. */
|
||||
static ogg_status_t ogg_status; /* Status indicator. */
|
||||
static OggVorbis_File ovFile; /* Ogg Vorbis file. */
|
||||
static qboolean ogg_started = false; /* Initialization flag. */
|
||||
static vorbis_info *ogg_info; /* Ogg Vorbis file information */
|
||||
static char ovBuf[4096]; /* Buffer for sound. */
|
||||
static cvar_t *cd_shuffle; /* Shuffle playback */
|
||||
static cvar_t *ogg_ignoretrack0; /* Toggle track 0 playing */
|
||||
static cvar_t *ogg_volume; /* Music volume. */
|
||||
static int ogg_curfile; /* Index of currently played file. */
|
||||
static int ogg_numbufs; /* Number of buffers for OpenAL */
|
||||
static int ovSection; /* Position in Ogg Vorbis file. */
|
||||
static ogg_status_t ogg_status; /* Status indicator. */
|
||||
static OggVorbis_File ovFile; /* Ogg Vorbis file. */
|
||||
static qboolean ogg_started; /* Initialization flag. */
|
||||
static vorbis_info *ogg_info; /* Ogg Vorbis file information */
|
||||
|
||||
enum { MAX_NUM_OGGTRACKS = 32 };
|
||||
static char* oggTracks[MAX_NUM_OGGTRACKS];
|
||||
|
@ -286,6 +287,7 @@ OGG_Stream(void)
|
|||
void
|
||||
OGG_PlayTrack(int trackNo)
|
||||
{
|
||||
// Track 0 means "stop music".
|
||||
if(trackNo == 0)
|
||||
{
|
||||
if(ogg_ignoretrack0->value == 0)
|
||||
|
@ -294,7 +296,9 @@ OGG_PlayTrack(int trackNo)
|
|||
return;
|
||||
}
|
||||
}
|
||||
else if(trackNo == -1) // random track
|
||||
|
||||
// Player has requested shuffle playback.
|
||||
if(cd_shuffle->value)
|
||||
{
|
||||
if(oggMaxFileIndex >= 0)
|
||||
{
|
||||
|
@ -546,8 +550,9 @@ OGG_Init(void)
|
|||
}
|
||||
|
||||
// Cvars
|
||||
ogg_volume = Cvar_Get("ogg_volume", "0.7", CVAR_ARCHIVE);
|
||||
cd_shuffle = Cvar_Get("cd_shuffle", "0", CVAR_ARCHIVE);
|
||||
ogg_ignoretrack0 = Cvar_Get("ogg_ignoretrack0", "0", CVAR_ARCHIVE);
|
||||
ogg_volume = Cvar_Get("ogg_volume", "0.7", CVAR_ARCHIVE);
|
||||
|
||||
// Commands
|
||||
Cmd_AddCommand("ogg", OGG_Cmd);
|
||||
|
|
Loading…
Reference in a new issue