Skip to content

Commit

Permalink
Merge pull request #54 from darknight1050/dev/unity2021
Browse files Browse the repository at this point in the history
Dev/unity2021
  • Loading branch information
RedBrumbler authored Feb 13, 2024
2 parents c3f1788 + 0c2078a commit 368c29e
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 48 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)

# stop symbol leaking
add_link_options(-Wl,--exclude-libs,ALL)
# compile options used
add_compile_options(-frtti -fPIE -fPIC -fexceptions -O3 -Wno-invalid-offsetof)
add_compile_options(-frtti -fPIE -fPIC -fexceptions -O3 -Wno-invalid-offsetof -fvisibility=hidden)
# compile definitions used
add_compile_definitions(VERSION=\"${MOD_VERSION}\")
add_compile_definitions(MOD_ID=\"${MOD_ID}\")
Expand Down
43 changes: 23 additions & 20 deletions qpm.shared.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@
{
"dependency": {
"id": "bsml",
"versionRange": "=0.4.5",
"versionRange": "=0.4.7",
"additionalData": {
"soLink": "https://github.com/RedBrumbler/Quest-BSML/releases/download/v0.4.5/libbsml.so",
"debugSoLink": "https://github.com/RedBrumbler/Quest-BSML/releases/download/v0.4.5/debug_libbsml.so",
"soLink": "https://github.com/RedBrumbler/Quest-BSML/releases/download/v0.4.7/libbsml.so",
"debugSoLink": "https://github.com/RedBrumbler/Quest-BSML/releases/download/v0.4.7/debug_libbsml.so",
"overrideSoName": "libbsml.so",
"modLink": "https://github.com/RedBrumbler/Quest-BSML/releases/download/v0.4.5/BSML.qmod",
"branchName": "version/v0_4_5",
"modLink": "https://github.com/RedBrumbler/Quest-BSML/releases/download/v0.4.7/BSML.qmod",
"branchName": "version/v0_4_7",
"cmake": true
}
},
"version": "0.4.5"
"version": "0.4.7"
},
{
"dependency": {
Expand Down Expand Up @@ -135,13 +135,13 @@
{
"dependency": {
"id": "custom-types",
"versionRange": "=0.16.14",
"versionRange": "=0.16.17",
"additionalData": {
"soLink": "https://github.com/QuestPackageManager/Il2CppQuestTypePatching/releases/download/v0.16.14/libcustom-types.so",
"debugSoLink": "https://github.com/QuestPackageManager/Il2CppQuestTypePatching/releases/download/v0.16.14/debug_libcustom-types.so",
"soLink": "https://github.com/QuestPackageManager/Il2CppQuestTypePatching/releases/download/v0.16.17/libcustom-types.so",
"debugSoLink": "https://github.com/QuestPackageManager/Il2CppQuestTypePatching/releases/download/v0.16.17/debug_libcustom-types.so",
"overrideSoName": "libcustom-types.so",
"modLink": "https://github.com/QuestPackageManager/Il2CppQuestTypePatching/releases/download/v0.16.14/CustomTypes.qmod",
"branchName": "version/v0_16_14",
"modLink": "https://github.com/QuestPackageManager/Il2CppQuestTypePatching/releases/download/v0.16.17/CustomTypes.qmod",
"branchName": "version/v0_16_17",
"compileOptions": {
"cppFlags": [
"-Wno-invalid-offsetof"
Expand All @@ -150,7 +150,7 @@
"cmake": true
}
},
"version": "0.16.14"
"version": "0.16.17"
},
{
"dependency": {
Expand Down Expand Up @@ -178,15 +178,15 @@
{
"dependency": {
"id": "beatsaber-hook",
"versionRange": "=5.0.7",
"versionRange": "=5.0.9",
"additionalData": {
"soLink": "https://github.com/QuestPackageManager/beatsaber-hook/releases/download/v5.0.7/libbeatsaber-hook_5_0_7.so",
"debugSoLink": "https://github.com/QuestPackageManager/beatsaber-hook/releases/download/v5.0.7/debug_libbeatsaber-hook_5_0_7.so",
"branchName": "version/v5_0_7",
"soLink": "https://github.com/QuestPackageManager/beatsaber-hook/releases/download/v5.0.9/libbeatsaber-hook_5_0_9.so",
"debugSoLink": "https://github.com/QuestPackageManager/beatsaber-hook/releases/download/v5.0.9/debug_libbeatsaber-hook_5_0_9.so",
"branchName": "version/v5_0_9",
"cmake": true
}
},
"version": "5.0.7"
"version": "5.0.9"
},
{
"dependency": {
Expand Down Expand Up @@ -225,12 +225,15 @@
{
"dependency": {
"id": "scotland2",
"versionRange": "=0.1.3",
"versionRange": "=0.1.4",
"additionalData": {
"overrideSoName": "libsl2.so"
"soLink": "https://github.com/sc2ad/scotland2/releases/download/v0.1.4/libsl2.so",
"debugSoLink": "https://github.com/sc2ad/scotland2/releases/download/v0.1.4/debug_libsl2.so",
"overrideSoName": "libsl2.so",
"branchName": "version/v0_1_4"
}
},
"version": "0.1.3"
"version": "0.1.4"
}
]
}
49 changes: 25 additions & 24 deletions shared/API.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "./_config.h"
#include <string>

#include "GlobalNamespace/CustomPreviewBeatmapLevel.hpp"
Expand All @@ -13,61 +14,61 @@
namespace RuntimeSongLoader::API {

/// @brief Loads Songs on disk. This will reload already loaded songs
void RefreshSongs();
SONGLOADER_EXPORT void RefreshSongs();

/// @brief Loads Songs on disk
/// @tparam fullRefresh If it should reload already loaded songs
/// @tparam songsLoaded gets called after songs got loaded
void RefreshSongs(bool fullRefresh, std::function<void(std::vector<GlobalNamespace::CustomPreviewBeatmapLevel*> const&)> const& songsLoaded = nullptr);
SONGLOADER_EXPORT void RefreshSongs(bool fullRefresh, std::function<void(std::vector<GlobalNamespace::CustomPreviewBeatmapLevel*> const&)> const& songsLoaded = nullptr);

/// @brief Loads Packs on disk
/// @tparam includeDefault If the default custom levels playlists should be added
void RefreshPacks(bool includeDefault = true);
SONGLOADER_EXPORT void RefreshPacks(bool includeDefault = true);

/// @brief Add a loading callback that gets called after songs got loaded
/// @tparam event Callback event
void AddSongsLoadedEvent(std::function<void(std::vector<GlobalNamespace::CustomPreviewBeatmapLevel*> const&)> const& event);
SONGLOADER_EXPORT void AddSongsLoadedEvent(std::function<void(std::vector<GlobalNamespace::CustomPreviewBeatmapLevel*> const&)> const& event);

/// @brief Add a callback that gets called before level packs get refreshed
/// @tparam event Callback event
void AddRefreshLevelPacksEvent(std::function<void(SongLoaderBeatmapLevelPackCollectionSO*)> const& event);
SONGLOADER_EXPORT void AddRefreshLevelPacksEvent(std::function<void(SongLoaderBeatmapLevelPackCollectionSO*)> const& event);

/// @brief Add a callback that gets called after it tried to load a BeatmapData
/// @tparam event Callback event
void AddBeatmapDataBasicInfoLoadedEvent(std::function<void(CustomJSONData::CustomLevelInfoSaveData*, std::string const&, BeatmapSaveDataVersion3::BeatmapSaveData*, GlobalNamespace::BeatmapDataBasicInfo*)> const& event);
SONGLOADER_EXPORT void AddBeatmapDataBasicInfoLoadedEvent(std::function<void(CustomJSONData::CustomLevelInfoSaveData*, std::string const&, BeatmapSaveDataVersion3::BeatmapSaveData*, GlobalNamespace::BeatmapDataBasicInfo*)> const& event);

/// @brief Add a callback that gets called when a song is deleted
/// @tparam event Callback event
void AddSongDeletedEvent(std::function<void()> const& event);
SONGLOADER_EXPORT void AddSongDeletedEvent(std::function<void()> const& event);

/// @brief Delets a song on filesystem (doesn't refresh songs)
/// @tparam path Path to the song on filesystem
/// @tparam finished Callback once done
void DeleteSong(std::string_view path, std::function<void()> const& finished = nullptr);
std::vector<GlobalNamespace::CustomPreviewBeatmapLevel*> GetLoadedSongs();
SONGLOADER_EXPORT void DeleteSong(std::string_view path, std::function<void()> const& finished = nullptr);

SONGLOADER_EXPORT std::vector<GlobalNamespace::CustomPreviewBeatmapLevel*> GetLoadedSongs();

/// @brief If songs did get loaded
bool HasLoadedSongs();
SONGLOADER_EXPORT bool HasLoadedSongs();

/// @brief gets how far along the loading progress the songloader is
float GetLoadingProgress();
SONGLOADER_EXPORT float GetLoadingProgress();

SONGLOADER_EXPORT std::optional<GlobalNamespace::CustomPreviewBeatmapLevel*> GetLevelByHash(std::string hash);

std::optional<GlobalNamespace::CustomPreviewBeatmapLevel*> GetLevelByHash(std::string hash);

std::optional<GlobalNamespace::CustomPreviewBeatmapLevel*> GetLevelById(std::string_view levelID);
SONGLOADER_EXPORT std::optional<GlobalNamespace::CustomPreviewBeatmapLevel*> GetLevelById(std::string_view levelID);

std::string GetCustomLevelsPrefix();
SONGLOADER_EXPORT std::string GetCustomLevelsPrefix();

std::string GetCustomLevelPacksPrefix();
SONGLOADER_EXPORT std::string GetCustomLevelPacksPrefix();

std::string GetCustomLevelsPath();
SONGLOADER_EXPORT std::string GetCustomLevelsPath();

std::string GetCustomWIPLevelsPath();
SONGLOADER_EXPORT std::string GetCustomWIPLevelsPath();

/// @brief gets custom levels pack from the songloader instance
RuntimeSongLoader::SongLoaderCustomBeatmapLevelPack* GetCustomLevelsPack();
SONGLOADER_EXPORT RuntimeSongLoader::SongLoaderCustomBeatmapLevelPack* GetCustomLevelsPack();

/// @brief gets custom wip levels collection from the songloader instance
RuntimeSongLoader::SongLoaderCustomBeatmapLevelPack* GetCustomWIPLevelsPack();
}
SONGLOADER_EXPORT RuntimeSongLoader::SongLoaderCustomBeatmapLevelPack* GetCustomWIPLevelsPack();
}
8 changes: 8 additions & 0 deletions shared/_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

#define SONGLOADER_EXPORT __attribute__((visibility("default")))
#ifdef __cplusplus
#define SONGLOADER_EXPORT_FUNC extern "C" SONGLOADER_EXPORT
#else
#define SONGLOADER_EXPORT_FUNC SONGLOADER_EXPORT
#endif
4 changes: 3 additions & 1 deletion src/CustomBeatmapLevelLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,11 @@ namespace RuntimeSongLoader::CustomBeatmapLevelLoader {
[=] {
try {
self->_loadedBeatmapLevels->PutToCache(levelID, reinterpret_cast<IBeatmapLevel*>(customBeatmapLevel));
} catch (std::runtime_error const& e) {
} catch (std::exception const& e) {
getLogger().Backtrace(20);
LOG_ERROR("CustomBeatmapLevelLoader_GetBeatmapLevelAsync Failed to put (%s) to cache: %s!", static_cast<std::string>(levelID).c_str(), e.what());
} catch (...) {
LOG_ERROR("CustomBeatmapLevelLoader_GetBeatmapLevelAsync Failed to put (%s) to cache! unknown exception (not std::exception) with no known what() method!", static_cast<std::string>(levelID).c_str());
}
}
);
Expand Down
6 changes: 4 additions & 2 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,9 @@ MAKE_HOOK_MATCH(PlayerDataFileManagerSO_LoadFromCurrentVersion, &PlayerDataFileM
return PlayerDataFileManagerSO_LoadFromCurrentVersion(self, playerSaveData, beatmapCharacteristicCollection);
}

extern "C" void setup(CModInfo* info) {
SONGLOADER_EXPORT_FUNC void setup(CModInfo* info) {
LOG_INFO("Starting SongLoader installation...");

info->id = "SongLoader";
info->version = VERSION;
info->version_long = 0;
Expand All @@ -323,7 +325,7 @@ extern "C" void setup(CModInfo* info) {
LOG_INFO("Base path is: %s", baseLevelsPath.c_str());
}

extern "C" void late_load() {
SONGLOADER_EXPORT_FUNC void late_load() {
LOG_INFO("Starting SongLoader installation...");

BSML::Init();
Expand Down

0 comments on commit 368c29e

Please sign in to comment.