diff options
author | chai <chaifix@163.com> | 2021-11-03 18:52:30 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-11-03 18:52:30 +0800 |
commit | 08ddd44b634d4da78edd0964f539a310544c7883 (patch) | |
tree | 108317d9138c3e8a19f3cc3f2ffcfba4768f22d5 /Runtime/Scripting | |
parent | 6f62a3d5ad405dbab5ac031fb8eeb03bdb395904 (diff) |
! UI9Slicing
Diffstat (limited to 'Runtime/Scripting')
-rw-r--r-- | Runtime/Scripting/GUI/Font.bind.cpp | 4 | ||||
-rw-r--r-- | Runtime/Scripting/Rendering/Rendering.bind.cpp | 20 | ||||
-rw-r--r-- | Runtime/Scripting/Resource/Resource.bind.cpp | 21 |
3 files changed, 41 insertions, 4 deletions
diff --git a/Runtime/Scripting/GUI/Font.bind.cpp b/Runtime/Scripting/GUI/Font.bind.cpp index 2d01925..7172027 100644 --- a/Runtime/Scripting/GUI/Font.bind.cpp +++ b/Runtime/Scripting/GUI/Font.bind.cpp @@ -7,10 +7,10 @@ #include "Runtime/Utilities/StaticInitiator.h"
#include "Runtime/GUI/UITextMesh.h"
-static std::vector<character::Codepoint>* s_Codepoints;
+static std::vector<character::Unicode>* s_Codepoints;
InitializeStaticVariables([](){
- s_Codepoints = new std::vector<character::Codepoint>();
+ s_Codepoints = new std::vector<character::Unicode>();
});
LUA_BIND_REGISTRY(Font) diff --git a/Runtime/Scripting/Rendering/Rendering.bind.cpp b/Runtime/Scripting/Rendering/Rendering.bind.cpp index 0b00fa3..c9332f8 100644 --- a/Runtime/Scripting/Rendering/Rendering.bind.cpp +++ b/Runtime/Scripting/Rendering/Rendering.bind.cpp @@ -3,6 +3,7 @@ #include "Runtime/Graphics/ImageData.h" #include "Runtime/Graphics/GfxDevice.h" #include "Runtime/GUI/UIQuad.h" +#include "Runtime/GUI/UI9Slicing.h" // Rendering.DrawUIQuad({}) static int DrawUIQuad(lua_State* L) @@ -20,8 +21,27 @@ static int ResetUniformState(lua_State* L) return 0; } +// mode, horizontal, vertical, texSize, quadSize +static int DrawUI9Slicing(lua_State* L) +{ + LUA_BIND_STATE(L); + + int mode = state.GetValue<int>(1, ESlicing::Slicing_Simple); + Vector2 horizontal = state.GetValue<Vector2>(2, Vector2::zero); + Vector2 vertical = state.GetValue<Vector2>(3, Vector2::zero); + Vector2 texSize = state.GetValue<Vector2>(4, Vector2::zero); + Vector2 quadSize = state.GetValue<Vector2>(5, Vector2::zero); + + UI9Slicing slicing = UI9Slicing(mode, horizontal, vertical, texSize, quadSize); + + slicing.Draw(); + + return 0; +} + static luaL_Reg funcs[] = { {"DrawUIQuad", DrawUIQuad}, + {"DrawUI9Slicing", DrawUI9Slicing}, {"ResetUniformState", ResetUniformState}, {0, 0} }; diff --git a/Runtime/Scripting/Resource/Resource.bind.cpp b/Runtime/Scripting/Resource/Resource.bind.cpp index a09460e..a10ed69 100644 --- a/Runtime/Scripting/Resource/Resource.bind.cpp +++ b/Runtime/Scripting/Resource/Resource.bind.cpp @@ -32,8 +32,25 @@ int LoadImageData(lua_State* L) ImageData* data = new ImageData(state.GetVM()); int channels; data->pixels = stbi_load(path, &data->width, &data->height, &channels, 0); - data->format = EPixelFormat::PixelFormat_RGB; - data->type = EPixelElementType::PixelType_UNSIGNED_BYTE; + if (channels == 1) + { + data->format = EPixelFormat::PixelFormat_R; + data->type = EPixelElementType::PixelType_UNSIGNED_BYTE; + } + else if (channels == 3) + { + data->format = EPixelFormat::PixelFormat_RGB; + data->type = EPixelElementType::PixelType_UNSIGNED_BYTE; + } + else if(channels == 4) + { + data->format = EPixelFormat::PixelFormat_RGBA; + data->type = EPixelElementType::PixelType_UNSIGNED_BYTE; + } + else + { + Assert(false); // 暂时不支持其他格式 + } data->PushUserdata(state); return 1; |