コード例 #1
0
void CUIMpTradeWnd::CleanUserItems()
{
	Msg("--CleanUserItems");
	SBuyItemInfo*	iinfo	= NULL;
	SBuyItemInfo::EItmState _state=SBuyItemInfo::e_bought;

	for(int i=0; i<3;++i )
	{
		if(i==0) _state = SBuyItemInfo::e_bought;
		else
		if(i==1) _state = SBuyItemInfo::e_sold;
		else
		if(i==2) _state = SBuyItemInfo::e_own;
	
		do{
			iinfo				= FindItem(_state);
			if(iinfo)
			{
				while( iinfo->m_cell_item->ChildsCount() )
				{
					CUICellItem* iii = iinfo->m_cell_item->PopChild	();
					SBuyItemInfo* iinfo_sub		= FindItem(iii);
					R_ASSERT2(	iinfo_sub->GetState()==_state || iinfo_sub->GetState()==SBuyItemInfo::e_shop,
								_state_names[_state]);
				}

				if(IsAddonAttached(iinfo, at_scope) )
				{
					SBuyItemInfo* detached_addon	= DetachAddon(iinfo, at_scope);
					detached_addon->SetState		(SBuyItemInfo::e_undefined);
					detached_addon->SetState		(SBuyItemInfo::e_shop);
					detached_addon->m_cell_item->SetOwnerList(NULL);
				}
				if(IsAddonAttached(iinfo, at_silencer) )
				{
					SBuyItemInfo* detached_addon	= DetachAddon(iinfo, at_silencer);
					detached_addon->SetState		(SBuyItemInfo::e_undefined);
					detached_addon->SetState		(SBuyItemInfo::e_shop);
					detached_addon->m_cell_item->SetOwnerList(NULL);
				}
				if(IsAddonAttached(iinfo, at_glauncher) )
				{
					SBuyItemInfo* detached_addon	= DetachAddon(iinfo, at_glauncher);
					detached_addon->SetState		(SBuyItemInfo::e_undefined);
					detached_addon->SetState		(SBuyItemInfo::e_shop);
					detached_addon->m_cell_item->SetOwnerList(NULL);
				}

				iinfo->SetState						(SBuyItemInfo::e_undefined);
				iinfo->SetState						(SBuyItemInfo::e_shop);
				iinfo->m_cell_item->SetOwnerList	(NULL);
			}
		}while(iinfo);
	}
	for(u32 i = e_first; i<e_player_total; ++i)
		m_list[i]->ClearAll	(false);
}
コード例 #2
0
SBuyItemInfo* CUIMpTradeWnd::FindItem(const shared_str& name_sect, SBuyItemInfo::EItmState type)
{
	ITEMS_vec_cit it = m_all_items.begin();
	ITEMS_vec_cit it_e = m_all_items.end();
	for(;it!=it_e;++it)
	{
		SBuyItemInfo* pitm = *it;
		if(pitm->m_name_sect==name_sect && pitm->GetState()==type)
			return pitm;
	}
	return NULL;
}
コード例 #3
0
SBuyItemInfo* CUIMpTradeWnd::CreateItem(const shared_str& name_sect, SBuyItemInfo::EItmState type, bool find_if_exist)
{
	SBuyItemInfo* iinfo			= (find_if_exist)?FindItem(name_sect, type):NULL;
	if(iinfo)
		return					iinfo;

	iinfo						= xr_new<SBuyItemInfo>();
	m_all_items.push_back		( iinfo );
	iinfo->m_name_sect			= name_sect;
	iinfo->SetState				(type);
	iinfo->m_cell_item			= create_cell_item(CreateItem_internal(name_sect));
	iinfo->m_cell_item->m_b_destroy_childs = false;
	return						iinfo;
}
コード例 #4
0
void CUIMpTradeWnd::DumpAllItems(LPCSTR s)
{
	std::sort		(m_all_items.begin(), m_all_items.end(), items_sorter());

	Msg("CUIMpTradeWnd::DumpAllItems.total[%d] reason [%s]", m_all_items.size(), s);
	ITEMS_vec_cit it = m_all_items.begin();
	ITEMS_vec_cit it_e = m_all_items.end();
	for(;it!=it_e;++it)
	{
		SBuyItemInfo* iinfo = *it;
		Msg("[%s] state[%s]", iinfo->m_name_sect.c_str(), iinfo->GetStateAsText());
	}
	Msg("------");
}
コード例 #5
0
void CUIMpTradeWnd::StorePreset(ETradePreset idx, bool bSilent)
{
	if(!bSilent)
	{
		string512						buff;
		sprintf							(buff,	"%s [%d]",
												CStringTable().translate("ui_st_preset_stored_to").c_str(), idx);
		SetInfoString					(buff);
	}
	ITEMS_vec_cit it				= m_all_items.begin();
	ITEMS_vec_cit it_e				= m_all_items.end();

	preset_items&	v				= m_preset_storage[idx];
	v.clear_not_free				();
	for(;it!=it_e; ++it)
	{
		SBuyItemInfo* iinfo			= *it;
		if(	!(iinfo->GetState()==SBuyItemInfo::e_bought || iinfo->GetState()==SBuyItemInfo::e_own)	)
		continue;

		u8 addon_state				= GetItemAddonsState_ext(iinfo);

		preset_items::iterator fit	= std::find_if(v.begin(), v.end(), preset_eq(iinfo->m_name_sect, addon_state) );
		if(fit!=v.end())
			continue;

		u32 cnt						= GetItemCount(iinfo->m_name_sect, SBuyItemInfo::e_bought, addon_state);
		cnt							+=GetItemCount(iinfo->m_name_sect, SBuyItemInfo::e_own, addon_state);
		if(0==cnt)				
			continue;

		v.resize					(v.size()+1);
		_preset_item& _one			= v.back();
		_one.sect_name				= iinfo->m_name_sect;
		_one.count					= cnt;
		_one.addon_state			= addon_state;

		if(addon_state&at_scope)
			_one.addon_names[0]			= GetAddonNameSect(iinfo, at_scope);

		if(addon_state&at_glauncher)
			_one.addon_names[1]			= GetAddonNameSect(iinfo, at_glauncher);

		if(addon_state&at_silencer)
			_one.addon_names[2]			= GetAddonNameSect(iinfo, at_silencer);
	}

	std::sort						(v.begin(), v.end(), preset_sorter(m_item_mngr));
}
コード例 #6
0
void CUIMpTradeWnd::DeleteHelperItems (CUIDragDropListEx* list)
{
	ITEMS_vec to_sell;

	for ( ITEMS_vec::iterator it	=	m_all_items.begin();
							  it	!=	m_all_items.end();
							  ++it )
	{
		SBuyItemInfo*		  item			=	*it;

		if ( item->m_cell_item->OwnerList() != list )
		{
			continue;
		}

		if ( item->GetState() != SBuyItemInfo::e_bought && item->GetState() != SBuyItemInfo::e_own )
		{
			continue;
		}

		if ( item->m_cell_item->IsHelper() )
		{
			if ( std::find(to_sell.begin(), to_sell.end(), item) == to_sell.end() )
			{
				to_sell.push_back(item);
			}
		}
	}

	for ( ITEMS_vec::iterator it	=	to_sell.begin();
							  it	!=	to_sell.end();
							  ++it )
	{
		SBuyItemInfo* tempo = NULL;
		TryToSellItem(*it, true, tempo);
	}
}