| 449 | //========================================================================== |
| 450 | |
| 451 | FTextureID FTextureManager::CreateTexture (int lumpnum, ETextureType usetype) |
| 452 | { |
| 453 | if (lumpnum != -1) |
| 454 | { |
| 455 | FString str; |
| 456 | if (!usefullnames) |
| 457 | str = fileSystem.GetFileShortName(lumpnum); |
| 458 | else |
| 459 | { |
| 460 | auto fn = fileSystem.GetFileFullName(lumpnum); |
| 461 | str = ExtractFileBase(fn); |
| 462 | } |
| 463 | auto out = MakeGameTexture(CreateTextureFromLump(lumpnum, usetype == ETextureType::Flat), str.GetChars(), usetype); |
| 464 | |
| 465 | if (out != NULL) |
| 466 | { |
| 467 | if (usetype == ETextureType::Flat) |
| 468 | { |
| 469 | int w = out->GetTexelWidth(); |
| 470 | int h = out->GetTexelHeight(); |
| 471 | |
| 472 | // Auto-scale flats with dimensions 128x128 and 256x256. |
| 473 | // In hindsight, a bad idea, but RandomLag made it sound better than it really is. |
| 474 | // Now we're stuck with this stupid behaviour. |
| 475 | if (w == 128 && h == 128) |
| 476 | { |
| 477 | out->SetScale(2, 2); |
| 478 | out->SetWorldPanning(true); |
| 479 | } |
| 480 | else if (w == 256 && h == 256) |
| 481 | { |
| 482 | out->SetScale(4, 4); |
| 483 | out->SetWorldPanning(true); |
| 484 | } |
| 485 | } |
| 486 | |
| 487 | return AddGameTexture(out); |
| 488 | } |
| 489 | else |
| 490 | { |
| 491 | Printf (TEXTCOLOR_ORANGE "Invalid data encountered for texture %s\n", fileSystem.GetFileFullPath(lumpnum).c_str()); |
| 492 | return FTextureID(-1); |
| 493 | } |
| 494 | } |
| 495 | return FTextureID(-1); |
| 496 | } |
| 497 | |
| 498 | //========================================================================== |
| 499 | // |
no test coverage detected