mirror of
https://github.com/whoahq/whoa.git
synced 2026-02-01 00:02:45 +03:00
feat(ui): implement CSimpleButton_SetDisabledFontObject
This commit is contained in:
parent
ec3fec5a93
commit
6bb419702f
@ -1,6 +1,7 @@
|
||||
#include "ui/CSimpleButtonScript.hpp"
|
||||
#include "gx/Coordinate.hpp"
|
||||
#include "ui/CSimpleButton.hpp"
|
||||
#include "ui/CSimpleFont.hpp"
|
||||
#include "ui/CSimpleFontString.hpp"
|
||||
#include "ui/CSimpleTexture.hpp"
|
||||
#include "util/Lua.hpp"
|
||||
@ -108,7 +109,28 @@ int32_t CSimpleButton_GetNormalFontObject(lua_State* L) {
|
||||
}
|
||||
|
||||
int32_t CSimpleButton_SetDisabledFontObject(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
auto type = CSimpleButton::GetObjectType();
|
||||
auto button = static_cast<CSimpleButton*>(FrameScript_GetObjectThis(L, type));
|
||||
|
||||
CSimpleFont* font = nullptr;
|
||||
|
||||
if (lua_type(L, 2) == LUA_TSTRING) {
|
||||
auto fontName = lua_tostring(L, 2);
|
||||
font = CSimpleFont::GetFont(fontName, 0);
|
||||
} else if (lua_type(L, 2) == LUA_TTABLE) {
|
||||
lua_rawgeti(L, 2, 0);
|
||||
font = static_cast<CSimpleFont*>(lua_touserdata(L, -1));
|
||||
lua_settop(L, -2);
|
||||
}
|
||||
|
||||
if (!button || !font || !font->IsA(CSimpleFont::GetObjectType())) {
|
||||
return luaL_error(L, "Usage: %s:SetDisabledFontObject(\"fontname\")", button->GetDisplayName());
|
||||
}
|
||||
|
||||
button->m_disabledFont = font;
|
||||
button->UpdateTextState(button->m_state);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t CSimpleButton_GetDisabledFontObject(lua_State* L) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user