Browse Source

Update tolua++ pkg files.

Aster Jian 12 years ago
parent
commit
1cdb324a6e
64 changed files with 859 additions and 646 deletions
  1. 0 2
      Extras/LuaScript/pkgs/Audio/Audio.pkg
  2. 7 2
      Extras/LuaScript/pkgs/Audio/Sound.pkg
  3. 1 0
      Extras/LuaScript/pkgs/Audio/SoundListener.pkg
  4. 3 1
      Extras/LuaScript/pkgs/Audio/SoundSource3D.pkg
  5. 1 12
      Extras/LuaScript/pkgs/AudioLuaAPI.pkg
  6. 20 0
      Extras/LuaScript/pkgs/Container/Ptr.pkg
  7. 16 0
      Extras/LuaScript/pkgs/Container/Str.pkg
  8. 3 1
      Extras/LuaScript/pkgs/Container/Vector.pkg
  9. 2 0
      Extras/LuaScript/pkgs/ContainerLuaAPI.pkg
  10. 139 0
      Extras/LuaScript/pkgs/Core/Context.pkg
  11. 0 2
      Extras/LuaScript/pkgs/Core/Timer.pkg
  12. 189 38
      Extras/LuaScript/pkgs/Core/Variant.pkg
  13. 1 163
      Extras/LuaScript/pkgs/CoreLuaAPI.pkg
  14. 1 4
      Extras/LuaScript/pkgs/Engine/Console.pkg
  15. 0 2
      Extras/LuaScript/pkgs/Engine/DebugHud.pkg
  16. 0 2
      Extras/LuaScript/pkgs/Engine/Engine.pkg
  17. 0 21
      Extras/LuaScript/pkgs/EngineLuaAPI.pkg
  18. 33 28
      Extras/LuaScript/pkgs/Graphics/AnimationController.pkg
  19. 0 2
      Extras/LuaScript/pkgs/Graphics/DebugRenderer.pkg
  20. 0 2
      Extras/LuaScript/pkgs/Graphics/Graphics.pkg
  21. 54 0
      Extras/LuaScript/pkgs/Graphics/Light.pkg
  22. 0 2
      Extras/LuaScript/pkgs/Graphics/Octree.pkg
  23. 46 0
      Extras/LuaScript/pkgs/Graphics/RenderPath.pkg
  24. 0 2
      Extras/LuaScript/pkgs/Graphics/Renderer.pkg
  25. 64 0
      Extras/LuaScript/pkgs/Graphics/Viewport.pkg
  26. 2 26
      Extras/LuaScript/pkgs/GraphicsLuaAPI.pkg
  27. 0 2
      Extras/LuaScript/pkgs/IO/FileSystem.pkg
  28. 0 2
      Extras/LuaScript/pkgs/IO/Log.pkg
  29. 0 16
      Extras/LuaScript/pkgs/IOLuaAPI.pkg
  30. 0 2
      Extras/LuaScript/pkgs/Input/Input.pkg
  31. 54 1
      Extras/LuaScript/pkgs/Input/InputEvents.pkg
  32. 0 38
      Extras/LuaScript/pkgs/InputLuaAPI.pkg
  33. 1 0
      Extras/LuaScript/pkgs/LuaScriptLuaAPI.pkg
  34. 11 1
      Extras/LuaScript/pkgs/Navigation/NavigationMesh.pkg
  35. 0 11
      Extras/LuaScript/pkgs/NavigationLuaAPI.pkg
  36. 0 2
      Extras/LuaScript/pkgs/Network/Network.pkg
  37. 0 11
      Extras/LuaScript/pkgs/NetworkLuaAPI.pkg
  38. 0 4
      Extras/LuaScript/pkgs/Physics/PhysicsWorld.pkg
  39. 0 9
      Extras/LuaScript/pkgs/PhysicsLuaAPI.pkg
  40. 24 14
      Extras/LuaScript/pkgs/Resource/ResourceCache.pkg
  41. 0 69
      Extras/LuaScript/pkgs/ResourceLuaAPI.pkg
  42. 117 2
      Extras/LuaScript/pkgs/Scene/Node.pkg
  43. 21 1
      Extras/LuaScript/pkgs/Scene/Scene.pkg
  44. 0 9
      Extras/LuaScript/pkgs/SceneLuaAPI.pkg
  45. 0 2
      Extras/LuaScript/pkgs/UI/BorderImage.pkg
  46. 0 2
      Extras/LuaScript/pkgs/UI/Button.pkg
  47. 0 2
      Extras/LuaScript/pkgs/UI/CheckBox.pkg
  48. 23 1
      Extras/LuaScript/pkgs/UI/Cursor.pkg
  49. 1 3
      Extras/LuaScript/pkgs/UI/DropDownList.pkg
  50. 0 2
      Extras/LuaScript/pkgs/UI/FileSelector.pkg
  51. 0 2
      Extras/LuaScript/pkgs/UI/Font.pkg
  52. 0 2
      Extras/LuaScript/pkgs/UI/LineEdit.pkg
  53. 0 2
      Extras/LuaScript/pkgs/UI/ListView.pkg
  54. 0 2
      Extras/LuaScript/pkgs/UI/Menu.pkg
  55. 0 2
      Extras/LuaScript/pkgs/UI/ScrollBar.pkg
  56. 0 2
      Extras/LuaScript/pkgs/UI/ScrollView.pkg
  57. 0 2
      Extras/LuaScript/pkgs/UI/Slider.pkg
  58. 24 1
      Extras/LuaScript/pkgs/UI/Sprite.pkg
  59. 0 2
      Extras/LuaScript/pkgs/UI/Text.pkg
  60. 0 2
      Extras/LuaScript/pkgs/UI/Text3D.pkg
  61. 0 2
      Extras/LuaScript/pkgs/UI/UI.pkg
  62. 0 3
      Extras/LuaScript/pkgs/UI/UIElement.pkg
  63. 0 2
      Extras/LuaScript/pkgs/UI/Window.pkg
  64. 1 102
      Extras/LuaScript/pkgs/UILuaAPI.pkg

+ 0 - 2
Extras/LuaScript/pkgs/Audio/Audio.pkg

@@ -44,5 +44,3 @@ public:
     /// Return sound type specific gain multiplied by master gain.
     float GetSoundSourceMasterGain(SoundType type) const { return masterGain_[SOUND_MASTER] * masterGain_[type]; }
 };
-
-Audio* GetAudio();

+ 7 - 2
Extras/LuaScript/pkgs/Audio/Sound.pkg

@@ -13,6 +13,12 @@ public:
     /// Fix interpolation by copying data from loop start to loop end (looped), or adding silence (oneshot.)
     void FixInterpolation();
     
+    /// Return sound data start.
+    signed char* GetStart() const { return data_.Get(); }
+    /// Return loop start.
+    signed char* GetRepeat() const { return repeat_; }
+    /// Return sound data end.
+    signed char* GetEnd() const { return end_; }
     /// Return length in seconds.
     float GetLength() const;
     /// Return total sound data size.
@@ -30,6 +36,5 @@ public:
     /// Return whether data is stereo.
     bool IsStereo() const { return stereo_; }
     /// Return whether is compressed in Ogg Vorbis format.
-    bool IsCompressed() const { return compressed_; }    
-
+    bool IsCompressed() const { return compressed_; }
 };

+ 1 - 0
Extras/LuaScript/pkgs/Audio/SoundListener.pkg

@@ -3,4 +3,5 @@ $#include "SoundListener.h"
 /// %Sound listener component
 class SoundListener : public Component
 {
+public:    
 };

+ 3 - 1
Extras/LuaScript/pkgs/Audio/SoundSource3D.pkg

@@ -3,7 +3,9 @@ $#include "SoundSource3D.h"
 /// %Sound source component with three-dimensional position.
 class SoundSource3D : public SoundSource
 {
-public:
+public:    
+    /// Register object factory.
+    static void RegisterObject(Context* context);
     /// Set attenuation parameters.
     void SetDistanceAttenuation(float nearDistance, float farDistance, float rolloffFactor);
     /// Set near distance. Distances closer than this do not have an effect.

+ 1 - 12
Extras/LuaScript/pkgs/AudioLuaAPI.pkg

@@ -1,7 +1,5 @@
 $#define TOLUA_RELEASE
 
-$#include "LuaScript.h"
-
 $pfile "Audio/Audio.pkg"
 $pfile "Audio/Sound.pkg"
 $pfile "Audio/SoundListener.pkg"
@@ -9,13 +7,4 @@ $pfile "Audio/SoundSource.pkg"
 $pfile "Audio/SoundSource3D.pkg"
 
 $using namespace Urho3D;
-$#pragma warning(disable:4800)
-
-${
-
-Audio* GetAudio()
-{
-    return GetLuaScriptContext()->GetSubsystem<Audio>();
-}
-
-$}
+$#pragma warning(disable:4800)

+ 20 - 0
Extras/LuaScript/pkgs/Container/Ptr.pkg

@@ -0,0 +1,20 @@
+$#include "RenderPath.h"
+$#include "Ptr.h"
+
+/// Shared pointer template class with intrusive reference counting.
+class SharedPtr
+{
+	TOLUA_TEMPLATE_BIND(T, RenderPath)
+public:
+    /// Point to the object.
+    bool operator < (const SharedPtr<T>& rhs) const { return ptr_ < rhs.ptr_; }
+    /// Test for equality with another shared pointer.
+    bool operator == (const SharedPtr<T>& rhs) const { return ptr_ == rhs.ptr_; }
+    
+	/// Check if the pointer is null.
+    bool Null() const { return ptr_ == 0; }
+    /// Check if the pointer is not null.
+    bool NotNull() const { return ptr_ != 0; }
+    /// Return the raw pointer.
+    T* Get() const { return ptr_; }	
+};

+ 16 - 0
Extras/LuaScript/pkgs/Container/Str.pkg

@@ -117,9 +117,11 @@ public:
     
     /// Test for equality with another string.
     bool operator == (const String& rhs) const { return strcmp(CString(), rhs.CString()) == 0; }
+    tolua_outside bool StringEq @ Eq(const String& rhs) const;
     /// Test if string is less than another string.
     bool operator < (const String& rhs) const { return strcmp(CString(), rhs.CString()) < 0; }
     bool operator == (const char* rhs) const { return strcmp(CString(), rhs) == 0; }
+    tolua_outside bool StringEq @ Eq(const char* rhs) const;
     /// Test if string is less than a C string.
     bool operator < (const char* rhs) const { return strcmp(CString(), rhs) < 0; }
     /// Return char at index.
@@ -236,3 +238,17 @@ public:
     /// Empty string.
     static const String EMPTY;
 };
+
+${
+
+static bool StringEq(const String* lhs, const char* rhs)
+{
+    return (*lhs) == rhs;
+}
+
+static bool StringEq(const String* lhs, const String& rhs)
+{
+    return (*lhs) == rhs;
+}
+
+$}

+ 3 - 1
Extras/LuaScript/pkgs/Container/Vector.pkg

@@ -1,9 +1,11 @@
+$#include "String.h"
 $#include "Vector.h"
+$#include "Vector3.h"
 
 /// %Vector template class.
 class Vector : public VectorBase
 {
-	TOLUA_TEMMPLATE_BIND(T, String)
+    TOLUA_TEMPLATE_BIND(T, String)
 public:
     /// Construct empty.
     Vector()

+ 2 - 0
Extras/LuaScript/pkgs/ContainerLuaAPI.pkg

@@ -1,6 +1,8 @@
 $#define TOLUA_RELEASE
 
+$pfile "Container/Ptr.pkg"
 $pfile "Container/Str.pkg"
+$pfile "Container/Vector.pkg"
 
 $using namespace Urho3D;
 $#pragma warning(disable:4800)

+ 139 - 0
Extras/LuaScript/pkgs/Core/Context.pkg

@@ -0,0 +1,139 @@
+$#include "Audio.h"
+$#include "Console.h"
+$#include "Context.h"
+$#include "DebugHud.h"
+$#include "DebugRenderer.h"
+$#include "Engine.h"
+$#include "FileSystem.h"
+$#include "Graphics.h"
+$#include "Input.h"
+$#include "Log.h"
+$#include "Network.h"
+$#include "Network.h"
+$#include "LuaScript.h"
+$#include "PhysicsWorld.h"
+$#include "Renderer.h"
+$#include "ResourceCache.h"
+$#include "Time.h"
+$#include "UI.h"
+
+
+/// Urho3D execution context. Provides access to subsystems, object factories and attributes, and event receivers.
+class Context
+{
+public:
+    /// Template version of returning a subsystem.
+    // template <class T> T* GetSubsystem() const;
+	Audio* GetSubsystem<Audio> @ GetAudio() const;
+	Console* GetSubsystem<Console> @ GetConsole() const;
+	DebugHud* GetSubsystem<DebugHud> @ GetDebugHud() const;
+	DebugRenderer* GetSubsystem<DebugRenderer> @ GetDebugRenderer() const;
+	Engine* GetSubsystem<Engine> @ GetEngine() const;
+	FileSystem* GetSubsystem<FileSystem> @ GetFileSystem() const;
+	Graphics* GetSubsystem<Graphics> @ GetGraphics() const;
+	Input* GetSubsystem<Input> @ GetInput() const;
+	Log* GetSubsystem<Log> @ GetLog() const;
+	Network* GetSubsystem<Network> @ GetNetwork() const;
+	PhysicsWorld* GetSubsystem<PhysicsWorld> @ GetPhysicsWorld() const;	
+	Renderer* GetSubsystem<Renderer> @ GetRenderer() const;	
+	ResourceCache* GetSubsystem<ResourceCache> @ GetCache() const;
+	Time* GetSubsystem<Time> @ GetTime() const;	
+	UI* GetSubsystem<UI> @ GetUI() const;
+};
+
+Context* GetContext();
+
+Audio* GetAudio();
+Console* GetConsole();
+DebugHud* GetDebugHud();
+DebugRenderer* GetDebugRenderer();
+Engine* GetEngine();
+FileSystem* GetFileSystem();
+Graphics* GetGraphics();
+Input* GetInput();
+Log* GetLog();
+Network* GetNetwork();
+PhysicsWorld* GetPhysicsWorld();
+Renderer* GetRenderer();
+ResourceCache* GetCache();
+Time* GetTime();	
+UI* GetUI();
+
+${
+
+static Audio* GetAudio()
+{
+    return GetContext()->GetSubsystem<Audio>();
+}
+
+static Console* GetConsole()
+{
+    return GetContext()->GetSubsystem<Console>();
+}
+
+static DebugHud* GetDebugHud()
+{
+    return GetContext()->GetSubsystem<DebugHud>();
+}
+
+static DebugRenderer* GetDebugRenderer()
+{
+    return GetContext()->GetSubsystem<DebugRenderer>();
+}
+
+static Engine* GetEngine()
+{
+    return GetContext()->GetSubsystem<Engine>();
+}
+
+static FileSystem* GetFileSystem()
+{
+    return GetContext()->GetSubsystem<FileSystem>();
+}
+
+static Graphics* GetGraphics()
+{
+    return GetContext()->GetSubsystem<Graphics>();
+}
+
+static Input* GetInput()
+{
+    return GetContext()->GetSubsystem<Input>();
+}
+
+static Log* GetLog()
+{
+    return GetContext()->GetSubsystem<Log>();
+}
+
+static Network* GetNetwork()
+{
+    return GetContext()->GetSubsystem<Network>();
+}
+
+static PhysicsWorld* GetPhysicsWorld()
+{
+    return GetContext()->GetSubsystem<PhysicsWorld>();
+}
+
+static Renderer* GetRenderer()
+{
+    return GetContext()->GetSubsystem<Renderer>();
+}
+
+static ResourceCache* GetCache()
+{
+    return GetContext()->GetSubsystem<ResourceCache>();
+}
+
+static Time* GetTime()
+{
+    return GetContext()->GetSubsystem<Time>();
+}
+
+static UI* GetUI()
+{
+    return GetContext()->GetSubsystem<UI>();
+}
+
+$}

+ 0 - 2
Extras/LuaScript/pkgs/Core/Timer.pkg

@@ -30,5 +30,3 @@ public:
     /// Return elapsed time from program start as seconds.
     float GetElapsedTime();    
 };
-
-Time* GetTime();

+ 189 - 38
Extras/LuaScript/pkgs/Core/Variant.pkg

@@ -55,11 +55,11 @@ struct ResourceRefList
 
     /// Construct with type only.
     ResourceRefList(ShortStringHash type);
-	
-	/// Object type.
+
+    /// Object type.
     ShortStringHash type_ @ type;
-    
-	/// Test for equality with another reference list.
+
+    /// Test for equality with another reference list.
     bool operator == (const ResourceRefList& rhs) const;
 };
 
@@ -99,7 +99,7 @@ public:
 
     /// Construct from a quaternion.
     Variant(const Quaternion& value);
-	
+
     /// Construct from a color.
     Variant(const Color& value);
 
@@ -142,7 +142,7 @@ public:
     /// Reset to empty.
     void Clear();
 
-	/// Test for equality with another variant.
+    /// Test for equality with another variant.
     bool operator == (const Variant& rhs) const;
     /// Test for equality with an integer. To return true, both the type and value must match.
     bool operator == (int rhs) const;
@@ -178,9 +178,8 @@ public:
     bool operator == (const StringHash& rhs) const;
     /// Test for equality with a ShortStringHash. To return true, both the type and value must match.
     bool operator == (const ShortStringHash& rhs) const;
-    
-	
-	/// Return int or zero on type mismatch.
+
+    /// Return int or zero on type mismatch.
     int GetInt() const;
     /// Return unsigned int or zero on type mismatch.
     int GetUInt() const;
@@ -230,33 +229,185 @@ public:
 class VariantMap
 {
 public:
-	tolua_outside int VariantMapGetInt @ GetInt(const char* key);
-	tolua_outside bool VariantMapGetBool @ GetBool(const char* key);
-	tolua_outside float VariantMapGetFloat @ GetFloat(const char* key);
-	tolua_outside const Vector2& VariantMapGetVector2 @ GetVector2(const char* key);
-	tolua_outside const Vector3& VariantMapGetVector3 @ GetVector3(const char* key);
-	tolua_outside const Vector4& VariantMapGetVector4 @ GetVector4(const char* key);
-	tolua_outside const Quaternion& VariantMapGetQuaternion @ GetQuaternion(const char* key);
-	tolua_outside const Color& VariantMapGetColor @ GetColor(const char* key);
-	tolua_outside const String& VariantMapGetString @ GetString(const char* key);
-	tolua_outside const void* VariantMapGetPtr @ GetPtr(const char* key);
-	tolua_outside const ResourceRef& VariantMapGetResourceRef @ GetResourceRef(const char* key);
-	tolua_outside const ResourceRefList& VariantMapGetResourceRefList @ GetResourceRefList(const char* key);
-	tolua_outside const IntRect& VariantMapGetIntRect @ GetIntRect(const char* key);
-	tolua_outside const IntVector2& VariantMapGetIntVector2 @ GetIntVector2(const char* key);
-
-	tolua_outside void VariantMapSetInt @ SetInt(const char* key, int value);
-	tolua_outside void VariantMapSetBool @ SetBool(const char* key, bool value);
-	tolua_outside void VariantMapSetFloat @ SetFloat(const char* key, float value);
-	tolua_outside void VariantMapSetVector2 @ SetVector2(const char* key, const Vector2& value);
-	tolua_outside void VariantMapSetVector3 @ SetVector3(const char* key, const Vector3& value);
-	tolua_outside void VariantMapSetVector4 @ SetVector4(const char* key, const Vector4& value);
-	tolua_outside void VariantMapSetQuaternion @ SetQuaternion(const char* key, const Quaternion& value);
-	tolua_outside void VariantMapSetColor @ SetColor(const char* key, const Color& value);
-	tolua_outside void VariantMapSetString @ SetString(const char* key, const String& value);
-	tolua_outside void VariantMapSetPtr @ SetPtr(const char* key, void* value);
-	tolua_outside void VariantMapSetResourceRef @ SetResourceRef(const char* key, const ResourceRef& value);
-	tolua_outside void VariantMapSetResourceRefList @ SetResourceRefList(const char* key, const ResourceRefList& value); 
-	tolua_outside void VariantMapSetIntRect @ SetIntRect(const char* key, const IntRect& value);
-	tolua_outside void VariantMapSetIntVector2 @ SetIntVector2(const char* key, const IntVector2& value);
+    VariantMap();
+
+    tolua_outside int VariantMapGetInt @ GetInt(const char* key);
+    tolua_outside bool VariantMapGetBool @ GetBool(const char* key);
+    tolua_outside float VariantMapGetFloat @ GetFloat(const char* key);
+    tolua_outside const Vector2& VariantMapGetVector2 @ GetVector2(const char* key);
+    tolua_outside const Vector3& VariantMapGetVector3 @ GetVector3(const char* key);
+    tolua_outside const Vector4& VariantMapGetVector4 @ GetVector4(const char* key);
+    tolua_outside const Quaternion& VariantMapGetQuaternion @ GetQuaternion(const char* key);
+    tolua_outside const Color& VariantMapGetColor @ GetColor(const char* key);
+    tolua_outside const String& VariantMapGetString @ GetString(const char* key);
+    tolua_outside const void* VariantMapGetPtr @ GetPtr(const char* key);
+    tolua_outside const ResourceRef& VariantMapGetResourceRef @ GetResourceRef(const char* key);
+    tolua_outside const ResourceRefList& VariantMapGetResourceRefList @ GetResourceRefList(const char* key);
+    tolua_outside const IntRect& VariantMapGetIntRect @ GetIntRect(const char* key);
+    tolua_outside const IntVector2& VariantMapGetIntVector2 @ GetIntVector2(const char* key);
+
+    tolua_outside void VariantMapSetInt @ SetInt(const char* key, int value);
+    tolua_outside void VariantMapSetBool @ SetBool(const char* key, bool value);
+    tolua_outside void VariantMapSetFloat @ SetFloat(const char* key, float value);
+    tolua_outside void VariantMapSetVector2 @ SetVector2(const char* key, const Vector2& value);
+    tolua_outside void VariantMapSetVector3 @ SetVector3(const char* key, const Vector3& value);
+    tolua_outside void VariantMapSetVector4 @ SetVector4(const char* key, const Vector4& value);
+    tolua_outside void VariantMapSetQuaternion @ SetQuaternion(const char* key, const Quaternion& value);
+    tolua_outside void VariantMapSetColor @ SetColor(const char* key, const Color& value);
+    tolua_outside void VariantMapSetString @ SetString(const char* key, const String& value);
+    tolua_outside void VariantMapSetPtr @ SetPtr(const char* key, void* value);
+    tolua_outside void VariantMapSetResourceRef @ SetResourceRef(const char* key, const ResourceRef& value);
+    tolua_outside void VariantMapSetResourceRefList @ SetResourceRefList(const char* key, const ResourceRefList& value); 
+    tolua_outside void VariantMapSetIntRect @ SetIntRect(const char* key, const IntRect& value);
+    tolua_outside void VariantMapSetIntVector2 @ SetIntVector2(const char* key, const IntVector2& value);
 };
+
+${
+
+const Variant& FindVariant(const VariantMap* vmap, const char* key)
+{
+    VariantMap::ConstIterator i = vmap->Find(ShortStringHash(key));
+    return i != vmap->End() ? i->second_ : Variant::EMPTY;
+}
+
+int VariantMapGetInt(const VariantMap* vmap, const char* key)
+{
+    return FindVariant(vmap, key).GetInt();
+}
+
+bool VariantMapGetBool(const VariantMap* vmap, const char* key)
+{
+    return FindVariant(vmap, key).GetBool();
+}
+
+float VariantMapGetFloat(const VariantMap* vmap, const char* key)
+{
+    return FindVariant(vmap, key).GetFloat();
+}
+
+const Vector2& VariantMapGetVector2(const VariantMap* vmap, const char* key)
+{
+    return FindVariant(vmap, key).GetVector2();
+}
+
+const Vector3& VariantMapGetVector3(const VariantMap* vmap, const char* key)
+{
+    return FindVariant(vmap, key).GetVector3();
+}
+
+const Vector4& VariantMapGetVector4(const VariantMap* vmap, const char* key)
+{
+    return FindVariant(vmap, key).GetVector4();
+}
+
+const Quaternion& VariantMapGetQuaternion(const VariantMap* vmap, const char* key)
+{
+    return FindVariant(vmap, key).GetQuaternion();
+}
+
+const Color& VariantMapGetColor(const VariantMap* vmap, const char* key)
+{
+    return FindVariant(vmap, key).GetColor();
+}
+
+const String& VariantMapGetString(const VariantMap* vmap, const char* key)
+{
+    return FindVariant(vmap, key).GetString();
+}
+
+const void* VariantMapGetPtr(const VariantMap* vmap, const char* key)
+{
+    return FindVariant(vmap, key).GetPtr();
+}
+
+const ResourceRef& VariantMapGetResourceRef(const VariantMap* vmap, const char* key)
+{
+    return FindVariant(vmap, key).GetResourceRef();
+}
+
+const ResourceRefList& VariantMapGetResourceRefList(const VariantMap* vmap, const char* key)
+{
+    return FindVariant(vmap, key).GetResourceRefList();
+}
+
+const IntRect& VariantMapGetIntRect(const VariantMap* vmap, const char* key)
+{
+    return FindVariant(vmap, key).GetIntRect();
+}
+
+const IntVector2& VariantMapGetIntVector2(const VariantMap* vmap, const char* key)
+{
+    return FindVariant(vmap, key).GetIntVector2();
+}
+
+void VariantMapSetInt(VariantMap* vmap, const char* key, int value)
+{
+    (*vmap)[ShortStringHash(key)] = value;
+}
+
+void VariantMapSetBool(VariantMap* vmap, const char* key, bool value)
+{
+    (*vmap)[ShortStringHash(key)] = value;
+}
+
+void VariantMapSetFloat(VariantMap* vmap, const char* key, float value)
+{
+    (*vmap)[ShortStringHash(key)] = value;
+}
+
+void VariantMapSetVector2(VariantMap* vmap, const char* key, const Vector2& value)
+{
+    (*vmap)[ShortStringHash(key)] = value;
+}
+
+void VariantMapSetVector3(VariantMap* vmap, const char* key, const Vector3& value)
+{
+    (*vmap)[ShortStringHash(key)] = value;
+}
+
+void VariantMapSetVector4(VariantMap* vmap, const char* key, const Vector4& value)
+{
+    (*vmap)[ShortStringHash(key)] = value;
+}
+
+void VariantMapSetQuaternion(VariantMap* vmap, const char* key, const Quaternion& value)
+{
+    (*vmap)[ShortStringHash(key)] = value;
+}
+
+void VariantMapSetColor(VariantMap* vmap, const char* key, const Color& value)
+{
+    (*vmap)[ShortStringHash(key)] = value;
+}
+
+void VariantMapSetString(VariantMap* vmap, const char* key, const String& value)
+{
+    (*vmap)[ShortStringHash(key)] = value;
+}
+
+void VariantMapSetPtr(VariantMap* vmap, const char* key, void* value)
+{
+    (*vmap)[ShortStringHash(key)] = value;
+}
+
+void VariantMapSetResourceRef(VariantMap* vmap, const char* key, const ResourceRef& value)
+{
+    (*vmap)[ShortStringHash(key)] = value;
+}
+
+void VariantMapSetResourceRefList(VariantMap* vmap, const char* key, const ResourceRefList& value)
+{
+    (*vmap)[ShortStringHash(key)] = value;
+}
+
+void VariantMapSetIntRect(VariantMap* vmap, const char* key, const IntRect& value)
+{
+    (*vmap)[ShortStringHash(key)] = value;
+}
+
+void VariantMapSetIntVector2(VariantMap* vmap, const char* key, const IntVector2& value)
+{
+    (*vmap)[ShortStringHash(key)] = value;
+}
+
+$}

+ 1 - 163
Extras/LuaScript/pkgs/CoreLuaAPI.pkg

@@ -1,7 +1,6 @@
 $#define TOLUA_RELEASE
 
-$#include "LuaScript.h"
-
+$pfile "Core/Context.pkg"
 $pfile "Core/ProcessUtils.pkg"
 $pfile "Core/StringUtils.pkg"
 $pfile "Core/Variant.pkg"
@@ -9,164 +8,3 @@ $pfile "Core/Timer.pkg"
 
 $using namespace Urho3D;
 $#pragma warning(disable:4800)
-
-${
-
-const char* GetPlatformCString()
-{
-    static String platform = GetPlatform();
-    return platform.CString();
-}
-
-Time* GetTime()
-{
-    return GetLuaScriptContext()->GetSubsystem<Time>();
-}
-
-const Variant& FindVariant(const VariantMap* vmap, const char* key)
-{
-    VariantMap::ConstIterator i = vmap->Find(ShortStringHash(key));
-    return i != vmap->End() ? i->second_ : Variant::EMPTY;
-}
-
-int VariantMapGetInt(const VariantMap* vmap, const char* key)
-{
-    return FindVariant(vmap, key).GetInt();
-}
-
-bool VariantMapGetBool(const VariantMap* vmap, const char* key)
-{
-    return FindVariant(vmap, key).GetBool();
-}
-
-float VariantMapGetFloat(const VariantMap* vmap, const char* key)
-{
-    return FindVariant(vmap, key).GetFloat();
-}
-
-const Vector2& VariantMapGetVector2(const VariantMap* vmap, const char* key)
-{
-    return FindVariant(vmap, key).GetVector2();
-}
-
-const Vector3& VariantMapGetVector3(const VariantMap* vmap, const char* key)
-{
-    return FindVariant(vmap, key).GetVector3();
-}
-
-const Vector4& VariantMapGetVector4(const VariantMap* vmap, const char* key)
-{
-    return FindVariant(vmap, key).GetVector4();
-}
-
-const Quaternion& VariantMapGetQuaternion(const VariantMap* vmap, const char* key)
-{
-    return FindVariant(vmap, key).GetQuaternion();
-}
-
-const Color& VariantMapGetColor(const VariantMap* vmap, const char* key)
-{
-    return FindVariant(vmap, key).GetColor();
-}
-
-const String& VariantMapGetString(const VariantMap* vmap, const char* key)
-{
-    return FindVariant(vmap, key).GetString();
-}
-
-const void* VariantMapGetPtr(const VariantMap* vmap, const char* key)
-{
-    return FindVariant(vmap, key).GetPtr();
-}
-
-const ResourceRef& VariantMapGetResourceRef(const VariantMap* vmap, const char* key)
-{
-    return FindVariant(vmap, key).GetResourceRef();
-}
-
-const ResourceRefList& VariantMapGetResourceRefList(const VariantMap* vmap, const char* key)
-{
-    return FindVariant(vmap, key).GetResourceRefList();
-}
-
-const IntRect& VariantMapGetIntRect(const VariantMap* vmap, const char* key)
-{
-    return FindVariant(vmap, key).GetIntRect();
-}
-
-const IntVector2& VariantMapGetIntVector2(const VariantMap* vmap, const char* key)
-{
-    return FindVariant(vmap, key).GetIntVector2();
-}
-
-void VariantMapSetInt(VariantMap* vmap, const char* key, int value)
-{
-    (*vmap)[ShortStringHash(key)] = value;
-}
-
-void VariantMapSetBool(VariantMap* vmap, const char* key, bool value)
-{
-    (*vmap)[ShortStringHash(key)] = value;
-}
-
-void VariantMapSetFloat(VariantMap* vmap, const char* key, float value)
-{
-    (*vmap)[ShortStringHash(key)] = value;
-}
-
-void VariantMapSetVector2(VariantMap* vmap, const char* key, const Vector2& value)
-{
-    (*vmap)[ShortStringHash(key)] = value;
-}
-
-void VariantMapSetVector3(VariantMap* vmap, const char* key, const Vector3& value)
-{
-    (*vmap)[ShortStringHash(key)] = value;
-}
-
-void VariantMapSetVector4(VariantMap* vmap, const char* key, const Vector4& value)
-{
-    (*vmap)[ShortStringHash(key)] = value;
-}
-
-void VariantMapSetQuaternion(VariantMap* vmap, const char* key, const Quaternion& value)
-{
-    (*vmap)[ShortStringHash(key)] = value;
-}
-
-void VariantMapSetColor(VariantMap* vmap, const char* key, const Color& value)
-{
-    (*vmap)[ShortStringHash(key)] = value;
-}
-
-void VariantMapSetString(VariantMap* vmap, const char* key, const String& value)
-{
-    (*vmap)[ShortStringHash(key)] = value;
-}
-
-void VariantMapSetPtr(VariantMap* vmap, const char* key, void* value)
-{
-    (*vmap)[ShortStringHash(key)] = value;
-}
-
-void VariantMapSetResourceRef(VariantMap* vmap, const char* key, const ResourceRef& value)
-{
-    (*vmap)[ShortStringHash(key)] = value;
-}
-
-void VariantMapSetResourceRefList(VariantMap* vmap, const char* key, const ResourceRefList& value)
-{
-    (*vmap)[ShortStringHash(key)] = value;
-}
-
-void VariantMapSetIntRect(VariantMap* vmap, const char* key, const IntRect& value)
-{
-    (*vmap)[ShortStringHash(key)] = value;
-}
-
-void VariantMapSetIntVector2(VariantMap* vmap, const char* key, const IntVector2& value)
-{
-    (*vmap)[ShortStringHash(key)] = value;
-}
-
-$}

+ 1 - 4
Extras/LuaScript/pkgs/Engine/Console.pkg

@@ -1,7 +1,7 @@
 $#include "Console.h"
 
 /// %Console window with log history and AngelScript prompt.
-class Console : public Object
+class Console
 {
 public:
     /// Set UI elements' style from an XML file.
@@ -46,6 +46,3 @@ public:
 	/// Return history row at index.
     const String& GetHistoryRow(unsigned index) const;
 };
-
-Console* GetConsole();
-

+ 0 - 2
Extras/LuaScript/pkgs/Engine/DebugHud.pkg

@@ -70,5 +70,3 @@ public:
 	/// Clear all application-specific stats.
     void ClearAppStats();
 };
-
-DebugHud* GetDebugHud();

+ 0 - 2
Extras/LuaScript/pkgs/Engine/Engine.pkg

@@ -58,5 +58,3 @@ public:
 	/// Return whether the engine has been created in headless mode.
     bool IsHeadless() const;
 };
-
-Engine* GetEngine();

+ 0 - 21
Extras/LuaScript/pkgs/EngineLuaAPI.pkg

@@ -1,29 +1,8 @@
 $#define TOLUA_RELEASE
 
-$#include "LuaScript.h"
-
 $pfile "Engine/Console.pkg"
 $pfile "Engine/DebugHud.pkg"
 $pfile "Engine/Engine.pkg"
 
 $using namespace Urho3D;
 $#pragma warning(disable:4800)
-
-${
-
-Console* GetConsole()
-{
-    return GetLuaScriptContext()->GetSubsystem<Console>();
-}
-
-DebugHud* GetDebugHud()
-{
-    return GetLuaScriptContext()->GetSubsystem<DebugHud>();
-}
-
-Engine* GetEngine()
-{
-    return GetLuaScriptContext()->GetSubsystem<Engine>();
-}
-
-$}

+ 33 - 28
Extras/LuaScript/pkgs/Graphics/AnimationController.pkg

@@ -5,61 +5,66 @@ class AnimationController : public Component
 {
 public:
     /// Play an animation and set full target weight. Name must be the full resource name. Return true on success.
-    bool Play(const String& name, unsigned char layer, bool looped, float fadeInTime = 0.0f);
+    bool Play(const char* name, unsigned char layer, bool looped);
+	bool Play(const char* name, unsigned char layer, bool looped, float fadeInTime = 0.0f);
     /// Play an animation, set full target weight and fade out all other animations on the same layer. Name must be the full resource name. Return true on success.
-    bool PlayExclusive(const String& name, unsigned char layer, bool looped, float fadeTime = 0.0f);
+    bool PlayExclusive(const char* name, unsigned char layer, bool looped);
+	bool PlayExclusive(const char* name, unsigned char layer, bool looped, float fadeTime = 0.0f);
     /// Stop an animation. Zero fadetime is instant. Return true on success.
-    bool Stop(const String& name, float fadeOutTime = 0.0f);
+    bool Stop(const char* name);
+	bool Stop(const char* name, float fadeOutTime = 0.0f);
     /// Stop all animations on a specific layer. Zero fadetime is instant.
-    void StopLayer(unsigned char layer, float fadeOutTime = 0.0f);
+    void StopLayer(unsigned char layer);
+	void StopLayer(unsigned char layer, float fadeOutTime = 0.0f);
     /// Stop all animations. Zero fadetime is instant.
-    void StopAll(float fadeTime = 0.0f);
+    void StopAll();
+	void StopAll(float fadeTime = 0.0f);
     /// Fade animation to target weight. Return true on success.
-    bool Fade(const String& name, float targetWeight, float fadeTime);
+    bool Fade(const char* name, float targetWeight, float fadeTime);
     /// Fade other animations on the same layer to target weight. Return true on success.
-    bool FadeOthers(const String& name, float targetWeight, float fadeTime);
+    bool FadeOthers(const char* name, float targetWeight, float fadeTime);
     
     /// Set animation blending layer priority. Return true on success.
-    bool SetLayer(const String& name, unsigned char layer);
+    bool SetLayer(const char* name, unsigned char layer);
     /// Set animation start bone. Return true on success.
-    bool SetStartBone(const String& name, const String& startBoneName);
+    bool SetStartBone(const char* name, const char* startBoneName);
     /// Set animation time position. Return true on success.
-    bool SetTime(const String& name, float time);
+    bool SetTime(const char* name, float time);
     /// Set animation weight. Return true on success.
-    bool SetWeight(const String& name, float weight);
+    bool SetWeight(const char* name, float weight);
     /// Set animation looping. Return true on success.
-    bool SetLooped(const String& name, bool enable);
+    bool SetLooped(const char* name, bool enable);
     /// Set animation speed. Return true on success.
-    bool SetSpeed(const String& name, float speed);
+    bool SetSpeed(const char* name, float speed);
     /// Set animation autofade on stop (non-looped animations only.) Zero time disables. Return true on success.
-    bool SetAutoFade(const String& name, float fadeOutTime);
+    bool SetAutoFade(const char* name, float fadeOutTime);
     
     /// Return whether an animation is active.
-    bool IsPlaying(const String& name) const;
+    bool IsPlaying(const char* name) const;
     /// Return whether an animation is fading in.
-    bool IsFadingIn(const String& name) const;
+    bool IsFadingIn(const char* name) const;
     /// Return whether an animation is fading out.
-    bool IsFadingOut(const String& name) const;
+    bool IsFadingOut(const char* name) const;
     /// Return animation blending layer.
-    unsigned char GetLayer(const String& name) const;
+    unsigned char GetLayer(const char* name) const;
     /// Return animation start bone, or null if no such animation.
-    Bone* GetStartBone(const String& name) const;
+    Bone* GetStartBone(const char* name) const;
     /// Return animation start bone name, or empty string if no such animation.
-    const String& GetStartBoneName(const String& name) const;
+    const String& GetStartBoneName(const char* name) const;
     /// Return animation time position.
-    float GetTime(const String& name) const;
+    float GetTime(const char* name) const;
     /// Return animation weight.
-    float GetWeight(const String& name) const;
+    float GetWeight(const char* name) const;
     /// Return animation looping.
-    bool IsLooped(const String& name) const;
+    bool IsLooped(const char* name) const;
     /// Return animation length.
-    float GetLength(const String& name) const;
+    float GetLength(const char* name) const;
     /// Return animation speed.
-    float GetSpeed(const String& name) const;
+    float GetSpeed(const char* name) const;
     /// Return animation fade target weight.
-    float GetFadeTarget(const String& name) const;
+    float GetFadeTarget(const char* name) const;
     /// Return animation fade time.
-    float GetFadeTime(const String& name) const;
+    float GetFadeTime(const char* name) const;
     /// Return animation autofade time.
-    float GetAutoFade(const String& name) const;
+    float GetAutoFade(const char* name) const;
 };

+ 0 - 2
Extras/LuaScript/pkgs/Graphics/DebugRenderer.pkg

@@ -33,5 +33,3 @@ public:
     /// Check whether a bounding box is inside the view frustum.
     bool IsInside(const BoundingBox& box) const;
 };
-
-DebugRenderer* GetDebugRenderer();

+ 0 - 2
Extras/LuaScript/pkgs/Graphics/Graphics.pkg

@@ -43,5 +43,3 @@ public:
 	/// Return whether the main window is using sRGB conversion on write.
     bool GetSRGB() const;
 };
-
-Graphics* GetGraphics();

+ 54 - 0
Extras/LuaScript/pkgs/Graphics/Light.pkg

@@ -8,6 +8,60 @@ enum LightType
     LIGHT_POINT
 };
 
+/// Shadow depth bias parameters.
+struct BiasParameters
+{
+    /// Construct undefined.
+    BiasParameters()
+    {
+    }
+    
+    /// Construct with initial values.
+    BiasParameters(float constantBias, float slopeScaledBias) :
+        constantBias_(constantBias),
+        slopeScaledBias_(slopeScaledBias)
+    {
+    }
+};
+
+/// Cascaded shadow map parameters.
+struct CascadeParameters
+{
+    /// Construct undefined.
+    CascadeParameters()
+    {
+    }
+    
+    /// Construct with initial values.
+    CascadeParameters(float split1, float split2, float split3, float split4, float fadeStart, float biasAutoAdjust = 1.0f) :
+        fadeStart_(fadeStart),
+        biasAutoAdjust_(biasAutoAdjust)
+    {
+        splits_[0] = split1;
+        splits_[1] = split2;
+        splits_[2] = split3;
+        splits_[3] = split4;
+    }
+};
+
+/// Shadow map focusing parameters.
+struct FocusParameters
+{
+    /// Construct undefined.
+    FocusParameters()
+    {
+    }
+    
+    /// Construct with initial values.
+    FocusParameters(bool focus, bool nonUniform, bool autoSize, float quantize, float minView) :
+        focus_(focus),
+        nonUniform_(nonUniform),
+        autoSize_(autoSize),
+        quantize_(quantize),
+        minView_(minView)
+    {
+    }
+};
 /// %Light component.
 class Light : public Drawable
 {

+ 0 - 2
Extras/LuaScript/pkgs/Graphics/Octree.pkg

@@ -29,5 +29,3 @@ public:
     /// Visualize the component as debug geometry.
     void DrawDebugGeometry(bool depthTest);
 };
-
-Octree* GetOctree();

+ 46 - 0
Extras/LuaScript/pkgs/Graphics/RenderPath.pkg

@@ -0,0 +1,46 @@
+$#include "RenderPath.h"
+
+/// Rendering path definition.
+class RenderPath
+{
+public:
+    /// Clone the rendering path.
+    SharedPtr<RenderPath> Clone();
+    /// Clear existing data and load from an XML file. Return true if successful.
+    bool Load(XMLFile* file);
+    /// Append data from an XML file. Return true if successful.
+    bool Append(XMLFile* file);
+    /// Enable/disable commands and rendertargets by tag.
+    void SetEnabled(const char* tag, bool active);
+    /// Toggle enabled state of commands and rendertargets by tag.
+    void ToggleEnabled(const char* tag);
+    /// Assign rendertarget at index.
+    void SetRenderTarget(unsigned index, const RenderTargetInfo& info);
+    /// Add a rendertarget.
+    void AddRenderTarget(const RenderTargetInfo& info);
+    /// Remove a rendertarget by index.
+    void RemoveRenderTarget(unsigned index);
+    /// Remove a rendertarget by name.
+    void RemoveRenderTarget(const char* name);
+    /// Remove rendertargets by tag name.
+    void RemoveRenderTargets(const char* tag);
+    /// Assign command at index.
+    void SetCommand(unsigned index, const RenderPathCommand& command);
+    /// Add a command to the end of the list.
+    void AddCommand(const RenderPathCommand& command);
+    /// Insert a command at a position.
+    void InsertCommand(unsigned index, const RenderPathCommand& command);
+    /// Remove a command by index.
+    void RemoveCommand(unsigned index);
+    /// Remove commands by tag name.
+    void RemoveCommands(const char* tag);
+    /// Set a shader parameter in all commands that define it.
+    void SetShaderParameter(const char* name, const Vector4& value);
+    
+    /// Return number of rendertargets.
+    unsigned GetNumRenderTargets() const { return renderTargets_.Size(); }
+    /// Return number of commands.
+    unsigned GetNumCommands() const { return commands_.Size(); }
+    /// Return a shader parameter (first appearance in any command.)
+    const Vector4& GetShaderParameter(const char* name) const;
+};

+ 0 - 2
Extras/LuaScript/pkgs/Graphics/Renderer.pkg

@@ -134,5 +134,3 @@ public:
     /// Return the frame update parameters.
     const FrameInfo& GetFrameInfo() { return frame_; }
 };
-
-Renderer* GetRenderer();

+ 64 - 0
Extras/LuaScript/pkgs/Graphics/Viewport.pkg

@@ -0,0 +1,64 @@
+$#include "Viewport.h"
+
+/// %Viewport definition either for a render surface or the backbuffer.
+class Viewport
+{    
+public:
+    /// Construct with defaults.
+    Viewport(Context* context);
+    /// Construct with a full rectangle.
+    Viewport(Context* context, Scene* scene, Camera* camera, RenderPath* renderPath = 0);
+    /// Construct with a specified rectangle.
+    Viewport(Context* context, Scene* scene, Camera* camera, const IntRect& rect, RenderPath* renderPath = 0);
+    /// Destruct.
+    ~Viewport();
+    
+    /// Set scene.
+    void SetScene(Scene* scene);
+    /// Set camera.
+    void SetCamera(Camera* camera);
+    /// Set rectangle.
+    void SetRect(const IntRect& rect);
+    /// Set rendering path.
+    void SetRenderPath(RenderPath* path);
+    /// Set rendering path from an XML file.
+    void SetRenderPath(XMLFile* file);
+    
+    /// Return scene.
+    Scene* GetScene() const;
+    /// Return camera.
+    Camera* GetCamera() const;
+    /// Return rectangle.
+    const IntRect& GetRect() const { return rect_; }
+    /// Return rendering path.
+    RenderPath* GetRenderPath() const;
+};
+
+Viewport* NewViewport(Context* context);
+Viewport* NewViewport(Context* context, Scene* scene, Camera* camera);
+Viewport* NewViewport(Context* context, Scene* scene, Camera* camera, const IntRect& rect);
+void Delete(Viewport* viewport);
+
+${
+
+Viewport* NewViewport(Context* context)
+{
+    return new Viewport(context);
+}
+
+Viewport* NewViewport(Context* context, Scene* scene, Camera* camera)
+{
+    return new Viewport(context, scene, camera);
+}
+
+Viewport* NewViewport(Context* context, Scene* scene, Camera* camera, const IntRect& rect)
+{
+    return new Viewport(context, scene, camera, rect);
+}
+
+void Delete(Viewport* viewport)
+{
+    delete viewport;
+}
+
+$}

+ 2 - 26
Extras/LuaScript/pkgs/GraphicsLuaAPI.pkg

@@ -1,7 +1,5 @@
 $#define TOLUA_RELEASE
 
-$#include "LuaScript.h"
-
 $pfile "Graphics/AnimatedModel.pkg"
 $pfile "Graphics/Animation.pkg"
 $pfile "Graphics/AnimationController.pkg"
@@ -19,6 +17,7 @@ $pfile "Graphics/Model.pkg"
 $pfile "Graphics/Octree.pkg"
 $pfile "Graphics/ParticleEmitter.pkg"
 $pfile "Graphics/Renderer.pkg"
+$pfile "Graphics/RenderPath.pkg"
 $pfile "Graphics/RenderSurface.pkg"
 $pfile "Graphics/Skeleton.pkg"
 $pfile "Graphics/Skybox.pkg"
@@ -29,31 +28,8 @@ $pfile "Graphics/TerrainPatch.pkg"
 $pfile "Graphics/Texture.pkg"
 $pfile "Graphics/Texture2D.pkg"
 $pfile "Graphics/TextureCube.pkg"
+$pfile "Graphics/Viewport.pkg"
 $pfile "Graphics/Zone.pkg"
 
 $using namespace Urho3D;
 $#pragma warning(disable:4800)
-
-${
-
-DebugRenderer* GetDebugRenderer()
-{
-    return GetLuaScriptContext()->GetSubsystem<DebugRenderer>();
-}
-
-Graphics* GetGraphics()
-{
-    return GetLuaScriptContext()->GetSubsystem<Graphics>();
-}
-
-Renderer* GetRenderer()
-{
-    return GetLuaScriptContext()->GetSubsystem<Renderer>();
-}
-
-Octree* GetOctree()
-{
-    return 0;
-}
-
-$}

+ 0 - 2
Extras/LuaScript/pkgs/IO/FileSystem.pkg

@@ -47,8 +47,6 @@ public:
     String GetUserDocumentsDir() const;
 };
 
-FileSystem* GetFileSystem();
-
 /// Split a full path to path, filename and extension. The extension will be converted to lowercase.
 void SplitPath(const String& fullPath, String& pathName, String& fileName, String& extension);
 /// Return the path from a full path.

+ 0 - 2
Extras/LuaScript/pkgs/IO/Log.pkg

@@ -35,5 +35,3 @@ public:
     /// Write raw output to the log.
     static void WriteRaw(const char* message, bool error = false);
 };
-
-Log* GetLog();

+ 0 - 16
Extras/LuaScript/pkgs/IOLuaAPI.pkg

@@ -1,7 +1,5 @@
 $#define TOLUA_RELEASE
 
-$#include "LuaScript.h"
-
 $pfile "IO/File.pkg"
 $pfile "IO/FileSystem.pkg"
 $pfile "IO/Log.pkg"
@@ -9,17 +7,3 @@ $pfile "IO/PackageFile.pkg"
 
 $using namespace Urho3D;
 $#pragma warning(disable:4800)
-
-${
-
-FileSystem* GetFileSystem()
-{
-    return GetLuaScriptContext()->GetSubsystem<FileSystem>();
-}
-
-Log* GetLog()
-{
-    return GetLuaScriptContext()->GetSubsystem<Log>();
-}
-
-$}

+ 0 - 2
Extras/LuaScript/pkgs/Input/Input.pkg

@@ -118,5 +118,3 @@ public:
     /// Return whether application window is minimized.
     bool IsMinimized() const;
 };
-
-Input* GetInput();

+ 54 - 1
Extras/LuaScript/pkgs/Input/InputEvents.pkg

@@ -9,6 +9,17 @@ static const int QUAL_CTRL; // 2;
 static const int QUAL_ALT; // 4;
 static const int QUAL_ANY; // 8;
 
+static const int KEY_1;
+static const int KEY_2;
+static const int KEY_3;
+static const int KEY_4;
+static const int KEY_5;
+static const int KEY_6;
+static const int KEY_7;
+static const int KEY_8;
+static const int KEY_9;
+static const int KEY_0;
+
 static const int KEY_A;
 static const int KEY_B;
 static const int KEY_C;
@@ -115,4 +126,46 @@ static const int HAT_CENTER; // SDL_HAT_CENTERED;
 static const int HAT_UP; // SDL_HAT_UP;
 static const int HAT_RIGHT; // SDL_HAT_RIGHT;
 static const int HAT_DOWN; // SDL_HAT_DOWN;
-static const int HAT_LEFT; // SDL_HAT_LEFT;
+static const int HAT_LEFT; // SDL_HAT_LEFT;
+
+${
+
+static const int KEY_1 = '1';
+static const int KEY_2 = '2';
+static const int KEY_3 = '3';
+static const int KEY_4 = '4';
+static const int KEY_5 = '5';
+static const int KEY_6 = '6';
+static const int KEY_7 = '7';
+static const int KEY_8 = '8';
+static const int KEY_9 = '9';
+static const int KEY_0 = '0';
+
+static const int KEY_A = 'A';
+static const int KEY_B = 'B';
+static const int KEY_C = 'C';
+static const int KEY_D = 'D';
+static const int KEY_E = 'E';
+static const int KEY_F = 'F';
+static const int KEY_G = 'G';
+static const int KEY_H = 'H';
+static const int KEY_I = 'I';
+static const int KEY_J = 'J';
+static const int KEY_K = 'K';
+static const int KEY_L = 'L';
+static const int KEY_M = 'M';
+static const int KEY_N = 'N';
+static const int KEY_O = 'O';
+static const int KEY_P = 'P';
+static const int KEY_Q = 'Q';
+static const int KEY_R = 'R';
+static const int KEY_S = 'S';
+static const int KEY_T = 'T';
+static const int KEY_U = 'U';
+static const int KEY_V = 'V';
+static const int KEY_W = 'W';
+static const int KEY_X = 'X';
+static const int KEY_Y = 'Y';
+static const int KEY_Z = 'Z';
+
+$}

+ 0 - 38
Extras/LuaScript/pkgs/InputLuaAPI.pkg

@@ -1,45 +1,7 @@
 $#define TOLUA_RELEASE
 
-$#include "LuaScript.h"
-
 $pfile "Input/Input.pkg"
 $pfile "Input/InputEvents.pkg"
 
 $using namespace Urho3D;
 $#pragma warning(disable:4800)
-
-${
-
-static const int KEY_A = 'A';
-static const int KEY_B = 'B';
-static const int KEY_C = 'C';
-static const int KEY_D = 'D';
-static const int KEY_E = 'E';
-static const int KEY_F = 'F';
-static const int KEY_G = 'G';
-static const int KEY_H = 'H';
-static const int KEY_I = 'I';
-static const int KEY_J = 'J';
-static const int KEY_K = 'K';
-static const int KEY_L = 'L';
-static const int KEY_M = 'M';
-static const int KEY_N = 'N';
-static const int KEY_O = 'O';
-static const int KEY_P = 'P';
-static const int KEY_Q = 'Q';
-static const int KEY_R = 'R';
-static const int KEY_S = 'S';
-static const int KEY_T = 'T';
-static const int KEY_U = 'U';
-static const int KEY_V = 'V';
-static const int KEY_W = 'W';
-static const int KEY_X = 'X';
-static const int KEY_Y = 'Y';
-static const int KEY_Z = 'Z';
-
-Input* GetInput()
-{
-    return GetLuaScriptContext()->GetSubsystem<Input>();
-}
-
-$}

+ 1 - 0
Extras/LuaScript/pkgs/LuaScriptLuaAPI.pkg

@@ -2,6 +2,7 @@ $#define TOLUA_RELEASE
 
 $#include "LuaScript.h"
 
+void SendEvent(const char* eventType, VariantMap& eventData);
 void SubscribeToEvent(const char* eventType, const char* funcName);
 
 $using namespace Urho3D;

+ 11 - 1
Extras/LuaScript/pkgs/Navigation/NavigationMesh.pkg

@@ -99,5 +99,15 @@ public:
     BoundingBox GetWorldBoundingBox() const;
     /// Return number of tiles.
     IntVector2 GetNumTiles() const { return IntVector2(numTilesX_, numTilesZ_); }
-
 };
+
+${
+
+PODVector<Vector3> NavigationMeshFindPath(NavigationMesh* navMesh, const Vector3& start, const Vector3& end, const Vector3& extents = Vector3::ONE)
+{
+    PODVector<Vector3> dest;
+    navMesh->FindPath(dest, start, end, extents);
+    return dest;
+}
+
+$}

+ 0 - 11
Extras/LuaScript/pkgs/NavigationLuaAPI.pkg

@@ -6,14 +6,3 @@ $pfile "Navigation/OffMeshConnection.pkg"
 
 $using namespace Urho3D;
 $#pragma warning(disable:4800)
-
-${
-
-PODVector<Vector3> NavigationMeshFindPath(NavigationMesh* navMesh, const Vector3& start, const Vector3& end, const Vector3& extents = Vector3::ONE)
-{
-    PODVector<Vector3> dest;
-    navMesh->FindPath(dest, start, end, extents);
-    return dest;
-}
-
-$}

+ 0 - 2
Extras/LuaScript/pkgs/Network/Network.pkg

@@ -44,5 +44,3 @@ public:
     /// Return the package download cache directory.
     const String& GetPackageCacheDir() const { return packageCacheDir_; }
 };
-
-Network* GetNetwork();

+ 0 - 11
Extras/LuaScript/pkgs/NetworkLuaAPI.pkg

@@ -1,7 +1,5 @@
 $#define TOLUA_RELEASE
 
-$#include "LuaScript.h"
-
 $pfile "Network/Connection.pkg"
 $pfile "Network/Controls.pkg"
 $pfile "Network/Network.pkg"
@@ -9,12 +7,3 @@ $pfile "Network/NetworkPriority.pkg"
 
 $using namespace Urho3D;
 $#pragma warning(disable:4800)
-
-${
-
-Network* GetNetwork()
-{
-    return GetLuaScriptContext()->GetSubsystem<Network>();
-}
-
-$}

+ 0 - 4
Extras/LuaScript/pkgs/Physics/PhysicsWorld.pkg

@@ -100,7 +100,3 @@ public:
     /// Return whether node dirtying should be disregarded.
     bool IsApplyingTransforms() const;
 };
-
-PhysicsWorld* GetPhysicsWorld();
-
-

+ 0 - 9
Extras/LuaScript/pkgs/PhysicsLuaAPI.pkg

@@ -7,12 +7,3 @@ $pfile "Physics/RigidBody.pkg"
 
 $using namespace Urho3D;
 $#pragma warning(disable:4800)
-
-${
-
-PhysicsWorld* GetPhysicsWorld()
-{
-    return 0;
-}
-
-$}

+ 24 - 14
Extras/LuaScript/pkgs/Resource/ResourceCache.pkg

@@ -1,4 +1,14 @@
+$#include "Animation.h"
+$#include "Font.h"
+$#include "Image.h"
+$#include "Material.h"
+$#include "Model.h"
 $#include "ResourceCache.h"
+$#include "Sound.h"
+$#include "Technique.h"
+$#include "Texture2D.h"
+$#include "TextureCube.h"
+$#include "XMLFile.h"
 
 /// %Resource cache subsystem. Loads resources on demand and stores them for later access.
 class ResourceCache
@@ -13,7 +23,20 @@ public:
     /// Enable or disable automatic reloading of resources as files are modified.
     void SetAutoReloadResources(bool enable);
     
-    /// Return whether a file exists by name.
+	/// Template version of returning a resource by name.
+    // template <class T> T* GetResource(const char* name);	
+	Animation* GetResource<Animation> @ GetAnimation(const char* name);
+	Font* GetResource<Font> @ GetFont(const char* name);
+	Image* GetResource<Image> @ GetImage(const char* name);
+	Material* GetResource<Material> @ GetMaterial(const char* name);
+	Model* GetResource<Model> @ GetModel(const char* name);
+	Sound* GetResource<Sound> @ GetSound(const char* name);
+	Technique* GetResource<Technique> @ GetTechnique(const char* name);
+	Texture2D* GetResource<Texture2D> @ GetTexture2D(const char* name);
+	TextureCube* GetResource<TextureCube> @ GetTextureCube(const char* name);
+	XMLFile* GetResource<XMLFile> @ GetXMLFile(const char* name);
+	
+	/// Return whether a file exists by name.
     bool Exists(const String& name) const;
     /// Return whether a file exists by name hash.
     bool Exists(StringHash nameHash) const;
@@ -29,17 +52,4 @@ public:
     String GetResourceFileName(const String& name) const;
     /// Return whether automatic resource reloading is enabled.
     bool GetAutoReloadResources() const;
-	
-	tolua_outside Animation* ResourceCacheGetAnimation @ GetAnimation(const char* fileName);
-	tolua_outside Font* ResourceCacheGetFont@ GetFont (const char* fileName);
-	tolua_outside Image* ResourceCacheGetImage @ GetImage(const char* fileName);
-	tolua_outside Material* ResourceCacheGetMaterial@ GetMaterial (const char* fileName);
-	tolua_outside Model* ResourceCacheGetModel @ GetModel(const char* fileName);
-	tolua_outside Sound* ResourceCacheGetSound @ GetSound(const char* fileName);
-	tolua_outside Technique* ResourceCacheGetTechnique @ GetTechnique(const char* fileName);
-	tolua_outside Texture2D* ResourceCacheGetTexture2D @ GetTexture2D(const char* fileName);
-	tolua_outside TextureCube* ResourceCacheGetTextureCube @ GetTextureCube(const char* fileName);
-	tolua_outside XMLFile * ResourceCacheGetXMLFile @ GetXMLFile(const char* fileName);
 };
-
-ResourceCache* GetCache();

+ 0 - 69
Extras/LuaScript/pkgs/ResourceLuaAPI.pkg

@@ -1,15 +1,5 @@
 $#define TOLUA_RELEASE
 
-$#include "Animation.h"
-$#include "Font.h"
-$#include "LuaScript.h"
-$#include "Material.h"
-$#include "Model.h"
-$#include "Sound.h"
-$#include "Technique.h"
-$#include "Texture2D.h"
-$#include "TextureCube.h"
-
 $pfile "Resource/Image.pkg"
 $pfile "Resource/Resource.pkg"
 $pfile "Resource/ResourceCache.pkg"
@@ -18,62 +8,3 @@ $pfile "Resource/XMLFile.pkg"
 
 $using namespace Urho3D;
 $#pragma warning(disable:4800)
-
-${
-
-ResourceCache* GetCache()
-{
-    return GetLuaScriptContext()->GetSubsystem<ResourceCache>();
-}
-
-Animation* ResourceCacheGetAnimation(ResourceCache* cache, const char* fileName)
-{
-    return cache->GetResource<Animation>(fileName);
-}
-
-Font* ResourceCacheGetFont(ResourceCache* cache, const char* fileName)
-{
-    return cache->GetResource<Font>(fileName);
-}
-
-Image* ResourceCacheGetImage(ResourceCache* cache, const char* fileName)
-{
-    return cache->GetResource<Image>(fileName);
-}
-
-Material* ResourceCacheGetMaterial(ResourceCache* cache, const char* fileName)
-{
-    return cache->GetResource<Material>(fileName);
-}
-
-Model* ResourceCacheGetModel(ResourceCache* cache, const char* fileName)
-{
-    return cache->GetResource<Model>(fileName);
-}
-
-Sound* ResourceCacheGetSound(ResourceCache* cache, const char* fileName)
-{
-    return cache->GetResource<Sound>(fileName);
-}
-
-Technique* ResourceCacheGetTechnique(ResourceCache* cache, const char* fileName)
-{
-    return cache->GetResource<Technique>(fileName);
-}
-
-Texture2D* ResourceCacheGetTexture2D(ResourceCache* cache, const char* fileName)
-{
-    return cache->GetResource<Texture2D>(fileName);
-}
-
-TextureCube* ResourceCacheGetTextureCube(ResourceCache* cache, const char* fileName)
-{
-    return cache->GetResource<TextureCube>(fileName);
-}
-
-XMLFile * ResourceCacheGetXMLFile(ResourceCache* cache, const char* fileName)
-{
-    return cache->GetResource<XMLFile>(fileName);
-}
-
-$}

+ 117 - 2
Extras/LuaScript/pkgs/Scene/Node.pkg

@@ -1,4 +1,25 @@
+$#include "AnimationController.h"
+$#include "AnimatedModel.h"
+$#include "Camera.h"
+$#include "CollisionShape.h"
+$#include "Constraint.h"
+$#include "DebugRenderer.h"
+$#include "Drawable.h"
+$#include "Light.h"
+$#include "Navigable.h"
+$#include "NavigationMesh.h"
+$#include "NetworkPriority.h"
 $#include "Node.h"
+$#include "Octree.h"
+$#include "OffMeshConnection.h"
+$#include "PhysicsWorld.h"
+$#include "RigidBody.h"
+$#include "SmoothedTransform.h"
+$#include "SoundListener.h"
+$#include "SoundSource.h"
+$#include "StaticModel.h"
+$#include "Terrain.h"
+$#include "Zone.h"
 
 /// Component and child node creation mode for networking.
 enum CreateMode
@@ -11,6 +32,11 @@ enum CreateMode
 class Node
 {
 public:
+    /// Construct.
+    Node(Context* context);
+    /// Destruct. Any child nodes are detached.
+    virtual ~Node();
+    
     /// Set name.
     void SetName(const String& name);
     /// Set position relative to parent node.
@@ -83,6 +109,7 @@ public:
     Component* CreateComponent(ShortStringHash type, CreateMode mode = REPLICATED, unsigned id = 0);
     /// Create a component to this node if it does not exist already.
     Component* GetOrCreateComponent(ShortStringHash type, CreateMode mode = REPLICATED, unsigned id = 0);
+    
     /// Remove a component from this node.
     void RemoveComponent(Component* component);
     /// Remove the first component of specific type from this node.
@@ -102,6 +129,54 @@ public:
     /// Remove listener component.
     void RemoveListener(Component* component);
     
+    /// Template version of creating a component.
+    // template <class T> T* CreateComponent(CreateMode mode = REPLICATED, unsigned id = 0);
+	AnimationController* CreateComponent<AnimationController> @ CreateAnimationController();
+	AnimatedModel* CreateComponent<AnimatedModel> @ CreateAnimatedModel();
+	Camera* CreateComponent<Camera> @ CreateCamera();
+	CollisionShape* CreateComponent<CollisionShape> @ CreateCollisionShape();
+	Constraint* CreateComponent<Constraint> @ CreateConstraint();
+	DebugRenderer* CreateComponent<DebugRenderer> @ CreateDebugRenderer();
+	Drawable* CreateComponent<Drawable> @ CreateDrawable();
+	Light* CreateComponent<Light> @ CreateLight();
+	Navigable* CreateComponent<Navigable> @ CreateNavigable();
+	NavigationMesh* CreateComponent<NavigationMesh> @ CreateNavigationMesh();
+	NetworkPriority* CreateComponent<NetworkPriority> @ CreateNetworkPriority();
+	Octree* CreateComponent<Octree> @ CreateOctree();
+	OffMeshConnection* CreateComponent<OffMeshConnection> @ CreateOffMeshConnection();
+	PhysicsWorld* CreateComponent<PhysicsWorld> @ CreatePhysicsWorld();
+	RigidBody* CreateComponent<RigidBody> @ CreateRigidBody();
+	SmoothedTransform* CreateComponent<SmoothedTransform> @ CreateSmoothedTransform();
+	SoundListener* CreateComponent<SoundListener> @ CreateSoundListener();
+	SoundSource* CreateComponent<SoundSource> @ CreateSoundSource();
+	StaticModel* CreateComponent<StaticModel> @ CreateStaticModel();
+	Terrain* CreateComponent<Terrain> @ CreateTerrain();
+	Zone* CreateComponent<Zone> @ CreateZone();
+
+    /// Template version of getting or creating a component.
+    // template <class T> T* GetOrCreateComponent(CreateMode mode = REPLICATED, unsigned id = 0);
+    AnimationController* GetOrCreateComponent<AnimationController> @ CreateAnimationController();
+	AnimatedModel* GetOrCreateComponent<AnimatedModel> @ CreateAnimatedModel();
+	Camera* GetOrCreateComponent<Camera> @ CreateCamera();
+	CollisionShape* GetOrCreateComponent<CollisionShape> @ CreateCollisionShape();
+	Constraint* GetOrCreateComponent<Constraint> @ CreateConstraint();
+	DebugRenderer* GetOrCreateComponent<DebugRenderer> @ CreateDebugRenderer();
+	Drawable* GetOrCreateComponent<Drawable> @ CreateDrawable();
+	Light* GetOrCreateComponent<Light> @ CreateLight();
+	Navigable* GetOrCreateComponent<Navigable> @ CreateNavigable();
+	NavigationMesh* GetOrCreateComponent<NavigationMesh> @ CreateNavigationMesh();
+	NetworkPriority* GetOrCreateComponent<NetworkPriority> @ CreateNetworkPriority();
+	Octree* GetOrCreateComponent<Octree> @ CreateOctree();
+	OffMeshConnection* GetOrCreateComponent<OffMeshConnection> @ CreateOffMeshConnection();
+	PhysicsWorld* GetOrCreateComponent<PhysicsWorld> @ CreatePhysicsWorld();
+	RigidBody* GetOrCreateComponent<RigidBody> @ CreateRigidBody();
+	SmoothedTransform* GetOrCreateComponent<SmoothedTransform> @ CreateSmoothedTransform();
+	SoundListener* GetOrCreateComponent<SoundListener> @ CreateSoundListener();
+	SoundSource* GetOrCreateComponent<SoundSource> @ CreateSoundSource();
+	StaticModel* GetOrCreateComponent<StaticModel> @ CreateStaticModel();
+	Terrain* GetOrCreateComponent<Terrain> @ CreateTerrain();
+	Zone* GetOrCreateComponent<Zone> @ CreateZone();
+
     /// Return ID.
     unsigned GetID() const { return id_; }
     /// Return name.
@@ -197,8 +272,48 @@ public:
     /// Return number of non-local components.
     unsigned GetNumNetworkComponents() const;
     /// Return component by type. If there are several, returns the first.
-    Component* GetComponent(ShortStringHash type) const;
+    // Component* GetComponent(ShortStringHash type) const;
     /// Return whether has a specific component.
-    bool HasComponent(ShortStringHash type) const;    
+    // bool HasComponent(ShortStringHash type) const;
 	
+	/// Template version of returning a component by type.
+    // template <class T> T* GetComponent() const;
+	AnimationController* GetComponent<AnimationController> @ GetAnimationController() const;
+	AnimatedModel* GetComponent<AnimatedModel> @ GetAnimatedModel() const;
+	Camera* GetComponent<Camera> @ GetCamera() const;
+	CollisionShape* GetComponent<CollisionShape> @ GetCollisionShape() const;
+	Constraint* GetComponent<Constraint> @ GetConstraint() const;
+	DebugRenderer* GetComponent<DebugRenderer> @ GetDebugRenderer() const;
+	Drawable* GetComponent<Drawable> @ GetDrawable() const;
+	Light* GetComponent<Light> @ GetLight() const;
+	Navigable* GetComponent<Navigable> @ GetNavigable() const;
+	NavigationMesh* GetComponent<NavigationMesh> @ GetNavigationMesh() const;
+	NetworkPriority* GetComponent<NetworkPriority> @ GetNetworkPriority() const;
+	Octree* GetComponent<Octree> @ GetOctree() const;
+	OffMeshConnection* GetComponent<OffMeshConnection> @ GetOffMeshConnection() const;
+	PhysicsWorld* GetComponent<PhysicsWorld> @ GetPhysicsWorld() const;
+	RigidBody* GetComponent<RigidBody> @ GetRigidBody() const;
+	SmoothedTransform* GetComponent<SmoothedTransform> @ GetSmoothedTransform() const;
+	SoundListener* GetComponent<SoundListener> @ GetSoundListener() const;
+	SoundSource* GetComponent<SoundSource> @ GetSoundSource() const;
+	StaticModel* GetComponent<StaticModel> @ GetStaticModel() const;
+	Terrain* GetComponent<Terrain> @ GetTerrain() const;
+	Zone* GetComponent<Zone> @ GetZone() const;
 };
+
+Node* NewNode(Context* context);
+void Delete(Node* node);
+
+${
+
+static Node* NewNode(Context* context)
+{
+    return new Node(context);
+}
+
+static void Delete(Node* node)
+{
+    delete node;
+}
+
+$}

+ 21 - 1
Extras/LuaScript/pkgs/Scene/Scene.pkg

@@ -9,6 +9,11 @@ static const unsigned LAST_LOCAL_ID;
 class Scene : public Node
 {
 public:
+    /// Construct.
+    Scene(Context* context);
+    /// Destruct.
+    virtual ~Scene();
+    
     /// Load from a binary file asynchronously. Return true if started successfully.
     bool LoadAsync(File* file);
     /// Load from an XML file asynchronously. Return true if started successfully.
@@ -91,4 +96,19 @@ public:
     void MarkReplicationDirty(Node* node);
 };
 
-Scene* GetScene();
+Scene* NewScene(Context* context);
+void Delete(Scene* scene);
+
+${
+
+static Scene* NewScene(Context* context)
+{
+    return new Scene(context);
+}
+
+static void Delete(Scene* scene)
+{
+    delete scene;
+}
+
+$}

+ 0 - 9
Extras/LuaScript/pkgs/SceneLuaAPI.pkg

@@ -6,12 +6,3 @@ $pfile "Scene/Scene.pkg"
 
 $using namespace Urho3D;
 $#pragma warning(disable:4800)
-
-${
-
-Scene* GetScene()
-{
-    return 0;
-}
-
-$}

+ 0 - 2
Extras/LuaScript/pkgs/UI/BorderImage.pkg

@@ -36,5 +36,3 @@ public:
     /// Return whether is tiled.
     bool IsTiled() const { return tiled_; }
 };
-
-BorderImage* NewBorderImage @ BorderImage();

+ 0 - 2
Extras/LuaScript/pkgs/UI/Button.pkg

@@ -28,5 +28,3 @@ public:
     /// Return repeat rate.
     float GetRepeatRate() const { return repeatRate_; }
 };
-
-Button* NewButton @ Button();

+ 0 - 2
Extras/LuaScript/pkgs/UI/CheckBox.pkg

@@ -16,5 +16,3 @@ public:
     /// Return checked image offset.
     const IntVector2& GetCheckedOffset() const { return checkedOffset_; }
 };
-
-CheckBox* NewCheckBox @ CheckBox();

+ 23 - 1
Extras/LuaScript/pkgs/UI/Cursor.pkg

@@ -18,6 +18,11 @@ enum CursorShape
 class Cursor : public BorderImage
 {
 public:
+    /// Construct.
+    Cursor(Context* context);
+    /// Destruct.
+    virtual ~Cursor();
+    
     /// Define a shape.
     void DefineShape(CursorShape shape, Image* image, const IntRect& imageRect, const IntVector2& hotSpot, bool osMouseVisible = false);
     /// Set current shape.
@@ -27,5 +32,22 @@ public:
     CursorShape GetShape() const { return shape_; }
 };
 
-Cursor* NewCursor @ Cursor();
+/// Create sprite without lua GC.
+Cursor* NewCursor(Context* context);
+
+/// Delete sprite.
+void Delete(Cursor* cursor);
+
+${
+
+static Cursor* NewCursor(Context* context)
+{
+	return new Cursor(context);
+}
+
+static void Delete(Cursor* cursor)
+{
+    delete cursor;
+}
 
+$}

+ 1 - 3
Extras/LuaScript/pkgs/UI/DropDownList.pkg

@@ -37,6 +37,4 @@ public:
     const String& GetPlaceholderText() const;
     /// Return whether popup should be automatically resized.
     bool GetResizePopup() const { return resizePopup_; }
-};
-
-DropDownList* NewDropDownList @ DropDownList();
+};

+ 0 - 2
Extras/LuaScript/pkgs/UI/FileSelector.pkg

@@ -63,5 +63,3 @@ public:
     /// Return directory mode flag.
     bool GetDirectoryMode() const { return directoryMode_; }
 };
-
-FileSelector* NewFileSelector @ FileSelector();

+ 0 - 2
Extras/LuaScript/pkgs/UI/Font.pkg

@@ -5,5 +5,3 @@ class Font : public Resource
 {
 public:    
 };
-
-Font* NewFont @ Font();

+ 0 - 2
Extras/LuaScript/pkgs/UI/LineEdit.pkg

@@ -46,5 +46,3 @@ public:
     /// Return text selection doubleclick interval in seconds.
     float GetDoubleClickInterval() const;
 };
-
-LineEdit* NewLineEdit @ LineEdit();

+ 0 - 2
Extras/LuaScript/pkgs/UI/ListView.pkg

@@ -86,5 +86,3 @@ public:
     /// Return item doubleclick interval in seconds.
     float GetDoubleClickInterval() const;
 };
-
-ListView* NewListView @ ListView();

+ 0 - 2
Extras/LuaScript/pkgs/UI/Menu.pkg

@@ -27,5 +27,3 @@ public:
     int GetAcceleratorQualifiers() const { return acceleratorQualifiers_; }
     int GetAcceleratorQualifiers() const;
 };
-
-Menu* NewMenu @ Menu();

+ 0 - 2
Extras/LuaScript/pkgs/UI/ScrollBar.pkg

@@ -40,5 +40,3 @@ public:
     /// Return slider element.
     Slider* GetSlider() const { return slider_; }
 };
-
-ScrollBar* NewScrollBar @ ScrollBar();

+ 0 - 2
Extras/LuaScript/pkgs/UI/ScrollView.pkg

@@ -39,5 +39,3 @@ public:
     /// Set view position attribute.
     void SetViewPositionAttr(const IntVector2& value);
 };
-
-ScrollView* NewScrollView @ ScrollView();

+ 0 - 2
Extras/LuaScript/pkgs/UI/Slider.pkg

@@ -26,5 +26,3 @@ public:
     /// Return paging minimum repeat rate (number of events per second).
     float GetRepeatRate() const { return repeatRate_; }
 };
-
-Slider* NewSlider @ Slider();

+ 24 - 1
Extras/LuaScript/pkgs/UI/Sprite.pkg

@@ -6,6 +6,11 @@ enum BlendMode{};
 class Sprite : public UIElement
 {
 public:
+	/// Construct.
+    Sprite(Context* context);
+    /// Destruct.
+    virtual ~Sprite();
+
     /// Set floating point position.
     void SetPosition(const Vector2& position);
     /// Set floating point position.
@@ -54,4 +59,22 @@ public:
     const Matrix3x4& GetTransform() const;
 };
 
-Sprite* NewSprite @ Sprite();
+/// Create sprite without lua GC.
+Sprite* NewSprite(Context* context);
+
+/// Delete sprite.
+void Delete(Sprite* sprite);
+
+${
+
+static Sprite* NewSprite(Context* context)
+{
+	return new Sprite(context);
+}
+
+static void Delete(Sprite* sprite)
+{
+    delete sprite;
+}
+
+$}

+ 0 - 2
Extras/LuaScript/pkgs/UI/Text.pkg

@@ -50,5 +50,3 @@ public:
     /// Return number of rows.
     unsigned GetNumRows() const { return rowWidths_.Size(); }
 };
-
-Text* NewText @ Text();

+ 0 - 2
Extras/LuaScript/pkgs/UI/Text3D.pkg

@@ -66,5 +66,3 @@ public:
     /// Return whether faces camera automatically.
     bool GetFaceCamera() const { return faceCamera_; }
 };
-
-Text3D* NewText3D @ Text3D();

+ 0 - 2
Extras/LuaScript/pkgs/UI/UI.pkg

@@ -54,5 +54,3 @@ public:
     /// Return true when UI has modal element(s).
     bool HasModalElement() const;
 };
-
-UI* GetUI();

+ 0 - 3
Extras/LuaScript/pkgs/UI/UIElement.pkg

@@ -344,6 +344,3 @@ public:
     /// Get element event sender.
     UIElement* GetElementEventSender() const;
 };
-
-UIElement* NewUIElement @ UIElement();
-

+ 0 - 2
Extras/LuaScript/pkgs/UI/Window.pkg

@@ -49,5 +49,3 @@ public:
     /// Get modal frame size.
     const IntVector2& GetModalFrameSize() const { return modalFrameSize_; }
 };
-
-Window* NewWindow @ Window();

+ 1 - 102
Extras/LuaScript/pkgs/UILuaAPI.pkg

@@ -1,7 +1,5 @@
 $#define TOLUA_RELEASE
 
-$#include "LuaScript.h"
-
 $pfile "UI/BorderImage.pkg"
 $pfile "UI/Button.pkg"
 $pfile "UI/CheckBox.pkg"
@@ -23,103 +21,4 @@ $pfile "UI/UIElement.pkg"
 $pfile "UI/Window.pkg"
 
 $using namespace Urho3D;
-$#pragma warning(disable:4800)
-
-${
-
-BorderImage* NewBorderImage()
-{
-    return new BorderImage(GetLuaScriptContext());
-}
-
-Button* NewButton()
-{
-    return new Button(GetLuaScriptContext());
-}
-
-CheckBox* NewCheckBox()
-{
-    return new CheckBox(GetLuaScriptContext());
-}
-
-Cursor* NewCursor()
-{
-    return new Cursor(GetLuaScriptContext());
-}
-
-DropDownList* NewDropDownList()
-{
-    return new DropDownList(GetLuaScriptContext());
-}
-
-FileSelector* NewFileSelector()
-{
-    return new FileSelector(GetLuaScriptContext());
-}
-
-Font* NewFont()
-{
-    return new Font(GetLuaScriptContext());
-}
-
-LineEdit* NewLineEdit()
-{
-    return new LineEdit(GetLuaScriptContext());
-}
-
-ListView* NewListView()
-{
-    return new ListView(GetLuaScriptContext());
-}
-
-Menu* NewMenu()
-{
-    return new Menu(GetLuaScriptContext());
-}
-
-ScrollBar* NewScrollBar()
-{
-    return new ScrollBar(GetLuaScriptContext());
-}
-
-ScrollView* NewScrollView()
-{
-    return new ScrollView(GetLuaScriptContext());
-}
-
-Slider* NewSlider()
-{
-    return new Slider(GetLuaScriptContext());
-}
-
-Sprite* NewSprite()
-{
-    return new Sprite(GetLuaScriptContext());
-}
-
-Text* NewText()
-{
-    return new Text(GetLuaScriptContext());
-}
-
-Text3D* NewText3D()
-{
-    return new Text3D(GetLuaScriptContext());
-}
-
-UI* GetUI()
-{
-    return GetLuaScriptContext()->GetSubsystem<UI>();
-}
-
-UIElement* NewUIElement()
-{
-    return new UIElement(GetLuaScriptContext());
-}
-
-Window* NewWindow()
-{
-    return new Window(GetLuaScriptContext());
-}
-
-$}
+$#pragma warning(disable:4800)