public void AutoDeckDetection(bool enable) { if (!_initialized) { return; } Config.Instance.AutoDeckDetection = enable; Config.Save(); DeckPickerList.UpdateAutoSelectToggleButton(); Core.TrayIcon.SetContextMenuProperty(TrayIcon.AutoSelectDeckMenuItemName, TrayIcon.CheckedProperty, enable); }
public async void ShowIncorrectDeckMessage() { if (Core.Game.Player.DrawnCards.Count == 0) { IsShowingIncorrectDeckMessage = false; return; } //wait for player hero to be detected and at least 3 cards to be drawn for (var i = 0; i < 50; i++) { if (Core.Game.Player.Class != null && Core.Game.Player.DrawnCards.Count >= 3) { break; } await Task.Delay(100); } if (string.IsNullOrEmpty(Core.Game.Player.Class) || Core.Game.Player.DrawnCards.Count < 3) { IsShowingIncorrectDeckMessage = false; Log.Info("No player hero detected or less then 3 cards drawn. Not showing dialog."); return; } await Task.Delay(1000); if (!NeedToIncorrectDeckMessage) { IsShowingIncorrectDeckMessage = false; return; } var decks = DeckList.Instance.Decks.Where( d => d.Class == Core.Game.Player.Class && !d.Archived && d.IsArenaRunCompleted != true && Core.Game.Player.DrawnCardIdsTotal.Distinct() .All(id => d.GetSelectedDeckVersion().Cards.Any(c => id == c.Id)) && Core.Game.Player.DrawnCards.All( c => d.GetSelectedDeckVersion() .Cards.Any(c2 => c2.Id == c.Id && c2.Count >= c.Count))).ToList(); Log.Info(decks.Count + " possible decks found."); Core.Game.NoMatchingDeck = decks.Count == 0; if (decks.Any(x => x == DeckList.Instance.ActiveDeck)) { Log.Info("Correct deck already selected."); IsShowingIncorrectDeckMessage = false; NeedToIncorrectDeckMessage = false; return; } if (decks.Count == 1 && Config.Instance.AutoSelectDetectedDeck) { var deck = decks.First(); Log.Info("Automatically selected deck: " + deck.Name); DeckPickerList.SelectDeck(deck); UpdateDeckList(deck); UseDeck(deck); } else { decks.Add(new Deck("Use no deck", "", new List <Card>(), new List <string>(), "", "", DateTime.Now, false, new List <Card>(), SerializableVersion.Default, new List <Deck>(), false, "", Guid.Empty, "")); if (decks.Count == 1 && DeckList.Instance.ActiveDeckVersion != null) { decks.Add(new Deck("No match - Keep using active deck", "", new List <Card>(), new List <string>(), "", "", DateTime.Now, false, new List <Card>(), SerializableVersion.Default, new List <Deck>(), false, "", Guid.Empty, "")); } var dsDialog = new DeckSelectionDialog(decks); dsDialog.ShowDialog(); var selectedDeck = dsDialog.SelectedDeck; if (selectedDeck != null) { if (selectedDeck.Name == "Use no deck") { SelectDeck(null, true); } else if (selectedDeck.Name == "No match - Keep using active deck") { Core.Game.IgnoreIncorrectDeck = DeckList.Instance.ActiveDeck; Log.Info($"Now ignoring {DeckList.Instance.ActiveDeck.Name} as an incorrect deck"); } else { Log.Info("Selected deck: " + selectedDeck.Name); DeckPickerList.SelectDeck(selectedDeck); UpdateDeckList(selectedDeck); UseDeck(selectedDeck); } } else { this.ShowMessage("Auto deck selection disabled.", "This can be re-enabled by selecting \"AUTO\" in the bottom right of the deck picker.").Forget(); DeckPickerList.UpdateAutoSelectToggleButton(); Config.Save(); } } IsShowingIncorrectDeckMessage = false; NeedToIncorrectDeckMessage = false; }
internal void LoadConfigSettings() { if (Config.Instance.TrackerWindowTop.HasValue) { Top = Config.Instance.TrackerWindowTop.Value; } if (Config.Instance.TrackerWindowLeft.HasValue) { Left = Config.Instance.TrackerWindowLeft.Value; } if (Config.Instance.WindowHeight < 0) { Config.Instance.Reset("WindowHeight"); } Height = Config.Instance.WindowHeight; if (Config.Instance.WindowWidth < 0) { Config.Instance.Reset("WindowWidth"); } Width = Config.Instance.WindowWidth; var titleBarCorners = new[] { new Point((int)Left + 5, (int)Top + 5), new Point((int)(Left + Width) - 5, (int)Top + 5), new Point((int)Left + 5, (int)(Top + TitlebarHeight) - 5), new Point((int)(Left + Width) - 5, (int)(Top + TitlebarHeight) - 5) }; if (!Screen.AllScreens.Any(s => titleBarCorners.Any(c => s.WorkingArea.Contains(c)))) { Top = 100; Left = 100; } if (Config.Instance.StartMinimized) { WindowState = WindowState.Minimized; if (Config.Instance.MinimizeToTray) { MinimizeToTray(); } } Options.Load(Core.Game); Help.TxtblockVersion.Text = "v" + Helper.GetCurrentVersion().ToVersionString(); Core.TrayIcon.SetContextMenuProperty("autoSelectDeck", "Checked", Config.Instance.AutoDeckDetection); // Don't select the 'archived' class on load var selectedClasses = Config.Instance.SelectedDeckPickerClasses.Where(c => c.ToString() != "Archived").ToList(); if (selectedClasses.Count == 0) { selectedClasses.Add(HeroClassAll.All); } DeckPickerList.SelectClasses(selectedClasses); DeckPickerList.SelectDeckType(Config.Instance.SelectedDeckPickerDeckType, true); DeckPickerList.UpdateAutoSelectToggleButton(); SortFilterDecksFlyout.LoadTags(DeckList.Instance.AllTags); SortFilterDecksFlyout.SetSelectedTags(Config.Instance.SelectedTags); TagControlEdit.LoadTags(DeckList.Instance.AllTags.Where(tag => tag != "All" && tag != "None").ToList()); SortFilterDecksFlyout.OperationSwitch.IsChecked = Config.Instance.TagOperation == TagFilerOperation.And; SortFilterDecksFlyout.ComboboxDeckSorting.SelectedItem = Config.Instance.SelectedDeckSorting; SortFilterDecksFlyout.CheckBoxSortByClass.IsChecked = Config.Instance.SortDecksByClass; SortFilterDecksFlyout.ComboboxDeckSortingArena.SelectedItem = Config.Instance.SelectedDeckSortingArena; SortFilterDecksFlyout.CheckBoxSortByClassArena.IsChecked = Config.Instance.SortDecksByClassArena; ManaCurveMyDecks.Visibility = Config.Instance.ManaCurveMyDecks ? Visibility.Visible : Visibility.Collapsed; Core.TrayIcon.SetContextMenuProperty("classCardsFirst", "Checked", Config.Instance.CardSortingClassFirst); Core.TrayIcon.SetContextMenuProperty("useNoDeck", "Checked", DeckList.Instance.ActiveDeck == null); MenuItemCheckBoxSyncOnStart.IsChecked = Config.Instance.HearthStatsSyncOnStart; MenuItemCheckBoxAutoUploadDecks.IsChecked = Config.Instance.HearthStatsAutoUploadNewDecks; MenuItemCheckBoxAutoUploadGames.IsChecked = Config.Instance.HearthStatsAutoUploadNewGames; MenuItemCheckBoxAutoSyncBackground.IsChecked = Config.Instance.HearthStatsAutoSyncInBackground; MenuItemCheckBoxAutoDeleteDecks.IsChecked = Config.Instance.HearthStatsAutoDeleteDecks; MenuItemCheckBoxAutoDeleteGames.IsChecked = Config.Instance.HearthStatsAutoDeleteMatches; }