// Inserts a new unique entry
BOOL LLEmbeddedItems::insertEmbeddedItem( LLInventoryItem* item, llwchar* ext_char, bool is_new)
{
	// Now insert a new one
	llwchar wc_emb;
	if (!sFreeEntries.empty())
	{
		wc_emb = sFreeEntries.top();
		sFreeEntries.pop();
	}
	else if (sEntries.empty())
	{
		wc_emb = LLTextEditor::FIRST_EMBEDDED_CHAR;
	}
	else
	{
		item_map_t::iterator last = sEntries.end();
		--last;
		wc_emb = last->first;
		if (wc_emb >= LLTextEditor::LAST_EMBEDDED_CHAR)
		{
			return FALSE;
		}
		++wc_emb;
	}

	sEntries[wc_emb].mItem = item;
	sEntries[wc_emb].mSaved = is_new ? FALSE : TRUE;
	*ext_char = wc_emb;
	mEmbeddedUsedChars.insert(wc_emb);
	return TRUE;
}
Beispiel #2
0
void item::remove() {
    //Remove the entry in map that points to current tuple
    item_map_t::iterator item_map_iter;
    item_map_iter=item_map.find(make_tuple(i_id));
    item_map.erase(item_map_iter);
    //Move last tuple in vector in the place of the deleted tuple
    //If current tuple is not the last tuple,
    if(tuple_id != count - 1) {

        //Move content of last tuple to fields in this tuple
        item item_vect_last_iter;
        item_vect_last_iter=item_vect.at(count - 1);

        i_id = item_vect_last_iter.i_id;
        i_im_id = item_vect_last_iter.i_im_id;
        strcpy(i_name, item_vect_last_iter.i_name);
        i_price = item_vect_last_iter.i_price;
        strcpy(i_data, item_vect_last_iter.i_data);

        //Remove the entry for the last tuple in map, and insert a new one with new tuple_id
        item_map_t::iterator item_map_iter;
        item_map_iter=item_map.find(make_tuple(i_id));
        if(item_map_iter != item_map.end())
            item_map.erase(item_map_iter);
        item_map.insert(make_pair(make_tuple(i_id), tuple_id));;

        //Call remove on the last entry of the vector
        item_vect_last_iter.remove();
    }
    else {		//if the tuple is the last tuple in the vector
        count--;
        item_vect.pop_back();
    }
    //item_vect.erase(tuple_id);
}
void LLEmbeddedItems::bindEmbeddedChars( const LLFontGL* font ) const
{
    if( sEntries.empty() )
    {
        return;
    }

    for (std::set<llwchar>::const_iterator iter1 = mEmbeddedUsedChars.begin(); iter1 != mEmbeddedUsedChars.end(); ++iter1)
    {
        llwchar wch = *iter1;
        item_map_t::iterator iter2 = sEntries.find(wch);
        if (iter2 == sEntries.end())
        {
            continue;
        }
        LLInventoryItem* item = iter2->second.mItem;
        if (!item)
        {
            continue;
        }
        LLUIImagePtr image = get_item_icon(item->getType(),
                                           item->getInventoryType(),
                                           0,
                                           item->getFlags() & LLInventoryItem::II_FLAGS_OBJECT_HAS_MULTIPLE_ITEMS);//LLUI::getUIImage(img_name);

        font->addEmbeddedChar( wch, image->getImage(), item->getName() );
    }
}
Beispiel #4
0
 virtual void print() const{
     printf("%s: \"%s\"\n", _name.c_str(), _description.c_str());
     item_map_t::const_iterator iter = _item_map.begin();
     for(; iter != _item_map.end(); ++ iter){
         printf("\t");
         iter->second.print();
     }
 }
// static
BOOL LLEmbeddedItems::getEmbeddedItemSaved(llwchar ext_char)
{
	if( ext_char >= LLTextEditor::FIRST_EMBEDDED_CHAR && ext_char <= LLTextEditor::LAST_EMBEDDED_CHAR )
	{
		item_map_t::iterator iter = sEntries.find(ext_char);
		if (iter != sEntries.end())
		{
			return iter->second.mSaved;
		}
	}
	return FALSE;
}
// static
LLInventoryItem* LLEmbeddedItems::getEmbeddedItem(llwchar ext_char)
{
	if( ext_char >= LLTextEditor::FIRST_EMBEDDED_CHAR && ext_char <= LLTextEditor::LAST_EMBEDDED_CHAR )
	{
		item_map_t::iterator iter = sEntries.find(ext_char);
		if (iter != sEntries.end())
		{
			return iter->second.mItem;
		}
	}
	return NULL;
}
// Removes an entry (all entries are unique)
BOOL LLEmbeddedItems::removeEmbeddedItem( llwchar ext_char )
{
	mEmbeddedUsedChars.erase(ext_char);
	item_map_t::iterator iter = sEntries.find(ext_char);
	if (iter != sEntries.end())
	{
		sEntries.erase(ext_char);
		sFreeEntries.push(ext_char);
		return TRUE;
	}
	return FALSE;
}
Beispiel #8
0
 void addMeasurement(const l4_uint32_t id, l4_uint64_t value){
     GET_STATS.enterMeasurement();
     _item_map_mutex.enter();
     item_map_t::iterator iter = _item_map.find(id);
     _item_map_mutex.leave();
     if(iter != _item_map.end()){
         iter->second.addMeasurement(value);
     } else {
         _item_map_mutex.enter();
         Item & item = _item_map[id];
         _item_map_mutex.leave();
         item.addMeasurement(value);
         std::stringstream s;
         s << "0x" << std::hex << id;
         item.setName(s.str());
     }
     GET_STATS.leaveMeasurement();
 }
void LLEmbeddedItems::bindEmbeddedChars( const LLFontGL* font ) const
{
	if( sEntries.empty() )
	{
		return; 
	}

	for (std::set<llwchar>::const_iterator iter1 = mEmbeddedUsedChars.begin(); iter1 != mEmbeddedUsedChars.end(); ++iter1)
	{
		llwchar wch = *iter1;
		item_map_t::iterator iter2 = sEntries.find(wch);
		if (iter2 == sEntries.end())
		{
			continue;
		}
		LLInventoryItem* item = iter2->second.mItem;
		if (!item)
		{
			continue;
		}
		const char* img_name;
		switch( item->getType() )
		{
		  case LLAssetType::AT_TEXTURE:
			if(item->getInventoryType() == LLInventoryType::IT_SNAPSHOT)
			{
				img_name = "inv_item_snapshot.tga";
			}
			else
			{
				img_name = "inv_item_texture.tga";
			}

			break;
		  case LLAssetType::AT_SOUND:			img_name = "inv_item_sound.tga";	break;
		  case LLAssetType::AT_CALLINGCARD:		img_name = "inv_item_callingcard_online.tga";   break;
		  case LLAssetType::AT_LANDMARK:		
			if (item->getFlags() & LLInventoryItemFlags::II_FLAGS_LANDMARK_VISITED)
			{
				img_name = "inv_item_landmark_visited.tga";	
			}
			else
			{
				img_name = "inv_item_landmark.tga";	
			}
			break;
		  case LLAssetType::AT_CLOTHING:		img_name = "inv_item_clothing.tga";	break;
		  case LLAssetType::AT_OBJECT:			
			if (item->getFlags() & LLInventoryItemFlags::II_FLAGS_OBJECT_HAS_MULTIPLE_ITEMS)
			{
				img_name = "inv_item_object_multi.tga";	
			}
			else
			{
				img_name = "inv_item_object.tga";	
			}
			break;
		  case LLAssetType::AT_NOTECARD:		img_name = "inv_item_notecard.tga";	break;
		  case LLAssetType::AT_LSL_TEXT:		img_name = "inv_item_script.tga";	break;
		  case LLAssetType::AT_BODYPART:		img_name = "inv_item_skin.tga";	break;
		  case LLAssetType::AT_ANIMATION:		img_name = "inv_item_animation.tga";break;
		  case LLAssetType::AT_GESTURE:			img_name = "inv_item_gesture.tga";	break;
		  default: llassert(0); continue;
		}

		LLUIImagePtr image = LLUI::getUIImage(img_name);

		font->addEmbeddedChar( wch, image->getImage(), item->getName() );
	}
}
Beispiel #10
0
 virtual void flush(){
     item_map_t::iterator iter = _item_map.begin();
     for(; iter != _item_map.end(); ++iter) iter->second.flush();
 }