@@ -138,12 +138,12 @@ BattlescapeState::BattlescapeState(Game *game) : State(game), _popups()
138138 _numAmmoLeft = new NumberText (30 , 5 , _icons->getX () + 8 , _icons->getY () + 4 );
139139 _btnRightHandItem = new InteractiveSurface (32 , 48 , _icons->getX () + 280 , _icons->getY () + 5 );
140140 _numAmmoRight = new NumberText (30 , 5 , _icons->getX () + 280 , _icons->getY () + 4 );
141- for (int i = 0 ; i < 10 ; ++i)
141+ for (int i = 0 ; i < VISIBLE_MAX ; ++i)
142142 {
143143 _btnVisibleUnit[i] = new InteractiveSurface (15 , 12 , _icons->getX () + iconsWidth - 20 , _icons->getY () - 16 - (i * 13 ));
144144 _numVisibleUnit[i] = new NumberText (15 , 12 , _icons->getX () + iconsWidth - 14 , _icons->getY () - 12 - (i * 13 ));
145145 }
146- _numVisibleUnit[9 ]->setX (304 ); // center number 10
146+ _numVisibleUnit[9 ]->setX (_numVisibleUnit[ 9 ]-> getX () - 2 ); // center number 10
147147 _warning = new WarningMessage (224 , 24 , _icons->getX () + 48 , _icons->getY () + 32 );
148148 _btnLaunch = new InteractiveSurface (32 , 24 , game->getScreen ()->getWidth () / game->getScreen ()->getXScale () - 32 , 0 );
149149 _btnLaunch->setVisible (false );
@@ -234,7 +234,7 @@ BattlescapeState::BattlescapeState(Game *game) : State(game), _popups()
234234 add (_numAmmoLeft);
235235 add (_btnRightHandItem);
236236 add (_numAmmoRight);
237- for (int i = 0 ; i < 10 ; ++i)
237+ for (int i = 0 ; i < VISIBLE_MAX ; ++i)
238238 {
239239 add (_btnVisibleUnit[i]);
240240 add (_numVisibleUnit[i]);
@@ -365,13 +365,7 @@ BattlescapeState::BattlescapeState(Game *game) : State(game), _popups()
365365 _btnStats->onMouseOut ((ActionHandler)&BattlescapeState::txtTooltipOut);
366366
367367 _btnLeftHandItem->onMouseClick ((ActionHandler)&BattlescapeState::btnLeftHandItemClick);
368- _btnLeftHandItem->setTooltip (" STR_LEFT_HAND" );
369- _btnLeftHandItem->onMouseIn ((ActionHandler)&BattlescapeState::txtTooltipIn);
370- _btnLeftHandItem->onMouseOut ((ActionHandler)&BattlescapeState::txtTooltipOut);
371368 _btnRightHandItem->onMouseClick ((ActionHandler)&BattlescapeState::btnRightHandItemClick);
372- _btnRightHandItem->setTooltip (" STR_RIGHT_HAND" );
373- _btnRightHandItem->onMouseIn ((ActionHandler)&BattlescapeState::txtTooltipIn);
374- _btnRightHandItem->onMouseOut ((ActionHandler)&BattlescapeState::txtTooltipOut);
375369
376370 _btnReserveNone->onMouseClick ((ActionHandler)&BattlescapeState::btnReserveClick);
377371 _btnReserveNone->onKeyboardPress ((ActionHandler)&BattlescapeState::btnReserveClick, (SDLKey)Options::getInt (" keyBattleReserveNone" ));
@@ -408,7 +402,7 @@ BattlescapeState::BattlescapeState(Game *game) : State(game), _popups()
408402 _btnStats->onKeyboardPress ((ActionHandler)&BattlescapeState::btnReloadClick, (SDLKey)Options::getInt (" keyBattleReload" ));
409403 _btnStats->onKeyboardPress ((ActionHandler)&BattlescapeState::btnPersonalLightingClick, (SDLKey)Options::getInt (" keyBattlePersonalLighting" ));
410404
411- for (int i = 0 ; i < 10 ; ++i)
405+ for (int i = 0 ; i < VISIBLE_MAX ; ++i)
412406 {
413407 std::stringstream key, tooltip;
414408 key << " keyBattleCenterEnemy" << (i+1 );
@@ -902,7 +896,7 @@ void BattlescapeState::btnShowLayersClick(Action *)
902896 */
903897void BattlescapeState::btnHelpClick (Action *)
904898{
905- if (_map-> getProjectile () == 0 ) // we're deliberately not using allowButtons() here, so we can save if something goes wrong during the alien turn, and submit it for dissection.
899+ if (allowButtons (true ))
906900 _game->pushState (new BattlescapeOptionsState (_game));
907901}
908902
@@ -998,7 +992,7 @@ void BattlescapeState::btnVisibleUnitClick(Action *action)
998992 int btnID = -1 ;
999993
1000994 // got to find out which button was pressed
1001- for (int i = 0 ; i < 10 && btnID == -1 ; ++i)
995+ for (int i = 0 ; i < VISIBLE_MAX && btnID == -1 ; ++i)
1002996 {
1003997 if (action->getSender () == _btnVisibleUnit[i])
1004998 {
@@ -1099,7 +1093,7 @@ void BattlescapeState::updateSoldierInfo()
10991093{
11001094 BattleUnit *battleUnit = _save->getSelectedUnit ();
11011095
1102- for (int i = 0 ; i < 10 ; ++i)
1096+ for (int i = 0 ; i < VISIBLE_MAX ; ++i)
11031097 {
11041098 _btnVisibleUnit[i]->setVisible (false );
11051099 _numVisibleUnit[i]->setVisible (false );
@@ -1189,7 +1183,7 @@ void BattlescapeState::updateSoldierInfo()
11891183
11901184 _save->getTileEngine ()->calculateFOV (_save->getSelectedUnit ());
11911185 int j = 0 ;
1192- for (std::vector<BattleUnit*>::iterator i = battleUnit->getVisibleUnits ()->begin (); i != battleUnit->getVisibleUnits ()->end (); ++i)
1186+ for (std::vector<BattleUnit*>::iterator i = battleUnit->getVisibleUnits ()->begin (); i != battleUnit->getVisibleUnits ()->end () && j < VISIBLE_MAX ; ++i)
11931187 {
11941188 _btnVisibleUnit[j]->setVisible (true );
11951189 _numVisibleUnit[j]->setVisible (true );
@@ -1218,7 +1212,7 @@ void BattlescapeState::blinkVisibleUnitButtons()
12181212 square2.w = 13 ;
12191213 square2.h = 10 ;
12201214
1221- for (int i = 0 ; i < 10 ; ++i)
1215+ for (int i = 0 ; i < VISIBLE_MAX ; ++i)
12221216 {
12231217 if (_btnVisibleUnit[i]->getVisible () == true )
12241218 {
@@ -1849,11 +1843,18 @@ bool BattlescapeState::getMouseOverIcons() const
18491843}
18501844
18511845/* *
1852- * Determines whether the player is allowed to press buttons?
1846+ * Determines whether the player is allowed to press buttons.
1847+ * Buttons are disabled in the middle of a shot, during the alien turn,
1848+ * and while a player's units are panicking.
1849+ * The save button is an exception as we want to still be able to save if something
1850+ * goes wrong during the alien turn, and submit the save file for dissection.
1851+ * @param allowSaving True, if the help button was clicked.
18531852 */
1854- bool BattlescapeState::allowButtons () const
1853+ bool BattlescapeState::allowButtons (bool allowSaving ) const
18551854{
1856- return (_save->getSide () == FACTION_PLAYER || _save->getDebugMode ()) && _map->getProjectile () == 0 ;
1855+ return ((allowSaving || _save->getSide () == FACTION_PLAYER || _save->getDebugMode ())
1856+ && _battleGame->getPanicHandled ()
1857+ && (_map->getProjectile () == 0 ));
18571858}
18581859
18591860/* *
0 commit comments