|
|
|
@ -14,6 +14,7 @@
|
|
|
|
|
#include "../mwworld/esmstore.hpp"
|
|
|
|
|
|
|
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
|
#include "../mwbase/mechanicsmanager.hpp"
|
|
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
|
#include "../mwbase/windowmanager.hpp"
|
|
|
|
|
|
|
|
|
@ -36,6 +37,7 @@ namespace MWGui
|
|
|
|
|
, mItemSelectionDialog(0)
|
|
|
|
|
, mMagicSelectionDialog(0)
|
|
|
|
|
, mSelectedIndex(-1)
|
|
|
|
|
, mActivatedIndex(-1)
|
|
|
|
|
{
|
|
|
|
|
getWidget(mOkButton, "OKButton");
|
|
|
|
|
getWidget(mInstructionLabel, "InstructionLabel");
|
|
|
|
@ -69,6 +71,8 @@ namespace MWGui
|
|
|
|
|
|
|
|
|
|
void QuickKeysMenu::clear()
|
|
|
|
|
{
|
|
|
|
|
mActivatedIndex = -1;
|
|
|
|
|
|
|
|
|
|
for (int i=0; i<10; ++i)
|
|
|
|
|
{
|
|
|
|
|
unassign(mQuickKeyButtons[i], i);
|
|
|
|
@ -254,6 +258,15 @@ namespace MWGui
|
|
|
|
|
mMagicSelectionDialog->setVisible(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QuickKeysMenu::updateActivatedQuickKey()
|
|
|
|
|
{
|
|
|
|
|
// there is no delayed action, nothing to do.
|
|
|
|
|
if (mActivatedIndex < 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
activateQuickKey(mActivatedIndex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QuickKeysMenu::activateQuickKey(int index)
|
|
|
|
|
{
|
|
|
|
|
assert (index-1 >= 0);
|
|
|
|
@ -263,6 +276,27 @@ namespace MWGui
|
|
|
|
|
|
|
|
|
|
MWWorld::Ptr player = MWMechanics::getPlayer();
|
|
|
|
|
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);
|
|
|
|
|
const MWMechanics::CreatureStats &playerStats = player.getClass().getCreatureStats(player);
|
|
|
|
|
|
|
|
|
|
// Delay action executing,
|
|
|
|
|
// if player is busy for now (casting a spell, attacking someone, etc.)
|
|
|
|
|
bool isDelayNeeded = MWBase::Environment::get().getMechanicsManager()->isAttackingOrSpell(player)
|
|
|
|
|
|| playerStats.getKnockedDown()
|
|
|
|
|
|| playerStats.getHitRecovery();
|
|
|
|
|
|
|
|
|
|
bool isReturnNeeded = playerStats.isParalyzed() || playerStats.isDead();
|
|
|
|
|
if (isReturnNeeded && type != Type_Item)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isDelayNeeded && type != Type_Item)
|
|
|
|
|
{
|
|
|
|
|
mActivatedIndex = index;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
mActivatedIndex = -1;
|
|
|
|
|
|
|
|
|
|
if (type == Type_Item || type == Type_MagicItem)
|
|
|
|
|
{
|
|
|
|
@ -309,6 +343,21 @@ namespace MWGui
|
|
|
|
|
else if (type == Type_Item)
|
|
|
|
|
{
|
|
|
|
|
MWWorld::Ptr item = *button->getUserData<MWWorld::Ptr>();
|
|
|
|
|
bool isWeapon = item.getTypeName() == typeid(ESM::Weapon).name();
|
|
|
|
|
|
|
|
|
|
// delay weapon switching if player is busy
|
|
|
|
|
if (isDelayNeeded && isWeapon)
|
|
|
|
|
{
|
|
|
|
|
mActivatedIndex = index;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// disable weapon switching if player is dead or paralyzed
|
|
|
|
|
if (isReturnNeeded && isWeapon)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->useItem(item);
|
|
|
|
|
MWWorld::ConstContainerStoreIterator rightHand = store.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
|
|
|
|
// change draw state only if the item is in player's right hand
|
|
|
|
|