diff --git a/src/Components/Modules/Materials.cpp b/src/Components/Modules/Materials.cpp index 466e4106..c9b4e744 100644 --- a/src/Components/Modules/Materials.cpp +++ b/src/Components/Modules/Materials.cpp @@ -93,6 +93,22 @@ namespace Components } } + int Materials::FormatImagePath(char* buffer, size_t size, int, int, const char* image) + { + if (Utils::String::StartsWith(image, "preview_")) + { + std::string newImage = image; + Utils::String::Replace(newImage, "preview_", "loadscreen_"); + + if (FileSystem::File(fmt::sprintf("images/%s.iwi", newImage.data())).exists()) + { + image = Utils::String::VA("%s", newImage.data()); + } + } + + return _snprintf_s(buffer, size, size, "images/%s.iwi", image); + } + #ifdef DEBUG void Materials::DumpImageCfg(int, const char*, const char* material) { @@ -126,6 +142,9 @@ namespace Components // Adapt death message to IW5 material format Utils::Hook(0x5A30D9, Materials::DeathMessageStub, HOOK_JUMP).install()->quick(); + // Resolve preview images to loadscreens + Utils::Hook(0x53AC19, Materials::FormatImagePath, HOOK_CALL).install()->quick(); + #ifdef DEBUG if (Flags::HasFlag("dump")) { diff --git a/src/Components/Modules/Materials.hpp b/src/Components/Modules/Materials.hpp index d8fc5e76..578dc353 100644 --- a/src/Components/Modules/Materials.hpp +++ b/src/Components/Modules/Materials.hpp @@ -23,6 +23,8 @@ namespace Components static int WriteDeathMessageIcon(char* string, int offset, Game::Material* material); static void DeathMessageStub(); + static int FormatImagePath(char* buffer, size_t size, int, int, const char* image); + #ifdef DEBUG static void DumpImageCfg(int, const char*, const char* material); static void DumpImageCfgPath(int, const char*, const char* material);