Exemple #1
0
        public void UpdateVisualAndPackData(ManagerForm Main, PackMetadata Pack)
        {
            try
            {
                //
                if (Main.CurrentPackList != null)
                {
                    if (Main.packSelectionListBox.SelectedItem != null)
                    {
                        if (Main.pastSelectedItem != Main.packSelectionListBox.SelectedItem.ToString()) // If the same pack was selected again, why go through all this crap once more?
                        {
                            Main.PackSettingsCheckedListBox.Items.Clear();                              // Clear the settings SelectedListBox
                            Main.packPreviewPictureBox.Image = GAspsRPmngr.Properties.Resources.blank;  // Clear the pack preview Picture box.
                            Main.packStatusLabel.Text        = "Pack Status: Loading...";

                            // some stuff

                            Main.CurrentSelectedItemNumber = Main.packSelectionListBox.Items.IndexOf(Main.packSelectionListBox.SelectedItem.ToString());
                            Main.CurrentSelectedItemNumber++;
                            Main.updateEditionsList(JsonConvert.SerializeObject((object)Main.CurrentPackList[Main.CurrentSelectedItemNumber.ToString()]["editions"]));

                            // Setting all the variables to their new value
                            if ((bool)Main.CurrentPackList[Main.CurrentSelectedItemNumber.ToString()]["external_source"])
                            {        // Retreive data from external JSON instead of from current JSON
                                Pack.Description   = (string)Main.CurrentPackList[Main.CurrentSelectedItemNumber.ToString()]["description"];
                                Pack.Image         = (string)Main.CurrentPackList[Main.CurrentSelectedItemNumber.ToString()]["image_preview"];
                                Pack.Resolutions   = (string)Main.CurrentPackList[Main.CurrentSelectedItemNumber.ToString()]["resolutions"];
                                Pack.Compatibility = (string)Main.CurrentPackList[Main.CurrentSelectedItemNumber.ToString()]["compatibility"];
                                Pack.Compatibility = (string)Main.CurrentPackList[Main.CurrentSelectedItemNumber.ToString()]["latest_version"];
                            }
                            else
                            { // Retreive data from current JSON instead of from external JSON
                                Pack.Description   = (string)Main.CurrentPackList[Main.CurrentSelectedItemNumber.ToString()]["description"];
                                Pack.Image         = (string)Main.CurrentPackList[Main.CurrentSelectedItemNumber.ToString()]["image_preview"];
                                Pack.Resolutions   = (string)Main.CurrentPackList[Main.CurrentSelectedItemNumber.ToString()]["resolutions"];
                                Pack.Compatibility = (string)Main.CurrentPackList[Main.CurrentSelectedItemNumber.ToString()]["compatibility"];
                                Pack.Compatibility = (string)Main.CurrentPackList[Main.CurrentSelectedItemNumber.ToString()]["latest_version"];
                            }

                            // Retreive data from current JSON that doesn't need to be changed and therefore not from external JSON

                            Pack.Name        = (string)Main.CurrentPackList[Main.CurrentSelectedItemNumber.ToString()]["name"];
                            Pack.Creator     = (string)Main.CurrentPackList[Main.CurrentSelectedItemNumber.ToString()]["creator"];
                            Pack.Resolutions = (string)Main.CurrentPackList[Main.CurrentSelectedItemNumber.ToString()]["resolutions"];

                            // Setting all the not label stuff to their new value

                            Main.packDescriptionTextBox.Text         = Pack.Description;
                            Main.packPreviewPictureBox.ImageLocation = Pack.Image;
                            Main.PackEditionComboBox.Text            = "";

                            // Setting all the labels to their new value

                            Main.packVersionLabel.Text       = "Latest Version: " + Pack.Compatibility;
                            Main.packCompatibilityLabel.Text = "MC Versions: " + Pack.Compatibility;
                            Main.currentPackLabel.Text       = Pack.Name;
                            Main.ResolutionsLabel.Text       = "Resolution(s): " + Pack.Resolutions;
                            Main.creatorLabel.Text           = "Created by " + Pack.Creator;

                            UpdateApplyButton(Main, Pack); // Essentially checking which buttons need to be enabled or disabled.
                        }
                    }
                }
                else //
                {
                    throw new System.ArgumentNullException("Pack List is null.");
                }
            }
            catch (Exception er)
            {
                ErrorForm form3 = new ErrorForm(er.Message, er.StackTrace, er.GetType().ToString());
                form3.ShowDialog();
            }
            if (Pack.HasOneEdition && Main.pastSelectedItem != Main.packSelectionListBox.SelectedItem.ToString() || Pack.HasNoEditions && Main.pastSelectedItem != Main.packSelectionListBox.SelectedItem.ToString())
            {
                Main.CurrentSelectedEditionNumber       = 1;
                Main.PackSettingsCheckedListBox.Enabled = true;
                Main.updateSettingsList(JsonConvert.SerializeObject((object)Main.CurrentPackList[Main.CurrentSelectedItemNumber.ToString()]["settings"]));
            }
            // If the selected pack has no selectable editions, check here for settings
            Main.pastSelectedItem = Main.packSelectionListBox.SelectedItem.ToString(); // We just checked a new pack, no need to check it directly again
        }