diff --git a/source/Steam DLL/CMakeLists.txt b/source/Steam DLL/CMakeLists.txt index e996a274..8e98c388 100644 --- a/source/Steam DLL/CMakeLists.txt +++ b/source/Steam DLL/CMakeLists.txt @@ -6,7 +6,7 @@ message("Using toolchain file ${CMAKE_TOOLCHAIN_FILE}.") ######################################################################################################################## project( EnderalSteam - VERSION 1.0.0 + VERSION 1.0.1 DESCRIPTION "Enderal SE Steam Support" LANGUAGES CXX) set(CMAKE_CXX_STANDARD 23) diff --git a/source/Steam DLL/src/Achievements.cpp b/source/Steam DLL/src/Achievements.cpp index d026ed17..03d7f08a 100644 --- a/source/Steam DLL/src/Achievements.cpp +++ b/source/Steam DLL/src/Achievements.cpp @@ -10,7 +10,7 @@ namespace Achievements { { std::map settings{ { "SendAchievementsToLE", false }, - { "TestMode", true }, + { "TestMode", false }, { "ShowWarningOnInitFail", true } }; LoadINI(&settings, "Data/SKSE/Plugins/EnderalSteam.ini"); @@ -36,9 +36,9 @@ namespace Achievements { bool success = SteamAPI_Init(); if (success) { - logger::info("Steam api init was successfull"); + logger::info("{}", "Steam api init was successfull"); } else { - logger::error("Error while initializing the steam api"); + logger::error("{}", "Error while initializing the steam api"); if (settings.at("ShowWarningOnInitFail")) { RE::DebugMessageBox("Unable to initialize Steam achievements. Try to restart the game and the Steam client. This warning can be disabled in SKSE\\Plugins\\EnderalSteam.ini."); } @@ -47,12 +47,12 @@ namespace Achievements { SteamInstance(new AchievementHolder()); } else { - logger::info("Already initialized steam api, skipping it"); + logger::info("{}", "Already initialized steam api, skipping it"); } } catch (const std::exception& ex) { std::string msg = "Exception while initializing the Steam API, steam achievements will not be available: " + std::string(ex.what()); - logger::error(msg.c_str()); + logger::error("{}", msg.c_str()); if (settings.at("ShowWarningOnInitFail")) { RE::DebugMessageBox("Unable to initialize Steam achievements. Try to restart the game and the Steam client. This warning can be disabled in SKSE\\Plugins\\EnderalSteam.ini."); } @@ -66,30 +66,30 @@ namespace Achievements { void AchievementHolder::onUserStatsReceived(UserStatsReceived_t * event) { try { std::string msg = "User id: " + std::to_string(event->m_steamIDUser.ConvertToUint64()) + ", game id: " + std::to_string(event->m_nGameID) + ", success state: " + std::to_string(event->m_eResult); - logger::info(msg.c_str()); + logger::info("{}", msg.c_str()); uint32 achievementCount = this->stats->GetNumAchievements(); msg = "There are " + std::to_string(achievementCount) + " achievements"; - logger::info(msg.c_str()); + logger::info("{}", msg.c_str()); } catch (const std::exception& ex) { std::string msg = "Exception during steam callback: onUserStatsReceived. Failed to print data: " + std::string(ex.what()); - logger::info(msg.c_str()); + logger::info("{}", msg.c_str()); } } bool AchievementHolder::setAchievementUnlocked(const char * achievementName) { std::string msg = "Unlocking achievement: " + std::string(achievementName); - logger::info(msg.c_str()); + logger::info("{}", msg.c_str()); bool success = this->stats->SetAchievement(achievementName); if (!success) { - logger::error("Error while unlocking achievement"); + logger::error("{}", "Error while unlocking achievement"); return false; } success = this->stats->StoreStats(); if (!success) { - logger::error("Error while storing unlocked achievement"); + logger::error("{}", "Error while storing unlocked achievement"); } return success; } diff --git a/source/Steam DLL/src/EventListener.cpp b/source/Steam DLL/src/EventListener.cpp index 5928fa7b..16805479 100644 --- a/source/Steam DLL/src/EventListener.cpp +++ b/source/Steam DLL/src/EventListener.cpp @@ -19,11 +19,9 @@ auto EventListener::ProcessEvent( -> RE::BSEventNotifyControl { if (a_event->opening && a_event->menuName == "Main Menu") { - SKSE::GetTaskInterface()->AddTask([]() { - logger::info("Main menu opened, trying to init steam API."); - Achievements::startSteam(); - }); RE::UI::GetSingleton()->RemoveEventSink(GetSingleton()); + logger::info("{}", "Main menu opened, trying to init steam API."); + Achievements::startSteam(); } return RE::BSEventNotifyControl::kContinue; diff --git a/source/Steam DLL/src/Main.cpp b/source/Steam DLL/src/Main.cpp index 1d6081c2..0131027e 100644 --- a/source/Steam DLL/src/Main.cpp +++ b/source/Steam DLL/src/Main.cpp @@ -24,15 +24,6 @@ namespace { spdlog::set_default_logger(std::move(log)); spdlog::set_pattern("[%l] %v"s); } - - void InitializeMessaging() - { - GetMessagingInterface()->RegisterListener([](MessagingInterface::Message* message) { - if (message->type == MessagingInterface::kPostLoad) { - EventListener::Install(); - } - }); - } } SKSEPluginLoad(const LoadInterface* skse) { @@ -46,7 +37,8 @@ SKSEPluginLoad(const LoadInterface* skse) { logger::info("{} {} is loading...", plugin->GetName(), version); Init(skse); - InitializeMessaging(); + + EventListener::Install(); GetPapyrusInterface()->Register(Papyrus::Bind); diff --git a/source/Steam DLL/src/Papyrus.cpp b/source/Steam DLL/src/Papyrus.cpp index e11d08dd..67a2796a 100644 --- a/source/Steam DLL/src/Papyrus.cpp +++ b/source/Steam DLL/src/Papyrus.cpp @@ -6,7 +6,7 @@ namespace Papyrus bool Bind(VM* a_vm) { if (!a_vm) { - logger::critical("couldn't get VM State"sv); + logger::critical("{}", "couldn't get VM State"sv); return false; } diff --git a/source/Steam DLL/src/PapyrusFunctions.h b/source/Steam DLL/src/PapyrusFunctions.h index c153d0b9..1d273f73 100644 --- a/source/Steam DLL/src/PapyrusFunctions.h +++ b/source/Steam DLL/src/PapyrusFunctions.h @@ -11,7 +11,7 @@ namespace Papyrus::PapyrusFunctions return SteamInstance()->setAchievementUnlocked(achievement.c_str()); } else { RE::DebugNotification(std::format("Achievement unlocked: {}", achievement.c_str()).c_str()); - logger::info(std::format("Achievement unlocked: {}", achievement.c_str()).c_str()); + logger::info("{}", std::format("Achievement unlocked: {}", achievement.c_str()).c_str()); return true; } } @@ -19,6 +19,6 @@ namespace Papyrus::PapyrusFunctions inline void Bind(VM& a_vm) { BIND(CallUnlockAchievement); - logger::info("Registered CallUnlockAchievement"sv); + logger::info("{}", "Registered CallUnlockAchievement"sv); } } diff --git a/source/Steam DLL/src/Util.h b/source/Steam DLL/src/Util.h index e443aec2..0e6543f7 100644 --- a/source/Steam DLL/src/Util.h +++ b/source/Steam DLL/src/Util.h @@ -73,6 +73,6 @@ inline void LoadINI(std::map* settings, const char* iniPath) } } catch (const std::exception& e) { - logger::error(e.what()); + logger::error("{}", e.what()); } } \ No newline at end of file diff --git a/source/Steam DLL/vcpkg.json b/source/Steam DLL/vcpkg.json index 774a3a33..8299bac1 100644 --- a/source/Steam DLL/vcpkg.json +++ b/source/Steam DLL/vcpkg.json @@ -1,7 +1,7 @@ { "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json", "name": "enderal-se-steam", - "version-string": "1.0.0", + "version-string": "1.0.1", "port-version": 0, "description": "Enderal SE Steam Support", "homepage": "https://eddoursul.win/mods/enderal-se/",