Exemplo n.º 1
0
 void _optimizer_ComputeUpgradesCompleted(object sender, ComputeUpgradesCompletedEventArgs e)
 {
     buttonCancel.DialogResult = DialogResult.Cancel;
     if (e.Cancelled)
     {
         labelMax.Text                        = string.Empty;
         buttonUpgrades.Text                  = "Build Upgrade List";
         buttonCancel.Text                    = "Close";
         buttonOptimize.Enabled               = buttonUpgrades.Enabled = checkBoxOverrideRegem.Enabled = checkBoxOverrideReenchant.Enabled =
             trackBarThoroughness.Enabled     = checkBoxMixology.Enabled = checkBoxOptimizeElixir.Enabled =
                 checkBoxOptimizeFood.Enabled = checkBoxOptimizeTalents.Enabled = checkBoxMutateTalents.Enabled =
                     comboBoxCalculationToOptimize.Enabled = true;
         foreach (Control ctrl in groupBoxRequirements.Controls)
         {
             ctrl.Enabled = true;
         }
         progressBarAlt.Value = progressBarMain.Value = 0;
     }
     else
     {
         progressBarAlt.Value = progressBarMain.Value = 100;
         FormUpgradeComparison.Instance.LoadData(e.Upgrades, null);
         ShowUpgradeComparison = true;
         Close();
     }
 }
Exemplo n.º 2
0
 private void optimizer_ComputeUpgradesCompleted(object sender, ComputeUpgradesCompletedEventArgs e)
 {
     if (e.Cancelled)
     {
         ControlsEnabled(true);
     }
     else
     {
         AltProgress.Value = MainProgress.Value = 100;
         UpgradesComparison upgrades = new UpgradesComparison(e.Upgrades, null);
         Close();
         upgrades.Show();
     }
 }
Exemplo n.º 3
0
 void _optimizer_ComputeUpgradesCompleted(object sender, ComputeUpgradesCompletedEventArgs e)
 {
     buttonCancel.DialogResult = DialogResult.Cancel;
     if (e.Cancelled)
     {
         labelMax.Text                    = string.Empty;
         buttonUpgrades.Text              = "Build Upgrade List";
         buttonOptimize.Enabled           = buttonUpgrades.Enabled = checkBoxOverrideRegem.Enabled = checkBoxOverrideReenchant.Enabled =
             trackBarThoroughness.Enabled = true;
         progressBarAlt.Value             = progressBarMain.Value = 0;
     }
     else
     {
         progressBarAlt.Value = progressBarMain.Value = 100;
         FormUpgradeComparison.Instance.LoadData(_character, e.Upgrades, null);
         FormUpgradeComparison.Instance.Show();
         Close();
         //FormUpgradeComparison.Instance.BringToFront();
     }
 }
Exemplo n.º 4
0
 void _optimizer_ComputeUpgradesCompleted(object sender, ComputeUpgradesCompletedEventArgs e)
 {
     switch (currentOperation)
     {
         case AsyncOperation.BuildUpgradeList:
             if (e.Cancelled || e.Error != null)
             {
                 currentOperation = AsyncOperation.None;
                 UpdateStatusLabel();
                 if (OperationCompleted != null)
                 {
                     OperationCompleted(this, EventArgs.Empty);
                 }
                 break;
             }
             if (upgradeListPhase == 0)
             {
                 foreach (KeyValuePair<CharacterSlot, List<ComparisonCalculationUpgrades>> kvp in e.Upgrades)
                 {
                     Dictionary<string, UpgradeEntry> map;
                     if (!upgradeList.TryGetValue(kvp.Key, out map))
                     {
                         map = new Dictionary<string, UpgradeEntry>();
                         upgradeList[kvp.Key] = map;
                     }
                     foreach (ComparisonCalculationBase comp in kvp.Value)
                     {
                         string key = comp.ItemInstance.GemmedId;
                         UpgradeEntry upgradeEntry;
                         if (!map.TryGetValue(key, out upgradeEntry))
                         {
                             upgradeEntry = new UpgradeEntry();
                             upgradeEntry.Item = comp.ItemInstance;
                             map[key] = upgradeEntry;
                         }
                     }
                 }
                 do
                 {
                     batchIndex++;
                 } while (batchIndex < BatchCharacterList.Count && CurrentBatchCharacter.Character == null);
                 if (batchIndex < BatchCharacterList.Count)
                 {
                     ComputeUpgradesCurrentBatchCharacter();
                 }
                 else
                 {
                     upgradeListPhase = 1;
                     batchIndex = 0;
                     upgradeListEnumerator = GetUpgradeListEnumerator();
                     if (upgradeListEnumerator.MoveNext())
                     {
                         EvaluateUpgradeCurrentBatchCharacter(true);
                     }
                     else
                     {
                         // upgrade list is empty, abort
                         currentOperation = AsyncOperation.None;
                         UpdateStatusLabel();
                         if (OperationCompleted != null)
                         {
                             OperationCompleted(this, EventArgs.Empty);
                         }
                         break;
                     }
                 }
             }
             break;
         case AsyncOperation.BuildProgressiveUpgradeList:
             {
                 if (e.Cancelled || e.Error != null)
                 {
                     currentOperation = AsyncOperation.None;
                     UpdateStatusLabel();
                     if (OperationCompleted != null)
                     {
                         OperationCompleted(this, EventArgs.Empty);
                     }
                     break;
                 }
                 ComparisonCalculationUpgrades bestComp = null;
                 foreach (KeyValuePair<CharacterSlot, List<ComparisonCalculationUpgrades>> kvp in e.Upgrades)
                 {
                     if (kvp.Value.Count > 0 && kvp.Value[0].OverallPoints > (bestComp != null ? bestComp.OverallPoints : 0))
                     {
                         bestComp = kvp.Value[0];
                     }
                 }
                 SuffixItem item = itemList[itemIndex];
                 CharacterSlot slot = Character.GetCharacterSlotByItemSlot(item.Item.Slot);
                 Dictionary<string, UpgradeEntry> map;
                 if (!upgradeList.TryGetValue(slot, out map))
                 {
                     map = new Dictionary<string, UpgradeEntry>();
                     upgradeList[slot] = map;
                 }
                 string key = item.SuffixId;
                 UpgradeEntry upgradeEntry;
                 if (!map.TryGetValue(key, out upgradeEntry))
                 {
                     upgradeEntry = new UpgradeEntry();
                     map[key] = upgradeEntry;
                 }
                 if (bestComp != null)
                 {
                     upgradeListPhase = 1; // item was used, from now on we do evaluate upgrade on specific item instance only
                     optimizedItemInstance = bestComp.ItemInstance;
                     // make item restrictions based on best character
                     itemGenerator.AddItemRestrictions(bestComp.CharacterItems, workingCharacter.CurrentCalculations.IncludeOffHandInCalculations(workingCharacter));
                     upgradeEntry.Item = bestComp.ItemInstance;
                     upgradeEntry.Value += bestComp.OverallPoints * CurrentBatchCharacter.Weight;
                     upgradeEntry.ValueList.Add(bestComp.OverallPoints);
                 }
                 else
                 {
                     // make item restrictions based on best character without using the item
                     itemGenerator.AddItemRestrictions(workingCharacter);
                     // with the addition of support for multiples of the same item the semantics of this changes
                     // we now treat the upgrade as completely separate item, so no need to restrict to it if it is used
                     // as that one is a separate instance
                     if (upgradeListPhase == 1)
                     {
                         upgradeEntry.Item = optimizedItemInstance;
                     }
                     upgradeEntry.ValueList.Add(0.0f);
                 }
                 // move to next character
                 do
                 {
                     batchIndex++;
                 } while (batchIndex < BatchCharacterList.Count && CurrentBatchCharacter.Character == null);
                 if (batchIndex < BatchCharacterList.Count)
                 {
                     if (upgradeListPhase == 0)
                     {
                         // so far we haven't made any changes yet
                         // we're working under assumption that the starting batch is valid i.e. an item will have the same gemming in all characters
                         int _thoroughness = Thoroughness;
                         workingCharacter = CurrentBatchCharacter.Character;
                         optimizer.InitializeItemCache(workingCharacter, CurrentBatchCharacter.Model, itemGenerator);
                         optimizer.ComputeUpgradesAsync(workingCharacter, _thoroughness, itemList[itemIndex]);
                     }
                     else
                     {
                         // 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);
                         if (ConsiderMultipleNewItems)
                         {
                             optimizer.ComputeUpgradesAsync(workingCharacter, _thoroughness, itemList[itemIndex]);
                         }
                         else
                         {
                             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;
     }
 }
Exemplo n.º 5
0
 void batchOptimizer_ComputeUpgradesCompleted(object sender, ComputeUpgradesCompletedEventArgs e)
 {
     batchOptimizer.ComputeUpgradesProgressChanged -= new ComputeUpgradesProgressChangedEventHandler(batchOptimizer_ComputeUpgradesProgressChanged);
     batchOptimizer.ComputeUpgradesCompleted -= new ComputeUpgradesCompletedEventHandler(batchOptimizer_ComputeUpgradesCompleted);
     currentOperation = AsyncOperation.None;
     UpdateStatusLabel();
     if (OperationCompleted != null)
     {
         OperationCompleted(this, EventArgs.Empty);
     }
     if (!e.Cancelled)
     {
         CustomSubpoints = null;
         Upgrades = e.Upgrades;
         if (UpgradeListCompleted != null)
         {
             UpgradeListCompleted(this, EventArgs.Empty);
         }
     }
 }
Exemplo n.º 6
0
 private void optimizer_ComputeUpgradesCompleted(object sender, ComputeUpgradesCompletedEventArgs e)
 {
     if (e.Cancelled) ControlsEnabled(true);
     else
     {
         AltProgress.Value = MainProgress.Value = 100;
         UpgradesComparison upgrades = new UpgradesComparison(e.Upgrades, null);
         Close();
         upgrades.Show();
     }
 }
Exemplo n.º 7
0
 void _optimizer_ComputeUpgradesCompleted(object sender, ComputeUpgradesCompletedEventArgs e)
 {
     switch (currentOperation)
     {
     case AsyncOperation.BuildUpgradeList:
         if (e.Cancelled || e.Error != null)
         {
             currentOperation        = AsyncOperation.None;
             buttonCancel.Enabled    = false;
             statusLabel.Text        = "";
             statusProgressBar.Value = 0;
             break;
         }
         if (upgradeListPhase == 0)
         {
             foreach (KeyValuePair <Character.CharacterSlot, List <ComparisonCalculationBase> > kvp in e.Upgrades)
             {
                 Dictionary <string, UpgradeEntry> map;
                 if (!upgradeList.TryGetValue(kvp.Key, out map))
                 {
                     map = new Dictionary <string, UpgradeEntry>();
                     upgradeList[kvp.Key] = map;
                 }
                 foreach (ComparisonCalculationBase comp in kvp.Value)
                 {
                     string       key = comp.Item.GemmedId + "." + ((comp.Enchant == null) ? "0" : comp.Enchant.Id.ToString());
                     UpgradeEntry upgradeEntry;
                     if (!map.TryGetValue(key, out upgradeEntry))
                     {
                         upgradeEntry         = new UpgradeEntry();
                         upgradeEntry.Item    = comp.Item;
                         upgradeEntry.Enchant = comp.Enchant;
                         map[key]             = upgradeEntry;
                     }
                 }
             }
             do
             {
                 batchIndex++;
             } while (batchIndex < BatchCharacterList.Count && CurrentBatchCharacter.Character == null);
             if (batchIndex < BatchCharacterList.Count)
             {
                 ComputeUpgradesCurrentBatchCharacter();
             }
             else
             {
                 upgradeListPhase      = 1;
                 batchIndex            = 0;
                 upgradeListEnumerator = GetUpgradeListEnumerator();
                 if (upgradeListEnumerator.MoveNext())
                 {
                     EvaluateUpgradeCurrentBatchCharacter(true);
                 }
                 else
                 {
                     // upgrade list is empty, abort
                     currentOperation        = AsyncOperation.None;
                     buttonCancel.Enabled    = false;
                     statusLabel.Text        = "";
                     statusProgressBar.Value = 0;
                     break;
                 }
             }
         }
         break;
     }
 }