Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

guiAudiocCtrl fixes #1302

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Loading