summaryrefslogtreecommitdiff
path: root/src/gui/widgets/itemshortcutcontainer.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-09-14 02:54:44 +0300
committerAndrei Karas <akaras@inbox.ru>2012-09-14 02:54:44 +0300
commit84499779fcf0c8b5392a88f1c9311775e692ebef (patch)
treef390326a50eed73d8f8c62107979a4d81093ce52 /src/gui/widgets/itemshortcutcontainer.cpp
parent4ee30f47b491de0ace9b692072fd286cf12c7828 (diff)
downloadmv-84499779fcf0c8b5392a88f1c9311775e692ebef.tar.gz
mv-84499779fcf0c8b5392a88f1c9311775e692ebef.tar.bz2
mv-84499779fcf0c8b5392a88f1c9311775e692ebef.tar.xz
mv-84499779fcf0c8b5392a88f1c9311775e692ebef.zip
Improve a bit some gui controls speed.
Diffstat (limited to 'src/gui/widgets/itemshortcutcontainer.cpp')
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp64
1 files changed, 34 insertions, 30 deletions
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index 04c6de606..8ebad55ed 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -94,7 +94,8 @@ ItemShortcutContainer::~ItemShortcutContainer()
void ItemShortcutContainer::draw(gcn::Graphics *graphics)
{
- if (!itemShortcut[mNumber])
+ const ItemShortcut *const selShortcut = itemShortcut[mNumber];
+ if (!selShortcut)
return;
mAlpha = Client::getGuiAlpha();
@@ -133,8 +134,8 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics)
g->drawText(key, itemX + 2, itemY + 2, gcn::Graphics::LEFT);
- const int itemId = itemShortcut[mNumber]->getItem(i);
- const unsigned char itemColor = itemShortcut[mNumber]->getItemColor(i);
+ const int itemId = selShortcut->getItem(i);
+ const unsigned char itemColor = selShortcut->getItemColor(i);
if (itemId < 0)
continue;
@@ -228,7 +229,8 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics)
void ItemShortcutContainer::mouseDragged(gcn::MouseEvent &event)
{
- if (!itemShortcut[mNumber])
+ ItemShortcut *const selShortcut = itemShortcut[mNumber];
+ if (!selShortcut)
return;
if (event.getButton() == gcn::MouseEvent::LEFT)
@@ -240,9 +242,8 @@ void ItemShortcutContainer::mouseDragged(gcn::MouseEvent &event)
if (index == -1)
return;
- const int itemId = itemShortcut[mNumber]->getItem(index);
- const unsigned char itemColor = itemShortcut[mNumber]->
- getItemColor(index);
+ const int itemId = selShortcut->getItem(index);
+ const unsigned char itemColor = selShortcut->getItemColor(index);
if (itemId < 0)
return;
@@ -258,7 +259,7 @@ void ItemShortcutContainer::mouseDragged(gcn::MouseEvent &event)
if (item)
{
mItemMoved = item;
- itemShortcut[mNumber]->removeItem(index);
+ selShortcut->removeItem(index);
}
}
else if (itemId < SKILL_MIN_ID && spellManager)
@@ -266,11 +267,11 @@ void ItemShortcutContainer::mouseDragged(gcn::MouseEvent &event)
const TextCommand *const spell = spellManager->getSpellByItem(
itemId);
if (spell)
- itemShortcut[mNumber]->removeItem(index);
+ selShortcut->removeItem(index);
}
else
{
- itemShortcut[mNumber]->removeItem(index);
+ selShortcut->removeItem(index);
}
}
if (mItemMoved)
@@ -283,7 +284,8 @@ void ItemShortcutContainer::mouseDragged(gcn::MouseEvent &event)
void ItemShortcutContainer::mousePressed(gcn::MouseEvent &event)
{
- if (!itemShortcut[mNumber])
+ ItemShortcut *const selShortcut = itemShortcut[mNumber];
+ if (!selShortcut)
return;
const int index = getIndexFromGrid(event.getX(), event.getY());
@@ -294,40 +296,41 @@ void ItemShortcutContainer::mousePressed(gcn::MouseEvent &event)
if (event.getButton() == gcn::MouseEvent::LEFT)
{
// Stores the selected item if theirs one.
- if (itemShortcut[mNumber]->isItemSelected() &&
- inventoryWindow && (inventoryWindow->isVisible() ||
- itemShortcut[mNumber]->getSelectedItem() >= SPELL_MIN_ID))
+ if (selShortcut->isItemSelected() && inventoryWindow &&
+ (inventoryWindow->isVisible() || selShortcut->getSelectedItem()
+ >= SPELL_MIN_ID))
{
- itemShortcut[mNumber]->setItem(index);
- itemShortcut[mNumber]->setItemSelected(-1);
+ selShortcut->setItem(index);
+ selShortcut->setItemSelected(-1);
if (spellShortcut)
spellShortcut->setItemSelected(-1);
inventoryWindow->unselectItem();
}
- else if (itemShortcut[mNumber]->getItem(index))
+ else if (selShortcut->getItem(index))
{
mItemClicked = true;
}
}
else if (event.getButton() == gcn::MouseEvent::RIGHT)
{
- if (viewport && itemShortcut[mNumber])
+ if (viewport && selShortcut)
{
- viewport->showItemPopup(itemShortcut[mNumber]->getItem(index),
- itemShortcut[mNumber]->getItemColor(index));
+ viewport->showItemPopup(selShortcut->getItem(index),
+ selShortcut->getItemColor(index));
}
}
}
void ItemShortcutContainer::mouseReleased(gcn::MouseEvent &event)
{
- if (!itemShortcut[mNumber])
+ ItemShortcut *const selShortcut = itemShortcut[mNumber];
+ if (!selShortcut)
return;
if (event.getButton() == gcn::MouseEvent::LEFT)
{
- if (itemShortcut[mNumber]->isItemSelected())
- itemShortcut[mNumber]->setItemSelected(-1);
+ if (selShortcut->isItemSelected())
+ selShortcut->setItemSelected(-1);
const int index = getIndexFromGrid(event.getX(), event.getY());
if (index == -1)
@@ -337,13 +340,13 @@ void ItemShortcutContainer::mouseReleased(gcn::MouseEvent &event)
}
if (mItemMoved)
{
- itemShortcut[mNumber]->setItems(index,
- mItemMoved->getId(), mItemMoved->getColor());
+ selShortcut->setItems(index, mItemMoved->getId(),
+ mItemMoved->getColor());
mItemMoved = nullptr;
}
- else if (itemShortcut[mNumber]->getItem(index) && mItemClicked)
+ else if (selShortcut->getItem(index) && mItemClicked)
{
- itemShortcut[mNumber]->useItem(index);
+ selShortcut->useItem(index);
}
if (mItemClicked)
@@ -354,7 +357,8 @@ void ItemShortcutContainer::mouseReleased(gcn::MouseEvent &event)
// Show ItemTooltip
void ItemShortcutContainer::mouseMoved(gcn::MouseEvent &event)
{
- if (!itemShortcut[mNumber])
+ const ItemShortcut *const selShortcut = itemShortcut[mNumber];
+ if (!selShortcut)
return;
const int index = getIndexFromGrid(event.getX(), event.getY());
@@ -362,8 +366,8 @@ void ItemShortcutContainer::mouseMoved(gcn::MouseEvent &event)
if (index == -1)
return;
- const int itemId = itemShortcut[mNumber]->getItem(index);
- const unsigned char itemColor = itemShortcut[mNumber]->getItemColor(index);
+ const int itemId = selShortcut->getItem(index);
+ const unsigned char itemColor = selShortcut->getItemColor(index);
if (itemId < 0)
return;