From a092d1fe190b54a0a31be09e171324006ab8c4b2 Mon Sep 17 00:00:00 2001 From: Latif Khalifa Date: Sun, 18 Mar 2012 04:36:01 +0000 Subject: [PATCH] RAD-333: Follow inventory links when doing inventory operations git-svn-id: https://radegast.googlecode.com/svn/trunk@1211 f7a694da-4d33-11de-9ad6-1127a62b9fcd --- .../GUI/Consoles/Inventory/CurrentOutfitFolder.cs | 17 ++++++++++++++ .../GUI/Consoles/Inventory/InventoryConsole.cs | 26 +++++++++++++++++----- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/Radegast/GUI/Consoles/Inventory/CurrentOutfitFolder.cs b/Radegast/GUI/Consoles/Inventory/CurrentOutfitFolder.cs index 752513d..5ed27f0 100644 --- a/Radegast/GUI/Consoles/Inventory/CurrentOutfitFolder.cs +++ b/Radegast/GUI/Consoles/Inventory/CurrentOutfitFolder.cs @@ -396,6 +396,23 @@ namespace Radegast Client.Appearance.Detach(item); RemoveLink(item.UUID); } + + /// + /// Resolves inventory links and returns a real inventory item that + /// the link is pointing to + /// + /// + /// + public InventoryItem RealInventoryItem(InventoryItem item) + { + if (item.IsLink() && Client.Inventory.Store.Contains(item.AssetUUID) && Client.Inventory.Store[item.AssetUUID] is InventoryItem) + { + return (InventoryItem)Client.Inventory.Store[item.AssetUUID]; + } + + return item; + } + #endregion Public methods } } diff --git a/Radegast/GUI/Consoles/Inventory/InventoryConsole.cs b/Radegast/GUI/Consoles/Inventory/InventoryConsole.cs index ef452ef..2cefb3b 100644 --- a/Radegast/GUI/Consoles/Inventory/InventoryConsole.cs +++ b/Radegast/GUI/Consoles/Inventory/InventoryConsole.cs @@ -1230,6 +1230,7 @@ namespace Radegast if (item.IsLink()) { raw += " (link)"; + item = instance.COF.RealInventoryItem(item); if (Inventory.Contains(item.AssetUUID) && Inventory[item.AssetUUID] is InventoryItem) { item = (InventoryItem)Inventory[item.AssetUUID]; @@ -1281,7 +1282,7 @@ namespace Radegast invTree.SelectedNode = node; if (node.Tag is InventoryItem) { - UpdateItemInfo(node.Tag as InventoryItem); + UpdateItemInfo(instance.COF.RealInventoryItem(node.Tag as InventoryItem)); } else { @@ -1305,6 +1306,7 @@ namespace Radegast } else { + #region Folder context menu if (node.Tag is InventoryFolder) { InventoryFolder folder = (InventoryFolder)node.Tag; @@ -1403,7 +1405,10 @@ namespace Radegast ctxInv.Items.Add(ctxItem); ctxInv.Items.Add(new ToolStripSeparator()); + } + if (folder.PreferredType == AssetType.Unknown || folder.PreferredType == AssetType.OutfitFolder) + { ctxItem = new ToolStripMenuItem("Take off Items", null, OnInvContextClick); ctxItem.Name = "outfit_take_off"; ctxInv.Items.Add(ctxItem); @@ -1418,10 +1423,12 @@ namespace Radegast } instance.ContextActionManager.AddContributions(ctxInv, folder); + #endregion Folder context menu } else if (node.Tag is InventoryItem) { - InventoryItem item = (InventoryItem)node.Tag; + #region Item context menu + InventoryItem item = instance.COF.RealInventoryItem((InventoryItem)node.Tag); ctxInv.Items.Clear(); ToolStripMenuItem ctxItem; @@ -1608,7 +1615,7 @@ namespace Radegast } instance.ContextActionManager.AddContributions(ctxInv, item); - + #endregion Item context menu } } } @@ -1723,7 +1730,7 @@ namespace Radegast foreach (InventoryBase item in Inventory.GetContents(f)) { if (item is InventoryItem) - newOutfit.Add((InventoryItem)item); + newOutfit.Add(instance.COF.RealInventoryItem((InventoryItem)item)); } appearnceWasBusy = client.Appearance.ManagerBusy; client.Appearance.ReplaceOutfit(newOutfit); @@ -1736,7 +1743,7 @@ namespace Radegast foreach (InventoryBase item in Inventory.GetContents(f)) { if (item is InventoryItem) - addToOutfit.Add((InventoryItem)item); + addToOutfit.Add(instance.COF.RealInventoryItem((InventoryItem)item)); } appearnceWasBusy = client.Appearance.ManagerBusy; client.Appearance.AddToOutfit(addToOutfit); @@ -1748,7 +1755,7 @@ namespace Radegast foreach (InventoryBase item in Inventory.GetContents(f)) { if (item is InventoryItem) - removeFromOutfit.Add((InventoryItem)item); + removeFromOutfit.Add(instance.COF.RealInventoryItem((InventoryItem)item)); } appearnceWasBusy = client.Appearance.ManagerBusy; client.Appearance.RemoveFromOutfit(removeFromOutfit); @@ -1762,6 +1769,13 @@ namespace Radegast #region Item actions InventoryItem item = (InventoryItem)invTree.SelectedNode.Tag; + // Copy, cut, and delete works on links directly + // The rest operate on the item that is pointed by the link + if (cmd != "copy_item" && cmd != "cut_item" && cmd != "delete_item") + { + item = instance.COF.RealInventoryItem(item); + } + switch (cmd) { case "copy_item": -- 2.11.0