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

Method draw

src/Battlescape/MiniMapView.cpp:62–152  ·  view source on GitHub ↗

* Draws the minimap. */

Source from the content-addressed store, hash-verified

60 * Draws the minimap.
61 */
62void MiniMapView::draw()
63{
64 int _startX = _camera->getCenterPosition().x - ((getWidth() / CELL_WIDTH) / 2);
65 int _startY = _camera->getCenterPosition().y - ((getHeight() / CELL_HEIGHT) / 2);
66
67 InteractiveSurface::draw();
68 if(!_set)
69 {
70 return;
71 }
72 drawRect(0, 0, getWidth(), getHeight(), 0);
73 this->lock();
74 for (int lvl = 0; lvl <= _camera->getCenterPosition().z; lvl++)
75 {
76 int py = _startY;
77 for (int y = Surface::getY(); y < getHeight () + Surface::getY(); y += CELL_HEIGHT)
78 {
79 int px = _startX;
80 for (int x = Surface::getX(); x < getWidth () + Surface::getX(); x += CELL_WIDTH)
81 {
82 MapData * data = 0;
83 Tile * t = 0;
84 Position p (px, py, lvl);
85 t = _battleGame->getTile(p);
86 if (!t)
87 {
88 px++;
89 continue;
90 }
91 int tileShade = 16;
92 if (t->isDiscovered(2))
93 {
94 tileShade = t->getShade();
95 }
96 for(int i = 0; i < 4; i++)
97 {
98 data = t->getMapData(i);
99
100 Surface * s = 0;
101 if(data && data->getMiniMapIndex())
102 {
103 s = _set->getFrame (data->getMiniMapIndex()+35);
104 }
105 if(s)
106 {
107 s->blitNShade(this, x, y, tileShade);
108 }
109 }
110 // alive units
111 if (t->getUnit() && t->getUnit()->getVisible())
112 {
113 int frame = t->getUnit()->getMiniMapSpriteIndex();
114 int size = t->getUnit()->getArmor()->getSize();
115 frame += (t->getPosition().y - t->getUnit()->getPosition().y) * size;
116 frame += t->getPosition().x - t->getUnit()->getPosition().x;
117 frame += _frame * size * size;
118 Surface * s = _set->getFrame(frame);
119 s->blitNShade(this, x, y, 0);

Callers

nothing calls this directly

Calls 15

getCenterPositionMethod · 0.80
getMiniMapIndexMethod · 0.80
getFrameMethod · 0.80
blitNShadeMethod · 0.80
getMiniMapSpriteIndexMethod · 0.80
unlockMethod · 0.80
lockMethod · 0.45
getTileMethod · 0.45
isDiscoveredMethod · 0.45
getShadeMethod · 0.45
getMapDataMethod · 0.45
getUnitMethod · 0.45

Tested by

no test coverage detected