Ejemplo n.º 1
0
        public void SetNullableHashEntry(string searchString, HashValueEntry defaultEntry, string[] sectionNames, AppearanceField setValueField = AppearanceField.Hash, Section baseMainSection = null, bool createAllMainSections = false)
        {
            var entries = GetAllEntries(AppearanceEntryType.MainListEntry, searchString);

            if (defaultEntry.Hash == 0 || defaultEntry.FirstString == null || defaultEntry.SecondString == null)
            {
                RemoveEntries(entries);
            }
            else
            {
                if (entries.Count < 1)
                {
                    if (createAllMainSections == true)
                    {
                        foreach (Section mainSection in MainSections)
                        {
                            CreateEntry(defaultEntry, sectionNames, mainSection);
                        }
                    }
                    else
                    {
                        if (baseMainSection == null)
                        {
                            baseMainSection = MainSections[0];
                        }
                        CreateEntry(defaultEntry, sectionNames, baseMainSection);
                    }
                }
                else
                {
                    SetAllEntries(entries, (object entry) =>
                    {
                        if (setValueField == AppearanceField.FirstString)
                        {
                            ((HashValueEntry)entry).FirstString = defaultEntry.FirstString;
                        }
                        else if (setValueField == AppearanceField.SecondString)
                        {
                            ((HashValueEntry)entry).SecondString = defaultEntry.SecondString;
                        }
                        else
                        {
                            ((HashValueEntry)entry).Hash = defaultEntry.Hash;
                        }
                    });
                }
            }
        }
        private void applyButton_Click(object sender, EventArgs e)
        {
            if (optionsBox.SelectedItem is null)
            {
                MessageBox.Show("Error: No appearance entry selected.");
                return;
            }

            HashValueEntry entry = options[(string)optionsBox.SelectedItem];

            entry.FirstString    = firstBox.Text;
            entry.SecondString   = secondBox.Text;
            entry.Hash.DepotPath = pathBox.Text;

            ChangesApplied();
            applyButton.Enabled = false;
        }
        private void optionsBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (optionsBox.SelectedItem != null)
            {
                HashValueEntry entry = options[(string)optionsBox.SelectedItem];

                firstBox.Text  = entry.FirstString;
                secondBox.Text = entry.SecondString;
                pathBox.Text   = entry.GetPath();
            }
            else
            {
                firstBox.Text  = string.Empty;
                secondBox.Text = string.Empty;
                pathBox.Text   = string.Empty;
            }

            applyButton.Enabled = false;
        }
        private void applyButton_Click(object sender, EventArgs e)
        {
            if (optionsBox.SelectedItem is null)
            {
                MessageBox.Show("Error: No appearance entry selected.");
                return;
            }

            HashValueEntry entry = options[(string)optionsBox.SelectedItem];

            if (!entry.IsPathValid(pathBox.Text))
            {
                MessageBox.Show("Invalid path. Must be a valid path to a base game '.app' file.");
                return;
            }

            entry.FirstString  = firstBox.Text;
            entry.SecondString = secondBox.Text;
            entry.SetPath(pathBox.Text);

            ChangesApplied();
            applyButton.Enabled = false;
        }