SoundAsset Refactor

This commit is contained in:
marauder2k7 2025-12-12 12:27:33 +00:00
parent 9f29bee45f
commit da40838560
61 changed files with 1333 additions and 1828 deletions

View file

@ -258,8 +258,7 @@ void GuiButtonBaseCtrl::onMouseDown(const GuiEvent& event)
if (mProfile->mCanKeyFocus)
setFirstResponder();
if (mProfile->isSoundButtonDownValid())
SFX->playOnce(mProfile->getSoundButtonDownProfile());
SFX->playOnce(mProfile->getSoundButtonDownSFXTrack());
mMouseDownPoint = event.mousePoint;
mMouseDragged = false;
@ -299,8 +298,7 @@ void GuiButtonBaseCtrl::onMouseEnter(const GuiEvent& event)
}
else
{
if (mProfile->isSoundButtonOverValid())
SFX->playOnce(mProfile->getSoundButtonOverProfile());
SFX->playOnce(mProfile->getSoundButtonOverSFXTrack());
mHighlighted = true;
messageSiblings(mRadioGroup);
@ -388,8 +386,7 @@ bool GuiButtonBaseCtrl::onKeyDown(const GuiEvent& event)
if ((event.keyCode == KEY_RETURN || event.keyCode == KEY_SPACE)
&& event.modifier == 0)
{
if (mProfile->isSoundButtonDownValid())
SFX->playOnce(mProfile->getSoundButtonDownProfile());
SFX->playOnce(mProfile->getSoundButtonDownSFXTrack());
return true;
}

View file

@ -282,7 +282,6 @@ GuiMLTextCtrl::GuiMLTextCtrl()
{
mActive = true;
//mInitialText = StringTable->EmptyString();
INIT_ASSET(DeniedSound);
}
//--------------------------------------------------------------------------
@ -344,8 +343,6 @@ bool GuiMLTextCtrl::onAdd()
if (!mTextBuffer.length() && mInitialText[0] != 0)
setText(mInitialText, dStrlen(mInitialText)+1);
_setDeniedSound(getDeniedSound());
return true;
}
@ -964,8 +961,8 @@ void GuiMLTextCtrl::insertChars(const char* inputChars,
if (numCharsToInsert <= 0)
{
// Play the "Denied" sound:
if ( numInputChars > 0 && getDeniedSoundProfile())
SFX->playOnce(getDeniedSoundProfile());
if ( numInputChars > 0)
SFX->playOnce(getDeniedSoundSFXTrack());
return;
}

View file

@ -265,7 +265,6 @@ class GuiMLTextCtrl : public GuiControl
// Too many chars sound:
DECLARE_SOUNDASSET(GuiMLTextCtrl, DeniedSound);
DECLARE_ASSET_SETGET(GuiMLTextCtrl, DeniedSound);
// Typeout over time
bool mUseTypeOverTime;
U32 mTypeOverTimeStartMS;

View file

@ -205,8 +205,7 @@ void GuiSliderCtrl::onMouseDown(const GuiEvent &event)
setFirstResponder();
mDepressed = true;
if (mProfile->isSoundButtonDownValid())
SFX->playOnce(mProfile->getSoundButtonDownProfile());
SFX->playOnce(mProfile->getSoundButtonDownSFXTrack());
Point2I curMousePos = globalToLocalCoord( event.mousePoint );
F32 value;
@ -262,11 +261,9 @@ void GuiSliderCtrl::onMouseEnter(const GuiEvent &event)
}
else
{
if( mActive && mProfile->mSoundButtonOver )
if( mActive )
{
//F32 pan = (F32(event.mousePoint.x)/F32(getRoot()->getWidth())*2.0f-1.0f)*0.8f;
if (mProfile->isSoundButtonOverValid())
SFX->playOnce(mProfile->getSoundButtonOverProfile());
SFX->playOnce(mProfile->getSoundButtonOverSFXTrack());
}
mMouseOver = true;

View file

@ -244,8 +244,6 @@ GuiControlProfile::GuiControlProfile(void) :
mTextOffset(0,0),
mBitmapArrayRects(0)
{
INIT_ASSET(SoundButtonDown);
INIT_ASSET(SoundButtonOver);
mLoadCount = 0;
mUseCount = 0;
@ -321,21 +319,6 @@ GuiControlProfile::GuiControlProfile(void) :
mUseBitmapArray = def->mUseBitmapArray;
mTextOffset = def->mTextOffset;
// default sound
_setSoundButtonDown(def->getSoundButtonDown());
if (getSoundButtonDown() != StringTable->EmptyString())
{
if (!getSoundButtonDownProfile())
Con::errorf(ConsoleLogEntry::General, "GuiControlProfile: Can't get default button pressed sound asset.");
}
_setSoundButtonOver(def->getSoundButtonOver());
if (getSoundButtonOver() != StringTable->EmptyString())
{
if (!getSoundButtonOverProfile())
Con::errorf(ConsoleLogEntry::General, "GuiControlProfile: Can't get default button hover sound asset.");
}
//used by GuiTextCtrl
mModal = def->mModal;
mAlignment = def->mAlignment;

View file

@ -467,10 +467,8 @@ public:
Vector<RectI> mBitmapArrayRects; ///< Used for controls which use an array of bitmaps such as checkboxes
DECLARE_SOUNDASSET(GuiControlProfile, SoundButtonDown); ///< Sound played when a button is pressed.
DECLARE_ASSET_SETGET(GuiControlProfile, SoundButtonDown);
DECLARE_SOUNDASSET(GuiControlProfile, SoundButtonOver); ///< Sound played when a button is hovered.
DECLARE_ASSET_SETGET(GuiControlProfile, SoundButtonOver);
StringTableEntry mChildrenProfileName; ///< The name of the profile to use for the children controls

View file

@ -40,7 +40,6 @@ ConsoleDocClass( GuiAudioCtrl,
GuiAudioCtrl::GuiAudioCtrl()
{
INIT_ASSET(Sound);
mTickPeriodMS = 100;
mLastThink = 0;
mCurrTick = 0;
@ -85,7 +84,7 @@ void GuiAudioCtrl::processTick()
{
mCurrTick = 0;
mLastThink = 0;
if (isSoundValid())
if (getSoundAsset().notNull())
{
_update();
}
@ -154,14 +153,11 @@ void GuiAudioCtrl::_update()
if (testCondition() && isAwake())
{
bool useTrackDescriptionOnly = (mUseTrackDescriptionOnly && getSoundProfile());
bool useTrackDescriptionOnly = mUseTrackDescriptionOnly;
if (getSoundProfile())
if (mSoundPlaying == NULL)
{
if (mSoundPlaying == NULL)
{
mSoundPlaying = SFX->createSource(getSoundProfile(), &(SFX->getListener().getTransform()));
}
mSoundPlaying = SFX->createSource(getSoundSFXTrack(), &(SFX->getListener().getTransform()));
}
if ( mSoundPlaying && !mSoundPlaying->isPlaying())

View file

@ -84,7 +84,6 @@ protected:
public:
DECLARE_SOUNDASSET(GuiAudioCtrl, Sound);
DECLARE_ASSET_SETGET(GuiAudioCtrl, Sound);
GuiAudioCtrl();
~GuiAudioCtrl();
// GuiControl.