diff --git a/interface/startmenu.swf b/interface/startmenu.swf index 0579e201..c9c56efe 100644 --- a/interface/startmenu.swf +++ b/interface/startmenu.swf @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:091d77517ed6e2bd14879b44f7b960a6870064cadb1055bb724d0d6625c8db69 -size 66683 +oid sha256:b657c032a482cc2cecdb58856f603bb2076ac2abe3aedc10542e9a683b4e6b6f +size 66671 diff --git a/source/Enderal DLL/src/Main.cpp b/source/Enderal DLL/src/Main.cpp index 387111af..69a38ed4 100644 --- a/source/Enderal DLL/src/Main.cpp +++ b/source/Enderal DLL/src/Main.cpp @@ -1,6 +1,7 @@ #include "EventListener.h" #include "Util.h" #include "Papyrus.h" +#include "Patches/MainMenuPatch.h" #include "Patches/FlatMapMarkers.h" #include "Patches/StayAtSystemPage.h" #include "Patches/MapMarkerPlacement.h" @@ -168,6 +169,7 @@ SKSEPluginLoad(const LoadInterface* skse) { GetPapyrusInterface()->Register(Papyrus::Bind); + MainMenuPatch::Install(); DialogueMenuPatch::Install(); HeroMenuPatch::Install(); TweenMenuPatch::Install(); diff --git a/source/Enderal DLL/src/Patches/MainMenuPatch.h b/source/Enderal DLL/src/Patches/MainMenuPatch.h new file mode 100644 index 00000000..c27b43c3 --- /dev/null +++ b/source/Enderal DLL/src/Patches/MainMenuPatch.h @@ -0,0 +1,73 @@ +#pragma once + +class MainMenuPatch : public RE::MainMenu +{ +public: + static void Install() + { + REL::Relocation vtbl(RE::VTABLE_MainMenu[0]); + _ProcessMessage = vtbl.write_vfunc(0x4, &ProcessMessageEx); + } + +private: + void ProcessEx(RE::GPtr a_movie) + { + RE::GFxValue entryList; + if (!uiMovie->Invoke("_root.MenuHolder.Menu_mc.MainList.__get__entryList", &entryList, nullptr, 0)) { + return; + } + + std::array values{ + "$CREATIONS", + "$CREATION CLUB", + "$DOWNLOADABLE CONTENT", + "$MOD MANAGER", + "$HELP", + }; + + bool bUpdated = false; + const auto size = entryList.GetArraySize(); + for (uint32_t i = size; i > 0; i--) { + RE::GFxValue entry; + if (!entryList.GetElement(i - 1, &entry)) + continue; + + RE::GFxValue entryText; + if (!entry.GetMember("text", &entryText)) + continue; + + const std::string text = entryText.GetString(); + + if (text.empty()) + continue; + + for (const auto name : values) { + if (text == name) { + bUpdated = true; + entryList.RemoveElement(i - 1); + } + } + } + + if (bUpdated) { + uiMovie->Invoke("_root.MenuHolder.Menu_mc.MainList.InvalidateData", nullptr, nullptr, 0); + } + } + + RE::UI_MESSAGE_RESULTS ProcessMessageEx(RE::UIMessage* a_message) + { + if (a_message->type == RE::UI_MESSAGE_TYPE::kShow) { + _show = true; + } else if (_show && (iIterations < 15) && a_message->type == RE::UI_MESSAGE_TYPE::kUpdate) { + iIterations++; + ProcessEx(uiMovie); + } + + return _ProcessMessage(this, a_message); + } + + inline static REL::Relocation _ProcessMessage; + + inline static bool _show{ false }; + inline static uint32_t iIterations{ 0 }; +};