Added Enderal SE support

This commit is contained in:
Eddoursul 2024-07-07 22:05:03 +02:00
parent 2b38e77101
commit 6b4b19bbfa
3 changed files with 36 additions and 16 deletions

View File

@ -7,6 +7,8 @@ RE::TESEffectShader* EventListener::regularBookShader;
RE::TESEffectShader* EventListener::spellBookShader; RE::TESEffectShader* EventListener::spellBookShader;
RE::TESEffectShader* EventListener::skillBookShader; RE::TESEffectShader* EventListener::skillBookShader;
bool EventListener::bEnderalMode = false;
auto EventListener::GetSingleton() -> EventListener* auto EventListener::GetSingleton() -> EventListener*
{ {
static EventListener singleton{}; static EventListener singleton{};
@ -24,8 +26,8 @@ void EventListener::Install()
std::map<std::string, std::any> settings{ std::map<std::string, std::any> settings{
{ "sRegularBookShader", "Skyrim.esm@C723A" }, { "sRegularBookShader", "Skyrim.esm@C723A" },
{ "sSpellBookShader", "Skyrim.esm@B6BF9" }, { "sSpellBookShader", "Skyrim.esm@B6BFA" },
{ "sSkillBookShader", "Skyrim.esm@B6BFA" }, { "sSkillBookShader", "Skyrim.esm@B6BF9" },
}; };
LoadINI(&settings, std::format("Data/SKSE/Plugins/{}.ini", SKSE::PluginDeclaration::GetSingleton()->GetName()).c_str()); LoadINI(&settings, std::format("Data/SKSE/Plugins/{}.ini", SKSE::PluginDeclaration::GetSingleton()->GetName()).c_str());
@ -35,6 +37,10 @@ void EventListener::Install()
EventListener::regularBookShader = retrieveFormByString(std::any_cast<std::string>(settings["sRegularBookShader"]), defaultShader)->As<RE::TESEffectShader>(); EventListener::regularBookShader = retrieveFormByString(std::any_cast<std::string>(settings["sRegularBookShader"]), defaultShader)->As<RE::TESEffectShader>();
EventListener::spellBookShader = retrieveFormByString(std::any_cast<std::string>(settings["sSpellBookShader"]), defaultShader)->As<RE::TESEffectShader>(); EventListener::spellBookShader = retrieveFormByString(std::any_cast<std::string>(settings["sSpellBookShader"]), defaultShader)->As<RE::TESEffectShader>();
EventListener::skillBookShader = retrieveFormByString(std::any_cast<std::string>(settings["sSkillBookShader"]), defaultShader)->As<RE::TESEffectShader>(); EventListener::skillBookShader = retrieveFormByString(std::any_cast<std::string>(settings["sSkillBookShader"]), defaultShader)->As<RE::TESEffectShader>();
if (EventListener::bEnderalMode = RE::TESDataHandler::GetSingleton()->GetModIndex("Enderal - Forgotten Stories.esm") != std::nullopt) {
logger::info("Detected Enderal SE, learning books will be highlighted as well");
}
} }
auto EventListener::ProcessEvent( auto EventListener::ProcessEvent(

View File

@ -24,6 +24,8 @@ public:
RE::BSTEventSource<RE::MenuOpenCloseEvent>* a_eventSource) RE::BSTEventSource<RE::MenuOpenCloseEvent>* a_eventSource)
-> RE::BSEventNotifyControl override; -> RE::BSEventNotifyControl override;
static bool bEnderalMode;
static RE::TESEffectShader* regularBookShader; static RE::TESEffectShader* regularBookShader;
static RE::TESEffectShader* skillBookShader; static RE::TESEffectShader* skillBookShader;
static RE::TESEffectShader* spellBookShader; static RE::TESEffectShader* spellBookShader;

View File

@ -8,7 +8,8 @@ inline void TryAddBookRefShader(RE::TESObjectREFR* a_ref)
return; return;
} }
if (const auto baseObj = a_ref->GetBaseObject(); baseObj->IsBook()) { if (const auto baseObj = a_ref->GetBaseObject()) {
if (baseObj->IsBook()) {
if (const auto bookObj = baseObj->As<RE::TESObjectBOOK>()) { if (const auto bookObj = baseObj->As<RE::TESObjectBOOK>()) {
if (!bookObj->IsRead()) { if (!bookObj->IsRead()) {
auto shader = EventListener::regularBookShader; auto shader = EventListener::regularBookShader;
@ -26,6 +27,17 @@ inline void TryAddBookRefShader(RE::TESObjectREFR* a_ref)
}); });
} }
} }
} else if (EventListener::bEnderalMode && baseObj->Is(RE::FormType::AlchemyItem)) {
if (const auto alchObj = baseObj->As<RE::AlchemyItem>()) {
if (alchObj->data.consumptionSound && alchObj->data.consumptionSound->formID == 0x7ea3a) {
SKSE::GetTaskInterface()->AddTask([a_ref]() {
if (a_ref) {
a_ref->ApplyEffectShader(EventListener::skillBookShader);
}
});
}
}
}
} }
} }