Do not use SKSE messaging in the Steam DLL, TestMode is off by default
This commit is contained in:
parent
fec0932935
commit
6782dbcde9
@ -6,7 +6,7 @@ message("Using toolchain file ${CMAKE_TOOLCHAIN_FILE}.")
|
|||||||
########################################################################################################################
|
########################################################################################################################
|
||||||
project(
|
project(
|
||||||
EnderalSteam
|
EnderalSteam
|
||||||
VERSION 1.0.0
|
VERSION 1.0.1
|
||||||
DESCRIPTION "Enderal SE Steam Support"
|
DESCRIPTION "Enderal SE Steam Support"
|
||||||
LANGUAGES CXX)
|
LANGUAGES CXX)
|
||||||
set(CMAKE_CXX_STANDARD 23)
|
set(CMAKE_CXX_STANDARD 23)
|
||||||
|
@ -10,7 +10,7 @@ namespace Achievements {
|
|||||||
{
|
{
|
||||||
std::map<std::string, bool> settings{
|
std::map<std::string, bool> settings{
|
||||||
{ "SendAchievementsToLE", false },
|
{ "SendAchievementsToLE", false },
|
||||||
{ "TestMode", true },
|
{ "TestMode", false },
|
||||||
{ "ShowWarningOnInitFail", true }
|
{ "ShowWarningOnInitFail", true }
|
||||||
};
|
};
|
||||||
LoadINI(&settings, "Data/SKSE/Plugins/EnderalSteam.ini");
|
LoadINI(&settings, "Data/SKSE/Plugins/EnderalSteam.ini");
|
||||||
@ -36,9 +36,9 @@ namespace Achievements {
|
|||||||
bool success = SteamAPI_Init();
|
bool success = SteamAPI_Init();
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
logger::info("Steam api init was successfull");
|
logger::info("{}", "Steam api init was successfull");
|
||||||
} else {
|
} else {
|
||||||
logger::error("Error while initializing the steam api");
|
logger::error("{}", "Error while initializing the steam api");
|
||||||
if (settings.at("ShowWarningOnInitFail")) {
|
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.");
|
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());
|
SteamInstance(new AchievementHolder());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logger::info("Already initialized steam api, skipping it");
|
logger::info("{}", "Already initialized steam api, skipping it");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const std::exception& ex) {
|
catch (const std::exception& ex) {
|
||||||
std::string msg = "Exception while initializing the Steam API, steam achievements will not be available: " + std::string(ex.what());
|
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")) {
|
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.");
|
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) {
|
void AchievementHolder::onUserStatsReceived(UserStatsReceived_t * event) {
|
||||||
try {
|
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);
|
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();
|
uint32 achievementCount = this->stats->GetNumAchievements();
|
||||||
msg = "There are " + std::to_string(achievementCount) + " achievements";
|
msg = "There are " + std::to_string(achievementCount) + " achievements";
|
||||||
logger::info(msg.c_str());
|
logger::info("{}", msg.c_str());
|
||||||
}
|
}
|
||||||
catch (const std::exception& ex) {
|
catch (const std::exception& ex) {
|
||||||
std::string msg = "Exception during steam callback: onUserStatsReceived. Failed to print data: " + std::string(ex.what());
|
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)
|
bool AchievementHolder::setAchievementUnlocked(const char * achievementName)
|
||||||
{
|
{
|
||||||
std::string msg = "Unlocking achievement: " + std::string(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);
|
bool success = this->stats->SetAchievement(achievementName);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
logger::error("Error while unlocking achievement");
|
logger::error("{}", "Error while unlocking achievement");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
success = this->stats->StoreStats();
|
success = this->stats->StoreStats();
|
||||||
if (!success) {
|
if (!success) {
|
||||||
logger::error("Error while storing unlocked achievement");
|
logger::error("{}", "Error while storing unlocked achievement");
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
@ -19,11 +19,9 @@ auto EventListener::ProcessEvent(
|
|||||||
-> RE::BSEventNotifyControl
|
-> RE::BSEventNotifyControl
|
||||||
{
|
{
|
||||||
if (a_event->opening && a_event->menuName == "Main Menu") {
|
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<RE::MenuOpenCloseEvent>(GetSingleton());
|
RE::UI::GetSingleton()->RemoveEventSink<RE::MenuOpenCloseEvent>(GetSingleton());
|
||||||
|
logger::info("{}", "Main menu opened, trying to init steam API.");
|
||||||
|
Achievements::startSteam();
|
||||||
}
|
}
|
||||||
|
|
||||||
return RE::BSEventNotifyControl::kContinue;
|
return RE::BSEventNotifyControl::kContinue;
|
||||||
|
@ -24,15 +24,6 @@ namespace {
|
|||||||
spdlog::set_default_logger(std::move(log));
|
spdlog::set_default_logger(std::move(log));
|
||||||
spdlog::set_pattern("[%l] %v"s);
|
spdlog::set_pattern("[%l] %v"s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitializeMessaging()
|
|
||||||
{
|
|
||||||
GetMessagingInterface()->RegisterListener([](MessagingInterface::Message* message) {
|
|
||||||
if (message->type == MessagingInterface::kPostLoad) {
|
|
||||||
EventListener::Install();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SKSEPluginLoad(const LoadInterface* skse) {
|
SKSEPluginLoad(const LoadInterface* skse) {
|
||||||
@ -46,7 +37,8 @@ SKSEPluginLoad(const LoadInterface* skse) {
|
|||||||
logger::info("{} {} is loading...", plugin->GetName(), version);
|
logger::info("{} {} is loading...", plugin->GetName(), version);
|
||||||
|
|
||||||
Init(skse);
|
Init(skse);
|
||||||
InitializeMessaging();
|
|
||||||
|
EventListener::Install();
|
||||||
|
|
||||||
GetPapyrusInterface()->Register(Papyrus::Bind);
|
GetPapyrusInterface()->Register(Papyrus::Bind);
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ namespace Papyrus
|
|||||||
bool Bind(VM* a_vm)
|
bool Bind(VM* a_vm)
|
||||||
{
|
{
|
||||||
if (!a_vm) {
|
if (!a_vm) {
|
||||||
logger::critical("couldn't get VM State"sv);
|
logger::critical("{}", "couldn't get VM State"sv);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ namespace Papyrus::PapyrusFunctions
|
|||||||
return SteamInstance()->setAchievementUnlocked(achievement.c_str());
|
return SteamInstance()->setAchievementUnlocked(achievement.c_str());
|
||||||
} else {
|
} else {
|
||||||
RE::DebugNotification(std::format("Achievement unlocked: {}", achievement.c_str()).c_str());
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -19,6 +19,6 @@ namespace Papyrus::PapyrusFunctions
|
|||||||
inline void Bind(VM& a_vm)
|
inline void Bind(VM& a_vm)
|
||||||
{
|
{
|
||||||
BIND(CallUnlockAchievement);
|
BIND(CallUnlockAchievement);
|
||||||
logger::info("Registered CallUnlockAchievement"sv);
|
logger::info("{}", "Registered CallUnlockAchievement"sv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,6 @@ inline void LoadINI(std::map<std::string, bool>* settings, const char* iniPath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
logger::error(e.what());
|
logger::error("{}", e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json",
|
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json",
|
||||||
"name": "enderal-se-steam",
|
"name": "enderal-se-steam",
|
||||||
"version-string": "1.0.0",
|
"version-string": "1.0.1",
|
||||||
"port-version": 0,
|
"port-version": 0,
|
||||||
"description": "Enderal SE Steam Support",
|
"description": "Enderal SE Steam Support",
|
||||||
"homepage": "https://eddoursul.win/mods/enderal-se/",
|
"homepage": "https://eddoursul.win/mods/enderal-se/",
|
||||||
|
Loading…
Reference in New Issue
Block a user