public static void GetAllContainersFromTreeItem(TreeItem treeItem, ObservableCollection <ContainerItem> items) { foreach (var node in treeItem.Children) { if (node.Type != ItemTypeEnum.ChildComputer && node.Type != ItemTypeEnum.ChildDevice) { var newContainer = new ContainerItem() { Id = node.Id, Name = node.Name, ParentId = node.ParentId, IsExpanded = node.IsExpanded, Type = node.Type, ParentType = node.ParentType, IsTrueContainer = node.Type != ItemTypeEnum.None }; if (node.Children.Count != 0) { GetAllContainersFromTreeItem(node, newContainer.Children); } items.Add(newContainer); } } }
private void sourceComboBox_SelectedIndexChanged(object sender, EventArgs e) { var lSelectedSourceItem = (ContainerItem)sourceComboBox.SelectedItem; if (lSelectedSourceItem == null) { return; } var lStreamNodes = lSelectedSourceItem.mXmlNode.SelectNodes("PresentationDescriptor/StreamDescriptor"); if (lStreamNodes == null) { return; } streamComboBox.Items.Clear(); foreach (var item in lStreamNodes) { var lNode = (XmlNode)item; if (lNode != null) { var lvalueNode = lNode.SelectSingleNode("@MajorType"); ContainerItem lSourceItem = new ContainerItem() { mFriendlyName = lvalueNode.Value.Replace("MFMediaType_", ""), mXmlNode = lNode }; streamComboBox.Items.Add(lSourceItem); } } }
// Initialization code protected override void Start() { base.Start(); // The player's inventory inventoryManager = GetComponentInChildren <InventoryManager> (); // The player manager needs to hold a reference to the PlayerController playerController = GetComponent <PlayerController> (); // Grabs the reference to the player animation animator = GetComponent <Animator> (); spriteRender = GetComponent <SpriteRenderer> (); currentArea = GameObject.Find("Entrance Room").GetComponent <Collider2D> (); tag = "Player"; recoveryTime = 1.5F; wallet = GetComponent <Wallet> (); keyRing = GetComponent <KeyRing> (); matchBox = GetComponent <MatchBox> (); bombBag = GetComponent <BombBag> (); quiver = GetComponent <Quiver> (); bombBag.enabled = false; quiver.enabled = false; matchBox.enabled = false; Health.InitializeContainer(6, 6); Wallet.InitializeContainer(999, 0); KeyRing.InitializeContainer(5, 5); _gameManager.GUIManager.AddHearts(Health.Capacity / 2); }
public void CheckTime(Player User, Room room, Item item, ContainerItem containerItem, frmGame mainForm) { mainForm.PlayerThinking("Time is " + DateTime.Now.Hour.ToString() + ":" + DateTime.Now.Minute.ToString()); }
// // CREATE ROOMS METHOD // public static void CreateRooms() { // // ROOM LIST // List <Room> roomList = new List <Room>(); // // ROOMS // Room room1 = new Room { Name = "Room 1", Image = GET_OUT.Properties.Resources.Room1, ThinkImage = GET_OUT.Properties.Resources.ThinkBubble, PlayerLocation = new int[] { 251, 298 }, ThinkingLocation = new Point(460, 84), ItemList = new List <Item>(), DoorList = new List <Door>(), CharacterList = new List <Character>() }; Room room2 = new Room { Name = "Room 2", Image = GET_OUT.Properties.Resources.Room2, ThinkImage = GET_OUT.Properties.Resources.ThinkBubbleRoom2, PlayerLocation = new int[] { 490, 330 }, ThinkingLocation = new Point(320, 54), ItemList = new List <Item>(), DoorList = new List <Door>(), CharacterList = new List <Character>() }; Room room3 = new Room { Name = "Room 3", Image = GET_OUT.Properties.Resources.Room3, ThinkImage = GET_OUT.Properties.Resources.ThinkBubbleRoom2, PlayerLocation = new int[] { 490, 330 }, ThinkingLocation = new Point(320, 54), ItemList = new List <Item>(), DoorList = new List <Door>(), CharacterList = new List <Character>() }; Room endPoint = new Room { Name = "End point", Image = GET_OUT.Properties.Resources.Room1, ThinkImage = GET_OUT.Properties.Resources.ThinkBubble, PlayerLocation = new int[] { 300, 330 }, ThinkingLocation = new Point(460, 84), ItemList = new List <Item>(), DoorList = new List <Door>(), CharacterList = new List <Character>() }; // // //------------------------------------------------------------------------------------------------ // // ITEMS // //------------------------------------------------------------------------------------------------ // // Item alarmClock = new Item( "Alarm clock", "Check time", "Perfectly fine working alarm", GET_OUT.Properties.Resources.AlarmClock, new int[] { 50, 60 }, true, false, null); Item burningAlarmClock = new Item( "Burning alarm clock", "Put out fire", "Cant tell the time when burning and broken", GET_OUT.Properties.Resources.BurningAlarmClock, new int[] { 50, 60 }, false, false, null); burningAlarmClock.TransformsTo = alarmClock; Item glassEmpty = new Item( "Empty glass", "Fill", "An empty glass. Ready to be filled and emptied again", GET_OUT.Properties.Resources.EmptyGlass, new int[] { 50, 60 }, true, false, null); Item glassFilledWater = new Item( "Water filled glass", "Empty", "Glass and water. Name a more iconic duo.", GET_OUT.Properties.Resources.FilledGlassWater, new int[] { 50, 60 }, true, false, null); glassEmpty.TransformsTo = glassFilledWater; glassFilledWater.TransformsTo = glassEmpty; burningAlarmClock.UsableItemPair = glassFilledWater; Item tape = new Item( "Tape", "Use", "My life is the only thing not repairable with this fantastic tape", GET_OUT.Properties.Resources.Tape, new int[] { 50, 60 }, true, false, null); Item apple = new Item( "Apple", "Eat", "This apple looks tasty", GET_OUT.Properties.Resources.Apple, new int[] { 50, 60 }, true, false, null); // // CONTAINER ITEMS // ContainerItem cabinet = new ContainerItem( "Cabinet", "Cabinet", "Just an ordinary cabinet", false, GET_OUT.Properties.Resources.CabinetOpen, new int[] { 380, 190 }, new List <ItemSlot> { new ItemSlot { Position = new int[] { 85, 75 }, SlottedItem = apple }, new ItemSlot { Position = new int[] { 145, 75 }, SlottedItem = apple }, new ItemSlot { Position = new int[] { 205, 75 }, SlottedItem = apple }, new ItemSlot { Position = new int[] { 265, 75 }, SlottedItem = apple }, new ItemSlot { Position = new int[] { 325, 75 }, SlottedItem = apple }, new ItemSlot { Position = new int[] { 85, 145 }, SlottedItem = apple }, new ItemSlot { Position = new int[] { 145, 145 }, SlottedItem = apple }, new ItemSlot { Position = new int[] { 205, 145 }, SlottedItem = apple }, new ItemSlot { Position = new int[] { 265, 145 }, SlottedItem = apple }, new ItemSlot { Position = new int[] { 325, 145 }, SlottedItem = apple }, }); ContainerItem fridge = new ContainerItem( "Frigde", "Fridge", "Cold things to eat", false, GET_OUT.Properties.Resources.FridgeOpen, new int[] { 300, 519 }, new List <ItemSlot> { new ItemSlot { Position = new int[] { 140, 250 }, SlottedItem = apple }, new ItemSlot { Position = new int[] { 200, 250 }, SlottedItem = apple }, new ItemSlot { Position = new int[] { 260, 250 }, SlottedItem = apple }, new ItemSlot { Position = new int[] { 140, 340 }, SlottedItem = apple }, new ItemSlot { Position = new int[] { 200, 340 }, SlottedItem = apple }, new ItemSlot { Position = new int[] { 260, 340 }, SlottedItem = apple }, new ItemSlot { Position = new int[] { 140, 430 }, SlottedItem = apple }, new ItemSlot { Position = new int[] { 200, 430 }, SlottedItem = apple }, new ItemSlot { Position = new int[] { 260, 430 }, SlottedItem = apple }, new ItemSlot { Position = new int[] { 140, 520 }, SlottedItem = apple }, new ItemSlot { Position = new int[] { 200, 520 }, SlottedItem = apple }, new ItemSlot { Position = new int[] { 260, 520 }, SlottedItem = apple } }); // // KEYS // Key mainKey = new Key( "Main key", "End point", "This is what i need to GET OUT", GET_OUT.Properties.Resources.MainKey); Key cabinetKey = new Key( "Cabinet key", "Cabinet", "Looks like it should unlock a cabinet of some sort", GET_OUT.Properties.Resources.CabinetKey); Key door2Key = new Key( "Door key", "Door 2", "Regular door key. Open doors.", GET_OUT.Properties.Resources.DoorKey); // // // room2.ItemList.Add(fridge); Briefcase = new ContainerItem( "Briefcase", null, "A very fine briefcase", false, GET_OUT.Properties.Resources.BriefcaseOpen, new int[] { 75, 115 }, new List <ItemSlot> { new ItemSlot { Position = new int[] { 80, 85 } }, new ItemSlot { Position = new int[] { 190, 85 } }, new ItemSlot { Position = new int[] { 80, 175 } }, new ItemSlot { Position = new int[] { 190, 175 } }, new ItemSlot { Position = new int[] { 80, 265 } }, new ItemSlot { Position = new int[] { 190, 265 } }, new ItemSlot { Position = new int[] { 330, 85 } }, new ItemSlot { Position = new int[] { 440, 85 } }, new ItemSlot { Position = new int[] { 330, 175 } }, new ItemSlot { Position = new int[] { 440, 175 } }, new ItemSlot { Position = new int[] { 330, 265 } }, new ItemSlot { Position = new int[] { 440, 265 } } }); // // //------------------------------------------------------------------------------------------------ // // CHARACTERS // //------------------------------------------------------------------------------------------------ // // // // ELOISE // // Character eloise = new Character { Name = "Eloise", Description = "There is something eerie with the look on her face", ImageBox = new PictureBox { Image = GET_OUT.Properties.Resources.Eloise, BackColor = Color.Transparent, Size = new Size(240, 471), Location = new Point(1356, 270), Visible = true }, ReactionPanel = new PictureBox { Image = GET_OUT.Properties.Resources.TalkBubble, BackColor = Color.Transparent, Size = new Size(300, 260), Location = new Point(1156, 12), Visible = true }, ReactionLabel = new Label { Size = new Size(280, 120), Location = new Point(1166, 24), BackColor = System.Drawing.Color.White, Font = new Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))), TextAlign = System.Drawing.ContentAlignment.MiddleCenter, Visible = true }, WantsItem = apple, SatisfactionItem = door2Key, ItemList = new List <Item>() }; // // RONNY // Character ronny = new Character { Name = "Ronny", Description = "That's one well shaped body, and what a handsome face.", WantsItem = apple, SatisfactionItem = mainKey, ItemList = new List <Item>(), CharacterItemSlot = new ItemSlot(), ImageBox = new PictureBox { Image = GET_OUT.Properties.Resources.Ronny, BackColor = Color.Transparent, Size = new Size(369, 700), Location = new Point(1022, 133), Visible = true }, ReactionPanel = new PictureBox { Image = GET_OUT.Properties.Resources.TalkBubbleRonny, BackColor = Color.Transparent, Size = new Size(300, 260), Location = new Point(1392, 3), Visible = true }, ReactionLabel = new Label { Size = new Size(280, 120), Location = new Point(1400, 15), BackColor = System.Drawing.Color.White, Font = new Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))), TextAlign = System.Drawing.ContentAlignment.MiddleCenter, Visible = true }, }; eloise.ItemList.Add(door2Key); room2.CharacterList.Add(eloise); // // //------------------------------------------------------------------------------------------------ // // ROOMS // //------------------------------------------------------------------------------------------------ // // //----------------------------------- // ROOM 1 //----------------------------------- // room1.ItemSlotList = new List <ItemSlot> { new ItemSlot { Position = new int[] { 1104, 611 }, SlottedItem = cabinet }, new ItemSlot { Position = new int[] { 820, 903 } }, new ItemSlot { Position = new int[] { 1020, 903 } }, new ItemSlot { Position = new int[] { 1220, 903 } } }; room1.DoorList = new List <Door> { new Door { FromRoom = room1, ToRoom = endPoint, Position = new int[] { 692, 296 }, Size = new int[] { 241, 473 }, IsLocked = true, ID = "End point" }, new Door { FromRoom = room1, ToRoom = room2, Position = new int[] { 1552, 288 }, Size = new int[] { 92, 541 }, IsLocked = false, ID = "Door 1" } }; // //----------------------------------- // ROOM 2 //----------------------------------- // room2.ItemSlotList = new List <ItemSlot> { new ItemSlot { Position = new int[] { 208, 210 }, SlottedItem = fridge }, new ItemSlot { Position = new int[] { 720, 470 }, SlottedItem = null }, new ItemSlot { Position = new int[] { 800, 470 }, SlottedItem = glassEmpty }, new ItemSlot { Position = new int[] { 1096, 470 }, SlottedItem = null }, new ItemSlot { Position = new int[] { 1176, 470 }, SlottedItem = null } }; /// /// DOOR LIST // room2.DoorList = new List <Door> { new Door { FromRoom = room2, ToRoom = room1, Position = new int[] { 98, 192 }, Size = new int[] { 82, 680 }, IsLocked = false, ID = null }, new Door { FromRoom = room2, ToRoom = room3, Position = new int[] { 1746, 197 }, Size = new int[] { 80, 680 }, IsLocked = true, ID = "Door 2" } }; // // //----------------------------------- // ROOM 3 //----------------------------------- // // room3.ItemSlotList = new List <ItemSlot> { new ItemSlot { Position = new int[] { 1462, 629 }, SlottedItem = burningAlarmClock }, new ItemSlot { Position = new int[] { 720, 750 } }, new ItemSlot { Position = new int[] { 800, 750 } }, new ItemSlot { Position = new int[] { 700, 850 } }, new ItemSlot { Position = new int[] { 770, 850 } } }; room3.DoorList = new List <Door> { new Door { FromRoom = room3, ToRoom = room2, Position = new int[] { 161, 226 }, Size = new int[] { 120, 738 }, IsLocked = false, ID = "Door 2" } }; ronny.CharacterItemSlot = room3.ItemSlotList.Find(itemSlot => itemSlot.SlottedItem == burningAlarmClock); ronny.ItemList.Add(mainKey); room3.CharacterList.Add(ronny); // // //----------------------------------- // END POINT //----------------------------------- // // endPoint.ItemSlotList = new List <ItemSlot>(); endPoint.DoorList = new List <Door>(); // // // roomList.Add(room1); roomList.Add(room2); roomList.Add(room3); roomList.Add(endPoint); StartingRoom = room1; //return StartingRoom; }
private void mediaTypeComboBox_SelectedIndexChanged(object sender, EventArgs e) { var lCurrentSubType = (string)streamComboBox.SelectedItem; var lCurrentSourceNode = mSelectedSourceXmlNode as XmlNode; if (lCurrentSourceNode == null) { return; } var lMediaTypesNode = lCurrentSourceNode.SelectNodes("PresentationDescriptor/StreamDescriptor/MediaTypes/MediaType[MediaTypeItem[@Name='MF_MT_SUBTYPE']/SingleValue[@Value='MFVideoFormat_" + lCurrentSubType + "']]"); if (lMediaTypesNode == null) { return; } var lStreamNode = lCurrentSourceNode.SelectSingleNode("PresentationDescriptor/StreamDescriptor"); if (lStreamNode == null) { return; } var lValueNode = lStreamNode.SelectSingleNode("@MajorTypeGUID"); string lXPath = "EncoderFactories/Group[@GUID='blank']/EncoderFactory"; lXPath = lXPath.Replace("blank", lValueNode.Value); string lxmldoc = ""; mCaptureManager.getCollectionOfEncoders(ref lxmldoc); System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); doc.LoadXml(lxmldoc); var lEncoderNodes = doc.SelectNodes(lXPath); encoderComboBox.Items.Clear(); foreach (var item in lEncoderNodes) { var lNode = (XmlNode)item; if (lNode != null) { var lvalueNode = lNode.SelectSingleNode("@Title"); ContainerItem lSourceItem = new ContainerItem() { mFriendlyName = lvalueNode.Value, mXmlNode = lNode }; encoderComboBox.Items.Add(lSourceItem); } } }
private int _MaxPropertyValue; // Max global property value #endregion #region Methods /// <summary> /// Constructs a new instance of UltimaLootAnalyzer. /// </summary> /// <param name="names">List of the mobile names to analyze.</param> public UltimaLootAnalyzer(ObservableCollection <UltimaPacket> packets, List <string> names) { _Names = names; _CorpseCount = 0; _HueCounter = new UltimaEnumPropertyCounter(); _GoldCounter = new UltimaSimpleCounter(); _InstrumentCounters = new List <UltimaSimpleCounter>(); _EquipmentCounters = new List <UltimaSimpleCounter>(); UltimaItemDefinitions itemDefinitions = Globals.Instance.ItemDefinitions; if (itemDefinitions == null) { throw new Exception("Item definitions not initialized"); } UltimaItemProperties propertyDefinitions = Globals.Instance.ItemProperties; if (propertyDefinitions == null) { throw new Exception("Item property definitions not initialized"); } // Initialize group UltimaItemDefinitionGroup goldGroup = null; UltimaItemDefinitionGroup instrumentsGroup = null; _Groups = new Dictionary <UltimaItemDefinitionGroup, UltimaSimpleCounter>(); _DefaultGroup = new UltimaDefaultLootGroup(); _PropertiesPerItem = new List <UltimaSimpleCounter>(); _Properties = new Dictionary <int, UltimaPropertyCounter>(); foreach (UltimaItemDefinitionGroup group in itemDefinitions.Groups) { if (group.Analyze) { _Groups.Add(group, new UltimaSimpleCounter()); } if (String.Equals(group.Name, "Gold", StringComparison.InvariantCultureIgnoreCase)) { goldGroup = group; } else if (String.Equals(group.Name, "Instruments", StringComparison.InvariantCultureIgnoreCase)) { instrumentsGroup = group; } } // Analyze packets Dictionary <uint, MobileIncommingPacket> mobiles = new Dictionary <uint, MobileIncommingPacket>(); Dictionary <uint, uint> mobilesToCorpses = new Dictionary <uint, uint>(); Dictionary <uint, ContainerContentPacket> corpsesToContainers = new Dictionary <uint, ContainerContentPacket>(); Dictionary <uint, QueryPropertiesResponsePacket> itemsToProperties = new Dictionary <uint, QueryPropertiesResponsePacket>(); foreach (UltimaPacket packet in packets) { if (packet is MobileIncommingPacket) { MobileIncommingPacket mobile = (MobileIncommingPacket)packet; if (!mobiles.ContainsKey(mobile.Serial)) { mobiles.Add(mobile.Serial, mobile); } } else if (packet is DeathAnimationPacket) { DeathAnimationPacket deathAnimation = (DeathAnimationPacket)packet; if (!mobilesToCorpses.ContainsKey(deathAnimation.Serial)) { mobilesToCorpses.Add(deathAnimation.Serial, deathAnimation.Corpse); } } else if (packet is ContainerContentPacket) { ContainerContentPacket containerContent = (ContainerContentPacket)packet; if (!corpsesToContainers.ContainsKey(containerContent.Serial)) { corpsesToContainers.Add(containerContent.Serial, containerContent); } } else if (packet is QueryPropertiesResponsePacket) { QueryPropertiesResponsePacket properties = (QueryPropertiesResponsePacket)packet; if (!itemsToProperties.ContainsKey(properties.Serial)) { itemsToProperties.Add(properties.Serial, properties); } } } Dictionary <ContainerContentPacket, List <ItemStatistics> > validCorpses = new Dictionary <ContainerContentPacket, List <ItemStatistics> >(); _MinPropertyCount = int.MaxValue; _MaxPropertyCount = int.MinValue; _MinPropertyValue = int.MaxValue; _MaxPropertyValue = int.MinValue; foreach (KeyValuePair <uint, uint> kvp in mobilesToCorpses) { MobileIncommingPacket mobile = null; ContainerContentPacket corpseContainer = null; ContainerContentPacket container = null; QueryPropertiesResponsePacket mobileProperties = null; if (!mobiles.TryGetValue(kvp.Key, out mobile)) { continue; } if (!itemsToProperties.TryGetValue(kvp.Key, out mobileProperties) || mobileProperties.Properties.Count == 0) { continue; } if (!corpsesToContainers.TryGetValue(kvp.Value, out corpseContainer)) { continue; } if (corpseContainer.Items.Count > 0) { ContainerItem corpse = corpseContainer.Items[0]; if (!corpsesToContainers.TryGetValue(corpse.Serial, out container)) { continue; } } else { continue; } string mobileName = GetMobileName(mobileProperties.Properties[0]); if (names.Contains(mobileName)) { // Analyze corpse StartAnalyzingCorpse(); List <ItemStatistics> validItems = new List <ItemStatistics>(); int equipmentCount = 0; int instrumentCount = 0; bool foundGold = false; _HueCounter.Gotcha(mobile.Hue); _CorpseCount += 1; Trace.WriteLine(""); Trace.WriteLine("Found corpse with " + container.Items.Count); foreach (ContainerItem item in container.Items) { QueryPropertiesResponsePacket properties = null; UltimaItemDefinition itemDefinition = null; UltimaArmorDefinition armorDefinition = null; bool analyzed = false; if (itemDefinitions.Items.ContainsKey(item.ItemID)) { itemDefinition = itemDefinitions.Items[item.ItemID]; armorDefinition = itemDefinition as UltimaArmorDefinition; } if (itemsToProperties.ContainsKey(item.Serial)) { properties = itemsToProperties[item.Serial]; } string name = GetItemName(properties.Properties[0]); // EA always generates gold last if (!foundGold) { if (itemDefinition != null) { UltimaItemDefinitionGroup group = itemDefinition.Parent; while (group.Parent != null) { group = group.Parent; } if (properties != null) { QueryPropertiesProperty nameProperty = properties.Properties[0]; // Treat stackable items as special if (!UltimaItemGenerator.IsStackable(nameProperty.Cliloc) && !UltimaItemGenerator.IsString(nameProperty.Cliloc) && !UltimaItemGenerator.IsSpecial(item.ItemID, nameProperty.Cliloc)) { if (_Groups.ContainsKey(group)) { _Groups[group].Gotcha(); analyzed = true; int propertiesPerItem = 0; int minPropertyValue = int.MaxValue; int maxPropertyValue = int.MinValue; bool isValidMinMax = false; bool hasSpecialDamage = false; foreach (QueryPropertiesProperty property in properties.Properties) { string propertyName = Globals.Instance.Clilocs.GetString(property.Cliloc); if (UltimaItemGenerator.IsDamage(property.Cliloc)) { if (property.Cliloc != 1060403) { if (!hasSpecialDamage) { propertiesPerItem += 1; } hasSpecialDamage = true; } } else if (propertyDefinitions.Properties.ContainsKey(property.Cliloc)) { UltimaItemProperty propertyDefinition = propertyDefinitions.Properties[property.Cliloc]; if (propertyDefinition.IsRunic) { UltimaClilocArgumentParser arguments = new UltimaClilocArgumentParser(property.Arguments); bool ignore = false; if (arguments.Length > 0) { int integer = 0; if (arguments.TryGetInteger(0, out integer)) { if (armorDefinition != null) { ignore = CheckIgnoreProperty(armorDefinition, propertyDefinition, ref integer); } if (!ignore) { GetPropertyCounter(property.Cliloc, 1).Gotcha(integer); if (propertyDefinition.Max > propertyDefinition.Min) { int percentage = (integer - propertyDefinition.Min) * 100 / (propertyDefinition.Max - propertyDefinition.Min); if (percentage > maxPropertyValue) { maxPropertyValue = percentage; } if (percentage > _MaxPropertyValue) { _MaxPropertyValue = percentage; } if (percentage < minPropertyValue) { minPropertyValue = percentage; } if (percentage < _MinPropertyValue) { _MinPropertyValue = percentage; } isValidMinMax = true; } } } else { GetPropertyCounter(property.Cliloc, 2).Gotcha(arguments[0]); } } else { GetPropertyCounter(property.Cliloc).Gotcha(null); } if (!ignore) { propertiesPerItem++; } } } } // Count number of properties UltimaSimpleCounter counter = null; while (propertiesPerItem >= _PropertiesPerItem.Count) { _PropertiesPerItem.Add(counter = new UltimaSimpleCounter()); } counter = _PropertiesPerItem[propertiesPerItem]; counter.StartAnalyzing(); counter.Gotcha(); counter.EndAnalyzing(); if (propertiesPerItem < _MinPropertyCount) { _MinPropertyCount = propertiesPerItem; } if (propertiesPerItem > _MaxPropertyCount) { _MaxPropertyCount = propertiesPerItem; } equipmentCount += 1; if (isValidMinMax) { validItems.Add(new ItemStatistics(item, propertiesPerItem, minPropertyValue, maxPropertyValue)); } else { validItems.Add(new ItemStatistics(item, propertiesPerItem)); } } } } } else { Trace.WriteLine("Cannot find item definition for:" + String.Format("0x{0:X}", item.ItemID) + "," + name); } // Check if special item if (itemDefinition != null && !analyzed) { UltimaItemDefinitionGroup group = itemDefinition.Parent; if (group == goldGroup) { _GoldCounter.Gotcha(item.Amount); analyzed = true; foundGold = true; } else if (group == instrumentsGroup) { analyzed = true; } } } if (!analyzed) { _DefaultGroup.AnalyzeItem(item.Serial, item.ItemID, item.Hue, item.Amount, properties); } } Trace.WriteLine(equipmentCount); // Count equipment UltimaSimpleCounter equipmentCounter = null; while (equipmentCount >= _EquipmentCounters.Count) { _EquipmentCounters.Add(equipmentCounter = new UltimaSimpleCounter()); } equipmentCounter = _EquipmentCounters[equipmentCount]; equipmentCounter.StartAnalyzing(); equipmentCounter.Gotcha(); equipmentCounter.EndAnalyzing(); // Count instruments UltimaSimpleCounter instrumentCounter = null; while (instrumentCount >= _InstrumentCounters.Count) { _InstrumentCounters.Add(instrumentCounter = new UltimaSimpleCounter()); } instrumentCounter = _InstrumentCounters[instrumentCount]; instrumentCounter.StartAnalyzing(); instrumentCounter.Gotcha(); instrumentCounter.EndAnalyzing(); if (validItems.Count > 0) { validCorpses.Add(container, validItems); } // Count corpses EndAnalyzingCorpse(); } } // Analyze items with max properties to determine property probabilities _MinPropertyCounts = new List <int>(); _MaxPropertyCounts = new List <int>(); _MinPropertyValues = new List <int>(); _MaxPropertyValues = new List <int>(); _ValidCorpseCount = 0; foreach (KeyValuePair <ContainerContentPacket, List <ItemStatistics> > kvp in validCorpses) { // Only ones with max items are valid if (kvp.Value.Count == _EquipmentCounters.Count - 1) { bool isValidMinMax = true; foreach (ItemStatistics item in kvp.Value) { if (!item.IsValidMinMax) { isValidMinMax = false; break; } } kvp.Value.Sort(SortByCount); if (_MinPropertyCounts.Count == 0) { foreach (ItemStatistics item in kvp.Value) { _MinPropertyCounts.Add(item.PropertyCount); } } else { for (int i = 0; i < kvp.Value.Count; i++) { int count = kvp.Value[i].PropertyCount; if (count < _MinPropertyCounts[i]) { _MinPropertyCounts[i] = count; } } } if (_MaxPropertyCounts.Count == 0) { foreach (ItemStatistics item in kvp.Value) { _MaxPropertyCounts.Add(item.PropertyCount); } } else { for (int i = 0; i < kvp.Value.Count; i++) { int count = kvp.Value[i].PropertyCount; if (count > _MaxPropertyCounts[i]) { _MaxPropertyCounts[i] = count; } } } if (isValidMinMax) { kvp.Value.Sort(SortByMin); if (_MinPropertyValues.Count == 0) { foreach (ItemStatistics item in kvp.Value) { _MinPropertyValues.Add(item.MinPropertyValue); } } else { for (int i = 0; i < kvp.Value.Count; i++) { int min = kvp.Value[i].MinPropertyValue; if (min < _MinPropertyValues[i]) { _MinPropertyValues[i] = min; } } } kvp.Value.Sort(SortByMax); if (_MaxPropertyValues.Count == 0) { foreach (ItemStatistics item in kvp.Value) { _MaxPropertyValues.Add(item.MaxPropertyValue); } } else { for (int i = 0; i < kvp.Value.Count; i++) { int max = kvp.Value[i].MaxPropertyValue; if (max > _MaxPropertyValues[i]) { _MaxPropertyValues[i] = max; } } } } _ValidCorpseCount += 1; } } }
public DomainItem(Func <RectangleF> area, IDomainFile item, IProject project, ContainerItem parent, Bitmap icon, Bitmap missingIcon, Func <Matrix> toControlTransform, Func <FileSystemObject, string, bool> rename) : base(area, item, project, parent, icon, missingIcon, f => f.Domains.Value, toControlTransform, rename) { }
private void RefreshContainerList() { Cursor = Cursors.WaitCursor; try { cmbContainers.Items.Clear(); ContainerItem defaultItem = new ContainerItem(null); cmbContainers.Items.Add(defaultItem); cmbContainers.Enabled = false; if ((long)txtStation.Tag != 0 && cmbDefaultReprocessor.SelectedValue != null) { CharCorp charcorp = (CharCorp)cmbDefaultReprocessor.SelectedValue; long station = (long)txtStation.Tag; AssetList containers = Assets.LoadReprocessableAssets(charcorp.ID, station, 1, true, false); if (containers.Count > 0 && cmbContainers.Items.Count == 1) { cmbContainers.Enabled = true; foreach (Asset container in containers) { cmbContainers.Items.Add(new ContainerItem(container)); } } } cmbContainers.SelectedItem = defaultItem; } catch (Exception ex) { new EMMAException(ExceptionSeverity.Error, "Problem refreshing available containers", ex); MessageBox.Show("Problem refreshing available containers.\r\nSee Logging/exceptionlog.txt" + " for details.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { Cursor = Cursors.Default; } }
protected LeafItem(Func <RectangleF> area, IProject project, ISaveableFile file, ContainerItem parent, ItemFilter filter, ISaveableFileProvider item, Func <Matrix> toControlTransform, Func <FileSystemObject, string, bool> rename) : base(new ConstructorParams(area, project, new FileSystemObject(file), parent, toControlTransform, rename)) { m_filter = filter; Item = item; }
public InventoryScreen(ClientWorldState clientWorldState, ContainerItem parentContainer, ContainerItem baseContainer) //(ClientWorldState clientWorldState) { this.ParentContainer = parentContainer; this.BaseContainer = baseContainer; world = clientWorldState; //this.GroundItems = world.GroundItemsInRange(world.PlayerCharacter.Id); //this.BaseContainer = (BagClientItem)world.PlayerCharacter.Inventory; }
public ContainerItemViewModel(ContainerItem containerItem) { ContainerItem = containerItem; _itemViewModel = new ItemDefinitionViewModel(ContainerItem.ItemDefinition); }
void On_Dblclick_Backpack(AControl control, int x, int y, MouseButton button) { ContainerItem backpack = ((Mobile)m_sourceEntity).Backpack; m_World.Interaction.DoubleClick(backpack); }
public static void ContainerOpenned(ContainerItem container) { onContainerOpened?.Invoke(container); }
private void SideMenu (ContainerItem item) { GenericMenu menu = new GenericMenu (); sideItem = _target.items.IndexOf (item); if (_target.items.Count > 0) { menu.AddItem (new GUIContent ("Delete"), false, Callback, "Delete"); } if (sideItem > 0 || sideItem < _target.items.Count-1) { menu.AddSeparator (""); } if (sideItem > 0) { menu.AddItem (new GUIContent ("Move up"), false, Callback, "Move up"); } if (sideItem < _target.items.Count-1) { menu.AddItem (new GUIContent ("Move down"), false, Callback, "Move down"); } menu.ShowAsContext (); }
private void encoderModeComboBox_SelectedIndexChanged(object sender, EventArgs e) { var lCurrentSourceNode = mSelectedSourceXmlNode as XmlNode; if (lCurrentSourceNode == null) { return; } var lStreamNode = lCurrentSourceNode.SelectSingleNode("PresentationDescriptor/StreamDescriptor"); if (lStreamNode == null) { return; } var lSelectedEncoderModeItem = (ContainerItem)encoderModeComboBox.SelectedItem; if (lSelectedEncoderModeItem == null) { return; } var lcompressedMediaTypeNodes = lSelectedEncoderModeItem.mXmlNode.SelectNodes("MediaTypes/MediaType"); compressedMediaTypeComboBox.Items.Clear(); foreach (var item in lcompressedMediaTypeNodes) { var lNode = (XmlNode)item; if (lNode != null) { var lvalueNode = lStreamNode.SelectSingleNode("@MajorType"); string mTitle = ""; if (lvalueNode != null && lvalueNode.Value == "MFMediaType_Video") { lvalueNode = lNode.SelectSingleNode("MediaTypeItem[@Name='MF_MT_FRAME_SIZE']/Value.ValueParts/ValuePart[1]/@Value"); mTitle = lvalueNode.Value; lvalueNode = lNode.SelectSingleNode("MediaTypeItem[@Name='MF_MT_FRAME_SIZE']/Value.ValueParts/ValuePart[2 ]/@Value"); mTitle += "x" + lvalueNode.Value; lvalueNode = lNode.SelectSingleNode("MediaTypeItem[@Name='MF_MT_FRAME_RATE']/RatioValue/@Value"); mTitle += ", " + lvalueNode.Value + " FPS, "; lvalueNode = lNode.SelectSingleNode("MediaTypeItem[@Name='MF_MT_SUBTYPE']/SingleValue/@Value"); mTitle += lvalueNode.Value.Replace("MFVideoFormat_", ""); } else if (lvalueNode != null && lvalueNode.Value == "MFMediaType_Audio") { lvalueNode = lNode.SelectSingleNode("MediaTypeItem[@Name='MF_MT_AUDIO_BITS_PER_SAMPLE']/SingleValue/@Value"); if (lvalueNode != null) { mTitle = lvalueNode.Value; } lvalueNode = lNode.SelectSingleNode("MediaTypeItem[@Name='MF_MT_AUDIO_NUM_CHANNELS']/SingleValue/@Value"); if (lvalueNode != null) { mTitle += "x" + lvalueNode.Value; } lvalueNode = lNode.SelectSingleNode("MediaTypeItem[@Name='MF_MT_AUDIO_SAMPLES_PER_SECOND']/SingleValue/@Value"); mTitle += ", "; lvalueNode = lNode.SelectSingleNode("MediaTypeItem[@Name='MF_MT_SUBTYPE']/SingleValue/@Value"); if (lvalueNode != null) { mTitle += lvalueNode.Value.Replace("MFVideoFormat_", ""); } } ContainerItem lSourceItem = new ContainerItem() { mFriendlyName = mTitle,// lvalueNode.Value.Replace("MFMediaType_", ""), mXmlNode = lNode }; compressedMediaTypeComboBox.Items.Add(lSourceItem); } } }
public override void OnInspectorGUI() { if (_target == null || inventoryManager == null) { OnEnable (); return; } if (!sideIcon) { sideIcon = (Texture2D) AssetDatabase.LoadAssetAtPath ("Assets/AdventureCreator/Graphics/Textures/inspector-use.png", typeof (Texture2D)); } EditorGUILayout.LabelField ("Stored Inventory items", EditorStyles.boldLabel); if (_target.items.Count > 0) { EditorGUILayout.BeginVertical ("Button"); for (int i=0; i<_target.items.Count; i++) { EditorGUILayout.BeginHorizontal (); EditorGUILayout.LabelField ("Item name:", GUILayout.Width (80f)); if (inventoryManager.CanCarryMultiple (_target.items[i].linkedID)) { EditorGUILayout.LabelField (inventoryManager.GetLabel (_target.items[i].linkedID), EditorStyles.boldLabel, GUILayout.Width (135f)); EditorGUILayout.LabelField ("Count:", GUILayout.Width (50f)); _target.items[i].count = EditorGUILayout.IntField (_target.items[i].count, GUILayout.Width (44f)); } else { EditorGUILayout.LabelField (inventoryManager.GetLabel (_target.items[i].linkedID), EditorStyles.boldLabel); _target.items[i].count = 1; } if (GUILayout.Button (sideIcon, GUILayout.Width (20f), GUILayout.Height (15f))) { SideMenu (_target.items[i]); } EditorGUILayout.EndHorizontal (); GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); } EditorGUILayout.EndVertical (); } else { EditorGUILayout.HelpBox ("This Container has no items", MessageType.Info); } EditorGUILayout.Space (); EditorGUILayout.BeginHorizontal (); EditorGUILayout.LabelField ("Item to create:", GUILayout.MaxWidth (130f)); itemNumber = EditorGUILayout.Popup (itemNumber, CreateItemList ()); if (GUILayout.Button ("Add new item")) { ContainerItem newItem = new ContainerItem (CreateItemID (itemNumber), _target.GetIDArray ()); _target.items.Add (newItem); } EditorGUILayout.EndHorizontal (); EditorGUILayout.Space (); if (GUI.changed) { EditorUtility.SetDirty (_target); } }
private void OpenContainer(ContainerItem container) { isContainerOpen = true; containerPanel.gameObject.SetActive(isContainerOpen); InstantiateContainerSlots(container); }
protected GraphItem(Func <RectangleF> area, T item, IProject project, ContainerItem parent, Bitmap icon, Bitmap missingIcon, ItemFilter filter, Func <Matrix> toControlTransform, Func <FileSystemObject, string, bool> rename) : base(area, item, icon, project, parent, filter, toControlTransform, rename) { m_icon = icon; m_missingIcon = missingIcon; }
private async Task fillSourceCmboBox() { if (mCaptureManager == null) { return; } System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); string lxmldoc = await mCaptureManager.getCollectionOfSourcesAsync(); if (string.IsNullOrEmpty(lxmldoc)) { return; } doc.LoadXml(lxmldoc); string lXPath = "//*["; if (toolStripMenuItem1.Checked) { lXPath += "Source.Attributes/Attribute[@Name='MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_CATEGORY']/SingleValue[@Value='CLSID_WebcamInterfaceDeviceCategory']"; } if (toolStripMenuItem2.Checked) { if (toolStripMenuItem1.Checked) { lXPath += "or "; } lXPath += "Source.Attributes/Attribute[@Name='MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_HW_SOURCE']/SingleValue[@Value='Software device']"; } if (dSCrossbarToolStripMenuItem.Checked) { if (toolStripMenuItem1.Checked || toolStripMenuItem2.Checked) { lXPath += "or "; } lXPath += "Source.Attributes/Attribute[@Name='MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_CATEGORY']/SingleValue[@Value='CLSID_VideoInputDeviceCategory']"; } lXPath += "]"; XmlNodeList lSourceNodes = null; try { lSourceNodes = doc.SelectNodes(lXPath); } catch (Exception) { } sourceComboBox.Items.Clear(); if (lSourceNodes == null) { return; } if (lSourceNodes != null) { foreach (var item in lSourceNodes) { var lNode = (XmlNode)item; if (lNode != null) { var lvalueNode = lNode.SelectSingleNode("Source.Attributes/Attribute[@Name='MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME']/SingleValue/@Value"); ContainerItem lSourceItem = new ContainerItem() { mFriendlyName = lvalueNode.Value, mXmlNode = lNode }; sourceComboBox.Items.Add(lSourceItem); } } } }
//This makes the instance InsertChildAlphabetically availble to ProjectItem protected static void InsertChildAlphabetically(ContainerItem parent, Item child) { parent.InsertChildAlphabetically(child); }
private void Register(Type typeInterface, Type typeImplementation, Guid?key = null, bool checkInheritance = true) { if (checkInheritance) { bool doesImplementInterface = typeImplementation.GetInterface(typeInterface.Name) == null; if (!typeInterface.IsInterface) { throw new InvalidOperationException("The first parameter to the method Register is not an interface"); } if (doesImplementInterface) { throw new InvalidOperationException("The second parameter does not implement interface:" + typeInterface.Name); } } if (typeImplementation.GetConstructors().Any(x => !x.GetParameters().Any())) // default constructor { #region Default Constructor ContainerItem containerItem = null; if (key.HasValue) { containerItem = new ContainerItem(key.Value, typeInterface, GetOrCreateLazyObjectOfType(typeImplementation, key)); } else { containerItem = new ContainerItem(typeInterface, GetOrCreateLazyObjectOfType(typeImplementation, key)); } _objects.Add(containerItem); #endregion } else // default constructor not found { #region Overloaded Constructor var constructor = typeImplementation.GetConstructors().FirstOrDefault(); if (constructor != null) { var parameters = constructor.GetParameters(); object[] parameterObjects = new object[parameters.Length]; for (int i = 0; i < parameters.Length; i++) { Type currentParameterType = parameters[i].ParameterType; parameterObjects[i] = GetOrCreateObjectOfType(currentParameterType, null); } ContainerItem containerItem = null; if (key.HasValue) { containerItem = new ContainerItem(key.Value, typeInterface, typeImplementation, parameterObjects); } else { containerItem = new ContainerItem(typeInterface, typeImplementation, parameterObjects); } _objects.Add(containerItem); } #endregion } }
public GumpPicContainer(AControl parent, int x, int y, int gumpID, int hue, ContainerItem containerItem) : base(parent, x, y, gumpID, hue) { m_containerItem = containerItem; }
public void OpenContainer(ContainerItem container) { currentContainerItem = container; isContainerOpen = true; UIEventHandler.ContainerOpenned(container); }
private void GenerateCommand_Executed(object sender, ExecutedRoutedEventArgs e) { if (_SaveFileDialog == null) { _SaveFileDialog = new SaveFileDialog(); _SaveFileDialog.Filter = "C# Source File (*.cs)|*.cs"; _SaveFileDialog.CheckPathExists = true; _SaveFileDialog.Title = "Save Class"; } if (_SaveFileDialog.ShowDialog() == true) { try { App.Window.ShowLoading(); if (e.Parameter is GenericGumpPacket) { GenericGumpPacket gump = (GenericGumpPacket)e.Parameter; using (FileStream stream = File.Open(_SaveFileDialog.FileName, FileMode.Create, FileAccess.Write, FileShare.None)) { UltimaGumpGenerator.Generate(stream, gump); } } else if (e.Parameter is WorldObjectPacket) { WorldObjectPacket item = (WorldObjectPacket)e.Parameter; QueryPropertiesResponsePacket properties = _SpyHelper.FindFirstPacket(item.Serial, typeof(QueryPropertiesResponsePacket)) as QueryPropertiesResponsePacket; using (FileStream stream = File.Open(_SaveFileDialog.FileName, FileMode.Create, FileAccess.Write, FileShare.None)) { UltimaItemGenerator.Generate(stream, item.ObjectID, item.Hue, item.Amount, properties); } } else if (e.Parameter is ContainerItem) { ContainerItem item = (ContainerItem)e.Parameter; QueryPropertiesResponsePacket properties = _SpyHelper.FindFirstPacket(item.Serial, typeof(QueryPropertiesResponsePacket)) as QueryPropertiesResponsePacket; using (FileStream stream = File.Open(_SaveFileDialog.FileName, FileMode.Create, FileAccess.Write, FileShare.None)) { UltimaItemGenerator.Generate(stream, item.ItemID, item.Hue, item.Amount, properties); } } else if (e.Parameter is MobileIncommingPacket) { MobileIncommingPacket mobile = (MobileIncommingPacket)e.Parameter; MobileNamePacket name = _SpyHelper.FindFirstPacket(mobile.Serial, typeof(MobileNamePacket)) as MobileNamePacket; using (FileStream stream = File.Open(_SaveFileDialog.FileName, FileMode.Create, FileAccess.Write, FileShare.None)) { UltimaMobileGenerator.Generate(stream, mobile, name); } } } catch (Exception ex) { ShowNotification(NotificationType.Error, ex); } finally { HideLoading(); } } }
public void CloseContainer() { isContainerOpen = false; this.currentContainerItem = null; }
private void SetFanArtType() { // Applies only to container Items NumItems = null; PlayableMediaItem playableMediaItem = SelectedItem as PlayableMediaItem; if (playableMediaItem != null) { MediaItem = playableMediaItem.MediaItem; SimpleTitle = playableMediaItem.SimpleTitle; } else { MediaItem = null; SimpleTitle = string.Empty; } SeriesFilterItem series = SelectedItem as SeriesFilterItem; if (series != null) { MediaItem = series.MediaItem; SimpleTitle = series.SimpleTitle; ItemDescription = series.StoryPlot; return; } SeasonFilterItem season = SelectedItem as SeasonFilterItem; if (season != null) { MediaItem = season.MediaItem; SimpleTitle = season.SimpleTitle; ItemDescription = season.StoryPlot; return; } EpisodeItem episode = SelectedItem as EpisodeItem; if (episode != null) { MediaItem = episode.MediaItem; SimpleTitle = episode.Series; ItemDescription = episode.StoryPlot; return; } MovieFilterItem movieCollection = SelectedItem as MovieFilterItem; if (movieCollection != null) { MediaItem = movieCollection.MediaItem; SimpleTitle = movieCollection.SimpleTitle; ItemDescription = null; return; } MovieItem movie = SelectedItem as MovieItem; if (movie != null) { MediaItem = movie.MediaItem; SimpleTitle = movie.SimpleTitle; ItemDescription = movie.StoryPlot; return; } VideoItem video = SelectedItem as VideoItem; if (video != null) { MediaItem = video.MediaItem; SimpleTitle = video.SimpleTitle; ItemDescription = video.StoryPlot; return; } AlbumFilterItem albumItem = SelectedItem as AlbumFilterItem; if (albumItem != null) { MediaItem = albumItem.MediaItem; SimpleTitle = albumItem.SimpleTitle; ItemDescription = albumItem.Description; return; } AudioItem audioItem = SelectedItem as AudioItem; if (audioItem != null) { MediaItem = audioItem.MediaItem; SimpleTitle = audioItem.SimpleTitle; ItemDescription = string.Empty; return; } ActorFilterItem actorItem = SelectedItem as ActorFilterItem; if (actorItem != null) { MediaItem = actorItem.MediaItem; SimpleTitle = actorItem.SimpleTitle; ItemDescription = actorItem.Description; return; } DirectorFilterItem directorItem = SelectedItem as DirectorFilterItem; if (directorItem != null) { MediaItem = directorItem.MediaItem; SimpleTitle = directorItem.SimpleTitle; ItemDescription = directorItem.Description; } WriterFilterItem writerItem = SelectedItem as WriterFilterItem; if (writerItem != null) { MediaItem = writerItem.MediaItem; SimpleTitle = writerItem.SimpleTitle; ItemDescription = writerItem.Description; } ArtistFilterItem artisitItem = SelectedItem as ArtistFilterItem; if (artisitItem != null) { MediaItem = artisitItem.MediaItem; SimpleTitle = artisitItem.SimpleTitle; ItemDescription = artisitItem.Description; } ComposerFilterItem composerItem = SelectedItem as ComposerFilterItem; if (composerItem != null) { MediaItem = composerItem.MediaItem; SimpleTitle = composerItem.SimpleTitle; ItemDescription = composerItem.Description; } CharacterFilterItem characterItem = SelectedItem as CharacterFilterItem; if (characterItem != null) { MediaItem = characterItem.MediaItem; SimpleTitle = characterItem.SimpleTitle; ItemDescription = string.Empty; } CompanyFilterItem companyItem = SelectedItem as CompanyFilterItem; if (companyItem != null) { MediaItem = companyItem.MediaItem; SimpleTitle = companyItem.SimpleTitle; ItemDescription = companyItem.Description; } TVNetworkFilterItem tvNetworkItem = SelectedItem as TVNetworkFilterItem; if (tvNetworkItem != null) { MediaItem = tvNetworkItem.MediaItem; SimpleTitle = tvNetworkItem.SimpleTitle; ItemDescription = tvNetworkItem.Description; } FilterItem filterItem = SelectedItem as FilterItem; if (filterItem != null) { MediaItem = filterItem.MediaItem; SimpleTitle = filterItem.SimpleTitle; ItemDescription = string.Empty; NumItems = filterItem.NumItems; return; } ContainerItem containerItem = SelectedItem as ContainerItem; if (containerItem != null) { // Morpheus 2017-04-27: setting the media item for containers lead to unintended layout in views // MediaItem = containerItem.FirstMediaItem; MediaItem = null; if (Guid.TryParse(containerItem.Id, out Guid dirId)) { MediaItem = new MediaItem(dirId); } SimpleTitle = containerItem.SimpleTitle; ItemDescription = string.Empty; NumItems = containerItem.NumItems; return; } FanArtMediaType = FanArtMediaTypes.Undefined; FanArtName = string.Empty; ItemDescription = string.Empty; }
public static void RunPatch(IPatcherState <ISkyrimMod, ISkyrimModGetter> state) { List <IngrCombination> combinations = new List <IngrCombination>(); IEnumerable <IIngredientGetter> ingredients = state.LoadOrder.PriorityOrder.OnlyEnabled().Ingredient().WinningOverrides(); ingredients = from ingrs in ingredients where !SkipPlugins.Contains(ingrs.FormKey.ModKey.Name.ToLower()) select ingrs; ingredients = from ingrs in ingredients where (!SkipIngrs.Intersect(ingrs.Name?.ToString()?.Split() !).Any() || SkipIngrs.Contains(ingrs.Name?.ToString())) select ingrs; ingredients = from ingrs in ingredients where !String.IsNullOrEmpty(ingrs.Name?.String) select ingrs; IEnumerator <IIngredientGetter> enumerator = ingredients.GetEnumerator(); int i = 0; int percent = (int)(ingredients.Count() * outputPercentage); while (enumerator.MoveNext()) { sw.Start(); if (i % percent == 0) { Console.WriteLine(i + " out of " + ingredients.Count() + " ingredients processed."); } List <IIngredientGetter> remainingingr = ingredients.Skip(i).ToList(); IIngredientGetter[] potionRecipeList = getIngredientsMatchingOneIngredient(enumerator.Current, remainingingr); if (String.IsNullOrEmpty(enumerator.Current.Name?.String)) { i++; continue; } foreach (IIngredientGetter ingr in potionRecipeList) { IEnumerable <IEffectGetter> ActiveEffects = ingr.Effects.Intersect(enumerator.Current.Effects).ToArray(); ActiveEffects = ActiveEffects.Distinct(); IEffectGetter[] ActiveEffectsA = ActiveEffects.ToArray(); if (ActiveEffectsA.Length < 1) { continue; } String potionString = "<font face='$HandwrittenFont'><font size='26'>"; potionString += "-<b>" + (enumerator.Current.Name + "<br><b>-<b>" + ingr.Name + "</b>"); List <String?> mgeflist = new List <String?>(); List <String?> mgeflists = new List <String?>(); foreach (IEffectGetter effect in ActiveEffectsA) { state.LinkCache.TryResolve <IMagicEffectGetter>(effect.BaseEffect.FormKey, out var mgeffect); mgeflist.Add(mgeffect?.Name?.String); mgeflists.AddRange(mgeffect?.Name?.String?.Split() !); } String prefix = "Potion"; int type = 0; if (!mgeflists.Intersect(potionWords.ToList()).Any() && mgeflists.Intersect(poisonWords.ToList()).Any()) { prefix = "Poison"; type = 1; if (mgeflist.Count() <= poisonSkipThreshold) { continue; } poisonRecipeCount++; } else if (mgeflists.Intersect(potionWords.ToList()).Any() && mgeflists.Intersect(poisonWords.ToList()).Any()) { prefix = "Impure Potion"; type = 2; if (mgeflist.Count() <= impureSkipThreshold) { continue; } impurepotionRecipeCount++; } else { if (mgeflist.Count() <= potionSkipThreshold) { continue; } potionRecipeCount++; } potionString += ("</font><font face='$HandwrittenFont'><font size='18'><br> to make " + prefix + " of "); String potionName = "Recipe: "; for (int k = 0; k < mgeflist.Count(); k++) { if (k > 0) { potionName += " and "; potionString += ("<br>"); } potionName += mgeflist[k]; potionString += (mgeflist[k]); } String sstring = ""; if (mgeflist.Count() > 1) { sstring = "s"; } potionString += ("<br></font><font size='14'> Contains " + mgeflist.Count() + " Effect" + sstring); potionString += "<\\font>"; IIngredientGetter[] ingrss = { enumerator.Current, ingr }; combinations.Add(new IngrCombination(potionName, ingrss, mgeflist?.ToArray() !, potionString, type)); } int j = i + 1; IEnumerator <IIngredientGetter> enumerator2 = remainingingr.GetEnumerator(); while (enumerator2.MoveNext()) { if (enumerator2.Current.Name?.Equals(enumerator.Current.Name) ?? true || String.IsNullOrEmpty(enumerator2.Current.Name?.String) || !enumerator.Current.Effects.Intersect(enumerator2.Current.Effects).Any()) { j++; continue; } List <IIngredientGetter> remainingingr2 = ingredients.Skip(j).ToList(); IIngredientGetter[] potionRecipeList2 = getIngredientsMatchingTwoIngredients(enumerator.Current, enumerator2.Current, remainingingr2); foreach (IIngredientGetter ingr in potionRecipeList2) { IEnumerable <IEffectGetter> ActiveEffects = ingr.Effects.Intersect(enumerator.Current.Effects); IEnumerable <IEffectGetter> ActiveEffects2 = ingr.Effects.Intersect(enumerator2.Current.Effects); IEnumerable <IEffectGetter> ActiveEffects3 = enumerator.Current.Effects.Intersect(enumerator2.Current.Effects); ActiveEffects.ToList().AddRange(ActiveEffects2); ActiveEffects.ToList().AddRange(ActiveEffects3); ActiveEffects = ActiveEffects.Distinct(); IEffectGetter[] ActiveEffectsA = ActiveEffects.ToArray(); if (ActiveEffectsA.Length < 1) { continue; } String potionString = "<font face='$HandwrittenFont'><font size='26'>"; potionString += "-<b>" + (enumerator.Current.Name + "<br></b>-<b>" + enumerator2.Current.Name + "<br></b>-<b>" + ingr.Name + "</b>"); List <String?> mgeflist = new List <String?>(); List <String?> mgeflists = new List <String?>(); foreach (IEffectGetter effect in ActiveEffects) { state.LinkCache.TryResolve <IMagicEffectGetter>(effect.BaseEffect.FormKey, out var mgeffect); mgeflist.Add(mgeffect?.Name?.String); mgeflists.AddRange(mgeffect?.Name?.String?.Split() !); } String prefix = "Potion"; int type = 0; if (!mgeflists.Intersect(potionWords.ToList()).Any() && mgeflists.Intersect(poisonWords.ToList()).Any()) { prefix = "Poison"; type = 1; if (mgeflist.Count() <= poisonSkipThreshold) { continue; } poisonRecipeCount++; } else if (mgeflist.Intersect(potionWords.ToList()).Any() && mgeflists.Intersect(poisonWords.ToList()).Any()) { prefix = "Impure Potion"; type = 2; if (mgeflists.Count() <= impureSkipThreshold) { continue; } impurepotionRecipeCount++; } else { if (mgeflist.Count() <= potionSkipThreshold) { continue; } potionRecipeCount++; } potionString += ("</font><font face='$HandwrittenFont'><font size='18'><br> to make " + prefix + " of: <br></font><font face='$HandwrittenFont'><font size='26'>"); String potionName = "Recipe: "; for (int k = 0; k < mgeflist.Count(); k++) { if (k > 0) { potionName += " and "; potionString += ("<br>"); } potionName += mgeflist[k]; potionString += (mgeflist[k]); } String sstring = ""; if (mgeflist.Count() > 1) { sstring = "s"; } potionString += ("<br></font><font size='14'> Contains " + mgeflist.Count() + " Effect" + sstring); potionString += "<\\font>"; IIngredientGetter[] ingrss = { enumerator.Current, enumerator2.Current, ingr }; combinations.Add(new IngrCombination(potionName, ingrss, mgeflist?.ToArray() !, potionString, type)); } j++; } i++; if (i % percent == 0) { sw.Stop(); Console.WriteLine("time elapsed: " + sw.Elapsed.TotalSeconds + " seconds"); sw.Reset(); } } Console.WriteLine("Creating Leveled lists..."); IEnumerable <IBookGetter> books = from book in state.LoadOrder.PriorityOrder.Book().WinningOverrides() where book.FormKey.Equals(new FormKey(new ModKey("Skyrim", ModType.Master), 0x0F5CB1)) select book; IBookGetter noteTemplate = books.ToList()[0]; Console.WriteLine("Creating " + combinations.Count() + " recipes."); percent = (int)(combinations.Count() * outputPercentage); i = 0; /* Main leveled list that gets added to recipe drop */ LeveledItem mainpotionRecipeLVLI = state.PatchMod.LeveledItems.AddNew(); LeveledItemEntry mainpotionRecipeLVLIentry = new LeveledItemEntry(); mainpotionRecipeLVLI.Entries = new Noggog.ExtendedList <LeveledItemEntry>(); LeveledItemEntryData mainpotionRecipeLVLIentrydata = new LeveledItemEntryData(); GlobalInt mainpotionGlobal = new GlobalInt(state.PatchMod.GetNextFormKey(), SkyrimRelease.SkyrimSE); mainpotionGlobal.Data = new Random().Next(minChance, maxChance); state.PatchMod.Globals.Set(mainpotionGlobal); mainpotionRecipeLVLI.Global = mainpotionGlobal; mainpotionRecipeLVLI.EditorID = "mainpotionRecipeList"; /* Must split sub leveled lists because it can only hold 128 items */ uint potionRecipeListCount = (potionRecipeCount / 128) + 1; uint poisonRecipeListCount = (poisonRecipeCount / 128) + 1; uint impurepotionRecipeListCount = (impurepotionRecipeCount / 128) + 1; LeveledItem[] potionRecipeLVLIs = new LeveledItem[potionRecipeListCount]; uint masterpotionRecipeListCount = ((potionRecipeListCount + poisonRecipeListCount + impurepotionRecipeListCount) / 128) + 1; LeveledItem[] masterpotionRecipeLVLIs = new LeveledItem[masterpotionRecipeListCount]; LeveledItemEntry[] masterpotionRecipeLVLIentries = new LeveledItemEntry[masterpotionRecipeListCount]; LeveledItemEntryData[] masterpotionRecipeLVLIentriesdata = new LeveledItemEntryData[masterpotionRecipeListCount]; GlobalInt[] masterpotionGlobals = new GlobalInt[masterpotionRecipeListCount]; LeveledItemEntry[] potionRecipeLVLIentries = new LeveledItemEntry[potionRecipeListCount]; LeveledItemEntryData[] potionRecipeLVLIentriesdata = new LeveledItemEntryData[potionRecipeListCount]; GlobalInt[] potionGlobals = new GlobalInt[potionRecipeListCount]; for (int k = 0; k < masterpotionRecipeListCount; k++) { masterpotionRecipeLVLIentries[k] = new LeveledItemEntry(); masterpotionRecipeLVLIentriesdata[k] = new LeveledItemEntryData(); masterpotionRecipeLVLIs[k] = state.PatchMod.LeveledItems.AddNew(); masterpotionRecipeLVLIs[k].Entries = new Noggog.ExtendedList <LeveledItemEntry>(); masterpotionGlobals[k] = new GlobalInt(state.PatchMod.GetNextFormKey(), SkyrimRelease.SkyrimSE); masterpotionGlobals[k].Data = new Random().Next(5, 25); state.PatchMod.Globals.Set(masterpotionGlobals[k]); masterpotionRecipeLVLIs[k].Global = masterpotionGlobals[k]; masterpotionRecipeLVLIs[k].EditorID = "masterpotionRecipeList" + k; masterpotionRecipeLVLIentriesdata[k].Reference = masterpotionRecipeLVLIs[k].FormKey; masterpotionRecipeLVLIentriesdata[k].Level = 1; masterpotionRecipeLVLIentriesdata[k].Count = 1; } for (int l = 0; l < potionRecipeListCount; l++) { potionRecipeLVLIentries[l] = new LeveledItemEntry(); potionRecipeLVLIentriesdata[l] = new LeveledItemEntryData(); potionRecipeLVLIs[l] = state.PatchMod.LeveledItems.AddNew(); potionRecipeLVLIs[l].Entries = new Noggog.ExtendedList <LeveledItemEntry>(); potionGlobals[l] = new GlobalInt(state.PatchMod.GetNextFormKey(), SkyrimRelease.SkyrimSE); potionGlobals[l].Data = new Random().Next(5, 25); state.PatchMod.Globals.Set(potionGlobals[l]); potionRecipeLVLIs[i].Global = potionGlobals[l]; potionRecipeLVLIs[l].EditorID = "potionRecipeList" + l; potionRecipeLVLIentriesdata[l].Reference = potionRecipeLVLIs[l].FormKey; potionRecipeLVLIentriesdata[l].Level = 1; potionRecipeLVLIentriesdata[l].Count = 1; } LeveledItem[] poisonRecipeLVLIs = new LeveledItem[poisonRecipeListCount]; LeveledItemEntry[] poisonRecipeLVLIentries = new LeveledItemEntry[poisonRecipeListCount]; LeveledItemEntryData[] poisonRecipeLVLIentriesdata = new LeveledItemEntryData[poisonRecipeListCount]; GlobalInt[] poisonGlobals = new GlobalInt[poisonRecipeListCount]; for (int l = 0; l < poisonRecipeListCount; l++) { poisonRecipeLVLIentries[l] = new LeveledItemEntry(); poisonRecipeLVLIentriesdata[l] = new LeveledItemEntryData(); poisonRecipeLVLIs[l] = state.PatchMod.LeveledItems.AddNew(); poisonRecipeLVLIs[l].Entries = new Noggog.ExtendedList <LeveledItemEntry>(); poisonGlobals[l] = new GlobalInt(state.PatchMod.GetNextFormKey(), SkyrimRelease.SkyrimSE); poisonGlobals[l].Data = new Random().Next(5, 25); state.PatchMod.Globals.Set(poisonGlobals[l]); poisonRecipeLVLIs[i].Global = poisonGlobals[l]; poisonRecipeLVLIs[l].EditorID = "poisonRecipeList" + l; poisonRecipeLVLIentriesdata[l].Reference = poisonRecipeLVLIs[l].FormKey; poisonRecipeLVLIentriesdata[l].Level = 1; poisonRecipeLVLIentriesdata[l].Count = 1; } LeveledItem[] impurepotionRecipeLVLIs = new LeveledItem[impurepotionRecipeListCount]; LeveledItemEntry[] impurepotionRecipeLVLIentries = new LeveledItemEntry[impurepotionRecipeListCount]; LeveledItemEntryData[] impurepotionRecipeLVLIentriesdata = new LeveledItemEntryData[impurepotionRecipeListCount]; GlobalInt[] impurepotionGlobals = new GlobalInt[impurepotionRecipeListCount]; for (int l = 0; l < impurepotionRecipeListCount; l++) { impurepotionRecipeLVLIentries[l] = new LeveledItemEntry(); impurepotionRecipeLVLIentriesdata[l] = new LeveledItemEntryData(); impurepotionRecipeLVLIs[l] = state.PatchMod.LeveledItems.AddNew(); impurepotionRecipeLVLIs[l].Entries = new Noggog.ExtendedList <LeveledItemEntry>(); impurepotionGlobals[l] = new GlobalInt(state.PatchMod.GetNextFormKey(), SkyrimRelease.SkyrimSE); impurepotionGlobals[l].Data = new Random().Next(5, 25); state.PatchMod.Globals.Set(impurepotionGlobals[l]); impurepotionRecipeLVLIs[i].Global = impurepotionGlobals[l]; impurepotionRecipeLVLIs[l].EditorID = "impurepotionRecipeList" + l; impurepotionRecipeLVLIentriesdata[l].Reference = impurepotionRecipeLVLIs[l].FormKey; impurepotionRecipeLVLIentriesdata[l].Level = 1; impurepotionRecipeLVLIentriesdata[l].Count = 1; } Console.WriteLine("Splitting potions into lists (" + potionRecipeListCount + " " + poisonRecipeListCount + " " + impurepotionRecipeListCount + ")"); uint potionIndex = 0, poisonIndex = 0, impurepotionIndex = 0; IEffectGetter[] effectCache = getAllEffects(ingredients).ToArray(); Dictionary <String, int> nameCache = new Dictionary <String, int>(); foreach (IngrCombination ic in combinations) { if (i % percent == 0) { Console.WriteLine(i + " out of " + combinations.Count() + " recipes created."); } IBook newRecipe = noteTemplate.DeepCopy(); newRecipe.FormKey = state.PatchMod.GetNextFormKey(); newRecipe.Description = ic.RecipeName; newRecipe.Name = ic.RecipeName; newRecipe.BookText = ic.PotionString; newRecipe.Weight = recipeWeight; String?name = "recipeof"; foreach (String?s in ic.MyEffects !) { name += s; } name = name.Replace(" ", String.Empty); int nameIndex = 0; if (nameCache.TryGetValue(name, out nameIndex)) { nameCache[name] = nameIndex + 1; name = name + nameCache[name]; } else { nameCache.Add(name, 0); name = name + "0"; } newRecipe.EditorID = name; state.PatchMod.Books.Set((Book)newRecipe); LeveledItemEntry lie = new LeveledItemEntry(); LeveledItemEntryData data = new LeveledItemEntryData(); data.Level = 1; data.Count = 1; data.Reference = new FormLink <IItemGetter>(newRecipe.FormKey); lie.Data = data; switch (ic.Type) { case 0: potionRecipeLVLIentriesdata[potionIndex / 128].Reference = potionRecipeLVLIs[potionIndex / 128].FormKey; potionRecipeLVLIentries[potionIndex / 128].Data = potionRecipeLVLIentriesdata[potionIndex / 128]; potionRecipeLVLIs[potionIndex / 128].Entries?.Add(lie); potionIndex++; break; case 1: poisonRecipeLVLIentriesdata[poisonIndex / 128].Reference = poisonRecipeLVLIs[poisonIndex / 128].FormKey; poisonRecipeLVLIentries[poisonIndex / 128].Data = poisonRecipeLVLIentriesdata[poisonIndex / 128]; poisonRecipeLVLIs[poisonIndex / 128].Entries?.Add(lie); poisonIndex++; break; case 2: impurepotionRecipeLVLIentriesdata[impurepotionIndex / 128].Reference = impurepotionRecipeLVLIs[impurepotionIndex / 128].FormKey; impurepotionRecipeLVLIentries[impurepotionIndex / 128].Data = impurepotionRecipeLVLIentriesdata[impurepotionIndex / 128]; impurepotionRecipeLVLIs[impurepotionIndex / 128].Entries?.Add(lie); impurepotionIndex++; break; } i++; } Console.WriteLine("Linking recipes to potion leveled list"); IEnumerable <ILeveledItemGetter> lvlilists = from list in state.LoadOrder.PriorityOrder.OnlyEnabled().LeveledItem().WinningOverrides() where list.EditorID?.Equals("LItemPotionAll") ?? true select list; ILeveledItemGetter allList = lvlilists.ToList()[0]; LeveledItem modifiedList = state.PatchMod.LeveledItems.GetOrAddAsOverride(allList); potionIndex = 0; poisonIndex = 0; impurepotionIndex = 0; for (int l = 0; l < masterpotionRecipeListCount; l++) { masterpotionRecipeLVLIentriesdata[l].Reference = masterpotionRecipeLVLIs[l].FormKey; masterpotionRecipeLVLIentries[l].Data = masterpotionRecipeLVLIentriesdata[l]; for (int k = 0; k < 128; k++) { if (potionIndex < potionRecipeLVLIentries.Count()) { masterpotionRecipeLVLIs[l].Entries?.Add(potionRecipeLVLIentries[potionIndex++]); } else if (poisonIndex < poisonRecipeLVLIentries.Count()) { masterpotionRecipeLVLIs[l].Entries?.Add(poisonRecipeLVLIentries[poisonIndex++]); } else if (impurepotionIndex < impurepotionRecipeLVLIentries.Count()) { masterpotionRecipeLVLIs[l].Entries?.Add(impurepotionRecipeLVLIentries[impurepotionIndex++]); } else { break; } } mainpotionRecipeLVLI.Entries?.Add(masterpotionRecipeLVLIentries[l]); } foreach (LeveledItem li in potionRecipeLVLIs) { state.PatchMod.LeveledItems.Set(li); } foreach (LeveledItem li in poisonRecipeLVLIs) { state.PatchMod.LeveledItems.Set(li); } foreach (LeveledItem li in impurepotionRecipeLVLIs) { state.PatchMod.LeveledItems.Set(li); } foreach (LeveledItem li in masterpotionRecipeLVLIs) { state.PatchMod.LeveledItems.Set(li); } mainpotionRecipeLVLIentrydata.Reference = mainpotionRecipeLVLI.FormKey; mainpotionRecipeLVLIentry.Data = mainpotionRecipeLVLIentrydata; mainpotionRecipeLVLIentrydata.Count = 1; mainpotionRecipeLVLIentrydata.Level = 1; modifiedList.Entries?.Add(mainpotionRecipeLVLIentry); state.PatchMod.LeveledItems.Set(mainpotionRecipeLVLI); Console.WriteLine("Adding recipes to defined containers"); IEnumerable <IContainerGetter> chests = from list in state.LoadOrder.PriorityOrder.OnlyEnabled().Container().WinningOverrides() where containerEditorIDs?.ToList().Contains(list.EditorID !) ?? true select list; ContainerEntry potionListContainerEntry = new ContainerEntry(); ContainerItem potionListContainerItem = new ContainerItem(); potionListContainerItem.Item = mainpotionRecipeLVLI.FormKey; potionListContainerItem.Count = 1; potionListContainerEntry.Item = potionListContainerItem; foreach (IContainerGetter chest in chests) { Container rChest = state.PatchMod.Containers.GetOrAddAsOverride(chest); rChest.Items?.Add(potionListContainerEntry); } }
public void Drink(Player User, Room room, Item item, ContainerItem containerItem, frmGame mainForm) { item.ItemSlot.SlottedItem = item.TransformsTo; }
public override void Update() { MouseOverItem = null; if (IsHoldingItem && _input.HandleMouseEvent(MouseEvent.Up, UltimaGameSettings.UserInterface.Mouse.InteractionButton)) { if (_world.Input.IsMouseOverUI) { // mouse over ui AControl target = _userInterface.MouseOverControl; // attempt to drop the item onto an interface. The only acceptable targets for dropping items are: // 1. ItemGumplings that... // a. ...represent containers (like a bag icon) // b. ...are of the same itemType and are generic, and can thus be merged. // c. ...are neither of the above; we attempt to drop the held item on top of the targeted item, if the targeted item is within a container. // 2. Gumps that represent open Containers (GumpPicContainers, e.g. an open GumpPic of a chest) // 3. Paperdolls for my character and equipment slots. // 4. Backpack gumppics (seen in paperdolls). if (target is ItemGumpling && !(target is ItemGumplingPaperdoll)) { var targetItem = ((ItemGumpling)target).Item; MouseOverItem = targetItem; if (targetItem.ItemData.IsContainer) // 1.a. { DropHeldItemToContainer((ContainerItem)targetItem); } else if (HeldItem.ItemID == targetItem.ItemID && HeldItem.ItemData.IsGeneric) // 1.b. { MergeHeldItem(targetItem); } else // 1.c. { if (targetItem.Parent != null && targetItem.Parent is ContainerItem) { DropHeldItemToContainer(targetItem.Parent as ContainerItem, target.X + (_input.MousePosition.x - target.ScreenX) - _heldItemOffset.X, target.Y + (_input.MousePosition.y - target.ScreenY) - _heldItemOffset.Y); } } } else if (target is GumpPicContainer) { ContainerItem targetItem = (ContainerItem)((GumpPicContainer)target).Item; MouseOverItem = targetItem; int x = (int)_input.MousePosition.x - _heldItemOffset.X - (target.X + target.Parent.X); int y = (int)_input.MousePosition.y - _heldItemOffset.Y - (target.Y + target.Parent.Y); DropHeldItemToContainer(targetItem, x, y); } else if (target is ItemGumplingPaperdoll || (target is GumpPic && ((GumpPic)target).IsPaperdoll) || (target is EquipmentSlot)) { if (HeldItem.ItemData.IsWearable) { WearHeldItem(); } } else if (target is GumpPicBackpack) { DropHeldItemToContainer((ContainerItem)((GumpPicBackpack)target).BackpackItem); } } else if (_world.Input.IsMouseOverWorld) { // mouse over world AEntity mouseOverEntity = _world.Input.MousePick.MouseOverObject; if (mouseOverEntity != null) { int x, y, z; if (mouseOverEntity is Mobile) { MergeHeldItem(mouseOverEntity); // if ((mouseOverEntity as Mobile).IsClientEntity) } else if (mouseOverEntity is Corpse) { MergeHeldItem(mouseOverEntity); } else if (mouseOverEntity is Item || mouseOverEntity is StaticItem) { x = (int)mouseOverEntity.Position.X; y = (int)mouseOverEntity.Position.Y; z = (int)mouseOverEntity.Z; if (mouseOverEntity is StaticItem) { z += ((StaticItem)mouseOverEntity).ItemData.Height; DropHeldItemToWorld(x, y, z); } else if (mouseOverEntity is Item) { var targetItem = mouseOverEntity as Item; MouseOverItem = targetItem; if (targetItem.ItemID == HeldItem.ItemID && HeldItem.ItemData.IsGeneric) { MergeHeldItem(targetItem); } else { z += ((Item)mouseOverEntity).ItemData.Height; DropHeldItemToWorld(x, y, z); } } } else if (mouseOverEntity is Ground) { x = (int)mouseOverEntity.Position.X; y = (int)mouseOverEntity.Position.Y; z = (int)mouseOverEntity.Z; DropHeldItemToWorld(x, y, z); } else { // over text? return; } } } } if (IsTargeting) { if (_input.HandleKeyboardEvent(KeyboardEvent.Press, WinKeys.Escape, false, false, false)) { SetTargeting(TargetType.Nothing, 0, 0); } if (_input.HandleMouseEvent(MouseEvent.Click, UltimaGameSettings.UserInterface.Mouse.InteractionButton)) { // If isTargeting is true, then the target cursor is active and we are waiting for the player to target something. switch (_targeting) { case TargetType.Object: case TargetType.Position: if (_world.Input.IsMouseOverUI) { // get object under mouse cursor. var target = _userInterface.MouseOverControl; if (target is ItemGumpling) { // ItemGumping is the base class for all items, containers, and paperdoll items. mouseTargetingEventObject(((ItemGumpling)target).Item); } else if (target.RootParent is MobileHealthTrackerGump) { // this is a mobile's mini-status gump (health bar, etc.) We can target it to cast spells on that mobile. mouseTargetingEventObject(((MobileHealthTrackerGump)target.RootParent).Mobile); } } else if (_world.Input.IsMouseOverWorld) { // Send Select Object or Select XYZ packet, depending on the entity under the mouse cursor. _world.Input.MousePick.PickOnly = PickType.PickStatics | PickType.PickObjects; mouseTargetingEventObject(_world.Input.MousePick.MouseOverObject); } break; case TargetType.MultiPlacement: // select X, Y, Z mouseTargetingEventXYZ(_world.Input.MousePick.MouseOverObject); break; default: throw new Exception("Unknown targetting type!"); } } } if (MouseOverItem == null && _world.Input.MousePick.MouseOverObject is Item) { var item = _world.Input.MousePick.MouseOverObject as Item; if (item is StaticItem || item.ItemData.Weight == 255) { return; } MouseOverItem = _world.Input.MousePick.MouseOverObject as Item; } }
private async void encoderComboBox_SelectedIndexChanged(object sender, EventArgs e) { do { if (mEncoderControl == null) { break; } var lSelectedEncoderItem = (ContainerItem)encoderComboBox.SelectedItem; if (lSelectedEncoderItem == null) { return; } var lselectedNode = lSelectedEncoderItem.mXmlNode; if (lselectedNode == null) { break; } var lEncoderNameAttr = lselectedNode.Attributes["Title"]; if (lEncoderNameAttr == null) { break; } var lCLSIDEncoderAttr = lselectedNode.Attributes["CLSID"]; if (lCLSIDEncoderAttr == null) { break; } Guid lCLSIDEncoder; if (!Guid.TryParse(lCLSIDEncoderAttr.Value, out lCLSIDEncoder)) { break; } var lSelectedSourceItem = (ContainerItem)sourceComboBox.SelectedItem; if (lSelectedSourceItem == null) { return; } var lSourceNode = lSelectedSourceItem.mXmlNode; if (lSourceNode == null) { return; } var lNode = lSourceNode.SelectSingleNode( "Source.Attributes/Attribute" + "[@Name='MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK' or @Name='MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_AUDCAP_SYMBOLIC_LINK']" + "/SingleValue/@Value"); if (lNode == null) { return; } string lSymbolicLink = lNode.Value; uint lStreamIndex = 0; var lSelectedMediaTypeItem = (ContainerItem)mediaTypeComboBox.SelectedItem; if (lSelectedMediaTypeItem == null) { return; } lSourceNode = lSelectedMediaTypeItem.mXmlNode; if (lSourceNode == null) { return; } lNode = lSourceNode.SelectSingleNode("@Index"); if (lNode == null) { return; } uint lMediaTypeIndex = 0; if (!uint.TryParse(lNode.Value, out lMediaTypeIndex)) { return; } if (mSourceControl == null) { return; } object lOutputMediaType = await mSourceControl.getSourceOutputMediaTypeAsync( lSymbolicLink, lStreamIndex, lMediaTypeIndex); string lMediaTypeCollection = await mEncoderControl.getMediaTypeCollectionOfEncoderAsync( lOutputMediaType, lCLSIDEncoder); XmlDocument lEncoderModedoc = new XmlDocument(); lEncoderModedoc.LoadXml(lMediaTypeCollection); var lEncoderNodes = lEncoderModedoc.SelectNodes("EncoderMediaTypes/Group"); encoderModeComboBox.Items.Clear(); foreach (var item in lEncoderNodes) { lNode = (XmlNode)item; if (lNode != null) { var lvalueNode = lNode.SelectSingleNode("@Title"); ContainerItem lSourceItem = new ContainerItem() { mFriendlyName = lvalueNode.Value, mXmlNode = lNode }; encoderModeComboBox.Items.Add(lSourceItem); } } } while (false); }
public ContainerItem(ContainerItem containerItem) { linkedID = containerItem.linkedID; count = containerItem.count; id = containerItem.id; }
protected override async void OnLoad(EventArgs e) { base.OnLoad(e); try { mCaptureManager = new CaptureManager("CaptureManager.dll"); } catch (System.Exception) { try { mCaptureManager = new CaptureManager(); } catch (System.Exception) { } } if (mCaptureManager == null) { return; } mSourceControl = await mCaptureManager.createSourceControlAsync(); mISessionControl = await mCaptureManager.createSessionControlAsync(); mSinkControl = await mCaptureManager.createSinkControlAsync(); mEncoderControl = await mCaptureManager.createEncoderControlAsync(); System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); string lxmldoc = await mCaptureManager.getCollectionOfSourcesAsync(); if (string.IsNullOrEmpty(lxmldoc)) { return; } doc.LoadXml(lxmldoc); var lSourceNodes = doc.DocumentElement.ChildNodes;// .SelectNodes("//*[Source.Attributes/Attribute[@Name='MF_DEVSOURCE_ATTRIBUTE_MEDIA_TYPE']/Value.ValueParts/ValuePart[@Value='MFMediaType_Video']]"); if (lSourceNodes != null) { foreach (var item in lSourceNodes) { var lNode = (XmlNode)item; if (lNode != null) { var lvalueNode = lNode.SelectSingleNode("Source.Attributes/Attribute[@Name='MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME']/SingleValue/@Value"); ContainerItem lSourceItem = new ContainerItem() { mFriendlyName = lvalueNode.Value, mXmlNode = lNode }; sourceComboBox.Items.Add(lSourceItem); } } } }
private void bwParseItemSource_DoWork(object sender, DoWorkEventArgs e) { string hdoc = e.Argument as string; int id = _lastItemId; string itemId = "0"; try { // First lets make sure it downloaded properly and pull the Item Id out of it. If not, stop working Regex idFinder = new Regex("wowhead.com.item=(\\d+)\""); Match match; if ((match = idFinder.Match(hdoc)).Success) { id = int.Parse(match.Groups[1].Value); } else { return; } // It didn't load right Item item = ItemCache.Instance.Items[id]; itemId = item.Id.ToString(); //bool LocInfoIsValid = item.LocationInfo != null && item.LocationInfo.Count > 0; if (/*LocInfoIsValid &&*/ item.LocationInfo[0] is VendorItem) { List<string> tokenIds = new List<string> { }; List<int> tokenCounts = new List<int> { }; string tokenName = "Unknown Currency"; //TokenDropInfo tokenDropInfo = null; int goldCost = 0; string repSource = "", repLevel = ""; #region Try to get the Token Names and individual costs int liststartpos = hdoc.IndexOf("new Listview({template: 'npc', id: 'sold-by'"); if (liststartpos > 1) { int listendpos = hdoc.IndexOf(";", liststartpos); string costExcerpt = hdoc.Substring(liststartpos, listendpos - liststartpos); // we are looking for something like cost:[0,0,0,[[40633,1]]] // cost:[gold,[[currencyId1,currencyQu1],[currencyId2,currencyQu2]],[objectId,objectQu]] Regex costRegex = new Regex(@"cost:\[(?<gold>\d+)\[(?:\[(?<currencyId1>\d+),(?<currencyQu1>\d+)\])?,?(?:\[(?<currencyId2>\d+),(?<currencyQu2>\d+)\])?\],\[(?:\[?(?<tokenId1>\d+),(?<tokenQu1>\d+)\]?)?,?(?:\[?(?<tokenId2>\d+),(?<tokenQu2>\d+)\]?)?\]\]"); Regex costRegexGoldOnly = new Regex(@"cost:\[(?<gold>\d+)\]"); Match costMatch; if ((costMatch = costRegex.Match(costExcerpt)).Success) { // Yay! it worked! // Start with Gold Cost. Items that don't cost Gold will still get a default of 0 goldCost = int.Parse(costMatch.Groups["gold"].Value); // Lets try Currency 1, such as Justice Points if (!String.IsNullOrEmpty(costMatch.Groups["currencyId1"].Value)) { tokenIds.Add(costMatch.Groups["currencyId1"].Value); tokenCounts.Add(int.Parse(costMatch.Groups["currencyQu1"].Value)); } // Lets try Currency 2, such as Justice Points // Not sure if there would ever actually be a 2nd here, but it was formatted as if it was possible // If nothing else, when currencyId1 fails but 2 is valid we put something in the array if (!String.IsNullOrEmpty(costMatch.Groups["currencyId2"].Value)) { tokenIds.Add(costMatch.Groups["currencyId2"].Value); tokenCounts.Add(int.Parse(costMatch.Groups["currencyQu2"].Value)); } // Lets try Token 1 cost, such as Mantle of the Conqueror if (!String.IsNullOrEmpty(costMatch.Groups["tokenId1"].Value)) { tokenIds.Add(costMatch.Groups["tokenId1"].Value); tokenCounts.Add(int.Parse(costMatch.Groups["tokenQu1"].Value)); } // Lets try Token 2 cost, such as Mantle of the Conqueror if (!String.IsNullOrEmpty(costMatch.Groups["tokenId2"].Value)) { tokenIds.Add(costMatch.Groups["tokenId2"].Value); tokenCounts.Add(int.Parse(costMatch.Groups["tokenQu2"].Value)); } } else if ((costMatch = costRegex.Match(costExcerpt)).Success) { // Yay! it worked! // Just do Gold Cost. Items that don't cost Gold will still get a default of 0 goldCost = int.Parse(costMatch.Groups["gold"].Value); } } #endregion #region Check to see if it requires a specific Faction and get its required level liststartpos = hdoc.IndexOf("Requires <a href=\"/faction="); if (liststartpos > 1) { int listendpos = hdoc.IndexOf("</td>", liststartpos); string repExcerpt = hdoc.Substring(liststartpos, listendpos - liststartpos); // we are looking for something like cost:[0,0,0,[[40633,1]]] // cost:[gold,[[currencyId1,currencyQu1],[currencyId2,currencyQu2]],[objectId,objectQu]] Regex repRegex = new Regex(@"Requires .a href=.\/faction=(?<factionId>\d+). class=.q\d.>.+\/a. - (?<level>(?:Friendly|Honored|Revered|Exalted))"); Match repMatch; if ((repMatch = repRegex.Match(repExcerpt)).Success) { // Yay! it worked! // Lets get the Faction's name based on the ID repSource = GetItemFactionVendorInfo(repMatch.Groups["factionId"].Value, "0")[0]; switch (repMatch.Groups["level"].Value) { case "Friendly":{ repLevel = "4"; break; } case "Honored": { repLevel = "5"; break; } case "Revered": { repLevel = "6"; break; } case "Exalted": { repLevel = "7"; break; } default: { repLevel = "0"; break; } } } } #endregion VendorItem vendorItem = item.LocationInfo[0] as VendorItem; vendorItem.Cost = goldCost; for (int i = 0; i < 3; i++) { if (tokenIds.Count < i + 1) { break; } // stop processing if we don't have any more // Check to see if it's a PvP token/Currency if (!String.IsNullOrEmpty(tokenIds[i]) && _pvpTokenMap.TryGetValue(tokenIds[i], out tokenName)) { if (tokenName == "Honor Points" || tokenIds[i] == "392") item.LocationInfo = new ItemLocationList() { new PvpItem() { Points = tokenCounts[i], PointType = "Honor" } }; else if (tokenName == "Conquest Points" || tokenIds[i] == "390") item.LocationInfo = new ItemLocationList() { new PvpItem() { Points = tokenCounts[i], PointType = "Conquest" } }; else item.LocationInfo = new ItemLocationList() { new PvpItem() { TokenCount = tokenCounts[i], TokenType = tokenName } }; vendorItem = null; // invalidate the vendor item so it doesn't get added in later break; } else if (tokenIds[i] != null && _vendorTokenMap.TryGetValue(tokenIds[i], out tokenName)) { vendorItem.TokenMap[tokenName] = tokenCounts[i]; } else if (tokenIds[i] != null) { if ((tokenName == "Justice Points" || tokenIds[i] == "395") || (tokenName == "Valor Points" || tokenIds[i] == "396")) { item.Cost = tokenCounts[i]; } // Sets the cost on the item for the user #region It's a PvE Token // ok now let's see what info we can get about this token string boss = null; string vendor = null; string area = null; string vendorarea = null; bool heroic = false; bool lfr = false; bool container = false; if (!_tokenDropMap.ContainsKey(tokenIds[i])) { // Not doing this =^( hopefully we won't actually need to cuz I mapped all the currencies listed in wowhead #region We *really* haven't seen this before so we need to pull the data /*XDocument docToken = wrw.DownloadItemWowhead(site, tokenIds[i]); if (docToken != null) { tokenNames[i] = docToken.SelectSingleNode("wowhead/item/name").Value; // we don't want token => boss propagation anymore, otherwise you get weird stuff like 277 gloves dropping from Toravon /*string tokenJson = docToken.SelectSingleNode("wowhead/item/json").InnerText; string tokenSource = string.Empty; if (tokenJson.Contains("\"source\":[")) { tokenSource = tokenJson.Substring(tokenJson.IndexOf("\"source\":[") + "\"source\":[".Length); tokenSource = tokenSource.Substring(0, tokenSource.IndexOf("]")); } string tokenSourcemore = string.Empty; if (tokenJson.Contains("\"sourcemore\":[{")) { tokenSourcemore = tokenJson.Substring(tokenJson.IndexOf("\"sourcemore\":[{") + "\"sourcemore\":[{".Length); tokenSourcemore = tokenSourcemore.Substring(0, tokenSourcemore.IndexOf("}]")); } if (!string.IsNullOrEmpty(tokenSource) && !string.IsNullOrEmpty(tokenSourcemore)) { string[] tokenSourceKeys = tokenSource.Split(','); string[] tokenSourcemoreKeys = tokenSourcemore.Split(new string[] { "},{" }, StringSplitOptions.RemoveEmptyEntries); // for tokens we prefer loot info, we don't care if it can be bought with badges tokenSource = tokenSourceKeys[0]; tokenSourcemore = tokenSourcemoreKeys[0]; int dropIndex = Array.IndexOf(tokenSourceKeys, "2"); if (dropIndex >= 0) { tokenSource = tokenSourceKeys[dropIndex]; tokenSourcemore = tokenSourcemoreKeys[dropIndex]; } if (tokenSource == "2") { foreach (string kv in tokenSourcemore.Split(',')) { if (!string.IsNullOrEmpty(kv)) { string[] keyvalsplit = kv.Split(':'); string key = keyvalsplit[0]; string val = keyvalsplit[1]; switch (key.Trim('"')) { case "t": container = val == "2" || val == "3"; break; case "n": // NPC 'Name' boss = val.Replace("\\'", "'").Trim('"'); break; case "z": // Zone area = GetZoneName(val); break; case "dd": // Dungeon Difficulty (1 = Normal, 2 = Heroic) heroic = val == "2"; break; } } } } } if (boss == null) { //boss = "Unknown Boss (Wowhead lacks data)"; area = null; // if boss is null prefer treating this as pve token }*/ /* if (tokenNames[i] != null) { _tokenDropMap[tokenIds[i]] = new TokenDropInfo() { Boss = boss, Area = area, Heroic = heroic, Name = tokenNames[i], Container = container }; } }*/ #endregion } else { #region We've seen this before so just use that data TokenDropInfo info = _tokenDropMap[tokenIds[i]]; boss = info.Boss; vendor = info.Vendor; area = info.Area; vendorarea = info.VendorArea; heroic = info.Heroic; lfr = info.LFR; tokenName = info.Name; container = info.Container; #endregion } if (tokenName != null) { #region This is NOT a Dropped Token, so treat it as a normal vendor item and include token info vendorItem.TokenMap[tokenName] = tokenCounts[i]; if (!String.IsNullOrEmpty(area) && !String.IsNullOrEmpty(vendorarea) && area != vendorarea && vendorarea != "Unknown Area") { // We are lucky enough to have BOTH drop points, so lets set both up vendorItem.VendorArea = vendorarea; vendorItem.VendorName = vendor; vendorItem.TokenMap[tokenName] = tokenCounts[i]; ItemLocation droppoint = new StaticDrop() { Area = area, Boss = boss, Heroic = heroic, LFR = lfr }; item.LocationInfo = new ItemLocationList() { vendorItem, droppoint }; vendorItem = null; break; } else { vendorItem.VendorArea = area; vendorItem.VendorName = boss; } #endregion } else if (area != null) { #region This is a Dropped Token or we know what vendor is dropping it, so assign it to where it drops from if (container) { ItemLocation locInfo = new ContainerItem() { Area = area, Container = boss, Heroic = heroic, LFR = lfr, }; item.LocationInfo = new ItemLocationList() { locInfo }; vendorItem = null; break; } else { ItemLocation locInfo = new StaticDrop() { Area = area, Boss = boss, Heroic = heroic, LFR = lfr, }; item.LocationInfo = new ItemLocationList() { locInfo }; vendorItem = null; break; } #endregion } else /*if (tokenNames[i] == null)*/ { // there was an error pulling token data from web // ignore source information vendorItem = null; break; } #endregion } else { #region There is no token so this is a normal vendor item if (!String.IsNullOrEmpty(repSource) && !String.IsNullOrEmpty(repLevel)) { string[] repInfo = GetItemFactionVendorInfo(repSource, repLevel); FactionItem locInfo = new FactionItem() { FactionName = repInfo[0], Level = (ReputationLevel)int.Parse(repLevel), // repInfo[3] Cost = goldCost, }; item.LocationInfo = new ItemLocationList() { locInfo }; vendorItem = null; break; }/* else { VendorItem locInfo = new VendorItem() { Cost = goldCost, }; if (!string.IsNullOrEmpty(n)) locInfo.VendorName = n; if (sourcemore != null && sourcemore.TryGetValue("z", out tmp)) { locInfo.VendorArea = GetZoneName(tmp.ToString()); } item.LocationInfo = new ItemLocationList() { locInfo }; vendorItem = null; break; }*/ #endregion } } if (vendorItem != null) { // We already set the Vendor Name and Zone item.LocationInfo = new ItemLocationList() { vendorItem }; } }else if (/*LocInfoIsValid &&*/ item.LocationInfo[0] is StaticDrop) { int count = 0, outof = 0; #region Try to get the Count and OutOf numbers, which are used to make the Drop Rate Perc int liststartpos = hdoc.IndexOf("new Listview({template: 'npc', id: 'dropped-by'"); if (liststartpos > 1) { int listendpos = hdoc.IndexOf(";", liststartpos); string dropExcerpt = hdoc.Substring(liststartpos, listendpos - liststartpos); // we are looking for something like count:2939,outof:13677 // (?:count:(?<count>\d+),outof:(?<outof>\d+)) Regex dropRegex = new Regex(@"(?:count:(?<count>\d+),outof:(?<outof>\d+))"); Match dropMatch; if ((dropMatch = dropRegex.Match(dropExcerpt)).Success) { // Yay! it worked! count = int.Parse(dropMatch.Groups["count"].Value); outof = int.Parse(dropMatch.Groups["outof"].Value); } } #endregion StaticDrop dropItem = item.LocationInfo[0] as StaticDrop; if (dropItem != null) { dropItem.Count = count; dropItem.OutOf = outof; item.LocationInfo = new ItemLocationList() { dropItem }; } } else if (/*LocInfoIsValid &&*/ item.LocationInfo[0] is PvpItem) { List<string> tokenIds = new List<string> { }; List<int> tokenCounts = new List<int> { }; string tokenName = "Unknown Currency"; //TokenDropInfo tokenDropInfo = null; string repSource = "", repLevel = ""; #region Try to get the Token Names and individual costs int liststartpos = hdoc.IndexOf("new Listview({template: 'npc', id: 'sold-by'"); if (liststartpos > 1) { int listendpos = hdoc.IndexOf(";", liststartpos); string costExcerpt = hdoc.Substring(liststartpos, listendpos - liststartpos); // we are looking for something like cost:[0,0,0,[[40633,1]]] // cost:[gold,[[currencyId1,currencyQu1],[currencyId2,currencyQu2]],[objectId,objectQu]] Regex costRegex = new Regex(@"cost:\[(?<gold>\d+),\[(?:\[(?<currencyId1>\d+),(?<currencyQu1>\d+)\])?,?(?:\[(?<currencyId2>\d+),(?<currencyQu2>\d+)\])?\],\[(?:\[?(?<tokenId1>\d+),(?<tokenQu1>\d+)\]?)?,?(?:\[?(?<tokenId2>\d+),(?<tokenQu2>\d+)\]?)?\]\]"); Regex costRegexGoldOnly = new Regex(@"cost:\[(?<gold>\d+)\]"); Match costMatch; if ((costMatch = costRegex.Match(costExcerpt)).Success) { // Yay! it worked! // Lets try Currency 1, such as Justice Points if (!String.IsNullOrEmpty(costMatch.Groups["currencyId1"].Value)) { tokenIds.Add(costMatch.Groups["currencyId1"].Value); tokenCounts.Add(int.Parse(costMatch.Groups["currencyQu1"].Value)); } // Lets try Currency 2, such as Justice Points // Not sure if there would ever actually be a 2nd here, but it was formatted as if it was possible // If nothing else, when currencyId1 fails but 2 is valid we put something in the array if (!String.IsNullOrEmpty(costMatch.Groups["currencyId2"].Value)) { tokenIds.Add(costMatch.Groups["currencyId2"].Value); tokenCounts.Add(int.Parse(costMatch.Groups["currencyQu2"].Value)); } // Lets try Token 1 cost, such as Mantle of the Conqueror if (!String.IsNullOrEmpty(costMatch.Groups["tokenId1"].Value)) { tokenIds.Add(costMatch.Groups["tokenId1"].Value); tokenCounts.Add(int.Parse(costMatch.Groups["tokenQu1"].Value)); } // Lets try Token 2 cost, such as Mantle of the Conqueror if (!String.IsNullOrEmpty(costMatch.Groups["tokenId2"].Value)) { tokenIds.Add(costMatch.Groups["tokenId2"].Value); tokenCounts.Add(int.Parse(costMatch.Groups["tokenQu2"].Value)); } } else if ((costMatch = costRegex.Match(costExcerpt)).Success) { // Yay! it worked! } } #endregion #region Check to see if it requires a specific Faction and get its required level liststartpos = hdoc.IndexOf("Requires <a href=\"/faction="); if (liststartpos > 1) { int listendpos = hdoc.IndexOf("</td>", liststartpos); string repExcerpt = hdoc.Substring(liststartpos, listendpos - liststartpos); // we are looking for something like cost:[0,0,0,[[40633,1]]] // cost:[gold,[[currencyId1,currencyQu1],[currencyId2,currencyQu2]],[objectId,objectQu]] Regex repRegex = new Regex(@"Requires .a href=.\/faction=(?<factionId>\d+). class=.q\d.>.+\/a. - (?<level>(?:Friendly|Honored|Revered|Exalted))"); Match repMatch; if ((repMatch = repRegex.Match(repExcerpt)).Success) { // Yay! it worked! // Lets get the Faction's name based on the ID repSource = GetItemFactionVendorInfo(repMatch.Groups["factionId"].Value, "0")[0]; switch (repMatch.Groups["level"].Value) { case "Friendly":{ repLevel = "4"; break; } case "Honored": { repLevel = "5"; break; } case "Revered": { repLevel = "6"; break; } case "Exalted": { repLevel = "7"; break; } default: { repLevel = "0"; break; } } } } #endregion PvpItem pvpItem = item.LocationInfo[0] as PvpItem; for (int i = 0; i < 3; i++) { if (tokenIds.Count < i + 1) { break; } // stop processing if we don't have any more // Check to see if it's a PvP token/Currency if (!String.IsNullOrEmpty(tokenIds[i]) && _pvpTokenMap.TryGetValue(tokenIds[i], out tokenName)) { if (tokenName == "Honor Points" || tokenIds[i] == "392") item.LocationInfo = new ItemLocationList() { new PvpItem() { Points = tokenCounts[i], PointType = "Honor" } }; else if (tokenName == "Conquest Points" || tokenIds[i] == "390") item.LocationInfo = new ItemLocationList() { new PvpItem() { Points = tokenCounts[i], PointType = "Conquest" } }; else item.LocationInfo = new ItemLocationList() { new PvpItem() { TokenCount = tokenCounts[i], TokenType = tokenName } }; pvpItem = null; // invalidate the vendor item so it doesn't get added in later break; } else if (tokenIds[i] != null && _vendorTokenMap.TryGetValue(tokenIds[i], out tokenName)) { //pvpItem.TokenMap[tokenName] = tokenCounts[i]; } else if (tokenIds[i] != null) { if ((tokenName == "Justice Points" || tokenIds[i] == "395") || (tokenName == "Valor Points" || tokenIds[i] == "396")) { item.Cost = tokenCounts[i]; } // Sets the cost on the item for the user #region It's a PvE Token // ok now let's see what info we can get about this token string boss = null; string vendor = null; string area = null; string vendorarea = null; bool heroic = false; bool lfr = false; bool container = false; if (!_tokenDropMap.ContainsKey(tokenIds[i])) { // Not doing this =^( hopefully we won't actually need to cuz I mapped all the currencies listed in wowhead #region We *really* haven't seen this before so we need to pull the data /*XDocument docToken = wrw.DownloadItemWowhead(site, tokenIds[i]); if (docToken != null) { tokenNames[i] = docToken.SelectSingleNode("wowhead/item/name").Value; // we don't want token => boss propagation anymore, otherwise you get weird stuff like 277 gloves dropping from Toravon /*string tokenJson = docToken.SelectSingleNode("wowhead/item/json").InnerText; string tokenSource = string.Empty; if (tokenJson.Contains("\"source\":[")) { tokenSource = tokenJson.Substring(tokenJson.IndexOf("\"source\":[") + "\"source\":[".Length); tokenSource = tokenSource.Substring(0, tokenSource.IndexOf("]")); } string tokenSourcemore = string.Empty; if (tokenJson.Contains("\"sourcemore\":[{")) { tokenSourcemore = tokenJson.Substring(tokenJson.IndexOf("\"sourcemore\":[{") + "\"sourcemore\":[{".Length); tokenSourcemore = tokenSourcemore.Substring(0, tokenSourcemore.IndexOf("}]")); } if (!string.IsNullOrEmpty(tokenSource) && !string.IsNullOrEmpty(tokenSourcemore)) { string[] tokenSourceKeys = tokenSource.Split(','); string[] tokenSourcemoreKeys = tokenSourcemore.Split(new string[] { "},{" }, StringSplitOptions.RemoveEmptyEntries); // for tokens we prefer loot info, we don't care if it can be bought with badges tokenSource = tokenSourceKeys[0]; tokenSourcemore = tokenSourcemoreKeys[0]; int dropIndex = Array.IndexOf(tokenSourceKeys, "2"); if (dropIndex >= 0) { tokenSource = tokenSourceKeys[dropIndex]; tokenSourcemore = tokenSourcemoreKeys[dropIndex]; } if (tokenSource == "2") { foreach (string kv in tokenSourcemore.Split(',')) { if (!string.IsNullOrEmpty(kv)) { string[] keyvalsplit = kv.Split(':'); string key = keyvalsplit[0]; string val = keyvalsplit[1]; switch (key.Trim('"')) { case "t": container = val == "2" || val == "3"; break; case "n": // NPC 'Name' boss = val.Replace("\\'", "'").Trim('"'); break; case "z": // Zone area = GetZoneName(val); break; case "dd": // Dungeon Difficulty (1 = Normal, 2 = Heroic) heroic = val == "2"; break; } } } } } if (boss == null) { //boss = "Unknown Boss (Wowhead lacks data)"; area = null; // if boss is null prefer treating this as pve token }*/ /* if (tokenNames[i] != null) { _tokenDropMap[tokenIds[i]] = new TokenDropInfo() { Boss = boss, Area = area, Heroic = heroic, Name = tokenNames[i], Container = container }; } }*/ #endregion } else { #region We've seen this before so just use that data TokenDropInfo info = _tokenDropMap[tokenIds[i]]; boss = info.Boss; vendor = info.Vendor; area = info.Area; vendorarea = info.VendorArea; heroic = info.Heroic; lfr = info.LFR; tokenName = info.Name; container = info.Container; #endregion } if (tokenName != null) { #region This is NOT a Dropped Token, so treat it as a normal vendor item and include token info //pvpItem.TokenMap[tokenName] = tokenCounts[i]; if (!String.IsNullOrEmpty(area) && !String.IsNullOrEmpty(vendorarea) && area != vendorarea && vendorarea != "Unknown Area") { // We are lucky enough to have BOTH drop points, so lets set both up //pvpItem.VendorArea = vendorarea; //pvpItem.VendorName = vendor; //pvpItem.TokenMap[tokenName] = tokenCounts[i]; ItemLocation droppoint = new StaticDrop() { Area = area, Boss = boss, Heroic = heroic, LFR = lfr, }; item.LocationInfo = new ItemLocationList() { pvpItem, droppoint }; pvpItem = null; break; } else { //pvpItem.VendorArea = area; //pvpItem.VendorName = boss; } #endregion } else if (area != null) { #region This is a Dropped Token or we know what vendor is dropping it, so assign it to where it drops from if (container) { ItemLocation locInfo = new ContainerItem() { Area = area, Container = boss, Heroic = heroic, LFR = lfr, }; item.LocationInfo = new ItemLocationList() { locInfo }; pvpItem = null; break; } else { ItemLocation locInfo = new StaticDrop() { Area = area, Boss = boss, Heroic = heroic, LFR = lfr, }; item.LocationInfo = new ItemLocationList() { locInfo }; pvpItem = null; break; } #endregion } else /*if (tokenNames[i] == null)*/ { // there was an error pulling token data from web // ignore source information pvpItem = null; break; } #endregion } else { #region There is no token so this is a normal vendor item if (!String.IsNullOrEmpty(repSource) && !String.IsNullOrEmpty(repLevel)) { string[] repInfo = GetItemFactionVendorInfo(repSource, repLevel); FactionItem locInfo = new FactionItem() { FactionName = repInfo[0], Level = (ReputationLevel)int.Parse(repLevel), // repInfo[3] //Cost = goldCost, }; item.LocationInfo = new ItemLocationList() { locInfo }; pvpItem = null; break; }/* else { VendorItem locInfo = new VendorItem() { Cost = goldCost, }; if (!string.IsNullOrEmpty(n)) locInfo.VendorName = n; if (sourcemore != null && sourcemore.TryGetValue("z", out tmp)) { locInfo.VendorArea = GetZoneName(tmp.ToString()); } item.LocationInfo = new ItemLocationList() { locInfo }; vendorItem = null; break; }*/ #endregion } } if (pvpItem != null) { // We already set the Vendor Name and Zone item.LocationInfo = new ItemLocationList() { pvpItem }; } } /*else if (item.LocationInfo == null) { * // NOTICE: This check isn't possible anymore, but it's generating an Unknown automatically so it's not necessary either // We DON'T have Source Data AND we didn't have one before. So lets set it to Unknown item.LocationInfo = new ItemLocationList() { UnknownItem.Construct() }; }*/ else { // We DON'T have Source Data // Since we are doing nothing, the ItemSource cache doesn't change // Therefore the original ItemSource persists, if it's there } // If it's Craftable and Binds on Pickup, mark it as such if (item.LocationInfo[0] is CraftedItem && (item.Bind == BindsOn.BoP)) { (item.LocationInfo[0] as CraftedItem).Bind = BindsOn.BoP; } } catch (Exception ex) { (sender as BackgroundWorker).ReportProgress(0, ex.Message + "|" + ex.StackTrace); } }