From 9684f90f8361fb314a60a387dc9ecf9bc4c3062a Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Thu, 30 May 2013 19:34:09 +0000 Subject: LuaWindow: Initial code, the window can be opened, but not much manipulated git-svn-id: http://mc-server.googlecode.com/svn/trunk@1532 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/UI/Window.cpp | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'source/UI/Window.cpp') diff --git a/source/UI/Window.cpp b/source/UI/Window.cpp index 2b279a22c..661f9f62f 100644 --- a/source/UI/Window.cpp +++ b/source/UI/Window.cpp @@ -101,6 +101,39 @@ void cWindow::SetSlot(cPlayer & a_Player, int a_SlotNum, const cItem & a_Item) +bool cWindow::IsSlotInPlayerMainInventory(int a_SlotNum) const +{ + // Returns true if the specified slot is in the Player Main Inventory slotarea + // The player main inventory is always 27 slots, 9 slots from the end of the inventory + return ((a_SlotNum >= GetNumSlots() - 36) && (a_SlotNum < GetNumSlots() - 9)); +} + + + + + +bool cWindow::IsSlotInPlayerHotbar(int a_SlotNum) const +{ + // Returns true if the specified slot is in the Player Hotbar slotarea + // The hotbar is always the last 9 slots + return ((a_SlotNum >= GetNumSlots() - 9) && (a_SlotNum < GetNumSlots())); +} + + + + + +bool cWindow::IsSlotInPlayerInventory(int a_SlotNum) const +{ + // Returns true if the specified slot is in the Player Main Inventory or Hotbar slotareas. Note that returns false for Armor. + // The player combined inventory is always the last 36 slots + return ((a_SlotNum >= GetNumSlots() - 36) && (a_SlotNum < GetNumSlots())); +} + + + + + void cWindow::GetSlots(cPlayer & a_Player, cItems & a_Slots) const { a_Slots.clear(); @@ -264,9 +297,9 @@ void cWindow::OwnerDestroyed() // Close window for each player. Note that the last one needs special handling while (m_OpenedBy.size() > 1) { - (*m_OpenedBy.begin() )->CloseWindow((char)GetWindowType()); + (*m_OpenedBy.begin() )->CloseWindow(); } - (*m_OpenedBy.begin() )->CloseWindow((char)GetWindowType()); + (*m_OpenedBy.begin() )->CloseWindow(); } -- cgit v1.2.3