@@ -87,21 +87,12 @@ class SoundAsset : public AssetBase
8787 typedef AssetPtr<SoundAsset> ConcreteAssetPtr;
8888
8989protected:
90- StringTableEntry mSoundFile [SFXPlayList::SFXPlaylistSettings::NUM_SLOTS];
91- StringTableEntry mSoundPath [SFXPlayList::SFXPlaylistSettings::NUM_SLOTS];
92- SimObjectPtr<SFXProfile> mSFXProfile [SFXPlayList::SFXPlaylistSettings::NUM_SLOTS];
9390
94- SFXDescription mProfileDesc ;
95- SFXPlayList mPlaylist ;
96- // subtitles
97- StringTableEntry mSubtitleString ;
98- bool mPreload ;
99- bool mIsPlaylist ;
10091 // SFXPlayList::SlotData mSlots;
10192
10293 /* These will be needed in the refactor!
10394 Resource<SFXResource> mSoundResource;
104-
95+
10596
10697 // SFXDesctriptions, some off these will be removed
10798 F32 mPitchAdjust;
@@ -121,9 +112,6 @@ class SoundAsset : public AssetBase
121112 F32 mPriority;
122113 */
123114
124- typedef Signal<void ()> SoundAssetChanged;
125- SoundAssetChanged mChangeSignal ;
126-
127115public:
128116 enum SoundAssetErrCode
129117 {
@@ -142,41 +130,79 @@ class SoundAsset : public AssetBase
142130 if (errCode > SoundAssetErrCode::Extended) return " undefined error" ;
143131 return mErrCodeStrings [errCode - Parent::Extended];
144132 };
133+
134+ private:
135+ StringTableEntry mSoundFile [SFXPlayList::SFXPlaylistSettings::NUM_SLOTS];
136+ Resource<SFXResource> mSoundResource [SFXPlayList::SFXPlaylistSettings::NUM_SLOTS];
137+
138+ SFXDescription mProfileDesc ;
139+
140+ SFXPlayList mPlaylist ;
141+ // subtitles
142+ StringTableEntry mSubtitleString ;
143+ bool mPreload ;
144+ bool mIsPlaylist ;
145+ SFXTrack* mResolvedTrack ;
146+ SFXDescription* mResolvedDescription ;
147+
148+ public:
145149 SoundAsset ();
146150 virtual ~SoundAsset ();
147151
148152 // / Engine.
149153 static void initPersistFields ();
154+ void onRemove () override ;
155+ void inspectPostApply () override ;
150156 void copyTo (SimObject* object) override ;
151157
152158 // SFXResource* getSound() { return mSoundResource; }
153- Resource<SFXResource> getSoundResource (const U32 slotId = 0 ) { load (); return mSFXProfile [slotId]-> getResource () ; }
159+ Resource<SFXResource> getSoundResource (const U32 slotId = 0 ) { load (); return mSoundResource [slotId]; }
154160
155161 // / Declare Console Object.
156162 DECLARE_CONOBJECT (SoundAsset);
157163
158- static bool _setSoundFile ( void * object, const char * index, const char * data);
164+ // asset Base load
159165 U32 load () override ;
160- inline StringTableEntry getSoundPath (const U32 slotId = 0 ) const { return mSoundPath [slotId]; };
161- SFXProfile* getSfxProfile (const U32 slotId = 0 ) { return mSFXProfile [slotId]; }
162- SFXPlayList* getSfxPlaylist () { return &mPlaylist ; }
163- SFXTrack* getSFXTrack () { load (); return mIsPlaylist ? dynamic_cast <SFXTrack*>(&mPlaylist ) : dynamic_cast <SFXTrack*>(mSFXProfile [0 ].getPointer ()); }
164- SFXDescription* getSfxDescription () { return &mProfileDesc ; }
165- bool isPlaylist (){ return mIsPlaylist ; }
166+
167+ void setSoundFile (StringTableEntry pSoundFile, U32 slot = 0 );
168+ inline StringTableEntry getSoundFile (U32 slot = 0 ) { return mSoundFile [slot]; }
169+ inline StringTableEntry getRelativeSoundFile (U32 slot = 0 ) { return collapseAssetFilePath (mSoundFile [slot]); }
170+
171+ SFXTrack* getSFXTrack () { load (); return mResolvedTrack ; }
172+ SFXDescription* getSfxDescription () { return mResolvedDescription ? mResolvedDescription : &mProfileDesc ; }
173+ bool isPlaylist () { return mIsPlaylist ; }
166174
167175 bool isLoop () { return mProfileDesc .mIsLooping ; }
168176 bool is3D () { return mProfileDesc .mIs3D ; }
169177
170178 static StringTableEntry getAssetIdByFileName (StringTableEntry fileName);
171179 static U32 getAssetById (StringTableEntry assetId, AssetPtr<SoundAsset>* materialAsset);
172- static U32 getAssetByFileName (StringTableEntry fileName, AssetPtr<SoundAsset>* matAsset);
180+ static U32 getAssetByFilename (StringTableEntry fileName, AssetPtr<SoundAsset>* matAsset);
181+
182+ void buildDescription ();
183+ SFXProfile* buildProfile ();
184+ SFXPlayList* buildPlaylist ();
185+
186+ void populateSFXTrack (void );
187+
188+ protected:
189+ // Asset Base callback
190+ void initializeAsset (void ) override ;
191+ void _onResourceChanged (const Torque::Path& path);
192+ void onAssetRefresh (void ) override ;
193+
194+ // / Taml callbacks.
195+ void onTamlPreWrite (void ) override ;
196+ void onTamlPostWrite (void ) override ;
197+ void onTamlCustomWrite (TamlCustomNodes& customNodes) override ;
198+ void onTamlCustomRead (const TamlCustomNodes& customNodes) override ;
173199
174200protected:
175- void initializeAsset (void ) override ;
176- void _onResourceChanged (const Torque::Path & path);
177- void onAssetRefresh (void ) override ;
201+ static bool _setSoundFile (void * obj, const char * index, const char * data) { U32 idx = 0 ; if (index) idx = dAtoi (index); static_cast <SoundAsset*>(obj)->setSoundFile (data, idx); return false ; }
202+
178203};
179204
205+ DECLARE_STRUCT (AssetPtr<SoundAsset>)
180206DefineConsoleType(TypeSoundAssetPtr, SoundAsset)
181207DefineConsoleType(TypeSoundAssetId, String)
182208
@@ -272,8 +298,8 @@ public: \
272298 \
273299 const StringTableEntry get##name() const \
274300 {\
275- if (m##name##Asset && (m##name##Asset->getSoundPath () != StringTable->EmptyString ()))\
276- return m##name##Asset->getSoundPath ();\
301+ if (m##name##Asset && (m##name##Asset->getSoundFile () != StringTable->EmptyString ()))\
302+ return m##name##Asset->getSoundFile ();\
277303 else if (m##name##AssetId != StringTable->EmptyString ())\
278304 return m##name##AssetId;\
279305 else if (m##name##Name != StringTable->EmptyString ())\
@@ -467,8 +493,8 @@ public: \
467493 \
468494 const StringTableEntry get##name(const U32& index) const \
469495 {\
470- if (m##name##Asset[index] && (m##name##Asset[index]->getSoundPath () != StringTable->EmptyString ()))\
471- return m##name##Asset[index]->getSoundPath ();\
496+ if (m##name##Asset[index] && (m##name##Asset[index]->getSoundFile () != StringTable->EmptyString ()))\
497+ return m##name##Asset[index]->getSoundFile ();\
472498 else if (m##name##AssetId[index] != StringTable->EmptyString ())\
473499 return m##name##AssetId[index];\
474500 else if (m##name##Name[index] != StringTable->EmptyString ())\
0 commit comments