-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathQuestUI.hpp
181 lines (147 loc) · 10.3 KB
/
QuestUI.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#pragma once
#include "scotland2/shared/loader.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "UnityEngine/UI/Button.hpp"
#include "HMUI/ViewController.hpp"
#include "HMUI/FlowCoordinator.hpp"
#include <concepts>
namespace QuestUI {
void Init();
bool DidInit();
int GetModsCount();
HMUI::FlowCoordinator* GetModSettingsFlowCoordinator();
class Register {
public:
enum MenuLocation{
Settings = 1,
MainMenu = 2,
AllViews = Settings | MainMenu
};
enum Type {
VIEW_CONTROLLER,
FLOW_COORDINATOR,
};
enum MenuType {
Solo = 1,
Online = 2,
Campaign = 4,
Custom = 8,
All = Solo | Online | Campaign | Custom
};
typedef void(*DidActivateEvent)(HMUI::ViewController* self, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling);
typedef void(*GameplaySetupMenuEvent)(UnityEngine::GameObject* self, bool firstActivation);
template<class T = HMUI::ViewController*>
static void RegisterModSettingsViewController(modloader::ModInfo modInfo, std::string title, bool showModInfo = true, DidActivateEvent didActivateEvent = nullptr) {
static_assert(std::is_convertible<T, HMUI::ViewController*>());
RegisterModSettings(modInfo, showModInfo, title, MenuLocation::Settings, csTypeOf(T), Type::VIEW_CONTROLLER, didActivateEvent);
}
template<class T = HMUI::ViewController*>
static void RegisterModSettingsViewController(modloader::ModInfo modInfo, std::string title, DidActivateEvent didActivateEvent) {
static_assert(std::is_convertible<T, HMUI::ViewController*>());
RegisterModSettingsViewController<T>(modInfo, title, true, didActivateEvent);
}
template<class T = HMUI::ViewController*>
static void RegisterModSettingsViewController(modloader::ModInfo modInfo, DidActivateEvent didActivateEvent = nullptr) {
static_assert(std::is_convertible<T, HMUI::ViewController*>());
RegisterModSettingsViewController<T>(modInfo, modInfo.id, true, didActivateEvent);
}
template<class T>
static void RegisterModSettingsFlowCoordinator(modloader::ModInfo modInfo) {
static_assert(std::is_convertible<T, HMUI::FlowCoordinator*>());
RegisterModSettings(modInfo, false, modInfo.id, MenuLocation::Settings, csTypeOf(T), Type::FLOW_COORDINATOR);
}
template<class T>
static void RegisterModSettingsFlowCoordinator(modloader::ModInfo modInfo, std::string title, bool showModInfo = false) {
static_assert(std::is_convertible<T, HMUI::FlowCoordinator*>());
RegisterModSettings(modInfo, showModInfo, title, MenuLocation::Settings, csTypeOf(T), Type::FLOW_COORDINATOR);
}
template<class T = HMUI::ViewController*>
static void RegisterMainMenuModSettingsViewController(modloader::ModInfo modInfo, std::string title, bool showModInfo = true, DidActivateEvent didActivateEvent = nullptr) {
static_assert(std::is_convertible<T, HMUI::ViewController*>());
RegisterModSettings(modInfo, showModInfo, title, MenuLocation::MainMenu, csTypeOf(T), Type::VIEW_CONTROLLER, didActivateEvent);
}
template<class T = HMUI::ViewController*>
static void RegisterMainMenuModSettingsViewController(modloader::ModInfo modInfo, std::string title, DidActivateEvent didActivateEvent) {
static_assert(std::is_convertible<T, HMUI::ViewController*>());
RegisterMainMenuModSettingsViewController<T>(modInfo, title, true, didActivateEvent);
}
template<class T = HMUI::ViewController*>
static void RegisterMainMenuModSettingsViewController(modloader::ModInfo modInfo, DidActivateEvent didActivateEvent = nullptr) {
static_assert(std::is_convertible<T, HMUI::ViewController*>());
RegisterMainMenuModSettingsViewController<T>(modInfo, modInfo.id, true, didActivateEvent);
}
template<class T>
static void RegisterMainMenuModSettingsFlowCoordinator(modloader::ModInfo modInfo) {
static_assert(std::is_convertible<T, HMUI::FlowCoordinator*>());
RegisterModSettings(modInfo, false, modInfo.id, MenuLocation::MainMenu, csTypeOf(T), Type::FLOW_COORDINATOR);
}
template<class T>
static void RegisterMainMenuModSettingsFlowCoordinator(modloader::ModInfo modInfo, std::string title, bool showModInfo = false) {
static_assert(std::is_convertible<T, HMUI::FlowCoordinator*>());
RegisterModSettings(modInfo, showModInfo, title, MenuLocation::MainMenu, csTypeOf(T), Type::FLOW_COORDINATOR);
}
template<class T = HMUI::ViewController*>
static void RegisterAllModSettingsViewController(modloader::ModInfo modInfo, std::string title, bool showModInfo = true, DidActivateEvent didActivateEvent = nullptr) {
static_assert(std::is_convertible<T, HMUI::ViewController*>());
RegisterModSettings(modInfo, showModInfo, title, MenuLocation::AllViews, csTypeOf(T), Type::VIEW_CONTROLLER, didActivateEvent);
}
template<class T = HMUI::ViewController*>
static void RegisterAllModSettingsViewController(modloader::ModInfo modInfo, std::string title, DidActivateEvent didActivateEvent) {
static_assert(std::is_convertible<T, HMUI::ViewController*>());
RegisterAllModSettingsViewController<T>(modInfo, title, true, didActivateEvent);
}
template<class T = HMUI::ViewController*>
static void RegisterAllModSettingsViewController(modloader::ModInfo modInfo, DidActivateEvent didActivateEvent = nullptr) {
static_assert(std::is_convertible<T, HMUI::ViewController*>());
RegisterAllModSettingsViewController<T>(modInfo, modInfo.id, true, didActivateEvent);
}
template<class T>
static void RegisterAllModSettingsFlowCoordinator(modloader::ModInfo modInfo) {
static_assert(std::is_convertible<T, HMUI::FlowCoordinator*>());
RegisterModSettings(modInfo, false, modInfo.id, MenuLocation::AllViews, csTypeOf(T), Type::FLOW_COORDINATOR);
}
template<class T>
static void RegisterAllModSettingsFlowCoordinator(modloader::ModInfo modInfo, std::string title, bool showModInfo = false) {
static_assert(std::is_convertible<T, HMUI::FlowCoordinator*>());
RegisterModSettings(modInfo, showModInfo, title, MenuLocation::AllViews, csTypeOf(T), Type::FLOW_COORDINATOR);
}
/// @brief Register a GameplaySetupMenu type for usage within the left menu
/// @tparam T the type to register
/// @param modInfo the modinfo used for the register
/// @param menuType when to actually present this type
template<class T>
static void RegisterGameplaySetupMenu(modloader::ModInfo modInfo, int menuType = MenuType::All) {
static_assert(std::is_convertible<T, UnityEngine::Component*>(), "Passed Type is not convertible to UnityEngine::Component!");
RegisterGameplaySetupMenu(modInfo, modInfo.id, csTypeOf(T), menuType, nullptr);
}
/// @brief Register a GameplaySetupMenu type for usage within the left menu
/// @tparam T the type to register
/// @param modInfo the modinfo used for the register
/// @param title the title used for display
/// @param menuType when to actually present this type
template<class T>
static void RegisterGameplaySetupMenu(modloader::ModInfo modInfo, std::string_view title, int menuType = MenuType::All) {
static_assert(std::is_convertible<T, UnityEngine::Component*>(), "Passed Type is not convertible to UnityEngine::Component!");
RegisterGameplaySetupMenu(modInfo, title, csTypeOf(T), menuType, nullptr);
}
/// @brief Register a GameplaySetupMenu type for usage within the left menu
/// @param modInfo the modinfo used for the register
/// @param title the title used for display
/// @param menuType when to actually present this type
/// @param setupEvent callback called when your object is constructed
static void RegisterGameplaySetupMenu(modloader::ModInfo modInfo, int menuType = MenuType::All, GameplaySetupMenuEvent setupEvent = nullptr) {
RegisterGameplaySetupMenu(modInfo, modInfo.id, nullptr, menuType, setupEvent);
}
/// @brief Register a GameplaySetupMenu type for usage within the left menu
/// @param modInfo the modinfo used for the register
/// @param title the title used for display
/// @param menuType when to actually present this type, MenuType bitmask
/// @param setupEvent callback called when your object is constructed
static void RegisterGameplaySetupMenu(modloader::ModInfo modInfo, std::string_view title, int menuType = MenuType::All, GameplaySetupMenuEvent setupEvent = nullptr) {
RegisterGameplaySetupMenu(modInfo, title, nullptr, menuType, setupEvent);
}
private:
static void RegisterModSettings(modloader::ModInfo modInfo, bool showModInfo, std::string title, MenuLocation location, Il2CppReflectionType* il2cpp_type, Type type, DidActivateEvent didActivateEvent = nullptr);
static void RegisterGameplaySetupMenu(modloader::ModInfo modInfo, std::string_view title, Il2CppReflectionType* il2cpp_type, int type, GameplaySetupMenuEvent setupEvent = nullptr);
};
}