Beispiel #1
0
void CInventoryItem::SetCount(int n)
{
	// Only positive values are allowed
	m_Count = (n >= 0) ? n : 0;

	NotifyItemChanged();
}
Beispiel #2
0
void CInventoryItem::SetValue(int n)
{
	// Only positive values are allowed
	if (n >= 0)
	{
		m_Value = n;

		NotifyItemChanged();
	}
}
Beispiel #3
0
void CInventoryItem::SetLootType(LootType t)
{
	// Only positive values are allowed
	if (t >= LOOT_NONE && t <= LOOT_COUNT)
	{
		m_LootType = t;
	}
	else
	{
		m_LootType = LOOT_NONE;
	}

	NotifyItemChanged();
}
NS_IMETHODIMP nsAbMDBDirectory::OnCardEntryChange
(uint32_t aAbCode, nsIAbCard *aCard, nsIAbDirectory *aParent)
{
  // Don't notify AbManager unless we have the parent
  if (!aParent)
    return NS_OK;

  NS_ENSURE_ARG_POINTER(aCard);
  nsCOMPtr<nsISupports> cardSupports(do_QueryInterface(aCard));
  nsresult rv;

  // Notify when
  // - any operation is done to a card belonging to this
  //        => if <this> is <aParent>, or
  // - a card belonging to a directory which is parent of this is deleted
  //        => if aAbCode is AB_NotifyDeleted && <this> is child of <aParent>, or
  // - a card belonging to a directory which is child of this is added/modified
  //        => if aAbCode is !AB_NotifyDeleted && <this> is parent of <aParent>

  if (aParent != this)
  {
    bool isChild = false;
    if (aAbCode != AB_NotifyDeleted)
      isChild = ContainsDirectory(this, aParent);
    else
      isChild = ContainsDirectory(aParent, this);

    if (!isChild)
      return NS_OK;
  }

  switch (aAbCode) {
  case AB_NotifyInserted:
    rv = NotifyItemAdded(cardSupports);
    break;
  case AB_NotifyDeleted:
    rv = NotifyItemDeleted(cardSupports);
    break;
  case AB_NotifyPropertyChanged:
    rv = NotifyItemChanged(cardSupports);
    break;
  default:
    rv = NS_ERROR_UNEXPECTED;
    break;
  }
    
  NS_ENSURE_SUCCESS(rv, rv);
  return rv;
}
Beispiel #5
0
void CInventoryItem::SetHUD(const idStr &HudName, int layer)
{
	DM_LOG(LC_INVENTORY, LT_DEBUG)LOGSTRING("Setting hud %s on layer %d\r", HudName.c_str(), layer); 
	if (m_Overlay == OVERLAYS_INVALID_HANDLE || m_HudName != HudName)
	{
		idEntity *owner = GetOwner();

		m_Hud = true;
		m_HudName = HudName;
		m_Overlay = owner->CreateOverlay(HudName, layer);
		idEntity* it = m_Item.GetEntity();
		if (it != NULL)
		{
			it->CallScriptFunctionArgs("inventory_item_init", true, 0, "eefs", it, owner, (float)m_Overlay, HudName.c_str());
		}
	}

	NotifyItemChanged();
}
Beispiel #6
0
void CInventoryItem::SetIcon(const idStr& newIcon)
{
	m_Icon = newIcon;

	NotifyItemChanged();
}