Skip to content

Commit

Permalink
Merge pull request #1302 from Azaezel/alpha41/guiAudioCtrlFixes
Browse files Browse the repository at this point in the history
guiAudiocCtrl fixes
  • Loading branch information
Azaezel authored Aug 7, 2024
2 parents 9260250 + e4b1a86 commit 35e50b5
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 27 deletions.
41 changes: 15 additions & 26 deletions Engine/source/gui/shiny/guiAudioCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,42 +43,38 @@ GuiAudioCtrl::GuiAudioCtrl()
mTickPeriodMS = 100;
mLastThink = 0;
mCurrTick = 0;
mPlayIf = "";
mSoundPlaying = NULL;

mUseTrackDescriptionOnly = false;
mDescription.mIs3D = false;
mDescription.mIsLooping = true;
mDescription.mIsStreaming = false;
mDescription.mFadeInTime = -1.f;
mDescription.mFadeOutTime = -1.f;

mVolume = 1;
mPitch = 1;
mFadeInTime = -1;
mFadeOutTime = -1;
mSourceGroup = NULL;
setProcessTicks();
}

GuiAudioCtrl::~GuiAudioCtrl()
{
if (mSoundPlaying)
mSoundPlaying->stop();
SFX_DELETE(mSoundPlaying);
}

bool GuiAudioCtrl::onWake()
{
return Parent::onWake();
bool awake = Parent::onWake();
setProcessTicks();
_update();
return awake;
}

void GuiAudioCtrl::onSleep()
{
if (mSoundPlaying)
mSoundPlaying->stop();
SFX_DELETE(mSoundPlaying);
Parent::onSleep();
_update();
}

void GuiAudioCtrl::onRemove()
{
Parent::onRemove();
}

void GuiAudioCtrl::processTick()
Expand Down Expand Up @@ -154,22 +150,13 @@ void GuiAudioCtrl::initPersistFields()

void GuiAudioCtrl::_update()
{
if (isSoundValid())
{
//mLocalProfile = *mSoundAsset->getSfxProfile();
mDescription = *mSoundAsset->getSfxDescription();
}

// Make sure all the settings are valid.
mDescription.validate();

bool useTrackDescriptionOnly = (mUseTrackDescriptionOnly && getSoundProfile());

if (getSoundProfile())
{
if (mSoundPlaying == NULL)
{
mSoundPlaying = SFX->createSource(getSoundProfile());
mSoundPlaying = SFX->createSource(getSoundProfile(), &(SFX->getListener().getTransform()));
}
}

Expand All @@ -193,9 +180,9 @@ void GuiAudioCtrl::_update()

}

if (testCondition() && isActive() && isAwake())
if (isAwake())
{
if (mSoundPlaying && !mSoundPlaying->isPlaying())
if (testCondition() && mSoundPlaying && !mSoundPlaying->isPlaying())
{
mSoundPlaying->play();
}
Expand All @@ -205,6 +192,8 @@ void GuiAudioCtrl::_update()
if (mSoundPlaying != NULL)
{
mSoundPlaying->stop();
SFX_DELETE(mSoundPlaying);
setProcessTicks(false);
}
}
}
2 changes: 1 addition & 1 deletion Engine/source/gui/shiny/guiAudioCtrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ class GuiAudioCtrl : public GuiTickCtrl
bool mUseTrackDescriptionOnly;

/// The description and variant values used by the local profile.
SFXDescription mDescription;
SFXSource* mSourceGroup;
F32 mVolume;
F32 mPitch;
Expand All @@ -91,6 +90,7 @@ class GuiAudioCtrl : public GuiTickCtrl
// GuiControl.
bool onWake() override;
void onSleep() override;
void onRemove() override;
void setActive(bool value) override {};
bool testCondition();
static void initPersistFields();
Expand Down
2 changes: 2 additions & 0 deletions Templates/BaseGame/game/core/gui/scripts/profiles.tscript
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ new GuiControlProfile (GuiDefaultProfile)
returnTab = false;
numbersOnly = false;
cursorColor = "0 0 0 255";
soundButtonDownAsset = "Core_GUI:buttonClick";
soundButtonOverAsset = "Core_GUI:buttonHover";
};

if(!isObject(GuiNonModalDefaultProfile))
Expand Down
10 changes: 10 additions & 0 deletions Templates/BaseGame/game/core/gui/sounds/buttonClick.asset.taml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<SoundAsset
AssetName="buttonClick"
sourceGroup="AudioChannelDefault"
MaxDistance="100">
<SoundAsset.slots>
<slots_beginarray
SoundFile="@assetFile=buttonClick.wav"
MaxDistance="100"/>
</SoundAsset.slots>
</SoundAsset>
Binary file not shown.
10 changes: 10 additions & 0 deletions Templates/BaseGame/game/core/gui/sounds/buttonHover.asset.taml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<SoundAsset
AssetName="buttonHover"
sourceGroup="AudioChannelDefault"
MaxDistance="100">
<SoundAsset.slots>
<slots_beginarray
SoundFile="@assetFile=buttonHover.wav"
MaxDistance="100"/>
</SoundAsset.slots>
</SoundAsset>
Binary file not shown.

0 comments on commit 35e50b5

Please sign in to comment.