From bc466f07a454271d4845a7e8c7f0822541c5afbd Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Thu, 20 Sep 2012 13:25:54 +0000 Subject: 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 --- source/cChestEntity.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'source/cChestEntity.cpp') diff --git a/source/cChestEntity.cpp b/source/cChestEntity.cpp index 2a69c7bdb..8914f5f41 100644 --- a/source/cChestEntity.cpp +++ b/source/cChestEntity.cpp @@ -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 -- cgit v1.2.3