コード例 #1
0
        private void ParameterEntryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Make sure params file is open
            if (paramEntries.Count <= 0)
            {
                return;
            }

            //Open param entry creation form
            bool   alreadyExists = false;
            bool   createBin     = false;
            string fileName      = "";

            if (bustupDirPath != null)
            {
                using (var entryDialog = new AddParam())
                {
                    if (entryDialog.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                    try
                    {
                        createBin     = AddParam.Result.createBin;
                        fileName      = AddParam.Result.fileName;
                        alreadyExists = AddParam.Result.alreadyExists;
                    }
                    catch
                    {
                    }
                }
                if (alreadyExists)
                {
                    return;
                }

                //Create .bin and/or add entry
                if (pType == BustupParamEditor.ParamEntry.ParamType.Assist)
                {
                    if (createBin && !File.Exists($"{bustupDirPath}\\{fileName}"))
                    {
                        DDS2.Create(bustupDirPath, fileName, true);
                    }
                    Params.AddEntry(paramFilePath, fileName, true);
                }
                else if (pType == BustupParamEditor.ParamEntry.ParamType.Normal)
                {
                    if (createBin && !File.Exists($"{bustupDirPath}\\{fileName}"))
                    {
                        DDS2.Create(bustupDirPath, fileName, false);
                    }
                    Params.AddEntry(paramFilePath, fileName, false);
                }
                //Reload file and select new entry
                LoadParams(paramFilePath);
                listBox1.SelectedIndex = listBox1.Items.Count - 1;
            }
            else
            {
                MessageBox.Show("Please set your Bustup .bin Directory path first!");
            }
        }