Inheritance: ISerializable
        public string RezAll(BotInventoryEval man, InventoryBase b, SimPosition dest)
        {
            string ret = "";
            var manager = man.Manager;
            if (b is InventoryItem)
            {
                InventoryItem item = b as InventoryItem;

                bool canCopy = (item.Permissions.OwnerMask & PermissionMask.Copy) == PermissionMask.Copy;

                ret += item.Name + nl;
                if (dest == null)
                {
                    Simulator sim = Client.Network.CurrentSim;
                    Client.Inventory.RequestRestoreRezFromInventory(sim, item, item.UUID);
                }
                else
                {
                    Simulator sim = SimRegion.GetRegion(dest.GlobalPosition).TheSimulator;
                    Client.Inventory.RequestRezFromInventory(sim, dest.SimRotation, dest.SimPosition, item, UUID.Zero);
                }
            }
            else if (b is InventoryFolder)
            {
                InventoryFolder folder = b as InventoryFolder;
                List<InventoryBase> folderContents = man.FolderContents(folder.UUID);
                if (folderContents != null)
                    foreach (InventoryBase list in folderContents)
                    {
                        ret += RezAll(man, list, dest);
                    }
            }
            return ret;
        }
 /// <summary>
 /// Determine whether the specified <seealso cref="OpenMetaverse.InventoryBase"/> object is equal to the current object
 /// </summary>
 /// <param name="o">InventoryBase object to compare against</param>
 /// <returns>true if objects are the same</returns>
 public virtual bool Equals(InventoryBase o)
 {
     return(o.UUID == UUID &&
            o.ParentUUID == ParentUUID &&
            o.Name == Name &&
            o.OwnerID == OwnerID);
 }
        /// <summary>
        /// Removes the InventoryObject and all related node data from Inventory.
        /// </summary>
        /// <param name="item">The InventoryObject to remove.</param>
        public void RemoveNodeFor(InventoryBase item)
        {
            lock (Items)
            {
                InventoryNode node;
                if (Items.TryGetValue(item.UUID, out node))
                {
                    if (node.Parent != null)
                    {
                        lock (node.Parent.Nodes.SyncRoot)
                            node.Parent.Nodes.Remove(item.UUID);
                    }
                    Items.Remove(item.UUID);
                    if (m_InventoryObjectRemoved != null)
                    {
                        OnInventoryObjectRemoved(new InventoryObjectRemovedEventArgs(item));
                    }
                }

                // In case there's a new parent:
                InventoryNode newParent;
                if (Items.TryGetValue(item.ParentUUID, out newParent))
                {
                    lock (newParent.Nodes.SyncRoot)
                        newParent.Nodes.Remove(item.UUID);
                }
            }
        }
Exemple #4
0
 protected void FireOnInventoryObjectAdded(InventoryBase obj)
 {
     if (OnInventoryObjectAdded != null)
     {
         try { OnInventoryObjectAdded(obj); }
         catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); }
     }
 }
Exemple #5
0
 protected void FireOnInventoryObjectUpdated(InventoryBase oldObject, InventoryBase newObject)
 {
     if (OnInventoryObjectUpdated != null)
     {
         try { OnInventoryObjectUpdated(oldObject, newObject); }
         catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); }
     }
 }
        /// <summary>
        /// De-serialization handler for the InventoryNode Class
        /// </summary>
        public InventoryNode(SerializationInfo info, StreamingContext ctxt)
        {
            parentID = (UUID)info.GetValue("Parent", typeof(UUID));
            Type type = (Type)info.GetValue("Type", typeof(Type));

            // Construct a new inventory object based on the Type stored in Type
            System.Reflection.ConstructorInfo ctr = type.GetConstructor(new Type[] { typeof(SerializationInfo), typeof(StreamingContext) });
            data = (InventoryBase)ctr.Invoke(new Object[] { info, ctxt });
        }
        /// <summary>
        /// De-serialization constructor for the InventoryNode Class
        /// </summary>
        public InventoryNode(InventoryBase data, InventoryNode parent)
        {
            this.data = data;
            this.parent = parent;

            if (parent != null)
            {
                // Add this node to the collection of parent nodes
                lock (parent.Nodes.SyncRoot) parent.Nodes.Add(data.UUID, this);
            }
        }
        /// <summary>
        /// De-serialization constructor for the InventoryNode Class
        /// </summary>
        public InventoryNode(InventoryBase data, InventoryNode parent)
        {
            this.data   = data;
            this.parent = parent;

            if (parent != null)
            {
                // Add this node to the collection of parent nodes
                lock (parent.Nodes.SyncRoot) parent.Nodes.Add(data.UUID, this);
            }
        }
Exemple #9
0
        internal Closet(PluginControl pc)
            : base(pc)
        {
            Title = "inventory";
            inv = control.instance.Client.Inventory.Store;
            selected = inv.RootNode.Data;

            control.listener.CreateGrammar(
                INVNAME,
                new string[] {
                    "read it",
                    "go there",
                    "close the closet",
                    "describe it" });
        }
Exemple #10
0
        public int CompareNodes(InventoryBase x, InventoryBase y, TreeNode nodeX, TreeNode nodeY)
        {
            int returnVal = 0;

            if (x is InventoryItem && y is InventoryItem)
            {
                InventoryItem itemX = (InventoryItem)x;
                InventoryItem itemY = (InventoryItem)y;

                returnVal = -itemX.CreationDate.CompareTo(itemY.CreationDate);
            }
            else if (x is InventoryFolder && y is InventoryFolder)
                returnVal = nodeX.Text.CompareTo(nodeY.Text);
            else if (x is InventoryFolder && y is InventoryItem)
                returnVal = 1;
            else if (x is InventoryItem && y is InventoryFolder)
                returnVal = -1;

            return returnVal;
        }
        public string GiveAll(BotInventoryEval man, InventoryBase b, SimObject dest, bool moveInsteadOfCopy)
        {
            string ret = "";
            var manager = man.Manager;
            if (b is InventoryItem)
            {
                InventoryItem item = b as InventoryItem;

                bool canCopy = (item.Permissions.OwnerMask & PermissionMask.Copy) == PermissionMask.Copy;

                ret += item.Name + nl;
                if (dest.IsAvatar)
                {
                    manager.GiveItem(item.UUID, item.Name, item.AssetType, dest.ID, true);
                }
                else
                {
                    throw new NotImplementedException("giving items to objects");
                }
            }
            else if (b is InventoryFolder)
            {
                InventoryFolder item = b as InventoryFolder;
                if (dest.IsAvatar)
                {
                    manager.GiveFolder(item.UUID, item.Name, AssetType.Folder, dest.ID, true);
                    return item.Name + nl;
                }
                InventoryFolder folder = b as InventoryFolder;
                List<InventoryBase> folderContents = man.FolderContents(folder.UUID);
                if (folderContents != null)
                    foreach (InventoryBase list in folderContents)
                    {
                        ret += GiveAll(man, list, dest, moveInsteadOfCopy);
                    }
            }
            return ret;
        }
Exemple #12
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="o"></param>
 /// <returns></returns>
 public override bool Equals(InventoryBase o)
 {
     InventoryFolder folder = o as InventoryFolder;
     return folder != null && Equals(folder);
 }
Exemple #13
0
 /// <summary>
 /// Creates inventory link to another inventory item or folder
 /// </summary>
 /// <param name="folderID">Put newly created link in folder with this UUID</param>
 /// <param name="bse">Inventory item or folder</param>
 /// <param name="callback">Method to call upon creation of the link</param>
 public void CreateLink(UUID folderID, InventoryBase bse, ItemCreatedCallback callback)
 {
     if (bse is InventoryFolder)
     {
         InventoryFolder folder = (InventoryFolder)bse;
         CreateLink(folderID, folder, callback);
     }
     else if (bse is InventoryItem)  
     {
         InventoryItem item = (InventoryItem)bse;
         CreateLink(folderID, item.UUID, item.Name, item.Description, AssetType.Link, item.InventoryType, UUID.Random(), callback);
     }
 }
Exemple #14
0
 /// <summary>
 /// Move an inventory item or folder to a new location and change its name
 /// </summary>
 /// <param name="item">The <seealso cref="T:InventoryBase"/> item or folder to move</param>
 /// <param name="newParent">The <seealso cref="T:InventoryFolder"/> to move item or folder to</param>
 /// <param name="newName">The name to change the item or folder to</param>
 public void Move(InventoryBase item, InventoryFolder newParent, string newName)
 {
     if (item is InventoryFolder)
         MoveFolder(item.UUID, newParent.UUID, newName);
     else
         MoveItem(item.UUID, newParent.UUID, newName);
 }
 TreeNode AddBase(TreeNode parent, InventoryBase obj)
 {
     if (obj is InventoryItem)
     {
         return AddItem(parent, (InventoryItem)obj);
     }
     else
     {
         return AddDir(parent, (InventoryFolder)obj);
     }
 }
 public SearchResult(InventoryBase inv, int level)
 {
     this.Inv = inv;
     this.Level = level;
 }
 public InventoryObjectAddedEventArgs(InventoryBase obj)
 {
     this.m_Obj = obj;
 }
 public bool Contains(InventoryBase obj)
 {
     return(Contains(obj.UUID));
 }
Exemple #19
0
 public bool Contains(InventoryBase obj)
 {
     return Contains(obj.UUID);
 }
Exemple #20
0
        /// <summary>
        /// Removes the InventoryObject and all related node data from Inventory.
        /// </summary>
        /// <param name="item">The InventoryObject to remove.</param>
        public void RemoveNodeFor(InventoryBase item)
        {
            lock (Items)
            {
                InventoryNode node;
                if (Items.TryGetValue(item.UUID, out node))
                {
                    if (node.Parent != null)
                        lock (node.Parent.Nodes.SyncRoot)
                            node.Parent.Nodes.Remove(item.UUID);
                    Items.Remove(item.UUID);
                    FireOnInventoryObjectRemoved(item);
                }

                // In case there's a new parent:
                InventoryNode newParent;
                if (Items.TryGetValue(item.ParentUUID, out newParent))
                {
                    lock (newParent.Nodes.SyncRoot)
                        newParent.Nodes.Remove(item.UUID);
                }
            }
        }
Exemple #21
0
        /// <summary>
        /// Updates the state of the InventoryNode and inventory data structure that
        /// is responsible for the InventoryObject. If the item was previously not added to inventory,
        /// it adds the item, and updates structure accordingly. If it was, it updates the 
        /// InventoryNode, changing the parent node if <code>item.parentUUID</code> does 
        /// not match <code>node.Parent.Data.UUID</code>.
        /// 
        /// You can not set the inventory root folder using this method
        /// </summary>
        /// <param name="item">The InventoryObject to store</param>
        public void UpdateNodeFor(InventoryBase item)
        {
            lock (Items)
            {
                InventoryNode itemParent = null;
                if (item.ParentUUID != UUID.Zero && !Items.TryGetValue(item.ParentUUID, out itemParent))
                {
                    // OK, we have no data on the parent, let's create a fake one.
                    InventoryFolder fakeParent = new InventoryFolder(item.ParentUUID);
                    fakeParent.DescendentCount = 1; // Dear god, please forgive me.
                    itemParent = new InventoryNode(fakeParent);
                    Items[item.ParentUUID] = itemParent;
                    // Unfortunately, this breaks the nice unified tree
                    // while we're waiting for the parent's data to come in.
                    // As soon as we get the parent, the tree repairs itself.
                    Logger.DebugLog("Attempting to update inventory child of " +
                        item.ParentUUID.ToString() + " when we have no local reference to that folder", Client);

                    if (Client.Settings.FETCH_MISSING_INVENTORY)
                    {
                        // Fetch the parent
                        List<UUID> fetchreq = new List<UUID>(1);
                        fetchreq.Add(item.ParentUUID);
                        //Manager.FetchInventory(fetchreq); // we cant fetch folder data! :-O
                    }
                }

                InventoryNode itemNode;
                if (Items.TryGetValue(item.UUID, out itemNode)) // We're updating.
                {
                    InventoryNode oldParent = itemNode.Parent;
                    // Handle parent change
                    if (oldParent == null || itemParent == null || itemParent.Data.UUID != oldParent.Data.UUID)
                    {
                        if (oldParent != null)
                        {
                            lock (oldParent.Nodes.SyncRoot)
                                oldParent.Nodes.Remove(item.UUID);
                        }
                        if (itemParent != null)
                        {
                            lock (itemParent.Nodes.SyncRoot)
                                itemParent.Nodes[item.UUID] = itemNode;
                        }
                    }

                    itemNode.Parent = itemParent;

                    FireOnInventoryObjectUpdated(itemNode.Data, item);

                    itemNode.Data = item;
                }
                else // We're adding.
                {
                    itemNode = new InventoryNode(item, itemParent);
                    Items.Add(item.UUID, itemNode);
                    FireOnInventoryObjectAdded(item);
                }
            }
        }
Exemple #22
0
 /// <summary>
 /// Determine whether the specified <seealso cref="OpenMetaverse.InventoryBase"/> object is equal to the current object
 /// </summary>
 /// <param name="o">InventoryBase object to compare against</param>
 /// <returns>true if objects are the same</returns>
 public virtual bool Equals(InventoryBase o)
 {
     return o.Guid == Guid
         && o.ParentGuid == ParentGuid
         && o.Name == Name
         && o.OwnerID == OwnerID;
 }
 /// <inheritdoc />
 /// <summary>
 /// Determine whether the specified <seealso cref="T:OpenMetaverse.InventoryBase" /> object is equal to the current object
 /// </summary>
 /// <param name="o">The <seealso cref="T:OpenMetaverse.InventoryBase" /> object to compare against</param>
 /// <returns>true if objects are the same</returns>
 public override bool Equals(InventoryBase o)
 {
     return(o is InventoryItem item && Equals(item));
 }
 /// <summary>
 /// Can this inventory type be worn
 /// </summary>
 /// <param name="item">Item to check</param>
 /// <returns>True if the inventory item can be worn</returns>
 public static bool CanBeWorn(InventoryBase item)
 {
     return item is InventoryWearable || item is InventoryAttachment || item is InventoryObject;
 }
Exemple #25
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public InventoryNode(SerializationInfo info, StreamingContext ctxt)
        {
            parentID = (UUID)info.GetValue("Parent", typeof(UUID));
            Type type = (Type)info.GetValue("Type", typeof(Type));

            if (type == typeof(InventoryAnimation))
            {
                data = new InventoryAnimation(info, ctxt);
            }

            if (type == typeof(InventoryAttachment))
            {
                data = new InventoryAttachment(info, ctxt);
            }

            if (type == typeof(InventoryCallingCard))
            {
                data = new InventoryCallingCard(info, ctxt);
            }

            if (type == typeof(InventoryFolder))
            {
                data = new InventoryFolder(info, ctxt);
            }

            if (type == typeof(InventoryGesture))
            {
                data = new InventoryGesture(info, ctxt);
            }

            if (type == typeof(InventoryLandmark))
            {
                data = new InventoryLandmark(info, ctxt);
            }

            if (type == typeof(InventoryLSL))
            {
                data = new InventoryLSL(info, ctxt);
            }

            if (type == typeof(InventoryNotecard))
            {
                data = new InventoryNotecard(info, ctxt);
            }

            if (type == typeof(InventoryObject))
            {
                data = new InventoryObject(info, ctxt);
            }

            if (type == typeof(InventorySnapshot))
            {
                data = new InventorySnapshot(info, ctxt);
            }

            if (type == typeof(InventorySound))
            {
                data = new InventorySound(info, ctxt);
            }

            if (type == typeof(InventoryTexture))
            {
                data = new InventoryTexture(info, ctxt);
            }

            if (type == typeof(InventoryWearable))
            {
                data = new InventoryWearable(info, ctxt);
            }
        }
Exemple #26
0
 void OnItemChange(object sender, TreeViewEventArgs e)
 {
     selected = (InventoryBase)e.Node.Tag;
     SayWhere();
 }
Exemple #27
0
 protected void FireOnInventoryObjectUpdated(InventoryBase oldObject, InventoryBase newObject)
 {
     if (OnInventoryObjectUpdated != null)
     {
         try { OnInventoryObjectUpdated(oldObject, newObject); }
         catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); }
     }
 }
 public InventoryObjectUpdatedEventArgs(InventoryBase oldObject, InventoryBase newObject)
 {
     this.m_OldObject = oldObject;
     this.m_NewObject = newObject;
 }
Exemple #29
0
 protected void FireOnInventoryObjectAdded(InventoryBase obj)
 {
     if (OnInventoryObjectAdded != null)
     {
         try { OnInventoryObjectAdded(obj); }
         catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); }
     }
 }
        void Exec_OnInventoryObjectUpdated(InventoryBase oldObject, InventoryBase newObject)
        {
            if (newObject == null) return;

            if (InvokeRequired)
            {
                BeginInvoke(new MethodInvoker(() => Exec_OnInventoryObjectUpdated(oldObject, newObject)));
                return;
            }

            lock (attachments)
            {
                if (attachments.ContainsKey(newObject.UUID))
                {
                    attachments[newObject.UUID].Item = (InventoryItem)newObject;
                }
            }

            // Find our current node in the tree
            TreeNode currentNode = findNodeForItem(newObject.UUID);

            // Find which node should be our parrent
            TreeNode parent = findNodeForItem(newObject.ParentUUID);

            if (parent == null) return;

            if (currentNode != null)
            {
                // Did we move to a different folder
                if (currentNode.Parent != parent)
                {
                    TreeNode movedNode = (TreeNode)currentNode.Clone();
                    movedNode.Tag = newObject;
                    parent.Nodes.Add(movedNode);
                    removeNode(currentNode);
                    cacheNode(movedNode);
                }
                else // Update
                {
                    currentNode.Tag = newObject;
                    currentNode.Text = ItemLabel(newObject, false);
                    currentNode.Name = newObject.Name;
                }
            }
            else // We are not in the tree already, add
            {
                AddBase(parent, newObject);
            }
        }
        Gdk.Pixbuf getprettyicon(InventoryBase item)
        {
            if (item is InventoryFolder)
                return getprettyfoldericon((InventoryFolder)item);

            if(item is OpenMetaverse.InventoryLandmark)
                return this.item_landmark;

            if(item is OpenMetaverse.InventoryAnimation)
                return this.item_animation;

            if(item is OpenMetaverse.InventoryWearable)
            {
                OpenMetaverse.InventoryWearable wearable=(OpenMetaverse.InventoryWearable)item;
                switch(wearable.WearableType)
                {
                case WearableType.Eyes:
                return this.item_clothing_eyes;

                case WearableType.Gloves:
                return this.item_clothing_gloves;

                case WearableType.Hair:
                return this.item_clothing_hair;

                case WearableType.Jacket:
                return this.item_clothing_jacket;

                case WearableType.Pants:
                return this.item_clothing_pants;

                case WearableType.Shape:
                return this.item_clothing_shape;

                case WearableType.Shirt:
                return this.item_clothing_shirt;

                case WearableType.Shoes:
                return this.item_clothing_shoes;

                case WearableType.Skin:
                return this.item_clothing_skin;

                case WearableType.Skirt:
                return this.item_clothing_skirt;

                case WearableType.Socks:
                return this.item_clothing_socks;

                case WearableType.Underpants:
                return this.item_clothing_underpants;

                case WearableType.Undershirt:
                return this.item_clothing_undershirt;

                default:
                return this.item_clothing;

                }

            }
            if (item is OpenMetaverse.InventoryGesture)
                return this.item_gesture;

            if (item is OpenMetaverse.InventoryNotecard)
                return this.item_notecard;

            if (item is OpenMetaverse.InventoryLSL)
                return this.item_script;

            if (item is OpenMetaverse.InventorySnapshot)
                return this.item_snapshot;

            if (item is OpenMetaverse.InventoryTexture)
                return this.item_texture;

            if (item is OpenMetaverse.InventorySound)
                return this.item_sound;

            if (item is OpenMetaverse.InventoryCallingCard)
                return this.item_callingcard;

            return item_object;
        }
        /// <summary>
        /// Returns text of the label
        /// </summary>
        /// <param name="invBase">Inventory item</param>
        /// <param name="returnRaw">Should we return raw text, or if false decorated text with (worn) info, and (no copy) etc. permission info</param>
        /// <returns></returns>
        public string ItemLabel(InventoryBase invBase, bool returnRaw)
        {
            if (returnRaw || (invBase is InventoryFolder))
                return invBase.Name;

            InventoryItem item = (InventoryItem)invBase;

            string raw = item.Name;

            if (item.IsLink())
            {
                raw += " (link)";
                if (Inventory.Contains(item.AssetUUID) && Inventory[item.AssetUUID] is InventoryItem)
                {
                    item = (InventoryItem)Inventory[item.AssetUUID];
                }
            }

            if ((item.Permissions.OwnerMask & PermissionMask.Modify) == 0)
                raw += " (no modify)";

            if ((item.Permissions.OwnerMask & PermissionMask.Copy) == 0)
                raw += " (no copy)";

            if ((item.Permissions.OwnerMask & PermissionMask.Transfer) == 0)
                raw += " (no transfer)";

            if (IsWorn(item))
                raw += " (worn)";

            if (IsAttached(item))
            {
                raw += " (worn on " + AttachedTo(item).ToString() + ")";
            }

            return raw;
        }
Exemple #33
0
 /// <summary>
 /// Move an inventory item or folder to a new location
 /// </summary>
 /// <param name="item">The <seealso cref="T:InventoryBase"/> item or folder to move</param>
 /// <param name="newParent">The <seealso cref="T:InventoryFolder"/> to move item or folder to</param>
 public void Move(InventoryBase item, InventoryFolder newParent)
 {
     if (item is InventoryFolder)
         MoveFolder(item.Guid, newParent.Guid);
     else
         MoveItem(item.Guid, newParent.Guid);
 }
        void Exec_OnInventoryObjectAdded(InventoryBase obj)
        {
            if (InvokeRequired)
            {
                Invoke(new MethodInvoker(delegate()
                    {
                        Exec_OnInventoryObjectAdded(obj);
                    }
                ));
                return;
            }

            lock (attachments)
            {
                if (attachments.ContainsKey(obj.UUID))
                {
                    attachments[obj.UUID].Item = (InventoryItem)obj;
                }
            }

            TreeNode parent = findNodeForItem(obj.ParentUUID);

            if (parent != null)
            {
                TreeNode newNode = AddBase(parent, obj);
                if (obj.Name == newItemName)
                {
                    if (newNode.Parent.IsExpanded)
                    {
                        newNode.BeginEdit();
                    }
                    else
                    {
                        newNode.Parent.Expand();
                    }
                }
            }
            newItemName = string.Empty;
        }
        /// <summary>
        /// De-serialization handler for the InventoryNode Class
        /// </summary>
        public InventoryNode(SerializationInfo info, StreamingContext ctxt)
        {
            parentID = (UUID)info.GetValue("Parent", typeof(UUID));
            Type type = (Type)info.GetValue("Type", typeof(Type));

            // Construct a new inventory object based on the Type stored in Type
            System.Reflection.ConstructorInfo ctr = type.GetConstructor(new Type[] {typeof(SerializationInfo),typeof(StreamingContext)});
            data = (InventoryBase) ctr.Invoke(new Object[] { info, ctxt });
        }
Exemple #36
0
 /// <summary>
 /// Determine whether the specified <seealso cref="OpenMetaverse.InventoryBase"/> object is equal to the current object
 /// </summary>
 /// <param name="o">InventoryBase object to compare against</param>
 /// <returns>true if objects are the same</returns>
 public virtual bool Equals(InventoryBase o)
 {
     return o.UUID == UUID
         && o.ParentUUID == ParentUUID
         && o.Name == Name
         && o.OwnerID == OwnerID;
 }
Exemple #37
0
 public InventoryClipboard(ClipboardOperation operation, InventoryBase item)
 {
     Operation = operation;
     Item = item;
 }
Exemple #38
0
 /// <summary>
 /// Determine whether the specified <seealso cref="OpenMetaverse.InventoryBase"/> object is equal to the current object
 /// </summary>
 /// <param name="o">The <seealso cref="OpenMetaverse.InventoryBase"/> object to compare against</param>
 /// <returns>true if objects are the same</returns>
 public override bool Equals(InventoryBase o)
 {
     InventoryItem item = o as InventoryItem;
     return item != null && Equals(item);
 }
        /// <summary>
        /// Updates the state of the InventoryNode and inventory data structure that
        /// is responsible for the InventoryObject. If the item was previously not added to inventory,
        /// it adds the item, and updates structure accordingly. If it was, it updates the
        /// InventoryNode, changing the parent node if <code>item.parentUUID</code> does
        /// not match <code>node.Parent.Data.UUID</code>.
        ///
        /// You can not set the inventory root folder using this method
        /// </summary>
        /// <param name="item">The InventoryObject to store</param>
        public void UpdateNodeFor(InventoryBase item)
        {
            lock (Items)
            {
                InventoryNode itemParent = null;
                if (item.ParentUUID != UUID.Zero && !Items.TryGetValue(item.ParentUUID, out itemParent))
                {
                    // OK, we have no data on the parent, let's create a fake one.
                    InventoryFolder fakeParent = new InventoryFolder(item.ParentUUID);
                    fakeParent.DescendentCount = 1; // Dear god, please forgive me.
                    itemParent             = new InventoryNode(fakeParent);
                    Items[item.ParentUUID] = itemParent;
                    // Unfortunately, this breaks the nice unified tree
                    // while we're waiting for the parent's data to come in.
                    // As soon as we get the parent, the tree repairs itself.
                    //Logger.DebugLog("Attempting to update inventory child of " +
                    //    item.ParentUUID.ToString() + " when we have no local reference to that folder", Client);

                    if (Client.Settings.FETCH_MISSING_INVENTORY)
                    {
                        // Fetch the parent
                        List <UUID> fetchreq = new List <UUID>(1);
                        fetchreq.Add(item.ParentUUID);
                    }
                }

                InventoryNode itemNode;
                if (Items.TryGetValue(item.UUID, out itemNode)) // We're updating.
                {
                    InventoryNode oldParent = itemNode.Parent;
                    // Handle parent change
                    if (oldParent == null || itemParent == null || itemParent.Data.UUID != oldParent.Data.UUID)
                    {
                        if (oldParent != null)
                        {
                            lock (oldParent.Nodes.SyncRoot)
                                oldParent.Nodes.Remove(item.UUID);
                        }
                        if (itemParent != null)
                        {
                            lock (itemParent.Nodes.SyncRoot)
                                itemParent.Nodes[item.UUID] = itemNode;
                        }
                    }

                    itemNode.Parent = itemParent;

                    if (m_InventoryObjectUpdated != null)
                    {
                        OnInventoryObjectUpdated(new InventoryObjectUpdatedEventArgs(itemNode.Data, item));
                    }

                    itemNode.Data = item;
                }
                else // We're adding.
                {
                    itemNode = new InventoryNode(item, itemParent);
                    Items.Add(item.UUID, itemNode);
                    if (m_InventoryObjectAdded != null)
                    {
                        OnInventoryObjectAdded(new InventoryObjectAddedEventArgs(item));
                    }
                }
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="data"></param>
 public InventoryNode(InventoryBase data)
 {
     this.data = data;
 }
Exemple #41
0
        private void Inventory_OnInventoryItemCopied(InventoryBase item)
        {
            if (InvokeRequired)
            {
                if (!instance.MonoRuntime || IsHandleCreated)
                    BeginInvoke(new MethodInvoker(() => Inventory_OnInventoryItemCopied(item)));
                return;
            }

            if (null == item) return;

            instance.TabConsole.DisplayNotificationInChat(
                string.Format("{0} saved to inventory", item.Name),
                ChatBufferTextStyle.Invisible);

            tlblStatus.Text = "Saved";

            if (item is InventoryNotecard)
            {
                Notecard nc = new Notecard(instance, (InventoryNotecard)item);
                nc.pnlKeepDiscard.Visible = true;
                nc.ShowDetached();
            }
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="data"></param>
 public InventoryNode(InventoryBase data)
 {
     this.data = data;
 }
Exemple #43
0
        string DescriptiveName(InventoryBase item)
        {
            string name = NiceName(item.Name);

             if (item is InventoryFolder)
                 return name + " folder";

             if (item is InventoryNotecard)
                 return name + ", a notecard";

             if (item is InventoryWearable)
                 return name + ", a " + WearableType(item as InventoryWearable);

             if (item is InventoryLandmark)
                 return name + ", a landmark";

             // TODO other types

             return name;
        }