ChatPlexSDK-BS 1.0.1-v6.2.0
C++ ChatPlex BeatSaber SDK
Loading...
Searching...
No Matches
ViewController.hpp
1#pragma once
2
3#include "IHMUIViewController.hpp"
4#include "../../CP_SDK/UI/Components/CHLayout.hpp"
5#include "../../CP_SDK/UI/Modals/ColorPicker.hpp"
6#include "../../CP_SDK/UI/Modals/Confirmation.hpp"
7#include "../../CP_SDK/UI/Modals/Dropdown.hpp"
8#include "../../CP_SDK/UI/Modals/Keyboard.hpp"
9#include "../../CP_SDK/UI/Modals/Loading.hpp"
10#include "../../CP_SDK/UI/Modals/Message.hpp"
11#include "../../CP_SDK/UI/Tooltip.hpp"
12#include "../../CP_SDK/UI/UISystem.hpp"
13#include "../../CP_SDK/Unity/Extensions/ColorU.hpp"
14
15#include <string>
16#include <map>
17
18#define SDK_UI_VIEW_CONTROLLER_INSTANCE() public: static CP_SDK::Utils::MonoPtr<___TargetType>& Instance() { return _Instance<___TargetType>(); }
19
20namespace CP_SDK_BS::UI {
21
22 namespace _u
23 {
24 using namespace UnityEngine;
25 }
26 namespace _v
27 {
28 using namespace CP_SDK::UI;
29 using namespace CP_SDK::Unity::Extensions;
30 using namespace CP_SDK::Utils;
31 }
32
35 {
36 CP_SDK_IL2CPP_INHERIT("CP_SDK_BS.UI", ViewController, IHMUIViewController);
37 CP_SDK_IL2CPP_DECLARE_CTOR_CHILD(ViewController);
38 CP_SDK_IL2CPP_DECLARE_DTOR_MONOBEHAVIOUR_CHILD(ViewController);
39
40 private:
41 std::u16string m_LogPrefix;
44 int m_ModalShowCount;
47 _v::MonoPtr<_v::Modals::Confirmation> m_ConfirmationModal;
53 bool m_UICreated;
54
55 static std::map<System::Type*, _v::MonoPtr<ViewController>> m_Instances;
56
57 public:
58 template<class t_Base> requires(std::is_assignable_v<ViewController*&, t_Base*>)
59 static _v::MonoPtr<t_Base>& _Instance()
60 {
61 auto l_Type = reinterpret_cast<System::Type*>(csTypeOf(t_Base*));
62 if (l_Type && m_Instances.contains(l_Type))
63 return *reinterpret_cast<_v::MonoPtr<t_Base>*>(&m_Instances[l_Type]);
64
66 }
67
68 public:
71
72 public:
73 bool UICreated();
74
75 private:
80 CP_SDK_IL2CPP_OVERRIDE_METHOD_EX(HMUI, ViewController, void, DidActivate, bool p_FirstActivation, bool p_AddedToHierarchy, bool p_ScreenSystemEnabling);
84 CP_SDK_IL2CPP_OVERRIDE_METHOD_EX(HMUI, ViewController, void, DidDeactivate, bool p_RemovedFromHierarchy, bool p_ScreenSystemDisabling);
85
86 protected:
95
96 public:
99 template<class t_ModalType>
100 t_ModalType* CreateModal()
101 {
102 return reinterpret_cast<t_ModalType*>(CreateModal_Impl(reinterpret_cast<System::Type*>(csTypeOf(t_ModalType*))));
103 }
104
105 private:
108 _v::IModal* CreateModal_Impl(System::Type* p_Type);
111 void ShowModal_Impl(_v::IModal* p_Modal);
114 void CloseModal_Impl(_v::IModal* p_Modal);
116 void CloseAllModals_Impl();
117
118 private:
124 void ShowColorPickerModal_Impl(_u::Color p_Value, bool p_Opacity, _v::CActionRef<_u::Color> p_Callback, _v::CActionRef<> p_CancelCallback = nullptr);
128 void ShowConfirmationModal_Impl(std::u16string_view p_Message, _v::CActionRef<bool> p_Callback);
133 void ShowDropdownModal_Impl(const std::vector<std::u16string>& p_Options, std::u16string_view p_Selected, _v::CActionRef<std::u16string_view> p_Callback);
139 void ShowKeyboardModal_Impl(std::u16string_view p_Value, _v::CActionRef<std::u16string_view> p_Callback, _v::CActionRef<> p_CancelCallback = nullptr, _v::KeyboardCustomKeys* p_CustomKeys = nullptr);
144 void ShowLoadingModal_Impl(std::u16string_view p_Message = {}, bool p_CancelButton = false, _v::CActionRef<> p_CancelCallback = nullptr);
148 void ShowMessageModal_Impl(std::u16string_view p_Message, _v::CActionRef<> p_Callback = nullptr);
149
150 private:
152 std::u16string_view KeyboardModal_GetValue_Impl();
155 void KeyboardModal_SetValue_Impl(std::u16string_view p_Value);
158 void KeyboardModal_Append_Impl(std::u16string_view p_ToAppend);
161 void LoadingModal_SetMessage_Impl(std::u16string_view p_Message);
162
163 private:
165 void CloseColorPickerModal_Impl();
167 void CloseConfirmationModal_Impl();
169 void CloseDropdownModal_Impl();
171 void CloseKeyboardModal_Impl();
173 void CloseLoadingModal_Impl();
175 void CloseMessageModal_Impl();
176
177 private:
181 void ShowTooltip_Impl(_u::Vector3 p_Position, std::u16string_view p_Text);
183 void HideTooltip_Impl();
184
185 };
186
187}
188
189CP_SDK_IL2CPP_INHERIT_HELPERS(CP_SDK_BS::UI::ViewController);
Abstract base modal component.
Definition IModal.hpp:22
IHMUIViewController interface.
View flow coordinator base class.
bool CanBeUpdated()
Can UI be updated.
_v::Action OnViewCreation
On view creation.
_v::Action OnViewDestruction
On view destruction.
_v::Action OnViewDeactivation
On view deactivation.
t_ModalType * CreateModal()
Create a modal of type t_ModalType.
_v::Action OnViewActivation
On view activation.
User interface components, views, flow coordinator, builders and factories.
Quality of life extensions to interact with Unity types.
Definition ColorU.hpp:6
Various platform utils like Delegate/Action/Function/Event system.
Definition Delegate.hpp:8
BeatSaber specific UI compoenents and utilities.