Exemple #1
0
void CUIMpTradeWnd::OnBtnRifleSilencerClicked(CUIWindow* w, void* d)
{
	CheckDragItemToDestroy				();
	CUIDragDropListEx*	res			= m_list[e_rifle];
	CUICellItem* ci					= (res->ItemsCount())?res->GetItemIdx(0):NULL;
	if(!ci)	
		return;

	SBuyItemInfo* pitem				= FindItem(ci);
	if(IsAddonAttached(pitem, at_silencer))
	{//detach
		SellItemAddons				(pitem,at_silencer);
	}else
	if(CanAttachAddon(pitem, at_silencer))
	{//attach
		shared_str addon_name		= GetAddonNameSect(pitem,at_silencer);

		if ( NULL==m_store_hierarchy->FindItem(addon_name) )
			return;
						
		SBuyItemInfo* addon_item	= CreateItem(addon_name, SBuyItemInfo::e_undefined, false);
		bool b_res_addon			= TryToBuyItem(addon_item, bf_normal, pitem );
		if(!b_res_addon)
			DestroyItem				(addon_item);
	}
}
Exemple #2
0
void CUIMpTradeWnd::OnBtnPistolAmmoClicked(CUIWindow* w, void* d)
{
	CheckDragItemToDestroy				();
	CUIDragDropListEx*	res		= m_list[e_pistol];
	CUICellItem* ci				= (res->ItemsCount())?res->GetItemIdx(0):NULL;
	if(!ci)	
		return;

	CInventoryItem* ii			= (CInventoryItem*)ci->m_pData;
	CWeapon*		wpn			= smart_cast<CWeapon*>(ii);
	R_ASSERT		(wpn);

	u32 ammo_idx				= (pInput->iGetAsyncKeyState(DIK_LSHIFT))?1:0;
	
	if(wpn->m_ammoTypes.size() < ammo_idx+1)	return;
	const shared_str& ammo_name	= wpn->m_ammoTypes[ammo_idx];

	if ( NULL==m_store_hierarchy->FindItem(ammo_name) )
		return;

	SBuyItemInfo* pitem			= CreateItem		(ammo_name, SBuyItemInfo::e_undefined, false);
	bool b_res					= TryToBuyItem		(pitem, bf_normal, NULL );
	if(!b_res)
		DestroyItem				(pitem);
}
Exemple #3
0
void CUIMpTradeWnd::OnBtnRifleAmmo2Clicked(CUIWindow* w, void* d)
{
	CheckDragItemToDestroy				();
	CUIDragDropListEx*	res		= m_list[e_rifle];
	CUICellItem* ci				= (res->ItemsCount())?res->GetItemIdx(0):NULL;
	if(!ci)	
		return;

	CInventoryItem* ii			= (CInventoryItem*)ci->m_pData;
	CWeaponMagazinedWGrenade* wpn = smart_cast<CWeaponMagazinedWGrenade*>(ii);
	if(!wpn)		
		return;

	u32 ammo_idx				= 0;
	
	const shared_str& ammo_name	= wpn->m_ammoTypes2[ammo_idx];

	if ( NULL==m_store_hierarchy->FindItem(ammo_name) )
		return;

	SBuyItemInfo* pitem			= CreateItem		(ammo_name, SBuyItemInfo::e_undefined, false);
	bool b_res					= TryToBuyItem		(pitem, bf_normal, NULL);
	if(!b_res)
		DestroyItem				(pitem);
}
Exemple #4
0
CUIDragDropListEx* UIHelper::CreateDragDropListEx( CUIXml& xml, LPCSTR ui_path, CUIWindow* parent )
{
	CUIDragDropListEx* ui			= new CUIDragDropListEx();
	parent->AttachChild				( ui );
	ui->SetAutoDelete				( true );
	CUIXmlInit::InitDragDropListEx	( xml, ui_path, 0, ui );
	return ui;
}
void CUIMpTradeWnd::SetupPlayerItemsBegin()
{
	for(int idx = e_first; idx<e_player_total; ++idx)
	{
		CUIDragDropListEx* lst			= m_list[idx];
		R_ASSERT(0==lst->ItemsCount());
	}

	UpdateHelperItems();
}
void CUIMpTradeWnd::FillUpSubLevelItems()
{
	CUIDragDropListEx*	pList			= m_list[e_shop];
	m_shop_wnd->AttachChild				(pList);
	pList->ClearAll						(false);
	
	const CStoreHierarchy::item& curr_level = m_store_hierarchy->CurrentLevel();

	for(u32 idx=0; idx<curr_level.m_items_in_group.size();++idx)
	{
		const shared_str& sect			= curr_level.m_items_in_group[idx];
		RenewShopItem					(sect, false);
	}
}
void CUIMpTradeWnd::OnBtnSellClicked(CUIWindow* w, void* d)
{
	CheckDragItemToDestroy				();
	CUIDragDropListEx*	pList			= m_list[e_player_bag];

	SBuyItemInfo*	iinfo	= NULL;
	while( pList->ItemsCount() )
	{
		CUICellItem* ci = pList->GetItemIdx(0);
		iinfo			= FindItem(ci);
		bool	b_ok	= true;
		SBuyItemInfo*	tmp_iinfo	= NULL;
		b_ok			= TryToSellItem(iinfo, true, tmp_iinfo);
		R_ASSERT		(b_ok);
	}
}
void CUIMpTradeWnd::SetupPlayerItemsBegin()
{
	if(
		(0!=GetItemCount(SBuyItemInfo::e_own))		||
		(0!=GetItemCount(SBuyItemInfo::e_sold))		||
		(0!=GetItemCount(SBuyItemInfo::e_bought))
		){
			DumpAllItems("");
			R_ASSERT2(0, "0!=GetItemCount");
		}

	for(int idx = e_first; idx<e_player_total; ++idx)
	{
		CUIDragDropListEx* lst			= m_list[idx];
		R_ASSERT(0==lst->ItemsCount());
	}
}
Exemple #9
0
void CUITradeWnd::FillList	(TIItemContainer& cont, CUIDragDropListEx& dragDropList, bool do_colorize)
{
	TIItemContainer::iterator it	= cont.begin();
	TIItemContainer::iterator it_e	= cont.end();

	for(; it != it_e; ++it) 
	{
		CUICellItem* itm			= create_cell_item	(*it);
		if(do_colorize)				ColorizeItem		(itm, CanMoveToOther(*it));
		dragDropList.SetItem		(itm);
	}

}