Ejemplo n.º 1
0
QVariant SceneTreeItem::data(int role) const
{
	QVariant v;

	switch(role)
	{
	case Qt::DecorationRole:
		v = ItemIcon();
		break;
	case Qt::DisplayRole:
		v = ItemName();
		break;
	case EIDR_Type:
		v = ItemType();
		break;
	case EIDR_Data:
		v = ItemData();
		break;
    case Qt::BackgroundColorRole:
        v = ItemBackgroundColor();
        break;
	default:
		break;
	}

	if(v.isNull())
	{
		v = QStandardItem::data(role);
	}

	return v;
}
Ejemplo n.º 2
0
void AddItem(CPlayer* p, int item, float amount, float clip)
{
	if(amount <= 0.0f)
		return;
    
	CHold* hold;
	int added = -1;
    
	for(int i=0; i<p->items.size(); i++)
	{
		hold = &p->items[i];
        
		if(hold->type != item)
			continue;
        
		hold->amount += amount;
		added = i;
		break;
	}
    
	if(added < 0)
	{
		CHold h(item, amount, clip);
		p->items.push_back(h);
		added = p->items.size() - 1;
	}
    
	CItemType* t = &g_itemType[item];
    
	if(p->equipped < 0 && t->equip)
		Equip(p, added, t);
    
	if(&g_player[g_localP] != p)
		return;
    
    int equippable = 0;
    CItemType* hT;
    for(int i=0; i<p->items.size(); i++)
	{
		hold = &p->items[i];
        hT = &g_itemType[hold->type];
        if(hT->equip)
            equippable ++;
    }
    
    if(equippable > 1)
        OpenAnotherView("switch item");
    
    //g_viewmode = FIRSTPERSON;
    
	RedoAmmo();
    
	char msg[16];
	sprintf(msg, "+%d", (int)amount);
	ItemIcon(t->icon, msg);
}