From 5aec8e6a4fd247b39303a980132181176cbddf5d Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Fri, 9 Feb 2024 16:40:18 +0500 Subject: [PATCH] xrUICore/Static/UIStatic.h: moved some script specific functions to _script.cpp --- src/xrUICore/Static/UIStatic.h | 16 ---------------- src/xrUICore/Static/UIStatic_script.cpp | 16 +++++++++++++--- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/xrUICore/Static/UIStatic.h b/src/xrUICore/Static/UIStatic.h index 22f40ca4c4c..16e235724ee 100644 --- a/src/xrUICore/Static/UIStatic.h +++ b/src/xrUICore/Static/UIStatic.h @@ -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(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; } diff --git a/src/xrUICore/Static/UIStatic_script.cpp b/src/xrUICore/Static/UIStatic_script.cpp index 91982564bbf..4e41ea6e238 100644 --- a/src/xrUICore/Static/UIStatic_script.cpp +++ b/src/xrUICore/Static/UIStatic_script.cpp @@ -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) { @@ -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(align)); + self->TextItemControl()->GetFont()->SetAligment(static_cast(align)); + }) + .def("GetTextAlign", +[](CUIStatic* self) -> u32 + { + return static_cast(self->TextItemControl()->GetTextAlignment()); + }) .def("SetHeading", &CUIStatic::SetHeading) .def("GetHeading", &CUIStatic::GetHeading)