* Updates soldier stats when * the soldier changes. */
| 398 | * the soldier changes. |
| 399 | */ |
| 400 | void SoldierInfoState::init() |
| 401 | { |
| 402 | State::init(); |
| 403 | if (_list->empty()) |
| 404 | { |
| 405 | _game->popState(); |
| 406 | return; |
| 407 | } |
| 408 | if (_soldierId >= _list->size()) |
| 409 | { |
| 410 | _soldierId = 0; |
| 411 | } |
| 412 | _soldier = _list->at(_soldierId); |
| 413 | _edtSoldier->setBig(); |
| 414 | _edtSoldier->setText(_soldier->getName()); |
| 415 | UnitStats *initial = _soldier->getInitStats(); |
| 416 | UnitStats *current = _soldier->getCurrentStats(); |
| 417 | |
| 418 | SurfaceSet *texture = _game->getResourcePack()->getSurfaceSet("BASEBITS.PCK"); |
| 419 | texture->getFrame(_soldier->getRankSprite())->setX(0); |
| 420 | texture->getFrame(_soldier->getRankSprite())->setY(0); |
| 421 | texture->getFrame(_soldier->getRankSprite())->blit(_rank); |
| 422 | |
| 423 | std::wostringstream ss; |
| 424 | ss << current->tu; |
| 425 | _numTimeUnits->setText(ss.str()); |
| 426 | _barTimeUnits->setMax(current->tu); |
| 427 | _barTimeUnits->setValue(current->tu); |
| 428 | _barTimeUnits->setValue2(initial->tu); |
| 429 | |
| 430 | std::wostringstream ss2; |
| 431 | ss2 << current->stamina; |
| 432 | _numStamina->setText(ss2.str()); |
| 433 | _barStamina->setMax(current->stamina); |
| 434 | _barStamina->setValue(current->stamina); |
| 435 | _barStamina->setValue2(initial->stamina); |
| 436 | |
| 437 | std::wostringstream ss3; |
| 438 | ss3 << current->health; |
| 439 | _numHealth->setText(ss3.str()); |
| 440 | _barHealth->setMax(current->health); |
| 441 | _barHealth->setValue(current->health); |
| 442 | _barHealth->setValue2(initial->health); |
| 443 | |
| 444 | std::wostringstream ss4; |
| 445 | ss4 << current->bravery; |
| 446 | _numBravery->setText(ss4.str()); |
| 447 | _barBravery->setMax(current->bravery); |
| 448 | _barBravery->setValue(current->bravery); |
| 449 | _barBravery->setValue2(initial->bravery); |
| 450 | |
| 451 | std::wostringstream ss5; |
| 452 | ss5 << current->reactions; |
| 453 | _numReactions->setText(ss5.str()); |
| 454 | _barReactions->setMax(current->reactions); |
| 455 | _barReactions->setValue(current->reactions); |
| 456 | _barReactions->setValue2(initial->reactions); |
| 457 |
nothing calls this directly
no test coverage detected