diff options
author | chai <chaifix@163.com> | 2021-11-05 14:25:39 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-11-05 14:25:39 +0800 |
commit | 2b9621a46288532b352b7838f96aca80f971e3d1 (patch) | |
tree | 6131ef5484e4f6d4c14c541b65a107869e3b112e | |
parent | 6d5787d8da9ad1685864668dd4c3d6aa73a563db (diff) |
*misc
-rw-r--r-- | Data/Libraries/GameLab/Editor/EditorWindow.lua | 5 | ||||
-rw-r--r-- | Data/Libraries/GameLab/Editor/GUI/Functions.lua | 0 | ||||
-rw-r--r-- | Data/Libraries/GameLab/Editor/GUI/init.lua | 2 | ||||
-rw-r--r-- | Data/Scripts/Editor/AssetBrowser.lua | 9 | ||||
-rw-r--r-- | Data/Scripts/EditorApplication.lua | 17 | ||||
-rw-r--r-- | Editor/GUI/EditorWindows.h | 6 | ||||
-rw-r--r-- | Editor/Scripting/EditorGUI/EditorGUI.bind.cpp | 86 | ||||
-rw-r--r-- | Projects/VisualStudio/Editor/Editor.vcxproj.filters | 18 | ||||
-rw-r--r-- | Runtime/GUI/Font.h | 2 | ||||
-rw-r--r-- | Runtime/GUI/UITextMesh.cpp | 1 | ||||
-rw-r--r-- | Runtime/GUI/UITextMesh.h | 12 | ||||
-rw-r--r-- | Runtime/Graphics/VertexBuffer.cpp | 1 | ||||
-rw-r--r-- | Runtime/Lua/LuaHelper.cpp | 41 | ||||
-rw-r--r-- | Runtime/Scripting/GUI/Font.bind.cpp | 91 |
14 files changed, 155 insertions, 136 deletions
diff --git a/Data/Libraries/GameLab/Editor/EditorWindow.lua b/Data/Libraries/GameLab/Editor/EditorWindow.lua index af79771..0122b2c 100644 --- a/Data/Libraries/GameLab/Editor/EditorWindow.lua +++ b/Data/Libraries/GameLab/Editor/EditorWindow.lua @@ -1,3 +1,8 @@ +-- EditorWindow是应用级别的逻辑窗口 +-- ContainerWindow +-- |- GUIWindow +-- |- EditorWindow + local EditorWindow = GameLab.Class("GameLab.Editor.EditorWindow") EditorWindow.Ctor = function(self, title) diff --git a/Data/Libraries/GameLab/Editor/GUI/Functions.lua b/Data/Libraries/GameLab/Editor/GUI/Functions.lua deleted file mode 100644 index e69de29..0000000 --- a/Data/Libraries/GameLab/Editor/GUI/Functions.lua +++ /dev/null diff --git a/Data/Libraries/GameLab/Editor/GUI/init.lua b/Data/Libraries/GameLab/Editor/GUI/init.lua index a1ccb7c..8e9b899 100644 --- a/Data/Libraries/GameLab/Editor/GUI/init.lua +++ b/Data/Libraries/GameLab/Editor/GUI/init.lua @@ -3,6 +3,4 @@ local m = GameLab.Editor.GUI local import = GameLab.import(...)
-import("Functions")
-
return m
\ No newline at end of file diff --git a/Data/Scripts/Editor/AssetBrowser.lua b/Data/Scripts/Editor/AssetBrowser.lua index d975934..42f4d71 100644 --- a/Data/Scripts/Editor/AssetBrowser.lua +++ b/Data/Scripts/Editor/AssetBrowser.lua @@ -3,6 +3,7 @@ local AssetBrowser = GameLab.Editor.EditorWindow.Extend("GameLab.Editor.AssetBro local GL = GameLab.Engine.GL
local Matrix44 = GameLab.Engine.Math.Matrix44
local Engine = GameLab.Engine
+local Editor = GameLab.Editor
local IO = GameLab.IO
local inspect = require("inspect")
@@ -38,12 +39,12 @@ AssetBrowser.OnGUI = function(self) Engine.Rendering.SetVector2("gamelab_ui_position", {0, 0})
--Engine.Rendering.SetTexture("gamelab_main_tex", tex)
--Engine.Rendering.DrawUIQuad({0, 0, 200, 200})
- _G["default_font"]:GetCharacters("你好世界!\nHello,World!\nProject Window Properties", 12)
+ Editor.GUI.Text(_G["default_font"], "你好世界!\nHello,World!\nProject Window Properties", 12)
- Engine.Rendering.SetVector2("gamelab_ui_position", {0, 100})
- _G["default_font"]:GetCharacters("结构体A中包含了4字节长度的int一个", 12)
+ -- Engine.Rendering.SetVector2("gamelab_ui_position", {0, 100})
+ -- Editor.GUI.Text(_G["default_font"], "你好世界!\nHello,World!\nProject Window Properties", 12)
- --Engine.Rendering.DrawUI9Slicing(1, {25, 25}, {25, 25}, {80, 80}, {400, 50} )
+ --Engine.Rendering.DrawUI9Slicing(1, {25, 25}, {25, 25}, {80, 80}, {400, 30} )
end
AssetBrowser.OnFocus = function(self)
diff --git a/Data/Scripts/EditorApplication.lua b/Data/Scripts/EditorApplication.lua index 535136b..0576994 100644 --- a/Data/Scripts/EditorApplication.lua +++ b/Data/Scripts/EditorApplication.lua @@ -29,23 +29,12 @@ guiWindow:SetPosition({0,0, 400, 400}) collectgarbage() -Debug.Log(GameLab.Path.GetRootDirectory()) - -Debug.Log(inspect{foo=1,2,3,4}) - local wnd = AssetBrowser.New() -Debug.Log(inspect(mainWindow._type)) guiWindow:SetInstance(wnd) local v = GameLab.Engine.Math.Vector4.New(1,2,3,4) -Debug.Log(inspect(v)) - -Debug.Log(EditorWindowManager.name) local c = Engine.Rendering.Color.New(1,1,1,1) -Debug.Log(inspect(c)) - -Debug.Log(inspect(GL.EBufferType)) GL.ClearColor({1,1,1,1}) GL.Clear(GL.EBufferType.ColorBuffer) @@ -62,13 +51,7 @@ local files = { "README.txt", } -GameLab.IO.ReadFilesAsync(files, function() - Debug.Log("finished") -end) - local imgData = Engine.Resource.LoadImageData("./Resources/Images/brickwall.jpg") -Debug.Log(tostring(imgData:GetWidth())) -Debug.Log(tostring(imgData:GetHeight())) local tex = Engine.Resource.LoadTexture("./Resources/Images/brickwall.jpg") diff --git a/Editor/GUI/EditorWindows.h b/Editor/GUI/EditorWindows.h index 78d9ca8..a8c96ad 100644 --- a/Editor/GUI/EditorWindows.h +++ b/Editor/GUI/EditorWindows.h @@ -153,6 +153,8 @@ private: void ProcessEventMessages(UINT message, WPARAM wParam, LPARAM lParam); bool SetRenderContext(); + //----------------------------------------------------------------- + std::string m_Name; ContainerWindow* m_ContainerWindow; @@ -160,9 +162,11 @@ private: HDC m_DC; std::vector<LuaBind::MemberRef> m_EditorWindows; - + LuaBind::MemberRef m_EditorWindow; // EditorWindowű LuaBind::MemberRef m_Script; // EditorWindowű + //----------------------------------------------------------------- + LUA_BIND_DECL_CLASS(GUIWindow); LUA_BIND_DECL_METHOD(_New); diff --git a/Editor/Scripting/EditorGUI/EditorGUI.bind.cpp b/Editor/Scripting/EditorGUI/EditorGUI.bind.cpp index dc7b88c..bd21f7d 100644 --- a/Editor/Scripting/EditorGUI/EditorGUI.bind.cpp +++ b/Editor/Scripting/EditorGUI/EditorGUI.bind.cpp @@ -1,4 +1,88 @@ #include "Editor/GUI/EditorWindows.h" +#include "Runtime/GUI/Font.h"
+#include "Runtime/Graphics/Shader.h" +#include "Runtime/Debug/Log.h" +#include "Runtime/Graphics/GfxDevice.h" +#include "Runtime/Common/DataBuffer.h"
+#include "Runtime/GUI/utf8.h"
+#include "Runtime/Utilities/StaticInitiator.h"
+#include "Runtime/GUI/UITextMesh.h"
+#include "Runtime/Math/Math.h" +#include "Runtime/GUI/TextMeshGenerator.h" +#include "Runtime/Utilities/AutoInvoke.h" +
+static std::vector<character::Unicode>* s_Codepoints;
+
+InitializeStaticVariables([]() {
+ s_Codepoints = new std::vector<character::Unicode>();
+}); + +// Editor.GUI.Text(font, str, pixelSize, lineHeight, color, anchor, alignment, wordwrap, preferred, encoding) +static int Text(lua_State* L) +{ + LUA_BIND_STATE(L); +
+ Font* font = (Font*)state.GetUserdata<Font>(1);
+ char* buf = (char*)state.GetValue<const char*>(2, "");
+ int pixelSize = state.GetValue<int>(3, 12);
+ int lineHeight = state.GetValue<int>(4, pixelSize + 3);
+ Color32 color = state.GetValue<Color32>(5, Color32::white);
+ int anchor = state.GetValue<int>(6, TextAnchor_UpperLeft);
+ int alignment = state.GetValue<int>(7, TextAlignment_Left);
+ bool wordwrap = state.GetValue<bool>(8, false);
+ int preferred = state.GetValue<int>(9, 0);
+ int encoding = state.GetValue<int>(10, EEncoding::Encoding_UTF8);
+
+ s_Codepoints->clear();
+ InvokeWhenLeave([]() {
+ s_Codepoints->clear();
+ });
+
+ if (encoding == EEncoding::Encoding_UTF8)
+ {
+ while (*buf != 0) {
+ int err;
+ s_Codepoints->push_back(utf8::getu8c(&buf, &err));
+ if (err != 0)
+ {
+ log_warning("Illegal utf8 bytes %d", err);
+ }
+ }
+ }
+ else if (encoding == EEncoding::Encoding_UTF16)
+ {
+ while (*buf != 0) {
+ unsigned short* s = (unsigned short*)(buf);
+ s_Codepoints->push_back(*s);
+ buf += 2;
+ }
+ }
+ else if (encoding == EEncoding::Encoding_ASCII)
+ {
+ while (*buf != 0) {
+ s_Codepoints->push_back(*buf);
+ buf += 1;
+ }
+ }
+
+ font->RenderCharacters(*s_Codepoints, pixelSize);
+
+ UnicodeString str;
+ str.str = s_Codepoints->data();
+ str.length = s_Codepoints->size();
+
+ WipeGLError();
+
+ const UITextMesh* tm = g_TextMeshGenerator.GetTextMesh(str, font, pixelSize, lineHeight, color, (ETextAnchor)anchor, (ETextAlignment)alignment, wordwrap, preferred);
+ tm->Draw();
+
+ return 0; +} + +static luaL_Reg guiFuncs[] = { + {"Text", Text}, + {0, 0} +}; // GameLab.Editor.GUI int luaopen_GameLab_Editor_GUI(lua_State* L) @@ -15,5 +99,7 @@ int luaopen_GameLab_Editor_GUI(lua_State* L) state.RegisterNativeClass<ContainerWindow>(); state.RegisterNativeClass<GUIWindow>(); + state.RegisterMethods(guiFuncs); + return 1; }
\ No newline at end of file diff --git a/Projects/VisualStudio/Editor/Editor.vcxproj.filters b/Projects/VisualStudio/Editor/Editor.vcxproj.filters index 3f940a7..c7de4d1 100644 --- a/Projects/VisualStudio/Editor/Editor.vcxproj.filters +++ b/Projects/VisualStudio/Editor/Editor.vcxproj.filters @@ -28,9 +28,6 @@ <Filter Include="Editor\Resource">
<UniqueIdentifier>{5b8dba28-42d0-450a-98e1-ca4a65a4fc76}</UniqueIdentifier>
</Filter>
- <Filter Include="Editor\Scripting\EditorGUI">
- <UniqueIdentifier>{848489fc-f661-4b10-91f5-db1687293b95}</UniqueIdentifier>
- </Filter>
<Filter Include="Editor\Scripting\EditorGUILayout">
<UniqueIdentifier>{87edd159-c171-4ccb-9094-9e5061c980d0}</UniqueIdentifier>
</Filter>
@@ -118,6 +115,9 @@ <Filter Include="Runtime\Scripting\GUI">
<UniqueIdentifier>{f209c361-c009-43ac-9e02-aa06804da376}</UniqueIdentifier>
</Filter>
+ <Filter Include="Editor\Scripting\GUI">
+ <UniqueIdentifier>{848489fc-f661-4b10-91f5-db1687293b95}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\Editor\GUI\Dock.cpp">
@@ -160,19 +160,19 @@ <Filter>Editor\Resource</Filter>
</ClCompile>
<ClCompile Include="..\..\..\Editor\Scripting\EditorGUI\EditorGUI.bind.cpp">
- <Filter>Editor\Scripting\EditorGUI</Filter>
+ <Filter>Editor\Scripting\GUI</Filter>
</ClCompile>
<ClCompile Include="..\..\..\Editor\Scripting\EditorScripting.cpp">
<Filter>Editor\Scripting</Filter>
</ClCompile>
<ClCompile Include="..\..\..\Editor\Scripting\EditorGUI\ContainerWindow.bind.cpp">
- <Filter>Editor\Scripting\EditorGUI</Filter>
+ <Filter>Editor\Scripting\GUI</Filter>
</ClCompile>
<ClCompile Include="..\..\..\Editor\Scripting\EditorGUI\GUIWindow.bind.cpp">
- <Filter>Editor\Scripting\EditorGUI</Filter>
+ <Filter>Editor\Scripting\GUI</Filter>
</ClCompile>
<ClCompile Include="..\..\..\Editor\Scripting\EditorGUI\SplitWindow.bind.cpp">
- <Filter>Editor\Scripting\EditorGUI</Filter>
+ <Filter>Editor\Scripting\GUI</Filter>
</ClCompile>
<ClCompile Include="..\..\..\Editor\Scripting\IMGUI\GUIButton.bind.cpp">
<Filter>Editor\Scripting\IMGUI</Filter>
@@ -405,7 +405,9 @@ <ClCompile Include="..\..\..\Runtime\GUI\UIMesh.cpp">
<Filter>Runtime\GUI</Filter>
</ClCompile>
- <ClCompile Include="..\..\..\Runtime\Graphics\Color.cpp" />
+ <ClCompile Include="..\..\..\Runtime\Graphics\Color.cpp">
+ <Filter>Runtime\Graphics</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\Editor\GUI\Dock.h">
diff --git a/Runtime/GUI/Font.h b/Runtime/GUI/Font.h index 565fafc..df0bc7b 100644 --- a/Runtime/GUI/Font.h +++ b/Runtime/GUI/Font.h @@ -36,7 +36,7 @@ namespace character Unicode codepoint; unsigned short size;//С }; -#pragma pack() +#pragma pack(pop) bool operator==(const Hash &other) const { diff --git a/Runtime/GUI/UITextMesh.cpp b/Runtime/GUI/UITextMesh.cpp index 23c0a9c..aeaee38 100644 --- a/Runtime/GUI/UITextMesh.cpp +++ b/Runtime/GUI/UITextMesh.cpp @@ -33,7 +33,6 @@ struct TextInfo { int line; // 0ʼ }; - InitializeStaticVariables([]() { VertexAttributeDescriptor POSITION = VertexAttributeDescriptor(0, 2, VertexAttrFormat_Float, sizeof(TextMeshVBOLayout)); VertexAttributeDescriptor UV = VertexAttributeDescriptor(sizeof(Vector2), 2, VertexAttrFormat_Float, sizeof(TextMeshVBOLayout)); diff --git a/Runtime/GUI/UITextMesh.h b/Runtime/GUI/UITextMesh.h index 505b390..ea543f3 100644 --- a/Runtime/GUI/UITextMesh.h +++ b/Runtime/GUI/UITextMesh.h @@ -36,6 +36,12 @@ class UITextMesh public: void Draw() const; +private: + friend class TextMeshGenerator; + + UITextMesh(const UnicodeString& str, Font* font, int pixelSize, int lineHeight, Color32 color32 = Color32::white, ETextAnchor anchor = TextAnchor_UpperLeft, ETextAlignment alignment = TextAlignment_Left, bool wordwrap = false, float preferred = 0)/*throw TextMeshException*/; + ~UITextMesh(); + GET(const Font*, Font, m_Font); GET(int, PixelSize, m_PixelSize); GET(int, LineHeight, m_LineHeight); @@ -46,12 +52,6 @@ public: GET(float, Preferred, m_Preferred); GET(const UnicodeString&, Content, m_Content); -private: - friend class TextMeshGenerator; - - UITextMesh(const UnicodeString& str, Font* font, int pixelSize, int lineHeight, Color32 color32 = Color32::white, ETextAnchor anchor = TextAnchor_UpperLeft, ETextAlignment alignment = TextAlignment_Left, bool wordwrap = false, float preferred = 0)/*throw TextMeshException*/; - ~UITextMesh(); - std::unordered_map<int, VertexBuffer*> m_VBOs; Font* m_Font; diff --git a/Runtime/Graphics/VertexBuffer.cpp b/Runtime/Graphics/VertexBuffer.cpp index 8973275..29ecc57 100644 --- a/Runtime/Graphics/VertexBuffer.cpp +++ b/Runtime/Graphics/VertexBuffer.cpp @@ -47,7 +47,6 @@ void VertexBuffer::FlushChunk(int actualVerts, int actualIndices) m_VB->FlushMapedRange(0, actualVBufferSize); m_IB->FlushMapedRange(0, actualIBufferSize); - // һҪunmap m_VB->UnMap(); m_IB->UnMap(); diff --git a/Runtime/Lua/LuaHelper.cpp b/Runtime/Lua/LuaHelper.cpp index 951f2fe..f1dc349 100644 --- a/Runtime/Lua/LuaHelper.cpp +++ b/Runtime/Lua/LuaHelper.cpp @@ -2,6 +2,7 @@ #include "Runtime/Math/Math.h" #include "Runtime/GUI/Font.h"
+#include "Runtime/Graphics/Color.h"
using namespace LuaBind;
@@ -16,7 +17,7 @@ Rect State::GetValue < Rect >(int idx, const Rect value) rect.width = GetField<float>(idx, "z", 0);
rect.height = GetField<float>(idx, "w", 0);
}
- else
+ else if (LuaHelper::IsType(*this, "table", idx))
{
rect.x = GetField<float>(idx, 1, 0);
rect.y = GetField<float>(idx, 2, 0);
@@ -35,7 +36,7 @@ Vector2 State::GetValue < Vector2 >(int idx, const Vector2 value) v2.x = GetField<float>(idx, "x", 0);
v2.y = GetField<float>(idx, "y", 0);
}
- else
+ else if (LuaHelper::IsType(*this, "table", idx))
{
v2.x = GetField<float>(idx, 1, 0);
v2.y = GetField<float>(idx, 2, 0);
@@ -53,7 +54,7 @@ Vector3 State::GetValue < Vector3 >(int idx, const Vector3 value) v3.y = GetField<float>(idx, "y", 0);
v3.z = GetField<float>(idx, "z", 0);
}
- else
+ else if (LuaHelper::IsType(*this, "table", idx))
{
v3.x = GetField<float>(idx, 1, 0);
v3.y = GetField<float>(idx, 2, 0);
@@ -73,7 +74,7 @@ Vector4 State::GetValue < Vector4 >(int idx, const Vector4 value) v4.z = GetField<float>(idx, "z", 0);
v4.w = GetField<float>(idx, "w", 0);
}
- else
+ else if (LuaHelper::IsType(*this, "table", idx))
{
v4.x = GetField<float>(idx, 1, 0);
v4.y = GetField<float>(idx, 2, 0);
@@ -84,6 +85,34 @@ Vector4 State::GetValue < Vector4 >(int idx, const Vector4 value) }
template <>
+Color32 State::GetValue < Color32 >(int idx, const Color32 value)
+{
+ Color32 col = value;
+ if (LuaHelper::IsType(*this, "GameLab.Engine.Rendering.Color", idx))
+ {
+ col.r = GetField<float>(idx, "r", 0) * 255.f;
+ col.g = GetField<float>(idx, "g", 0) * 255.f;
+ col.b = GetField<float>(idx, "b", 0) * 255.f;
+ col.a = GetField<float>(idx, "a", 0) * 255.f;
+ }
+ else if (LuaHelper::IsType(*this, "GameLab.Engine.Rendering.Color32", idx))
+ {
+ col.r = GetField<int>(idx, "r", 0);
+ col.g = GetField<int>(idx, "g", 0);
+ col.b = GetField<int>(idx, "b", 0);
+ col.a = GetField<int>(idx, "a", 0);
+ }
+ else if(LuaHelper::IsType(*this, "table", idx))
+ {
+ col.r = GetField<float>(idx, 1, 0);
+ col.g = GetField<float>(idx, 2, 0);
+ col.b = GetField<float>(idx, 3, 0);
+ col.a = GetField<float>(idx, 4, 0);
+ }
+ return col;
+}
+
+template <>
Matrix44 State::GetValue < Matrix44 >(int idx, const Matrix44 value)
{
Matrix44 m4 = value;
@@ -109,7 +138,7 @@ Matrix44 State::GetValue < Matrix44 >(int idx, const Matrix44 value) m4.m[3][2] = GetField<float>(idx, "m32", 0);
m4.m[3][3] = GetField<float>(idx, "m33", 0);
}
- else
+ else if (LuaHelper::IsType(*this, "table", idx))
{
m4.m[0][0] = GetField<float>(idx, 1, 0);
m4.m[0][1] = GetField<float>(idx, 2, 0);
@@ -159,6 +188,8 @@ bool LuaHelper::IsType(LuaBind::State& state, const char* typeName, int idx) {
int top = state.GetTop();
cc8* type = luaL_typename(state, idx);
+ if (strcmp(type, "nil") == 0 || strcmp(type, "no value") == 0)
+ return false;
if (strcmp(type, typeName) == 0)
return true;
state.GetField(idx, "_type");
diff --git a/Runtime/Scripting/GUI/Font.bind.cpp b/Runtime/Scripting/GUI/Font.bind.cpp index 0570df0..8759fe1 100644 --- a/Runtime/Scripting/GUI/Font.bind.cpp +++ b/Runtime/Scripting/GUI/Font.bind.cpp @@ -10,19 +10,10 @@ #include "Runtime/GUI/TextMeshGenerator.h" #include "Runtime/Utilities/AutoInvoke.h" -static std::vector<character::Unicode>* s_Codepoints;
-
-InitializeStaticVariables([](){
- s_Codepoints = new std::vector<character::Unicode>();
-});
-
LUA_BIND_REGISTRY(Font) { LUA_BIND_REGISTER_METHODS(state, - { "New", _New }, - { "GetCharacter", _GetCharacter }, - { "GetCharacters", _GetCharacters }, - { "GetGlyphAtlas", _GetGlyphAtlas } + { "New", _New } ); } @@ -83,83 +74,3 @@ LUA_BIND_IMPL_METHOD(Font, _New) return 1;
}
-
-// font:GetCharacter(char, size, encoding)
-LUA_BIND_IMPL_METHOD(Font, _GetCharacter) -{
- LUA_BIND_PREPARE(L, Font);
- return 1;
-}
-
-// font:GetCharacter(str, size, wordwrap, preferredWidth, encoding)
-LUA_BIND_IMPL_METHOD(Font, _GetCharacters) -{
- LUA_BIND_PREPARE(L, Font);
- //LUA_BIND_CHECK(L, "US");
-
- char* buf = (char*)state.GetValue<const char*>(2, "");
- int size = state.GetValue<int>(3, 12);
- bool wordwrap = state.GetValue<bool>(4, false);
- float preferred = state.GetValue<float>(5, 0);
- int encoding = state.GetValue<int>(6, EEncoding::Encoding_UTF8);
-
- s_Codepoints->clear();
- InvokeWhenLeave([]() {
- s_Codepoints->clear();
- });
-
- if (encoding == EEncoding::Encoding_UTF8)
- {
- while (*buf != 0) {
- int err;
- s_Codepoints->push_back(utf8::getu8c(&buf, &err));
- if (err != 0)
- {
- log_warning("Illegal utf8 bytes %d", err);
- }
- }
- }
- else if (encoding == EEncoding::Encoding_UTF16)
- {
- while (*buf != 0) {
- unsigned short* s = (unsigned short*)(buf);
- s_Codepoints->push_back(*s);
- buf += 2;
- }
- }
- else if (encoding == EEncoding::Encoding_ASCII)
- {
- while (*buf != 0) {
- s_Codepoints->push_back(*buf);
- buf += 1;
- }
- }
-
- self->RenderCharacters(*s_Codepoints, size);
-
- UnicodeString str;
- str.str = s_Codepoints->data();
- str.length = s_Codepoints->size();
-
- WipeGLError();
-
- const UITextMesh* tm = g_TextMeshGenerator.GetTextMesh(str, self, size, size + 3, Color32::white, TextAnchor_UpperLeft, TextAlignment_Left, wordwrap, preferred);
- tm->Draw();
-
- return 0;
-}
-
-// font:GetAtlas(i)
-// return lightuserdata
-LUA_BIND_IMPL_METHOD(Font, _GetGlyphAtlas) -{
- LUA_BIND_PREPARE(L, Font);
- //LUA_BIND_CHECK(L, "UN");
-
- //int i = state.GetValue<int>(2, 0);
- //GlyphAtals atlas = self->m_Atlases[i];
-
- //state.Push((const void*)atlas.altas);
-
- return 1;
-}
\ No newline at end of file |