-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
66 changed files
with
2,781 additions
and
27 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#pragma once | ||
|
||
#include "HMUI/ImageView.hpp" | ||
#include "UI/ReeUIComponentV2.hpp" | ||
#include "UI/Abstract/IReeModal.hpp" | ||
#include "UnityEngine/GameObject.hpp" | ||
#include "System/Action.hpp" | ||
#include "main.hpp" | ||
|
||
namespace BeatLeader { | ||
|
||
template<typename C = BeatLeader::ReeComponent*> | ||
requires(std::is_convertible_v<C, BeatLeader::ReeComponent*>) | ||
class AbstractReeModal : public ReeUIComponentV2<C>, public IReeModal { | ||
protected: | ||
System::Action* closeAction; | ||
bool offClickCloses; | ||
|
||
public: | ||
virtual void OnInitialize() override { | ||
auto* bg = this->LocalComponent()->_content->template GetComponent<HMUI::ImageView*>(); | ||
if (bg != nullptr) { | ||
bg->set_raycastTarget(true); | ||
} | ||
offClickCloses = true; | ||
} | ||
|
||
virtual void OnContextChanged() { | ||
// Virtual - implemented by derived classes | ||
} | ||
|
||
virtual void OnResume() { | ||
// Virtual - implemented by derived classes | ||
} | ||
|
||
virtual void OnPause() { | ||
// Virtual - implemented by derived classes | ||
} | ||
|
||
virtual void OnInterrupt() { | ||
// Virtual - implemented by derived classes | ||
} | ||
|
||
virtual void OnOffClick() { | ||
BeatLeaderLogger.error("OnOffClick"); | ||
if (offClickCloses) { | ||
Close(); | ||
} | ||
} | ||
|
||
void ClearContext() { | ||
// Context handling will be implemented by derived classes | ||
} | ||
|
||
virtual void SetContext(Il2CppObject* context) { | ||
// Context handling will be implemented by derived classes | ||
OnContextChanged(); | ||
} | ||
|
||
// IReeModal implementation | ||
void Resume(void* state, System::Action* closeAction) override { | ||
this->closeAction = closeAction; | ||
SetContext(reinterpret_cast<Il2CppObject*>(state)); | ||
this->LocalComponent()->get_gameObject()->SetActive(true); | ||
this->LocalComponent()->_content->get_gameObject()->SetActive(true); | ||
OnResume(); | ||
} | ||
|
||
void Pause() override { | ||
this->LocalComponent()->get_gameObject()->SetActive(false); | ||
this->LocalComponent()->_content->get_gameObject()->SetActive(false); | ||
OnPause(); | ||
} | ||
|
||
void Interrupt() override { | ||
this->LocalComponent()->get_gameObject()->SetActive(false); | ||
this->LocalComponent()->_content->get_gameObject()->SetActive(false); | ||
OnInterrupt(); | ||
} | ||
|
||
void Close() override { | ||
if (closeAction != nullptr) { | ||
closeAction->Invoke(); | ||
} | ||
} | ||
|
||
void HandleOffClick() override { | ||
OnOffClick(); | ||
} | ||
}; | ||
|
||
} // namespace BeatLeader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#pragma once | ||
|
||
#include "custom-types/shared/macros.hpp" | ||
#include "System/Action.hpp" | ||
|
||
namespace BeatLeader { | ||
class IReeModal { | ||
public: | ||
virtual ~IReeModal() = default; | ||
virtual void Resume(void* state, System::Action* closeAction) = 0; | ||
virtual void Pause() = 0; | ||
virtual void Interrupt() = 0; | ||
virtual void Close() = 0; | ||
virtual void HandleOffClick() = 0; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
#pragma once | ||
|
||
#include "UnityEngine/Transform.hpp" | ||
#include "UnityEngine/GameObject.hpp" | ||
#include "HMUI/Screen.hpp" | ||
#include "HMUI/ModalView.hpp" | ||
#include "HMUI/ImageView.hpp" | ||
#include "UnityEngine/MonoBehaviour.hpp" | ||
#include "System/Collections/Generic/Dictionary_2.hpp" | ||
#include "System/Collections/Generic/Stack_1.hpp" | ||
#include "System/Action.hpp" | ||
#include "UI/Abstract/AbstractReeModal.hpp" | ||
#include "UI/ReeUIComponentV2.hpp" | ||
#include "UnityEngine/SceneManagement/Scene.hpp" | ||
#include "UnityEngine/SceneManagement/SceneManager.hpp" | ||
|
||
#include <unordered_map> | ||
#include <stack> | ||
|
||
DECLARE_CLASS_CUSTOM(BeatLeader, ReeModalSystemComponent, BeatLeader::ReeComponent, | ||
DECLARE_INSTANCE_FIELD(UnityEngine::Transform*, _container); | ||
DECLARE_INSTANCE_FIELD(HMUI::ModalView*, _modalView); | ||
DECLARE_INSTANCE_FIELD(HMUI::Screen*, _screen); | ||
) | ||
|
||
namespace BeatLeader { | ||
|
||
class ReeModalSystem : public ReeUIComponentV2<BeatLeader::ReeModalSystemComponent*> { | ||
private: | ||
static std::unordered_map<int, ReeModalSystem*> activeModals; | ||
static System::Action* interruptAllEvent; | ||
|
||
std::unordered_map<std::string, IReeModal*> pool; | ||
std::stack<std::pair<IReeModal*, Il2CppObject*>> modalStack; | ||
IReeModal* activeModal; | ||
Il2CppObject* activeModalState; | ||
bool hasActiveModal; | ||
|
||
void PopOpen(IReeModal* modal, Il2CppObject* state); | ||
void OpenImmediately(); | ||
void CloseOrPop(); | ||
void OnActiveSceneChanged(UnityEngine::SceneManagement::Scene from, UnityEngine::SceneManagement::Scene to); | ||
|
||
public: | ||
void Construct(HMUI::Screen* screen); | ||
void OnInitialize() override; | ||
void OnDispose() override; | ||
void OnDisable(); | ||
void InitializeModal(); | ||
void OnBlockerClicked(); | ||
void ShowModal(bool animated); | ||
void HideModal(bool animated); | ||
void InterruptAll(); | ||
void ForceUpdate(); | ||
StringW GetContent() override; | ||
|
||
template<typename T> | ||
static void OpenModal(UnityEngine::Transform* screenChild, Il2CppObject* state) | ||
requires std::is_base_of_v<IReeModal, T> && | ||
std::is_base_of_v<ReeUIComponentV2<typename T::ComponentType>, T> | ||
{ | ||
auto screen = screenChild->GetComponentInParent<HMUI::Screen*>(); | ||
OpenModal<T>(screen, state); | ||
} | ||
|
||
template<typename T> | ||
static void OpenModal(HMUI::Screen* screen, Il2CppObject* state, bool interruptActiveModals = true) | ||
requires std::is_base_of_v<IReeModal, T> && | ||
std::is_base_of_v<ReeUIComponentV2<typename T::ComponentType>, T> | ||
{ | ||
ReeModalSystem* controller; | ||
int key = screen->GetHashCode(); | ||
|
||
auto it = activeModals.find(key); | ||
if (it != activeModals.end()) { | ||
controller = it->second; | ||
} else { | ||
controller = ReeModalSystem::Instantiate<ReeModalSystem>(screen->get_transform()); | ||
controller->Construct(screen); | ||
controller->LocalComponent()->ManualInit(screen->get_transform()); | ||
activeModals[key] = controller; | ||
} | ||
|
||
if (interruptActiveModals) { | ||
if (interruptAllEvent) interruptAllEvent->Invoke(); | ||
} | ||
|
||
controller->OpenModalInternal<T>(state); | ||
} | ||
|
||
template<typename T> | ||
BeatLeader::IReeModal* GetOrInstantiateModal() | ||
requires std::is_base_of_v<IReeModal, T> && | ||
std::is_base_of_v<ReeUIComponentV2<typename T::ComponentType>, T> | ||
{ | ||
auto type = (std::string)typeid(T).name(); | ||
auto it = pool.find(type); | ||
if (it != pool.end()) return it->second; | ||
|
||
auto component = T::template Instantiate<T>(LocalComponent()->_container); | ||
component->LocalComponent()->ManualInit(LocalComponent()->_container); | ||
|
||
pool[type] = component; | ||
return component; | ||
} | ||
|
||
template<typename T> | ||
void OpenModalInternal(Il2CppObject* state) | ||
requires std::is_base_of_v<IReeModal, T> && | ||
std::is_base_of_v<ReeUIComponentV2<typename T::ComponentType>, T> | ||
{ | ||
auto modal = GetOrInstantiateModal<T>(); | ||
PopOpen(modal, state); | ||
} | ||
|
||
static void ForceUpdateAll(); | ||
}; | ||
|
||
} // namespace BeatLeader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// #pragma once | ||
|
||
// #include <unordered_map> | ||
// #include <string> | ||
// #include "UnityEngine/Sprite.hpp" | ||
|
||
// namespace BeatLeader::UI::BSML_Addons { | ||
// class BSMLAddonsLoader { | ||
// private: | ||
// static bool ready; | ||
// static std::unordered_map<std::string, UnityEngine::Sprite*> spritesToCache; | ||
|
||
// public: | ||
// static void LoadAddons(); | ||
// }; | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
#include "bsml/shared/BSML/TypeHandlers/TypeHandler.hpp" | ||
#include "UI/BSML_Addons/Components/BetterButton.hpp" | ||
|
||
namespace BeatLeader::UI::TypeHandlers { | ||
class BetterButtonHandler : public BSML::TypeHandler<BeatLeader::UI::BSML_Addons::BetterButton*> { | ||
using Base = TypeHandler<BeatLeader::UI::BSML_Addons::BetterButton*>; | ||
using Base::Base; | ||
|
||
virtual Base::PropMap get_props() const override; | ||
virtual Base::SetterMap get_setters() const override; | ||
virtual void HandleType(const BSML::ComponentTypeWithData& componentType, BSML::BSMLParserParams& parserParams) override; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
|
||
#include "bsml/shared/BSML/TypeHandlers/TypeHandler.hpp" | ||
#include "UI/BSML_Addons/Components/BetterImage.hpp" | ||
#include "UnityEngine/UI/Image.hpp" | ||
|
||
namespace BeatLeader::UI::TypeHandlers { | ||
class BetterImageHandler : public BSML::TypeHandler<BeatLeader::UI::BSML_Addons::BetterImage*> { | ||
using Base = TypeHandler<BeatLeader::UI::BSML_Addons::BetterImage*>; | ||
using Base::Base; | ||
|
||
virtual Base::PropMap get_props() const override; | ||
virtual Base::SetterMap get_setters() const override; | ||
virtual void HandleType(const BSML::ComponentTypeWithData& componentType, BSML::BSMLParserParams& parserParams) override; | ||
|
||
public: | ||
static void HandleImage(const std::map<std::string, std::string>& data, UnityEngine::UI::Image* image); | ||
static void HandleImage(const std::map<std::string, std::string>& data, UnityEngine::UI::Image* image, const std::string& prefix); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
|
||
#include "UnityEngine/UI/Button.hpp" | ||
#include "UnityEngine/UI/Image.hpp" | ||
#include "UnityEngine/MonoBehaviour.hpp" | ||
#include "custom-types/shared/macros.hpp" | ||
#include "UI/BSML_Addons/Tags/BetterButtonTag.hpp" | ||
|
||
namespace BeatLeader::UI::BSML_Addons { | ||
class BetterButtonTag; | ||
} | ||
|
||
DECLARE_CLASS_CODEGEN(BeatLeader::UI::BSML_Addons, BetterButton, UnityEngine::MonoBehaviour, | ||
DECLARE_INSTANCE_FIELD(UnityEngine::UI::Button*, button); | ||
DECLARE_INSTANCE_FIELD(UnityEngine::UI::Image*, targetGraphic); | ||
DECLARE_CTOR(ctor); | ||
|
||
DECLARE_INSTANCE_METHOD(void, Init, UnityEngine::UI::Button* btn, UnityEngine::UI::Image* graphic); | ||
|
||
private: | ||
friend class ::BeatLeader::UI::BSML_Addons::BetterButtonTag; | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#pragma once | ||
|
||
#include "UnityEngine/MonoBehaviour.hpp" | ||
#include "UI/BSML_Addons/Components/FixedImageView.hpp" | ||
#include "custom-types/shared/macros.hpp" | ||
|
||
DECLARE_CLASS_CODEGEN(BeatLeader::UI::BSML_Addons, BetterImage, UnityEngine::MonoBehaviour, | ||
DECLARE_INSTANCE_FIELD(BeatLeader::UI::BSML_Addons::FixedImageView*, image); | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#pragma once | ||
|
||
#include "HMUI/ImageView.hpp" | ||
#include "custom-types/shared/macros.hpp" | ||
|
||
DECLARE_CLASS_CODEGEN(BeatLeader::UI::BSML_Addons, FixedImageView, HMUI::ImageView) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#pragma once | ||
|
||
#include "bsml/shared/BSML/Tags/BSMLTag.hpp" | ||
|
||
namespace BeatLeader::UI::BSML_Addons { | ||
class BetterButtonTag : public BSML::BSMLTag { | ||
public: | ||
BetterButtonTag() : BSMLTag() {} | ||
protected: | ||
UnityEngine::GameObject* CreateObject(UnityEngine::Transform* parent) const override; | ||
}; | ||
} |
Oops, something went wrong.