mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-12 11:12:29 +00:00
feat(ui): implement SetBackdropColor/SetBackdropBorderColor script methods
This commit is contained in:
parent
1ad95653c7
commit
a9bb4ccdce
1 changed files with 60 additions and 2 deletions
|
|
@ -2,12 +2,50 @@
|
||||||
#include "gx/Coordinate.hpp"
|
#include "gx/Coordinate.hpp"
|
||||||
#include "ui/CSimpleFrame.hpp"
|
#include "ui/CSimpleFrame.hpp"
|
||||||
#include "ui/FrameScript.hpp"
|
#include "ui/FrameScript.hpp"
|
||||||
|
#include "ui/CBackdropGenerator.hpp"
|
||||||
#include "util/Lua.hpp"
|
#include "util/Lua.hpp"
|
||||||
#include "util/Unimplemented.hpp"
|
#include "util/Unimplemented.hpp"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
static int32_t sub_960420(lua_State* L, int idx, CImVector& color) {
|
||||||
|
auto red = lua_tonumber(L, idx++);
|
||||||
|
if (red < 0.0) {
|
||||||
|
red = 0.0;
|
||||||
|
}
|
||||||
|
if (red >= 1.0) {
|
||||||
|
red = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto green = lua_tonumber(L, idx++);
|
||||||
|
if (green < 0.0) {
|
||||||
|
green = 0.0;
|
||||||
|
}
|
||||||
|
if (green >= 1.0) {
|
||||||
|
green = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto blue = lua_tonumber(L, idx++);
|
||||||
|
if (blue < 0.0) {
|
||||||
|
blue = 0.0;
|
||||||
|
}
|
||||||
|
if (blue >= 1.0) {
|
||||||
|
blue = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto alpha = lua_isnumber(L, idx) ? lua_tonumber(L, idx++) : 1.0;
|
||||||
|
if (alpha < 0.0) {
|
||||||
|
alpha = 0.0;
|
||||||
|
}
|
||||||
|
if (alpha >= 1.0) {
|
||||||
|
alpha = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
color.Set(alpha, red, green, blue);
|
||||||
|
return idx;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t CSimpleFrame_GetTitleRegion(lua_State* L) {
|
int32_t CSimpleFrame_GetTitleRegion(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
WHOA_UNIMPLEMENTED(0);
|
||||||
}
|
}
|
||||||
|
|
@ -460,7 +498,17 @@ int32_t CSimpleFrame_GetBackdropColor(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleFrame_SetBackdropColor(lua_State* L) {
|
int32_t CSimpleFrame_SetBackdropColor(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
int32_t type = CSimpleFrame::GetObjectType();
|
||||||
|
CSimpleFrame* object = static_cast<CSimpleFrame*>(FrameScript_GetObjectThis(L, type));
|
||||||
|
|
||||||
|
CImVector color;
|
||||||
|
sub_960420(L, 2, color);
|
||||||
|
|
||||||
|
if (object->m_backdrop) {
|
||||||
|
object->m_backdrop->SetVertexColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleFrame_GetBackdropBorderColor(lua_State* L) {
|
int32_t CSimpleFrame_GetBackdropBorderColor(lua_State* L) {
|
||||||
|
|
@ -468,7 +516,17 @@ int32_t CSimpleFrame_GetBackdropBorderColor(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleFrame_SetBackdropBorderColor(lua_State* L) {
|
int32_t CSimpleFrame_SetBackdropBorderColor(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
int32_t type = CSimpleFrame::GetObjectType();
|
||||||
|
CSimpleFrame* object = static_cast<CSimpleFrame*>(FrameScript_GetObjectThis(L, type));
|
||||||
|
|
||||||
|
CImVector color;
|
||||||
|
sub_960420(L, 2, color);
|
||||||
|
|
||||||
|
if (object->m_backdrop) {
|
||||||
|
object->m_backdrop->SetBorderVertexColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleFrame_SetDepth(lua_State* L) {
|
int32_t CSimpleFrame_SetDepth(lua_State* L) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue