3#include "../../UI/Components/CPrimaryButton.hpp"
4#include "../../UI/Components/CSecondaryButton.hpp"
5#include "IXUIElement.hpp"
6#include "IXUIBindable.hpp"
7#include "IXUIElementReady.hpp"
14 template<
class t_Base,
class t_Component>
19 public std::enable_shared_from_this<t_Base>
29 std::shared_ptr<t_Base> AsShared() {
return std::enable_shared_from_this<t_Base>::shared_from_this(); }
49 if (p_OnClick.IsValid())
52 SetText(std::u16string(p_Label));
60 virtual void BuildUI(_u::Transform* p_Parent)
override
62 if constexpr (std::is_same_v<t_Component, _v::CPrimaryButton>)
67 try { m_OnReady(m_Element.Ptr()); m_OnReady.Clear(); }
68 catch (
const std::exception& l_Exception)
70 if constexpr (std::is_same_v<t_Component, _v::CPrimaryButton>)
71 ChatPlexSDK::Logger()->Error(u
"[CP_SDK.XUI][_XUIPOrSButton<CPrimaryButton>.BuildUI] Error OnReady:");
73 ChatPlexSDK::Logger()->Error(u
"[CP_SDK.XUI][_XUIPOrSButton<CSecondaryButton>.BuildUI] Error OnReady:");
83 if (m_Element) p_Functor(m_Element.Ptr());
84 else m_OnReady += p_Functor;
85 return reinterpret_cast<t_Base*
>(
this);
89 virtual t_Base*
Bind(std::shared_ptr<t_Base>* p_Target)
override
91 *p_Target = std::enable_shared_from_this<t_Base>::shared_from_this();
92 return reinterpret_cast<t_Base*
>(
this);
99 t_Base*
OnClick(
_v::Action<> p_Functor,
bool p_Add =
true) XUI_PROXY_IMPL_EX(t_Component, { x->OnClick(p_Functor, p_Add); })
104 t_Base*
SetActive(bool p_Active) XUI_PROXY_IMPL_EX(t_Component, { x->get_gameObject()->SetActive(p_Active); })
109 t_Base*
SetWidth(float p_Width) XUI_PROXY_IMPL_EX(t_Component, { x->SetWidth(p_Width); })
112 t_Base*
SetHeight(
float p_Height) XUI_PROXY_IMPL_EX(t_Component, { x->SetHeight(p_Height); })
117 t_Base*
SetBackgroundSprite(_u::Sprite* p_Sprite) XUI_PROXY_IMPL_EX(t_Component, { x->SetBackgroundSprite(p_Sprite); })
120 t_Base*
SetFontSize(
float p_Size) XUI_PROXY_IMPL_EX(t_Component, { x->SetFontSize(p_Size); })
123 t_Base*
SetIconSprite(_u::Sprite* p_Sprite) XUI_PROXY_IMPL_EX(t_Component, { x->SetIconSprite(p_Sprite); })
126 t_Base*
SetInteractable(
bool p_Interactable) XUI_PROXY_IMPL_EX(t_Component, { x->SetInteractable(p_Interactable); })
129 t_Base*
SetOverflowMode(_u::TextOverflowModes p_OverflowMode) XUI_PROXY_IMPL_EX(t_Component, { x->SetOverflowMode(p_OverflowMode); })
132 t_Base*
SetText(std::u16string p_Text) XUI_PROXY_IMPL_EX(t_Component, { x->SetText(p_Text); })
135 t_Base*
SetTooltip(std::u16string p_Tooltip) XUI_PROXY_IMPL_EX(t_Component, { x->SetTooltip(p_Tooltip); })
static Logging::ILogger * Logger()
Logger instance.
IXUIElement Bind interface.
std::u16string_view GetInitialName()
Get initial name.
IXUIElement OnReady functor interface.
Tree like syntax CP_SDK::UI builder.