* Changes the current base to display and * initializes the internal base grid. * @param base Pointer to base to display. */
| 84 | * @param base Pointer to base to display. |
| 85 | */ |
| 86 | void BaseView::setBase(Base *base) |
| 87 | { |
| 88 | _base = base; |
| 89 | _selFacility = 0; |
| 90 | |
| 91 | // Clear grid |
| 92 | for (int x = 0; x < BASE_SIZE; ++x) |
| 93 | for (int y = 0; y < BASE_SIZE; ++y) |
| 94 | _facilities[x][y] = 0; |
| 95 | |
| 96 | // Fill grid with base facilities |
| 97 | for (std::vector<BaseFacility*>::iterator i = _base->getFacilities()->begin(); i != _base->getFacilities()->end(); ++i) |
| 98 | { |
| 99 | for (int y = (*i)->getY(); y < (*i)->getY() + (*i)->getRules()->getSize(); ++y) |
| 100 | { |
| 101 | for (int x = (*i)->getX(); x < (*i)->getX() + (*i)->getRules()->getSize(); ++x) |
| 102 | { |
| 103 | _facilities[x][y] = *i; |
| 104 | } |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | _redraw = true; |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * Changes the texture to use for drawing |
no test coverage detected