private void Item_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { TreeViewItem tvi = tvSlots.SelectedItem as TreeViewItem; if (tvi == null || tvi.Tag == null) { lvItem.SetItem(null); return; } DDOItemData item = tvi.Tag as DDOItemData; if (item != null) { EquipmentSlotType est; if (tvi.HasItems) { est = (EquipmentSlotType)(tvi.Parent as TreeViewItem).Tag; } else { est = (EquipmentSlotType)((tvi.Parent as TreeViewItem).Parent as TreeViewItem).Tag; } lvItem.SetItem(new BuildItem(tvi.Tag as DDOItemData, est)); } else { lvItem.SetItem(null); } }
public static bool IsItemAllowed(DDOItemData item) { if (item.QuestFoundIn == null) { return(false); } if (item.QuestFoundIn.Adpack != null && !QuestSourceAllowed[item.QuestFoundIn.Adpack.Name]) { return(false); } if (item.QuestFoundIn.IsFree) { return(true); } if (item.QuestFoundIn.Adpack == null) { return(QuestSourceAllowed[FreeToVIP]); } if (item.QuestFoundIn.Adpack.FreeToVIP && !QuestSourceAllowed[FreeToVIP]) { return(false); } if (!item.MinorArtifact && item.QuestFoundIn.IsRaid && !QuestSourceAllowed[RaidDrops]) { return(false); } return(true); }
private void Item_MouseDoubleClick(object sender, MouseButtonEventArgs e) { TreeViewItem tvi = tvSlots.SelectedItem as TreeViewItem; if (tvi == null || tvi.HasItems || tvi.Tag == null) { return; } DDOItemData item = tvi.Tag as DDOItemData; if (item == null) { return; } EquipmentSlotType est; if (tvi.HasItems) { est = (EquipmentSlotType)(tvi.Parent as TreeViewItem).Tag; } else { est = (EquipmentSlotType)((tvi.Parent as TreeViewItem).Parent as TreeViewItem).Tag; } ((PlannerWindow)(Owner.Owner)).SlotItem(new BuildItem(item, est)); ((PlannerWindow)(Owner.Owner)).CalculateGearSet(true); }
private void ChangeSlot_Click(object sender, RoutedEventArgs e) { TreeViewItem tvi = tvItems.SelectedItem as TreeViewItem; ACustomItemContainer cic = tvi.Tag as ACustomItemContainer; DDOItemData item = cic.GetItem(); SlotType slot = SlotType.None; if (!GetSlot(item.Slot, cic.GetDisallowedSlots(), out slot)) { return; } if (slot == item.Slot) { return; } tvi.IsSelected = false; (tvi.Parent as TreeViewItem).Items.Remove(tvi); if (ItemPropertiesArea.Child == CustomIP) { RemoveSlotSpecificProperties(item); } item.Slot = slot; if (ItemPropertiesArea.Child == CustomIP) { AddSlotSpecificProperties(item); } tvi = AddItemToTreeView(cic); tvi.IsSelected = true; tvi.BringIntoView(); CustomItemChangedSlot?.Invoke(item); }
private void ItemListMouseDoubleClick(object sender, MouseButtonEventArgs e) { if (lbItems.SelectedItem == null) { return; } DDOItemData item = (lbItems.SelectedItem as ListBoxItem).Tag as DDOItemData; ItemDoubleClicked?.Invoke(item); }
private void ItemListMouseRightButtonUp(object sender, MouseButtonEventArgs e) { if (lbItems.SelectedItem == null) { return; } DDOItemData item = (lbItems.SelectedItem as ListBoxItem).Tag as DDOItemData; System.Diagnostics.Process.Start(item.WikiURL); }
public override bool FromXml(XmlElement xci) { try { XmlElement xi = (XmlElement)xci.GetElementsByTagName("Item")[0]; Item = DDOItemData.FromXml(xi); return(true); } catch { return(false); } }
public void SetItem(DDOItemData item) { Item = item; lvDetails.Items.Clear(); if (item == null) { return; } foreach (var ip in item.Properties) { AddItemProperty(ip); } }
public static BuildItem FromXml(XmlElement xe) { try { DDOItemData item = DatasetManager.Dataset.Items.Find(i => i.Name == xe.GetAttribute("item")); if (item == null) { return(null); } EquipmentSlotType est = (EquipmentSlotType)Enum.Parse(typeof(EquipmentSlotType), xe.GetAttribute("slot")); if (est == EquipmentSlotType.None) { return(null); } BuildItem bi = new BuildItem(item, est); if (!xe.HasChildNodes) { return(bi); } List <ItemProperty> found = new List <ItemProperty>(); foreach (XmlElement xc in xe.ChildNodes) { string property = xc.InnerText; string type = xc.GetAttribute("type"); foreach (var ip in item.Properties) { if (ip.Options != null && !found.Contains(ip)) { foreach (var op in ip.Options) { if (op.Property == property && ((string.IsNullOrWhiteSpace(op.Type) && type == "untyped") || op.Type == type)) { bi.OptionProperties.Add(op); found.Add(ip); break; } } } } } return(bi); } catch { return(null); } }
private void Item_MouseRightButtonUp(object sender, MouseButtonEventArgs e) { TreeViewItem tvi = tvSlots.SelectedItem as TreeViewItem; if (tvi == null || tvi.Tag == null) { return; } DDOItemData item = tvi.Tag as DDOItemData; if (item == null) { return; } System.Diagnostics.Process.Start(item.WikiURL); }
public static bool CanBeUsedTogether(DDOItemData weapon, DDOItemData offhand) { if (weapon.Handedness == 1) { return(true); } else { if (offhand.Slot != SlotType.Offhand) { return(false); } return(RuneArmCompatibleTwoHandedWeaponTypes.Contains(weapon.WeaponType) && (OffhandCategory)offhand.Category == OffhandCategory.RuneArm); } }
bool BuildFilterProperty(TreeViewItem tvi, DDOItemData item, ItemProperty p, SlotType slot) { string prefix = "(" + (slot == SlotType.None ? "gear set filter" : slot.ToString() + " filter") + ") "; bool added = false; foreach (BuildFilter bf in Build.TestFilters[slot]) { if (bf.Property == p.Property) { if (bf.Type == null || bf.Type == p.Type || (bf.Type == "untyped" && string.IsNullOrWhiteSpace(p.Type))) { if (bf.Include) { TreeViewItem tvip = new TreeViewItem(); tvip.Header = prefix + p.Property + ", " + (string.IsNullOrWhiteSpace(p.Type) ? "untyped" : p.Type) + ", " + p.Value; tvip.Tag = item; tvi.Items.Add(tvip); added = true; } } } else if (p.Options != null && !p.HideOptions) { foreach (var op in p.Options) { if (bf.Property == op.Property) { if (bf.Type == null || bf.Type == op.Type || (bf.Type == "untyped" && string.IsNullOrWhiteSpace(op.Type))) { if (bf.Include) { TreeViewItem tvip = new TreeViewItem(); tvip.Header = "> " + prefix + op.Property + ", " + (string.IsNullOrWhiteSpace(op.Type) ? "untyped" : op.Type) + ", " + op.Value; tvip.Tag = item; tvi.Items.Add(tvip); added = true; } } } } } } return(added); }
void RemoveSlotSpecificProperties(DDOItemData item) { switch (item.Slot) { case SlotType.Body: item.Properties.Remove(item.Properties.Find(p => p.Property == "Armor Category")); break; case SlotType.Offhand: item.Properties.Remove(item.Properties.Find(p => p.Property == "Offhand Category")); break; case SlotType.Weapon: item.Properties.Remove(item.Properties.Find(p => p.Property == "Weapon Category")); item.Properties.Remove(item.Properties.Find(p => p.Property == "Handedness")); break; } }
void AddSlotSpecificProperties(DDOItemData item) { switch (item.Slot) { case SlotType.Body: item.AddProperty("Armor Category", ArmorCategory.Cloth.ToString(), 0, null, 1); item.Category = (int)ArmorCategory.Cloth; break; case SlotType.Offhand: item.AddProperty("Offhand Category", OffhandCategory.Orb.ToString(), 0, null, 1); item.Category = (int)OffhandCategory.Orb; break; case SlotType.Weapon: item.AddProperty("Handedness", null, 1, null, 1); item.AddProperty("Weapon Category", WeaponCategory.Simple.ToString(), 0, null, 1); item.Category = (int)WeaponCategory.Simple; break; } }
private void LvSets_SelectionChanged(object sender, SelectionChangedEventArgs e) { SlotPanel.Children.Clear(); SlotPanel.Tag = null; SelectedItems.Clear(); SelectedWeapon = null; SelectedOffhand = null; btnApply.IsEnabled = false; if (lvSets.SelectedItem == null) { return; } DDOItemSet set = (lvSets.SelectedItem as NamedSetInfo).Set; SlotPanel.Tag = set; foreach (var item in set.Items) { // don't show items that aren't allowed if (!QuestSourceManager.IsItemAllowed(item)) { continue; } string group = item.Slot.ToString() + " Slot"; bool ro = false; // search for an existing groupbox first GroupBox gb = null; StackPanel sp = null; foreach (GroupBox tgb in SlotPanel.Children) { if ((tgb.Header as Label).Content.ToString() == group) { gb = tgb; if ((gb.Header as Label).Foreground == Brushes.Red) { ro = true; } sp = gb.Content as StackPanel; break; } } if (gb == null) { gb = new GroupBox(); Label header = new Label { Content = group }; header.Content = group; gb.Header = header; sp = new StackPanel(); gb.Content = sp; SlotPanel.Children.Add(gb); foreach (var eq in EquipmentSlots) { if (item.Slot == eq.Value.SlotType) { if (eq.Value.SlotType != SlotType.Finger && eq.Value.SlotType != SlotType.Weapon && eq.Value.IsLocked) { ro = true; break; } } } bool go = false; if (item.Slot == SlotType.Finger) { if (FingerLimit <= 0) { ro = true; } else if (FingerLimit == 1) { go = true; } } else if (item.Slot == SlotType.Weapon) { if (item.Handedness == 1) { if (WeaponSlot.IsLocked && OffhandSlot.IsLocked) { ro = true; } else if (WeaponSlot.IsLocked || OffhandSlot.IsLocked) { go = true; } } else if (item.Handedness == 2) { if (WeaponSlot.IsLocked) { ro = true; } else if (OffhandSlot.IsLocked) { if (OffhandSlot.Item == null) { ro = true; } else if (OffhandSlot.Item.Item.Slot == SlotType.Weapon) { ro = true; } else if ((OffhandCategory)OffhandSlot.Item.Item.Category != OffhandCategory.RuneArm) { ro = true; } else if (!DatasetManager.RuneArmCompatibleTwoHandedWeaponTypes.Contains(item.WeaponType)) { ro = true; } else { go = true; } } } } if (ro) { header.Foreground = Brushes.Red; } else if (go) { header.Foreground = Brushes.Goldenrod; } } CheckBox cb = new CheckBox { Content = item.Name, Tag = item }; if (ro) { cb.IsEnabled = false; } else { // we do individual offhand evaluation here if (item.Slot == SlotType.Offhand) { if (WeaponSlot.IsLocked && WeaponSlot.Item != null && WeaponSlot.Item.Item.Handedness == 2) { if (!DatasetManager.RuneArmCompatibleTwoHandedWeaponTypes.Contains(WeaponSlot.Item.Item.WeaponType) || (OffhandCategory)item.Category != OffhandCategory.RuneArm) { cb.IsEnabled = false; } else { cb.Click += ItemCheckBox_Clicked; } } else { cb.Click += ItemCheckBox_Clicked; } } else { cb.Click += ItemCheckBox_Clicked; } } cb.ToolTip = item.Name; cb.MouseRightButtonDown += ItemCheckBox_MouseRightButtonDown; sp.Children.Add(cb); } tcSetBonuses.Items.Clear(); foreach (var sb in set.SetBonuses) { TabItem ti = new TabItem { Header = sb.MinimumItems + " Pieces" }; ListViewItemProperties ip = new ListViewItemProperties(); ip.SetSetBonuses(sb); ti.Content = ip; ti.Tag = sb; tcSetBonuses.Items.Add(ti); } tcSetBonuses.SelectedIndex = 0; }
public BuildItem(DDOItemData item, EquipmentSlotType slot) { Item = item; Slot = slot; }
private void ItemCheckBox_Clicked(object sender, RoutedEventArgs e) { CheckBox cb = sender as CheckBox; if (cb.IsChecked.Value) { DDOItemData si = cb.Tag as DDOItemData; DDOItemData ci; int fi = 0; for (int i = 0; i < SelectedItems.Count; i++) { ci = SelectedItems[i].Tag as DDOItemData; if (si.Slot == ci.Slot) { // finger slots don't get unchecked, since there could be two of them if (si.Slot == SlotType.Finger) { fi++; } // weapon slot doesn't get checked, since a weapon could be in the offhand else if (si.Slot != SlotType.Weapon) { SelectedItems[i].IsChecked = false; SelectedItems.RemoveAt(i); if (SelectedOffhand == ci) { SelectedOffhand = null; } break; } } } if (si.Slot == SlotType.Finger) { if (fi >= FingerLimit) { MessageBox.Show("Can't use more than " + (FingerLimit == 1 ? "one finger item" : "two finger items") + ". Remove one before adding another.", "Finger slots at capacity", MessageBoxButton.OK, MessageBoxImage.Stop); cb.IsChecked = false; } else { SelectedItems.Add(cb); } } else if (si.Slot == SlotType.Weapon) { bool allow = false; if (si.Handedness == 1) { if (WeaponSlot.IsLocked) { if (WeaponSlot.Item == null || WeaponSlot.Item.Item.Handedness == 1) { if (SelectedOffhand == null) { SelectedOffhand = si; allow = true; } } } else if (SelectedWeapon == null) { SelectedWeapon = si; allow = true; } else if (SelectedWeapon.Handedness == 1 && !OffhandSlot.IsLocked && SelectedOffhand == null) { SelectedOffhand = si; allow = true; } } else if (si.Handedness == 2) { if (SelectedWeapon == null) { if (OffhandSlot.Item == null) { allow = true; } else if (OffhandSlot.IsLocked) { if (OffhandSlot.Item.Item.Slot == SlotType.Offhand && DatasetManager.CanBeUsedTogether(si, OffhandSlot.Item.Item)) { allow = true; } } else if (SelectedOffhand == null) { allow = true; } else if (SelectedOffhand.Slot == SlotType.Offhand && DatasetManager.CanBeUsedTogether(si, SelectedOffhand)) { allow = true; } if (allow) { SelectedWeapon = si; } } } if (!allow) { MessageBox.Show("There are no hands available to use the selected weapon. Free up a weapon or offhand item to add another.", "Weapon/Offhand slots at capacity", MessageBoxButton.OK, MessageBoxImage.Stop); cb.IsChecked = false; } else { SelectedItems.Add(cb); } } else if (si.Slot == SlotType.Offhand) { bool allow = false; if (SelectedOffhand == null) { if (SelectedWeapon != null) { allow = DatasetManager.CanBeUsedTogether(SelectedWeapon, si); } else if (WeaponSlot.Item != null) { allow = DatasetManager.CanBeUsedTogether(WeaponSlot.Item.Item, si); } else { allow = true; } } if (!allow) { MessageBox.Show("There are no hands available to use the selected offhand. Free up a weapon item first.", "Weapon/Offhand slots at capacity", MessageBoxButton.OK, MessageBoxImage.Stop); cb.IsChecked = false; } else { SelectedItems.Add(cb); SelectedOffhand = si; } } else { SelectedItems.Add(cb); } } // item is being deselected by user else { SelectedItems.Remove(cb); DDOItemData id = cb.Tag as DDOItemData; if (id.Slot == SlotType.Offhand) { SelectedOffhand = null; } else if (id.Slot == SlotType.Weapon) { if (SelectedWeapon == id) { SelectedWeapon = null; if (SelectedOffhand != null && SelectedOffhand.Slot == SlotType.Weapon) { SelectedWeapon = SelectedOffhand; SelectedOffhand = null; } } else if (SelectedOffhand == id) { SelectedOffhand = null; } } } // update minimum item notification for bonuses tabs TabItem sti = null; foreach (TabItem ti in tcSetBonuses.Items) { DDOItemSetBonus sb = ti.Tag as DDOItemSetBonus; if (sb.MinimumItems <= SelectedItems.Count) { sti = ti; } ti.Header = sb.MinimumItems.ToString() + " Pieces"; } if (sti != null) { sti.Header = (sti.Tag as DDOItemSetBonus).MinimumItems.ToString() + " Pieces *"; } btnApply.IsEnabled = SelectedItems.Count > 0; }