public void Select(Item item) { _button.SelectedItem = item; _characterSlot = Character.CharacterSlot.None; ItemToolTip.Instance.Hide(this); this.Hide(); }
void ItemCache_ItemsChanged(object sender, EventArgs e) { Items = ItemCache.Instance.RelevantItems; Character.CharacterSlot characterSlot = _characterSlot; _characterSlot = Character.CharacterSlot.None; LoadGearBySlot(characterSlot); }
public void Show(ItemButton button, Character.CharacterSlot slot) { _button = button; this.SetAutoLocation(button); this.LoadGearBySlot(slot); base.Show(); }
public void Show(Item item, Character.CharacterSlot equipSlot, Character itemCharacter, bool allowDelete) { _item = item; _itemCharacter = itemCharacter; _menuItemEquipAll.Visible = (_itemCharacter != null); _equipSlot = equipSlot; _menuItemEquip.Enabled = (this.Character[equipSlot] != item); _menuItemEquip.Visible = equipSlot != Character.CharacterSlot.None; _menuItemDelete.Enabled = allowDelete && _menuItemEquip.Enabled; _menuItemDeleteDuplicates.Enabled = allowDelete; _menuItemName.Text = item.Name; this.Show(Control.MousePosition); }
private void ComparisonGraph_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e) { //if (e.Button == MouseButtons.Right) //{ if (e.X <= 106) { int itemIndex = (int)Math.Floor(((float)(e.Y - 44f + _scrollBar.Value)) / 36f); if (itemIndex >= 0 && itemIndex < ItemCalculations.Length && ItemCalculations[itemIndex].Item != null && ItemCalculations[itemIndex].Item.Id != 0) { Item item = ItemCalculations[itemIndex].Item; if (e.X < 10) { if (item != null && item.Id != 0) { if ((e.Button & MouseButtons.Right) != 0) { if (item.Id > 0 && !item.IsGem) { ItemEnchantContextualMenu.Instance.Show(item); } } else { Character.ToggleItemAvailability(item, (Control.ModifierKeys & Keys.Control) == 0); } } } else if (item.Id > 0) { Character.CharacterSlot slot = EquipSlot; Item showItem = ItemCalculations[itemIndex].Item; if (slot == Character.CharacterSlot.AutoSelect) { if (SlotMap != null && SlotMap.ContainsKey(showItem.Slot)) { slot = SlotMap[showItem.Slot]; } else { slot = Item.DefaultSlotMap[showItem.Slot]; } } ItemContextualMenu.Instance.Show(showItem, slot, ItemCalculations[itemIndex].Character, true); } } } //} }
public void LoadGearBySlot(Character.CharacterSlot slot) { if (slot != _characterSlot) { _characterSlot = slot; List <ComparisonCalculationBase> itemCalculations = new List <ComparisonCalculationBase>(); if (this.Items != null && this.Character != null) { foreach (Item item in this.Items) { if (item.FitsInSlot(slot)) { itemCalculations.Add(Calculations.GetItemCalculations(item, this.Character, slot)); } } } itemCalculations.Sort(new System.Comparison <ComparisonCalculationBase>(CompareItemCalculations)); ItemCalculations = itemCalculations.ToArray(); } }
public void LoadGearBySlot(Character.CharacterSlot slot) { Calculations.ClearCache(); List <ComparisonCalculationBase> itemCalculations = new List <ComparisonCalculationBase>(); if (Items != null && Character != null) { foreach (Item item in Items) { if (item.FitsInSlot(slot)) { itemCalculations.Add(Calculations.GetItemCalculations(item, Character, slot)); } } } comparisonGraph1.RoundValues = true; comparisonGraph1.CustomRendered = false; comparisonGraph1.ItemCalculations = itemCalculations.ToArray(); comparisonGraph1.EquipSlot = slot == Character.CharacterSlot.Gems || slot == Character.CharacterSlot.Metas ? Character.CharacterSlot.None : slot; }
public bool FitsInSlot(Character.CharacterSlot charSlot) { //And if I fell with all the strength I held inside... switch (charSlot) { case Character.CharacterSlot.Head: return(this.Slot == ItemSlot.Head); case Character.CharacterSlot.Neck: return(this.Slot == ItemSlot.Neck); case Character.CharacterSlot.Shoulders: return(this.Slot == ItemSlot.Shoulders); case Character.CharacterSlot.Back: return(this.Slot == ItemSlot.Back); case Character.CharacterSlot.Chest: return(this.Slot == ItemSlot.Chest); case Character.CharacterSlot.Shirt: return(this.Slot == ItemSlot.Shirt); case Character.CharacterSlot.Tabard: return(this.Slot == ItemSlot.Tabard); case Character.CharacterSlot.Wrist: return(this.Slot == ItemSlot.Wrist); case Character.CharacterSlot.Hands: return(this.Slot == ItemSlot.Hands); case Character.CharacterSlot.Waist: return(this.Slot == ItemSlot.Waist); case Character.CharacterSlot.Legs: return(this.Slot == ItemSlot.Legs); case Character.CharacterSlot.Feet: return(this.Slot == ItemSlot.Feet); case Character.CharacterSlot.Finger1: case Character.CharacterSlot.Finger2: return(this.Slot == ItemSlot.Finger); case Character.CharacterSlot.Trinket1: case Character.CharacterSlot.Trinket2: return(this.Slot == ItemSlot.Trinket); case Character.CharacterSlot.MainHand: return(this.Slot == ItemSlot.TwoHand || this.Slot == ItemSlot.OneHand || this.Slot == ItemSlot.MainHand); case Character.CharacterSlot.OffHand: return(this.Slot == ItemSlot.OneHand || this.Slot == ItemSlot.OffHand); case Character.CharacterSlot.Ranged: return(this.Slot == ItemSlot.Ranged); case Character.CharacterSlot.Projectile: return(this.Slot == ItemSlot.Projectile); case Character.CharacterSlot.ProjectileBag: return(this.Slot == ItemSlot.ProjectileBag); case Character.CharacterSlot.Gems: return(this.Slot == ItemSlot.Red || this.Slot == ItemSlot.Blue || this.Slot == ItemSlot.Yellow || this.Slot == ItemSlot.Purple || this.Slot == ItemSlot.Green || this.Slot == ItemSlot.Orange || this.Slot == ItemSlot.Prismatic); case Character.CharacterSlot.Metas: return(this.Slot == ItemSlot.Meta); default: return(false); } //I wouldn't be out here... alone tonight }
public void Show(Item item, Character.CharacterSlot equipSlot, bool allowDelete) { Show(item, equipSlot, null, allowDelete); }
public void LoadAvailableGear(CharacterCalculationsBase currentCalculations) { List <ComparisonCalculationBase> itemCalculations = new List <ComparisonCalculationBase>(); SortedList <Item.ItemSlot, Character.CharacterSlot> slotMap = new SortedList <Item.ItemSlot, Character.CharacterSlot>(); if (Items != null && Character != null) { SortedList <string, Item> items = new SortedList <string, Item>(); float Finger1 = (Character[Character.CharacterSlot.Finger1] == null ? 0 : Calculations.GetItemCalculations( Character[Character.CharacterSlot.Finger1], Character, Character.CharacterSlot.Finger1).OverallPoints); float Finger2 = (Character[Character.CharacterSlot.Finger2] == null ? 0 : Calculations.GetItemCalculations( Character[Character.CharacterSlot.Finger2], Character, Character.CharacterSlot.Finger2).OverallPoints); float Trinket1 = (Character[Character.CharacterSlot.Trinket1] == null ? 0 : Calculations.GetItemCalculations( Character[Character.CharacterSlot.Trinket1], Character, Character.CharacterSlot.Trinket1).OverallPoints); float Trinket2 = (Character[Character.CharacterSlot.Trinket2] == null ? 0 : Calculations.GetItemCalculations( Character[Character.CharacterSlot.Trinket2], Character, Character.CharacterSlot.Trinket2).OverallPoints); if (Finger2 < Finger1) { slotMap[Item.ItemSlot.Finger] = Character.CharacterSlot.Finger2; } if (Trinket2 < Trinket1) { slotMap[Item.ItemSlot.Trinket] = Character.CharacterSlot.Trinket2; } float MainHand = (Character[Character.CharacterSlot.MainHand] == null ? 0 : Calculations.GetItemCalculations( Character[Character.CharacterSlot.MainHand], Character, Character.CharacterSlot.MainHand).OverallPoints); float OffHand = (Character[Character.CharacterSlot.OffHand] == null ? 0 : Calculations.GetItemCalculations( Character[Character.CharacterSlot.OffHand], Character, Character.CharacterSlot.OffHand).OverallPoints); if (MainHand > OffHand) { slotMap[Item.ItemSlot.OneHand] = Character.CharacterSlot.OffHand; } foreach (Item relevantItem in ItemCache.RelevantItems) { try { Item.ItemSlot iSlot = relevantItem.Slot; Character.CharacterSlot slot; if (slotMap.ContainsKey(iSlot)) { slot = slotMap[iSlot]; } else { slot = Item.DefaultSlotMap[iSlot]; } if (slot != Character.CharacterSlot.None) { ComparisonCalculationBase slotCalc; Item currentItem = Character[slot]; if (currentItem == null) { slotCalc = Calculations.CreateNewComparisonCalculation(); } else { slotCalc = Calculations.GetItemCalculations(currentItem, Character, slot); } foreach (Item item in ItemCache.Instance.FindAllItemsById(relevantItem.Id)) { if (!items.ContainsKey(item.GemmedId) && (currentItem == null || currentItem.GemmedId != item.GemmedId)) { if (currentItem != null && currentItem.Unique) { Character.CharacterSlot otherSlot = Character.CharacterSlot.None; switch (slot) { case Character.CharacterSlot.Finger1: otherSlot = Character.CharacterSlot.Finger2; break; case Character.CharacterSlot.Finger2: otherSlot = Character.CharacterSlot.Finger1; break; case Character.CharacterSlot.Trinket1: otherSlot = Character.CharacterSlot.Trinket2; break; case Character.CharacterSlot.Trinket2: otherSlot = Character.CharacterSlot.Trinket1; break; case Character.CharacterSlot.MainHand: otherSlot = Character.CharacterSlot.OffHand; break; case Character.CharacterSlot.OffHand: otherSlot = Character.CharacterSlot.MainHand; break; } if (otherSlot != Character.CharacterSlot.None && Character[otherSlot] != null && Character[otherSlot].Id == item.Id) { continue; } } ComparisonCalculationBase itemCalc = Calculations.GetItemCalculations(item, Character, slot); bool include = false; for (int i = 0; i < itemCalc.SubPoints.Length; i++) { itemCalc.SubPoints[i] -= slotCalc.SubPoints[i]; include |= itemCalc.SubPoints[i] > 0; } itemCalc.OverallPoints -= slotCalc.OverallPoints; if (itemCalc.OverallPoints > 0) { itemCalculations.Add(itemCalc); } items[item.GemmedId] = item; } } } } catch (Exception) { } } } comparisonGraph1.RoundValues = true; comparisonGraph1.CustomRendered = false; comparisonGraph1.DisplayMode = ComparisonGraph.GraphDisplayMode.Overall; comparisonGraph1.ItemCalculations = itemCalculations.ToArray(); comparisonGraph1.EquipSlot = Character.CharacterSlot.AutoSelect; comparisonGraph1.SlotMap = slotMap; }
public virtual ComparisonCalculationBase GetItemCalculations(Item item, Character character, Character.CharacterSlot slot) { bool useCache = character == _cachedCharacter && slot == _cachedSlot; Character characterWithSlotEmpty = null; if (!useCache) { characterWithSlotEmpty = character.Clone(); } Character characterWithNewItem = character.Clone(); if (slot != Character.CharacterSlot.Metas && slot != Character.CharacterSlot.Gems) { if (!useCache) { characterWithSlotEmpty[slot] = null; } characterWithNewItem[slot] = item; } CharacterCalculationsBase characterStatsWithSlotEmpty; if (useCache) { characterStatsWithSlotEmpty = _cachedCharacterStatsWithSlotEmpty; } else { characterStatsWithSlotEmpty = GetCharacterCalculations(characterWithSlotEmpty); _cachedCharacter = character; _cachedSlot = slot; _cachedCharacterStatsWithSlotEmpty = characterStatsWithSlotEmpty; } Item additionalItem = null; if (item.FitsInSlot(Character.CharacterSlot.Gems) || item.FitsInSlot(Character.CharacterSlot.Metas)) { additionalItem = item; } CharacterCalculationsBase characterStatsWithNewItem = GetCharacterCalculations(characterWithNewItem, additionalItem); ComparisonCalculationBase itemCalc = CreateNewComparisonCalculation(); itemCalc.Item = item; itemCalc.Name = item.Name; itemCalc.Equipped = character[slot] == item; itemCalc.OverallPoints = characterStatsWithNewItem.OverallPoints - characterStatsWithSlotEmpty.OverallPoints; float[] subPoints = new float[characterStatsWithNewItem.SubPoints.Length]; for (int i = 0; i < characterStatsWithNewItem.SubPoints.Length; i++) { subPoints[i] = characterStatsWithNewItem.SubPoints[i] - characterStatsWithSlotEmpty.SubPoints[i]; } itemCalc.SubPoints = subPoints; characterStatsWithNewItem.ToString(); return(itemCalc); }
public virtual void ClearCache() { _cachedCharacterStatsWithSlotEmpty = null; _cachedCharacter = null; _cachedSlot = Character.CharacterSlot.Shirt; }
public static ComparisonCalculationBase GetItemCalculations(Item item, Character character, Character.CharacterSlot slot) { return(Instance.GetItemCalculations(item, character, slot)); }