Added partial shift+click handling to the survival inventory
git-svn-id: http://mc-server.googlecode.com/svn/trunk@730 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
@@ -86,36 +86,42 @@ cItem* cWindow::GetDraggingItem( cPlayer * a_Player /* = 0 */ )
|
||||
|
||||
void cWindow::Clicked( cPacket_WindowClick* a_ClickPacket, cPlayer & a_Player )
|
||||
{
|
||||
if( a_ClickPacket->m_WindowID != m_WindowID )
|
||||
if (a_ClickPacket->m_WindowID != m_WindowID)
|
||||
{
|
||||
LOG("WRONG WINDOW ID! (exp %d, got %d)", m_WindowID, a_ClickPacket->m_WindowID);
|
||||
return;
|
||||
}
|
||||
|
||||
if( m_bInventoryVisible )
|
||||
if (m_bInventoryVisible)
|
||||
{
|
||||
cWindow* Window = a_Player.GetInventory().GetWindow();
|
||||
if( Window )
|
||||
cWindow * Window = a_Player.GetInventory().GetWindow();
|
||||
if (Window != NULL)
|
||||
{
|
||||
m_DraggingItem = Window->GetDraggingItem();
|
||||
}
|
||||
}
|
||||
bool bAsync = false;
|
||||
if( a_ClickPacket->m_SlotNum == -999 ) // Outside window click
|
||||
if (a_ClickPacket->m_SlotNum == -999) // Outside window click
|
||||
{
|
||||
if( a_ClickPacket->m_RightMouse )
|
||||
a_Player.TossItem( true );
|
||||
else
|
||||
a_Player.TossItem( true, m_DraggingItem->m_ItemCount );
|
||||
}
|
||||
else if( GetSlot( a_ClickPacket->m_SlotNum ) != 0 )
|
||||
{
|
||||
cItem* Item = GetSlot( a_ClickPacket->m_SlotNum );
|
||||
if( a_ClickPacket->m_ItemID != Item->m_ItemID
|
||||
|| a_ClickPacket->m_ItemCount != Item->m_ItemCount
|
||||
|| a_ClickPacket->m_ItemUses != Item->m_ItemHealth )
|
||||
if (a_ClickPacket->m_RightMouse)
|
||||
{
|
||||
if( !((a_ClickPacket->m_ItemID == -1 || a_ClickPacket->m_ItemID == 0) && (Item->m_ItemID == -1 || Item->m_ItemID == 0 )) )
|
||||
a_Player.TossItem( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
a_Player.TossItem( true, m_DraggingItem->m_ItemCount );
|
||||
}
|
||||
}
|
||||
else if (GetSlot(a_ClickPacket->m_SlotNum) != NULL)
|
||||
{
|
||||
cItem * Item = GetSlot(a_ClickPacket->m_SlotNum);
|
||||
if (
|
||||
(a_ClickPacket->m_ItemID != Item->m_ItemID) ||
|
||||
(a_ClickPacket->m_ItemCount != Item->m_ItemCount) ||
|
||||
(a_ClickPacket->m_ItemUses != Item->m_ItemHealth)
|
||||
)
|
||||
{
|
||||
if (!((a_ClickPacket->m_ItemID == -1 || a_ClickPacket->m_ItemID == 0) && (Item->m_ItemID == -1 || Item->m_ItemID == 0 )) )
|
||||
{
|
||||
LOGD("My ID: %i Their ID: %i", Item->m_ItemID, a_ClickPacket->m_ItemID );
|
||||
LOGD("My Count: %i Their Count: %i", Item->m_ItemCount, a_ClickPacket->m_ItemCount );
|
||||
@@ -124,13 +130,13 @@ void cWindow::Clicked( cPacket_WindowClick* a_ClickPacket, cPlayer & a_Player )
|
||||
}
|
||||
}
|
||||
}
|
||||
if( m_DraggingItem && a_ClickPacket->m_SlotNum > -1 && a_ClickPacket->m_SlotNum < m_NumSlots )
|
||||
if (m_DraggingItem && (a_ClickPacket->m_SlotNum > -1) && (a_ClickPacket->m_SlotNum < m_NumSlots))
|
||||
{
|
||||
if( a_ClickPacket->m_RightMouse == 0 )
|
||||
if (a_ClickPacket->m_RightMouse == 0)
|
||||
{
|
||||
if( !m_DraggingItem->Equals( m_Slots[a_ClickPacket->m_SlotNum] ) )
|
||||
if (!m_DraggingItem->Equals(m_Slots[a_ClickPacket->m_SlotNum]))
|
||||
{
|
||||
cItem tmp( *m_DraggingItem );
|
||||
cItem tmp(*m_DraggingItem);
|
||||
*m_DraggingItem = m_Slots[a_ClickPacket->m_SlotNum];
|
||||
m_Slots[a_ClickPacket->m_SlotNum] = tmp; // Switch contents
|
||||
}
|
||||
@@ -283,6 +289,40 @@ void cWindow::OwnerDestroyed()
|
||||
|
||||
|
||||
|
||||
bool cWindow::ForEachPlayer(cItemCallback<cPlayer> & a_Callback)
|
||||
{
|
||||
cCSLock Lock(m_CS);
|
||||
for (cPlayerList::iterator itr = m_OpenedBy.begin(), end = m_OpenedBy.end(); itr != end; ++itr)
|
||||
{
|
||||
if (a_Callback.Item(*itr))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
} // for itr - m_OpenedBy[]
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool cWindow::ForEachClient(cItemCallback<cClientHandle> & a_Callback)
|
||||
{
|
||||
cCSLock Lock(m_CS);
|
||||
for (cPlayerList::iterator itr = m_OpenedBy.begin(), end = m_OpenedBy.end(); itr != end; ++itr)
|
||||
{
|
||||
if (a_Callback.Item((*itr)->GetClientHandle()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
} // for itr - m_OpenedBy[]
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cWindow::Destroy()
|
||||
{
|
||||
LOGD("Destroying window %p (type %d)", this, m_WindowType);
|
||||
|
||||
Reference in New Issue
Block a user