* Draw representation of an object (tile) for GUI purposes. * @param x Position x of image. * @param y Position y of image. * @param spec Object spec to draw. * @param view The object's view. */
| 490 | * @param view The object's view. |
| 491 | */ |
| 492 | void DrawNewObjectTileInGUI(int x, int y, const ObjectSpec *spec, uint8_t view) |
| 493 | { |
| 494 | ObjectResolverObject object(spec, nullptr, INVALID_TILE, view); |
| 495 | const auto *group = object.Resolve<TileLayoutSpriteGroup>(); |
| 496 | if (group == nullptr) return; |
| 497 | |
| 498 | auto processor = group->ProcessRegisters(object, nullptr); |
| 499 | auto dts = processor.GetLayout(); |
| 500 | |
| 501 | PaletteID palette; |
| 502 | if (Company::IsValidID(_local_company)) { |
| 503 | /* Get the colours of our company! */ |
| 504 | if (spec->flags.Test(ObjectFlag::Uses2CC)) { |
| 505 | const Livery &l = Company::Get(_local_company)->livery[0]; |
| 506 | palette = SPR_2CCMAP_BASE + l.colour1 + l.colour2 * 16; |
| 507 | } else { |
| 508 | palette = GetCompanyPalette(_local_company); |
| 509 | } |
| 510 | } else { |
| 511 | /* There's no company, so just take the base palette. */ |
| 512 | palette = spec->flags.Test(ObjectFlag::Uses2CC) ? SPR_2CCMAP_BASE : PALETTE_RECOLOUR_START; |
| 513 | } |
| 514 | |
| 515 | SpriteID image = dts.ground.sprite; |
| 516 | PaletteID pal = dts.ground.pal; |
| 517 | |
| 518 | if (GB(image, 0, SPRITE_WIDTH) != 0) { |
| 519 | DrawSprite(image, GroundSpritePaletteTransform(image, pal, palette), x, y); |
| 520 | } |
| 521 | |
| 522 | DrawNewGRFTileSeqInGUI(x, y, &dts, 0, palette); |
| 523 | } |
| 524 | |
| 525 | /** |
| 526 | * Perform a callback for an object. |
no test coverage detected