فهرست منبع

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
AzaezelX 3 سال پیش
والد
کامیت
4590e14a13

+ 2 - 0
Engine/source/T3D/assets/SoundAsset.cpp

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

+ 0 - 27
Engine/source/T3D/assets/SoundAsset.h

@@ -39,7 +39,6 @@
 #include "assets/assetFieldTypes.h"
 #endif
 
-#include "gui/editor/guiInspectorTypes.h"
 #ifndef _ASSET_PTR_H_
 #include "assets/assetPtr.h"
 #endif 
@@ -145,33 +144,7 @@ protected:
 
 DefineConsoleType(TypeSoundAssetPtr, SoundAsset)
 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
 
 //Singular assets

+ 32 - 0
Engine/source/T3D/assets/SoundAssetInspectors.h

@@ -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

+ 6 - 6
Engine/source/gui/buttons/guiButtonBaseCtrl.cpp

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

+ 18 - 59
Engine/source/gui/core/guiTypes.cpp

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

+ 9 - 7
Engine/source/gui/core/guiTypes.h

@@ -36,6 +36,10 @@
 #include "console/dynamicTypes.h"
 #endif
 
+#ifndef SOUND_ASSET_H_
+#include "T3D/assets/SoundAsset.h"
+#endif
+
 #include "T3D/assets/ImageAsset.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
    Vector<RectI> mBitmapArrayRects;                ///< Used for controls which use an array of bitmaps such as checkboxes
 
-   // sound members
-   SimObjectPtr< SFXTrack > mSoundButtonDown;                   ///< Sound played when the object is "down" ie a button is pushed
-   SimObjectPtr< SFXTrack > mSoundButtonOver;                   ///< Sound played when the mouse is over the object
+   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);
 
    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.
 
    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:
    DECLARE_CONOBJECT(GuiControlProfile);

+ 0 - 3
Templates/BaseGame/game/data/UI/UI.tscript

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

+ 2 - 2
Templates/BaseGame/game/data/UI/scripts/profiles.tscript

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

+ 10 - 4
Templates/BaseGame/game/data/UI/sounds/buttonClick.asset.taml

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

+ 10 - 6
Templates/BaseGame/game/data/UI/sounds/buttonHover.asset.taml

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