| 1108 | //========================================================================== |
| 1109 | |
| 1110 | void FTextureManager::AddLocalizedVariants() |
| 1111 | { |
| 1112 | std::vector<FolderEntry> content; |
| 1113 | fileSystem.GetFilesInFolder("localized/textures/", content, false); |
| 1114 | for (auto &entry : content) |
| 1115 | { |
| 1116 | FString name = entry.name; |
| 1117 | auto tokens = name.Split(".", FString::TOK_SKIPEMPTY); |
| 1118 | if (tokens.Size() == 2) |
| 1119 | { |
| 1120 | auto ext = tokens[1]; |
| 1121 | // Do not interpret common extensions for images as language IDs. |
| 1122 | if (ext.CompareNoCase("png") == 0 || ext.CompareNoCase("jpg") == 0 || ext.CompareNoCase("gfx") == 0 || ext.CompareNoCase("tga") == 0 || ext.CompareNoCase("lmp") == 0) |
| 1123 | { |
| 1124 | Printf("%s contains no language IDs and will be ignored\n", entry.name); |
| 1125 | continue; |
| 1126 | } |
| 1127 | } |
| 1128 | if (tokens.Size() >= 2) |
| 1129 | { |
| 1130 | FString base = ExtractFileBase(tokens[0].GetChars()); |
| 1131 | FTextureID origTex = CheckForTexture(base.GetChars(), ETextureType::MiscPatch); |
| 1132 | if (origTex.isValid()) |
| 1133 | { |
| 1134 | FTextureID tex = CheckForTexture(entry.name, ETextureType::MiscPatch); |
| 1135 | if (tex.isValid()) |
| 1136 | { |
| 1137 | auto otex = GetGameTexture(origTex); |
| 1138 | auto ntex = GetGameTexture(tex); |
| 1139 | if (otex->GetDisplayWidth() != ntex->GetDisplayWidth() || otex->GetDisplayHeight() != ntex->GetDisplayHeight()) |
| 1140 | { |
| 1141 | Printf("Localized texture %s must be the same size as the one it replaces\n", entry.name); |
| 1142 | } |
| 1143 | else |
| 1144 | { |
| 1145 | tokens[1].ToLower(); |
| 1146 | auto langids = tokens[1].Split("-", FString::TOK_SKIPEMPTY); |
| 1147 | for (auto &lang : langids) |
| 1148 | { |
| 1149 | if (lang.Len() == 2 || lang.Len() == 3) |
| 1150 | { |
| 1151 | uint32_t langid = MAKE_ID(lang[0], lang[1], lang[2], 0); |
| 1152 | uint64_t comboid = (uint64_t(langid) << 32) | origTex.GetIndex(); |
| 1153 | LocalizedTextures.Insert(comboid, tex.GetIndex()); |
| 1154 | Textures[origTex.GetIndex()].Flags |= TEXFLAG_HASLOCALIZATION; |
| 1155 | } |
| 1156 | else |
| 1157 | { |
| 1158 | Printf("Invalid language ID in texture %s\n", entry.name); |
| 1159 | } |
| 1160 | } |
| 1161 | } |
| 1162 | } |
| 1163 | else |
| 1164 | { |
| 1165 | Printf("%s is not a texture\n", entry.name); |
| 1166 | } |
| 1167 | } |
nothing calls this directly
no test coverage detected