MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / draw

Method draw

src/Basescape/MiniBaseView.cpp:94–151  ·  view source on GitHub ↗

* Draws the view of all the bases with facilities * in varying colors. */

Source from the content-addressed store, hash-verified

92 * in varying colors.
93 */
94void MiniBaseView::draw()
95{
96 Surface::draw();
97 for (size_t i = 0; i < MAX_BASES; ++i)
98 {
99 // Draw base squares
100 if (i == _base)
101 {
102 SDL_Rect r;
103 r.x = i * (MINI_SIZE + 2);
104 r.y = 0;
105 r.w = MINI_SIZE + 2;
106 r.h = MINI_SIZE + 2;
107 drawRect(&r, 1);
108 }
109 _texture->getFrame(41)->setX(i * (MINI_SIZE + 2));
110 _texture->getFrame(41)->setY(0);
111 _texture->getFrame(41)->blit(this);
112
113 // Draw facilities
114 if (i < _bases->size())
115 {
116 SDL_Rect r;
117 lock();
118 for (std::vector<BaseFacility*>::iterator f = _bases->at(i)->getFacilities()->begin(); f != _bases->at(i)->getFacilities()->end(); ++f)
119 {
120 int pal;
121 if ((*f)->getBuildTime() == 0)
122 pal = 3;
123 else
124 pal = 2;
125
126 r.x = i * (MINI_SIZE + 2) + 2 + (*f)->getX() * 2;
127 r.y = 2 + (*f)->getY() * 2;
128 r.w = (*f)->getRules()->getSize() * 2;
129 r.h = (*f)->getRules()->getSize() * 2;
130 drawRect(&r, Palette::blockOffset(pal)+3);
131 r.x++;
132 r.y++;
133 r.w--;
134 r.h--;
135 drawRect(&r, Palette::blockOffset(pal)+5);
136 r.x--;
137 r.y--;
138 drawRect(&r, Palette::blockOffset(pal)+2);
139 r.x++;
140 r.y++;
141 r.w--;
142 r.h--;
143 drawRect(&r, Palette::blockOffset(pal)+3);
144 r.x--;
145 r.y--;
146 setPixel(r.x, r.y, Palette::blockOffset(pal)+1);
147 }
148 unlock();
149 }
150 }
151}

Callers

nothing calls this directly

Calls 10

getFrameMethod · 0.80
getFacilitiesMethod · 0.80
setXMethod · 0.45
setYMethod · 0.45
blitMethod · 0.45
getBuildTimeMethod · 0.45
getXMethod · 0.45
getYMethod · 0.45
getSizeMethod · 0.45
getRulesMethod · 0.45

Tested by

no test coverage detected