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

Method drawGrid

src/Battlescape/Inventory.cpp:130–201  ·  view source on GitHub ↗

* Draws the inventory grid for item placement. */

Source from the content-addressed store, hash-verified

128 * Draws the inventory grid for item placement.
129 */
130void Inventory::drawGrid()
131{
132 _grid->clear();
133 Text text = Text(80, 9, 0, 0);
134 text.setPalette(_grid->getPalette());
135 text.initText(_game->getResourcePack()->getFont("FONT_BIG"), _game->getResourcePack()->getFont("FONT_SMALL"), _game->getLanguage());
136 text.setColor(Palette::blockOffset(4)-1);
137 text.setHighContrast(true);
138
139 Uint8 color = Palette::blockOffset(0)+8;
140 for (std::map<std::string, RuleInventory*>::iterator i = _game->getRuleset()->getInventories()->begin(); i != _game->getRuleset()->getInventories()->end(); ++i)
141 {
142 // Draw grid
143 if (i->second->getType() == INV_SLOT)
144 {
145 for (std::vector<RuleSlot>::iterator j = i->second->getSlots()->begin(); j != i->second->getSlots()->end(); ++j)
146 {
147 SDL_Rect r;
148 r.x = i->second->getX() + RuleInventory::SLOT_W * j->x;
149 r.y = i->second->getY() + RuleInventory::SLOT_H * j->y;
150 r.w = RuleInventory::SLOT_W + 1;
151 r.h = RuleInventory::SLOT_H + 1;
152 _grid->drawRect(&r, color);
153 r.x++;
154 r.y++;
155 r.w -= 2;
156 r.h -= 2;
157 _grid->drawRect(&r, 0);
158 }
159 }
160 else if (i->second->getType() == INV_HAND)
161 {
162 SDL_Rect r;
163 r.x = i->second->getX();
164 r.y = i->second->getY();
165 r.w = RuleInventory::HAND_W * RuleInventory::SLOT_W;
166 r.h = RuleInventory::HAND_H * RuleInventory::SLOT_H;
167 _grid->drawRect(&r, color);
168 r.x++;
169 r.y++;
170 r.w -= 2;
171 r.h -= 2;
172 _grid->drawRect(&r, 0);
173 }
174 else if (i->second->getType() == INV_GROUND)
175 {
176 for (int x = i->second->getX(); x <= 320; x += RuleInventory::SLOT_W)
177 {
178 for (int y = i->second->getY(); y <= 200; y += RuleInventory::SLOT_H)
179 {
180 SDL_Rect r;
181 r.x = x;
182 r.y = y;
183 r.w = RuleInventory::SLOT_W + 1;
184 r.h = RuleInventory::SLOT_H + 1;
185 _grid->drawRect(&r, color);
186 r.x++;
187 r.y++;

Callers

nothing calls this directly

Calls 15

getLanguageMethod · 0.80
getInventoriesMethod · 0.80
getSlotsMethod · 0.80
drawRectMethod · 0.80
getSpacingMethod · 0.80
TextClass · 0.70
clearMethod · 0.45
setPaletteMethod · 0.45
getPaletteMethod · 0.45
initTextMethod · 0.45
getFontMethod · 0.45
getResourcePackMethod · 0.45

Tested by

no test coverage detected