From 74ca8143a7c2352425d549b681b2838bda5ee218 Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 20 Nov 2021 14:10:24 +0800 Subject: *misc --- Editor/Scripting/GUI/EditorGUI.bind.cpp | 78 --------------------------------- 1 file changed, 78 deletions(-) (limited to 'Editor/Scripting/GUI/EditorGUI.bind.cpp') diff --git a/Editor/Scripting/GUI/EditorGUI.bind.cpp b/Editor/Scripting/GUI/EditorGUI.bind.cpp index e0b94e0..e4ba24e 100644 --- a/Editor/Scripting/GUI/EditorGUI.bind.cpp +++ b/Editor/Scripting/GUI/EditorGUI.bind.cpp @@ -13,82 +13,6 @@ #include "Editor/Win/Win.h" using namespace LuaBind; -using namespace Win; - -static std::vector* s_Codepoints; - -InitializeStaticVariables([]() { - s_Codepoints = new std::vector(); -}); - -// 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(1); - char* buf = (char*)state.GetValue(2, ""); - int pixelSize = state.GetValue(3, 12); - int lineHeight = state.GetValue(4, pixelSize + 3); - Color32 color = state.GetValue(5, Color32::white); - int anchor = state.GetValue(6, TextAnchor_UpperLeft); - int alignment = state.GetValue(7, TextAlignment_Left); - bool wordwrap = state.GetValue(8, false); - int preferred = state.GetValue(9, 0); - int encoding = state.GetValue(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(); - - WipeGLError(); - - return 0; -} - -static luaL_Reg guiFuncs[] = { - {"Text", Text}, - {0, 0} -}; int luaopen_GameLab_Editor_GUI(lua_State* L) { @@ -101,7 +25,5 @@ int luaopen_GameLab_Editor_GUI(lua_State* L) state.PushNamespace("Editor"); state.PushNamespace("GUI"); - state.RegisterMethods(guiFuncs); - return 1; } \ No newline at end of file -- cgit v1.1-26-g67d0