Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenAlex committed Jul 28, 2024
1 parent 6489c1e commit 7fc20f4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 28 deletions.
15 changes: 7 additions & 8 deletions include/logging.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Paper::LogLevel::INF>(str, "BetterSongSearch" __VA_OPT__(, __VA_ARGS__))
//#define LOG_DEBUG(value...)
#define DEBUG(str, ...) Paper::Logger::fmtLogTag<Paper::LogLevel::DBG>(str, "BetterSongSearch" __VA_OPT__(, __VA_ARGS__))
//#define LOG_ERROR(value...)
#define ERROR(str, ...) Paper::Logger::fmtLogTag<Paper::LogLevel::ERR>(str, "BetterSongSearch" __VA_OPT__(, __VA_ARGS__))
#define WARNING(str, ...) Paper::Logger::fmtLogTag<Paper::LogLevel::WRN>(str, "BetterSongSearch" __VA_OPT__(, __VA_ARGS__))
#define CRITICAL(str, ...) Paper::Logger::fmtLogTag<Paper::LogLevel::CRIT>(str, "BetterSongSearch" __VA_OPT__(, __VA_ARGS__))
static constexpr auto Logger = Paper::ConstLoggerContext(MOD_ID);

#define INFO(str, ...) Paper::Logger::fmtLogTag<Paper::LogLevel::INF>(str, MOD_ID __VA_OPT__(, __VA_ARGS__))
#define DEBUG(str, ...) Paper::Logger::fmtLogTag<Paper::LogLevel::DBG>(str, MOD_ID __VA_OPT__(, __VA_ARGS__))
#define ERROR(str, ...) Paper::Logger::fmtLogTag<Paper::LogLevel::ERR>(str, MOD_ID __VA_OPT__(, __VA_ARGS__))
#define WARNING(str, ...) Paper::Logger::fmtLogTag<Paper::LogLevel::WRN>(str, MOD_ID __VA_OPT__(, __VA_ARGS__))
#define CRITICAL(str, ...) Paper::Logger::fmtLogTag<Paper::LogLevel::CRIT>(str, MOD_ID __VA_OPT__(, __VA_ARGS__))
5 changes: 1 addition & 4 deletions include/main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
#include "UnityEngine/GameObject.hpp"
22 changes: 6 additions & 16 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,14 @@ 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) {
info.id = MOD_ID;
info.version = VERSION;
modInfo.assign(info);

getConfig().Load(); // Load the config file
getPluginConfig().Init(modInfo);
getConfig().Reload();
getConfig().Write();
INFO("Completed setup!");

std::thread([]{
Expand Down Expand Up @@ -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();
}

0 comments on commit 7fc20f4

Please sign in to comment.