Example #1
0
        /// <summary>
        /// Counts the number of files which LoadAllFiles will load.  Used to set the max value of the progress bar.
        /// </summary>
        /// <returns>Total number of files that LoadAllFiles() will load.</returns>
        private int LoadAllFilesTotal()
        {
            int numIT = GamePathResolver.GetCharacterList()?.Count() ?? 0;

            numIT = numIT * 2;            // Assuming that there is 1 stash file per character
            int numVaults = GamePathResolver.GetVaultList()?.Count() ?? 0;

            return(Math.Max(0, numIT + numVaults - 1));
        }
Example #2
0
        /// <summary>
        /// Counts the number of files which LoadAllFiles will load.  Used to set the max value of the progress bar.
        /// </summary>
        /// <returns>Total number of files that LoadAllFiles() will load.</returns>
        private int LoadAllFilesTotal()
        {
            string[] list;

            list = GamePathResolver.GetCharacterList();
            int numIT = list?.Length ?? 0;

            list = GamePathResolver.GetVaultList();
            int numVaults = list?.Length ?? 0;

            return(Math.Max(0, numIT + numVaults - 1));
        }
Example #3
0
        /// <summary>
        /// Gets a list of available player files and populates the drop down list.
        /// </summary>
        private void GetPlayerList()
        {
            // Initialize the character combo-box
            this.characterComboBox.Items.Clear();

            string[] charactersIT = GamePathResolver.GetCharacterList();

            int numIT = 0;

            if (charactersIT != null)
            {
                numIT = charactersIT.Length;
            }

            if (numIT == 0)
            {
                this.characterComboBox.Items.Add(Resources.MainFormNoCharacters);
                this.characterComboBox.SelectedIndex = 0;
            }
            else
            {
                this.characterComboBox.Items.Add(Resources.MainFormSelectCharacter);
                this.characterComboBox.SelectedIndex = 0;

                string characterDesignator = string.Empty;

                // Modified by VillageIdiot
                // Added to support custom Maps
                if (GamePathResolver.IsCustom)
                {
                    characterDesignator = string.Concat(characterDesignator, PlayerService.CustomDesignator);
                }

                string[] characters = charactersIT.Select(c => string.Concat(c, characterDesignator)).ToArray();
                this.characterComboBox.Items.AddRange(characters);
            }
        }
Example #4
0
        /// <summary>
        /// Loads all of the players, stashes, and vaults.
        /// Shows a progress dialog.
        /// Used for the searching function.
        /// </summary>
        private void LoadAllFiles()
        {
            // Check to see if we failed the last time we tried loading all of the files.
            // If we did fail then turn it off and skip it.
            if (!Config.Settings.Default.LoadAllFilesCompleted)
            {
                if (MessageBox.Show(
                        Resources.MainFormDisableLoadAllFiles,
                        Resources.MainFormDisableLoadAllFilesCaption,
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Information,
                        MessageBoxDefaultButton.Button1,
                        RightToLeftOptions) == DialogResult.Yes)
                {
                    Config.Settings.Default.LoadAllFilesCompleted = true;
                    Config.Settings.Default.LoadAllFiles          = false;
                    Config.Settings.Default.Save();
                    return;
                }
            }

            string[] vaults = GamePathResolver.GetVaultList();

            string[] charactersIT = GamePathResolver.GetCharacterList();

            int numIT = charactersIT?.Length ?? 0;

            int numVaults = vaults?.Length ?? 0;

            // Since this takes a while, show a progress dialog box.
            int total = numIT + numVaults - 1;

            if (total > 0)
            {
                // We were successful last time so we reset the flag for this attempt.
                Config.Settings.Default.LoadAllFilesCompleted = false;
                Config.Settings.Default.Save();
            }
            else
            {
                return;
            }

            // Load all of the Immortal Throne player files and stashes.
            for (int i = 0; i < numIT; ++i)
            {
                // Get the player & player's stash
                try
                {
                    var result = this.playerService.LoadPlayer(charactersIT[i], true);

                    if (result.PlayerArgumentException != null)
                    {
                        string msg = string.Format(CultureInfo.CurrentUICulture, "{0}\n{1}\n{2}", Resources.MainFormPlayerReadError, result.PlayerFile, result.PlayerArgumentException.Message);
                        MessageBox.Show(msg, Resources.GlobalError, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, RightToLeftOptions);
                    }
                    if (result.StashArgumentException != null)
                    {
                        string msg = string.Format(CultureInfo.CurrentUICulture, "{0}\n{1}\n{2}", Resources.MainFormPlayerReadError, result.StashFile, result.StashArgumentException.Message);
                        MessageBox.Show(msg, Resources.GlobalError, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, RightToLeftOptions);
                    }
                }
                catch (IOException exception)
                {
                    Log.ErrorException(exception);
                    MessageBox.Show(Log.FormatException(exception), Resources.GlobalError, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, RightToLeftOptions);
                }

                this.backgroundWorker1.ReportProgress(1);
            }

            // Load all of the vaults.
            for (int i = 0; i < numVaults; ++i)
            {
                var result = this.vaultService.LoadVault(vaults[i]);
                if (result.ArgumentException != null)
                {
                    string msg = string.Format(CultureInfo.CurrentUICulture, "{0}\n{1}\n{2}", Resources.MainFormPlayerReadError, result.Filename, result.ArgumentException.Message);
                    MessageBox.Show(msg, Resources.GlobalError, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, RightToLeftOptions);
                }

                this.backgroundWorker1.ReportProgress(1);
            }

            // We made it so set the flag to indicate we were successful.
            Config.Settings.Default.LoadAllFilesCompleted = true;
            Config.Settings.Default.Save();
        }