| 43 | #include "texinfo.h" |
| 44 | |
| 45 | FGameTexture* GetSkyTexture(FTextureID baseid, int lognumtiles, const int16_t *tilemap, int remap) |
| 46 | { |
| 47 | FString synthname; |
| 48 | |
| 49 | |
| 50 | if ((lognumtiles == 0 && remap == 0) || lognumtiles > 4 || lognumtiles < 0) |
| 51 | { |
| 52 | // no special handling - let the old code do its job as-is |
| 53 | return nullptr; |
| 54 | } |
| 55 | |
| 56 | int numtiles = 1 << lognumtiles; |
| 57 | synthname.Format("Sky%04x%02x", baseid.GetIndex(), remap); |
| 58 | for(int i = 0; i < numtiles; i++) |
| 59 | { |
| 60 | synthname += 'A' + tilemap[i]; |
| 61 | }; |
| 62 | auto tex = TexMan.FindGameTexture(synthname.GetChars()); |
| 63 | if (tex) return tex; |
| 64 | auto basetex = TexMan.GetGameTexture(baseid); |
| 65 | auto scalex = basetex->GetScaleX(); |
| 66 | auto scaley = basetex->GetScaleY(); |
| 67 | |
| 68 | TArray<TexPartBuild> build(numtiles, true); |
| 69 | int tilewidth = basetex->GetTexelWidth(); |
| 70 | for(int i = 0; i < numtiles; i++) |
| 71 | { |
| 72 | // Todo - allow named textures for the single patches |
| 73 | auto texture = TexMan.GameByIndex(baseid.GetIndex() + tilemap[i]); |
| 74 | if (!texture || !texture->isValid() || texture->GetTexture() == 0) return nullptr; |
| 75 | build[i].TexImage = static_cast<FImageTexture*>(texture->GetTexture()); |
| 76 | build[i].OriginX = tilewidth * i; |
| 77 | build[i].Translation = GPalette.GetTranslation(GetTranslationType(remap), GetTranslationIndex(remap)); |
| 78 | } |
| 79 | auto tt = MakeGameTexture(new FImageTexture(new FMultiPatchTexture(tilewidth*numtiles, basetex->GetTexelHeight(), build, false, false)), synthname.GetChars(), ETextureType::Override); |
| 80 | tt->SetScale(scalex, scaley); |
| 81 | tt->SetUpscaleFlag(basetex->GetUpscaleFlag(), true); |
| 82 | TexMan.AddGameTexture(tt, true); |
| 83 | return tt; |
| 84 | } |
no test coverage detected