mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-14 03:09:08 +00:00
Fixed: Sound CSheetId implementation
This commit is contained in:
parent
1ac3f3f170
commit
1a32d2691c
5 changed files with 29 additions and 22 deletions
|
@ -54,7 +54,7 @@ class CSound
|
||||||
friend class CAudioMixerUser;
|
friend class CAudioMixerUser;
|
||||||
public:
|
public:
|
||||||
/// Factory for specialized sound.
|
/// Factory for specialized sound.
|
||||||
static CSound *createSound(const NLMISC::CSheetId &sheetId, NLGEORGES::UFormElm& formRoot);
|
static CSound *createSound(const std::string &name, NLGEORGES::UFormElm& formRoot);
|
||||||
|
|
||||||
enum TSOUND_TYPE
|
enum TSOUND_TYPE
|
||||||
{
|
{
|
||||||
|
|
|
@ -86,8 +86,7 @@ void CBackgroundSoundManager::addSound(const std::string &soundName, uint layerI
|
||||||
CAudioMixerUser *mixer = CAudioMixerUser::instance();
|
CAudioMixerUser *mixer = CAudioMixerUser::instance();
|
||||||
TSoundData sd;
|
TSoundData sd;
|
||||||
|
|
||||||
nlassert(soundName.find(".sound") != std::string::npos);
|
sd.SoundName = NLMISC::CSheetId(soundName, "sound"); // note: loaded from .primitive
|
||||||
sd.SoundName = NLMISC::CSheetId(soundName);
|
|
||||||
sd.Sound = mixer->getSoundId(sd.SoundName);
|
sd.Sound = mixer->getSoundId(sd.SoundName);
|
||||||
sd.Source = 0;
|
sd.Source = 0;
|
||||||
|
|
||||||
|
|
|
@ -37,9 +37,8 @@ using namespace NLMISC;
|
||||||
|
|
||||||
namespace NLSOUND {
|
namespace NLSOUND {
|
||||||
|
|
||||||
CSound *CSound::createSound(const NLMISC::CSheetId &sheetId, NLGEORGES::UFormElm& formRoot)
|
CSound *CSound::createSound(const std::string &filename, NLGEORGES::UFormElm& formRoot)
|
||||||
{
|
{
|
||||||
std::string filename = sheetId.toString();
|
|
||||||
CSound *ret = NULL;
|
CSound *ret = NULL;
|
||||||
string soundType;
|
string soundType;
|
||||||
|
|
||||||
|
@ -134,8 +133,9 @@ void CSound::serial(NLMISC::IStream &s)
|
||||||
s.serial(_Direction);
|
s.serial(_Direction);
|
||||||
s.serial(_Looping);
|
s.serial(_Looping);
|
||||||
s.serial(_MaxDist);
|
s.serial(_MaxDist);
|
||||||
|
|
||||||
_Name.serialString(s, "sound");
|
_Name.serialString(s, "sound");
|
||||||
|
|
||||||
nlassert(CGroupControllerRoot::getInstance()); // not sure
|
nlassert(CGroupControllerRoot::getInstance()); // not sure
|
||||||
#if NLSOUND_SHEET_VERSION_BUILT < 2
|
#if NLSOUND_SHEET_VERSION_BUILT < 2
|
||||||
if (s.isReading()) _GroupController = static_cast<CGroupController *>(CAudioMixerUser::instance()->getGroupController(NLSOUND_SHEET_V1_DEFAULT_SOUND_GROUP_CONTROLLER));
|
if (s.isReading()) _GroupController = static_cast<CGroupController *>(CAudioMixerUser::instance()->getGroupController(NLSOUND_SHEET_V1_DEFAULT_SOUND_GROUP_CONTROLLER));
|
||||||
|
|
|
@ -153,7 +153,7 @@ public:
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// load the values using the george sheet (called by GEORGE::loadForm)
|
// load the values using the george sheet (called by GEORGE::loadForm)
|
||||||
void readGeorges (const NLMISC::CSmartPtr<NLGEORGES::UForm> &form, const NLMISC::CSheetId &name)
|
void readGeorges (const NLMISC::CSmartPtr<NLGEORGES::UForm> &form, const std::string &name)
|
||||||
{
|
{
|
||||||
// just call the sound creation method with the xml form.
|
// just call the sound creation method with the xml form.
|
||||||
Sound = CSound::createSound(name, form->getRootNode());
|
Sound = CSound::createSound(name, form->getRootNode());
|
||||||
|
@ -259,8 +259,7 @@ public:
|
||||||
void CSoundBank::load(const std::string &packedSheetDir, bool packedSheetUpdate)
|
void CSoundBank::load(const std::string &packedSheetDir, bool packedSheetUpdate)
|
||||||
{
|
{
|
||||||
// this structure is fill by the loadForm() function and will contain all you need
|
// this structure is fill by the loadForm() function and will contain all you need
|
||||||
//std::map<std::string, CSoundSerializer> Container;
|
std::map<std::string, CSoundSerializer> container; // load the old way for compatibility
|
||||||
std::map<NLMISC::CSheetId, CSoundSerializer> container;
|
|
||||||
nlassert(!_Loaded);
|
nlassert(!_Loaded);
|
||||||
// Just call the GEORGE::loadFrom method to read all available sounds
|
// Just call the GEORGE::loadFrom method to read all available sounds
|
||||||
::loadForm("sound", packedSheetDir + "sounds.packed_sheets", container, packedSheetUpdate, false);
|
::loadForm("sound", packedSheetDir + "sounds.packed_sheets", container, packedSheetUpdate, false);
|
||||||
|
@ -269,11 +268,12 @@ void CSoundBank::load(const std::string &packedSheetDir, bool packedSheetUpdate)
|
||||||
// get the largest sheet id needed and init the sound bank
|
// get the largest sheet id needed and init the sound bank
|
||||||
uint32 maxShortId = 0;
|
uint32 maxShortId = 0;
|
||||||
{
|
{
|
||||||
std::map<NLMISC::CSheetId, CSoundSerializer>::iterator first(container.begin()), last(container.end());
|
std::map<std::string, CSoundSerializer>::iterator first(container.begin()), last(container.end());
|
||||||
for (; first != last; ++first)
|
for (; first != last; ++first)
|
||||||
{
|
{
|
||||||
if (first->first.getShortId() > maxShortId)
|
if (first->second.Sound != 0)
|
||||||
maxShortId = first->first.getShortId();
|
if (first->second.Sound->getName().getShortId() > maxShortId)
|
||||||
|
maxShortId = first->second.Sound->getName().getShortId();
|
||||||
}
|
}
|
||||||
++maxShortId; // inc for size = last idx + 1
|
++maxShortId; // inc for size = last idx + 1
|
||||||
if (container.size() == 0)
|
if (container.size() == 0)
|
||||||
|
@ -290,7 +290,7 @@ void CSoundBank::load(const std::string &packedSheetDir, bool packedSheetUpdate)
|
||||||
|
|
||||||
// add all the loaded sound in the sound banks
|
// add all the loaded sound in the sound banks
|
||||||
{
|
{
|
||||||
std::map<NLMISC::CSheetId, CSoundSerializer>::iterator first(container.begin()), last(container.end());
|
std::map<std::string, CSoundSerializer>::iterator first(container.begin()), last(container.end());
|
||||||
for (; first != last; ++first)
|
for (; first != last; ++first)
|
||||||
{
|
{
|
||||||
if (first->second.Sound != 0)
|
if (first->second.Sound != 0)
|
||||||
|
|
|
@ -1265,6 +1265,19 @@ void postlogInit()
|
||||||
// set the primitive context
|
// set the primitive context
|
||||||
CPrimitiveContext::instance().CurrentLigoConfig = &LigoConfig;
|
CPrimitiveContext::instance().CurrentLigoConfig = &LigoConfig;
|
||||||
|
|
||||||
|
{
|
||||||
|
H_AUTO(InitRZShIdI)
|
||||||
|
|
||||||
|
nmsg = "Initializing sheets...";
|
||||||
|
ProgressBar.newMessage ( ClientCfg.buildLoadingString(nmsg) );
|
||||||
|
|
||||||
|
// Initialize Sheet IDs.
|
||||||
|
CSheetId::init (ClientCfg.UpdatePackedSheet);
|
||||||
|
|
||||||
|
initLast = initCurrent;
|
||||||
|
initCurrent = ryzomGetLocalTime();
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
H_AUTO(InitRZSound)
|
H_AUTO(InitRZSound)
|
||||||
|
|
||||||
|
@ -1275,12 +1288,13 @@ void postlogInit()
|
||||||
{
|
{
|
||||||
// tmp fix : it seems that, at this point, if the bg downloader window has focus and
|
// tmp fix : it seems that, at this point, if the bg downloader window has focus and
|
||||||
// not the Ryzom one, then sound init fails
|
// not the Ryzom one, then sound init fails
|
||||||
#ifdef NL_OS_WINDOWS
|
/*#ifdef NL_OS_WINDOWS
|
||||||
HWND hWnd = Driver->getDisplay ();
|
HWND hWnd = Driver->getDisplay ();
|
||||||
nlassert (hWnd);
|
nlassert (hWnd);
|
||||||
ShowWindow(hWnd, SW_RESTORE);
|
ShowWindow(hWnd, SW_RESTORE);
|
||||||
SetForegroundWindow(hWnd);
|
SetForegroundWindow(hWnd);
|
||||||
#endif
|
#endif*/
|
||||||
|
// bg downloader not used anymore anyways
|
||||||
SoundMngr = new CSoundManager(&ProgressBar);
|
SoundMngr = new CSoundManager(&ProgressBar);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1323,13 +1337,7 @@ void postlogInit()
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
H_AUTO(InitRZShIdI)
|
H_AUTO(InitRZSheetL)
|
||||||
|
|
||||||
nmsg = "Initializing sheets...";
|
|
||||||
ProgressBar.newMessage ( ClientCfg.buildLoadingString(nmsg) );
|
|
||||||
|
|
||||||
// Initialize Sheet IDs.
|
|
||||||
CSheetId::init (ClientCfg.UpdatePackedSheet);
|
|
||||||
|
|
||||||
// load packed sheets
|
// load packed sheets
|
||||||
nmsg = "Loading sheets...";
|
nmsg = "Loading sheets...";
|
||||||
|
|
Loading…
Reference in a new issue