1
0
Fork 0
cuberite-2a/src/UI/MinecartWithChestWindow.h

69 lines
1.5 KiB
C
Raw Normal View History

2014-12-13 14:06:55 +00:00
// MinecartWithChestWindow.h
// Representing the UI window for the minecart chest entity
#pragma once
#include "Window.h"
#include "../Entities/Minecart.h"
2020-04-13 16:38:06 +00:00
class cMinecartWithChestWindow:
2014-12-13 14:06:55 +00:00
public cWindow
{
2020-04-13 16:38:06 +00:00
using Super = cWindow;
2014-12-13 14:06:55 +00:00
public:
2020-04-13 16:38:06 +00:00
2014-12-13 14:06:55 +00:00
cMinecartWithChestWindow(cMinecartWithChest * a_ChestCart) :
cWindow(wtChest, "Minecart with Chest"),
m_ChestCart(a_ChestCart)
{
m_SlotAreas.push_back(new cSlotAreaMinecartWithChest(a_ChestCart, *this));
m_SlotAreas.push_back(new cSlotAreaInventory(*this));
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
a_ChestCart->GetWorld()->BroadcastSoundEffect("block.chest.open", a_ChestCart->GetPosition(), 1, 1);
2014-12-13 14:06:55 +00:00
}
virtual void DistributeStack(cItem & a_ItemStack, int a_Slot, cPlayer & a_Player, cSlotArea * a_ClickedArea, bool a_ShouldApply) override
2014-12-17 18:14:01 +00:00
{
cSlotAreas AreasInOrder;
if (a_ClickedArea == m_SlotAreas[0])
{
// Chest Area
AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
2020-04-13 16:38:06 +00:00
Super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
2014-12-17 18:14:01 +00:00
}
else
{
// Hotbar or Inventory
AreasInOrder.push_back(m_SlotAreas[0]); /* Chest */
2020-04-13 16:38:06 +00:00
Super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
2014-12-17 18:14:01 +00:00
}
}
virtual ~cMinecartWithChestWindow() override
2014-12-13 14:06:55 +00:00
{
m_ChestCart->GetWorld()->BroadcastSoundEffect("block.chest.close", m_ChestCart->GetPosition(), 1, 1);
2014-12-13 14:06:55 +00:00
}
private:
cMinecartWithChest * m_ChestCart;
};