private void CreateBustupBin_Click(object sender, EventArgs e) { int lastSelectedIndex = listBox1.SelectedIndex; //Create BIN based on selected entry if (pType == BustupParamEditor.ParamEntry.ParamType.Assist) { DDS2.Create(bustupDirPath, listBox1.SelectedItem.ToString(), true); } else if (pType == BustupParamEditor.ParamEntry.ParamType.Normal) { DDS2.Create(bustupDirPath, listBox1.SelectedItem.ToString(), false); } //Reload file at previously selected index LoadParams(paramFilePath); listBox1.SelectedIndex = lastSelectedIndex; }
private void Listbox_SelectionChanged(object sender, EventArgs e) { if (listBox1.SelectedItem != null) { numUpDwn_MouthFrame.Value = 0; numUpDwn_EyeFrame.Value = 0; btn_CreateBin.Enabled = false; btn_OpenImgFolder.Enabled = false; btn_RepackBin.Enabled = false; numUpDwn_EyeFrame.Enabled = false; numUpDwn_MouthFrame.Enabled = false; comboBox_InitAnim.Enabled = false; if (previousSelectedIndex != -1) { // Prompt to save changes if form != data entry on leave if (numUpDwn_OffsetX.Text != pEntry.OffsetX.ToString() || numUpDwn_OffsetY.Text != pEntry.OffsetY.ToString() || numUpDwn_EyePosX.Text != pEntry.EyePositionX.ToString() || numUpDwn_EyePosY.Text != pEntry.EyepositionY.ToString() || numUpDwn_MouthPosX.Text != pEntry.MouthPositionX.ToString() || numUpDwn_MouthPosY.Text != pEntry.MouthPositionY.ToString() || comboBox_InitAnim.SelectedIndex != Params.GetInitAnim(pEntry.InitialAnimation)) { DialogResult result = MessageBox.Show($"Save changes to {listBox1.Items[previousSelectedIndex].ToString()}?\nYour changes will be discarded if you select No.", "Unsaved Changes", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { pEntry.OffsetX = float.Parse(numUpDwn_OffsetX.Text); pEntry.OffsetY = float.Parse(numUpDwn_OffsetY.Text); pEntry.EyePositionX = float.Parse(numUpDwn_EyePosX.Text); pEntry.EyepositionY = float.Parse(numUpDwn_EyePosY.Text); pEntry.MouthPositionX = float.Parse(numUpDwn_MouthPosX.Text); pEntry.MouthPositionY = float.Parse(numUpDwn_MouthPosY.Text); pEntry.InitialAnimation = Params.SetInitAnim(comboBox_InitAnim.SelectedIndex); if (pEntry.EntryData != null) { Program.Save(pEntry, paramFilePath); } } } } // Attempt to load new data from selected param entry into form try { pEntry = Validation.SelectedEntry(paramEntries, listBox1.SelectedItem.ToString()); numUpDwn_OffsetX.Text = pEntry.OffsetX.ToString(); numUpDwn_OffsetY.Text = pEntry.OffsetY.ToString(); numUpDwn_EyePosX.Text = pEntry.EyePositionX.ToString(); numUpDwn_EyePosY.Text = pEntry.EyepositionY.ToString(); numUpDwn_MouthPosX.Text = pEntry.MouthPositionX.ToString(); numUpDwn_MouthPosY.Text = pEntry.MouthPositionY.ToString(); comboBox_InitAnim.SelectedIndex = Params.GetInitAnim(pEntry.InitialAnimation); previousSelectedIndex = listBox1.SelectedIndex; numUpDwn_OffsetX.Enabled = true; numUpDwn_OffsetY.Enabled = true; numUpDwn_EyePosX.Enabled = true; numUpDwn_EyePosY.Enabled = true; numUpDwn_MouthPosX.Enabled = true; numUpDwn_MouthPosY.Enabled = true; comboBox_InitAnim.Enabled = true; selectedBustup = $"{bustupDirPath}\\{listBox1.SelectedItem.ToString()}"; if (bustupDirPath != "" && File.Exists(selectedBustup)) { btn_OpenImgFolder.Enabled = true; btn_RepackBin.Enabled = true; btn_CreateBin.Enabled = false; numUpDwn_EyeFrame.Enabled = true; numUpDwn_MouthFrame.Enabled = true; extractedBustupDir = DDS2.Extract(selectedBustup); pngs = Directory.GetFiles($"{extractedBustupDir}\\PNG"); pictureBox_Base.ImageLocation = pngs[0]; pictureBox_Eyes.Parent = pictureBox_Base; pictureBox_Mouth.Parent = pictureBox_Base; pictureBox_Eyes.ImageLocation = pngs[1]; pictureBox_Mouth.ImageLocation = pngs[5]; pictureBox_Eyes.Size = new Size(Image.FromFile(pngs[2]).Width, Image.FromFile(pngs[2]).Height); pictureBox_Mouth.Size = new Size(Image.FromFile(pngs[3]).Width, Image.FromFile(pngs[3]).Height); pictureBox_Eyes.Location = new System.Drawing.Point(Convert.ToInt32(pEntry.EyePositionX), Convert.ToInt32(pEntry.EyepositionY)); pictureBox_Mouth.Location = new System.Drawing.Point(Convert.ToInt32(pEntry.MouthPositionX), Convert.ToInt32(pEntry.MouthPositionY)); } else { pictureBox_Base.ImageLocation = null; pictureBox_Mouth.ImageLocation = null; pictureBox_Eyes.ImageLocation = null; btn_CreateBin.Enabled = true; } } catch { numUpDwn_OffsetX.Enabled = false; numUpDwn_OffsetY.Enabled = false; numUpDwn_EyePosX.Enabled = false; numUpDwn_EyePosY.Enabled = false; numUpDwn_MouthPosX.Enabled = false; numUpDwn_MouthPosY.Enabled = false; } } }
private void ToolstripRenameEntry_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.RenameEntry(paramFilePath, fileName, true, listBox1.SelectedIndex); } else if (pType == BustupParamEditor.ParamEntry.ParamType.Normal) { if (createBin && !File.Exists($"{bustupDirPath}\\{fileName}")) { DDS2.Create(bustupDirPath, fileName, false); } Params.RenameEntry(paramFilePath, fileName, false, listBox1.SelectedIndex); } //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!"); } }
private void RepackBin_Click(object sender, EventArgs e) { DDS2.Repack(extractedBustupDir); }