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

Method init

src/Battlescape/UnitInfoState.cpp:472–620  ·  view source on GitHub ↗

* Updates unit info which can change * after going into other screens. */

Source from the content-addressed store, hash-verified

470 * after going into other screens.
471 */
472void UnitInfoState::init()
473{
474 State::init();
475 std::wostringstream ss;
476 ss << _unit->getTimeUnits();
477 _numTimeUnits->setText(ss.str());
478 _barTimeUnits->setMax(_unit->getStats()->tu);
479 _barTimeUnits->setValue(_unit->getTimeUnits());
480
481 ss.str(L"");
482 // aliens have their rank in their "name", soldiers don't
483 if (_unit->getType() == "SOLDIER")
484 {
485 ss << tr(_unit->getRankString());
486 ss << " ";
487 }
488 ss << _unit->getName(_game->getLanguage(), BattlescapeGame::_debugPlay);
489 _txtName->setBig();
490 _txtName->setText(ss.str());
491
492 ss.str(L"");
493 ss << _unit->getEnergy();
494 _numEnergy->setText(ss.str());
495 _barEnergy->setMax(_unit->getStats()->stamina);
496 _barEnergy->setValue(_unit->getEnergy());
497
498 ss.str(L"");
499 ss << _unit->getHealth();
500 _numHealth->setText(ss.str());
501 _barHealth->setMax(_unit->getStats()->health);
502 _barHealth->setValue(_unit->getHealth());
503 _barHealth->setValue2(_unit->getStunlevel());
504
505 ss.str(L"");
506 ss << _unit->getFatalWounds();
507 _numFatalWounds->setText(ss.str());
508 _barFatalWounds->setMax(_unit->getFatalWounds());
509 _barFatalWounds->setValue(_unit->getFatalWounds());
510
511 ss.str(L"");
512 ss << _unit->getStats()->bravery;
513 _numBravery->setText(ss.str());
514 _barBravery->setMax(_unit->getStats()->bravery);
515 _barBravery->setValue(_unit->getStats()->bravery);
516
517 ss.str(L"");
518 ss << _unit->getMorale();
519 _numMorale->setText(ss.str());
520 _barMorale->setMax(100);
521 _barMorale->setValue(_unit->getMorale());
522
523 ss.str(L"");
524 ss << _unit->getStats()->reactions;
525 _numReactions->setText(ss.str());
526 _barReactions->setMax(_unit->getStats()->reactions);
527 _barReactions->setValue(_unit->getStats()->reactions);
528
529 ss.str(L"");

Callers

nothing calls this directly

Calls 15

initFunction · 0.85
getTimeUnitsMethod · 0.80
setMaxMethod · 0.80
getLanguageMethod · 0.80
getEnergyMethod · 0.80
getHealthMethod · 0.80
setValue2Method · 0.80
getStunlevelMethod · 0.80
getFatalWoundsMethod · 0.80
getMoraleMethod · 0.80
isResearchedMethod · 0.80
getSavedGameMethod · 0.80

Tested by

no test coverage detected