Ejemplo n.º 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 static int LoadAllFilesTotal()
        {
            string[] list;

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

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

            return(Math.Max(0, numIT + numIT + numVaults - 1));
        }
Ejemplo n.º 2
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 = TQData.GetCharacterList();

            int numIT = 0;

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

            if (numIT < 1)
            {
                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 (TQData.IsCustom)
                {
                    characterDesignator = string.Concat(characterDesignator, "<Custom Map>");
                }

                // Combine the 2 arrays into 1 then add them
                string[] characters = new string[numIT];
                int      i;
                int      j = 0;

                // Put the IT chars first since that is most likely what people want to use.
                for (i = 0; i < numIT; ++i)
                {
                    characters[j++] = string.Concat(charactersIT[i], characterDesignator);
                }

                this.characterComboBox.Items.AddRange(characters);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets a list of available player files and populates the drop down list.
        /// </summary>
        private void GetPlayerList()
        {
            if (this.playerService is null)
            {
                this.playerService = new PlayerService(this.userContext);
            }

            // Initialize the character combo-box
            this.characterComboBox.Items.Clear();

            string[] charactersIT = TQData.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 (TQData.IsCustom)
                {
                    characterDesignator = string.Concat(characterDesignator, PlayerService.CustomDesignator);
                }

                string[] characters = charactersIT.Select(c => string.Concat(c, characterDesignator)).ToArray();
                this.characterComboBox.Items.AddRange(characters);
            }
        }
Ejemplo n.º 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 = TQData.GetVaultList();

            string[] charactersIT = TQData.GetCharacterList();

            int numIT = charactersIT?.Length ?? 0;

            int numVaults = vaults?.Length ?? 0;

            // Since this takes a while, show a progress dialog box.
            int total = numIT + 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();
        }