mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-12 19:31:41 +00:00
Converts all game, gui editor, and system classes to utilize assets
Processed core, tools and default modules to utilize assets Converted all console types that were string based, such as TypeImageFilename to utilize const char*/the string table, which avoids a lot of type swapping shenanigans and avoids string corruption Removed unneeded MainEditor mockup module Removed some unused/duplicate image assets from the tools
This commit is contained in:
parent
83b0432283
commit
5525f8ecdd
1708 changed files with 19619 additions and 4596 deletions
|
|
@ -42,19 +42,20 @@
|
|||
|
||||
// Debug Profiling.
|
||||
#include "platform/profiler.h"
|
||||
#include "sfx/sfxTypes.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_CONOBJECT(SoundAsset);
|
||||
|
||||
ConsoleType(SoundAssetPtr, TypeSoundAssetPtr, SoundAsset, ASSET_ID_FIELD_PREFIX)
|
||||
ConsoleType(SoundAssetPtr, TypeSoundAssetPtr, const char*, ASSET_ID_FIELD_PREFIX)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleGetType(TypeSoundAssetPtr)
|
||||
{
|
||||
// Fetch asset Id.
|
||||
return (*((AssetPtr<SoundAsset>*)dptr)).getAssetId();
|
||||
return *((const char**)(dptr));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -65,21 +66,7 @@ ConsoleSetType(TypeSoundAssetPtr)
|
|||
if (argc == 1)
|
||||
{
|
||||
// Yes, so fetch field value.
|
||||
const char* pFieldValue = argv[0];
|
||||
|
||||
// Fetch asset pointer.
|
||||
AssetPtr<SoundAsset>* pAssetPtr = dynamic_cast<AssetPtr<SoundAsset>*>((AssetPtrBase*)(dptr));
|
||||
|
||||
// Is the asset pointer the correct type?
|
||||
if (pAssetPtr == NULL)
|
||||
{
|
||||
// No, so fail.
|
||||
//Con::warnf("(TypeSoundAssetPtr) - Failed to set asset Id '%d'.", pFieldValue);
|
||||
return;
|
||||
}
|
||||
|
||||
// Set asset.
|
||||
pAssetPtr->setAssetId(pFieldValue);
|
||||
*((const char**)dptr) = StringTable->insert(argv[0]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -90,15 +77,57 @@ ConsoleSetType(TypeSoundAssetPtr)
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleType(assetIdString, TypeSoundAssetId, const char*, ASSET_ID_FIELD_PREFIX)
|
||||
|
||||
ConsoleGetType(TypeSoundAssetId)
|
||||
{
|
||||
// Fetch asset Id.
|
||||
return *((const char**)(dptr));
|
||||
}
|
||||
|
||||
ConsoleSetType(TypeSoundAssetId)
|
||||
{
|
||||
// Was a single argument specified?
|
||||
if (argc == 1)
|
||||
{
|
||||
// Yes, so fetch field value.
|
||||
*((const char**)dptr) = StringTable->insert(argv[0]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Warn.
|
||||
Con::warnf("(TypeAssetId) - Cannot set multiple args to a single asset.");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
SoundAsset::SoundAsset()
|
||||
{
|
||||
mSoundFile = StringTable->EmptyString();
|
||||
mSoundPath = StringTable->EmptyString();
|
||||
mSubtitleString = StringTable->EmptyString();
|
||||
|
||||
mPitchAdjust = 1;
|
||||
mVolumeAdjust = 1;
|
||||
mLoadedState = AssetErrCode::NotLoaded;
|
||||
mPreload = false;
|
||||
// SFX description inits
|
||||
// reverb is useless here, reverb is inacted on listener.
|
||||
mProfileDesc.mPitch = 1;
|
||||
mProfileDesc.mVolume = 1;
|
||||
mProfileDesc.mIs3D = false;
|
||||
mProfileDesc.mIsLooping = false;
|
||||
mProfileDesc.mIsStreaming = false;
|
||||
mProfileDesc.mUseHardware = false;
|
||||
mProfileDesc.mMinDistance = 1;
|
||||
mProfileDesc.mMaxDistance = 100;
|
||||
mProfileDesc.mConeInsideAngle = 360;
|
||||
mProfileDesc.mConeOutsideAngle = 360;
|
||||
mProfileDesc.mConeOutsideVolume = 1;
|
||||
mProfileDesc.mRolloffFactor = -1.0f;
|
||||
mProfileDesc.mScatterDistance = Point3F(0.f, 0.f, 0.f);
|
||||
mProfileDesc.mPriority = 1.0f;
|
||||
mProfileDesc.mSourceGroup = NULL;
|
||||
|
||||
//mSound = nullptr;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -117,8 +146,24 @@ void SoundAsset::initPersistFields()
|
|||
addProtectedField("soundFile", TypeAssetLooseFilePath, Offset(mSoundFile, SoundAsset),
|
||||
&setSoundFile, &getSoundFile, "Path to the sound file.");
|
||||
|
||||
addField("pitchAdjust", TypeF32, Offset(mPitchAdjust, SoundAsset), "Adjustment of the pitch value");
|
||||
addField("volumeAdjust", TypeF32, Offset(mVolumeAdjust, SoundAsset), "Adjustment to the volume.");
|
||||
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("is3D", TypeBool, Offset(mProfileDesc.mIs3D, SoundAsset), "Set this sound to 3D.");
|
||||
addField("isLooping", TypeBool, Offset(mProfileDesc.mIsLooping, SoundAsset), "Does this sound loop.");
|
||||
// if streaming, a default packet size should be chosen for all sounds.
|
||||
addField("isStreaming", TypeBool, Offset(mProfileDesc.mIsStreaming, SoundAsset), "Use streaming.");
|
||||
//....why?
|
||||
addField("useHardware", TypeBool, Offset(mProfileDesc.mUseHardware, SoundAsset), "Use hardware mixing for this sound.");
|
||||
addField("minDistance", TypeF32, Offset(mProfileDesc.mMinDistance, SoundAsset), "Minimum distance for sound.");
|
||||
// more like it.
|
||||
addField("maxDistance", TypeF32, Offset(mProfileDesc.mMaxDistance, SoundAsset), "Max distance for sound.");
|
||||
addField("coneInsideAngle", TypeS32, Offset(mProfileDesc.mConeInsideAngle, SoundAsset), "Cone inside angle.");
|
||||
addField("coneOutsideAngle", TypeS32, Offset(mProfileDesc.mConeOutsideAngle, SoundAsset), "Cone outside angle.");
|
||||
addField("coneOutsideVolume", TypeS32, Offset(mProfileDesc.mConeOutsideVolume, SoundAsset), "Cone outside volume.");
|
||||
addField("rolloffFactor", TypeF32, Offset(mProfileDesc.mRolloffFactor, SoundAsset), "Rolloff factor.");
|
||||
addField("scatterDistance", TypePoint3F, Offset(mProfileDesc.mScatterDistance, SoundAsset), "Randomization to the spacial position of the sound.");
|
||||
addField("sourceGroup", TypeSFXSourceName, Offset(mProfileDesc.mSourceGroup, SoundAsset), "Group that sources playing with this description should be put into.");
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
@ -131,20 +176,73 @@ void SoundAsset::copyTo(SimObject* object)
|
|||
|
||||
void SoundAsset::initializeAsset(void)
|
||||
{
|
||||
mSoundPath = expandAssetFilePath(mSoundFile);
|
||||
Parent::initializeAsset();
|
||||
|
||||
if (mSoundFile == StringTable->EmptyString())
|
||||
return;
|
||||
|
||||
//ResourceManager::get().getChangedSignal.notify(this, &SoundAsset::_onResourceChanged);
|
||||
|
||||
//Ensure our path is expando'd if it isn't already
|
||||
if (!Platform::isFullPath(mSoundPath))
|
||||
mSoundPath = getOwned() ? expandAssetFilePath(mSoundFile) : mSoundPath;
|
||||
|
||||
mSoundPath = expandAssetFilePath(mSoundPath);
|
||||
|
||||
loadSound();
|
||||
}
|
||||
|
||||
void SoundAsset::_onResourceChanged(const Torque::Path &path)
|
||||
{
|
||||
if (path != Torque::Path(mSoundPath))
|
||||
return;
|
||||
|
||||
refreshAsset();
|
||||
|
||||
loadSound();
|
||||
}
|
||||
|
||||
void SoundAsset::onAssetRefresh(void)
|
||||
{
|
||||
mSoundPath = expandAssetFilePath(mSoundFile);
|
||||
if (mSoundFile == StringTable->EmptyString())
|
||||
return;
|
||||
|
||||
//Update
|
||||
if (!Platform::isFullPath(mSoundFile))
|
||||
mSoundPath = getOwned() ? expandAssetFilePath(mSoundFile) : mSoundPath;
|
||||
|
||||
loadSound();
|
||||
}
|
||||
|
||||
bool SoundAsset::loadSound()
|
||||
{
|
||||
if (mSoundPath)
|
||||
{
|
||||
if (!Platform::isFile(mSoundPath))
|
||||
{
|
||||
Con::errorf("SoundAsset::initializeAsset: Attempted to load file %s but it was not valid!", mSoundFile);
|
||||
mLoadedState = BadFileReference;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{// = new SFXProfile(mProfileDesc, mSoundFile, mPreload);
|
||||
mSFXProfile.setDescription(&mProfileDesc);
|
||||
mSFXProfile.setSoundFileName(mSoundFile);
|
||||
mSFXProfile.setPreload(mPreload);
|
||||
}
|
||||
|
||||
}
|
||||
mChangeSignal.trigger();
|
||||
mLoadedState = Ok;
|
||||
return true;
|
||||
}
|
||||
|
||||
void SoundAsset::setSoundFile(const char* pSoundFile)
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(pSoundFile != NULL, "Cannot use a NULL shape file.");
|
||||
AssertFatal(pSoundFile != NULL, "Cannot use a NULL sound file.");
|
||||
|
||||
// Fetch image file.
|
||||
// Fetch sound file.
|
||||
pSoundFile = StringTable->insert(pSoundFile);
|
||||
|
||||
// Ignore no change,
|
||||
|
|
@ -152,7 +250,7 @@ void SoundAsset::setSoundFile(const char* pSoundFile)
|
|||
return;
|
||||
|
||||
// Update.
|
||||
mSoundFile = StringTable->insert(pSoundFile);
|
||||
mSoundFile = pSoundFile;
|
||||
|
||||
// Refresh the asset.
|
||||
refreshAsset();
|
||||
|
|
@ -162,3 +260,43 @@ DefineEngineMethod(SoundAsset, getSoundPath, const char*, (), , "")
|
|||
{
|
||||
return object->getSoundPath();
|
||||
}
|
||||
|
||||
IMPLEMENT_CONOBJECT(GuiInspectorTypeSoundAssetPtr);
|
||||
|
||||
ConsoleDocClass(GuiInspectorTypeSoundAssetPtr,
|
||||
"@brief Inspector field type for Sounds\n\n"
|
||||
"Editor use only.\n\n"
|
||||
"@internal"
|
||||
);
|
||||
|
||||
void GuiInspectorTypeSoundAssetPtr::consoleInit()
|
||||
{
|
||||
Parent::consoleInit();
|
||||
|
||||
ConsoleBaseType::getType(TypeSoundAssetPtr)->setInspectorFieldType("GuiInspectorTypeSoundAssetPtr");
|
||||
}
|
||||
|
||||
GuiControl * GuiInspectorTypeSoundAssetPtr::constructEditControl()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool GuiInspectorTypeSoundAssetPtr::updateRects()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
IMPLEMENT_CONOBJECT(GuiInspectorTypeSoundAssetId);
|
||||
|
||||
ConsoleDocClass(GuiInspectorTypeSoundAssetId,
|
||||
"@brief Inspector field type for Sounds\n\n"
|
||||
"Editor use only.\n\n"
|
||||
"@internal"
|
||||
);
|
||||
|
||||
void GuiInspectorTypeSoundAssetId::consoleInit()
|
||||
{
|
||||
Parent::consoleInit();
|
||||
|
||||
ConsoleBaseType::getType(TypeSoundAssetId)->setInspectorFieldType("GuiInspectorTypeSoundAssetId");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue