瀏覽代碼

Added managed HString

Marko Pintera 12 年之前
父節點
當前提交
c58b45571a

+ 1 - 0
BansheeEngine.sln

@@ -47,6 +47,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
 		Opts.txt = Opts.txt
 		Opts.txt = Opts.txt
 		RenderOperation.txt = RenderOperation.txt
 		RenderOperation.txt = RenderOperation.txt
 		ResourceBundles.txt = ResourceBundles.txt
 		ResourceBundles.txt = ResourceBundles.txt
+		SpriteTexture.txt = SpriteTexture.txt
 		TODO.txt = TODO.txt
 		TODO.txt = TODO.txt
 		TODODoc.txt = TODODoc.txt
 		TODODoc.txt = TODODoc.txt
 		TODOEditor.txt = TODOEditor.txt
 		TODOEditor.txt = TODOEditor.txt

+ 17 - 0
BansheeMono/Include/BsMonoUtil.h

@@ -12,6 +12,9 @@ namespace BansheeEngine
 	public:
 	public:
 		static CM::WString monoToWString(MonoString* str)
 		static CM::WString monoToWString(MonoString* str)
 		{
 		{
+			if(str == nullptr)
+				return CM::StringUtil::WBLANK;
+
 			int len = mono_string_length(str);
 			int len = mono_string_length(str);
 			mono_unichar2* monoChars = mono_string_chars(str);
 			mono_unichar2* monoChars = mono_string_chars(str);
 
 
@@ -22,6 +25,20 @@ namespace BansheeEngine
 			return ret;
 			return ret;
 		}
 		}
 
 
+		static MonoString* wstringToMono(MonoDomain* domain, const CM::WString& str)
+		{
+			CM::UINT32 len = (CM::UINT32)str.length();
+			mono_unichar2* monoChars = (mono_unichar2*)CM::cm_alloc<mono_unichar2>(len);
+
+			for(CM::UINT32 i = 0; i < len; i++)
+				monoChars[i] = str[i];
+
+			MonoString* monoString = mono_string_new_utf16(domain, monoChars, len);
+
+			CM::cm_free(monoChars);
+			return monoString;
+		}
+
 		static void throwIfException(MonoObject* exception)
 		static void throwIfException(MonoObject* exception)
 		{
 		{
 			if(exception != nullptr)
 			if(exception != nullptr)

+ 25 - 55
CSharpWrap.txt

@@ -1,15 +1,4 @@
 Classes that need C# wrappers:
 Classes that need C# wrappers:
-Math (Instead of a wrapper create actual C# classes, but which map 1-1 with C++ code so we can move them through C++/C# boundaries):
- -Vector2
- -Vector3
- -Vector4
- -Matrix3
- -Matrix4
- -Quaternion
- -Rect
- -Int2
- -Color
-
 Resources:
 Resources:
  - Mesh
  - Mesh
  - Texture
  - Texture
@@ -48,12 +37,6 @@ Systems:
 
 
  -----------------
  -----------------
 
 
-// TODO - I might need to call this
- retval = mono_jit_exec (domain, assembly, argc - 1, argv + 1);
-to call a Main function in the assembly
-
- -----------------
-
 For EditorWindow, add a new class in BansheeEditor, which pretty much does the job of  EditorWidget::open
 For EditorWindow, add a new class in BansheeEditor, which pretty much does the job of  EditorWidget::open
  - Except it creates an empty widget. (It will also create a window, but in C++ code)
  - Except it creates an empty widget. (It will also create a window, but in C++ code)
  - All the window docking/undocking moving/resizing is done in C++
  - All the window docking/undocking moving/resizing is done in C++
@@ -108,35 +91,32 @@ Eventually make all math classes templates that work on both doubles and floats.
 
 
 ----------------------------
 ----------------------------
 
 
-EditorGUI - NOT a component
- - Internally just a GUIWidget
- - has AddArea method
- - has main field that points to main Layout
- - shares interface with "GUI", which is used for main game window
- - has a reference to GUISkin. Default is GUISkin.main
-
-GUIArea
- - has layout field
- - has AddLayoutX, AddLayoutY
-
-GUILayout
- - has AddButton, AddLabel, AddLayoutX, AddLayoutY
-
-GUIButton, GUILabel
- - Require GUILayoutOptions, GUIElementStyle upon construction
- - Have Destroy() methods
+Implement:
+ - GUIContent
+ - HString
 
 
-GUIElementStyle
- - Requires font
- - Requires SpriteTexture
- - Create DUMMY font and texture classes for now
-
-GUISkin 
- - Has pointers to GUIElementStyles for button, label, etc. plus support for custom styles using GetStyle(name), SetStyle(name)
-
-Immediate:
- - Implement ScriptGUIBase
- - Delete: GUIWidget and ScriptGUIWidget
+ - Button
+ - Texture
+ - RenderTexture
+ - Toggle
+ - TextField
+ - ListBox
+ - DropDownBox
+ - ScrollArea
+
+ - Space
+ - FlexibleSpace
+
+ - Destroy()
+ - GUISkin
+   - List of properties with all common styles, like .button, .label
+   - Get/SetStyle methods for custom styles
+   - GUISkin.main <- default skin
+ - GUI (Non EditorGUI version)
+
+ - Implement Font
+ - SpriteTexture needs to be a handle
+ - Implement C# SpriteTexture
 
 
 When loading resources I need to be able to load both project resources and engine ones. 
 When loading resources I need to be able to load both project resources and engine ones. 
  - BuiltinResources can be used for accessing default resources like GUI skin textures and similar
  - BuiltinResources can be used for accessing default resources like GUI skin textures and similar
@@ -150,16 +130,6 @@ ScriptGUILabel currently accepts a WString, while it should be accepting a HStri
 
 
  BsApplication::getPrimaryViewport is not implemented
  BsApplication::getPrimaryViewport is not implemented
 
 
-Reconsider making scripts a static library
- - The scripts would only have one external header that allows you to start the script engine and load assemblies
- - So BansheeEngine script library would be dependant on BansheeEngine
- - BansheeEditor script library would be dependant on BansheeEditor, BansheEngine and BansheeEngineScript
- - Maybe even make them .dlls? Then BansheeEngine and bansheeeditor doesn't need to know about their includes
-
-IGNORE RESOURCES FOR NOW. When building the GUI make sure that they all temporarily use the native skin
- - Later implement GUIBase.skin (and actually implement GUISkin because it's just a dummy for now)
-
-
 ----------------------------
 ----------------------------
 
 
   I want my .exe to be native. Internally it will call MBansheeEngine and MBansheeEditor.
   I want my .exe to be native. Internally it will call MBansheeEngine and MBansheeEditor.

+ 2 - 1
MBansheeEditor/ProjectSelectWindow.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using System.Text;
 using System.Text;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
+using BansheeEngine;
 
 
 namespace BansheeEditor
 namespace BansheeEditor
 {
 {
@@ -11,7 +12,7 @@ namespace BansheeEditor
         public ProjectSelectWindow()
         public ProjectSelectWindow()
             :base(0, 0, 200, 200)
             :base(0, 0, 200, 200)
         {
         {
-            GUI.main.AddLabel("Test test");
+            GUI.main.AddLabel(new HString("Test test"));
         }
         }
     }
     }
 }
 }

+ 3 - 3
MBansheeEngine/GUI.cs

@@ -17,17 +17,17 @@ namespace BansheeEngine
             return ((GUIBase)instance).AddArea(x, y, width, height, depth);
             return ((GUIBase)instance).AddArea(x, y, width, height, depth);
         }
         }
 
 
-        public GUIArea AddResizableAreaX(int offsetLeft, int offsetRight, int offsetTop, int height, short depth = 0)
+        public new static GUIArea AddResizableAreaX(int offsetLeft, int offsetRight, int offsetTop, int height, short depth = 0)
         {
         {
             return ((GUIBase)instance).AddResizableAreaX(offsetLeft, offsetRight, offsetTop, height, depth);
             return ((GUIBase)instance).AddResizableAreaX(offsetLeft, offsetRight, offsetTop, height, depth);
         }
         }
 
 
-        public GUIArea AddResizableAreaY(int offsetTop, int offsetBottom, int offsetLeft, int width, short depth = 0)
+        public new static GUIArea AddResizableAreaY(int offsetTop, int offsetBottom, int offsetLeft, int width, short depth = 0)
         {
         {
             return ((GUIBase)instance).AddResizableAreaY(offsetTop, offsetBottom, offsetLeft, width, depth);
             return ((GUIBase)instance).AddResizableAreaY(offsetTop, offsetBottom, offsetLeft, width, depth);
         }
         }
 
 
-        public GUIArea AddResizableAreaXY(int offsetLeft, int offsetRight, int offsetTop, int offsetBottom, short depth = 0)
+        public new static GUIArea AddResizableAreaXY(int offsetLeft, int offsetRight, int offsetTop, int offsetBottom, short depth = 0)
         {
         {
             return ((GUIBase)instance).AddResizableAreaXY(offsetLeft, offsetRight, offsetTop, offsetBottom, depth);
             return ((GUIBase)instance).AddResizableAreaXY(offsetLeft, offsetRight, offsetTop, offsetBottom, depth);
         }
         }

+ 3 - 3
MBansheeEngine/GUILabel.cs

@@ -4,12 +4,12 @@ namespace BansheeEngine
 {
 {
     public sealed class GUILabel : ScriptObject
     public sealed class GUILabel : ScriptObject
     {
     {
-        internal GUILabel(GUILayout parentLayout, string name, GUIElementStyle style, params GUIOption[] options)
+        internal GUILabel(GUILayout parentLayout, HString value, GUIElementStyle style, params GUIOption[] options)
         {
         {
-            Internal_CreateInstance(this, parentLayout, name, style, options);
+            Internal_CreateInstance(this, parentLayout, value, style, options);
         }
         }
 
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_CreateInstance(GUILabel instance, GUILayout layout, string name, GUIElementStyle style, GUIOption[] options);
+        private static extern void Internal_CreateInstance(GUILabel instance, GUILayout layout, HString value, GUIElementStyle style, GUIOption[] options);
     }
     }
 }
 }

+ 3 - 3
MBansheeEngine/GUILayout.cs

@@ -5,17 +5,17 @@ namespace BansheeEngine
 {
 {
     public abstract class GUILayout : ScriptObject
     public abstract class GUILayout : ScriptObject
     {
     {
-        public GUILabel AddLabel(string name, GUIElementStyle style, params GUIOption[] options)
+        public GUILabel AddLabel(HString name, GUIElementStyle style, params GUIOption[] options)
         {
         {
             return new GUILabel(this, name, style, options);
             return new GUILabel(this, name, style, options);
         }
         }
 
 
-        public GUILabel AddLabel(string name, GUIElementStyle style)
+        public GUILabel AddLabel(HString name, GUIElementStyle style)
         {
         {
             return new GUILabel(this, name, style, new GUIOption[0]);
             return new GUILabel(this, name, style, new GUIOption[0]);
         }
         }
 
 
-        public GUILabel AddLabel(string name, params GUIOption[] options)
+        public GUILabel AddLabel(HString name, params GUIOption[] options)
         {
         {
             return new GUILabel(this, name, null, options);
             return new GUILabel(this, name, null, options);
         }
         }

+ 24 - 0
MBansheeEngine/HString.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Runtime.CompilerServices;
+
+namespace BansheeEngine
+{
+    public sealed class HString : ScriptObject
+    {
+        public HString(string identifier)
+        {
+            Internal_CreateInstance(this, identifier);
+        }
+
+        public void setParameter(int idx, string value)
+        {
+            Internal_SetParameter(mCachedPtr, idx, value);
+        }
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_CreateInstance(HString instance, string identifier);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetParameter(IntPtr nativeInstance, int idx, string identifier);
+    }
+}

+ 2 - 0
MBansheeEngine/MBansheeEngine.csproj

@@ -57,6 +57,7 @@
     <Compile Include="GUIOption.cs" />
     <Compile Include="GUIOption.cs" />
     <Compile Include="GUISkin.cs" />
     <Compile Include="GUISkin.cs" />
     <Compile Include="GUIWidget.cs" />
     <Compile Include="GUIWidget.cs" />
+    <Compile Include="HString.cs" />
     <Compile Include="MathEx.cs" />
     <Compile Include="MathEx.cs" />
     <Compile Include="Matrix3.cs" />
     <Compile Include="Matrix3.cs" />
     <Compile Include="Matrix4.cs" />
     <Compile Include="Matrix4.cs" />
@@ -66,6 +67,7 @@
     <Compile Include="Resource.cs" />
     <Compile Include="Resource.cs" />
     <Compile Include="ScriptObject.cs" />
     <Compile Include="ScriptObject.cs" />
     <Compile Include="SpriteTexture.cs" />
     <Compile Include="SpriteTexture.cs" />
+    <Compile Include="StringTable.cs" />
     <Compile Include="Texture2D.cs" />
     <Compile Include="Texture2D.cs" />
     <Compile Include="TextureFormat.cs" />
     <Compile Include="TextureFormat.cs" />
     <Compile Include="Vector2.cs" />
     <Compile Include="Vector2.cs" />

+ 239 - 0
MBansheeEngine/StringTable.cs

@@ -0,0 +1,239 @@
+using System;
+using System.Runtime.CompilerServices;
+
+namespace BansheeEngine
+{
+    public sealed class StringTable
+    {
+        public Language GetActiveLanguage()
+        {
+            Language value;
+            Internal_GetActiveLanguage(out value);
+            return value;
+        }
+
+		public void SetActiveLanguage(Language language)
+		{
+            Internal_SetActiveLanguage(language);
+		}
+
+		public void SetString(string identifier, Language language, string value)
+		{
+		    Internal_SetString(identifier, language, value);
+		}
+
+		public void RemoveString(string identifier)
+		{
+		    Internal_RemoveString(identifier);
+		}
+
+        public string GetLocalizedString(string identifier)
+        {
+            string value;
+            Internal_GetLocalizedString(identifier, out value);
+            return value;
+        }
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_GetActiveLanguage(out Language value);
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetActiveLanguage(Language value);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetString(string identifier, Language language, string value);
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_RemoveString(string identifier);
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_GetLocalizedString(string identifier, out string value);
+    }
+
+    public enum Language
+	{
+		Afar, 
+		Abkhazian, 
+		Avestan, 
+		Afrikaans, 
+		Akan, 
+		Amharic, 
+		Aragonese, 
+		Arabic, 
+		Assamese, 
+		Avaric, 
+		Aymara, 
+		Azerbaijani, 
+		Bashkir, 
+		Belarusian, 
+		Bulgarian, 
+		Bihari, 
+		Bislama, 
+		Bambara, 
+		Bengali, 
+		Tibetan, 
+		Breton, 
+		Bosnian, 
+		Catalan, 
+		Chechen, 
+		Chamorro, 
+		Corsican, 
+		Cree, 
+		Czech, 
+		ChurchSlavic,
+		Chuvash, 
+		Welsh, 
+		Danish, 
+		German, 
+		Maldivian, 
+		Bhutani, 
+		Ewe, 		
+		Greek, 
+		EnglishUK, 
+		EnglishUS,
+		Esperanto, 
+		Spanish, 
+		Estonian, 
+		Basque, 
+		Persian, 
+		Fulah, 
+		Finnish, 
+		Fijian, 
+		Faroese, 
+		French, 
+		WesternFrisian, 
+		Irish, 
+		ScottishGaelic, 
+		Galician, 
+		Guarani, 
+		Gujarati, 
+		Manx, 
+		Hausa, 
+		Hebrew, 
+		Hindi, 
+		HiriMotu, 
+		Croatian, 
+		Haitian, 
+		Hungarian, 
+		Armenian, 
+		Herero, 
+		Interlingua, 
+		Indonesian, 
+		Interlingue, 
+		Igbo, 
+		SichuanYi, 
+		Inupiak, 
+		Ido, 
+		Icelandic, 
+		Italian, 
+		Inuktitut, 
+		Japanese, 
+		Javanese, 
+		Georgian, 
+		Kongo, 
+		Kikuyu, 
+		Kuanyama, 
+		Kazakh, 
+		Kalaallisut, 
+		Cambodian, 
+		Kannada, 
+		Korean, 
+		Kanuri, 
+		Kashmiri, 
+		Kurdish, 
+		Komi, 
+		Cornish, 
+		Kirghiz, 
+		Latin, 
+		Luxembourgish, 
+		Ganda, 
+		Limburgish,
+		Lingala, 
+		Laotian, 
+		Lithuanian, 
+		LubaKatanga, 
+		Latvian,
+		Malagasy, 
+		Marshallese, 
+		Maori, 
+		Macedonian, 
+		Malayalam, 
+		Mongolian, 
+		Moldavian, 
+		Marathi, 
+		Malay, 
+		Maltese, 
+		Burmese, 
+		Nauru, 
+		NorwegianBokmal, 
+		Ndebele, 
+		Nepali, 
+		Ndonga, 
+		Dutch, 
+		NorwegianNynorsk, 
+		Norwegian, 
+		Navaho, 
+		Nyanja, 
+		Provençal, 
+		Ojibwa, 
+		Oromo, 
+		Oriya, 
+		Ossetic, 
+		Punjabi, 
+		Pali, 
+		Polish, 
+		Pushto, 
+		Portuguese, 
+		Quechua, 
+		Romansh, 
+		Kirundi, 
+		Romanian, 
+		Russian, 
+		Kinyarwanda, 
+		Sanskrit, 
+		Sardinian, 
+		Sindhi, 
+		NorthernSami, 
+		Sangro, 
+		Sinhalese, 
+		Slovak, 
+		Slovenian, 
+		Samoan, 
+		Shona, 
+		Somali, 
+		Albanian, 
+		Serbian, 
+		Swati,
+		Sesotho,
+		Sundanese, 
+		Swedish, 
+		Swahili, 
+		Tamil, 
+		Telugu, 
+		Tajik, 
+		Thai, 
+		Tigrinya, 
+		Turkmen, 
+		Tagalog, 
+		Setswana, 
+		Tonga, 
+		Turkish, 
+		Tsonga, 
+		Tatar,
+		Twi, 
+		Tahitian, 
+		Uighur, 
+		Ukrainian, 
+		Urdu, 
+		Uzbek, 
+		Venda, 
+		Vietnamese, 
+		Volapuk, 
+		Walloon, 
+		Wolof, 
+		Xhosa, 
+		Yiddish, 
+		Yoruba, 
+		Zhuang,
+		Chinese,
+		Zulu,
+		Count // Number of entries
+	};
+}

+ 1 - 1
SBansheeEngine/Include/BsScriptGUILabel.h

@@ -14,7 +14,7 @@ namespace BansheeEngine
 		void* getNativeRaw() const { return mLabel; }
 		void* getNativeRaw() const { return mLabel; }
 
 
 	private:
 	private:
-		static void internal_createInstance(MonoObject* instance, MonoObject* parentLayout, MonoString* label, MonoObject* style, MonoArray* guiOptions);
+		static void internal_createInstance(MonoObject* instance, MonoObject* parentLayout, MonoObject* label, MonoObject* style, MonoArray* guiOptions);
 		static void internal_destroyInstance(ScriptGUILabel* nativeInstance);
 		static void internal_destroyInstance(ScriptGUILabel* nativeInstance);
 
 
 		static void initRuntimeData();
 		static void initRuntimeData();

+ 29 - 0
SBansheeEngine/Include/BsScriptHString.h

@@ -0,0 +1,29 @@
+#pragma once
+
+#include "BsScriptEnginePrerequisites.h"
+#include "BsScriptObject.h"
+#include "CmHString.h"
+
+namespace BansheeEngine
+{
+	class BS_SCR_BE_EXPORT ScriptHString : public ScriptObject<ScriptHString>
+	{
+	public:
+		static void initMetaData();
+
+		const CM::HString& getInternalValue() const { return mString; }
+		void* getNativeRaw() const { return (void*)&mString; }
+
+	private:
+		static void internal_createInstance(MonoObject* instance, MonoString* identifier);
+		static void internal_destroyInstance(ScriptHString* nativeInstance);
+		static void internal_setParameter(CM::HString* nativeInstance, CM::UINT32 idx, MonoString* value);
+
+		static void initRuntimeData();
+
+		ScriptHString(const CM::HString& string);
+
+		GUIArea* mArea;
+		CM::HString mString;
+	};
+}

+ 26 - 0
SBansheeEngine/Include/BsScriptStringTable.h

@@ -0,0 +1,26 @@
+#pragma once
+
+#include "BsScriptEnginePrerequisites.h"
+#include "BsScriptObject.h"
+#include "CmStringTable.h"
+
+namespace BansheeEngine
+{
+	class BS_SCR_BE_EXPORT ScriptStringTable : public ScriptObject<ScriptStringTable>
+	{
+	public:
+		static void initMetaData();
+
+	private:
+		static void internal_GetActiveLanguage(CM::Language* value);
+		static void internal_SetActiveLanguage(CM::Language value);
+
+		static void internal_SetString(MonoString* identifier, CM::Language language, MonoString* value);
+		static void internal_RemoveString(MonoString* identifier);
+		static void internal_GetLocalizedString(MonoString* identifier, MonoString** value);
+
+		static void initRuntimeData();
+
+		ScriptStringTable() { }
+	};
+}

+ 4 - 0
SBansheeEngine/SBansheeEngine.vcxproj

@@ -234,9 +234,11 @@
     <ClInclude Include="Include\BsScriptGUIElementStyle.h" />
     <ClInclude Include="Include\BsScriptGUIElementStyle.h" />
     <ClInclude Include="Include\BsScriptGUILabel.h" />
     <ClInclude Include="Include\BsScriptGUILabel.h" />
     <ClInclude Include="Include\BsScriptGUILayout.h" />
     <ClInclude Include="Include\BsScriptGUILayout.h" />
+    <ClInclude Include="Include\BsScriptHString.h" />
     <ClInclude Include="Include\BsScriptMacros.h" />
     <ClInclude Include="Include\BsScriptMacros.h" />
     <ClInclude Include="Include\BsScriptObject.h" />
     <ClInclude Include="Include\BsScriptObject.h" />
     <ClInclude Include="Include\BsScriptSpriteTexture.h" />
     <ClInclude Include="Include\BsScriptSpriteTexture.h" />
+    <ClInclude Include="Include\BsScriptStringTable.h" />
     <ClInclude Include="Include\BsScriptTexture2D.h" />
     <ClInclude Include="Include\BsScriptTexture2D.h" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
@@ -248,7 +250,9 @@
     <ClCompile Include="Source\BsScriptGUIElementStyle.cpp" />
     <ClCompile Include="Source\BsScriptGUIElementStyle.cpp" />
     <ClCompile Include="Source\BsScriptGUILabel.cpp" />
     <ClCompile Include="Source\BsScriptGUILabel.cpp" />
     <ClCompile Include="Source\BsScriptGUILayout.cpp" />
     <ClCompile Include="Source\BsScriptGUILayout.cpp" />
+    <ClCompile Include="Source\BsScriptHString.cpp" />
     <ClCompile Include="Source\BsScriptSpriteTexture.cpp" />
     <ClCompile Include="Source\BsScriptSpriteTexture.cpp" />
+    <ClCompile Include="Source\BsScriptStringTable.cpp" />
     <ClCompile Include="Source\BsScriptTexture2D.cpp" />
     <ClCompile Include="Source\BsScriptTexture2D.cpp" />
   </ItemGroup>
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

+ 12 - 0
SBansheeEngine/SBansheeEngine.vcxproj.filters

@@ -51,6 +51,12 @@
     <ClInclude Include="Include\BsScriptEnginePrerequisites.h">
     <ClInclude Include="Include\BsScriptEnginePrerequisites.h">
       <Filter>Header Files</Filter>
       <Filter>Header Files</Filter>
     </ClInclude>
     </ClInclude>
+    <ClInclude Include="Include\BsScriptStringTable.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsScriptHString.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsScriptTexture2D.cpp">
     <ClCompile Include="Source\BsScriptTexture2D.cpp">
@@ -83,5 +89,11 @@
     <ClCompile Include="Source\BsScriptEnginePlugin.cpp">
     <ClCompile Include="Source\BsScriptEnginePlugin.cpp">
       <Filter>Source Files</Filter>
       <Filter>Source Files</Filter>
     </ClCompile>
     </ClCompile>
+    <ClCompile Include="Source\BsScriptHString.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsScriptStringTable.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   </ItemGroup>
 </Project>
 </Project>

+ 4 - 3
SBansheeEngine/Source/BsScriptGUILabel.cpp

@@ -11,6 +11,7 @@
 #include "BsScriptGUIElementStyle.h"
 #include "BsScriptGUIElementStyle.h"
 #include "BsScriptGUILayout.h"
 #include "BsScriptGUILayout.h"
 #include "BsScriptGUIArea.h"
 #include "BsScriptGUIArea.h"
+#include "BsScriptHString.h"
 
 
 using namespace CamelotFramework;
 using namespace CamelotFramework;
 
 
@@ -34,10 +35,10 @@ namespace BansheeEngine
 		metaData.scriptClass->addInternalCall("Internal_DestroyInstance", &ScriptGUILabel::internal_destroyInstance);
 		metaData.scriptClass->addInternalCall("Internal_DestroyInstance", &ScriptGUILabel::internal_destroyInstance);
 	}
 	}
 
 
-	void ScriptGUILabel::internal_createInstance(MonoObject* instance, MonoObject* parentLayout, MonoString* label, MonoObject* style, MonoArray* guiOptions)
+	void ScriptGUILabel::internal_createInstance(MonoObject* instance, MonoObject* parentLayout, MonoObject* label, MonoObject* style, MonoArray* guiOptions)
 	{
 	{
 		ScriptGUILayout* scriptLayout = ScriptGUILayout::toNative(parentLayout);
 		ScriptGUILayout* scriptLayout = ScriptGUILayout::toNative(parentLayout);
-		HString nativeLabel(MonoUtil::monoToWString(label));
+		ScriptHString* nativeLabel = ScriptHString::toNative(label);
 		GUIOptions options;
 		GUIOptions options;
 
 
 		UINT32 arrayLen = (UINT32)mono_array_length(guiOptions);
 		UINT32 arrayLen = (UINT32)mono_array_length(guiOptions);
@@ -49,7 +50,7 @@ namespace BansheeEngine
 		if(style != nullptr)
 		if(style != nullptr)
 			elemStyle = ScriptGUIElementStyle::toNative(style)->getInternalValue();
 			elemStyle = ScriptGUIElementStyle::toNative(style)->getInternalValue();
 
 
-		GUILabel* guiLabel = GUILabel::create(scriptLayout->getParentArea()->getParentWidget(), nativeLabel, options, elemStyle); // TODO - Use proper HString
+		GUILabel* guiLabel = GUILabel::create(scriptLayout->getParentArea()->getParentWidget(), nativeLabel->getInternalValue(), options, elemStyle); // TODO - Use proper HString
 		GUILayout* nativeLayout = scriptLayout->getInternalValue();
 		GUILayout* nativeLayout = scriptLayout->getInternalValue();
 		nativeLayout->addElement(guiLabel);
 		nativeLayout->addElement(guiLabel);
 
 

+ 50 - 0
SBansheeEngine/Source/BsScriptHString.cpp

@@ -0,0 +1,50 @@
+#include "BsScriptHString.h"
+#include "BsScriptMeta.h"
+#include "BsMonoField.h"
+#include "BsMonoClass.h"
+#include "BsMonoManager.h"
+#include "BsMonoUtil.h"
+
+using namespace CamelotFramework;
+
+namespace BansheeEngine
+{
+	ScriptHString::ScriptHString(const HString& string)
+		:mString(string)
+	{ }
+
+	void ScriptHString::initMetaData()
+	{
+		metaData = ScriptMeta("MBansheeEngine", "BansheeEngine", "HString", &ScriptHString::initRuntimeData);
+
+		MonoManager::registerScriptType(&metaData);
+	}
+
+	void ScriptHString::initRuntimeData()
+	{
+		metaData.scriptClass->addInternalCall("Internal_CreateInstance", &ScriptHString::internal_createInstance);
+		metaData.scriptClass->addInternalCall("Internal_DestroyInstance", &ScriptHString::internal_destroyInstance);
+		metaData.scriptClass->addInternalCall("Internal_SetParameter", &ScriptHString::internal_setParameter);
+	}
+
+	void ScriptHString::internal_createInstance(MonoObject* instance, MonoString* identifier)
+	{
+		HString string(MonoUtil::monoToWString(identifier));
+
+		ScriptHString* nativeInstance = new (cm_alloc<ScriptHString>()) ScriptHString(string);
+		nativeInstance->createInstance(instance);
+
+		metaData.thisPtrField->setValue(instance, nativeInstance);
+	}
+
+	void ScriptHString::internal_destroyInstance(ScriptHString* nativeInstance)
+	{
+		nativeInstance->destroyInstance();
+		cm_delete(nativeInstance);
+	}
+
+	void ScriptHString::internal_setParameter(HString* nativeInstance, UINT32 idx, MonoString* value)
+	{
+		nativeInstance->setParameter(idx, MonoUtil::monoToWString(value));
+	}
+}

+ 55 - 0
SBansheeEngine/Source/BsScriptStringTable.cpp

@@ -0,0 +1,55 @@
+#include "BsScriptStringTable.h"
+#include "BsScriptMeta.h"
+#include "BsMonoField.h"
+#include "BsMonoClass.h"
+#include "BsMonoManager.h"
+#include "BsMonoUtil.h"
+
+using namespace CamelotFramework;
+
+namespace BansheeEngine
+{
+	void ScriptStringTable::initMetaData()
+	{
+		metaData = ScriptMeta("MBansheeEngine", "BansheeEngine", "StringTable", &ScriptStringTable::initRuntimeData);
+
+		MonoManager::registerScriptType(&metaData);
+	}
+	void ScriptStringTable::initRuntimeData()
+	{
+		metaData.scriptClass->addInternalCall("Internal_GetActiveLanguage", &ScriptStringTable::internal_GetActiveLanguage);
+		metaData.scriptClass->addInternalCall("Internal_SetActiveLanguage", &ScriptStringTable::internal_SetActiveLanguage);
+
+		metaData.scriptClass->addInternalCall("Internal_SetString", &ScriptStringTable::internal_SetString);
+		metaData.scriptClass->addInternalCall("Internal_RemoveString", &ScriptStringTable::internal_RemoveString);
+		metaData.scriptClass->addInternalCall("Internal_GetLocalizedString", &ScriptStringTable::internal_GetLocalizedString);
+	}
+
+	void ScriptStringTable::internal_GetActiveLanguage(CM::Language* value)
+	{
+		*value = StringTable::instance().getActiveLanguage();
+	}
+
+	void ScriptStringTable::internal_SetActiveLanguage(CM::Language value)
+	{
+		StringTable::instance().setActiveLanguage(value);
+	}
+
+	void ScriptStringTable::internal_SetString(MonoString* identifier, CM::Language language, MonoString* value)
+	{
+		StringTable::instance().setString(MonoUtil::monoToWString(identifier), language, MonoUtil::monoToWString(value));
+	}
+
+	void ScriptStringTable::internal_RemoveString(MonoString* identifier)
+	{
+		StringTable::instance().removeString(MonoUtil::monoToWString(identifier));
+	}
+
+	void ScriptStringTable::internal_GetLocalizedString(MonoString* identifier, MonoString** value)
+	{
+		CM::HString stringHandle(MonoUtil::monoToWString(identifier));
+		WString outString = stringHandle;
+
+		*value = MonoUtil::wstringToMono(MonoManager::instance().getDomain(), outString);
+	}
+}

+ 35 - 0
SpriteTexture.txt

@@ -0,0 +1,35 @@
+Completely worked out how to deal with texture animation and sprite textures:
+
+TextureMovie - derives from Texture
+ - isAnimated() - returns true
+ - getFrames - decodes all frames and returns them as individual textures. Make a note that this is an extremely slow process. For normals textures it just returns self.
+    - I will need this when providing a texture to SpriteGenerator among other things, so it may extract frames an generate an atlas (although I don't expect this will be 
+	  needed for actual movies, I want to keep the functionality the same for all textures)
+ - getBindableTexture() - texture used by RenderSystem. Normal textures just return self, while animated textures return the current frame
+ - DOES NOT support sprites (i.e. multiple textures from a single atlas, only multiple separate textures)
+ - TextureMovieTheora decodes textures on the fly
+ - TextureMovieRaw is created from a bunch of normal textures (using some utility method)
+ - play/stop/rewind/setSpeed/move(+/- frameCount)
+
+SpriteTexture
+ - Inherits from Resource
+ - Replace all references to it using shared_ptr with handles
+ - How do I create it?
+   - From native code allow a constructor that accepts a single texture (no atlas)
+   - And another constructor that accepts an uv an atlas
+ - Can contain sprite animation
+   - Some constructors accept a list of uvs, list of pages (referencing an atlas), a list of atlases and FPS
+    - (Need multiple atlases as some animations might be lengthty)
+   - Will have play/stop/rewind/getTime()/etc. methods
+ - It is up to the renderer to use animation data.
+   - GUIManager will be modified so use animation data if it exists
+ - For use in Scene I may add a special SpriteRenderer that uses certain logic and a certain material which supports sprite animation
+
+SpriteGenerator
+  - generateAtlas: Accepts a list of textures and outputs a list of SpriteTextures and a texture atlas
+  - generateSpriteAnimation: Accepts a list of textures, and generates a single SpriteTexture with a set of UVs and FPS
+  - All of them must be manually saved using Resources::create if they are to persist
+
+
+TODO - How to handle animating uvs?
+ - Things using animated textures will need to manually set the uvs every frame?