ChatPlexSDK-BS 1.0.1-v6.2.0
C++ ChatPlex BeatSaber SDK
Loading...
Searching...
No Matches
IXUIElementWithChilds.hpp
1#pragma once
2
3#include "IXUIElement.hpp"
4
5#include <UnityEngine/Transform.hpp>
6
7namespace CP_SDK::XUI {
8
11 template<class t_Base>
13 : public IXUIElement
14 {
15 CP_SDK_NO_COPYMOVE_CTORS(IXUIElementWithChilds);
16
17 protected:
18 std::vector<std::shared_ptr<IXUIElement>> m_Childs;
19
20 protected:
21
26 IXUIElementWithChilds(std::u16string_view p_Name, ETypeID p_TypeID, const std::vector<std::shared_ptr<IXUIElement>>& p_Childs)
27 : IXUIElement(p_Name, p_TypeID), m_Childs(p_Childs)
28 { }
30 virtual ~IXUIElementWithChilds() = default;
31
32 protected:
35 void BuildUIChilds(_u::Transform* p_Parent)
36 {
37 if (m_Childs.empty())
38 return;
39
40 for (auto l_I = 0; l_I < m_Childs.size(); ++l_I)
41 m_Childs[l_I]->BuildUI(p_Parent);
42 }
43
44 public:
48 template<class t_ChildType>
50 {
51 for (auto l_I = 0; l_I < m_Childs.size(); ++l_I)
52 {
53 if (m_Childs[l_I]->m_TypeID != t_ChildType::TypeID)
54 continue;
55
56 p_Functor(reinterpret_cast<t_ChildType*>(m_Childs[l_I].get()));
57 }
58
59 return reinterpret_cast<t_Base*>(this);
60 }
61
62 };
63
64}
Element interface.
virtual void BuildUI(_u::Transform *p_Parent)=0
BuildUI for this element into p_Parent transform.
IXUIElement with children abstract class.
virtual ~IXUIElementWithChilds()=default
Destructor.
void BuildUIChilds(_u::Transform *p_Parent)
BuildUI for children into p_Parent transform.
IXUIElementWithChilds(std::u16string_view p_Name, ETypeID p_TypeID, const std::vector< std::shared_ptr< IXUIElement > > &p_Childs)
Constructor.
t_Base * ForEachDirect(_v::CActionRef< t_ChildType * > p_Functor)
For each direct XUIElement child of type t_ChildType.
Tree like syntax CP_SDK::UI builder.