mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 16:44:36 +00:00
Merge pull request #1302 from Azaezel/alpha41/guiAudioCtrlFixes
guiAudiocCtrl fixes
This commit is contained in:
commit
35e50b54b9
7 changed files with 38 additions and 27 deletions
|
|
@ -43,42 +43,38 @@ GuiAudioCtrl::GuiAudioCtrl()
|
||||||
mTickPeriodMS = 100;
|
mTickPeriodMS = 100;
|
||||||
mLastThink = 0;
|
mLastThink = 0;
|
||||||
mCurrTick = 0;
|
mCurrTick = 0;
|
||||||
mPlayIf = "";
|
|
||||||
mSoundPlaying = NULL;
|
mSoundPlaying = NULL;
|
||||||
|
|
||||||
mUseTrackDescriptionOnly = false;
|
mUseTrackDescriptionOnly = false;
|
||||||
mDescription.mIs3D = false;
|
|
||||||
mDescription.mIsLooping = true;
|
|
||||||
mDescription.mIsStreaming = false;
|
|
||||||
mDescription.mFadeInTime = -1.f;
|
|
||||||
mDescription.mFadeOutTime = -1.f;
|
|
||||||
|
|
||||||
mVolume = 1;
|
mVolume = 1;
|
||||||
mPitch = 1;
|
mPitch = 1;
|
||||||
mFadeInTime = -1;
|
mFadeInTime = -1;
|
||||||
mFadeOutTime = -1;
|
mFadeOutTime = -1;
|
||||||
mSourceGroup = NULL;
|
mSourceGroup = NULL;
|
||||||
setProcessTicks();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiAudioCtrl::~GuiAudioCtrl()
|
GuiAudioCtrl::~GuiAudioCtrl()
|
||||||
{
|
{
|
||||||
if (mSoundPlaying)
|
|
||||||
mSoundPlaying->stop();
|
|
||||||
SFX_DELETE(mSoundPlaying);
|
SFX_DELETE(mSoundPlaying);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GuiAudioCtrl::onWake()
|
bool GuiAudioCtrl::onWake()
|
||||||
{
|
{
|
||||||
return Parent::onWake();
|
bool awake = Parent::onWake();
|
||||||
|
setProcessTicks();
|
||||||
|
_update();
|
||||||
|
return awake;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiAudioCtrl::onSleep()
|
void GuiAudioCtrl::onSleep()
|
||||||
{
|
{
|
||||||
if (mSoundPlaying)
|
|
||||||
mSoundPlaying->stop();
|
|
||||||
SFX_DELETE(mSoundPlaying);
|
|
||||||
Parent::onSleep();
|
Parent::onSleep();
|
||||||
|
_update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiAudioCtrl::onRemove()
|
||||||
|
{
|
||||||
|
Parent::onRemove();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiAudioCtrl::processTick()
|
void GuiAudioCtrl::processTick()
|
||||||
|
|
@ -154,22 +150,13 @@ void GuiAudioCtrl::initPersistFields()
|
||||||
|
|
||||||
void GuiAudioCtrl::_update()
|
void GuiAudioCtrl::_update()
|
||||||
{
|
{
|
||||||
if (isSoundValid())
|
|
||||||
{
|
|
||||||
//mLocalProfile = *mSoundAsset->getSfxProfile();
|
|
||||||
mDescription = *mSoundAsset->getSfxDescription();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure all the settings are valid.
|
|
||||||
mDescription.validate();
|
|
||||||
|
|
||||||
bool useTrackDescriptionOnly = (mUseTrackDescriptionOnly && getSoundProfile());
|
bool useTrackDescriptionOnly = (mUseTrackDescriptionOnly && getSoundProfile());
|
||||||
|
|
||||||
if (getSoundProfile())
|
if (getSoundProfile())
|
||||||
{
|
{
|
||||||
if (mSoundPlaying == NULL)
|
if (mSoundPlaying == NULL)
|
||||||
{
|
{
|
||||||
mSoundPlaying = SFX->createSource(getSoundProfile());
|
mSoundPlaying = SFX->createSource(getSoundProfile(), &(SFX->getListener().getTransform()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -193,9 +180,9 @@ void GuiAudioCtrl::_update()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (testCondition() && isActive() && isAwake())
|
if (isAwake())
|
||||||
{
|
{
|
||||||
if (mSoundPlaying && !mSoundPlaying->isPlaying())
|
if (testCondition() && mSoundPlaying && !mSoundPlaying->isPlaying())
|
||||||
{
|
{
|
||||||
mSoundPlaying->play();
|
mSoundPlaying->play();
|
||||||
}
|
}
|
||||||
|
|
@ -205,6 +192,8 @@ void GuiAudioCtrl::_update()
|
||||||
if (mSoundPlaying != NULL)
|
if (mSoundPlaying != NULL)
|
||||||
{
|
{
|
||||||
mSoundPlaying->stop();
|
mSoundPlaying->stop();
|
||||||
|
SFX_DELETE(mSoundPlaying);
|
||||||
|
setProcessTicks(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,6 @@ protected:
|
||||||
bool mUseTrackDescriptionOnly;
|
bool mUseTrackDescriptionOnly;
|
||||||
|
|
||||||
/// The description and variant values used by the local profile.
|
/// The description and variant values used by the local profile.
|
||||||
SFXDescription mDescription;
|
|
||||||
SFXSource* mSourceGroup;
|
SFXSource* mSourceGroup;
|
||||||
F32 mVolume;
|
F32 mVolume;
|
||||||
F32 mPitch;
|
F32 mPitch;
|
||||||
|
|
@ -91,6 +90,7 @@ public:
|
||||||
// GuiControl.
|
// GuiControl.
|
||||||
bool onWake() override;
|
bool onWake() override;
|
||||||
void onSleep() override;
|
void onSleep() override;
|
||||||
|
void onRemove() override;
|
||||||
void setActive(bool value) override {};
|
void setActive(bool value) override {};
|
||||||
bool testCondition();
|
bool testCondition();
|
||||||
static void initPersistFields();
|
static void initPersistFields();
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,8 @@ new GuiControlProfile (GuiDefaultProfile)
|
||||||
returnTab = false;
|
returnTab = false;
|
||||||
numbersOnly = false;
|
numbersOnly = false;
|
||||||
cursorColor = "0 0 0 255";
|
cursorColor = "0 0 0 255";
|
||||||
|
soundButtonDownAsset = "Core_GUI:buttonClick";
|
||||||
|
soundButtonOverAsset = "Core_GUI:buttonHover";
|
||||||
};
|
};
|
||||||
|
|
||||||
if(!isObject(GuiNonModalDefaultProfile))
|
if(!isObject(GuiNonModalDefaultProfile))
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
<SoundAsset
|
||||||
|
AssetName="buttonClick"
|
||||||
|
sourceGroup="AudioChannelDefault"
|
||||||
|
MaxDistance="100">
|
||||||
|
<SoundAsset.slots>
|
||||||
|
<slots_beginarray
|
||||||
|
SoundFile="@assetFile=buttonClick.wav"
|
||||||
|
MaxDistance="100"/>
|
||||||
|
</SoundAsset.slots>
|
||||||
|
</SoundAsset>
|
||||||
BIN
Templates/BaseGame/game/core/gui/sounds/buttonClick.wav
Normal file
BIN
Templates/BaseGame/game/core/gui/sounds/buttonClick.wav
Normal file
Binary file not shown.
|
|
@ -0,0 +1,10 @@
|
||||||
|
<SoundAsset
|
||||||
|
AssetName="buttonHover"
|
||||||
|
sourceGroup="AudioChannelDefault"
|
||||||
|
MaxDistance="100">
|
||||||
|
<SoundAsset.slots>
|
||||||
|
<slots_beginarray
|
||||||
|
SoundFile="@assetFile=buttonHover.wav"
|
||||||
|
MaxDistance="100"/>
|
||||||
|
</SoundAsset.slots>
|
||||||
|
</SoundAsset>
|
||||||
BIN
Templates/BaseGame/game/core/gui/sounds/buttonHover.wav
Normal file
BIN
Templates/BaseGame/game/core/gui/sounds/buttonHover.wav
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue