internal static void SortStore() { // first check areaviewer for a selected Instance -> NWN2AreaViewer areaviewer; NWN2InstanceCollection collection; if ((areaviewer = NWN2ToolsetMainForm.App.GetActiveViewer() as NWN2AreaViewer) != null && (collection = areaviewer.SelectedInstances) != null && collection.Count == 1 && collection[0] is NWN2StoreTemplate) { var store = collection[0] as NWN2StoreInstance; var its = new NWN2InstanceStoreItemCollection(); // add items in the store of all types into 'its' int count = store.ArmorItems.Count; for (int i = 0; i != count; ++i) { its.Add(store.ArmorItems[i]); } store.ArmorItems.Clear(); count = store.WeaponItems.Count; for (int i = 0; i != count; ++i) { its.Add(store.WeaponItems[i]); } store.WeaponItems.Clear(); count = store.PotionItems.Count; for (int i = 0; i != count; ++i) { its.Add(store.PotionItems[i]); } store.PotionItems.Clear(); count = store.RingItems.Count; for (int i = 0; i != count; ++i) { its.Add(store.RingItems[i]); } store.RingItems.Clear(); count = store.MiscellaneousItems.Count; for (int i = 0; i != count; ++i) { its.Add(store.MiscellaneousItems[i]); } store.MiscellaneousItems.Clear(); // sort the items that are in 'its' to their store-panels per their BaseItems.2da "StorePanel" val TwoDAReference TwoDaRef; int id; for (int i = 0; i != its.Count; ++i) { id = its[i].Item.BaseItem.Row; TwoDaRef = new TwoDAReference("baseitems", "StorePanel", false, id); // NOTE: If row is invalid a blank string is returned. switch (TwoDaRef.ToString()) { // case "0": default: store.ArmorItems.Add(its[i]); break; case "1": store.WeaponItems.Add(its[i]); break; case "2": store.PotionItems.Add(its[i]); break; case "3": store.RingItems.Add(its[i]); break; case "4": store.MiscellaneousItems.Add(its[i]); break; } } var a = new INWN2Instance[] { store }; NWN2ToolsetMainForm.App.AreaContents.SelectInstances(a); // update store panels. // NOTE: Floating panels won't be updated. } else // second check blueprint tree for a selected Blueprint -> { object[] selection = NWN2ToolsetMainForm.App.BlueprintView.Selection; if (selection != null && selection.Length == 1 && (selection[0] as INWN2Template).ObjectType == NWN2ObjectType.Store) { var store = selection[0] as NWN2StoreBlueprint; var its = new NWN2BlueprintStoreItemCollection(); // add items in the store of all types into 'its' int count = store.ArmorItems.Count; for (int i = 0; i != count; ++i) { its.Add(store.ArmorItems[i]); } store.ArmorItems.Clear(); count = store.WeaponItems.Count; for (int i = 0; i != count; ++i) { its.Add(store.WeaponItems[i]); } store.WeaponItems.Clear(); count = store.PotionItems.Count; for (int i = 0; i != count; ++i) { its.Add(store.PotionItems[i]); } store.PotionItems.Clear(); count = store.RingItems.Count; for (int i = 0; i != count; ++i) { its.Add(store.RingItems[i]); } store.RingItems.Clear(); count = store.MiscellaneousItems.Count; for (int i = 0; i != count; ++i) { its.Add(store.MiscellaneousItems[i]); } store.MiscellaneousItems.Clear(); // sort the items that are in 'its' to their store-panels per their BaseItems.2da "StorePanel" val TwoDAReference TwoDaRef; int id; for (int i = 0; i != its.Count; ++i) { var it = new NWN2ItemInstance(its[i].Item); id = it.BaseItem.Row; TwoDaRef = new TwoDAReference("baseitems", "StorePanel", false, id); // NOTE: If row is invalid a blank string is returned. switch (TwoDaRef.ToString()) { // case "0": default: store.ArmorItems.Add(its[i]); break; case "1": store.WeaponItems.Add(its[i]); break; case "2": store.PotionItems.Add(its[i]); break; case "3": store.RingItems.Add(its[i]); break; case "4": store.MiscellaneousItems.Add(its[i]); break; } } string label = (selection[0] as INWN2Object).LocalizedName[BWLanguages.CurrentLanguage]; NWN2ToolsetMainForm.App.CreateNewPropertyPanel(selection, NWN2ToolsetMainForm.App.Module, false, label); // update store panels. // NOTE: Floating panels won't be updated. } } }
/// <summary> /// Turns an Item instance into a blueprint inventory item /// </summary> /// <param name="item">The iteminstance we want to turn into a Blueprint inventory Item</param> /// <param name="droppable">Whether the item should be dropable</param> /// <param name="pp">Whether the item should be pickpocketable</param> /// <returns>The blueprint inventory item</returns> private NWN2BlueprintInventoryItem createBlueprintItemInfo(NWN2ItemInstance item, bool droppable, bool pp) { var blueItem = NWN2ItemInstance.CreateBlueprintFromInstance(item, module.Repository, false); NWN2BlueprintInventoryItem itemInfo = new NWN2BlueprintInventoryItem(); itemInfo.Item = blueItem.Resource; itemInfo.Droppable = droppable; itemInfo.Pickpocketable = pp; itemInfo.InInventory = true; return itemInfo; }
// The following 2 methods comes from LazjensCPSInventoryManager /// <summary> /// Creates a instance inventroy item /// </summary> /// <param name="item">The instance item we want to make into an instance inventory item</param> /// <param name="droppable">Whether the item should be dropable</param> /// <param name="pp">Whether the item should be pickpocketable</param> /// <returns>The instance inventory item</returns> private static NWN2InstanceInventoryItem createInstanceItemInfo(NWN2ItemInstance item, bool droppable, bool pp) { NWN2InstanceInventoryItem itemInfo = new NWN2InstanceInventoryItem(); itemInfo.Item = item; itemInfo.Droppable = droppable; itemInfo.Pickpocketable = pp; itemInfo.InInventory = true; return itemInfo; }
private void Validate(NWN2ItemInstance item) { // Custom validation of only instances here. log.WriteLine("ERROR: Item \"{0}\" instanced. Use ACR_Spawn instead.", item.Tag); // Validation of all NWN2ItemTemplates (in areas, blueprints). Validate((NWN2ItemTemplate)item, item.Tag); }