Пример #1
0
        private async void SelectSaveDataPath_Click(object sender, RoutedEventArgs e)
        {
#if (!SQUIRREL)
            var dialog       = new FolderBrowserDialog();
            var dialogResult = dialog.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                var saveInAppData = Config.Instance.SaveDataInAppData.HasValue && Config.Instance.SaveDataInAppData.Value;
                if (!saveInAppData)
                {
                    foreach (var value in new List <bool> {
                        true, false
                    })
                    {
                        Config.Instance.SaveDataInAppData = value;
                        Helper.CopyReplayFiles();
                        DeckStatsList.SetupDeckStatsFile();
                        DeckList.SetupDeckListFile();
                        DefaultDeckStats.SetupDefaultDeckStatsFile();
                        Config.Instance.DataDirPath = dialog.SelectedPath;
                    }
                }
                Config.Instance.DataDirPath = dialog.SelectedPath;
                Config.Save();
                if (!saveInAppData)
                {
                    await MessageDialogs.ShowMessage(Core.MainWindow, "Restart required.", "Click ok to restart HDT");

                    Core.MainWindow.Restart();
                }
            }
#endif
        }
Пример #2
0
        private async void ButtonHearthstoneLogsDirectory_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new FolderBrowserDialog();

            dialog.SelectedPath = Config.Instance.HearthstoneDirectory;
            var dialogResult = dialog.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                //Logs directory needs to be a child directory in Hearthstone directory
                if (!dialog.SelectedPath.StartsWith(Config.Instance.HearthstoneDirectory + @"\"))
                {
                    await MessageDialogs.ShowMessage(Core.MainWindow, "Invalid argument", "Selected directory not in Hearthstone directory!");

                    return;
                }

                //Check if same path selected (no restart required)
                if (Config.Instance.HearthstoneLogsDirectoryName.Equals(dialog.SelectedPath))
                {
                    return;
                }

                Config.Instance.HearthstoneLogsDirectoryName = dialog.SelectedPath.Remove(0, Config.Instance.HearthstoneDirectory.Length + 1);
                Config.Save();

                await MessageDialogs.ShowMessage(Core.MainWindow, "Restart required.", "Click ok to restart HDT");

                Core.MainWindow.Restart();
            }
        }
        private void ButtonHSReplaynet_Click(object sender, RoutedEventArgs e)
        {
            var url = Helper.BuildHsReplayNetUrl("premium", "updatenotes");

            if (!Helper.TryOpenUrl(url))
            {
                MessageDialogs.ShowMessage(Core.MainWindow, "Could not start your browser", "You can find our premium page at https://hsreplay.net/premium/").Forget();
            }
        }
        private async void OnHearthMirroCheckFailed()
        {
            await Stop(true);

            Core.MainWindow.ActivateWindow();
            while (Core.MainWindow.Visibility != Visibility.Visible || Core.MainWindow.WindowState == WindowState.Minimized)
            {
                await Task.Delay(100);
            }
            await MessageDialogs.ShowMessage(Core.MainWindow, "Uneven permissions",
                                             "It appears that Hearthstone (Battle.net) and HDT do not have the same permissions.\n\nPlease run both as administrator or local user.\n\nIf you don't know what any of this means, just run HDT as administrator.");
        }
        private void DockPanel_Drop(object sender, DragEventArgs e)
        {
            var dir       = PluginManager.PluginDirectory.FullName;
            var prevCount = PluginManager.Instance.Plugins.Count;

            try
            {
                if (e.Data.GetDataPresent(DataFormats.FileDrop))
                {
                    var plugins      = 0;
                    var droppedFiles = (string[])e.Data.GetData(DataFormats.FileDrop);
                    if (droppedFiles == null)
                    {
                        return;
                    }
                    foreach (var pluginPath in droppedFiles)
                    {
                        if (pluginPath.EndsWith(".dll"))
                        {
                            File.Copy(pluginPath, Path.Combine(dir, Path.GetFileName(pluginPath)), true);
                            plugins++;
                        }
                        else if (pluginPath.EndsWith(".zip"))
                        {
                            var path = Path.Combine(dir, Path.GetFileNameWithoutExtension(pluginPath));
                            ZipFile.ExtractToDirectory(pluginPath, path);
                            if (Directory.GetDirectories(path).Length == 1 && Directory.GetFiles(path).Length == 0)
                            {
                                Directory.Delete(path, true);
                                ZipFile.ExtractToDirectory(pluginPath, dir);
                            }
                            plugins++;
                        }
                    }
                    if (plugins <= 0)
                    {
                        return;
                    }
                    PluginManager.Instance.LoadPlugins(PluginManager.Instance.SyncPlugins());
                    if (prevCount == 0)
                    {
                        ListBoxPlugins.SelectedIndex = 0;
                        GroupBoxDetails.Visibility   = Visibility.Visible;
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                MessageDialogs.ShowMessage(Core.MainWindow, "Error Importing Plugin", $"Please import manually to {dir}.").Forget();
            }
        }
Пример #6
0
        private void ButtonGamePath_OnClick(object sender, RoutedEventArgs e)
        {
            var dialog = new FolderBrowserDialog {
                Description = "Select your Hearthstone Directory", ShowNewFolderButton = false
            };
            var dialogResult = dialog.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                Config.Instance.HearthstoneDirectory = dialog.SelectedPath;
                Config.Save();
                MessageDialogs.ShowMessage(Core.MainWindow, "Restart required.", "Please restart HDT for this setting to take effect.").Forget();
            }
        }
Пример #7
0
        private async void CheckboxDataSaveAppData_Unchecked(object sender, RoutedEventArgs e)
        {
#if (!SQUIRREL)
            if (!_initialized)
            {
                return;
            }
            Config.Instance.SaveDataInAppData = false;
            Config.Save();
            await MessageDialogs.ShowMessage(Core.MainWindow, "Restart required.", "Click ok to restart HDT");

            Core.MainWindow.Restart();
#endif
        }
Пример #8
0
        private async void CheckboxConfigSaveAppData_Unchecked(object sender, RoutedEventArgs e)
        {
#if (!SQUIRREL)
            if (!_initialized)
            {
                return;
            }
            var path = Config.Instance.ConfigPath;
            Config.Instance.SaveConfigInAppData = false;
            XmlManager <Config> .Save(path, Config.Instance);

            await MessageDialogs.ShowMessage(Core.MainWindow, "Restart required.", "Click ok to restart HDT");

            Core.MainWindow.Restart();
#endif
        }
        private static void ShowDeckSelectionDialog(List <Deck> decks)
        {
            decks.Add(new Deck("Use no deck", "", new List <Card>(), new List <string>(), "", "", DateTime.Now, false, new List <Card>(),
                               SerializableVersion.Default, new List <Deck>(), Guid.Empty));
            if (decks.Count == 1 && DeckList.Instance.ActiveDeck != 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>(), Guid.Empty));
            }
            _waitingForUserInput = true;
            Log.Info("Waiting for user input...");
            var dsDialog = new DeckSelectionDialog(decks);

            dsDialog.ShowDialog();

            var selectedDeck = dsDialog.SelectedDeck;

            if (selectedDeck != null)
            {
                if (selectedDeck.Name == "Use no deck")
                {
                    Log.Info("Auto deck detection disabled.");
                    Core.MainWindow.SelectDeck(null, true);
                    NotFoundCards.Clear();
                }
                else if (selectedDeck.Name == "No match - Keep using active deck")
                {
                    IgnoredDeckId = DeckList.Instance.ActiveDeck?.DeckId ?? Guid.Empty;
                    Log.Info($"Now ignoring {DeckList.Instance.ActiveDeck?.Name}");
                    NotFoundCards.Clear();
                }
                else
                {
                    Log.Info("Selected deck: " + selectedDeck.Name);
                    Core.MainWindow.SelectDeck(selectedDeck, true);
                }
            }
            else
            {
                Log.Info("Auto deck detection disabled.");
                MessageDialogs.ShowMessage(Core.MainWindow, "Auto deck selection disabled.", "This can be re-enabled under 'options (advanced) > tracker > general'.").Forget();
                Config.Instance.AutoDeckDetection = false;
                Config.Save();
                Core.MainWindow.AutoDeckDetection(false);
            }
            _waitingForUserInput = false;
        }
        private void ButtonOpenPluginsFolder_OnClick(object sender, RoutedEventArgs e)
        {
            var dir = PluginManager.PluginDirectory;

            if (!dir.Exists)
            {
                try
                {
                    dir.Create();
                }
                catch (Exception)
                {
                    MessageDialogs.ShowMessage(Core.MainWindow, "Error",
                                               $"Plugins directory was not found and can not be created. Please manually create a folder called 'Plugins' under {dir}.").Forget();
                }
            }
            Helper.TryOpenUrl(dir.FullName);
        }
Пример #11
0
        private async void ButtonRestore_Click(object sender, RoutedEventArgs e)
        {
            var selected = ListBoxBackups.SelectedItem as BackupFile;

            if (selected == null)
            {
                return;
            }
            var result =
                await
                DialogManager.ShowMessageAsync(Core.MainWindow, "Restore backup " + selected.DisplayName,
                                               "This can not be undone! Make sure you have a current backup (if necessary). To create one, CANCEL and click \"CREATE NEW\".",
                                               MessageDialogStyle.AffirmativeAndNegative);

            if (result != MessageDialogResult.Affirmative)
            {
                return;
            }
            BackupManager.Restore(selected.FileInfo, true);
            MessageDialogs.ShowMessage(Core.MainWindow, "Success", "Please restart HDT for this to take effect.").Forget();
        }