| 1417 | } |
| 1418 | |
| 1419 | void BattleView::update() |
| 1420 | { |
| 1421 | bool realTime = battle.mode == Battle::Mode::RealTime; |
| 1422 | |
| 1423 | // Parent update |
| 1424 | BattleTileView::update(); |
| 1425 | |
| 1426 | // Update turn based stuff |
| 1427 | if (!realTime) |
| 1428 | { |
| 1429 | if (state->current_battle->hotseat) |
| 1430 | { |
| 1431 | if (state->current_battle->currentActiveOrganisation != |
| 1432 | state->current_battle->currentPlayer && |
| 1433 | state->current_battle->currentActiveOrganisation != state->getCivilian()) |
| 1434 | { |
| 1435 | fw().stageQueueCommand( |
| 1436 | {StageCmd::Command::PUSH, |
| 1437 | mksp<MessageBox>( |
| 1438 | "Next Turn", |
| 1439 | format("%s, it is your turn!", |
| 1440 | state->current_battle->currentActiveOrganisation->name), |
| 1441 | MessageBox::ButtonOptions::Ok, |
| 1442 | [this] { |
| 1443 | state->current_battle->currentPlayer = |
| 1444 | state->current_battle->currentActiveOrganisation; |
| 1445 | })}); |
| 1446 | updateHiddenForm(); |
| 1447 | return; |
| 1448 | } |
| 1449 | } |
| 1450 | |
| 1451 | // Figure out whether our/not our turn state has changed |
| 1452 | bool notMyTurn = endTurnRequested || battle.turnEndAllowed || |
| 1453 | !battle.interruptUnits.empty() || !battle.interruptQueue.empty() || |
| 1454 | battle.currentActiveOrganisation != battle.currentPlayer; |
| 1455 | if (notMyTurn && activeTab != notMyTurnTab) |
| 1456 | { |
| 1457 | setSelectedTab(notMyTurnTab); |
| 1458 | lastSelectedUnits = battle.battleViewSelectedUnits; |
| 1459 | battle.battleViewSelectedUnits.clear(); |
| 1460 | updateTBButtons(); |
| 1461 | } |
| 1462 | else if (!notMyTurn && activeTab == notMyTurnTab) |
| 1463 | { |
| 1464 | setSelectedTab(mainTab); |
| 1465 | battle.battleViewSelectedUnits = lastSelectedUnits; |
| 1466 | updateTBButtons(); |
| 1467 | } |
| 1468 | |
| 1469 | // Confirmation for units that have unfinished movement |
| 1470 | if (endTurnRequested && !unitPendingConfirmation && |
| 1471 | battle.ticksWithoutAction >= TICKS_TRY_END_TURN) |
| 1472 | { |
| 1473 | for (auto &u : battle.units) |
| 1474 | { |
| 1475 | if (u.second->owner != battle.currentActiveOrganisation || |
| 1476 | u.second->missions.empty() || |
nothing calls this directly
no test coverage detected