private void btnSet33_Click(object sender, EventArgs e) { #warning properly test if this works IPersonality personality = Personalities.ElementAt(cmbPersonality33.SelectedIndex).Value; string name = "e" + cmbMode33.SelectedIndex.ToString("00") + "_" + personality.Slot.ToString("00") + "_" + cmbHeight33.SelectedIndex.ToString("00") + ".ICF"; ppParser pp = personality.GetIcfPP(); IWriteFile sub = pp.Subfiles.First(iw => iw.Name.ToLower() == name.ToLower()); int index = pp.Subfiles.IndexOf(sub); var icf = new ICF(); try { icf.Rotation.X = float.Parse(txtRotX.Text).DegreesToRadians(); icf.Rotation.Y = float.Parse(txtRotY.Text).DegreesToRadians(); icf.Rotation.Z = float.Parse(txtRotZ.Text).DegreesToRadians(); icf.Zoom1 = float.Parse(txtZoom1.Text); icf.Position.X = float.Parse(txtPosX.Text); icf.Position.Y = float.Parse(txtPosY.Text); icf.Position.Z = float.Parse(txtPosZ.Text); } catch (Exception ex) when (ex is FormatException || ex is ArgumentNullException) { MessageBox.Show("Error: One or more of the values are not valid number(s).", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } sub = new MemSubfile(new MemoryStream(icf.Export()), sub.Name); pp.Subfiles[index] = sub; var back = pp.WriteArchive(pp.FilePath, false, "bak", true); ShowLoadingForm(); back.RunWorkerAsync(); while (back.IsBusy) { Application.DoEvents(); } HideLoadingForm(); MessageBox.Show("Finished!"); }
public void LoadICF() { if (cmbHeight33.SelectedIndex < 0 || cmbMode33.SelectedIndex < 0 || cmbPersonality33.SelectedIndex < 0) return; IPersonality personality = Personalities.ElementAt(cmbPersonality33.SelectedIndex).Value; int height = personality.Gender == Gender.Female ? cmbHeight33.SelectedIndex : cmbHeight33.SelectedIndex + 1; string name = "e" + cmbMode33.SelectedIndex.ToString("00") + "_" + personality.Slot.ToString("00") + "_" + height.ToString("00") + ".ICF"; ppParser pp = personality.GetIcfPP(); IWriteFile sub = pp.Subfiles.First(iw => iw.Name.ToLower() == name.ToLower()); ICF icf; using (MemoryStream mem = Tools.GetStreamFromSubfile(sub)) icf = new ICF(mem); txtRotX.Text = icf.Rotation.X.RadiansToDegrees().ToString(); txtRotY.Text = icf.Rotation.Y.RadiansToDegrees().ToString(); txtRotZ.Text = icf.Rotation.Z.RadiansToDegrees().ToString(); txtZoom1.Text = icf.Zoom1.ToString(); txtPosX.Text = icf.Position.X.ToString(); txtPosY.Text = icf.Position.Y.ToString(); txtPosZ.Text = icf.Position.Z.ToString(); }