MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / renderBase

Method renderBase

game/ui/components/basegraphics.cpp:45–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45void BaseGraphics::renderBase(Vec2<int> renderPos, const Base &base)
46{
47 // Draw grid
48 sp<Image> grid = fw().data->loadImage(
49 "PCK:xcom3/ufodata/base.pck:xcom3/ufodata/base.tab:0:xcom3/ufodata/base.pcx");
50 Vec2<int> i;
51 for (i.x = 0; i.x < Base::SIZE; i.x++)
52 {
53 for (i.y = 0; i.y < Base::SIZE; i.y++)
54 {
55 Vec2<int> pos = renderPos + i * TILE_SIZE;
56 fw().renderer->draw(grid, pos);
57 }
58 }
59
60 // Draw corridors
61 for (i.x = 0; i.x < Base::SIZE; i.x++)
62 {
63 for (i.y = 0; i.y < Base::SIZE; i.y++)
64 {
65 int sprite = getCorridorSprite(base, i);
66 if (sprite != 0)
67 {
68 Vec2<int> pos = renderPos + i * TILE_SIZE;
69 auto image = format(
70 "PCK:xcom3/ufodata/base.pck:xcom3/ufodata/base.tab:%d:xcom3/ufodata/base.pcx",
71 sprite);
72 fw().renderer->draw(fw().data->loadImage(image), pos);
73 }
74 }
75 }
76
77 // Draw facilities
78 sp<Image> circleS = fw().data->loadImage(
79 "PCK:xcom3/ufodata/base.pck:xcom3/ufodata/base.tab:25:xcom3/ufodata/base.pcx");
80 sp<Image> circleL = fw().data->loadImage(
81 "PCK:xcom3/ufodata/base.pck:xcom3/ufodata/base.tab:26:xcom3/ufodata/base.pcx");
82 auto font = ui().getFont("smalfont");
83 for (auto &facility : base.facilities)
84 {
85 sp<Image> sprite = facility->type->sprite;
86 Vec2<int> pos = renderPos + facility->pos * TILE_SIZE;
87 if (facility->buildTime == 0)
88 {
89 fw().renderer->draw(sprite, pos);
90 }
91 else
92 {
93 // Fade out facility
94 fw().renderer->drawTinted(sprite, pos, Colour(255, 255, 255, 128));
95 // Draw construction overlay
96 if (facility->type->size == 1)
97 {
98 fw().renderer->draw(circleS, pos);
99 }
100 else
101 {
102 fw().renderer->draw(circleL, pos);

Callers

nothing calls this directly

Calls 7

formatFunction · 0.85
ColourClass · 0.85
loadImageMethod · 0.45
drawMethod · 0.45
getFontMethod · 0.45
drawTintedMethod · 0.45
getStringMethod · 0.45

Tested by

no test coverage detected