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::skillBookShader;
bool EventListener::bEnderalMode = false;
auto EventListener::GetSingleton() -> EventListener*
{
static EventListener singleton{};
@ -24,8 +26,8 @@ void EventListener::Install()
std::map<std::string, std::any> settings{
{ "sRegularBookShader", "Skyrim.esm@C723A" },
{ "sSpellBookShader", "Skyrim.esm@B6BF9" },
{ "sSkillBookShader", "Skyrim.esm@B6BFA" },
{ "sSpellBookShader", "Skyrim.esm@B6BFA" },
{ "sSkillBookShader", "Skyrim.esm@B6BF9" },
};
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::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>();
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(

View File

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

View File

@ -8,22 +8,34 @@ inline void TryAddBookRefShader(RE::TESObjectREFR* a_ref)
return;
}
if (const auto baseObj = a_ref->GetBaseObject(); baseObj->IsBook()) {
if (const auto bookObj = baseObj->As<RE::TESObjectBOOK>()) {
if (!bookObj->IsRead()) {
auto shader = EventListener::regularBookShader;
if (const auto baseObj = a_ref->GetBaseObject()) {
if (baseObj->IsBook()) {
if (const auto bookObj = baseObj->As<RE::TESObjectBOOK>()) {
if (!bookObj->IsRead()) {
auto shader = EventListener::regularBookShader;
if (bookObj->TeachesSpell()) {
shader = EventListener::spellBookShader;
} else if (bookObj->TeachesSkill()) {
shader = EventListener::skillBookShader;
}
SKSE::GetTaskInterface()->AddTask([a_ref, shader]() {
if (a_ref) {
a_ref->ApplyEffectShader(shader);
if (bookObj->TeachesSpell()) {
shader = EventListener::spellBookShader;
} else if (bookObj->TeachesSkill()) {
shader = EventListener::skillBookShader;
}
});
SKSE::GetTaskInterface()->AddTask([a_ref, shader]() {
if (a_ref) {
a_ref->ApplyEffectShader(shader);
}
});
}
}
} 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);
}
});
}
}
}
}