Skip to content

Commit

Permalink
xrUICore/Static/UIStatic.h: moved some script specific functions to _…
Browse files Browse the repository at this point in the history
…script.cpp
  • Loading branch information
Xottab-DUTY committed Feb 9, 2024
1 parent 62b347d commit 5aec8e6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
16 changes: 0 additions & 16 deletions src/xrUICore/Static/UIStatic.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,6 @@ class XRUICORE_API CUIStatic : public CUIWindow, public ITextureOwner, public CU
TextItemControl()->SetTextColor(color);
}

void SetTextColor_script(int a, int r, int g, int b)
{
TextItemControl()->SetTextColor(color_argb(a, r, g, b));
}

u32 GetTextAlign_script()
{
return static_cast<u32>(TextItemControl()->GetTextAlignment());
}

void SetTextAlign_script(u32 align)
{
TextItemControl()->SetTextAlignment((CGameFont::EAligment)align);
TextItemControl()->GetFont()->SetAligment((CGameFont::EAligment)align);
}

virtual void SetTextX(float text_x) { TextItemControl()->m_TextOffset.x = text_x; }
virtual void SetTextY(float text_y) { TextItemControl()->m_TextOffset.y = text_y; }
virtual float GetTextX() { return TextItemControl()->m_TextOffset.x; }
Expand Down
16 changes: 13 additions & 3 deletions src/xrUICore/Static/UIStatic_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ SCRIPT_EXPORT(CUIStatic, (CUIWindow),
.def("SetColor", &CUIStatic::SetColor)
.def("GetColor", &CUIStatic::GetColor)

.def("SetTextColor", &CUIStatic::SetTextColor_script)
.def("SetTextColor", +[](CUIStatic* self, int a, int r, int g, int b)
{
self->SetTextColor(color_argb(a, r, g, b));
})

.def("Init", +[](CUIStatic* self, float x, float y, float width, float height)
{
Expand Down Expand Up @@ -82,8 +85,15 @@ SCRIPT_EXPORT(CUIStatic, (CUIWindow),
.def("SetStretchTexture", &CUIStatic::SetStretchTexture)
.def("GetStretchTexture", &CUIStatic::GetStretchTexture)

.def("SetTextAlign", &CUIStatic::SetTextAlign_script)
.def("GetTextAlign", &CUIStatic::GetTextAlign_script)
.def("SetTextAlign", +[](CUIStatic* self, u32 align)
{
self->TextItemControl()->SetTextAlignment(static_cast<CGameFont::EAligment>(align));
self->TextItemControl()->GetFont()->SetAligment(static_cast<CGameFont::EAligment>(align));
})
.def("GetTextAlign", +[](CUIStatic* self) -> u32
{
return static_cast<u32>(self->TextItemControl()->GetTextAlignment());
})

.def("SetHeading", &CUIStatic::SetHeading)
.def("GetHeading", &CUIStatic::GetHeading)
Expand Down

0 comments on commit 5aec8e6

Please sign in to comment.