- --(no)sound toggles sound initialization (to explicitly disable sound)

- --(no)shadows toggles shadows (instead of --shadows yes/no)
- Removed unused functions from warzoneconfig


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@680 4a71c877-e1ca-e34f-864e-861f7616d084
master
Dennis Schridde 2006-09-03 12:41:55 +00:00
parent de5553bd9f
commit 1607f7e194
6 changed files with 70 additions and 63 deletions

View File

@ -266,10 +266,12 @@ BOOL closeWarzoneKey( void )
return TRUE;
}
///
// =======================================================================================================================
// =======================================================================================================================
//
/**
* Read config setting pName into val
* \param *pName Config setting
* \param *val Place where to store the setting
* \return Whether we succeed to find the setting
*/
BOOL getWarzoneKeyNumeric( STRING *pName, DWORD *val )
{
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -29,6 +29,9 @@
#include "cheat.h"
#include "init.h"
// For setting shadows and sound options
#include "lib/framework/configfile.h"
extern BOOL NETsetupTCPIP(LPVOID *addr, char * machine);
extern BOOL scanGameSpyFlags(LPSTR gflag,LPSTR value);
@ -42,10 +45,6 @@ void debug_callback_file( void**, const char * );
void debug_callback_file_init( void** );
void debug_callback_file_exit( void** );
// Functions for --shadow toggle
void setDrawShadows( BOOL val );
BOOL setWarzoneKeyNumeric( STRING *pName, DWORD val );
//! Whether to play the intro video
BOOL clIntroVideo;
@ -103,7 +102,9 @@ BOOL ParseCommandLineEarly(int argc, char** argv)
" --window Play in windowed mode\n"
" --version Output version info and exit\n"
" --viewport WIDTHxHEIGHT Set the dimensions of the viewport (screen or window)\n"
" --shadows YES/NO Toggles the shadows\n" );
" --(no)shadows Toggles the shadows\n"
" --(no)sound Toggles the sound\n"
);
return FALSE;
}
else if ( stricmp(tokenType, "--datadir") == 0 )
@ -246,26 +247,28 @@ BOOL ParseCommandLine(int argc, char** argv)
strncat(saveGameName, token, 240);
SetGameMode(GS_SAVEGAMELOAD);
}
else if ( stricmp( tokenType,"--shadows") == 0 )
else if ( stricmp( tokenType, "--shadows" ) == 0 )
{
token = argv[++i];
if ( stricmp( token, "yes" ) == 0 )
{
setDrawShadows( TRUE );
setWarzoneKeyNumeric( "shadows", TRUE );
}
else if ( stricmp( token, "no" ) == 0 )
{
setDrawShadows( FALSE );
setWarzoneKeyNumeric( "shadows", FALSE );
}
else
{
debug( LOG_ERROR, "Shadow toggle must be \"yes\" or \"no\"! Aborting!" );
return FALSE;
}
// FIXME Should setDrawShadows go into warzoneconfig? Or how should config values be handled in general? By the system using it? Or by warzoneconfig? Or by config keys only?
//setDrawShadows( TRUE );
setWarzoneKeyNumeric( "shadows", TRUE );
}
else if ( stricmp(tokenType, "--viewport") == 0 )
else if ( stricmp( tokenType, "--noshadows" ) == 0 )
{
//setDrawShadows( FALSE );
setWarzoneKeyNumeric( "shadows", FALSE );
}
else if ( stricmp( tokenType, "--sound" ) == 0 )
{
war_setSoundEnabled( TRUE );
setWarzoneKeyNumeric( "sound", TRUE );
}
else if ( stricmp( tokenType, "--nosound" ) == 0 )
{
war_setSoundEnabled( FALSE );
setWarzoneKeyNumeric( "sound", FALSE );
}
else if ( stricmp( tokenType, "--viewport" ) == 0 )
{
token = argv[++i];
if ( !sscanf( token, "%ix%i", &width, &height ) == 2 )

View File

@ -139,6 +139,18 @@ BOOL loadConfig(BOOL bResourceAvailable)
setWarzoneKeyNumeric("shadows", TRUE);
}
// //////////////////////////
// enable sound
if(getWarzoneKeyNumeric("sound", &val))
{
war_setSoundEnabled( val );
}
else
{
war_setSoundEnabled( TRUE );
setWarzoneKeyNumeric( "sound", TRUE );
}
// //////////////////////////
// invert mouse
if(getWarzoneKeyNumeric("mouseflip", &val))

View File

@ -1022,10 +1022,12 @@ BOOL systemInitialise(void)
return FALSE;
}
if (!audio_Init(droidAudioTrackStopped))
if ( war_getSoundEnabled() && !audio_Init(droidAudioTrackStopped) )
{
debug( LOG_SOUND, "Couldn't initialise audio system: continuing without audio\n" );
}
else
debug( LOG_SOUND, "Sound disabled!" );
if (war_GetPlayAudioCDs()) {
cdAudio_Open(UserMusicPath);

View File

@ -37,6 +37,7 @@ typedef struct _warzoneGlobals
BOOL allowSubtitles;
BOOL playAudioCDs;
BOOL Fullscreen;
BOOL soundEnabled;
} WARZONE_GLOBALS;
/***************************************************************************/
@ -67,6 +68,8 @@ void war_SetDefaultStates(void)//Sets all states
war_SetAdditive(FALSE);
war_SetPlayAudioCDs(TRUE);
war_setSoundEnabled( TRUE );
}
void war_SetPlayAudioCDs(BOOL b) {
@ -161,39 +164,13 @@ SEQ_MODE war_GetSeqMode(void)
return warGlobs.seqMode;
}
/***************************************************************************/
/***************************************************************************/
void war_SetDirectDrawDeviceName(char* pDDDeviceName)
void war_setSoundEnabled( BOOL soundEnabled )
{
ASSERT( strlen(pDDDeviceName) < 255,"DirectDraw device string exceeds max string length." );
if (strlen(pDDDeviceName) >= 255)
{
pDDDeviceName[255] = 0;
}
strcpy((char*)(warGlobs.DDrawDriverName),pDDDeviceName);
warGlobs.soundEnabled = soundEnabled;
}
char* war_GetDirectDrawDeviceName(void)
BOOL war_getSoundEnabled( void )
{
return (char*)(warGlobs.DDrawDriverName);
return warGlobs.soundEnabled;
}
/***************************************************************************/
/***************************************************************************/
void war_SetDirect3DDeviceName(char* pD3DDeviceName)
{
ASSERT( strlen(pD3DDeviceName) < 255,"Direct3D device string exceeds max string length." );
if (strlen(pD3DDeviceName) >= 255)
{
pD3DDeviceName[255] = 0;
}
strcpy((char*)(warGlobs.D3DDriverName),pD3DDeviceName);
}
char* war_GetDirect3DDeviceName(void)
{
return (char*)(warGlobs.D3DDriverName);
}

View File

@ -39,10 +39,6 @@ extern void war_SetAdditive(BOOL val);
extern BOOL war_GetAdditive(void);
extern void war_SetSeqMode(SEQ_MODE mode);
extern SEQ_MODE war_GetSeqMode(void);
extern void war_SetDirectDrawDeviceName(char* pDDDeviceName);
extern char* war_GetDirectDrawDeviceName(void);
extern void war_SetDirect3DDeviceName(char* pD3DDeviceName);
extern char* war_GetDirect3DDeviceName(void);
extern void war_SetPlayAudioCDs(BOOL b);
extern BOOL war_GetPlayAudioCDs(void);
extern void war_SetAllowSubtitles(BOOL);
@ -50,4 +46,19 @@ extern BOOL war_GetAllowSubtitles(void);
extern void war_setFullscreen(BOOL);
extern BOOL war_getFullscreen(void);
/**
* Enable or disable sound initialization
* Has no effect after systemInitialize()!
*
* \param soundEnabled enable sound (or not)
*/
void war_setSoundEnabled( BOOL soundEnabled );
/**
* Whether we should initialize sound or not
*
* \return Enable sound (or not)
*/
BOOL war_getSoundEnabled( void );
#endif // _warzoneConfig_h