Skip to content

Commit

Permalink
Rebrand BSML to fix rare crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenAlex committed Mar 26, 2023
1 parent 33bb09a commit f2a57ba
Show file tree
Hide file tree
Showing 27 changed files with 66 additions and 66 deletions.
6 changes: 0 additions & 6 deletions include/BSMLDataCache_internal.hpp

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "System/Collections/Generic/Dictionary_2.hpp"
#include "System/Collections/Generic/IReadOnlyDictionary_2.hpp"

DECLARE_CLASS_CODEGEN(BSML, AnimationController, UnityEngine::MonoBehaviour,
DECLARE_CLASS_CODEGEN(FSML, AnimationController, UnityEngine::MonoBehaviour,
DECLARE_INSTANCE_FIELD(AnimationControllerData*, loadingAnimation);
using StringToAnimDataDictionary = System::Collections::Generic::Dictionary_2<StringW, Il2CppObject*>;
DECLARE_INSTANCE_FIELD(StringToAnimDataDictionary*, registeredAnimations);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "UnityEngine/Material.hpp"
#include "UnityEngine/UI/Image.hpp"

DECLARE_CLASS_CODEGEN(BSML, AnimationControllerData, Il2CppObject,
DECLARE_CLASS_CODEGEN(FSML, AnimationControllerData, Il2CppObject,
DECLARE_INSTANCE_FIELD(UnityEngine::Sprite*, sprite);
DECLARE_INSTANCE_FIELD(int, uvIndex);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// this is just included because otherwise the SafePtr complains about conversion to unity object
#include "UnityEngine/Object.hpp"

namespace BSML {
namespace FSML {
class FrameInfo;
class AnimationInfo {
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "custom-types/shared/coroutine.hpp"


DECLARE_CLASS_CODEGEN(BSML, AnimationLoader, Il2CppObject,
DECLARE_CLASS_CODEGEN(FSML, AnimationLoader, Il2CppObject,
public:
enum class AnimationType {
GIF,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "AnimationControllerData.hpp"

DECLARE_CLASS_CODEGEN(BSML, AnimationStateUpdater, UnityEngine::MonoBehaviour,
DECLARE_CLASS_CODEGEN(FSML, AnimationStateUpdater, UnityEngine::MonoBehaviour,
DECLARE_INSTANCE_FIELD(UnityEngine::UI::Image*, image);
DECLARE_INSTANCE_FIELD(AnimationControllerData*, controllerData);
DECLARE_INSTANCE_METHOD(AnimationControllerData*, get_controllerData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "beatsaber-hook/shared/utils/typedefs.h"
#include "custom-types/shared/coroutine.hpp"

namespace BSML {
namespace FSML {
class GifDecoder {
public:
static custom_types::Helpers::Coroutine Process(ArrayW<uint8_t> data, std::function<void(AnimationInfo*)> onFinished);
Expand Down
26 changes: 13 additions & 13 deletions include/BSMLDataCache.hpp → include/FSMLDataCache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,39 @@
#include <string>
#include "beatsaber-hook/shared/utils/typedefs.h"

namespace BSML::DataCache {
namespace FSML::DataCache {
class Entry;
/// @brief Registers an entry in the datacache.
/// @param key the key to use in your BSML file if you want to use this data as a source
/// @param key the key to use in your FSML file if you want to use this data as a source
/// @param value the entry to register
void RegisterEntry(std::string key, const Entry* value);

class Entry {
public:
Entry(std::string key) { BSML::DataCache::RegisterEntry(key, this); }
Entry(std::string key) { FSML::DataCache::RegisterEntry(key, this); }
virtual ArrayW<uint8_t> get_data() const = 0;
};
}

/** define used by BSML to get data from your mod into a cache to be used by anything that requires access to data within a mod for things like images
/** define used by FSML to get data from your mod into a cache to be used by anything that requires access to data within a mod for things like images
* Make sure it returns a valid ArrayW<uint8_t>
* if you want to use the data registered this way in your BSML file, use it like this:
* if you want to use the data registered this way in your FSML file, use it like this:
*
* say my mod is Qosmetics, and uses the MOD_ID Qosmetics.
* if I wanted to use a data key, it'd look like this in my BSML file: Qosmetics_sabericon
* sabericon is what I typed into the BSML_DATACACHE macro as you can see below:
* if I wanted to use a data key, it'd look like this in my FSML file: Qosmetics_sabericon
* sabericon is what I typed into the FSML_DATACACHE macro as you can see below:
*
* BSML_DATACACHE(sabericon) {
* FSML_DATACACHE(sabericon) {
* return IncludedAssets::sabericon_png;
* }
*
* the keys are prepended with your MOD_ID to prevent key collisions with other mods
*/
#define BSML_DATACACHE(key)\
class BSMLDataCacheEntry_##key : public BSML::DataCache::Entry {\
#define FSML_DATACACHE(key)\
class FSMLDataCacheEntry_##key : public FSML::DataCache::Entry {\
public:\
BSMLDataCacheEntry_##key() : BSML::DataCache::Entry(MOD_ID "_" #key) {}\
FSMLDataCacheEntry_##key() : FSML::DataCache::Entry(MOD_ID "_" #key) {}\
ArrayW<uint8_t> get_data() const override;\
};\
static const BSMLDataCacheEntry_##key BSMLDataCacheEntry_##key##_instance{};\
ArrayW<uint8_t> BSMLDataCacheEntry_##key::get_data() const
static const FSMLDataCacheEntry_##key FSMLDataCacheEntry_##key##_instance{};\
ArrayW<uint8_t> FSMLDataCacheEntry_##key::get_data() const
6 changes: 6 additions & 0 deletions include/FSMLDataCache_internal.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once
#include "FSMLDataCache.hpp"

namespace FSML::DataCache {
const Entry* Get(std::string key);
}
4 changes: 2 additions & 2 deletions include/Helpers/creation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "UnityEngine/Transform.hpp"
#include "UnityEngine/Vector2.hpp"

namespace BSML::Helpers {
namespace FSML::Helpers {
/// @brief creates a text object
/// @param parent the parent transform of the text object
/// @param text the string to write
Expand Down Expand Up @@ -70,7 +70,7 @@ namespace BSML::Helpers {
/// @param object the object to add the hoverhint to
/// @param text the text to display in the hoverhint
/// @return the hoverhint
template<BSML::Concepts::HasGameObject T>
template<FSML::Concepts::HasGameObject T>
HMUI::HoverHint* AddHoverHint(T object, StringW text) {
return AddHoverHint(object->get_gameObject(), text);
}
Expand Down
2 changes: 1 addition & 1 deletion include/Helpers/delegates.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "fmt/format.h"

namespace BSML {
namespace FSML {
/// @brief struct to check argcount
template <int argc, int check>
struct check_count_equals {
Expand Down
2 changes: 1 addition & 1 deletion include/Helpers/extension.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

#include "UnityEngine/UI/Button.hpp"

namespace BSML::Helpers {
namespace FSML::Helpers {
void SetButtonText(UnityEngine::UI::Button* button, StringW text);
}
2 changes: 1 addition & 1 deletion include/Helpers/getters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "GlobalNamespace/IVRPlatformHelper.hpp"
#include "GlobalNamespace/MainFlowCoordinator.hpp"

namespace BSML::Helpers {
namespace FSML::Helpers {
VRUIControls::PhysicsRaycasterWithCache* GetPhysicsRaycasterWithCache();
Zenject::DiContainer* GetDiContainer();
HMUI::HoverHintController* GetHoverHintController();
Expand Down
2 changes: 1 addition & 1 deletion include/Helpers/utilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "UnityEngine/UI/Image.hpp"
#include "System/Uri.hpp"

namespace BSML::Utilities {
namespace FSML::Utilities {
/// @brief Finds a sprite by name.
UnityEngine::Sprite* FindSpriteCached(StringW name);

Expand Down
8 changes: 4 additions & 4 deletions include/concepts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
#include "UnityEngine/Transform.hpp"


namespace BSML::Concepts {
namespace FSML::Concepts {
template<typename T, typename U>
concept BSMLConvertible = std::is_convertible_v<T, U>;
concept FSMLConvertible = std::is_convertible_v<T, U>;

template<typename T>
concept HasGameObject = !BSMLConvertible<T, UnityEngine::GameObject*> && requires (T a) { {a->get_gameObject() } -> BSMLConvertible<UnityEngine::GameObject*>; };
concept HasGameObject = !FSMLConvertible<T, UnityEngine::GameObject*> && requires (T a) { {a->get_gameObject() } -> FSMLConvertible<UnityEngine::GameObject*>; };

template<typename T>
concept HasTransform = !BSMLConvertible<T, UnityEngine::Transform*> && requires (T a) { {a->get_transform() } -> BSMLConvertible<UnityEngine::Transform*>; };
concept HasTransform = !FSMLConvertible<T, UnityEngine::Transform*> && requires (T a) { {a->get_transform() } -> FSMLConvertible<UnityEngine::Transform*>; };
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#include "main.hpp"
#include "BSML/Animations/AnimationController.hpp"
#include "FSML/Animations/AnimationController.hpp"


#include "UnityEngine/GameObject.hpp"
#include <chrono>

DEFINE_TYPE(BSML, AnimationController);
DEFINE_TYPE(FSML, AnimationController);

namespace BSML {
namespace FSML {
SafePtrUnity<AnimationController> AnimationController::instance;
AnimationController* AnimationController::get_instance() {
if (!instance) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#include "BSML/Animations/AnimationControllerData.hpp"
#include "FSML/Animations/AnimationControllerData.hpp"

#include "Helpers/utilities.hpp"

#include "UnityEngine/SpriteMeshType.hpp"
#include "UnityEngine/Texture2D.hpp"
#include <chrono>

DEFINE_TYPE(BSML, AnimationControllerData);
DEFINE_TYPE(FSML, AnimationControllerData);


namespace BSML {
namespace FSML {
AnimationControllerData* AnimationControllerData::Make_new(UnityEngine::Texture2D* tex, ArrayW<UnityEngine::Rect> uvs, ArrayW<float> delays) {
auto self = AnimationControllerData::New_ctor();
// Init uvIndex to 0 for force frame drawing thing
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "BSML/Animations/AnimationInfo.hpp"
#include "FSML/Animations/AnimationInfo.hpp"

namespace BSML {
namespace FSML {
AnimationInfo::~AnimationInfo() {
for (auto f : frames) { if (f) delete f; }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "main.hpp"
#include "BSML/Animations/AnimationLoader.hpp"
#include "BSML/Animations/GIF/GifDecoder.hpp"
#include "FSML/Animations/AnimationLoader.hpp"
#include "FSML/Animations/GIF/GifDecoder.hpp"


#include "UnityEngine/SystemInfo.hpp"
Expand All @@ -14,10 +14,10 @@

#include "GlobalNamespace/SharedCoroutineStarter.hpp"
#include "System/Func_1.hpp"
DEFINE_TYPE(BSML, AnimationLoader);
DEFINE_TYPE(FSML, AnimationLoader);


namespace BSML {
namespace FSML {
int get_atlasSizeLimit() {
using GetMaxTextureSize = function_ptr_t<int>;
static auto getMaxTextureSize = reinterpret_cast<GetMaxTextureSize>(il2cpp_functions::resolve_icall("UnityEngine.SystemInfo::GetMaxTextureSize"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "BSML/Animations/AnimationStateUpdater.hpp"
#include "FSML/Animations/AnimationStateUpdater.hpp"

DEFINE_TYPE(BSML, AnimationStateUpdater);
DEFINE_TYPE(FSML, AnimationStateUpdater);

namespace BSML {
namespace FSML {
AnimationControllerData* AnimationStateUpdater::get_controllerData() {
return controllerData;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "BSML/Animations/GIF/GifDecoder.hpp"
#include "FSML/Animations/GIF/GifDecoder.hpp"
#include "main.hpp"
#include "Helpers/delegates.hpp"

Expand Down Expand Up @@ -34,7 +34,7 @@ inline uint32_t make_black_transparent(const uint32_t& v) {
return v >> 8 ? v : 0;
}

namespace BSML {
namespace FSML {

custom_types::Helpers::Coroutine GifDecoder::Process(ArrayW<uint8_t> data, std::function<void(AnimationInfo*)> onFinished) {
auto animationInfo = new AnimationInfo();
Expand Down
4 changes: 2 additions & 2 deletions src/BSMLDataCache.cpp → src/FSMLDataCache.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "BSMLDataCache_internal.hpp"
#include "FSMLDataCache_internal.hpp"
#include "main.hpp"
#include <map>

namespace BSML::DataCache {
namespace FSML::DataCache {
std::map<std::string, const Entry*> dataCache;
void RegisterEntry(std::string key, const Entry* value) {
INFO("Registering Data, Key: {}", key);
Expand Down
2 changes: 1 addition & 1 deletion src/Helpers/creation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
using namespace UnityEngine;
using namespace TMPro;

namespace BSML::Helpers {
namespace FSML::Helpers {
TMP_Text* CreateText(System::Type* type, UnityEngine::Transform* parent, StringW text, Vector2 anchoredPosition, Vector2 sizeDelta) {
auto gameObj = GameObject::New_ctor("CustomUIText");
gameObj->SetActive(false);
Expand Down
2 changes: 1 addition & 1 deletion src/Helpers/extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using namespace TMPro;
using namespace UnityEngine;
using namespace UnityEngine::UI;

namespace BSML::Helpers {
namespace FSML::Helpers {
void SetButtonText(Button* button, StringW text) {
auto localizer = button->GetComponentInChildren<Polyglot::LocalizedTextMeshProUGUI*>(true);
if (localizer)
Expand Down
2 changes: 1 addition & 1 deletion src/Helpers/getters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ using namespace GlobalNamespace;

#define CacheNotFoundWarningLog(type) WARNING("Can't find '{}'! (This shouldn't happen and can cause unexpected behaviour)", #type)

namespace BSML::Helpers {
namespace FSML::Helpers {
SafePtr<PhysicsRaycasterWithCache> physicsRaycaster;
PhysicsRaycasterWithCache* GetPhysicsRaycasterWithCache()
{
Expand Down
12 changes: 6 additions & 6 deletions src/Helpers/utilities.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Helpers/utilities.hpp"
#include "BSMLDataCache_internal.hpp"
#include "FSMLDataCache_internal.hpp"
#include "main.hpp"

#include "GlobalNamespace/SharedCoroutineStarter.hpp"
Expand All @@ -21,10 +21,10 @@
#include "UnityEngine/Networking/DownloadHandler.hpp"
#include "UnityEngine/Networking/UnityWebRequestAsyncOperation.hpp"

#include "BSML/Animations/AnimationStateUpdater.hpp"
#include "BSML/Animations/AnimationController.hpp"
#include "BSML/Animations/AnimationControllerData.hpp"
#include "BSML/Animations/AnimationLoader.hpp"
#include "FSML/Animations/AnimationStateUpdater.hpp"
#include "FSML/Animations/AnimationController.hpp"
#include "FSML/Animations/AnimationControllerData.hpp"
#include "FSML/Animations/AnimationLoader.hpp"

#include "System/Uri.hpp"
#include "Utils/Utils.hpp"
Expand All @@ -39,7 +39,7 @@
using namespace UnityEngine;
using namespace UnityEngine::Networking;

namespace BSML::Utilities {
namespace FSML::Utilities {

template<typename T, typename U>
using Dictionary = System::Collections::Generic::Dictionary_2<T, U>;
Expand Down
6 changes: 3 additions & 3 deletions src/ImageView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void NyaUtils::ImageView::GetImage(std::function<void(bool success)> finished)
int randomIndex = Nya::Utils::random(0, fileList.size()-1);

auto path = fileList[randomIndex];
BSML::Utilities::SetImage(this->imageView, "file://" + path, true, BSML::Utilities::ScaleOptions(),[finished, this]() {
FSML::Utilities::SetImage(this->imageView, "file://" + path, true, FSML::Utilities::ScaleOptions(),[finished, this]() {
if (finished != nullptr) finished(true);
});
}
Expand Down Expand Up @@ -192,7 +192,7 @@ void NyaUtils::ImageView::GetImage(std::function<void(bool success)> finished)
this->tempName = fileFullName;
this->isNSFW = NSFWEnabled;

BSML::Utilities::SetImage(this->imageView, "file://" + path, true, BSML::Utilities::ScaleOptions(),[finished, this]() {
FSML::Utilities::SetImage(this->imageView, "file://" + path, true, FSML::Utilities::ScaleOptions(),[finished, this]() {
if (finished != nullptr) finished(true);
});
}
Expand All @@ -218,7 +218,7 @@ void NyaUtils::ImageView::GetImage(std::function<void(bool success)> finished)

void NyaUtils::ImageView::SetErrorImage()
{
BSML::Utilities::RemoveAnimationUpdater(this->imageView);
FSML::Utilities::RemoveAnimationUpdater(this->imageView);
this->imageView->set_sprite(QuestUI::BeatSaberUI::ArrayToSprite(IncludedAssets::Chocola_Dead_png));
}

Expand Down

0 comments on commit f2a57ba

Please sign in to comment.