From 452eceb3ba4bdbbc77786dc7f7235c03f1c62302 Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 15 Nov 2021 01:19:35 +0800 Subject: *class --- Editor/GUI/ContainerWindow.cpp | 32 +++---- Editor/Scripting/IMGUI/GUIButton.bind.cpp | 1 - Editor/Scripting/Window/EditorGUI.bind.cpp | 118 ----------------------- Editor/Scripting/Window/Window.bind.cpp | 148 +++++++++++++++++++++++++++++ 4 files changed, 164 insertions(+), 135 deletions(-) delete mode 100644 Editor/Scripting/IMGUI/GUIButton.bind.cpp delete mode 100644 Editor/Scripting/Window/EditorGUI.bind.cpp create mode 100644 Editor/Scripting/Window/Window.bind.cpp (limited to 'Editor') diff --git a/Editor/GUI/ContainerWindow.cpp b/Editor/GUI/ContainerWindow.cpp index f76ac73..7a71d14 100644 --- a/Editor/GUI/ContainerWindow.cpp +++ b/Editor/GUI/ContainerWindow.cpp @@ -43,22 +43,22 @@ LRESULT CALLBACK ContainerWindow::ContainerWndProc(HWND hWnd, UINT message, WPAR } case WM_SETICON: return WM_SETICON; - case WM_PAINT: - { - static PAINTSTRUCT ps; - self->SetAsRenderContext(); - - glEnable(GL_BLEND); - float c = 26 / 255.f; - glClearColor(c, c, c, 1); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glFlush(); - - BeginPaint(self->m_Window, &ps); - EndPaint(self->m_Window, &ps); - UpdateWindow(self->m_Window); - return 0; - } + //case WM_PAINT: + //{ + // static PAINTSTRUCT ps; + // self->SetAsRenderContext(); + + // glEnable(GL_BLEND); + // float c = 26 / 255.f; + // glClearColor(c, c, c, 1); + // glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + // glFlush(); + + // BeginPaint(self->m_Window, &ps); + // EndPaint(self->m_Window, &ps); + // UpdateWindow(self->m_Window); + // return 0; + //} case WM_ENTERMENULOOP: // µã»÷²Ëµ¥ return 0; diff --git a/Editor/Scripting/IMGUI/GUIButton.bind.cpp b/Editor/Scripting/IMGUI/GUIButton.bind.cpp deleted file mode 100644 index 8b13789..0000000 --- a/Editor/Scripting/IMGUI/GUIButton.bind.cpp +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Editor/Scripting/Window/EditorGUI.bind.cpp b/Editor/Scripting/Window/EditorGUI.bind.cpp deleted file mode 100644 index 838e752..0000000 --- a/Editor/Scripting/Window/EditorGUI.bind.cpp +++ /dev/null @@ -1,118 +0,0 @@ -#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" - -using namespace LuaBind; - -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(); - - return 0; -} - -static luaL_Reg guiFuncs[] = { - {"Text", Text}, - {0, 0} -}; - -// GameLab.Editor.Window -int luaopen_GameLab_Editor_Window(lua_State* L) -{ - log_info_tag("Scripting", "luaopen_GameLab_Editor_Window()"); - - LUA_BIND_STATE(L); - - state.PushGlobalNamespace(); - state.PushNamespace("GameLab"); - state.PushNamespace("Editor"); - state.PushNamespace("Window"); - - state.PushNamespace("Internal"); - state.RegisterNativeClass(); - state.RegisterNativeClass(); - state.PopNamespace(); - - LUA_BIND_REGISTER_ENUM(state, "EShowMode", - { "NormalWindow", ContainerWindow::kShowNormalWindow }, - { "ShowPopupMenu", ContainerWindow::kShowPopupMenu }, - { "Utility ", ContainerWindow::kShowUtility }, - { "NoShadow", ContainerWindow::kShowNoShadow }, - { "MainWindow", ContainerWindow::kShowMainWindow }, - { "AuxWindow", ContainerWindow::kShowAuxWindow } - ); - - state.RegisterMethods(guiFuncs); - - return 1; -} \ No newline at end of file diff --git a/Editor/Scripting/Window/Window.bind.cpp b/Editor/Scripting/Window/Window.bind.cpp new file mode 100644 index 0000000..b720c98 --- /dev/null +++ b/Editor/Scripting/Window/Window.bind.cpp @@ -0,0 +1,148 @@ +#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" +#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(); + + return 0; +} + +static int SetCursor(lua_State* L) +{ + LUA_BIND_STATE(L); + LUA_BIND_CHECK(state, "N"); + + int type = state.GetValue(state, 1); + Win::SetCursor((ECursor)type); + + return 0; +} + +static luaL_Reg guiFuncs[] = { + {"Text", Text}, + {"SetCursor", SetCursor}, + {0, 0} +}; + +// GameLab.Editor.Window +int luaopen_GameLab_Editor_Window(lua_State* L) +{ + log_info_tag("Scripting", "luaopen_GameLab_Editor_Window()"); + + LUA_BIND_STATE(L); + + state.PushGlobalNamespace(); + state.PushNamespace("GameLab"); + state.PushNamespace("Editor"); + state.PushNamespace("Window"); + + state.PushNamespace("Internal"); + state.RegisterNativeClass(); + state.RegisterNativeClass(); + state.PopNamespace(); + + LUA_BIND_REGISTER_ENUM(state, "EShowMode", + { "NormalWindow", ContainerWindow::kShowNormalWindow }, + { "ShowPopupMenu", ContainerWindow::kShowPopupMenu }, + { "Utility ", ContainerWindow::kShowUtility }, + { "NoShadow", ContainerWindow::kShowNoShadow }, + { "MainWindow", ContainerWindow::kShowMainWindow }, + { "AuxWindow", ContainerWindow::kShowAuxWindow } + ); + + LUA_BIND_REGISTER_ENUM(state, "ECursor", + { "AppStarting", Cursor_AppStarting }, + { "Arrow", Cursor_Arrow }, + { "Cross", Cursor_Cross }, + { "Help", Cursor_Help }, + { "IBeam", Cursor_IBeam }, + { "NO", Cursor_NO }, + { "SizeAll", Cursor_SizeAll }, + { "SizeNESW", Cursor_SizeNESW }, + { "SizeNS", Cursor_SizeNS }, + { "SizeNWSE", Cursor_SizeNWSE }, + { "SizeWE", Cursor_SizeWE }, + { "UpArrow", Cursor_UpArrow }, + { "Wait", Cursor_Wait } + ); + + state.RegisterMethods(guiFuncs); + + return 1; +} \ No newline at end of file -- cgit v1.1-26-g67d0