1

Cleanup for 1.0

This commit is contained in:
Eddoursul 2022-07-14 20:36:46 +02:00
parent 41940cc4f3
commit 85581cf147
3 changed files with 14 additions and 11 deletions

Binary file not shown.

View File

@ -64,7 +64,7 @@ namespace ArtifactTracker
std::map<std::string, bool> settings{ std::map<std::string, bool> settings{
{ "DumpItemList", false }, { "DumpItemList", false },
{ "NewArtifactNotifications", true }, { "NewArtifactNotifications", false },
}; };
LoadINI(&settings, "Data/SKSE/Plugins/ArtifactTracker.ini"); LoadINI(&settings, "Data/SKSE/Plugins/ArtifactTracker.ini");
@ -177,7 +177,6 @@ namespace ArtifactTracker
std::uint32_t savedCount = g_listStored->forms.size() + g_listFound->forms.size() + g_listNew->forms.size(); std::uint32_t savedCount = g_listStored->forms.size() + g_listFound->forms.size() + g_listNew->forms.size();
if (savedCount != g_artifactMap.size()) { if (savedCount != g_artifactMap.size()) {
log::info("Reverting g_listNew");
ListRevert(g_listNew); ListRevert(g_listNew);
} }
@ -224,6 +223,8 @@ namespace ArtifactTracker
log::error("MoreHUD Inventory Edition has not been detected."); log::error("MoreHUD Inventory Edition has not been detected.");
} }
// TODO: Uncomment when/if QuickLoot EE brings back registering formlists
/*
if (const auto pluginInfo = g_loadInterface->GetPluginInfo("QuickLootEE"); pluginInfo) { if (const auto pluginInfo = g_loadInterface->GetPluginInfo("QuickLootEE"); pluginInfo) {
if (!g_bLoaded) log::info("Detected {} v{}", pluginInfo->name, pluginInfo->version); if (!g_bLoaded) log::info("Detected {} v{}", pluginInfo->name, pluginInfo->version);
if (pluginInfo->version == 0) { if (pluginInfo->version == 0) {
@ -239,6 +240,7 @@ namespace ArtifactTracker
} else if (!g_bLoaded) { } else if (!g_bLoaded) {
log::error("QuickLoot EE has not been detected."); log::error("QuickLoot EE has not been detected.");
} }
*/
} }
void SetContainerMode(const bool bOpening) void SetContainerMode(const bool bOpening)
@ -285,7 +287,6 @@ namespace ArtifactTracker
if (cellStorage) { if (cellStorage) {
g_bHomeContainer = false; g_bHomeContainer = false;
g_cellStorage = cellStorage; g_cellStorage = cellStorage;
//RE::UI::GetSingleton()->AddEventSink<RE::MenuOpenCloseEvent>(EventListener::GetSingleton());
RE::ScriptEventSourceHolder::GetSingleton()->AddEventSink<RE::TESActivateEvent>(EventListener::GetSingleton()); RE::ScriptEventSourceHolder::GetSingleton()->AddEventSink<RE::TESActivateEvent>(EventListener::GetSingleton());
#ifdef _DEBUG #ifdef _DEBUG
log::info("Home mode ON"); log::info("Home mode ON");
@ -294,7 +295,6 @@ namespace ArtifactTracker
} else if (g_cellStorage) { } else if (g_cellStorage) {
g_bHomeContainer = false; g_bHomeContainer = false;
g_cellStorage = nullptr; g_cellStorage = nullptr;
//RE::UI::GetSingleton()->RemoveEventSink<RE::MenuOpenCloseEvent>(EventListener::GetSingleton());
RE::ScriptEventSourceHolder::GetSingleton()->RemoveEventSink<RE::TESActivateEvent>(EventListener::GetSingleton()); RE::ScriptEventSourceHolder::GetSingleton()->RemoveEventSink<RE::TESActivateEvent>(EventListener::GetSingleton());
#ifdef _DEBUG #ifdef _DEBUG
log::info("Home mode OFF"); log::info("Home mode OFF");

View File

@ -2,6 +2,9 @@
#include <SimpleIni.h> #include <SimpleIni.h>
using namespace SKSE;
using namespace SKSE::log;
inline void ListRemoveItem(RE::BGSListForm* a_List, RE::TESForm* a_form) inline void ListRemoveItem(RE::BGSListForm* a_List, RE::TESForm* a_form)
{ {
using func_t = decltype(&ListRemoveItem); using func_t = decltype(&ListRemoveItem);
@ -83,7 +86,7 @@ inline std::int32_t GetItemCount(RE::TESObjectREFR* a_container, RE::FormID a_fo
inline bool RefListHasItem(RE::TESForm* a_refOrList, RE::FormID a_formID) inline bool RefListHasItem(RE::TESForm* a_refOrList, RE::FormID a_formID)
{ {
if (!a_refOrList || !a_formID) { if (!a_refOrList || !a_formID) {
SKSE::log::warn("Invalid arguments in RefHasItem"); log::warn("Invalid arguments in RefListHasItem");
return false; return false;
} }
@ -135,11 +138,11 @@ inline bool IsInSameCell(RE::TESObjectREFR* ref)
inline void LoadINI(std::map<std::string, bool>* settings, const char* iniPath) inline void LoadINI(std::map<std::string, bool>* settings, const char* iniPath)
{ {
for (auto it = settings->begin(); it != settings->end(); it++) { for (auto it = settings->begin(); it != settings->end(); it++) {
SKSE::log::info("[DEFAULT] {} = {}", it->first, it->second); log::info("[DEFAULT] {} = {}", it->first, it->second);
} }
if (!std::filesystem::exists(iniPath)) { if (!std::filesystem::exists(iniPath)) {
SKSE::log::warn("{} does not exist, using default values.", iniPath); log::warn("{} does not exist, using default values.", iniPath);
return; return;
} }
@ -158,7 +161,7 @@ inline void LoadINI(std::map<std::string, bool>* settings, const char* iniPath)
for (const auto& k : keysList) { for (const auto& k : keysList) {
if (it->first == k.pItem) { if (it->first == k.pItem) {
settings->insert_or_assign(k.pItem, ini.GetBoolValue("", k.pItem, settings->at(k.pItem))); settings->insert_or_assign(k.pItem, ini.GetBoolValue("", k.pItem, settings->at(k.pItem)));
SKSE::log::info("[INI] {} = {}", k.pItem, settings->at(k.pItem)); log::info("[INI] {} = {}", k.pItem, settings->at(k.pItem));
bExists = true; bExists = true;
break; break;
} }
@ -170,12 +173,12 @@ inline void LoadINI(std::map<std::string, bool>* settings, const char* iniPath)
} }
if (bUpdateINI) { if (bUpdateINI) {
SKSE::log::info("New settings detected, adding to ArtifactTracker.ini"); log::info("New settings detected, adding to ArtifactTracker.ini");
ini.SaveFile(iniPath); ini.SaveFile(iniPath);
} }
} catch (const std::exception& e) { } catch (const std::exception& e) {
SKSE::log::error(e.what()); log::error(e.what());
} }
} }
@ -186,7 +189,7 @@ inline void RunBenchmark(std::function<void()> benchmark, std::string desc)
const auto end = std::chrono::high_resolution_clock::now(); const auto end = std::chrono::high_resolution_clock::now();
const auto elapsed = std::chrono::duration<double>(end - start); const auto elapsed = std::chrono::duration<double>(end - start);
SKSE::log::info("{}: Elapsed time: {} seconds", desc, elapsed.count()); log::info("{}: Elapsed time: {} seconds", desc, elapsed.count());
} }
inline std::vector<RE::Actor*> GetPlayerFollowers() inline std::vector<RE::Actor*> GetPlayerFollowers()