From 7fc20f4df3e89480f51d3ff3ff8d145d1813239a Mon Sep 17 00:00:00 2001 From: Alex Uskov Date: Sun, 28 Jul 2024 19:54:43 +0400 Subject: [PATCH] Code cleanup --- include/logging.hpp | 15 +++++++-------- include/main.hpp | 5 +---- src/main.cpp | 22 ++++++---------------- 3 files changed, 14 insertions(+), 28 deletions(-) diff --git a/include/logging.hpp b/include/logging.hpp index b9f17a2..6e8a882 100644 --- a/include/logging.hpp +++ b/include/logging.hpp @@ -3,11 +3,10 @@ #include "beatsaber-hook/shared/utils/utils.h" #include "paper/shared/logger.hpp" -//#define LOG_INFO(value...) -#define INFO(str, ...) Paper::Logger::fmtLogTag(str, "BetterSongSearch" __VA_OPT__(, __VA_ARGS__)) -//#define LOG_DEBUG(value...) -#define DEBUG(str, ...) Paper::Logger::fmtLogTag(str, "BetterSongSearch" __VA_OPT__(, __VA_ARGS__)) -//#define LOG_ERROR(value...) -#define ERROR(str, ...) Paper::Logger::fmtLogTag(str, "BetterSongSearch" __VA_OPT__(, __VA_ARGS__)) -#define WARNING(str, ...) Paper::Logger::fmtLogTag(str, "BetterSongSearch" __VA_OPT__(, __VA_ARGS__)) -#define CRITICAL(str, ...) Paper::Logger::fmtLogTag(str, "BetterSongSearch" __VA_OPT__(, __VA_ARGS__)) +static constexpr auto Logger = Paper::ConstLoggerContext(MOD_ID); + +#define INFO(str, ...) Paper::Logger::fmtLogTag(str, MOD_ID __VA_OPT__(, __VA_ARGS__)) +#define DEBUG(str, ...) Paper::Logger::fmtLogTag(str, MOD_ID __VA_OPT__(, __VA_ARGS__)) +#define ERROR(str, ...) Paper::Logger::fmtLogTag(str, MOD_ID __VA_OPT__(, __VA_ARGS__)) +#define WARNING(str, ...) Paper::Logger::fmtLogTag(str, MOD_ID __VA_OPT__(, __VA_ARGS__)) +#define CRITICAL(str, ...) Paper::Logger::fmtLogTag(str, MOD_ID __VA_OPT__(, __VA_ARGS__)) diff --git a/include/main.hpp b/include/main.hpp index 738bbc8..9143659 100644 --- a/include/main.hpp +++ b/include/main.hpp @@ -9,7 +9,4 @@ #include "beatsaber-hook/shared/utils/hooking.hpp" #include "beatsaber-hook/shared/config/config-utils.hpp" #include "beatsaber-hook/shared/utils/il2cpp-functions.hpp" -#include "UnityEngine/GameObject.hpp" - -// Define these functions here so that we can easily read configuration and log information from other files -Configuration& getConfig(); \ No newline at end of file +#include "UnityEngine/GameObject.hpp" \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index c582749..42a99dc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -32,12 +32,6 @@ using namespace BetterSongSearch::Util; inline modloader::ModInfo modInfo = {MOD_ID, VERSION, GIT_COMMIT}; // Stores the ID and version of our mod, and is sent to the modloader upon startup -// Loads the config from disk using our modInfo, then returns it for use -Configuration& getConfig() { - static Configuration config(modInfo); - return config; -} - // Called at the early stages of game loading BSS_EXPORT_FUNC void setup(CModInfo& info) { @@ -45,10 +39,7 @@ BSS_EXPORT_FUNC void setup(CModInfo& info) { info.version = VERSION; modInfo.assign(info); - getConfig().Load(); // Load the config file getPluginConfig().Init(modInfo); - getConfig().Reload(); - getConfig().Write(); INFO("Completed setup!"); std::thread([]{ @@ -246,14 +237,13 @@ BSS_EXPORT_FUNC void late_load() { BSML::Init(); custom_types::Register::AutoRegister(); - auto logger = Paper::ConstLoggerContext("BSSHooks"); + INSTALL_HOOK(Logger, ReturnToBSS); + INSTALL_HOOK(Logger, GameplaySetupViewController_RefreshContent); + INSTALL_HOOK(Logger, LevelFilteringNavigationController_Setup); + INSTALL_HOOK(Logger, MultiplayerLevelScenesTransitionSetupDataSO_Init); - INSTALL_HOOK(logger, ReturnToBSS); - INSTALL_HOOK(logger, GameplaySetupViewController_RefreshContent); - INSTALL_HOOK(logger, LevelFilteringNavigationController_Setup); - // Auto open to BSS - // INSTALL_HOOK(logger, MainFlowCoordinator_DidActivate); - INSTALL_HOOK(logger, MultiplayerLevelScenesTransitionSetupDataSO_Init); + // Automatic testing + // INSTALL_HOOK(Logger, MainFlowCoordinator_DidActivate); manager.Init(); } \ No newline at end of file