Refactor of sound asset

Refactored to match image asset.
This commit is contained in:
marauder2k7 2026-04-05 14:17:17 +01:00
parent 5796f0ea07
commit 71273e63c9
46 changed files with 639 additions and 775 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;
@ -393,9 +391,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;
}
//otherwise, pass the event to it's parent

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

@ -264,8 +264,7 @@ class GuiMLTextCtrl : public GuiControl
bool mUseURLMouseCursor;
// Too many chars sound:
DECLARE_SOUNDASSET(GuiMLTextCtrl, DeniedSound);
DECLARE_ASSET_SETGET(GuiMLTextCtrl, DeniedSound);
DECLARE_SOUNDASSET(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;
@ -322,19 +320,8 @@ GuiControlProfile::GuiControlProfile(void) :
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.");
}
_setSoundButtonDown(def->getSoundButtonDownFile());
_setSoundButtonOver(def->getSoundButtonOverFile());
//used by GuiTextCtrl
mModal = def->mModal;

View file

@ -466,11 +466,8 @@ public:
bool mUseBitmapArray; ///< Flag to use the bitmap array or to fallback to non-array rendering
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);
DECLARE_SOUNDASSET(GuiControlProfile, SoundButtonDown) ///< Sound played when a button is pressed.
DECLARE_SOUNDASSET(GuiControlProfile, SoundButtonOver) ///< Sound played when a button is hovered.
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

@ -83,8 +83,7 @@ protected:
void _update();
public:
DECLARE_SOUNDASSET(GuiAudioCtrl, Sound);
DECLARE_ASSET_SETGET(GuiAudioCtrl, Sound);
DECLARE_SOUNDASSET(GuiAudioCtrl, Sound)
GuiAudioCtrl();
~GuiAudioCtrl();
// GuiControl.