* Draws the view of all the bases with facilities * in varying colors. */
| 92 | * in varying colors. |
| 93 | */ |
| 94 | void 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 | } |
nothing calls this directly
no test coverage detected