summaryrefslogtreecommitdiffstats
path: root/src/UI/SlotArea.cpp
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-07-09 14:30:06 +0200
committerHowaner <franzi.moos@googlemail.com>2014-07-09 14:30:06 +0200
commit3615bf825b53d3e192ad7fe6d047bd713bc00394 (patch)
treea6abe23cb87841069e88ca7533abdf1683fe8a7f /src/UI/SlotArea.cpp
parentAdded drop window action. (diff)
downloadcuberite-3615bf825b53d3e192ad7fe6d047bd713bc00394.tar
cuberite-3615bf825b53d3e192ad7fe6d047bd713bc00394.tar.gz
cuberite-3615bf825b53d3e192ad7fe6d047bd713bc00394.tar.bz2
cuberite-3615bf825b53d3e192ad7fe6d047bd713bc00394.tar.lz
cuberite-3615bf825b53d3e192ad7fe6d047bd713bc00394.tar.xz
cuberite-3615bf825b53d3e192ad7fe6d047bd713bc00394.tar.zst
cuberite-3615bf825b53d3e192ad7fe6d047bd713bc00394.zip
Diffstat (limited to '')
-rw-r--r--src/UI/SlotArea.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp
index 68ec78930..93beca9c6 100644
--- a/src/UI/SlotArea.cpp
+++ b/src/UI/SlotArea.cpp
@@ -77,6 +77,19 @@ void cSlotArea::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickA
DropClicked(a_Player, a_SlotNum, (a_ClickAction == caCtrlDropKey));
return;
}
+ case caNumber1:
+ case caNumber2:
+ case caNumber3:
+ case caNumber4:
+ case caNumber5:
+ case caNumber6:
+ case caNumber7:
+ case caNumber8:
+ case caNumber9:
+ {
+ NumberClicked(a_Player, a_SlotNum, a_ClickAction);
+ return;
+ }
default:
{
break;
@@ -283,6 +296,31 @@ void cSlotArea::DropClicked(cPlayer & a_Player, int a_SlotNum, bool a_DropStack)
+void cSlotArea::NumberClicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction)
+{
+ if ((a_ClickAction < caNumber1) || (a_ClickAction > caNumber9))
+ {
+ return;
+ }
+
+ int HotbarSlot = (int)a_ClickAction - (int)caNumber1;
+ cItem ItemInHotbar(a_Player.GetInventory().GetHotbarSlot(HotbarSlot));
+ cItem ItemInSlot(*GetSlot(a_SlotNum, a_Player));
+
+ // The items are equal. Do nothing.
+ if (ItemInHotbar.IsEqual(ItemInSlot))
+ {
+ return;
+ }
+
+ a_Player.GetInventory().SetHotbarSlot(HotbarSlot, ItemInSlot);
+ SetSlot(a_SlotNum, a_Player, ItemInHotbar);
+}
+
+
+
+
+
void cSlotArea::OnPlayerAdded(cPlayer & a_Player)
{
UNUSED(a_Player);