Exemplo n.º 1
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));
}
Exemplo n.º 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;
}
Exemplo n.º 3
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);
	}
}