ChatPlexSDK-BS 1.0.1-v6.2.0
C++ ChatPlex BeatSaber SDK
Loading...
Searching...
No Matches
HMUIViewFlowCoordinator.hpp
1#pragma once
2
3#include "HMUIUIUtils.hpp"
4#include "../../CP_SDK/Utils/Delegate.hpp"
5#include "../../CP_SDK/Utils/Il2cpp.hpp"
6#include "../../CP_SDK/Utils/MonoPtr.hpp"
7
8#include <custom-types/shared/coroutine.hpp>
9
10#include <HMUI/FlowCoordinator.hpp>
11#include <HMUI/ViewController.hpp>
12
13#include <tuple>
14#include <queue>
15
16#define SDK_UI_FLOW_COORDINATOR_INSTANCE() public: static CP_SDK::Utils::MonoPtr<___TargetType>& Instance() { return _Instance<___TargetType>(); }
17#define SDK_UI_FLOW_COORDINATOR_DESTROY() public: static void Destroy() { _Destroy <___TargetType>(); }
18
19namespace CP_SDK_BS::UI {
20
21 namespace _u
22 {
23 using namespace UnityEngine;
24 }
25 namespace _v
26 {
27 //using namespace CP_SDK;
28 //using namespace CP_SDK::UI;
29 using namespace CP_SDK::Utils;
30 }
31
33 class HMUIViewFlowCoordinator : public HMUI::FlowCoordinator
34 {
35 CP_SDK_IL2CPP_INHERIT("CP_SDK_BS.UI", HMUIViewFlowCoordinator, HMUI::FlowCoordinator);
36 CP_SDK_IL2CPP_DECLARE_CTOR(HMUIViewFlowCoordinator);
37 CP_SDK_IL2CPP_DECLARE_DTOR_MONOBEHAVIOUR(HMUIViewFlowCoordinator);
38
39 private:
40 static std::map<System::Type*, _v::MonoPtr<HMUIViewFlowCoordinator>> m_Instances;
41
42 public:
43 template<class t_Base> requires(std::is_assignable_v<HMUIViewFlowCoordinator*&, t_Base*>)
44 static _v::MonoPtr<t_Base>& _Instance()
45 {
46 auto l_Type = reinterpret_cast<System::Type*>(csTypeOf(t_Base*));
47 if (l_Type && m_Instances.contains(l_Type))
48 return *reinterpret_cast<_v::MonoPtr<t_Base>*>(&m_Instances[l_Type]);
49
50 m_Instances[l_Type] = HMUIUIUtils::CreateFlowCoordinator<t_Base*>();
51 return *reinterpret_cast<_v::MonoPtr<t_Base>*>(&m_Instances[l_Type]);
52 }
53 template<class t_Base> requires(std::is_assignable_v<HMUIViewFlowCoordinator*&, t_Base*>)
54 static void _Destroy()
55 {
56 auto l_Type = reinterpret_cast<System::Type*>(csTypeOf(t_Base*));
57 auto l_It = m_Instances.find(l_Type);
58 if (!l_Type || l_It == m_Instances.end())
59 return;
60
61 if (m_Instances[l_Type])
62 _u::GameObject::Destroy(m_Instances[l_Type]->get_gameObject());
63
64 m_Instances.erase(l_It);
65 }
66
67 public:
74
75 private:
76 std::queue<t_Views> m_SwitchQueue;
77 bool m_IsDequeueEngaged;
78 _v::MonoPtr<HMUI::FlowCoordinator> m_BackupFlowCoordinator;
79
80 protected:
83
84 public:
89 CP_SDK_IL2CPP_OVERRIDE_METHOD_EX(HMUI, FlowCoordinator, void, DidActivate, bool p_FirstActivation, bool p_AddedToHierarchy, bool p_ScreenSystemEnabling);
92 CP_SDK_IL2CPP_OVERRIDE_METHOD_EX(HMUI, FlowCoordinator, void, BackButtonWasPressed, HMUI::ViewController* p_TopViewController);
93
94 public:
97 void Present(bool p_IgnoreBackuping = false);
99 void Dismiss();
100
101 protected:
107
108 protected:
114
115 public:
120
121 public:
124 void ChangeView(HMUI::ViewController* p_NewView, HMUI::ViewController* p_Left = nullptr, HMUI::ViewController* p_Right = nullptr);
125
126 private:
128 void DequeueViewController();
130 static custom_types::Helpers::Coroutine DequeueViewControllerWhileOldInTransition(HMUIViewFlowCoordinator* p_Self);
131
132 protected:
135 template<class t_ViewController> requires(std::is_assignable_v<HMUI::ViewController*&, t_ViewController>)
136 t_ViewController CreateViewController()
137 {
138 return HMUIUIUtils::CreateViewController<t_ViewController>();
139 }
143 template<class t_ViewController> requires(std::is_assignable_v<HMUI::ViewController*&, t_ViewController*>)
145 {
146 if (*p_ViewController)
147 {
148 _u::GameObject::DestroyImmediate((*p_ViewController)->get_gameObject());
149 *p_ViewController = nullptr;
150 }
151 }
152
153 };
154
155}
156
157CP_SDK_IL2CPP_INHERIT_HELPERS(CP_SDK_BS::UI::HMUIViewFlowCoordinator);
Delegate helper class.
Definition Delegate.hpp:123
CP_SDK_IL2CPP_OVERRIDE_METHOD_EX(HMUI, FlowCoordinator, void, BackButtonWasPressed, HMUI::ViewController *p_TopViewController)
When the back button is pressed.
_v::Action< bool > Present_Override
Present this HMUIViewFlowCoordinator.
_v::Func< t_Views > GetInitialViewsController
Get initial views controller (Middle, Left, Right)
void Dismiss()
Dismiss this HMUIViewFlowCoordinator.
_v::Func< std::u16string_view > Title
Initial title.
t_ViewController CreateViewController()
Create a view controller.
CP_SDK_IL2CPP_OVERRIDE_METHOD_EX(HMUI, FlowCoordinator, void, DidActivate, bool p_FirstActivation, bool p_AddedToHierarchy, bool p_ScreenSystemEnabling)
On activation.
void HideLeftScreen()
Hide the left screen.
void Present(bool p_IgnoreBackuping=false)
Present this HMUIViewFlowCoordinator.
_v::Action Dismiss_Override
Dismiss this HMUIViewFlowCoordinator.
_v::Func< bool, HMUI::ViewController * > OnBackButtonPressed
On back button pressed.
void HideRightScreen()
Hide the right screen.
static void DestroyViewController(_v::MonoPtr< t_ViewController > *p_ViewController)
Destroy view controller.
void ChangeView(HMUI::ViewController *p_NewView, HMUI::ViewController *p_Left=nullptr, HMUI::ViewController *p_Right=nullptr)
Enqueue a main view controller change.
Various platform utils like Delegate/Action/Function/Event system.
Definition Delegate.hpp:8
BeatSaber specific UI compoenents and utilities.