From 4eb8b53d9596e4bb5490168fd602c7a6a740ce27 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 20 Feb 2019 00:42:02 +0100 Subject: [PATCH] - enforce that localized graphics need to be the same size as the one they replace. This is one of those things where the work needed to make it robust stands in no relation to the gain. This simply isn't worth the hassle of going through the entire code and fixing every single use of the 2D texture drawing functions. Unfortunately this means that the graphics items for the menu cannot be replaced this way because their size will most likely differ, but considering that the only candidates for this are the contents of Doom's main menu, the episode menu, the skill menu and the single player summary screen, it's simply not worth it. In all these cases the IWAD contents can just as easily be replaced with text and user mods which want to offer localized menus will have to work within the confines of the system, e.g. making sure that all menu items are designed to have proper size for substitution to work or by requesting text based menus, which will be added as a modding feature later. --- src/gamedata/textures/texturemanager.cpp | 35 +++++++++++++++--------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/gamedata/textures/texturemanager.cpp b/src/gamedata/textures/texturemanager.cpp index 5562fe690..88de868d4 100644 --- a/src/gamedata/textures/texturemanager.cpp +++ b/src/gamedata/textures/texturemanager.cpp @@ -1044,21 +1044,30 @@ void FTextureManager::AddLocalizedVariants() FTextureID tex = CheckForTexture(entry.name, ETextureType::MiscPatch); if (tex.isValid()) { - tokens[1].ToLower(); - auto langids = tokens[1].Split("-", FString::TOK_SKIPEMPTY); - auto lang = langids.Last(); - for (auto &lang : langids) + FTexture *otex = GetTexture(origTex); + FTexture *ntex = GetTexture(tex); + if (otex->GetDisplayWidth() != ntex->GetDisplayWidth() || otex->GetDisplayHeight() != ntex->GetDisplayHeight()) { - if (lang.Len() == 2 || lang.Len() == 3) + Printf("Localized texture %s must be the same size as the one it replaces\n", entry.name); + } + else + { + tokens[1].ToLower(); + auto langids = tokens[1].Split("-", FString::TOK_SKIPEMPTY); + auto lang = langids.Last(); + for (auto &lang : langids) { - uint32_t langid = MAKE_ID(lang[0], lang[1], lang[2], 0); - uint64_t comboid = (uint64_t(langid) << 32) | tex.GetIndex(); - LocalizedTextures.Insert(comboid, GetTexture(origTex)); - Textures[origTex.GetIndex()].HasLocalization = true; - } - else - { - Printf("Invalid language ID in texture %s\n", entry.name); + if (lang.Len() == 2 || lang.Len() == 3) + { + uint32_t langid = MAKE_ID(lang[0], lang[1], lang[2], 0); + uint64_t comboid = (uint64_t(langid) << 32) | tex.GetIndex(); + LocalizedTextures.Insert(comboid, GetTexture(origTex)); + Textures[origTex.GetIndex()].HasLocalization = true; + } + else + { + Printf("Invalid language ID in texture %s\n", entry.name); + } } } }