MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / setFormStats

Method setFormStats

game/ui/ufopaedia/ufopaediacategoryview.cpp:247–547  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

245}
246
247void UfopaediaCategoryView::setFormStats()
248{
249 for (unsigned int i = 0; i < statsLabels.size(); i++)
250 {
251 statsLabels[i]->setText("");
252 statsValues[i]->setText("");
253 }
254 for (unsigned int i = 0; i < orgLabels.size(); i++)
255 {
256 orgLabels[i]->setText("");
257 orgValues[i]->setText("");
258 }
259 unsigned int row = 0;
260 if (this->position_iterator != this->category->entries.end())
261 {
262 UString data_id = this->position_iterator->second->data_id;
263 UfopaediaEntry::Data data_type = this->position_iterator->second->data_type;
264 if (data_id.length() > 0)
265 {
266 switch (data_type)
267 {
268 case UfopaediaEntry::Data::Organisation:
269 {
270 StateRef<Organisation> ref = {state.get(), data_id};
271 StateRef<Organisation> player = state->getPlayer();
272 // FIXME: Should this be hardcoded?
273 if (data_id != "ORG_ALIEN")
274 {
275 orgLabels[1]->setText(tr("Balance"));
276 orgValues[1]->setText(format("$%d", ref->balance));
277 orgLabels[2]->setText(tr("Income"));
278 orgValues[2]->setText(format("$%d", ref->income));
279
280 if (ref != player)
281 {
282 UString relation = tr(ref->name);
283 switch (ref->isRelatedTo(player))
284 {
285 case Organisation::Relation::Allied:
286 relation += tr(": allied towards:");
287 break;
288 case Organisation::Relation::Friendly:
289 relation += tr(": friendly towards:");
290 break;
291 case Organisation::Relation::Neutral:
292 relation += tr(": neutral towards:");
293 break;
294 case Organisation::Relation::Unfriendly:
295 relation += tr(": unfriendly towards:");
296 break;
297 case Organisation::Relation::Hostile:
298 relation += tr(": hostile towards:");
299 break;
300 }
301 relation += UString(" ") + tr(player->name);
302 orgLabels[0]->setText(relation);
303 orgLabels[3]->setText(tr("Alien Infiltration"));
304 orgValues[3]->setText(format("%d%%", ref->infiltrationValue / 2));

Callers

nothing calls this directly

Calls 12

trFunction · 0.85
formatFunction · 0.85
endMethod · 0.80
getPlayerMethod · 0.80
isRelatedToMethod · 0.80
emptyMethod · 0.80
getRoundsPerSecondMethod · 0.80
sizeMethod · 0.45
setTextMethod · 0.45
getMethod · 0.45
getRangeInMetresMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected