@@ -160,6 +160,7 @@ InventoryState::InventoryState(Game *game, bool tu, BattlescapeState *parent) :
160160
161161 _btnOk->onMouseClick ((ActionHandler)&InventoryState::btnOkClick);
162162 _btnOk->onKeyboardPress ((ActionHandler)&InventoryState::btnOkClick, (SDLKey)Options::getInt (" keyCancel" ));
163+ _btnOk->onKeyboardPress ((ActionHandler)&InventoryState::btnOkClick, (SDLKey)Options::getInt (" keyBattleInventory" ));
163164 _btnPrev->onMouseClick ((ActionHandler)&InventoryState::btnPrevClick);
164165 _btnPrev->onKeyboardPress ((ActionHandler)&InventoryState::btnPrevClick, (SDLKey)Options::getInt (" keyBattlePrevUnit" ));
165166 _btnNext->onMouseClick ((ActionHandler)&InventoryState::btnNextClick);
@@ -172,6 +173,8 @@ InventoryState::InventoryState(Game *game, bool tu, BattlescapeState *parent) :
172173 _inv->setTuMode (_tu);
173174 _inv->setSelectedUnit (_game->getSavedGame ()->getSavedBattle ()->getSelectedUnit ());
174175 _inv->onMouseClick ((ActionHandler)&InventoryState::invClick, 0 );
176+ _inv->onMouseOver ((ActionHandler)&InventoryState::invMouseOver);
177+ _inv->onMouseOut ((ActionHandler)&InventoryState::invMouseOut);
175178}
176179
177180/* *
@@ -433,11 +436,13 @@ void InventoryState::btnUnloadClick(Action *)
433436{
434437 if (_inv->getSelectedItem () != 0 && _inv->getSelectedItem ()->getAmmoItem () != 0 && _inv->getSelectedItem ()->needsAmmo ())
435438 {
436- _inv->unload ();
437- _txtItem->setText (L" " );
438- _txtAmmo->setText (L" " );
439- _selAmmo->clear ();
440- updateStats ();
439+ if (_inv->unload ())
440+ {
441+ _txtItem->setText (L" " );
442+ _txtAmmo->setText (L" " );
443+ _selAmmo->clear ();
444+ updateStats ();
445+ }
441446 }
442447}
443448
@@ -465,10 +470,21 @@ void InventoryState::btnRankClick(Action *)
465470 */
466471void InventoryState::invClick (Action *)
467472{
468- BattleItem *item = _inv->getSelectedItem ();
469- _txtItem->setText (L" " );
470- _txtAmmo->setText (L" " );
471- _selAmmo->clear ();
473+ updateStats ();
474+ }
475+
476+ /* *
477+ * Shows item info.
478+ * @param action Pointer to an action.
479+ */
480+ void InventoryState::invMouseOver (Action *)
481+ {
482+ if (_inv->getSelectedItem () != 0 )
483+ {
484+ return ;
485+ }
486+
487+ BattleItem *item = _inv->getMouseOverItem ();
472488 if (item != 0 )
473489 {
474490 if (item->getUnit () && item->getUnit ()->getStatus () == STATUS_UNCONSCIOUS )
@@ -506,10 +522,36 @@ void InventoryState::invClick(Action *)
506522 else if (item->getAmmoQuantity () != 0 && item->needsAmmo ())
507523 {
508524 s = tr (" STR_AMMO_ROUNDS_LEFT" ).arg (item->getAmmoQuantity ());
525+ _selAmmo->clear ();
526+ }
527+ else
528+ {
529+ _selAmmo->clear ();
509530 }
510531 _txtAmmo->setText (s);
511532 }
512- updateStats ();
533+ else
534+ {
535+ _txtItem->setText (L" " );
536+ _txtAmmo->setText (L" " );
537+ _selAmmo->clear ();
538+ }
539+ }
540+
541+ /* *
542+ * Hides item info.
543+ * @param action Pointer to an action.
544+ */
545+ void InventoryState::invMouseOut (Action *)
546+ {
547+ if (_inv->getSelectedItem () != 0 )
548+ {
549+ return ;
550+ }
551+
552+ _txtItem->setText (L" " );
553+ _txtAmmo->setText (L" " );
554+ _selAmmo->clear ();
513555}
514556
515557/* *
0 commit comments