Merge branch 'GuiProfileSoundAssets' of https://github.com/marauder2k9-torque/Torque3D into alpha401/resolveAudioConflict

# Conflicts:
#	Templates/BaseGame/game/data/UI/UI.tscript
#	Templates/BaseGame/game/data/UI/sounds/buttonClick.asset.taml
#	Templates/BaseGame/game/data/UI/sounds/buttonHover.asset.taml
This commit is contained in:
AzaezelX 2022-08-29 17:47:07 -05:00
commit 4590e14a13
10 changed files with 89 additions and 114 deletions

View file

@ -48,6 +48,8 @@
#include "platform/profiler.h" #include "platform/profiler.h"
#include "sfx/sfxTypes.h" #include "sfx/sfxTypes.h"
#include "SoundAssetInspectors.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT(SoundAsset); IMPLEMENT_CONOBJECT(SoundAsset);

View file

@ -39,7 +39,6 @@
#include "assets/assetFieldTypes.h" #include "assets/assetFieldTypes.h"
#endif #endif
#include "gui/editor/guiInspectorTypes.h"
#ifndef _ASSET_PTR_H_ #ifndef _ASSET_PTR_H_
#include "assets/assetPtr.h" #include "assets/assetPtr.h"
#endif #endif
@ -145,33 +144,7 @@ protected:
DefineConsoleType(TypeSoundAssetPtr, SoundAsset) DefineConsoleType(TypeSoundAssetPtr, SoundAsset)
DefineConsoleType(TypeSoundAssetId, String) DefineConsoleType(TypeSoundAssetId, String)
#ifdef TORQUE_TOOLS
//-----------------------------------------------------------------------------
// TypeAssetId GuiInspectorField Class
//-----------------------------------------------------------------------------
class GuiInspectorTypeSoundAssetPtr : public GuiInspectorTypeFileName
{
typedef GuiInspectorTypeFileName Parent;
public:
GuiBitmapButtonCtrl* mEditButton;
DECLARE_CONOBJECT(GuiInspectorTypeSoundAssetPtr);
static void consoleInit();
virtual GuiControl* constructEditControl();
virtual bool updateRects();
};
class GuiInspectorTypeSoundAssetId : public GuiInspectorTypeSoundAssetPtr
{
typedef GuiInspectorTypeSoundAssetPtr Parent;
public:
DECLARE_CONOBJECT(GuiInspectorTypeSoundAssetId);
static void consoleInit();
};
#endif
#pragma region Singular Asset Macros #pragma region Singular Asset Macros
//Singular assets //Singular assets

View file

@ -0,0 +1,32 @@
#pragma once
#include "Soundasset.h"
#ifndef _GUI_INSPECTOR_TYPES_H_
#include "gui/editor/guiInspectorTypes.h"
#endif
#ifdef TORQUE_TOOLS
class GuiInspectorTypeSoundAssetPtr : public GuiInspectorTypeFileName
{
typedef GuiInspectorTypeFileName Parent;
public:
GuiBitmapButtonCtrl* mEditButton;
DECLARE_CONOBJECT(GuiInspectorTypeSoundAssetPtr);
static void consoleInit();
virtual GuiControl* constructEditControl();
virtual bool updateRects();
};
class GuiInspectorTypeSoundAssetId : public GuiInspectorTypeSoundAssetPtr
{
typedef GuiInspectorTypeSoundAssetPtr Parent;
public:
DECLARE_CONOBJECT(GuiInspectorTypeSoundAssetId);
static void consoleInit();
};
#endif

View file

@ -252,8 +252,8 @@ void GuiButtonBaseCtrl::onMouseDown(const GuiEvent &event)
if (mProfile->mCanKeyFocus) if (mProfile->mCanKeyFocus)
setFirstResponder(); setFirstResponder();
if (mProfile->mSoundButtonDown) if (mProfile->getSoundButtonDown())
SFX->playOnce(mProfile->mSoundButtonDown); SFX->playOnce(mProfile->getSoundButtonDownProfile());
mMouseDownPoint = event.mousePoint; mMouseDownPoint = event.mousePoint;
mMouseDragged = false; mMouseDragged = false;
@ -292,8 +292,8 @@ void GuiButtonBaseCtrl::onMouseEnter(const GuiEvent &event)
} }
else else
{ {
if ( mActive && mProfile->mSoundButtonOver ) if (mProfile->getSoundButtonOver())
SFX->playOnce(mProfile->mSoundButtonOver); SFX->playOnce(mProfile->getSoundButtonOverProfile());
mHighlighted = true; mHighlighted = true;
} }
@ -377,8 +377,8 @@ bool GuiButtonBaseCtrl::onKeyDown(const GuiEvent &event)
if ((event.keyCode == KEY_RETURN || event.keyCode == KEY_SPACE) if ((event.keyCode == KEY_RETURN || event.keyCode == KEY_SPACE)
&& event.modifier == 0) && event.modifier == 0)
{ {
if ( mProfile->mSoundButtonDown ) if (mProfile->getSoundButtonDown())
SFX->playOnce( mProfile->mSoundButtonDown); SFX->playOnce(mProfile->getSoundButtonDownProfile());
return true; return true;
} }

View file

@ -218,60 +218,6 @@ bool GuiControlProfile::protectedSetBitmap( void *object, const char *index, con
return false; return false;
} }
const char* GuiControlProfile::protectedGetSoundButtonDown( void* object, const char* data )
{
GuiControlProfile* profile = reinterpret_cast< GuiControlProfile* >( object );
SFXTrack* track = profile->mSoundButtonDown;
if( !track )
return "";
return track->getName();
}
bool GuiControlProfile::protectedSetSoundButtonDown( void* object, const char* index, const char* data )
{
GuiControlProfile* profile = reinterpret_cast< GuiControlProfile* >( object );
SFXTrack* track = NULL;
if( data && data[ 0] && !Sim::findObject( data, track ) )
{
Con::errorf( "GuiControlProfile::protectedSetSoundButtonDown - no SFXTrack '%s'", data );
return false;
}
profile->mSoundButtonDown = track;
return false;
}
const char* GuiControlProfile::protectedGetSoundButtonOver( void* object, const char* data )
{
GuiControlProfile* profile = reinterpret_cast< GuiControlProfile* >( object );
SFXTrack* track = profile->mSoundButtonOver;
if( !track )
return "";
return track->getName();
}
bool GuiControlProfile::protectedSetSoundButtonOver( void* object, const char* index, const char* data )
{
GuiControlProfile* profile = reinterpret_cast< GuiControlProfile* >( object );
SFXTrack* track = NULL;
if( data && data[ 0] && !Sim::findObject( data, track ) )
{
Con::errorf( "GuiControlProfile::protectedSetSoundButtonOver - no SFXTrack '%s'", data );
return false;
}
profile->mSoundButtonOver = track;
return false;
}
GuiControlProfile::GuiControlProfile(void) : GuiControlProfile::GuiControlProfile(void) :
mFillColor(255,0,255,255), mFillColor(255,0,255,255),
mFillColorHL(255,0,255,255), mFillColorHL(255,0,255,255),
@ -293,6 +239,8 @@ GuiControlProfile::GuiControlProfile(void) :
mTextOffset(0,0), mTextOffset(0,0),
mBitmapArrayRects(0) mBitmapArrayRects(0)
{ {
INIT_ASSET(SoundButtonDown);
INIT_ASSET(SoundButtonOver);
mLoadCount = 0; mLoadCount = 0;
mUseCount = 0; mUseCount = 0;
@ -367,8 +315,19 @@ GuiControlProfile::GuiControlProfile(void) :
mTextOffset = def->mTextOffset; mTextOffset = def->mTextOffset;
// default sound // default sound
mSoundButtonDown = def->mSoundButtonDown; _setSoundButtonDown(def->getSoundButtonDown());
mSoundButtonOver = def->mSoundButtonOver; 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 //used by GuiTextCtrl
mModal = def->mModal; mModal = def->mModal;
@ -478,9 +437,9 @@ void GuiControlProfile::initPersistFields()
addField("hasBitmapArray", TypeBool, Offset(mUseBitmapArray, GuiControlProfile), addField("hasBitmapArray", TypeBool, Offset(mUseBitmapArray, GuiControlProfile),
"If true, 'bitmap' is an array of images." ); "If true, 'bitmap' is an array of images." );
addProtectedField( "soundButtonDown", TypeSFXTrackName, Offset(mSoundButtonDown, GuiControlProfile), INITPERSISTFIELD_SOUNDASSET(SoundButtonDown, GuiControlProfile, "The sound button down.");
&GuiControlProfile::protectedSetSoundButtonDown, &GuiControlProfile::protectedGetSoundButtonDown, INITPERSISTFIELD_SOUNDASSET(SoundButtonOver, GuiControlProfile, "The sound button down.");
"Sound to play when mouse has been pressed on control." );
addProtectedField( "soundButtonOver", TypeSFXTrackName, Offset(mSoundButtonOver, GuiControlProfile), addProtectedField( "soundButtonOver", TypeSFXTrackName, Offset(mSoundButtonOver, GuiControlProfile),
&GuiControlProfile::protectedSetSoundButtonOver, &GuiControlProfile::protectedGetSoundButtonOver, &GuiControlProfile::protectedSetSoundButtonOver, &GuiControlProfile::protectedGetSoundButtonOver,
"Sound to play when mouse is hovering over control." ); "Sound to play when mouse is hovering over control." );

View file

@ -36,6 +36,10 @@
#include "console/dynamicTypes.h" #include "console/dynamicTypes.h"
#endif #endif
#ifndef SOUND_ASSET_H_
#include "T3D/assets/SoundAsset.h"
#endif
#include "T3D/assets/ImageAsset.h" #include "T3D/assets/ImageAsset.h"
#include "gfx/gfxDevice.h" #include "gfx/gfxDevice.h"
@ -562,9 +566,11 @@ public:
bool mUseBitmapArray; ///< Flag to use the bitmap array or to fallback to non-array rendering 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 Vector<RectI> mBitmapArrayRects; ///< Used for controls which use an array of bitmaps such as checkboxes
// sound members DECLARE_SOUNDASSET(GuiControlProfile, SoundButtonDown); ///< Sound played when a button is pressed.
SimObjectPtr< SFXTrack > mSoundButtonDown; ///< Sound played when the object is "down" ie a button is pushed DECLARE_ASSET_SETGET(GuiControlProfile, SoundButtonDown);
SimObjectPtr< SFXTrack > mSoundButtonOver; ///< Sound played when the mouse is over the object
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 StringTableEntry mChildrenProfileName; ///< The name of the profile to use for the children controls
@ -583,10 +589,6 @@ protected:
GuiControlProfile* mChildrenProfile; ///< Profile used with children controls (such as the scroll bar on a popup menu) when defined. GuiControlProfile* mChildrenProfile; ///< Profile used with children controls (such as the scroll bar on a popup menu) when defined.
static bool protectedSetBitmap( void *object, const char *index, const char *data ); static bool protectedSetBitmap( void *object, const char *index, const char *data );
static bool protectedSetSoundButtonDown( void* object, const char* index, const char* data );
static bool protectedSetSoundButtonOver( void* object, const char* index, const char* data );
static const char* protectedGetSoundButtonDown( void* object, const char* data );
static const char* protectedGetSoundButtonOver( void* object, const char* data );
public: public:
DECLARE_CONOBJECT(GuiControlProfile); DECLARE_CONOBJECT(GuiControlProfile);

View file

@ -29,9 +29,6 @@ function UI::onDestroyGameServer(%this){}
function UI::initClient(%this) function UI::initClient(%this)
{ {
//Load UI stuff //Load UI stuff
//we need to load this because some of the menu profiles use the sounds here
%this.queueExec("./datablocks/guiSounds");
//Profiles //Profiles
%this.queueExec("./scripts/profiles"); %this.queueExec("./scripts/profiles");

View file

@ -100,8 +100,8 @@ new GuiControlProfile( GuiMenuButtonProfile )
canKeyFocus = false; canKeyFocus = false;
//bitmapAsset = "UI:menu_button_image"; //bitmapAsset = "UI:menu_button_image";
hasBitmapArray = false; hasBitmapArray = false;
soundButtonDown = menuButtonPressed; soundButtonDown = "UI:buttonClick";
soundButtonOver = menuButtonHover; soundButtonOver = "UI:buttonHover";
category = "Core"; category = "Core";
}; };

View file

@ -1,4 +1,10 @@
<SoundAsset <SoundAsset
AssetName="buttonClick" AssetName="buttonClick"
soundFile="@assetFile=buttonClick.wav" soundFile="@assetFile=buttonClick.wav"
sourceGroup="AudioChannelGui"/> PitchAdjust="1"
VolumeAdjust="1"
is3D="false"
minDistance="1"
maxDistance="100"
sourceGroup="AudioChannelGui"
/>

View file

@ -1,6 +1,10 @@
<SoundAsset <SoundAsset
AssetName="buttonHover" AssetName="buttonHover"
soundFile="@assetFile=buttonHover.wav" soundFile="@assetFile=buttonHover.wav"
useHardware="true" PitchAdjust="1"
maxDistance="120" VolumeAdjust="1"
sourceGroup="AudioChannelGui"/> is3D="false"
minDistance="1"
maxDistance="100"
sourceGroup="AudioChannelGui"
/>