Example #1
0
        private void NameGrid_MouseEnter(object sender, MouseEventArgs e)
        {
            ComparisonCalculationBase calc = ((Grid)sender).Tag as ComparisonCalculationBase;

            if ((calc.Description != null || calc.ItemInstance != null || calc.Item != null) && (!ContextMenuService.GetContextMenu(((Grid)sender)).IsOpen))
            {
                if (calc.ItemInstance != null)
                {
                    MainPage.Tooltip.ItemInstance = calc.ItemInstance;
                }
                else if (calc.Item != null)
                {
                    MainPage.Tooltip.Item = calc.Item;
                }
                else if (calc.ItemSet != null)
                {
                    MainPage.Tooltip.ItemSet = calc.ItemSet; MainPage.Tooltip.CurrentString = calc.Name + "|" + calc.Description;
                }
                else
                {
                    MainPage.Tooltip.CurrentString = calc.Name + "|" + calc.Description;
                }
                if (calc is ComparisonCalculationUpgrades)
                {
                    ComparisonCalculationUpgrades upgrades = calc as ComparisonCalculationUpgrades;
                    MainPage.Tooltip.CharacterItems = upgrades.CharacterItems;
                }
                MainPage.Tooltip.Show((Grid)sender, 162 + Rawr.Properties.GeneralSettings.Default.ItemNameWidthSetting * 20 + 1, 2);
            }
        }
Example #2
0
 public void RemoveItem(ItemInstance item)
 {
     string[] keys = new string[_itemCalculations.Keys.Count];
     _itemCalculations.Keys.CopyTo(keys, 0);
     foreach (string slot in keys)
     {
         List <ComparisonCalculationUpgrades> slotItems = new List <ComparisonCalculationUpgrades>(
             _itemCalculations[slot]);
         ComparisonCalculationUpgrades existing = slotItems.Find(ccu => ccu.ItemInstance.GemmedId == item.GemmedId);
         if (existing != null)
         {
             slotItems.Remove(existing);
         }
         _itemCalculations[slot] = slotItems.ToArray();
     }
     comparisonGraph1.ItemCalculations = _itemCalculations[_currentSlot];
 }
Example #3
0
        void _optimizer_EvaluateUpgradeCompleted(object sender, EvaluateUpgradeCompletedEventArgs e)
        {
            switch (currentOperation)
            {
                case AsyncOperation.BuildUpgradeList:
                    upgradeListEnumerator.Current.Value += e.UpgradeValue * CurrentBatchCharacter.Weight;
                    upgradeListEnumerator.Current.ValueList.Add(e.UpgradeValue);
                    if (upgradeListEnumerator.MoveNext())
                    {
                        EvaluateUpgradeCurrentBatchCharacter(false);
                    }
                    else
                    {
                        do
                        {
                            batchIndex++;
                        } while (batchIndex < BatchCharacterList.Count && CurrentBatchCharacter.Character == null);
                        if (batchIndex < BatchCharacterList.Count)
                        {
                            upgradeListEnumerator = GetUpgradeListEnumerator();
                            upgradeListEnumerator.MoveNext();
                            EvaluateUpgradeCurrentBatchCharacter(true);
                        }
                        else
                        {
                            currentOperation = AsyncOperation.None;
                            UpdateStatusLabel();
                            if (OperationCompleted != null)
                            {
                                OperationCompleted(this, EventArgs.Empty);
                            }

                            float totalValue = 0f;
                            foreach (BatchCharacter batchCharacter in BatchCharacterList)
                            {
                                if (batchCharacter.Character != null)
                                {
                                    totalValue += batchCharacter.Weight;
                                }
                            }

                            Dictionary<CharacterSlot, List<ComparisonCalculationUpgrades>> upgrades = new Dictionary<CharacterSlot, List<ComparisonCalculationUpgrades>>();

                            foreach (var kvp in upgradeList)
                            {
                                Dictionary<string, UpgradeEntry> filtered = new Dictionary<string, UpgradeEntry>();
                                foreach (UpgradeEntry entry in kvp.Value.Values)
                                {
                                    UpgradeEntry existingEntry;
                                    filtered.TryGetValue(entry.Item.SuffixId, out existingEntry);
                                    if (entry.Value > 0 && (existingEntry == null || entry.Value > existingEntry.Value))
                                    {
                                        filtered[entry.Item.SuffixId] = entry;
                                    }
                                }

                                upgrades[kvp.Key] = new List<ComparisonCalculationUpgrades>();
                                foreach (UpgradeEntry entry in filtered.Values)
                                {
                                    ComparisonCalculationUpgrades itemCalc = new ComparisonCalculationUpgrades();
                                    itemCalc.ItemInstance = entry.Item;
                                    itemCalc.CharacterItems = null;
                                    itemCalc.Name = entry.Item.Name;
                                    itemCalc.Equipped = false;
                                    itemCalc.OverallPoints = entry.Value / totalValue;
                                    itemCalc.SubPoints = entry.ValueList.ToArray();

                                    upgrades[kvp.Key].Add(itemCalc);                                    
                                }
                            }
                            List<string> customSubpoints = new List<string>();
                            foreach (BatchCharacter batchCharacter in BatchCharacterList)
                            {
                                customSubpoints.Add(batchCharacter.Name);
                            }
                            Upgrades = upgrades;
                            CustomSubpoints = customSubpoints.ToArray();
                            if (UpgradeListCompleted != null)
                            {
                                UpgradeListCompleted(this, EventArgs.Empty);
                            }
                        }
                    }
                    break;
                case AsyncOperation.BuildProgressiveUpgradeList:
                    if (e.Cancelled || e.Error != null)
                    {
                        currentOperation = AsyncOperation.None;
                        UpdateStatusLabel();
                        if (OperationCompleted != null)
                        {
                            OperationCompleted(this, EventArgs.Empty);
                        }
                        break;
                    }
                    CharacterSlot slot = Character.GetCharacterSlotByItemSlot(optimizedItemInstance.Slot);
                    Dictionary<string, UpgradeEntry> map;
                    if (!upgradeList.TryGetValue(slot, out map))
                    {
                        map = new Dictionary<string, UpgradeEntry>();
                        upgradeList[slot] = map;
                    }
                    string key = optimizedItemInstance.SuffixId;
                    UpgradeEntry upgradeEntry;
                    if (!map.TryGetValue(key, out upgradeEntry))
                    {
                        upgradeEntry = new UpgradeEntry();
                        upgradeEntry.Item = optimizedItemInstance;
                        map[key] = upgradeEntry;
                    }
                    if (e.UpgradeValue > 0)
                    {
                        // make item restrictions based on best character
                        itemGenerator.AddItemRestrictions(e.Upgrade.CharacterItems, workingCharacter.CurrentCalculations.IncludeOffHandInCalculations(workingCharacter));
                        upgradeEntry.Value += e.UpgradeValue * CurrentBatchCharacter.Weight;
                        upgradeEntry.ValueList.Add(e.UpgradeValue);
                    }
                    else
                    {
                        // make item restrictions based on best character without using the item
                        itemGenerator.AddItemRestrictions(workingCharacter);
                        upgradeEntry.ValueList.Add(0.0f);
                    }
                    // move to next character
                    do
                    {
                        batchIndex++;
                    } while (batchIndex < BatchCharacterList.Count && CurrentBatchCharacter.Character == null);
                    if (batchIndex < BatchCharacterList.Count)
                    {                        
                        // we made item restrictions, first we have to optimize character without the item
                        int _thoroughness = Thoroughness;
                        workingCharacter = CurrentBatchCharacter.Character.Clone();
                        // regularize character with current item restrictions
                        itemGenerator.RegularizeCharacter(workingCharacter);
                        optimizer.InitializeItemCache(workingCharacter, CurrentBatchCharacter.Model, itemGenerator);
                        optimizer.OptimizeCharacterAsync(workingCharacter, _thoroughness, true);
                    }
                    else
                    {
                        // we finished all characters for this item
                        // move to next item
                        itemIndex++;
                        if (itemIndex < itemList.Length)
                        {
                            batchIndex = 0;
                            upgradeListPhase = 0;
                            int _thoroughness = Thoroughness;
                            // we have to reinitialize item generator because of the restrictions we made
                            //CreateBatchItemGenerator();
                            itemGenerator.RestoreAvailabilityInformation();
                            optimizer.InitializeItemCache(CurrentBatchCharacter.Character, CurrentBatchCharacter.Model, itemGenerator);
                            workingCharacter = CurrentBatchCharacter.Character;
                            optimizer.ComputeUpgradesAsync(CurrentBatchCharacter.Character, _thoroughness, itemList[itemIndex]);
                        }
                        else
                        {
                            // we're done
                            WrapUpProgressiveUpgradeList();
                        }
                    }
                    break;
            }
        }
Example #4
0
        void WrapUpProgressiveUpgradeList()
        {
            currentOperation = AsyncOperation.None;
            UpdateStatusLabel();
            if (OperationCompleted != null)
            {
                OperationCompleted(this, EventArgs.Empty);
            }

            float totalValue = 0f;
            foreach (BatchCharacter batchCharacter in BatchCharacterList)
            {
                if (batchCharacter.Character != null)
                {
                    totalValue += batchCharacter.Weight;
                }
            }

            Dictionary<CharacterSlot, List<ComparisonCalculationUpgrades>> upgrades = new Dictionary<CharacterSlot, List<ComparisonCalculationUpgrades>>();

            foreach (var kvp in upgradeList)
            {
                upgrades[kvp.Key] = new List<ComparisonCalculationUpgrades>();
                Dictionary<int, UpgradeEntry> filtered = new Dictionary<int, UpgradeEntry>();
                foreach (UpgradeEntry entry in kvp.Value.Values)
                {
                    if (entry.Value > 0)
                    {
                        ComparisonCalculationUpgrades itemCalc = new ComparisonCalculationUpgrades();
                        itemCalc.ItemInstance = entry.Item;
                        itemCalc.CharacterItems = null;
                        itemCalc.Name = entry.Item.Name;
                        itemCalc.Equipped = false;
                        itemCalc.OverallPoints = entry.Value / totalValue;
                        itemCalc.SubPoints = entry.ValueList.ToArray();

                        upgrades[kvp.Key].Add(itemCalc);
                    }
                }
            }
            List<string> customSubpoints = new List<string>();
            foreach (BatchCharacter batchCharacter in BatchCharacterList)
            {
                customSubpoints.Add(batchCharacter.Name);
            }
            CustomSubpoints = customSubpoints.ToArray();
            Upgrades = upgrades;
            if (UpgradeListCompleted != null)
            {
                UpgradeListCompleted(this, EventArgs.Empty);
            }
        }