Enable music in snowballs
This commit is contained in:
parent
eafe83cbe2
commit
b04cab3ec0
8 changed files with 252 additions and 221 deletions
|
@ -7,10 +7,12 @@ Password = "password2";
|
||||||
LSHost = "opennel.org:49994";
|
LSHost = "opennel.org:49994";
|
||||||
FSHost = "";
|
FSHost = "";
|
||||||
SaveConfig = 1;
|
SaveConfig = 1;
|
||||||
SoundEnabled = 0;
|
SoundEnabled = 1;
|
||||||
SoundDriver = "FMod";
|
SoundDriver = "OpenAl";
|
||||||
|
MusicVolume = 0.2;
|
||||||
ScreenWidth = 1024;
|
ScreenWidth = 1024;
|
||||||
ScreenHeight = 768;
|
ScreenHeight = 768;
|
||||||
|
ScreenFull = 0;
|
||||||
ShardId = 300;
|
ShardId = 300;
|
||||||
UseDirectClient = 1;
|
UseDirectClient = 1;
|
||||||
ClientApplication = "snowballs";
|
ClientApplication = "snowballs";
|
||||||
|
|
|
@ -75,12 +75,13 @@ HMDDevice = "Auto";
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// The sound driver, choose between "Auto", "FMod", "DSound" and "OpenAl"
|
// The sound driver, choose between "Auto", "FMod", "DSound" and "OpenAl"
|
||||||
SoundDriver = "FMod";
|
SoundDriver = "OpenAl";
|
||||||
SoundMaxTracks = 32;
|
SoundMaxTracks = 32;
|
||||||
SoundUseEax = 1;
|
SoundUseEax = 1;
|
||||||
SoundUseADPCM = 1;
|
SoundUseADPCM = 1;
|
||||||
SoundForceSoftware = 1;
|
SoundForceSoftware = 1;
|
||||||
SoundEnabled = 1;
|
SoundEnabled = 1;
|
||||||
|
MusicVolume = 0.2;
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -12,9 +12,9 @@ NL_DEFAULT_PROPS(snowballs_client "Snowballs, Client: Snowballs Client")
|
||||||
NL_ADD_RUNTIME_FLAGS(snowballs_client)
|
NL_ADD_RUNTIME_FLAGS(snowballs_client)
|
||||||
|
|
||||||
# If sound is enabled then add the definitions and link the libraries.
|
# If sound is enabled then add the definitions and link the libraries.
|
||||||
IF(ENABLE_SOUND)
|
IF(WITH_SOUND)
|
||||||
ADD_DEFINITIONS(-DSBCLIENT_WITH_SOUND)
|
ADD_DEFINITIONS(-DSBCLIENT_WITH_SOUND)
|
||||||
TARGET_LINK_LIBRARIES(snowballs_client ${NELSOUND_LIBRARY})
|
TARGET_LINK_LIBRARIES(snowballs_client nelsound)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
INSTALL(TARGETS snowballs_client RUNTIME DESTINATION ${NL_BIN_PREFIX} COMPONENT snowballsclient)
|
INSTALL(TARGETS snowballs_client RUNTIME DESTINATION ${NL_BIN_PREFIX} COMPONENT snowballsclient)
|
||||||
|
|
|
@ -762,10 +762,10 @@ void updateEntities ()
|
||||||
switch (entity.Type)
|
switch (entity.Type)
|
||||||
{
|
{
|
||||||
case CEntity::Self:
|
case CEntity::Self:
|
||||||
jdir = CVector(-(float)cos(entity.Angle), -(float)sin(entity.Angle), 0.0f);
|
jdir = CVector(-(float)cos(entity.Angle - (Pi * 0.5)), -(float)sin(entity.Angle - (Pi * 0.5)), 0.0f);
|
||||||
break;
|
break;
|
||||||
case CEntity::Other:
|
case CEntity::Other:
|
||||||
jdir = CVector(-(float)cos(entity.Angle), -(float)sin(entity.Angle), 0.0f);
|
jdir = CVector(-(float)cos(entity.Angle - (Pi * 0.5)), -(float)sin(entity.Angle - (Pi * 0.5)), 0.0f);
|
||||||
break;
|
break;
|
||||||
case CEntity::Snowball:
|
case CEntity::Snowball:
|
||||||
jdir = entity.Trajectory.evalSpeed(LocalTime).normed();
|
jdir = entity.Trajectory.evalSpeed(LocalTime).normed();
|
||||||
|
|
|
@ -68,6 +68,7 @@
|
||||||
#include "interface.h"
|
#include "interface.h"
|
||||||
#include "lens_flare.h"
|
#include "lens_flare.h"
|
||||||
#include "mouse_listener.h"
|
#include "mouse_listener.h"
|
||||||
|
#include "sound.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "internationalization.h"
|
#include "internationalization.h"
|
||||||
#include "game_time.h"
|
#include "game_time.h"
|
||||||
|
@ -301,6 +302,8 @@ void initCore()
|
||||||
LoadedCore = true;
|
LoadedCore = true;
|
||||||
// Seed the randomizer
|
// Seed the randomizer
|
||||||
srand(uint(time(0)));
|
srand(uint(time(0)));
|
||||||
|
// Sheet Id
|
||||||
|
CSheetId::initWithoutSheet(); // Temporary for sound
|
||||||
// Load configuration file, set paths, extension remapping
|
// Load configuration file, set paths, extension remapping
|
||||||
CConfiguration::init();
|
CConfiguration::init();
|
||||||
// Load language file
|
// Load language file
|
||||||
|
@ -333,11 +336,9 @@ void initCore()
|
||||||
displayLoadingState("Initialize Loading");
|
displayLoadingState("Initialize Loading");
|
||||||
initLoadingState();
|
initLoadingState();
|
||||||
// Initialize sound for loading screens etc
|
// Initialize sound for loading screens etc
|
||||||
//#ifdef NL_OS_WINDOWS
|
displayLoadingState("Initialize Sound");
|
||||||
// displayLoadingState("Initialize Sound");
|
initSound();
|
||||||
// initSound();
|
playMusic(SBCLIENT_MUSIC_WAIT);
|
||||||
// playMusic(SBCLIENT_MUSIC_WAIT);
|
|
||||||
//#endif
|
|
||||||
// Required for 3d rendering (3d nel logo etc)
|
// Required for 3d rendering (3d nel logo etc)
|
||||||
displayLoadingState("Initialize Light");
|
displayLoadingState("Initialize Light");
|
||||||
initLight();
|
initLight();
|
||||||
|
@ -366,9 +367,7 @@ void initIngame()
|
||||||
if (!LoadedIngame)
|
if (!LoadedIngame)
|
||||||
{
|
{
|
||||||
LoadedIngame = true;
|
LoadedIngame = true;
|
||||||
//#ifdef NL_OS_WINDOWS
|
playMusic(SBCLIENT_MUSIC_WAIT);
|
||||||
// playMusic(SBCLIENT_MUSIC_WAIT);
|
|
||||||
//#endif
|
|
||||||
displayLoadingState("Initialize");
|
displayLoadingState("Initialize");
|
||||||
|
|
||||||
// Create a scene
|
// Create a scene
|
||||||
|
@ -441,10 +440,9 @@ void initIngame()
|
||||||
|
|
||||||
void initOnline()
|
void initOnline()
|
||||||
{
|
{
|
||||||
if (LoadedOnline) return;
|
if (LoadedOnline)
|
||||||
//#ifdef NL_OS_WINDOWS
|
return;
|
||||||
// playMusic(SBCLIENT_MUSIC_WAIT);
|
playMusic(SBCLIENT_MUSIC_WAIT);
|
||||||
//#endif
|
|
||||||
|
|
||||||
displayLoadingState("Connecting");
|
displayLoadingState("Connecting");
|
||||||
|
|
||||||
|
@ -460,9 +458,7 @@ void initOnline()
|
||||||
|
|
||||||
displayLoadingState("Ready!");
|
displayLoadingState("Ready!");
|
||||||
|
|
||||||
//#ifdef NL_OS_WINDOWS
|
playMusic(SBCLIENT_MUSIC_BACKGROUND);
|
||||||
// playMusic(SBCLIENT_MUSIC_BACKGROUND);
|
|
||||||
//#endif
|
|
||||||
LoadedOnline = true;
|
LoadedOnline = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -471,9 +467,7 @@ void initOffline()
|
||||||
if (!LoadedOffline)
|
if (!LoadedOffline)
|
||||||
{
|
{
|
||||||
LoadedOffline = true;
|
LoadedOffline = true;
|
||||||
//#ifdef NL_OS_WINDOWS
|
playMusic(SBCLIENT_MUSIC_WAIT);
|
||||||
// playMusic(SBCLIENT_MUSIC_WAIT);
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
uint32 id = NextEID++;
|
uint32 id = NextEID++;
|
||||||
Login = ucstring("Entity" + toString(id));
|
Login = ucstring("Entity" + toString(id));
|
||||||
|
@ -492,9 +486,7 @@ void initOffline()
|
||||||
|
|
||||||
displayLoadingState("Ready!");
|
displayLoadingState("Ready!");
|
||||||
|
|
||||||
//#ifdef NL_OS_WINDOWS
|
playMusic(SBCLIENT_MUSIC_BACKGROUND);
|
||||||
// playMusic(SBCLIENT_MUSIC_BACKGROUND);
|
|
||||||
//#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -517,9 +509,7 @@ void releaseCore()
|
||||||
// Release the loading state textures
|
// Release the loading state textures
|
||||||
releaseLoadingState();
|
releaseLoadingState();
|
||||||
// Release the sound
|
// Release the sound
|
||||||
//#ifdef NL_OS_WINDOWS
|
releaseSound();
|
||||||
// releaseSound();
|
|
||||||
//#endif
|
|
||||||
// Release the text context
|
// Release the text context
|
||||||
Driver->deleteTextContext(TextContext);
|
Driver->deleteTextContext(TextContext);
|
||||||
TextContext = NULL;
|
TextContext = NULL;
|
||||||
|
@ -529,11 +519,13 @@ void releaseCore()
|
||||||
Driver = NULL;
|
Driver = NULL;
|
||||||
|
|
||||||
// Release timing system
|
// Release timing system
|
||||||
CGameTime::init();
|
CGameTime::release();
|
||||||
// Release language file
|
// Release language file
|
||||||
CInternationalization::init();
|
CInternationalization::release();
|
||||||
// Release the configuration
|
// Release the configuration
|
||||||
CConfiguration::release();
|
CConfiguration::release();
|
||||||
|
// Release sheet id
|
||||||
|
CSheetId::uninit(); // Temporary for sound
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -611,9 +603,7 @@ void releaseOffline()
|
||||||
|
|
||||||
void loopLogin()
|
void loopLogin()
|
||||||
{
|
{
|
||||||
//#ifdef NL_OS_WINDOWS
|
playMusic(SBCLIENT_MUSIC_LOGIN);
|
||||||
// playMusic(SBCLIENT_MUSIC_LOGIN);
|
|
||||||
//#endif
|
|
||||||
// todo: login screen, move this stuff to a button or something
|
// todo: login screen, move this stuff to a button or something
|
||||||
displayLoadingState("Login");
|
displayLoadingState("Login");
|
||||||
if (ConfigFile->getVar("Local").asInt() == 0)
|
if (ConfigFile->getVar("Local").asInt() == 0)
|
||||||
|
@ -730,9 +720,7 @@ void loopIngame()
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
// 11. Update Sound (sound driver)
|
// 11. Update Sound (sound driver)
|
||||||
//#ifdef NL_OS_WINDOWS
|
updateSound(); // Update the sound
|
||||||
// updateSound(); // Update the sound
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
// 12. Update Outgoing (network, send new position etc)
|
// 12. Update Outgoing (network, send new position etc)
|
||||||
// ...
|
// ...
|
||||||
|
@ -1118,9 +1106,7 @@ void updateLoadingState(const char *state, bool network, bool information)
|
||||||
void updateLoadingState(ucstring state, bool network, bool information)
|
void updateLoadingState(ucstring state, bool network, bool information)
|
||||||
{
|
{
|
||||||
CGameTime::updateTime(); // important that time is updated here!!!
|
CGameTime::updateTime(); // important that time is updated here!!!
|
||||||
//#ifdef NL_OS_WINDOWS
|
updateSound();
|
||||||
// updateSound();
|
|
||||||
//#endif
|
|
||||||
renderLoadingState(state, true);
|
renderLoadingState(state, true);
|
||||||
if (information) renderInformation();
|
if (information) renderInformation();
|
||||||
if (network) updateNetwork();
|
if (network) updateNetwork();
|
||||||
|
|
|
@ -41,7 +41,9 @@
|
||||||
// - Bloom
|
// - Bloom
|
||||||
// 2.2
|
// 2.2
|
||||||
// - OculusVR support
|
// - OculusVR support
|
||||||
#define SBCLIENT_VERSION "2.2"
|
// 2.3
|
||||||
|
// - Add music
|
||||||
|
#define SBCLIENT_VERSION "2.3"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,10 @@
|
||||||
#include <nel/sound/u_listener.h>
|
#include <nel/sound/u_listener.h>
|
||||||
#include <nel/sound/u_source.h>
|
#include <nel/sound/u_source.h>
|
||||||
|
|
||||||
|
#include "snowballs_client.h"
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
#include "entities.h"
|
#include "entities.h"
|
||||||
|
#include "configuration.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// Namespaces
|
// Namespaces
|
||||||
|
@ -41,116 +43,149 @@ using namespace std;
|
||||||
using namespace NLMISC;
|
using namespace NLMISC;
|
||||||
using namespace NLSOUND;
|
using namespace NLSOUND;
|
||||||
|
|
||||||
#ifdef SBCLIENT_WITH_SOUND
|
namespace SBCLIENT
|
||||||
|
{
|
||||||
|
|
||||||
////
|
|
||||||
//// Variables
|
|
||||||
////
|
|
||||||
//
|
//
|
||||||
//UAudioMixer *AudioMixer = NULL;
|
// Variables
|
||||||
|
///
|
||||||
|
|
||||||
|
#ifdef SBCLIENT_WITH_SOUND
|
||||||
|
UAudioMixer *AudioMixer = NULL;
|
||||||
//TSoundId SoundId;
|
//TSoundId SoundId;
|
||||||
//const vector<TSoundId> *SoundIdArray;
|
//const vector<TSoundId> *SoundIdArray;
|
||||||
//static bool SoundEnabled;
|
static bool SoundEnabled;
|
||||||
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
////
|
// Functions
|
||||||
//// Functions
|
|
||||||
////
|
|
||||||
//
|
|
||||||
//#ifdef NL_OS_WINDOWS
|
|
||||||
//void initSound2();
|
|
||||||
//void releaseSound2();
|
|
||||||
//#endif
|
|
||||||
//
|
|
||||||
//void cbConfigFileSoundMaxTracks(NLMISC::CConfigFile::CVar &var)
|
|
||||||
//{
|
|
||||||
////#ifdef NL_OS_WINDOWS
|
|
||||||
//// AudioMixer->changeMaxTrack(var.asInt());
|
|
||||||
////#endif
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void cbConfigFileSoundEnabled(NLMISC::CConfigFile::CVar &var)
|
|
||||||
//{
|
|
||||||
////#ifdef NL_OS_WINDOWS
|
|
||||||
//// if (var.asBool() != SoundEnabled)
|
|
||||||
//// {
|
|
||||||
//// if (var.asBool()) initSound2();
|
|
||||||
//// else releaseSound2();
|
|
||||||
//// }
|
|
||||||
////#endif
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void cbConfigFileFail(NLMISC::CConfigFile::CVar &var)
|
|
||||||
//{
|
|
||||||
// //nlwarning("You can't modify the config variable '%s' at runtime for now, please restart the game", var.asString().c_str());
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
////#ifdef NL_OS_WINDOWS
|
|
||||||
////void initSound2()
|
|
||||||
////{
|
|
||||||
//// AudioMixer = UAudioMixer::createAudioMixer ();
|
|
||||||
//// std::string driverName;
|
|
||||||
//// NLSOUND::UAudioMixer::TDriver driverType;
|
|
||||||
//// if (!ConfigFile->exists("SoundDriver"))
|
|
||||||
////#ifdef NL_OS_WINDOWS
|
|
||||||
//// driverType = NLSOUND::UAudioMixer::DriverFMod;
|
|
||||||
////#elif defined (NL_OS_UNIX)
|
|
||||||
//// driverType = NLSOUND::UAudioMixer::DriverOpenAl;
|
|
||||||
////#else
|
|
||||||
//// driverType = NLSOUND::UAudioMixer::DriverAuto;
|
|
||||||
////#endif
|
|
||||||
//// else
|
|
||||||
//// {
|
|
||||||
//// driverName = ConfigFile->getVar("SoundDriver").asString();
|
|
||||||
//// if (driverName == "Auto") driverType = NLSOUND::UAudioMixer::DriverAuto;
|
|
||||||
//// else if (driverName == "FMod") driverType = NLSOUND::UAudioMixer::DriverFMod;
|
|
||||||
//// else if (driverName == "DSound") driverType = NLSOUND::UAudioMixer::DriverDSound;
|
|
||||||
//// else if (driverName == "OpenAl") driverType = NLSOUND::UAudioMixer::DriverOpenAl;
|
|
||||||
//// else nlerror("SoundDriver value '%s' is invalid.", driverName.c_str());
|
|
||||||
//// }
|
|
||||||
////
|
|
||||||
//// AudioMixer->init(
|
|
||||||
//// ConfigFile->exists("SoundMaxTracks")
|
|
||||||
//// ? ConfigFile->getVar("SoundMaxTracks").asInt() : 32,
|
|
||||||
//// ConfigFile->exists("SoundUseEax")
|
|
||||||
//// ? ConfigFile->getVar("SoundUseEax").asBool() : true,
|
|
||||||
//// ConfigFile->exists("SoundUseADPCM")
|
|
||||||
//// ? ConfigFile->getVar("SoundUseADPCM").asBool() : true,
|
|
||||||
//// NULL, false, driverType,
|
|
||||||
//// ConfigFile->exists("SoundForceSoftware")
|
|
||||||
//// ? ConfigFile->getVar("SoundForceSoftware").asBool() : true);
|
|
||||||
////
|
|
||||||
//// ConfigFile->setCallback("SoundMaxTracks", cbConfigFileSoundMaxTracks);
|
|
||||||
//// ConfigFile->setCallback("SoundUseEax", cbConfigFileFail);
|
|
||||||
//// ConfigFile->setCallback("SoundUseADPCM", cbConfigFileFail);
|
|
||||||
//// ConfigFile->setCallback("SoundForceSoftware", cbConfigFileFail);
|
|
||||||
//// ConfigFile->setCallback("SoundDriver", cbConfigFileFail);
|
|
||||||
////
|
|
||||||
//// PlaylistManager = new SBCLIENT::CMusicPlaylistManager(AudioMixer, ConfigFile, "SoundPlaylist");
|
|
||||||
////
|
|
||||||
//// /* AudioMixer->loadSoundBuffers ("sounds.nss", &SoundIdArray);
|
|
||||||
//// nlassert( SoundIdArray->size() == 2 );
|
|
||||||
//// SoundId = (*SoundIdArray)[0];
|
|
||||||
//// // StSoundId = (*SoundIdArray)[1]; */
|
|
||||||
////
|
|
||||||
//// SoundEnabled = true;
|
|
||||||
////}
|
|
||||||
////#endif
|
|
||||||
//
|
|
||||||
//void initSound()
|
|
||||||
//{
|
|
||||||
////#ifdef NL_OS_WINDOWS
|
|
||||||
//// if (ConfigFile->exists("SoundEnabled") ? ConfigFile->getVar("SoundEnabled").asBool() : false) initSound2();
|
|
||||||
//// ConfigFile->setCallback("SoundEnabled", cbConfigFileSoundEnabled);
|
|
||||||
////#endif
|
|
||||||
//}
|
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#ifdef SBCLIENT_WITH_SOUND
|
||||||
|
|
||||||
|
void initSound2();
|
||||||
|
void releaseSound2();
|
||||||
|
|
||||||
|
void cbConfigFileSoundMaxTracks(NLMISC::CConfigFile::CVar &var)
|
||||||
|
{
|
||||||
|
if (AudioMixer)
|
||||||
|
AudioMixer->changeMaxTrack(var.asInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
void cbConfigFileSoundEnabled(NLMISC::CConfigFile::CVar &var)
|
||||||
|
{
|
||||||
|
if (var.asBool() != SoundEnabled)
|
||||||
|
{
|
||||||
|
if (var.asBool())
|
||||||
|
initSound2();
|
||||||
|
else
|
||||||
|
releaseSound2();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cbConfigFileMusicVolume(NLMISC::CConfigFile::CVar &var)
|
||||||
|
{
|
||||||
|
if (AudioMixer)
|
||||||
|
AudioMixer->setMusicVolume(var.asFloat());
|
||||||
|
}
|
||||||
|
|
||||||
|
void cbConfigFileFail(NLMISC::CConfigFile::CVar &var)
|
||||||
|
{
|
||||||
|
nlwarning("You can't modify the config variable '%s' at runtime for now, please restart the game", var.asString().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void initSound2()
|
||||||
|
{
|
||||||
|
AudioMixer = UAudioMixer::createAudioMixer();
|
||||||
|
std::string driverName;
|
||||||
|
NLSOUND::UAudioMixer::TDriver driverType;
|
||||||
|
if (!ConfigFile->exists("SoundDriver"))
|
||||||
|
#ifdef NL_OS_WINDOWS
|
||||||
|
driverType = NLSOUND::UAudioMixer::DriverFMod;
|
||||||
|
#elif defined(NL_OS_UNIX)
|
||||||
|
driverType = NLSOUND::UAudioMixer::DriverOpenAl;
|
||||||
|
#else
|
||||||
|
driverType = NLSOUND::UAudioMixer::DriverAuto;
|
||||||
|
#endif
|
||||||
|
else
|
||||||
|
{
|
||||||
|
driverName = ConfigFile->getVar("SoundDriver").asString();
|
||||||
|
if (driverName == "Auto")
|
||||||
|
driverType = NLSOUND::UAudioMixer::DriverAuto;
|
||||||
|
else if (driverName == "FMod")
|
||||||
|
driverType = NLSOUND::UAudioMixer::DriverFMod;
|
||||||
|
else if (driverName == "DSound")
|
||||||
|
driverType = NLSOUND::UAudioMixer::DriverDSound;
|
||||||
|
else if (driverName == "OpenAl")
|
||||||
|
driverType = NLSOUND::UAudioMixer::DriverOpenAl;
|
||||||
|
else
|
||||||
|
nlerror("SoundDriver value '%s' is invalid.", driverName.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
AudioMixer->init(
|
||||||
|
ConfigFile->exists("SoundMaxTracks")
|
||||||
|
? ConfigFile->getVar("SoundMaxTracks").asInt()
|
||||||
|
: 32,
|
||||||
|
ConfigFile->exists("SoundUseEax")
|
||||||
|
? ConfigFile->getVar("SoundUseEax").asBool()
|
||||||
|
: true,
|
||||||
|
ConfigFile->exists("SoundUseADPCM")
|
||||||
|
? ConfigFile->getVar("SoundUseADPCM").asBool()
|
||||||
|
: true,
|
||||||
|
NULL, true, driverType,
|
||||||
|
ConfigFile->exists("SoundForceSoftware")
|
||||||
|
? ConfigFile->getVar("SoundForceSoftware").asBool()
|
||||||
|
: true);
|
||||||
|
|
||||||
|
ConfigFile->setCallback("SoundMaxTracks", cbConfigFileSoundMaxTracks);
|
||||||
|
ConfigFile->setCallback("SoundUseEax", cbConfigFileFail);
|
||||||
|
ConfigFile->setCallback("SoundUseADPCM", cbConfigFileFail);
|
||||||
|
ConfigFile->setCallback("SoundForceSoftware", cbConfigFileFail);
|
||||||
|
ConfigFile->setCallback("SoundDriver", cbConfigFileFail);
|
||||||
|
CConfiguration::setAndCallback("MusicVolume", cbConfigFileMusicVolume);
|
||||||
|
|
||||||
|
// PlaylistManager = new SBCLIENT::CMusicPlaylistManager(AudioMixer, ConfigFile, "SoundPlaylist");
|
||||||
|
|
||||||
|
/* AudioMixer->loadSoundBuffers ("sounds.nss", &SoundIdArray);
|
||||||
|
nlassert( SoundIdArray->size() == 2 );
|
||||||
|
SoundId = (*SoundIdArray)[0];
|
||||||
|
// StSoundId = (*SoundIdArray)[1]; */
|
||||||
|
|
||||||
|
SoundEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void releaseSound2()
|
||||||
|
{
|
||||||
|
SoundEnabled = false;
|
||||||
|
ConfigFile->setCallback("SoundMaxTracks", NULL);
|
||||||
|
ConfigFile->setCallback("SoundUseEax", NULL);
|
||||||
|
ConfigFile->setCallback("SoundUseADPCM", NULL);
|
||||||
|
ConfigFile->setCallback("SoundForceSoftware", NULL);
|
||||||
|
ConfigFile->setCallback("SoundDriver", NULL);
|
||||||
|
// delete PlaylistManager;
|
||||||
|
// PlaylistManager = NULL;
|
||||||
|
delete AudioMixer;
|
||||||
|
AudioMixer = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void initSound()
|
||||||
|
{
|
||||||
|
#ifdef SBCLIENT_WITH_SOUND
|
||||||
|
if (ConfigFile->exists("SoundEnabled") ? ConfigFile->getVar("SoundEnabled").asBool() : false)
|
||||||
|
initSound2();
|
||||||
|
ConfigFile->setCallback("SoundEnabled", cbConfigFileSoundEnabled);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
//void playSound (CEntity &entity, TSoundId id)
|
//void playSound (CEntity &entity, TSoundId id)
|
||||||
//{
|
//{
|
||||||
///* entity.Source = AudioMixer->createSource (id);
|
///* entity.Source = AudioMixer->createSource (id);
|
||||||
// entity.Source->setLooping (true);
|
// entity.Source->setLooping (true);
|
||||||
// entity.Source->play ();
|
// entity.Source->play ();
|
||||||
//*/}
|
//*/}
|
||||||
//
|
|
||||||
//void deleteSound (CEntity &entity)
|
//void deleteSound (CEntity &entity)
|
||||||
//{
|
//{
|
||||||
///* if (entity.Source != NULL)
|
///* if (entity.Source != NULL)
|
||||||
|
@ -162,42 +197,36 @@ using namespace NLSOUND;
|
||||||
// entity.Source = NULL;
|
// entity.Source = NULL;
|
||||||
// }
|
// }
|
||||||
//*/}
|
//*/}
|
||||||
//
|
|
||||||
//void updateSound()
|
void updateSound()
|
||||||
//{
|
{
|
||||||
////#ifdef NL_OS_WINDOWS
|
#ifdef SBCLIENT_WITH_SOUND
|
||||||
//// if (SoundEnabled)
|
if (SoundEnabled)
|
||||||
//// {
|
{
|
||||||
//// PlaylistManager->update(DiffTime);
|
// PlaylistManager->update(DiffTime);
|
||||||
//// AudioMixer->update();
|
AudioMixer->update();
|
||||||
//// }
|
}
|
||||||
////#endif
|
#endif
|
||||||
//}
|
}
|
||||||
//
|
|
||||||
////#ifdef NL_OS_WINDOWS
|
void releaseSound()
|
||||||
////void releaseSound2()
|
{
|
||||||
////{
|
#ifdef SBCLIENT_WITH_SOUND
|
||||||
//// SoundEnabled = false;
|
ConfigFile->setCallback("SoundEnabled", NULL);
|
||||||
//// ConfigFile->setCallback("SoundMaxTracks", NULL);
|
if (SoundEnabled) releaseSound2();
|
||||||
//// ConfigFile->setCallback("SoundUseEax", NULL);
|
#endif
|
||||||
//// ConfigFile->setCallback("SoundUseADPCM", NULL);
|
}
|
||||||
//// ConfigFile->setCallback("SoundForceSoftware", NULL);
|
|
||||||
//// ConfigFile->setCallback("SoundDriver", NULL);
|
void playMusic(const char *file)
|
||||||
//// delete PlaylistManager;
|
{
|
||||||
//// PlaylistManager = NULL;
|
#ifdef SBCLIENT_WITH_SOUND
|
||||||
//// delete AudioMixer;
|
if (AudioMixer)
|
||||||
//// AudioMixer = NULL;
|
AudioMixer->playMusic(file, 1000, true, true);
|
||||||
////}
|
#endif
|
||||||
////#endif
|
}
|
||||||
//
|
|
||||||
//void releaseSound()
|
} /* namespace SBCLIENT */
|
||||||
//{
|
|
||||||
////#ifdef NL_OS_WINDOWS
|
|
||||||
//// ConfigFile->setCallback("SoundEnabled", NULL);
|
|
||||||
//// if (SoundEnabled) releaseSound2();
|
|
||||||
////#endif
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
////#ifdef NL_OS_WINDOWS
|
////#ifdef NL_OS_WINDOWS
|
||||||
////
|
////
|
||||||
////void playMusic(sint32 playlist, sint32 track)
|
////void playMusic(sint32 playlist, sint32 track)
|
||||||
|
@ -211,35 +240,38 @@ using namespace NLSOUND;
|
||||||
//// if (SoundEnabled)
|
//// if (SoundEnabled)
|
||||||
//// PlaylistManager->setVolume(playlist, volume);
|
//// PlaylistManager->setVolume(playlist, volume);
|
||||||
////}
|
////}
|
||||||
////
|
|
||||||
////NLMISC_COMMAND(music_bg,"background music","")
|
NLMISC_COMMAND(music_bg,"background music","")
|
||||||
////{
|
{
|
||||||
//// if (args.size() != 0) return false;
|
if (args.size() != 0) return false;
|
||||||
//// playMusic(SBCLIENT_MUSIC_BACKGROUND);
|
SBCLIENT::playMusic(SBCLIENT_MUSIC_BACKGROUND);
|
||||||
//// return true;
|
return true;
|
||||||
////}
|
}
|
||||||
////
|
|
||||||
////NLMISC_COMMAND(music_bg_beat,"background music with beat","")
|
NLMISC_COMMAND(music_bg_beat,"background music with beat","")
|
||||||
////{
|
{
|
||||||
//// if (args.size() != 0) return false;
|
if (args.size() != 0)
|
||||||
//// PlaylistManager->playMusic(SBCLIENT_MUSIC_BACKGROUND_BEAT);
|
return false;
|
||||||
//// return true;
|
SBCLIENT::playMusic(SBCLIENT_MUSIC_BACKGROUND_BEAT);
|
||||||
////}
|
return true;
|
||||||
////
|
}
|
||||||
////NLMISC_COMMAND(music_wait,"loading music","")
|
|
||||||
////{
|
NLMISC_COMMAND(music_wait,"loading music","")
|
||||||
//// if (args.size() != 0) return false;
|
{
|
||||||
//// PlaylistManager->playMusic(SBCLIENT_MUSIC_WAIT);
|
if (args.size() != 0)
|
||||||
//// return true;
|
return false;
|
||||||
////}
|
SBCLIENT::playMusic(SBCLIENT_MUSIC_WAIT);
|
||||||
////
|
return true;
|
||||||
////NLMISC_COMMAND(music_login,"login screen music","")
|
}
|
||||||
////{
|
|
||||||
//// if (args.size() != 0) return false;
|
NLMISC_COMMAND(music_login,"login screen music","")
|
||||||
//// PlaylistManager->playMusic(SBCLIENT_MUSIC_LOGIN);
|
{
|
||||||
//// return true;
|
if (args.size() != 0)
|
||||||
////}
|
return false;
|
||||||
////
|
SBCLIENT::playMusic(SBCLIENT_MUSIC_LOGIN);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
////#endif
|
////#endif
|
||||||
|
|
||||||
#endif // SBCLIENT_WITH_SOUND
|
/* end of file */
|
||||||
|
|
|
@ -35,35 +35,43 @@
|
||||||
// Defines
|
// Defines
|
||||||
//
|
//
|
||||||
|
|
||||||
//#define SBCLIENT_MUSIC_WAIT (0), (0)
|
#define SBCLIENT_MUSIC_WAIT "xtarsia_evil-snowballs_wait.ogg"
|
||||||
//#define SBCLIENT_MUSIC_LOGIN (1), (0)
|
#define SBCLIENT_MUSIC_LOGIN "xtarsia_evil-snowballs_login.ogg"
|
||||||
//#define SBCLIENT_MUSIC_BACKGROUND (2), (0)
|
#define SBCLIENT_MUSIC_BACKGROUND "xtarsia_evil-snowballs_beat.ogg" /* "xtarsia_evil-snowballs_game.ogg" */
|
||||||
//#define SBCLIENT_MUSIC_BACKGROUND_BEAT (2), (1)
|
#define SBCLIENT_MUSIC_BACKGROUND_BEAT "xtarsia_evil-snowballs_beat.ogg"
|
||||||
|
|
||||||
|
namespace SBCLIENT {
|
||||||
|
|
||||||
//
|
//
|
||||||
// External variables
|
// External variables
|
||||||
//
|
//
|
||||||
|
|
||||||
//extern NLSOUND::UAudioMixer *AudioMixer;
|
#ifdef SBCLIENT_WITH_SOUND
|
||||||
|
extern NLSOUND::UAudioMixer *AudioMixer;
|
||||||
//extern NLSOUND::TSoundId SoundId;
|
//extern NLSOUND::TSoundId SoundId;
|
||||||
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
////
|
// External functions
|
||||||
//// External functions
|
|
||||||
////
|
|
||||||
//
|
//
|
||||||
|
|
||||||
//void playMusic(sint32 playlist, sint32 track);
|
//void playMusic(sint32 playlist, sint32 track);
|
||||||
//void setMusicVolume(sint32 playlist, float volume);
|
//void setMusicVolume(sint32 playlist, float volume);
|
||||||
//
|
|
||||||
//void initSound();
|
void initSound();
|
||||||
//void updateSound();
|
void updateSound();
|
||||||
//void releaseSound();
|
void releaseSound();
|
||||||
//
|
|
||||||
|
void playMusic(const char *file);
|
||||||
|
|
||||||
//// Set and play a sound on an entity
|
//// Set and play a sound on an entity
|
||||||
//void playSound(CEntity &entity, NLSOUND::TSoundId id);
|
//void playSound(CEntity &entity, NLSOUND::TSoundId id);
|
||||||
//
|
|
||||||
//// Remove the sound system link to the entity
|
//// Remove the sound system link to the entity
|
||||||
//void deleteSound(CEntity &entity);
|
//void deleteSound(CEntity &entity);
|
||||||
|
|
||||||
|
} /* namespace SBCLIENT */
|
||||||
|
|
||||||
#endif // SBCLIENT_SOUND_H
|
#endif // SBCLIENT_SOUND_H
|
||||||
|
|
||||||
/* End of sound.h */ // duh
|
/* End of sound.h */ // duh
|
||||||
|
|
Loading…
Reference in a new issue