| 615 | //========================================================================== |
| 616 | |
| 617 | void FTextureManager::AddHiresTextures (int wadnum) |
| 618 | { |
| 619 | int firsttx = fileSystem.GetFirstEntry(wadnum); |
| 620 | int lasttx = fileSystem.GetLastEntry(wadnum); |
| 621 | |
| 622 | TArray<FTextureID> tlist; |
| 623 | |
| 624 | if (firsttx == -1 || lasttx == -1) |
| 625 | { |
| 626 | return; |
| 627 | } |
| 628 | |
| 629 | for (;firsttx <= lasttx; ++firsttx) |
| 630 | { |
| 631 | if (fileSystem.GetFileNamespace(firsttx) == ns_hires) |
| 632 | { |
| 633 | auto Name = fileSystem.GetFileShortName(firsttx); |
| 634 | |
| 635 | if (fileSystem.CheckNumForName (Name, ns_hires) == firsttx) |
| 636 | { |
| 637 | tlist.Clear(); |
| 638 | int amount = ListTextures(Name, tlist); |
| 639 | if (amount == 0) |
| 640 | { |
| 641 | // A texture with this name does not yet exist |
| 642 | auto newtex = MakeGameTexture(CreateTextureFromLump(firsttx), Name, ETextureType::Override); |
| 643 | if (newtex != NULL) |
| 644 | { |
| 645 | AddGameTexture(newtex); |
| 646 | } |
| 647 | } |
| 648 | else |
| 649 | { |
| 650 | for(unsigned int i = 0; i < tlist.Size(); i++) |
| 651 | { |
| 652 | FTexture * newtex = CreateTextureFromLump(firsttx); |
| 653 | if (newtex != NULL) |
| 654 | { |
| 655 | auto oldtex = Textures[tlist[i].GetIndex()].Texture; |
| 656 | |
| 657 | // Replace the entire texture and adjust the scaling and offset factors. |
| 658 | auto gtex = MakeGameTexture(newtex, nullptr, ETextureType::Override); |
| 659 | gtex->SetWorldPanning(true); |
| 660 | gtex->SetDisplaySize(oldtex->GetDisplayWidth(), oldtex->GetDisplayHeight()); |
| 661 | double xscale1 = oldtex->GetTexelLeftOffset(0) * gtex->GetScaleX() / oldtex->GetScaleX(); |
| 662 | double xscale2 = oldtex->GetTexelLeftOffset(1) * gtex->GetScaleX() / oldtex->GetScaleX(); |
| 663 | double yscale1 = oldtex->GetTexelTopOffset(0) * gtex->GetScaleY() / oldtex->GetScaleY(); |
| 664 | double yscale2 = oldtex->GetTexelTopOffset(1) * gtex->GetScaleY() / oldtex->GetScaleY(); |
| 665 | gtex->SetOffsets(0, xs_RoundToInt(xscale1), xs_RoundToInt(yscale1)); |
| 666 | gtex->SetOffsets(1, xs_RoundToInt(xscale2), xs_RoundToInt(yscale2)); |
| 667 | ReplaceTexture(tlist[i], gtex, true); |
| 668 | } |
| 669 | } |
| 670 | } |
| 671 | progressFunc(); |
| 672 | } |
| 673 | } |
| 674 | } |
nothing calls this directly
no test coverage detected