summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dragdrop.h11
-rw-r--r--src/gui/outfitwindow.cpp29
-rw-r--r--src/gui/widgets/dropshortcutcontainer.cpp16
-rw-r--r--src/gui/widgets/itemcontainer.cpp3
4 files changed, 43 insertions, 16 deletions
diff --git a/src/dragdrop.h b/src/dragdrop.h
index 37f1b6ee5..5630f9248 100644
--- a/src/dragdrop.h
+++ b/src/dragdrop.h
@@ -45,6 +45,7 @@ class DragDrop
public:
DragDrop(Item *const item, const DragDropSource source) :
mItem(item),
+ mSelItem(nullptr),
mSource(source)
{
}
@@ -70,8 +71,18 @@ class DragDrop
bool isEmpty() const
{ return mSource == DRAGDROP_SOURCE_EMPTY; }
+ void select(Item *const item)
+ { mSelItem = item; }
+
+ void deselect()
+ { mSelItem = nullptr; }
+
+ Item *getSelected()
+ { return mSelItem; }
+
private:
Item *mItem;
+ Item *mSelItem;
DragDropSource mSource;
};
diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp
index 04320049c..da5609148 100644
--- a/src/gui/outfitwindow.cpp
+++ b/src/gui/outfitwindow.cpp
@@ -371,20 +371,6 @@ void OutfitWindow::draw(gcn::Graphics *graphics)
}
}
}
-/*
- if (mItemMoved)
- {
- // Draw the item image being dragged by the cursor.
- const Image *const image = mItemMoved->getImage();
- if (image)
- {
- const int tPosX = mCursorPosX - (image->mBounds.w / 2);
- const int tPosY = mCursorPosY - (image->mBounds.h / 2);
-
- g->drawImage(image, tPosX, tPosY);
- }
- }
-*/
BLOCK_END("OutfitWindow::draw")
}
@@ -451,8 +437,20 @@ void OutfitWindow::mousePressed(gcn::MouseEvent &event)
mMoved = false;
event.consume();
- if (mItems[mCurrentOutfit][index])
+ if (mItems[mCurrentOutfit][index] > 0)
+ {
mItemClicked = true;
+ }
+ else
+ {
+ Item *const selected = dragDrop.getSelected();
+ if (selected)
+ {
+ mItems[mCurrentOutfit][index] = selected->getId();
+ mItemColors[mCurrentOutfit][index] = selected->getColor();
+ dragDrop.deselect();
+ }
+ }
Window::mousePressed(event);
}
@@ -483,6 +481,7 @@ void OutfitWindow::mouseReleased(gcn::MouseEvent &event)
mItems[mCurrentOutfit][index] = item->getId();
mItemColors[mCurrentOutfit][index] = item->getColor();
dragDrop.clear();
+ dragDrop.deselect();
}
}
if (mItemClicked)
diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp
index fcd708bdc..aa4e1d829 100644
--- a/src/gui/widgets/dropshortcutcontainer.cpp
+++ b/src/gui/widgets/dropshortcutcontainer.cpp
@@ -207,7 +207,20 @@ void DropShortcutContainer::mousePressed(gcn::MouseEvent &event)
if (event.getButton() == gcn::MouseEvent::LEFT)
{
- mItemClicked = true;
+ if (dropShortcut->getItem(index) > 0)
+ {
+ mItemClicked = true;
+ }
+ else
+ {
+ Item *const selected = dragDrop.getSelected();
+ if (selected)
+ {
+ dropShortcut->setItems(index, selected->getId(),
+ selected->getColor());
+ dragDrop.deselect();
+ }
+ }
}
else if (event.getButton() == gcn::MouseEvent::RIGHT)
{
@@ -246,6 +259,7 @@ void DropShortcutContainer::mouseReleased(gcn::MouseEvent &event)
{
dropShortcut->setItems(index, item->getId(), item->getColor());
dragDrop.clear();
+ dragDrop.deselect();
}
}
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index f591af19c..eb353f5cf 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -401,11 +401,13 @@ void ItemContainer::mousePressed(gcn::MouseEvent &event)
if (mSelectedIndex == index && mClicks != 2)
{
dragDrop.dragItem(item, DragDropSource::DRAGDROP_SOURCE_INVENTORY);
+ dragDrop.select(item);
mSelectionStatus = SEL_DESELECTING;
}
else if (item && item->getId())
{
dragDrop.dragItem(item, DragDropSource::DRAGDROP_SOURCE_INVENTORY);
+ dragDrop.select(item);
setSelectedIndex(index);
mSelectionStatus = SEL_SELECTING;
@@ -420,6 +422,7 @@ void ItemContainer::mousePressed(gcn::MouseEvent &event)
}
else
{
+ dragDrop.deselect();
selectNone();
}
}