ChatPlexSDK-BS 1.0.1-v6.2.0
C++ ChatPlex BeatSaber SDK
Loading...
Searching...
No Matches
ViewController.hpp
1#pragma once
2
3#include "IViewController.hpp"
4#include "Modals/ColorPicker.hpp"
5#include "Modals/Confirmation.hpp"
6#include "Modals/Dropdown.hpp"
7#include "Modals/Keyboard.hpp"
8#include "Modals/Loading.hpp"
9#include "Modals/Message.hpp"
10#include "Tooltip.hpp"
11
12#include <map>
13
14#define CP_SDK_UI_VIEW_CONTROLLER_INSTANCE() public: static CP_SDK::Utils::MonoPtr<___TargetType>& Instance() { return _Instance<___TargetType>(); }
15
16namespace CP_SDK::UI {
17
18 namespace _u
19 {
20 using namespace System;
21 using namespace UnityEngine;
22 }
23 namespace _v
24 {
25 using namespace CP_SDK::Utils;
26 }
27
30 {
31 CP_SDK_IL2CPP_INHERIT("CP_SDK.UI", ViewController, IViewController);
32 CP_SDK_IL2CPP_DECLARE_CTOR_CHILD(ViewController);
33 CP_SDK_IL2CPP_DECLARE_DTOR_MONOBEHAVIOUR_CHILD(ViewController);
34
35 private:
36 std::u16string m_LogPrefix;
39 _v::MonoPtr<IScreen> m_CurrentScreen;
40 int m_ModalShowCount;
41 _v::MonoPtr<Components::CHLayout> m_ModalContainer;
43 _v::MonoPtr<Modals::Confirmation> m_ConfirmationModal;
44 _v::MonoPtr<Modals::Dropdown> m_DropdownModal;
45 _v::MonoPtr<Modals::Keyboard> m_KeyboardModal;
46 _v::MonoPtr<Modals::Loading> m_LoadingModal;
47 _v::MonoPtr<Modals::Message> m_MessageModal;
48 _v::MonoPtr<Tooltip> m_Tooltip;
49 bool m_UICreated;
50
51 static std::map<_u::Type*, _v::MonoPtr<ViewController>> m_Instances;
52
53 public:
54 template<class t_Base> requires(std::is_assignable_v<ViewController*&, t_Base*>)
55 static _v::MonoPtr<t_Base>& _Instance()
56 {
57 auto l_Type = reinterpret_cast<_u::Type*>(csTypeOf(t_Base*));
58 if (l_Type && m_Instances.contains(l_Type))
59 return *reinterpret_cast<_v::MonoPtr<t_Base>*>(&m_Instances[l_Type]);
60
62 }
63 static ViewController* _Instance(_u::Type* p_Type)
64 {
65 if (p_Type && m_Instances.contains(p_Type))
66 return m_Instances[p_Type].Ptr(false);
67
68 return nullptr;
69 }
70
71 public:
74
75 public:
77 UIFieldRefDel<_u::RectTransform> ModalContainerRTransform;
79 UIFieldRefDel<IScreen> CurrentScreen;
80 bool UICreated();
81
82 private:
84 DECLARE_INSTANCE_METHOD(void, Awake);
86 void Init();
87
88 private:
91 void __Activate_Impl(IScreen* p_Screen);
93 void __Deactivate_Impl();
94
95 protected:
104
105 public:
108 template<class t_ModalType>
109 t_ModalType* CreateModal()
110 {
111 return reinterpret_cast<t_ModalType*>(CreateModal_Impl(reinterpret_cast<_u::Type*>(csTypeOf(t_ModalType*))));
112 }
113
114 private:
117 IModal* CreateModal_Impl(_u::Type* p_Type);
120 void ShowModal_Impl(IModal* p_Modal);
123 void CloseModal_Impl(IModal* p_Modal);
125 void CloseAllModals_Impl();
126
127 private:
133 void ShowColorPickerModal_Impl(_u::Color p_Value, bool p_Opacity, _v::CActionRef<_u::Color> p_Callback, _v::CActionRef<>& p_CancelCallback = nullptr);
137 void ShowConfirmationModal_Impl(std::u16string_view p_Message, _v::CActionRef<bool> p_Callback);
142 void ShowDropdownModal_Impl(const std::vector<std::u16string>& p_Options, std::u16string_view p_Selected, _v::CActionRef<std::u16string_view> p_Callback);
148 void ShowKeyboardModal_Impl(std::u16string_view p_Value, _v::CActionRef<std::u16string_view> p_Callback, _v::CActionRef<> p_CancelCallback = nullptr, KeyboardCustomKeys* p_CustomKeys = nullptr);
153 void ShowLoadingModal_Impl(std::u16string_view p_Message = {}, bool p_CancelButton = false, _v::CActionRef<> p_CancelCallback = nullptr);
157 void ShowMessageModal_Impl(std::u16string_view p_Message, _v::CActionRef<> p_Callback = nullptr);
158
159 private:
161 std::u16string_view KeyboardModal_GetValue_Impl();
164 void KeyboardModal_SetValue_Impl(std::u16string_view p_Value);
167 void KeyboardModal_Append_Impl(std::u16string_view p_ToAppend);
170 void LoadingModal_SetMessage_Impl(std::u16string_view p_Message);
171
172 private:
174 void CloseColorPickerModal_Impl();
176 void CloseConfirmationModal_Impl();
178 void CloseDropdownModal_Impl();
180 void CloseKeyboardModal_Impl();
182 void CloseLoadingModal_Impl();
184 void CloseMessageModal_Impl();
185
186 private:
190 void ShowTooltip_Impl(_u::Vector3 p_Position, std::u16string_view p_Text);
192 void HideTooltip_Impl();
193
194 };
195
196}
197
198CP_SDK_IL2CPP_INHERIT_HELPERS(CP_SDK::UI::ViewController);
Abstract base modal component.
Definition IModal.hpp:22
Abstract screen.
Definition IScreen.hpp:30
IViewController interface.
IViewController interface.
bool CanBeUpdated()
Can UI be updated.
_v::Action OnViewCreation
On view creation.
_v::Action OnViewDestruction
On view destruction.
_v::Action OnViewDeactivation
On view deactivation.
_v::Action OnViewActivation
On view activation.
t_ModalType * CreateModal()
Create a modal of type t_ModalType.
Delegate helper class.
Definition Delegate.hpp:123
User interface components, views, flow coordinator, builders and factories.
Various platform utils like Delegate/Action/Function/Event system.
Definition Delegate.hpp:8