[Materials] Redirect preview images to loadscreens

This is a temporary workaround. We should create real previews!
This commit is contained in:
momo5502 2016-12-13 21:31:51 +01:00
parent b593987b72
commit bc5aed43d8
2 changed files with 21 additions and 0 deletions

View File

@ -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 #ifdef DEBUG
void Materials::DumpImageCfg(int, const char*, const char* material) void Materials::DumpImageCfg(int, const char*, const char* material)
{ {
@ -126,6 +142,9 @@ namespace Components
// Adapt death message to IW5 material format // Adapt death message to IW5 material format
Utils::Hook(0x5A30D9, Materials::DeathMessageStub, HOOK_JUMP).install()->quick(); 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 #ifdef DEBUG
if (Flags::HasFlag("dump")) if (Flags::HasFlag("dump"))
{ {

View File

@ -23,6 +23,8 @@ namespace Components
static int WriteDeathMessageIcon(char* string, int offset, Game::Material* material); static int WriteDeathMessageIcon(char* string, int offset, Game::Material* material);
static void DeathMessageStub(); static void DeathMessageStub();
static int FormatImagePath(char* buffer, size_t size, int, int, const char* image);
#ifdef DEBUG #ifdef DEBUG
static void DumpImageCfg(int, const char*, const char* material); static void DumpImageCfg(int, const char*, const char* material);
static void DumpImageCfgPath(int, const char*, const char* material); static void DumpImageCfgPath(int, const char*, const char* material);