|
|
@ -33,44 +33,41 @@ namespace MWGui
|
|
|
|
|
|
|
|
|
|
|
|
QuickKeysMenu::QuickKeysMenu()
|
|
|
|
QuickKeysMenu::QuickKeysMenu()
|
|
|
|
: WindowBase("openmw_quickkeys_menu.layout")
|
|
|
|
: WindowBase("openmw_quickkeys_menu.layout")
|
|
|
|
|
|
|
|
, mKey(std::vector<keyData>(10))
|
|
|
|
|
|
|
|
, mSelected(nullptr)
|
|
|
|
|
|
|
|
, mActivated(nullptr)
|
|
|
|
, mAssignDialog(0)
|
|
|
|
, mAssignDialog(0)
|
|
|
|
, mItemSelectionDialog(0)
|
|
|
|
, mItemSelectionDialog(0)
|
|
|
|
, mMagicSelectionDialog(0)
|
|
|
|
, mMagicSelectionDialog(0)
|
|
|
|
, mSelectedIndex(-1)
|
|
|
|
|
|
|
|
, mActivatedIndex(-1)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
getWidget(mOkButton, "OKButton");
|
|
|
|
getWidget(mOkButton, "OKButton");
|
|
|
|
getWidget(mInstructionLabel, "InstructionLabel");
|
|
|
|
getWidget(mInstructionLabel, "InstructionLabel");
|
|
|
|
|
|
|
|
|
|
|
|
mMainWidget->setSize(mMainWidget->getWidth(),
|
|
|
|
mMainWidget->setSize(mMainWidget->getWidth(),
|
|
|
|
mMainWidget->getHeight() + (mInstructionLabel->getTextSize().height - mInstructionLabel->getHeight()));
|
|
|
|
mMainWidget->getHeight() +
|
|
|
|
|
|
|
|
(mInstructionLabel->getTextSize().height - mInstructionLabel->getHeight()));
|
|
|
|
|
|
|
|
|
|
|
|
mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onOkButtonClicked);
|
|
|
|
mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onOkButtonClicked);
|
|
|
|
center();
|
|
|
|
center();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 10; ++i)
|
|
|
|
for (int i = 0; i < 10; ++i)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ItemWidget* button;
|
|
|
|
mKey[i].index = i+1;
|
|
|
|
getWidget(button, "QuickKey" + MyGUI::utility::toString(i+1));
|
|
|
|
getWidget(mKey[i].button, "QuickKey" + MyGUI::utility::toString(i+1));
|
|
|
|
|
|
|
|
mKey[i].button->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onQuickKeyButtonClicked);
|
|
|
|
button->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onQuickKeyButtonClicked);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mQuickKeyButtons.push_back(button);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mAssigned.push_back(Type_Unassigned);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unassign(button, i);
|
|
|
|
unassign(&mKey[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QuickKeysMenu::clear()
|
|
|
|
void QuickKeysMenu::clear()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mActivatedIndex = -1;
|
|
|
|
mActivated = nullptr;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i=0; i<10; ++i)
|
|
|
|
for (int i=0; i<10; ++i)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
unassign(mQuickKeyButtons[i], i);
|
|
|
|
unassign(&mKey[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -91,10 +88,7 @@ namespace MWGui
|
|
|
|
// Check if quick keys are still valid
|
|
|
|
// Check if quick keys are still valid
|
|
|
|
for (int i=0; i<10; ++i)
|
|
|
|
for (int i=0; i<10; ++i)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ItemWidget* button = mQuickKeyButtons[i];
|
|
|
|
switch (mKey[i].type)
|
|
|
|
int type = mAssigned[i];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case Type_Unassigned:
|
|
|
|
case Type_Unassigned:
|
|
|
|
case Type_HandToHand:
|
|
|
|
case Type_HandToHand:
|
|
|
@ -103,49 +97,55 @@ namespace MWGui
|
|
|
|
case Type_Item:
|
|
|
|
case Type_Item:
|
|
|
|
case Type_MagicItem:
|
|
|
|
case Type_MagicItem:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MWWorld::Ptr item = *button->getUserData<MWWorld::Ptr>();
|
|
|
|
MWWorld::Ptr item = *mKey[i].button->getUserData<MWWorld::Ptr>();
|
|
|
|
// Make sure the item is available and is not broken
|
|
|
|
// Make sure the item is available and is not broken
|
|
|
|
if (item.getRefData().getCount() < 1 ||
|
|
|
|
if (!item || item.getRefData().getCount() < 1 ||
|
|
|
|
(item.getClass().hasItemHealth(item) &&
|
|
|
|
(item.getClass().hasItemHealth(item) &&
|
|
|
|
item.getClass().getItemHealth(item) <= 0))
|
|
|
|
item.getClass().getItemHealth(item) <= 0))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Try searching for a compatible replacement
|
|
|
|
// Try searching for a compatible replacement
|
|
|
|
std::string id = item.getCellRef().getRefId();
|
|
|
|
item = store.findReplacement(mKey[i].id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (item)
|
|
|
|
|
|
|
|
mKey[i].button->setUserData(MWWorld::Ptr(item));
|
|
|
|
|
|
|
|
|
|
|
|
item = store.findReplacement(id);
|
|
|
|
|
|
|
|
button->setUserData(MWWorld::Ptr(item));
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QuickKeysMenu::unassign(ItemWidget* key, int index)
|
|
|
|
void QuickKeysMenu::unassign(keyData* key)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
key->clearUserStrings();
|
|
|
|
key->button->clearUserStrings();
|
|
|
|
key->setItem(MWWorld::Ptr());
|
|
|
|
key->button->setItem(MWWorld::Ptr());
|
|
|
|
while (key->getChildCount()) // Destroy number label
|
|
|
|
|
|
|
|
MyGUI::Gui::getInstance().destroyWidget(key->getChildAt(0));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (index == 9)
|
|
|
|
while (key->button->getChildCount()) // Destroy number label
|
|
|
|
|
|
|
|
MyGUI::Gui::getInstance().destroyWidget(key->button->getChildAt(0));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (key->index == 9)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mAssigned[index] = Type_HandToHand;
|
|
|
|
key->type = Type_HandToHand;
|
|
|
|
|
|
|
|
|
|
|
|
MyGUI::ImageBox* image = key->createWidget<MyGUI::ImageBox>("ImageBox",
|
|
|
|
MyGUI::ImageBox* image = key->button->createWidget<MyGUI::ImageBox>("ImageBox",
|
|
|
|
MyGUI::IntCoord(14, 13, 32, 32), MyGUI::Align::Default);
|
|
|
|
MyGUI::IntCoord(14, 13, 32, 32), MyGUI::Align::Default);
|
|
|
|
|
|
|
|
|
|
|
|
image->setImageTexture("icons\\k\\stealth_handtohand.dds");
|
|
|
|
image->setImageTexture("icons\\k\\stealth_handtohand.dds");
|
|
|
|
image->setNeedMouseFocus(false);
|
|
|
|
image->setNeedMouseFocus(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mAssigned[index] = Type_Unassigned;
|
|
|
|
key->type = Type_Unassigned;
|
|
|
|
|
|
|
|
key->id = "";
|
|
|
|
|
|
|
|
key->name = "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MyGUI::TextBox* textBox = key->button->createWidgetReal<MyGUI::TextBox>("SandText",
|
|
|
|
|
|
|
|
MyGUI::FloatCoord(0,0,1,1), MyGUI::Align::Default);
|
|
|
|
|
|
|
|
|
|
|
|
MyGUI::TextBox* textBox = key->createWidgetReal<MyGUI::TextBox>("SandText", MyGUI::FloatCoord(0,0,1,1), MyGUI::Align::Default);
|
|
|
|
textBox->setTextAlign(MyGUI::Align::Center);
|
|
|
|
textBox->setTextAlign (MyGUI::Align::Center);
|
|
|
|
textBox->setCaption(MyGUI::utility::toString(key->index));
|
|
|
|
textBox->setCaption (MyGUI::utility::toString(index+1));
|
|
|
|
textBox->setNeedMouseFocus(false);
|
|
|
|
textBox->setNeedMouseFocus (false);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -154,19 +154,20 @@ namespace MWGui
|
|
|
|
int index = -1;
|
|
|
|
int index = -1;
|
|
|
|
for (int i = 0; i < 10; ++i)
|
|
|
|
for (int i = 0; i < 10; ++i)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (sender == mQuickKeyButtons[i] || sender->getParent () == mQuickKeyButtons[i])
|
|
|
|
if (sender == mKey[i].button || sender->getParent() == mKey[i].button)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
index = i;
|
|
|
|
index = i;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
assert(index != -1);
|
|
|
|
assert(index != -1);
|
|
|
|
mSelectedIndex = index;
|
|
|
|
mSelected = &mKey[index];
|
|
|
|
|
|
|
|
|
|
|
|
// open assign dialog
|
|
|
|
// open assign dialog
|
|
|
|
if (!mAssignDialog)
|
|
|
|
if (!mAssignDialog)
|
|
|
|
mAssignDialog = new QuickKeysMenuAssign(this);
|
|
|
|
mAssignDialog = new QuickKeysMenuAssign(this);
|
|
|
|
mAssignDialog->setVisible (true);
|
|
|
|
|
|
|
|
|
|
|
|
mAssignDialog->setVisible(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QuickKeysMenu::onOkButtonClicked (MyGUI::Widget *sender)
|
|
|
|
void QuickKeysMenu::onOkButtonClicked (MyGUI::Widget *sender)
|
|
|
@ -174,10 +175,9 @@ namespace MWGui
|
|
|
|
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_QuickKeysMenu);
|
|
|
|
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_QuickKeysMenu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QuickKeysMenu::onItemButtonClicked(MyGUI::Widget* sender)
|
|
|
|
void QuickKeysMenu::onItemButtonClicked(MyGUI::Widget* sender)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!mItemSelectionDialog )
|
|
|
|
if (!mItemSelectionDialog)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mItemSelectionDialog = new ItemSelectionDialog("#{sQuickMenu6}");
|
|
|
|
mItemSelectionDialog = new ItemSelectionDialog("#{sQuickMenu6}");
|
|
|
|
mItemSelectionDialog->eventItemSelected += MyGUI::newDelegate(this, &QuickKeysMenu::onAssignItem);
|
|
|
|
mItemSelectionDialog->eventItemSelected += MyGUI::newDelegate(this, &QuickKeysMenu::onAssignItem);
|
|
|
@ -187,43 +187,45 @@ namespace MWGui
|
|
|
|
mItemSelectionDialog->openContainer(MWMechanics::getPlayer());
|
|
|
|
mItemSelectionDialog->openContainer(MWMechanics::getPlayer());
|
|
|
|
mItemSelectionDialog->setFilter(SortFilterItemModel::Filter_OnlyUsableItems);
|
|
|
|
mItemSelectionDialog->setFilter(SortFilterItemModel::Filter_OnlyUsableItems);
|
|
|
|
|
|
|
|
|
|
|
|
mAssignDialog->setVisible (false);
|
|
|
|
mAssignDialog->setVisible(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QuickKeysMenu::onMagicButtonClicked(MyGUI::Widget* sender)
|
|
|
|
void QuickKeysMenu::onMagicButtonClicked(MyGUI::Widget* sender)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!mMagicSelectionDialog )
|
|
|
|
if (!mMagicSelectionDialog)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mMagicSelectionDialog = new MagicSelectionDialog(this);
|
|
|
|
mMagicSelectionDialog = new MagicSelectionDialog(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mMagicSelectionDialog->setVisible(true);
|
|
|
|
mMagicSelectionDialog->setVisible(true);
|
|
|
|
|
|
|
|
|
|
|
|
mAssignDialog->setVisible (false);
|
|
|
|
mAssignDialog->setVisible(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QuickKeysMenu::onUnassignButtonClicked(MyGUI::Widget* sender)
|
|
|
|
void QuickKeysMenu::onUnassignButtonClicked(MyGUI::Widget* sender)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
unassign(mQuickKeyButtons[mSelectedIndex], mSelectedIndex);
|
|
|
|
unassign(mSelected);
|
|
|
|
mAssignDialog->setVisible (false);
|
|
|
|
mAssignDialog->setVisible(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QuickKeysMenu::onCancelButtonClicked(MyGUI::Widget* sender)
|
|
|
|
void QuickKeysMenu::onCancelButtonClicked(MyGUI::Widget* sender)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mAssignDialog->setVisible (false);
|
|
|
|
mAssignDialog->setVisible(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QuickKeysMenu::onAssignItem(MWWorld::Ptr item)
|
|
|
|
void QuickKeysMenu::onAssignItem(MWWorld::Ptr item)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
assert (mSelectedIndex >= 0);
|
|
|
|
assert(mSelected);
|
|
|
|
ItemWidget* button = mQuickKeyButtons[mSelectedIndex];
|
|
|
|
|
|
|
|
while (button->getChildCount()) // Destroy number label
|
|
|
|
|
|
|
|
MyGUI::Gui::getInstance().destroyWidget(button->getChildAt(0));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mAssigned[mSelectedIndex] = Type_Item;
|
|
|
|
while (mSelected->button->getChildCount()) // Destroy number label
|
|
|
|
|
|
|
|
MyGUI::Gui::getInstance().destroyWidget(mSelected->button->getChildAt(0));
|
|
|
|
|
|
|
|
|
|
|
|
button->setItem(item, ItemWidget::Barter);
|
|
|
|
mSelected->type = Type_Item;
|
|
|
|
button->setUserString ("ToolTipType", "ItemPtr");
|
|
|
|
mSelected->id = item.getCellRef().getRefId();
|
|
|
|
button->setUserData(MWWorld::Ptr(item));
|
|
|
|
mSelected->name = item.getClass().getName(item);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mSelected->button->setItem(item, ItemWidget::Barter);
|
|
|
|
|
|
|
|
mSelected->button->setUserString("ToolTipType", "ItemPtr");
|
|
|
|
|
|
|
|
mSelected->button->setUserData(item);
|
|
|
|
|
|
|
|
|
|
|
|
if (mItemSelectionDialog)
|
|
|
|
if (mItemSelectionDialog)
|
|
|
|
mItemSelectionDialog->setVisible(false);
|
|
|
|
mItemSelectionDialog->setVisible(false);
|
|
|
@ -234,40 +236,39 @@ namespace MWGui
|
|
|
|
mItemSelectionDialog->setVisible(false);
|
|
|
|
mItemSelectionDialog->setVisible(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QuickKeysMenu::onAssignMagicItem (MWWorld::Ptr item)
|
|
|
|
void QuickKeysMenu::onAssignMagicItem(MWWorld::Ptr item)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
assert (mSelectedIndex >= 0);
|
|
|
|
assert(mSelected);
|
|
|
|
ItemWidget* button = mQuickKeyButtons[mSelectedIndex];
|
|
|
|
|
|
|
|
while (button->getChildCount()) // Destroy number label
|
|
|
|
while (mSelected->button->getChildCount()) // Destroy number label
|
|
|
|
MyGUI::Gui::getInstance().destroyWidget(button->getChildAt(0));
|
|
|
|
MyGUI::Gui::getInstance().destroyWidget(mSelected->button->getChildAt(0));
|
|
|
|
|
|
|
|
|
|
|
|
mAssigned[mSelectedIndex] = Type_MagicItem;
|
|
|
|
mSelected->type = Type_MagicItem;
|
|
|
|
|
|
|
|
|
|
|
|
button->setFrame("textures\\menu_icon_select_magic_magic.dds", MyGUI::IntCoord(2, 2, 40, 40));
|
|
|
|
mSelected->button->setFrame("textures\\menu_icon_select_magic_magic.dds", MyGUI::IntCoord(2, 2, 40, 40));
|
|
|
|
button->setIcon(item);
|
|
|
|
mSelected->button->setIcon(item);
|
|
|
|
|
|
|
|
|
|
|
|
button->setUserString ("ToolTipType", "ItemPtr");
|
|
|
|
mSelected->button->setUserString("ToolTipType", "ItemPtr");
|
|
|
|
button->setUserData(MWWorld::Ptr(item));
|
|
|
|
mSelected->button->setUserData(MWWorld::Ptr(item));
|
|
|
|
|
|
|
|
|
|
|
|
if (mMagicSelectionDialog)
|
|
|
|
if (mMagicSelectionDialog)
|
|
|
|
mMagicSelectionDialog->setVisible(false);
|
|
|
|
mMagicSelectionDialog->setVisible(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QuickKeysMenu::onAssignMagic (const std::string& spellId)
|
|
|
|
void QuickKeysMenu::onAssignMagic(const std::string& spellId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
assert (mSelectedIndex >= 0);
|
|
|
|
assert(mSelected);
|
|
|
|
ItemWidget* button = mQuickKeyButtons[mSelectedIndex];
|
|
|
|
while (mSelected->button->getChildCount()) // Destroy number label
|
|
|
|
while (button->getChildCount()) // Destroy number label
|
|
|
|
MyGUI::Gui::getInstance().destroyWidget(mSelected->button->getChildAt(0));
|
|
|
|
MyGUI::Gui::getInstance().destroyWidget(button->getChildAt(0));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mAssigned[mSelectedIndex] = Type_Magic;
|
|
|
|
mSelected->type = Type_Magic;
|
|
|
|
|
|
|
|
mSelected->id = spellId;
|
|
|
|
|
|
|
|
|
|
|
|
button->setItem(MWWorld::Ptr());
|
|
|
|
mSelected->button->setItem(MWWorld::Ptr());
|
|
|
|
button->setUserString ("ToolTipType", "Spell");
|
|
|
|
mSelected->button->setUserString("ToolTipType", "Spell");
|
|
|
|
button->setUserString ("Spell", spellId);
|
|
|
|
mSelected->button->setUserString("Spell", spellId);
|
|
|
|
|
|
|
|
|
|
|
|
const MWWorld::ESMStore &esmStore =
|
|
|
|
const MWWorld::ESMStore &esmStore = MWBase::Environment::get().getWorld()->getStore();
|
|
|
|
MWBase::Environment::get().getWorld()->getStore();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// use the icon of the first effect
|
|
|
|
// use the icon of the first effect
|
|
|
|
const ESM::Spell* spell = esmStore.get<ESM::Spell>().find(spellId);
|
|
|
|
const ESM::Spell* spell = esmStore.get<ESM::Spell>().find(spellId);
|
|
|
@ -280,14 +281,14 @@ namespace MWGui
|
|
|
|
path.insert(slashPos+1, "b_");
|
|
|
|
path.insert(slashPos+1, "b_");
|
|
|
|
path = MWBase::Environment::get().getWindowManager()->correctIconPath(path);
|
|
|
|
path = MWBase::Environment::get().getWindowManager()->correctIconPath(path);
|
|
|
|
|
|
|
|
|
|
|
|
button->setFrame("textures\\menu_icon_select_magic.dds", MyGUI::IntCoord(2, 2, 40, 40));
|
|
|
|
mSelected->button->setFrame("textures\\menu_icon_select_magic.dds", MyGUI::IntCoord(2, 2, 40, 40));
|
|
|
|
button->setIcon(path);
|
|
|
|
mSelected->button->setIcon(path);
|
|
|
|
|
|
|
|
|
|
|
|
if (mMagicSelectionDialog)
|
|
|
|
if (mMagicSelectionDialog)
|
|
|
|
mMagicSelectionDialog->setVisible(false);
|
|
|
|
mMagicSelectionDialog->setVisible(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QuickKeysMenu::onAssignMagicCancel ()
|
|
|
|
void QuickKeysMenu::onAssignMagicCancel()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mMagicSelectionDialog->setVisible(false);
|
|
|
|
mMagicSelectionDialog->setVisible(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -295,18 +296,17 @@ namespace MWGui
|
|
|
|
void QuickKeysMenu::updateActivatedQuickKey()
|
|
|
|
void QuickKeysMenu::updateActivatedQuickKey()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// there is no delayed action, nothing to do.
|
|
|
|
// there is no delayed action, nothing to do.
|
|
|
|
if (mActivatedIndex < 0)
|
|
|
|
if (!mActivated)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
activateQuickKey(mActivatedIndex);
|
|
|
|
activateQuickKey(mActivated->index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QuickKeysMenu::activateQuickKey(int index)
|
|
|
|
void QuickKeysMenu::activateQuickKey(int index)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
assert (index-1 >= 0);
|
|
|
|
assert(index >= 1 && index <= 9);
|
|
|
|
ItemWidget* button = mQuickKeyButtons[index-1];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QuickKeyType type = mAssigned[index-1];
|
|
|
|
keyData *key = &mKey[index-1];
|
|
|
|
|
|
|
|
|
|
|
|
MWWorld::Ptr player = MWMechanics::getPlayer();
|
|
|
|
MWWorld::Ptr player = MWMechanics::getPlayer();
|
|
|
|
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);
|
|
|
|
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);
|
|
|
@ -319,117 +319,103 @@ namespace MWGui
|
|
|
|
|| playerStats.getHitRecovery();
|
|
|
|
|| playerStats.getHitRecovery();
|
|
|
|
|
|
|
|
|
|
|
|
bool isReturnNeeded = playerStats.isParalyzed() || playerStats.isDead();
|
|
|
|
bool isReturnNeeded = playerStats.isParalyzed() || playerStats.isDead();
|
|
|
|
if (isReturnNeeded && type != Type_Item)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isDelayNeeded && type != Type_Item)
|
|
|
|
if (isReturnNeeded)
|
|
|
|
{
|
|
|
|
|
|
|
|
mActivatedIndex = index;
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
else if (isDelayNeeded)
|
|
|
|
|
|
|
|
mActivated = key;
|
|
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
else
|
|
|
|
mActivatedIndex = -1;
|
|
|
|
mActivated = nullptr;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (type == Type_Item || type == Type_MagicItem)
|
|
|
|
if (key->type == Type_Item || key->type == Type_MagicItem)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MWWorld::Ptr item = *button->getUserData<MWWorld::Ptr>();
|
|
|
|
MWWorld::Ptr item = *key->button->getUserData<MWWorld::Ptr>();
|
|
|
|
// Make sure the item is available and is not broken
|
|
|
|
|
|
|
|
if (item.getRefData().getCount() < 1 ||
|
|
|
|
MWWorld::ContainerStoreIterator it = store.begin();
|
|
|
|
(item.getClass().hasItemHealth(item) &&
|
|
|
|
for (; it != store.end(); ++it)
|
|
|
|
item.getClass().getItemHealth(item) <= 0))
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Try searching for a compatible replacement
|
|
|
|
if (*it == item)
|
|
|
|
std::string id = item.getCellRef().getRefId();
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (it == store.end())
|
|
|
|
|
|
|
|
item = nullptr;
|
|
|
|
|
|
|
|
|
|
|
|
item = store.findReplacement(id);
|
|
|
|
// check the item is available and not broken
|
|
|
|
button->setUserData(MWWorld::Ptr(item));
|
|
|
|
if (!item || item.getRefData().getCount() < 1 ||
|
|
|
|
|
|
|
|
(item.getClass().hasItemHealth(item) && item.getClass().getItemHealth(item) <= 0))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
item = store.findReplacement(key->id);
|
|
|
|
|
|
|
|
|
|
|
|
if (item.getRefData().getCount() < 1)
|
|
|
|
if (!item || item.getRefData().getCount() < 1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// No replacement was found
|
|
|
|
MWBase::Environment::get().getWindowManager()->messageBox(
|
|
|
|
MWBase::Environment::get().getWindowManager ()->messageBox (
|
|
|
|
"#{sQuickMenu5} " + key->name);
|
|
|
|
"#{sQuickMenu5} " + item.getClass().getName(item));
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (type == Type_Magic)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
std::string spellId = button->getUserString("Spell");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Make sure the player still has this spell
|
|
|
|
if (key->type == Type_Item)
|
|
|
|
MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
|
|
|
|
|
|
|
|
MWMechanics::Spells& spells = stats.getSpells();
|
|
|
|
|
|
|
|
if (!spells.hasSpell(spellId))
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId);
|
|
|
|
bool isWeapon = item.getTypeName() == typeid(ESM::Weapon).name();
|
|
|
|
MWBase::Environment::get().getWindowManager()->messageBox (
|
|
|
|
bool isTool = item.getTypeName() == typeid(ESM::Probe).name() ||
|
|
|
|
"#{sQuickMenu5} " + spell->mName);
|
|
|
|
item.getTypeName() == typeid(ESM::Lockpick).name();
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
store.setSelectedEnchantItem(store.end());
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->setSelectedSpell(spellId, int(MWMechanics::getSpellSuccessChance(spellId, player)));
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWorld()->getPlayer().setDrawState(MWMechanics::DrawState_Spell);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (type == Type_Item)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MWWorld::Ptr item = *button->getUserData<MWWorld::Ptr>();
|
|
|
|
|
|
|
|
bool isWeapon = item.getTypeName() == typeid(ESM::Weapon).name();
|
|
|
|
|
|
|
|
bool isTool = item.getTypeName() == typeid(ESM::Probe).name() || item.getTypeName() == typeid(ESM::Lockpick).name();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// delay weapon switching if player is busy
|
|
|
|
// delay weapon switching if player is busy
|
|
|
|
if (isDelayNeeded && (isWeapon || isTool))
|
|
|
|
if (isDelayNeeded && (isWeapon || isTool))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mActivatedIndex = index;
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// disable weapon switching if player is dead or paralyzed
|
|
|
|
MWBase::Environment::get().getWindowManager()->useItem(item);
|
|
|
|
if (isReturnNeeded && (isWeapon || isTool))
|
|
|
|
MWWorld::ConstContainerStoreIterator rightHand = store.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
|
|
|
{
|
|
|
|
// change draw state only if the item is in player's right hand
|
|
|
|
return;
|
|
|
|
if (rightHand != store.end() && item == *rightHand)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWorld()->getPlayer().setDrawState(MWMechanics::DrawState_Weapon);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (key->type == Type_MagicItem)
|
|
|
|
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
|
|
|
|
|
|
|
|
if (rightHand != store.end() && item == *rightHand)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MWBase::Environment::get().getWorld()->getPlayer().setDrawState(MWMechanics::DrawState_Weapon);
|
|
|
|
// equip, if it can be equipped
|
|
|
|
|
|
|
|
if (!item.getClass().getEquipmentSlots(item).first.empty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->useItem(item);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// make sure that item was successfully equipped
|
|
|
|
|
|
|
|
if (!store.isEquipped(item))
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
store.setSelectedEnchantItem(it);
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWorld()->getPlayer().setDrawState(MWMechanics::DrawState_Spell);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (type == Type_MagicItem)
|
|
|
|
else if (key->type == Type_Magic)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MWWorld::Ptr item = *button->getUserData<MWWorld::Ptr>();
|
|
|
|
std::string spellId = key->id;
|
|
|
|
|
|
|
|
|
|
|
|
// retrieve ContainerStoreIterator to the item
|
|
|
|
// Make sure the player still has this spell
|
|
|
|
MWWorld::ContainerStoreIterator it = store.begin();
|
|
|
|
MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
|
|
|
|
for (; it != store.end(); ++it)
|
|
|
|
MWMechanics::Spells& spells = stats.getSpells();
|
|
|
|
{
|
|
|
|
|
|
|
|
if (*it == item)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(it != store.end());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// equip, if it can be equipped
|
|
|
|
if (!spells.hasSpell(spellId))
|
|
|
|
if (!item.getClass().getEquipmentSlots(item).first.empty())
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MWBase::Environment::get().getWindowManager()->useItem(item);
|
|
|
|
const ESM::Spell* spell =
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId);
|
|
|
|
// make sure that item was successfully equipped
|
|
|
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sQuickMenu5} " + spell->mName);
|
|
|
|
if (!store.isEquipped(item))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
store.setSelectedEnchantItem(it);
|
|
|
|
store.setSelectedEnchantItem(store.end());
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager()
|
|
|
|
|
|
|
|
->setSelectedSpell(spellId, int(MWMechanics::getSpellSuccessChance(spellId, player)));
|
|
|
|
MWBase::Environment::get().getWorld()->getPlayer().setDrawState(MWMechanics::DrawState_Spell);
|
|
|
|
MWBase::Environment::get().getWorld()->getPlayer().setDrawState(MWMechanics::DrawState_Spell);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (type == Type_HandToHand)
|
|
|
|
else if (key->type == Type_HandToHand)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
store.unequipSlot(MWWorld::InventoryStore::Slot_CarriedRight, player);
|
|
|
|
store.unequipSlot(MWWorld::InventoryStore::Slot_CarriedRight, player);
|
|
|
|
MWBase::Environment::get().getWorld()->getPlayer().setDrawState(MWMechanics::DrawState_Weapon);
|
|
|
|
MWBase::Environment::get().getWorld()->getPlayer().setDrawState(MWMechanics::DrawState_Weapon);
|
|
|
@ -491,9 +477,9 @@ namespace MWGui
|
|
|
|
|
|
|
|
|
|
|
|
for (int i=0; i<10; ++i)
|
|
|
|
for (int i=0; i<10; ++i)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ItemWidget* button = mQuickKeyButtons[i];
|
|
|
|
ItemWidget* button = mKey[i].button;
|
|
|
|
|
|
|
|
|
|
|
|
int type = mAssigned[i];
|
|
|
|
int type = mKey[i].type;
|
|
|
|
|
|
|
|
|
|
|
|
ESM::QuickKeys::QuickKey key;
|
|
|
|
ESM::QuickKeys::QuickKey key;
|
|
|
|
key.mType = type;
|
|
|
|
key.mType = type;
|
|
|
@ -541,30 +527,29 @@ namespace MWGui
|
|
|
|
if (i >= 10)
|
|
|
|
if (i >= 10)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
mSelectedIndex = i;
|
|
|
|
mSelected = &mKey[i];
|
|
|
|
int keyType = it->mType;
|
|
|
|
mSelected->type = (QuickKeysMenu::QuickKeyType) it->mType;
|
|
|
|
std::string id = it->mId;
|
|
|
|
mSelected->id = it->mId;
|
|
|
|
ItemWidget* button = mQuickKeyButtons[i];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (keyType)
|
|
|
|
switch (mSelected->type)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case Type_Magic:
|
|
|
|
case Type_Magic:
|
|
|
|
if (MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search(id))
|
|
|
|
if (MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search(mSelected->id))
|
|
|
|
onAssignMagic(id);
|
|
|
|
onAssignMagic(mSelected->id);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case Type_Item:
|
|
|
|
case Type_Item:
|
|
|
|
case Type_MagicItem:
|
|
|
|
case Type_MagicItem:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Find the item by id
|
|
|
|
// Find the item by id
|
|
|
|
MWWorld::Ptr item = store.findReplacement(id);
|
|
|
|
MWWorld::Ptr item = store.findReplacement(mSelected->id);
|
|
|
|
|
|
|
|
|
|
|
|
if (item.isEmpty())
|
|
|
|
if (item.isEmpty())
|
|
|
|
unassign(button, i);
|
|
|
|
unassign(&mKey[i]);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (keyType == Type_Item)
|
|
|
|
if (mSelected->type == Type_Item)
|
|
|
|
onAssignItem(item);
|
|
|
|
onAssignItem(item);
|
|
|
|
else if (keyType == Type_MagicItem)
|
|
|
|
else if (mSelected->type == Type_MagicItem)
|
|
|
|
onAssignMagicItem(item);
|
|
|
|
onAssignMagicItem(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -572,7 +557,7 @@ namespace MWGui
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case Type_Unassigned:
|
|
|
|
case Type_Unassigned:
|
|
|
|
case Type_HandToHand:
|
|
|
|
case Type_HandToHand:
|
|
|
|
unassign(button, i);
|
|
|
|
unassign(&mKey[i]);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|