1
0

Refactored windows.

As described on the forum: http://forum.mc-server.org/showthread.php?tid=561
For now, only basic clicking works; shift-click not implemented yet.

git-svn-id: http://mc-server.googlecode.com/svn/trunk@867 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com
2012-09-20 13:25:54 +00:00
parent 2b35b9a724
commit bc466f07a4
35 changed files with 1574 additions and 1565 deletions

View File

@@ -5,7 +5,7 @@
#include "cItem.h"
#include "cClientHandle.h"
#include "cPlayer.h"
#include "cWindow.h"
#include "UI/cWindow.h"
#include "cWorld.h"
#include "cRoot.h"
#include "cPickup.h"
@@ -88,9 +88,9 @@ const cItem * cChestEntity::GetSlot( int a_Slot ) const
void cChestEntity::SetSlot( int a_Slot, cItem & a_Item )
void cChestEntity::SetSlot(int a_Slot, const cItem & a_Item)
{
if( a_Slot > -1 && a_Slot < c_ChestHeight*c_ChestWidth )
if ((a_Slot > -1) && (a_Slot < c_ChestHeight * c_ChestWidth))
{
m_Content[a_Slot] = a_Item;
}
@@ -170,22 +170,18 @@ void cChestEntity::SendTo(cClientHandle & a_Client)
void cChestEntity::UsedBy(cPlayer * a_Player)
{
if (!GetWindow())
if (GetWindow() == NULL)
{
cWindow * Window = new cWindow(this, true, cWindow::Chest, 1);
Window->SetSlots(GetContents(), GetChestHeight() * c_ChestWidth);
Window->SetWindowTitle("UberChest");
OpenWindow( Window );
OpenWindow(new cChestWindow(m_PosX, m_PosY, m_PosZ, this));
}
if ( GetWindow() )
if (GetWindow())
{
if( a_Player->GetWindow() != GetWindow() )
{
a_Player->OpenWindow( GetWindow() );
GetWindow()->SendWholeWindow( a_Player->GetClientHandle() );
GetWindow()->SendWholeWindow(*a_Player->GetClientHandle());
}
}
m_World->BroadcastBlockAction(m_PosX, m_PosY, m_PosZ, 1, 1, E_BLOCK_CHEST);
// This is rather a hack
// Instead of marking the chunk as dirty upon chest contents change, we mark it dirty now