public void Initialize(Dictionary <EquipmentSlotType, EquipmentSlotControl> es) { FingerLimit = 2; EquipmentSlots = es; WeaponSlot = EquipmentSlots[EquipmentSlotType.Weapon]; OffhandSlot = EquipmentSlots[EquipmentSlotType.Offhand]; if (EquipmentSlots[EquipmentSlotType.Finger1].IsLocked) { FingerLimit--; } if (EquipmentSlots[EquipmentSlotType.Finger2].IsLocked) { FingerLimit--; } foreach (var set in DatasetManager.Dataset.Sets) { if (string.IsNullOrWhiteSpace(set.Value.WikiURL)) { continue; } int ml = 0; List <DDOAdventurePackData> apds = new List <DDOAdventurePackData>(); foreach (var item in set.Value.Items) { if (item.QuestFoundIn.Adpack != null && !apds.Contains(item.QuestFoundIn.Adpack)) { apds.Add(item.QuestFoundIn.Adpack); } if (!QuestSourceManager.IsItemAllowed(item)) { continue; } var mlp = item.Properties.Find(i => i.Property == "Minimum Level"); if (mlp != null && mlp.Value > ml) { ml = (int)mlp.Value; } } foreach (var apd in apds) { if (QuestSourceManager.IsAllowed(apd)) { Sets.Add(new NamedSetInfo { Name = set.Value.Name, ML = ml, WikiURL = set.Value.WikiURL, Set = set.Value }); break; } } } Sets.Sort((a, b) => a.ML < b.ML ? -1 : (a.ML > b.ML ? 1 : a.Name.CompareTo(b.Name))); lvSets.ItemsSource = Sets; SetFilter(CustomFilter); }
void Initialize() { List <DDOItemProperty> ips = DatasetManager.Dataset.ItemProperties.Select(ip => ip.Value).OrderBy(ip => ip.Property).ToList(); // populate by property treeview foreach (var ip in ips) { TreeViewItem tvi = new TreeViewItem(); TextBlock header = new TextBlock(); header.Inlines.Add(new Run { Text = ip.Property, FontWeight = FontWeights.Bold }); if (ip.Items.Count == 0) { header.Inlines.Add(" (set bonus only)"); } else { header.Inlines.Add(" (" + ip.SlotsFoundOn + ")"); tvi.Tag = ip; foreach (var ipt in ip.Types) { string type = ipt; if (string.IsNullOrWhiteSpace(ipt)) { type = "untyped"; } TreeViewItem tvii = new TreeViewItem(); SlotType st = SlotType.None; bool itemnotallowed = false; foreach (var item in ip.Items) { if (!QuestSourceManager.IsItemAllowed(item)) { itemnotallowed = true; continue; } if (item.Properties.Find(p => p.Property == ip.Property && (p.Type == type || (type == "untyped" && string.IsNullOrWhiteSpace(p.Type)))) != null) { st |= item.Slot; } } if (st != SlotType.None) { tvii.Header = type + " (" + st + ")"; tvii.Tag = ip; tvi.Items.Add(tvii); } else if (!itemnotallowed) { tvii.Header = type + " (set bonus only)"; tvi.Items.Add(tvii); } } } if (tvi.HasItems) { tvi.Header = header; tvByProperty.Items.Add(tvi); } } // populate by slot treeview // setup dictionary for quicker processing string[] slotnames = Enum.GetNames(typeof(SlotType)); Dictionary <SlotType, TreeViewItem> slots = new Dictionary <SlotType, TreeViewItem>(); foreach (string s in slotnames) { if (s == "None") { continue; } TreeViewItem tvi = new TreeViewItem(); TextBlock tb = new TextBlock(); tb.Inlines.Add(new Run { Text = s, FontWeight = FontWeights.Bold }); tvi.Header = tb; tvBySlot.Items.Add(tvi); SlotType st = (SlotType)Enum.Parse(typeof(SlotType), s); slots.Add(st, tvi); tvi.Tag = st; } foreach (var ip in ips) { Dictionary <SlotType, TreeViewItem> ipslots = new Dictionary <SlotType, TreeViewItem>(); List <string> types; TreeViewItem tvi; TextBlock tb; foreach (var item in ip.Items) { if (!QuestSourceManager.IsItemAllowed(item)) { continue; } bool first; if (ipslots.ContainsKey(item.Slot)) { tvi = ipslots[item.Slot]; tb = tvi.Header as TextBlock; types = tvi.Tag as List <string>; first = false; } else { tvi = new TreeViewItem(); tb = new TextBlock(); tb.Inlines.Add(new Run { Text = ip.Property, FontWeight = FontWeights.Bold }); tb.Inlines.Add(" ("); tvi.Header = tb; types = new List <string>(ip.Types); tvi.Tag = types; slots[item.Slot].Items.Add(tvi); ipslots[item.Slot] = tvi; first = true; } foreach (var p in item.Properties) { if (p.Options != null && !p.HideOptions) { foreach (var op in p.Options) { if (op.Property == ip.Property) { first = ProcessPropertyForSlots(op.Type, types, first, tb); } } } else if (p.Property == ip.Property) { first = ProcessPropertyForSlots(p.Type, types, first, tb); } } } // add ")" to the end of each treeviewitem foreach (var ipsl in ipslots) { (ipsl.Value.Header as TextBlock).Inlines.Add(")"); ipsl.Value.Tag = ip; } } }
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; }
void PopulateItemListForProperty(DDOItemProperty ip, SlotType slot) { foreach (var item in ip.Items) { if (!QuestSourceManager.IsItemAllowed(item)) { continue; } if (slot != SlotType.None && item.Slot != slot) { continue; } ListBoxItem lbi = new ListBoxItem(); TextBlock tb = new TextBlock(); lbi.Content = tb; lbi.Tag = item; tb.Inlines.Add(new Run { Text = item.Name, FontWeight = FontWeights.Bold }); tb.Inlines.Add(" (" + item.Slot + ") ("); bool first = true; foreach (var p in item.Properties) { if (p.Options != null && !p.HideOptions) { foreach (var op in p.Options) { if (op.Property == ip.Property) { if (first) { first = false; } else { tb.Inlines.Add(", "); } tb.Inlines.Add(string.IsNullOrWhiteSpace(op.Type) ? "untyped" : op.Type); tb.Inlines.Add(" " + op.Value); } } } else if (p.Property == ip.Property) { if (first) { first = false; } else { tb.Inlines.Add(", "); } tb.Inlines.Add(string.IsNullOrWhiteSpace(p.Type) ? "untyped" : p.Type); tb.Inlines.Add(" " + p.Value); } } tb.Inlines.Add(")"); lbItems.Items.Add(lbi); } }