Bläddra i källkod

Update Audio Lua API.

aster2013 12 år sedan
förälder
incheckning
073854bfb3

+ 2 - 2
Docs/LuaScriptAPI.dox

@@ -24,6 +24,7 @@ Methods:
 - bool IsInitialized() const
 - float GetMasterGain(SoundType type) const
 - SoundListener* GetListener() const
+- const PODVector<SoundSource*>& GetSoundSources() const
 - void AddSoundSource(SoundSource* soundSource)
 - void RemoveSoundSource(SoundSource* soundSource)
 - float GetSoundSourceMasterGain(SoundType type) const
@@ -34,10 +35,10 @@ Properties:
 - unsigned sampleSize (readonly)
 - int mixRate (readonly)
 - bool interpolation (readonly)
-- SoundListener* listener
 - bool stereo (readonly)
 - bool playing (readonly)
 - bool initialized (readonly)
+- SoundListener* listener
 
 ### Sound : Resource
 
@@ -107,7 +108,6 @@ Methods:
 - bool IsPlaying() const
 - void PlayLockless(Sound* sound)
 - void StopLockless()
-- void SetPlayPositionLockless(signed char* position)
 
 Properties:
 

+ 7 - 8
Source/Engine/LuaScript/pkgs/Audio/Audio.pkg

@@ -27,19 +27,18 @@ class Audio : public Object
     bool IsInitialized() const;
     float GetMasterGain(SoundType type) const;
     SoundListener* GetListener() const;
+    const PODVector<SoundSource*>& GetSoundSources() const;
 
     void AddSoundSource(SoundSource* soundSource);
     void RemoveSoundSource(SoundSource* soundSource);
-
     float GetSoundSourceMasterGain(SoundType type) const;
     void MixOutput(void *dest, unsigned samples);
-    
-    tolua_readonly tolua_property__get_set unsigned sampleSize;
-    tolua_readonly tolua_property__get_set int mixRate;
-    tolua_readonly tolua_property__get_set bool interpolation;
 
-    tolua_property__get_set SoundListener* listener;
-    tolua_readonly tolua_property__is_set bool stereo;    
-    tolua_readonly tolua_property__is_set bool playing;
+    tolua_readonly tolua_property__get_set unsigned sampleSize;
+    tolua_readonly tolua_property__get_set int mixRate;
+    tolua_readonly tolua_property__get_set bool interpolation;
+    tolua_readonly tolua_property__is_set bool stereo;
+    tolua_readonly tolua_property__is_set bool playing;
     tolua_readonly tolua_property__is_set bool initialized;
+    tolua_property__get_set SoundListener* listener;
 };

+ 7 - 11
Source/Engine/LuaScript/pkgs/Audio/SoundSource.pkg

@@ -4,7 +4,6 @@ enum SoundType{};
 
 class SoundSource : public Component
 {
-
     void Play(Sound* sound);
     void Play(Sound* sound, float frequency);
     void Play(Sound* sound, float frequency, float gain);
@@ -17,7 +16,6 @@ class SoundSource : public Component
     void SetPanning(float panning);
     void SetAutoRemove(bool enable);
 
-    
     Sound* GetSound() const;
     SoundType GetSoundType() const;
     float GetTimePosition() const;
@@ -30,16 +28,14 @@ class SoundSource : public Component
     
     void PlayLockless(Sound* sound);
     void StopLockless();
-    void SetPlayPositionLockless(signed char* position);
-
-    
+        
     tolua_readonly tolua_property__get_set Sound* sound;
-    tolua_property__get_set SoundType soundType;
+    tolua_property__get_set SoundType soundType;
     tolua_readonly tolua_property__get_set float timePosition;
-    tolua_property__get_set float frequency;
-    tolua_property__get_set float gain;
-    tolua_property__get_set float attenuation;
-    tolua_property__get_set float panning;
-    tolua_property__get_set bool autoRemove;
+    tolua_property__get_set float frequency;
+    tolua_property__get_set float gain;
+    tolua_property__get_set float attenuation;
+    tolua_property__get_set float panning;
+    tolua_property__get_set bool autoRemove;
     tolua_readonly tolua_property__is_set bool playing;
 };

+ 12 - 0
Source/Engine/LuaScript/tolua++urho3d.cpp

@@ -196,6 +196,18 @@ template<> int tolua_pushurho3dpodvector<unsigned>(lua_State* L, void* data, con
     return 1;
 }
 
+template<> int tolua_pushurho3dpodvector<SoundSource*>(lua_State* L, void* data, const char* /*type*/)
+{
+    const PODVector<SoundSource*>& vector = *((const PODVector<SoundSource*>*)data);
+    lua_newtable(L);
+    for (unsigned i = 0; i < vector.Size(); ++i)
+    {
+        tolua_pushusertype(L, vector[i], "SoundSource");
+        lua_rawseti(L, -2, i + 1);
+    }
+    return 1;
+}
+
 template<> int tolua_pushurho3dpodvector<UIElement*>(lua_State* L, void* data, const char* /*type*/)
 {
     const PODVector<UIElement*>& vector = *((const PODVector<UIElement*>*)data);

+ 4 - 0
Source/Engine/LuaScript/tolua++urho3d.h

@@ -31,6 +31,7 @@ struct lua_State;
 
 namespace Urho3D
 {
+    class SoundSource;
     class UIElement;
 }
 
@@ -76,8 +77,11 @@ template<typename T> int tolua_pushurho3dpodvector(lua_State* L, void* data, con
 template<> int tolua_pushurho3dpodvector<int>(lua_State* L, void* data, const char* type);
 /// Push PODVector<unsigned> to Lua as a table.
 template<> int tolua_pushurho3dpodvector<unsigned>(lua_State* L, void* data, const char* type);
+/// Push PODVector<SoundSource*> to Lua as a table.
+template<> int tolua_pushurho3dpodvector<SoundSource*>(lua_State* L, void* data, const char* type);
 /// Push PODVector<UIElement*> to Lua as a table.
 template<> int tolua_pushurho3dpodvector<UIElement*>(lua_State* L, void* data, const char* type);
+
 /// Push PODVector<Vector3> to Lua as a table.
 template<> int tolua_pushurho3dpodvector<Vector3>(lua_State* L, void* data, const char* type);
 /// Push PODVector<IntVector2> to Lua as a table.