From 501f9934731114562c3659918d9d7b39625eb7b5 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 10 Mar 2012 20:20:36 +0300 Subject: Allow add skills to shortcuts bar (same as for magic and script commands). --- src/gui/widgets/itemcontainer.cpp | 2 ++ src/gui/widgets/itemshortcutcontainer.cpp | 29 +++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) (limited to 'src/gui/widgets') diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 669d05a66..6438f5deb 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -293,6 +293,8 @@ void ItemContainer::selectNone() outfitWindow->setItemSelected(-1); if (shopWindow) shopWindow->setItemSelected(-1); +// if (skillDialog) +// skillDialog->setItemSelected(-1); } void ItemContainer::setSelectedIndex(int newIndex) diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index 130d641fe..1c15ccf2b 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -37,6 +37,7 @@ #include "gui/inventorywindow.h" #include "gui/itempopup.h" #include "gui/palette.h" +#include "gui/skilldialog.h" #include "gui/spellpopup.h" #include "gui/theme.h" #include "gui/viewport.h" @@ -165,7 +166,7 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) } } } - else if (spellManager) // this is magic shortcut + else if (itemId < SKILL_MIN_ID && spellManager) // this is magic shortcut { TextCommand *spell = spellManager->getSpellByItem(itemId); if (spell) @@ -185,7 +186,15 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) itemY + mBoxHeight / 2, gcn::Graphics::LEFT); } } - + else if (skillDialog) + { + SkillInfo *skill = skillDialog->getSkill(itemId - SKILL_MIN_ID); + if (skill) + { + g->drawText(skill->shortName, itemX + 2, + itemY + mBoxHeight / 2, gcn::Graphics::LEFT); + } + } } if (mItemMoved) @@ -239,12 +248,16 @@ void ItemShortcutContainer::mouseDragged(gcn::MouseEvent &event) itemShortcut[mNumber]->removeItem(index); } } - else if (spellManager) + else if (itemId < SKILL_MIN_ID && spellManager) { TextCommand *spell = spellManager->getSpellByItem(itemId); if (spell) itemShortcut[mNumber]->removeItem(index); } + else + { + itemShortcut[mNumber]->removeItem(index); + } } if (mItemMoved) { @@ -268,8 +281,8 @@ void ItemShortcutContainer::mousePressed(gcn::MouseEvent &event) { // Stores the selected item if theirs one. if (itemShortcut[mNumber]->isItemSelected() && - (inventoryWindow && (inventoryWindow->isVisible() || - itemShortcut[mNumber]->getSelectedItem() >= SPELL_MIN_ID))) + inventoryWindow && (inventoryWindow->isVisible() || + itemShortcut[mNumber]->getSelectedItem() >= SPELL_MIN_ID)) { itemShortcut[mNumber]->setItem(index); itemShortcut[mNumber]->setItemSelected(-1); @@ -359,7 +372,7 @@ void ItemShortcutContainer::mouseMoved(gcn::MouseEvent &event) mItemPopup->setVisible(false); } } - else if (spellManager) + else if (itemId < SKILL_MIN_ID && spellManager) { mItemPopup->setVisible(false); TextCommand *spell = spellManager->getSpellByItem(itemId); @@ -373,6 +386,10 @@ void ItemShortcutContainer::mouseMoved(gcn::MouseEvent &event) mSpellPopup->setVisible(false); } } + else if (skillDialog) + { + mItemPopup->setVisible(false); + } } // Hide ItemTooltip -- cgit v1.2.3-70-g09d2