⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inventoryexdialog.cpp

📁 墨香最新私服
💻 CPP
📖 第 1 页 / 共 3 页
字号:
// InventoryExDialog.cpp: implementation of the CInventoryExDialog class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "InventoryExDialog.h"
#include "WindowIDEnum.h"
#include "./Interface/cWindowManager.h"
#include "./Interface/cIconGridDialog.h"
#include "./Interface/cStatic.h"
#include "./Interface/cPushupButton.h"
#include "ObjectStateManager.h"

#include "GameIn.h"

#include "ItemManager.h"
#include "ObjectManager.h"
#include "KyungGongManager.h"
#include "MugongManager.h"
#include "ChatManager.h"

#include "DealItem.h"
#include "cDivideBox.h"
#include "./Audio/MHAudioManager.h"

#include "MugongDialog.h"
#include "DealDialog.h"

#include "./Input/UserInput.h"

#include "PyogukDialog.h"
#include "MunpaDialog.h"
#include "GuildWarehouseDialog.h"

#include "MainBarDialog.h"
#include "PKManager.h"
#include "cMsgBox.h"
#include "QuestManager.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CInventoryExDialog::CInventoryExDialog()
{
	m_type				= WT_INVENTORYDIALOG;
	m_pWearedDlg		= NULL;
	m_pMoneyEdit		= NULL;
	m_fSpread			= FALSE;
	m_iInventoryState	= eITEMDEFAULT_STATE;
	m_pTempDeleteItem	= NULL;

	m_BtnPushstartTime		= 0;
	m_BtnPushDelayTime		= 500;
	m_bPushTabWithMouseOver = FALSE;
}

CInventoryExDialog::~CInventoryExDialog()
{
	m_pWearedDlg = NULL;
}

void CInventoryExDialog::ReleaseInventory()
{
	//秦浆 抛捞喉 曼炼秦辑 瘤款促?
	//弊府靛 酒捞能 dlg -> delete;
	//扩档快俊 adddestroylist
}

void CInventoryExDialog::Render()
{
	cDialog::RenderWindow();
	cDialog::RenderComponent();
	cTabDialog::RenderTabComponent();
}
void CInventoryExDialog::Add(cWindow * window)
{
	if(window->GetType() == WT_PUSHUPBUTTON)
		AddTabBtn(curIdx1++, (cPushupButton * )window);
	else if(window->GetType() == WT_ICONGRIDDIALOG)
	{
		AddTabSheet(curIdx2++, window);
		((cIconGridDialog*)window)->SetDragOverIconType( WT_ITEM );
	}
	else 
		cDialog::Add(window);
}


DWORD CInventoryExDialog::ActionEvent(CMouse * mouseInfo)
{
	//酒捞能 靛贰弊吝老锭.. 促弗 徘栏肺 捞悼秦具茄促.
	if( WINDOWMGR->IsDragWindow() && WINDOWMGR->GetDragDlg() )
	{
		if( WINDOWMGR->GetDragDlg()->GetType() == WT_ITEM )
		{
			DWORD we = WE_NULL;
			if(!m_bActive) return we;
			we = cDialog::ActionEvent(mouseInfo);

			BOOL bMouseOver = FALSE;
			for( int i = 0 ; i < m_bTabNum ; i++ )
			{
				m_ppPushupTabBtn[i]->ActionEvent( mouseInfo );
				
				if( we & WE_MOUSEOVER )
					if( m_ppPushupTabBtn[i]->PtInWindow( mouseInfo->GetMouseX(), mouseInfo->GetMouseY() ) )
					{
						bMouseOver = TRUE;
						
						if( m_bPushTabWithMouseOver )
						{
							if( i != m_bSelTabNum )
							{
								SelectTab(i);		//鉴辑瘤虐扁(荐访芒锭巩..)
								m_bSelTabNum = i;
							}
						}
						else
						{
							if( m_BtnPushstartTime == 0 )
								m_BtnPushstartTime = gCurTime;
							else if( gCurTime - m_BtnPushstartTime > m_BtnPushDelayTime )
								m_bPushTabWithMouseOver = TRUE;
						}				
					}
			}
			
			if( !bMouseOver )
				m_BtnPushstartTime = 0;
			
			we |= m_ppWindowTabSheet[m_bSelTabNum]->ActionEvent( mouseInfo );
			return we;
		}
	}

	m_BtnPushstartTime		= 0;
	m_bPushTabWithMouseOver = FALSE;
	return cTabDialog::ActionEvent( mouseInfo );	
}


WORD CInventoryExDialog::GetTabIndex( POSTYPE absPos )
{
	return ( absPos - TP_INVENTORY_START ) / TABCELL_INVENTORY_NUM;
}

BOOL CInventoryExDialog::AddItem(ITEMBASE * itemBase)
{
	if( itemBase->dwDBIdx == 0 )
	{
//		DEBUGMSG( 0, "Item DB idx == 0" );
		return FALSE;
	}

	CItem * newItem = ITEMMGR->MakeNewItem( itemBase, "AddItem" );
	if(newItem == NULL)
		return FALSE;
	
	return AddItem( newItem );
}

// 康距 Dura档 刘啊 矫难 霖促.府家胶 昏力鳖瘤.
BOOL CInventoryExDialog::AddItem(CItem* pItem)
{
	if(pItem == NULL)
	{
		ASSERT(pItem);
		return FALSE;
	}

	//祸 函券
	ITEMMGR->RefreshItem( pItem );
	//add 窍绰 酒捞袍父 refresh 窍搁 等促?


	if(TP_INVENTORY_START <= pItem->GetPosition() && pItem->GetPosition() < TP_INVENTORY_END)
	{
		
		// 牢亥配府 
		int tabIndex = GetTabIndex( pItem->GetPosition() );
		cIconGridDialog * dlg = (cIconGridDialog *)GetTabSheet(tabIndex);

//		WORD relPos = pItem->GetPosition()-INVENTORY_STARTPOSITION-CELLNUMPERPAGE*tabIndex;
		WORD relPos = pItem->GetPosition()-TP_INVENTORY_START-TABCELL_INVENTORY_NUM*tabIndex;
		CItem * item = (CItem * )dlg->GetIconForIdx(relPos);
		if(item)
		{
			ASSERT(0);
			return FALSE;
		}
		else
		{
			return dlg->AddIcon(relPos, pItem);
		}
	}
	else if(TP_WEAR_START <= pItem->GetPosition() && pItem->GetPosition() < TP_WEAR_END)
	{
		// 厘馒芒
		return m_pWearedDlg->AddItem(pItem->GetPosition()-TP_WEAR_START, pItem);
	}
	else
		return FALSE;
}

BOOL CInventoryExDialog::DeleteItem(POSTYPE Pos,CItem** ppItem)
{
//	if(INVENTORY_STARTPOSITION <= Pos && Pos < INVENTORY_ENDPOSITION)
	if(TP_INVENTORY_START <= Pos && Pos < TP_INVENTORY_END)
	{
		int TabIndex = GetTabIndex( Pos );
		cIconGridDialog * Dlg = (cIconGridDialog *)GetTabSheet(TabIndex);
		if(!Dlg->IsAddable(Pos - TP_INVENTORY_START-TABCELL_INVENTORY_NUM*TabIndex))
			return Dlg->DeleteIcon(Pos-TP_INVENTORY_START-TABCELL_INVENTORY_NUM*TabIndex, (cIcon **)ppItem);
//		if(!Dlg->IsAddable(Pos - INVENTORY_STARTPOSITION-CELLNUMPERPAGE*TabIndex))
//			return Dlg->DeleteIcon(Pos-INVENTORY_STARTPOSITION-CELLNUMPERPAGE*TabIndex, (cIcon **)ppItem);
		else
			return FALSE;
	}
//	else if(WEAR_STARTPOSITION <= Pos && Pos < WEAR_ENDPOSITION)
	else if(TP_WEAR_START <= Pos && Pos < TP_WEAR_END)
	{
//		if(!m_pWearedDlg->IsAddable(Pos - WEAR_STARTPOSITION))
//			return m_pWearedDlg->DeleteItem(Pos-WEAR_STARTPOSITION, (cIcon **)ppItem);
		if(!m_pWearedDlg->IsAddable(Pos - TP_WEAR_START))
			return m_pWearedDlg->DeleteItem(Pos-TP_WEAR_START, (cIcon **)ppItem);
		else
		{
			return FALSE;
		}
	}
	else
		return FALSE;
}
BOOL CInventoryExDialog::UpdateItemDurabilityAdd(POSTYPE absPos, int dur)
{
//	if(INVENTORY_STARTPOSITION <= absPos && absPos < INVENTORY_ENDPOSITION)
	if(TP_INVENTORY_START <= absPos && absPos < TP_INVENTORY_END)
	{
		int TabIndex = GetTabIndex( absPos );
		cIconGridDialog * Dlg = (cIconGridDialog *)GetTabSheet(TabIndex);
//		WORD relPos = absPos-INVENTORY_STARTPOSITION-CELLNUMPERPAGE*TabIndex;
		WORD relPos = absPos-TP_INVENTORY_START-TABCELL_INVENTORY_NUM*TabIndex;
		CItem * item = (CItem * )Dlg->GetIconForIdx(relPos);
		item->SetDurability(item->GetDurability()+dur);
		return TRUE;
	}
	else
		return FALSE;
}
CItem * CInventoryExDialog::GetItemForIdx(POSTYPE absPos)
{
//	if(INVENTORY_STARTPOSITION <= absPos && absPos < INVENTORY_ENDPOSITION)
	if(TP_INVENTORY_START <= absPos && absPos < TP_INVENTORY_END)
	{
		int TabIndex = GetTabIndex( absPos );
		cIconGridDialog * Dlg = (cIconGridDialog *)GetTabSheet(TabIndex);
		return (CItem *)Dlg->GetIconForIdx(absPos-TP_INVENTORY_START-TABCELL_INVENTORY_NUM*TabIndex);
//		return (CItem *)Dlg->GetIconForIdx(absPos-INVENTORY_STARTPOSITION-CELLNUMPERPAGE*TabIndex);
	}
//	else if(WEAR_STARTPOSITION <= absPos && absPos < WEAR_ENDPOSITION)
	else if(TP_WEAR_START <= absPos && absPos < TP_WEAR_END)
	{
//		return (CItem *)m_pWearedDlg->GetIconForIdx(absPos-WEAR_STARTPOSITION);
		return (CItem *)m_pWearedDlg->GetIconForIdx(absPos-TP_WEAR_START);
	}
	else
		return NULL;
}

void CInventoryExDialog::UseItem(CItem* pItem)
{
	ASSERT(pItem);

	if( WINDOWMGR->IsDragWindow() && WINDOWMGR->GetDragDlg() )
	if( WINDOWMGR->GetDragDlg()->GetType() == WT_ITEM)
		return;
	
//KES...
	if( m_bDisable )	return;		//牢亥 叼胶俊捞喉捞搁 酒捞袍 荤侩 阂啊瓷
	
//KES EXCHANGE 031002
	if( pItem->IsLocked() ) return;
//
	if( HERO->GetState() == eObjectState_Die )	//磷篮 惑怕俊辑绰 酒捞袍 荤侩 给茄促.
		return;

	eITEM_KINDBIT bits = pItem->GetItemKind();
	if(bits & eYOUNGYAK_ITEM)
	{
		// 酒捞袍狼 荤侩
		MSG_ITEM_USE_SYN msg;
		msg.Category = MP_ITEM;
		msg.Protocol = MP_ITEM_USE_SYN;
		msg.dwObjectID = HEROID;
		msg.TargetPos = pItem->GetPosition();
		msg.wItemIdx = pItem->GetItemIdx();

/*
		msg.wTableIdx = eItemTable_Inventory;
		msg.wIconIdx = pItem->GetItemIdx();
		msg.wAbsPosition = pItem->GetPosition();
*/
		
		NETWORK->Send(&msg,sizeof(msg));
	}
	else if(bits & eCHANGE_ITEM)	// change item
	{
		MSG_ITEM_USE_SYN msg;
		msg.Category = MP_ITEM;
		msg.Protocol = MP_ITEM_USE_CHANGEITEM_SYN;
		msg.dwObjectID = HEROID;
		msg.TargetPos = pItem->GetPosition();
		msg.wItemIdx = pItem->GetItemIdx();
	
		NETWORK->Send(&msg,sizeof(msg));
	}
	else if(bits & eEQUIP_ITEM)
	{
		if( OBJECTSTATEMGR->CheckAvailableState(HERO,eCAS_EQUIPITEM) == FALSE )
		{
			CAction act;
			act.InitAction(eActionKind_EquipItem,(void*)pItem->GetDBIdx(),0,NULL);
			HERO->SetNextAction(&act);
			return;
		}

		// 厘馒 酒捞袍	
		switch( GetTableIdxPosition( pItem->GetPosition() ) )
		{
		case eItemTable_Inventory:
			{
				if(ITEMMGR->CanEquip(pItem->GetItemIdx()))
				{
					ITEM_INFO * pInfo = ITEMMGR->GetItemInfo(pItem->GetItemIdx());
					if(!pInfo) return ;
					
					// 馆瘤2贸府
					WORD EquipToPos = pInfo->EquipKind;
					if(pInfo->EquipKind == eWearedItem_Ring1)
					{
//						if(IsExist(EquipToPos+WEAR_STARTPOSITION))
						if(IsExist(EquipToPos+TP_WEAR_START))
						{
//							if(!IsExist(EquipToPos+1+WEAR_STARTPOSITION))
							if(!IsExist(EquipToPos+1+TP_WEAR_START))
								EquipToPos++;
						}
					}
					CItem * pToItem = GetItemForIdx( EquipToPos + TP_WEAR_START );
					FakeGeneralItemMove(EquipToPos + TP_WEAR_START, pItem, pToItem);
					/*
					MSG_ITEM_MOVE_SYN msg;
					msg.Category			= MP_ITEM;
					msg.Protocol			= MP_ITEM_MOVE_SYN;
					msg.dwObjectID			= HEROID;

					msg.FromPos				= pItem->GetPosition();
					msg.wFromItemIdx		= pItem->GetItemIdx();
					msg.ToPos				= EquipToPos + TP_WEAR_START;
					msg.wToItemIdx			= 0;

					if(msg.FromPos == msg.ToPos)
						return;
					NETWORK->Send(&msg,sizeof(msg));
					*/
				}	
			}
			break;
		case eItemTable_Weared:
			{
				POSTYPE emptyPos;
				if( GetBlankPositionRestrictRef( emptyPos ) )
				{
					CItem * pToItem = GetItemForIdx( emptyPos );
					FakeGeneralItemMove(emptyPos, pItem, pToItem);
					/*
					
					MSG_ITEM_MOVE_SYN msg;
					msg.Category			= MP_ITEM;
					msg.Protocol			= MP_ITEM_MOVE_SYN;
					msg.dwObjectID			= HEROID;

					msg.FromPos				= pItem->GetPosition();
					msg.wFromItemIdx		= pItem->GetItemIdx();
					msg.ToPos				= emptyPos;
					msg.wToItemIdx			= 0;

					if(msg.FromPos == msg.ToPos)
						return;

					NETWORK->Send(&msg,sizeof(msg));*/
					
				}
			}
			break;
		}
		
	}
	else if(bits & eMUGONG_ITEM)
	{
		//if(!GAMEIN->GetMugongDialog()->CanBeMoved())
		//	return;

		if(MUGONGMGR->GetMugongByMugongIdx(pItem->GetItemInfo()->MugongNum) != NULL)
				return ;

		if(bits == eMUGONG_ITEM_JINBUB)
		{
			if(!ITEMMGR->CanConvertToMugong(pItem->GetItemIdx(),MUGONGTYPE_JINBUB))
				return;
		}
		else if(bits == eMUGONG_ITEM_KYUNGGONG)		// 版傍老 版快父 版傍皋聪廉俊辑 贸府茄促.
		{
			//if(!ITEMMGR->CanConvertToMugong(pItem->GetItemIdx(),MUGONGTYPE_KYUNGGONG))
			//	return;
			if(KYUNGGONGMGR->IsSetableKyungGong(HERO,pItem) == FALSE)
				return;
		}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -