mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 16:14:38 +00:00
Merge pull request #1209 from Azaezel/alpha41/simplifySoundSlots
Alpha41/simplify sound slots
This commit is contained in:
commit
142c6c9a28
4 changed files with 27 additions and 34 deletions
|
|
@ -173,7 +173,7 @@ SoundAsset::SoundAsset()
|
||||||
mPlaylist.mRandomMode = SFXPlayList::RANDOM_NotRandom;
|
mPlaylist.mRandomMode = SFXPlayList::RANDOM_NotRandom;
|
||||||
mPlaylist.mTrace = false;
|
mPlaylist.mTrace = false;
|
||||||
mPlaylist.mLoopMode = SFXPlayList::LOOP_All;
|
mPlaylist.mLoopMode = SFXPlayList::LOOP_All;
|
||||||
mPlaylist.mActiveSlots = 12;
|
mPlaylist.mActiveSlots = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -190,9 +190,10 @@ void SoundAsset::initPersistFields()
|
||||||
docsURL;
|
docsURL;
|
||||||
// Call parent.
|
// Call parent.
|
||||||
Parent::initPersistFields();
|
Parent::initPersistFields();
|
||||||
|
addGroup("SoundSlots");
|
||||||
addArray("slots", SFXPlayList::SFXPlaylistSettings::NUM_SLOTS);
|
addArray("slots", SFXPlayList::SFXPlaylistSettings::NUM_SLOTS);
|
||||||
addProtectedField("soundFile", TypeAssetLooseFilePath, Offset(mSoundFile, SoundAsset),
|
addProtectedField("soundFile", TypeAssetLooseFilePath, Offset(mSoundFile, SoundAsset),
|
||||||
&_setSoundFile, &_getSoundFile, SFXPlayList::SFXPlaylistSettings::NUM_SLOTS, "Path to the sound file.");
|
&_setSoundFile, &defaultProtectedGetFn, SFXPlayList::SFXPlaylistSettings::NUM_SLOTS, "Path to the sound file.");
|
||||||
|
|
||||||
addField("replay", TYPEID< SFXPlayList::EReplayMode >(), Offset(mPlaylist.mSlots.mReplayMode, SoundAsset), SFXPlayList::SFXPlaylistSettings::NUM_SLOTS,
|
addField("replay", TYPEID< SFXPlayList::EReplayMode >(), Offset(mPlaylist.mSlots.mReplayMode, SoundAsset), SFXPlayList::SFXPlaylistSettings::NUM_SLOTS,
|
||||||
"Behavior when an already playing sound is encountered on this slot from a previous cycle.\n"
|
"Behavior when an already playing sound is encountered on this slot from a previous cycle.\n"
|
||||||
|
|
@ -263,7 +264,9 @@ void SoundAsset::initPersistFields()
|
||||||
"Behavior when assigned state is deactivated while slot is playing.\n\n"
|
"Behavior when assigned state is deactivated while slot is playing.\n\n"
|
||||||
"@ref SFXPlayList_states");
|
"@ref SFXPlayList_states");
|
||||||
endArray("slots");
|
endArray("slots");
|
||||||
|
endGroup("SoundSlots");
|
||||||
|
|
||||||
|
addGroup("General Profile");
|
||||||
addField("pitchAdjust", TypeF32, Offset(mProfileDesc.mPitch, SoundAsset), "Adjustment of the pitch value 1 is default.");
|
addField("pitchAdjust", TypeF32, Offset(mProfileDesc.mPitch, SoundAsset), "Adjustment of the pitch value 1 is default.");
|
||||||
addField("volumeAdjust", TypeF32, Offset(mProfileDesc.mVolume, SoundAsset), "Adjustment to the volume.");
|
addField("volumeAdjust", TypeF32, Offset(mProfileDesc.mVolume, SoundAsset), "Adjustment to the volume.");
|
||||||
addField("is3D", TypeBool, Offset(mProfileDesc.mIs3D, SoundAsset), "Set this sound to 3D.");
|
addField("is3D", TypeBool, Offset(mProfileDesc.mIs3D, SoundAsset), "Set this sound to 3D.");
|
||||||
|
|
@ -274,6 +277,7 @@ void SoundAsset::initPersistFields()
|
||||||
addField("useHardware", TypeBool, Offset(mProfileDesc.mUseHardware, SoundAsset), "Use hardware mixing for this sound.");
|
addField("useHardware", TypeBool, Offset(mProfileDesc.mUseHardware, SoundAsset), "Use hardware mixing for this sound.");
|
||||||
addField("sourceGroup", TypeSFXSourceName, Offset(mProfileDesc.mSourceGroup, SoundAsset), "Group that sources playing with this description should be put into.");
|
addField("sourceGroup", TypeSFXSourceName, Offset(mProfileDesc.mSourceGroup, SoundAsset), "Group that sources playing with this description should be put into.");
|
||||||
addField("preload", TypeBool, Offset(mPreload, SoundAsset), "Whether to preload sound data when the profile is added to system.");
|
addField("preload", TypeBool, Offset(mPreload, SoundAsset), "Whether to preload sound data when the profile is added to system.");
|
||||||
|
endGroup("General Profile");
|
||||||
|
|
||||||
addGroup("Fading");
|
addGroup("Fading");
|
||||||
addField("fadeInTime", TypeF32, Offset(mProfileDesc.mFadeInTime, SoundAsset), "Number of seconds to gradually fade in volume from zero when playback starts.");
|
addField("fadeInTime", TypeF32, Offset(mProfileDesc.mFadeInTime, SoundAsset), "Number of seconds to gradually fade in volume from zero when playback starts.");
|
||||||
|
|
@ -321,6 +325,8 @@ void SoundAsset::initializeAsset(void)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
mSoundPath[i] = getOwned() ? expandAssetFilePath(mSoundFile[i]) : mSoundPath[i];
|
mSoundPath[i] = getOwned() ? expandAssetFilePath(mSoundFile[i]) : mSoundPath[i];
|
||||||
|
if (!Torque::FS::IsFile(mSoundPath[i]))
|
||||||
|
Con::errorf("SoundAsset::initializeAsset (%s)[%d] could not find %s!", getAssetName(), i, mSoundPath[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -437,32 +443,22 @@ U32 SoundAsset::load()
|
||||||
return mLoadedState;
|
return mLoadedState;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringTableEntry SoundAsset::getSoundFile(const char* pSoundFile, const U32 slotId)
|
bool SoundAsset::_setSoundFile(void* object, const char* index, const char* data)
|
||||||
{
|
{
|
||||||
for (U32 i = 0; i < 12; i++)
|
SoundAsset* pData = static_cast<SoundAsset*>(object);
|
||||||
{
|
|
||||||
if(mSoundFile[i] == pSoundFile)
|
|
||||||
return mSoundFile[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SoundAsset::setSoundFile(const char* pSoundFile, const U32 slotId)
|
U32 id = 0;
|
||||||
{
|
if (index)
|
||||||
// Sanity!
|
id = dAtoui(index);
|
||||||
AssertFatal(pSoundFile != NULL, "Cannot use a NULL sound file.");
|
|
||||||
|
|
||||||
// Fetch sound file.
|
|
||||||
pSoundFile = StringTable->insert(pSoundFile, true);
|
|
||||||
|
|
||||||
//Ignore no change,
|
|
||||||
if (pSoundFile == mSoundFile[slotId])
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Update.
|
// Update.
|
||||||
mSoundFile[slotId] = getOwned() ? expandAssetFilePath(pSoundFile) : pSoundFile;
|
pData->mSoundFile[id] = StringTable->insert(data, true);
|
||||||
|
if (pData->mSoundFile[id] == StringTable->EmptyString())
|
||||||
|
pData->mSoundPath[id] = StringTable->EmptyString();
|
||||||
|
|
||||||
// Refresh the asset.
|
// Refresh the asset.
|
||||||
refreshAsset();
|
pData->refreshAsset();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringTableEntry SoundAsset::getAssetIdByFileName(StringTableEntry fileName)
|
StringTableEntry SoundAsset::getAssetIdByFileName(StringTableEntry fileName)
|
||||||
|
|
|
||||||
|
|
@ -87,9 +87,9 @@ class SoundAsset : public AssetBase
|
||||||
typedef AssetPtr<SoundAsset> ConcreteAssetPtr;
|
typedef AssetPtr<SoundAsset> ConcreteAssetPtr;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
StringTableEntry mSoundFile[12];
|
StringTableEntry mSoundFile[SFXPlayList::SFXPlaylistSettings::NUM_SLOTS];
|
||||||
StringTableEntry mSoundPath[12];
|
StringTableEntry mSoundPath[SFXPlayList::SFXPlaylistSettings::NUM_SLOTS];
|
||||||
SFXProfile mSFXProfile[12];
|
SFXProfile mSFXProfile[SFXPlayList::SFXPlaylistSettings::NUM_SLOTS];
|
||||||
|
|
||||||
SFXDescription mProfileDesc;
|
SFXDescription mProfileDesc;
|
||||||
SFXPlayList mPlaylist;
|
SFXPlayList mPlaylist;
|
||||||
|
|
@ -155,9 +155,8 @@ public:
|
||||||
/// Declare Console Object.
|
/// Declare Console Object.
|
||||||
DECLARE_CONOBJECT(SoundAsset);
|
DECLARE_CONOBJECT(SoundAsset);
|
||||||
|
|
||||||
void setSoundFile(const char* pSoundFile, const U32 slotId = 0);
|
static bool _setSoundFile(void* object, const char* index, const char* data);
|
||||||
U32 load();
|
U32 load();
|
||||||
StringTableEntry getSoundFile(const char* pSoundFile, const U32 slotId = 0);
|
|
||||||
inline StringTableEntry getSoundPath(const U32 slotId = 0) const { return mSoundPath[slotId]; };
|
inline StringTableEntry getSoundPath(const U32 slotId = 0) const { return mSoundPath[slotId]; };
|
||||||
SFXProfile* getSfxProfile(const U32 slotId = 0) { return &mSFXProfile[slotId]; }
|
SFXProfile* getSfxProfile(const U32 slotId = 0) { return &mSFXProfile[slotId]; }
|
||||||
SFXPlayList* getSfxPlaylist() { return &mPlaylist; }
|
SFXPlayList* getSfxPlaylist() { return &mPlaylist; }
|
||||||
|
|
@ -176,9 +175,6 @@ protected:
|
||||||
virtual void initializeAsset(void);
|
virtual void initializeAsset(void);
|
||||||
void _onResourceChanged(const Torque::Path & path);
|
void _onResourceChanged(const Torque::Path & path);
|
||||||
virtual void onAssetRefresh(void);
|
virtual void onAssetRefresh(void);
|
||||||
|
|
||||||
static bool _setSoundFile(void *obj, const char *index, const char *data) { static_cast<SoundAsset*>(obj)->setSoundFile(data, index ? dAtoi(index) : 0); return false; }
|
|
||||||
static const char* _getSoundFile(void* obj, const char* data) { return static_cast<SoundAsset*>(obj)->getSoundFile(data); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DefineConsoleType(TypeSoundAssetPtr, SoundAsset)
|
DefineConsoleType(TypeSoundAssetPtr, SoundAsset)
|
||||||
|
|
|
||||||
|
|
@ -3345,8 +3345,8 @@ Torque::Path AssetImporter::importSoundAsset(AssetImportObject* assetItem)
|
||||||
|
|
||||||
StringTableEntry assetName = StringTable->insert(assetItem->assetName.c_str());
|
StringTableEntry assetName = StringTable->insert(assetItem->assetName.c_str());
|
||||||
|
|
||||||
String imageFileName = assetItem->filePath.getFileName() + "." + assetItem->filePath.getExtension();
|
String soundFileName = assetItem->filePath.getFileName() + "." + assetItem->filePath.getExtension();
|
||||||
String assetPath = targetPath + "/" + imageFileName;
|
String assetPath = targetPath + "/" + soundFileName;
|
||||||
String tamlPath = targetPath + "/" + assetName + ".asset.taml";
|
String tamlPath = targetPath + "/" + assetName + ".asset.taml";
|
||||||
String originalPath = assetItem->filePath.getFullPath().c_str();
|
String originalPath = assetItem->filePath.getFullPath().c_str();
|
||||||
|
|
||||||
|
|
@ -3362,7 +3362,7 @@ Torque::Path AssetImporter::importSoundAsset(AssetImportObject* assetItem)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
newAsset->setAssetName(assetName);
|
newAsset->setAssetName(assetName);
|
||||||
newAsset->setSoundFile(imageFileName.c_str());
|
newAsset->_setSoundFile(newAsset, "0", soundFileName.c_str());
|
||||||
|
|
||||||
//If it's not a re-import, check that the file isn't being in-place imported. If it isn't, store off the original
|
//If it's not a re-import, check that the file isn't being in-place imported. If it isn't, store off the original
|
||||||
//file path for reimporting support later
|
//file path for reimporting support later
|
||||||
|
|
|
||||||
|
|
@ -277,7 +277,8 @@ SFXSource::SFXSource( SFXTrack* track, SFXDescription* description )
|
||||||
|
|
||||||
if( mTrack != NULL )
|
if( mTrack != NULL )
|
||||||
deleteNotify( mTrack );
|
deleteNotify( mTrack );
|
||||||
deleteNotify( mDescription );
|
if (mDescription != NULL)
|
||||||
|
deleteNotify( mDescription );
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue