mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-27 07:15:37 +00:00
sound asset conversions - afxmagicmissile for a datablock case and guimltextcrtl for an object-instance case
This commit is contained in:
parent
33210c4a1e
commit
00515fffa8
4 changed files with 30 additions and 20 deletions
|
|
@ -142,8 +142,7 @@ U32 Projectile::smProjectileWarpTicks = 5;
|
||||||
afxMagicMissileData::afxMagicMissileData()
|
afxMagicMissileData::afxMagicMissileData()
|
||||||
{
|
{
|
||||||
INIT_ASSET(ProjectileShape);
|
INIT_ASSET(ProjectileShape);
|
||||||
|
INIT_ASSET(ProjectileSound);
|
||||||
sound = NULL;
|
|
||||||
|
|
||||||
/* From stock Projectile code...
|
/* From stock Projectile code...
|
||||||
explosion = NULL;
|
explosion = NULL;
|
||||||
|
|
@ -248,7 +247,7 @@ afxMagicMissileData::afxMagicMissileData(const afxMagicMissileData& other, bool
|
||||||
{
|
{
|
||||||
CLONE_ASSET(ProjectileShape);
|
CLONE_ASSET(ProjectileShape);
|
||||||
projectileShape = other.projectileShape; // -- TSShape loads using projectileShapeName
|
projectileShape = other.projectileShape; // -- TSShape loads using projectileShapeName
|
||||||
sound = other.sound;
|
CLONE_ASSET(ProjectileSound);
|
||||||
splash = other.splash;
|
splash = other.splash;
|
||||||
splashId = other.splashId; // -- for pack/unpack of splash ptr
|
splashId = other.splashId; // -- for pack/unpack of splash ptr
|
||||||
lightDesc = other.lightDesc;
|
lightDesc = other.lightDesc;
|
||||||
|
|
@ -338,7 +337,7 @@ void afxMagicMissileData::initPersistFields()
|
||||||
INITPERSISTFIELD_SHAPEASSET(ProjectileShape, afxMagicMissileData, "Shape for the projectile");
|
INITPERSISTFIELD_SHAPEASSET(ProjectileShape, afxMagicMissileData, "Shape for the projectile");
|
||||||
addField("scale", TypePoint3F, Offset(scale, afxMagicMissileData));
|
addField("scale", TypePoint3F, Offset(scale, afxMagicMissileData));
|
||||||
|
|
||||||
addField("sound", TypeSFXTrackName, Offset(sound, afxMagicMissileData));
|
INITPERSISTFIELD_SOUNDASSET(ProjectileSound, afxMagicMissileData, "sound for the projectile");
|
||||||
|
|
||||||
/* From stock Projectile code...
|
/* From stock Projectile code...
|
||||||
addField("explosion", TYPEID< ExplosionData >(), Offset(explosion, ProjectileData));
|
addField("explosion", TYPEID< ExplosionData >(), Offset(explosion, ProjectileData));
|
||||||
|
|
@ -533,9 +532,12 @@ bool afxMagicMissileData::preload(bool server, String &errorStr)
|
||||||
Con::errorf(ConsoleLogEntry::General, "ProjectileData::preload: Invalid packet, bad datablockId(decal): %d", decalId);
|
Con::errorf(ConsoleLogEntry::General, "ProjectileData::preload: Invalid packet, bad datablockId(decal): %d", decalId);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
String sfxErrorStr;
|
_setProjectileSound(getProjectileSound());
|
||||||
if( !sfxResolve( &sound, sfxErrorStr) )
|
if (getProjectileSound() != StringTable->EmptyString())
|
||||||
Con::errorf(ConsoleLogEntry::General, "afxMagicMissileData::preload: Invalid packet: %s", sfxErrorStr.c_str());
|
{
|
||||||
|
if (!getProjectileSoundProfile())
|
||||||
|
Con::errorf(ConsoleLogEntry::General, "afxMagicMissileData::preload: Cant get an sfxProfile for afxMagicMissileData.");
|
||||||
|
}
|
||||||
|
|
||||||
if (!lightDesc && lightDescId != 0)
|
if (!lightDesc && lightDescId != 0)
|
||||||
if (Sim::findObject(lightDescId, lightDesc) == false)
|
if (Sim::findObject(lightDescId, lightDesc) == false)
|
||||||
|
|
@ -547,7 +549,7 @@ bool afxMagicMissileData::preload(bool server, String &errorStr)
|
||||||
projectileShape = mProjectileShapeAsset->getShapeResource();
|
projectileShape = mProjectileShapeAsset->getShapeResource();
|
||||||
if (bool(projectileShape) == false)
|
if (bool(projectileShape) == false)
|
||||||
{
|
{
|
||||||
errorStr = String::ToString("afxMagicMissileData::load: Couldn't load shape \"%s\"", mProjectileShapeAssetId);
|
errorStr = String::ToString("afxMagicMissileData::preload: Couldn't load shape \"%s\"", mProjectileShapeAssetId);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/* From stock Projectile code...
|
/* From stock Projectile code...
|
||||||
|
|
@ -641,7 +643,7 @@ void afxMagicMissileData::packData(BitStream* stream)
|
||||||
DataBlockObjectIdLast);
|
DataBlockObjectIdLast);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
sfxWrite( stream, sound );
|
PACKDATA_ASSET(ProjectileSound);
|
||||||
|
|
||||||
if ( stream->writeFlag(lightDesc != NULL))
|
if ( stream->writeFlag(lightDesc != NULL))
|
||||||
stream->writeRangedU32(lightDesc->getId(), DataBlockObjectIdFirst,
|
stream->writeRangedU32(lightDesc->getId(), DataBlockObjectIdFirst,
|
||||||
|
|
@ -747,7 +749,7 @@ void afxMagicMissileData::unpackData(BitStream* stream)
|
||||||
decalId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast);
|
decalId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
sfxRead( stream, &sound );
|
UNPACKDATA_ASSET(ProjectileSound);
|
||||||
|
|
||||||
if (stream->readFlag())
|
if (stream->readFlag())
|
||||||
lightDescId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast);
|
lightDescId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast);
|
||||||
|
|
@ -1170,8 +1172,8 @@ bool afxMagicMissile::onNewDataBlock(GameBaseData* dptr, bool reload)
|
||||||
|
|
||||||
SFX_DELETE( mSound );
|
SFX_DELETE( mSound );
|
||||||
|
|
||||||
if ( mDataBlock->sound )
|
if (mDataBlock->getProjectileSound())
|
||||||
mSound = SFX->createSource( mDataBlock->sound );
|
mSound = SFX->createSource(mDataBlock->getProjectileSoundProfile());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -2006,7 +2008,7 @@ void afxMagicMissile::get_launch_data(Point3F& pos, Point3F& vel)
|
||||||
|
|
||||||
void afxMagicMissile::updateSound()
|
void afxMagicMissile::updateSound()
|
||||||
{
|
{
|
||||||
if (!mDataBlock->sound)
|
if (!mDataBlock->isProjectileSoundValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( mSound )
|
if ( mSound )
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,8 @@ public:
|
||||||
SplashData* splash; // Water Splash Datablock
|
SplashData* splash; // Water Splash Datablock
|
||||||
S32 splashId; // Water splash ID
|
S32 splashId; // Water splash ID
|
||||||
|
|
||||||
SFXTrack* sound; // Projectile Sound
|
DECLARE_SOUNDASSET(afxMagicMissileData, ProjectileSound);
|
||||||
|
DECLARE_ASSET_SETGET(afxMagicMissileData, ProjectileSound);
|
||||||
|
|
||||||
LightDescription *lightDesc;
|
LightDescription *lightDesc;
|
||||||
S32 lightDescId;
|
S32 lightDescId;
|
||||||
|
|
|
||||||
|
|
@ -268,7 +268,7 @@ GuiMLTextCtrl::GuiMLTextCtrl()
|
||||||
{
|
{
|
||||||
mActive = true;
|
mActive = true;
|
||||||
//mInitialText = StringTable->EmptyString();
|
//mInitialText = StringTable->EmptyString();
|
||||||
Sim::findObject("InputDeniedSound", mDeniedSound);
|
INIT_ASSET(DeniedSound);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
|
|
@ -290,7 +290,7 @@ void GuiMLTextCtrl::initPersistFields()
|
||||||
addField("lineSpacing", TypeS32, Offset(mLineSpacingPixels, GuiMLTextCtrl), "The number of blank pixels to place between each line.\n");
|
addField("lineSpacing", TypeS32, Offset(mLineSpacingPixels, GuiMLTextCtrl), "The number of blank pixels to place between each line.\n");
|
||||||
addField("allowColorChars", TypeBool, Offset(mAllowColorChars, GuiMLTextCtrl), "If true, the control will allow characters to have unique colors.");
|
addField("allowColorChars", TypeBool, Offset(mAllowColorChars, GuiMLTextCtrl), "If true, the control will allow characters to have unique colors.");
|
||||||
addField("maxChars", TypeS32, Offset(mMaxBufferSize, GuiMLTextCtrl), "Maximum number of characters that the control will display.");
|
addField("maxChars", TypeS32, Offset(mMaxBufferSize, GuiMLTextCtrl), "Maximum number of characters that the control will display.");
|
||||||
addField("deniedSound", TypeSFXTrackName, Offset(mDeniedSound, GuiMLTextCtrl), "If the text will not fit in the control, the deniedSound is played.");
|
INITPERSISTFIELD_SOUNDASSET(DeniedSound, GuiMLTextCtrl, "If the text will not fit in the control, the deniedSound is played.");
|
||||||
addField("text", TypeCaseString, Offset( mInitialText, GuiMLTextCtrl ), "Text to display in this control.");
|
addField("text", TypeCaseString, Offset( mInitialText, GuiMLTextCtrl ), "Text to display in this control.");
|
||||||
addField("useURLMouseCursor", TypeBool, Offset(mUseURLMouseCursor, GuiMLTextCtrl), "If true, the mouse cursor will turn into a hand cursor while over a link in the text.\n"
|
addField("useURLMouseCursor", TypeBool, Offset(mUseURLMouseCursor, GuiMLTextCtrl), "If true, the mouse cursor will turn into a hand cursor while over a link in the text.\n"
|
||||||
"This is dependant on the markup language used by the GuiMLTextCtrl\n");
|
"This is dependant on the markup language used by the GuiMLTextCtrl\n");
|
||||||
|
|
@ -323,6 +323,9 @@ bool GuiMLTextCtrl::onAdd()
|
||||||
|
|
||||||
if (!mTextBuffer.length() && mInitialText[0] != 0)
|
if (!mTextBuffer.length() && mInitialText[0] != 0)
|
||||||
setText(mInitialText, dStrlen(mInitialText)+1);
|
setText(mInitialText, dStrlen(mInitialText)+1);
|
||||||
|
|
||||||
|
_setDeniedSound(getDeniedSound());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -917,8 +920,8 @@ void GuiMLTextCtrl::insertChars(const char* inputChars,
|
||||||
if (numCharsToInsert <= 0)
|
if (numCharsToInsert <= 0)
|
||||||
{
|
{
|
||||||
// Play the "Denied" sound:
|
// Play the "Denied" sound:
|
||||||
if ( numInputChars > 0 && mDeniedSound )
|
if ( numInputChars > 0 && getDeniedSoundProfile())
|
||||||
SFX->playOnce(mDeniedSound);
|
SFX->playOnce(getDeniedSoundProfile());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,10 @@
|
||||||
#include "core/stringBuffer.h"
|
#include "core/stringBuffer.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef SOUND_ASSET_H
|
||||||
|
#include "T3D/assets/SoundAsset.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
class GFont;
|
class GFont;
|
||||||
class SFXTrack;
|
class SFXTrack;
|
||||||
|
|
||||||
|
|
@ -258,8 +262,8 @@ class GuiMLTextCtrl : public GuiControl
|
||||||
bool mUseURLMouseCursor;
|
bool mUseURLMouseCursor;
|
||||||
|
|
||||||
// Too many chars sound:
|
// Too many chars sound:
|
||||||
SFXTrack* mDeniedSound;
|
DECLARE_SOUNDASSET(GuiMLTextCtrl, DeniedSound);
|
||||||
|
DECLARE_ASSET_SETGET(GuiMLTextCtrl, DeniedSound);
|
||||||
//-------------------------------------- Protected interface
|
//-------------------------------------- Protected interface
|
||||||
protected:
|
protected:
|
||||||
// Inserting and deleting character blocks...
|
// Inserting and deleting character blocks...
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue