/// <summary> /// Loads a TAS into the editor /// </summary> private void loadMovie(string filename, bool fromRecent) { resetApplication(); // initialize the editor Editor = new frmEditing(); mnuEditing.Enabled = true; // copy the clean frame data to the undo buffer as the first item mnuUndoChange.Enabled = true; // make sure the file isn't locked before we do anything else System.IO.FileStream fs = null; try { fs = System.IO.File.OpenRead(filename); FrameData.Format = IsValid(filename); ResourceManager rm = new ResourceManager("MovieSplicer.Properties.Resources", GetType().Assembly); // load the movie object up with the correct format and display a thumbnail switch (FrameData.Format) { case MovieType.SMV: Movie = new SNES9x(filename); Methods.PopulateMovieInfo.SMV(ref tvInfo, ref Movie); pbFormat.Image = ((System.Drawing.Icon)(rm.GetObject("icon_smv"))).ToBitmap(); break; case MovieType.FCM: Movie = new FCEU(filename); Methods.PopulateMovieInfo.FCM(ref tvInfo, ref Movie); pbFormat.Image = ((System.Drawing.Icon)(rm.GetObject("icon_fcm"))).ToBitmap(); break; case MovieType.GMV: Movie = new Gens(filename); Methods.PopulateMovieInfo.GMV(ref tvInfo, ref Movie); pbFormat.Image = ((System.Drawing.Icon)(rm.GetObject("icon_gmv"))).ToBitmap(); break; case MovieType.FMV: Movie = new Famtasia(filename); Methods.PopulateMovieInfo.FMV(ref tvInfo, ref Movie); pbFormat.Image = ((System.Drawing.Icon)(rm.GetObject("icon_fmv"))).ToBitmap(); break; case MovieType.VBM: Movie = new VisualBoyAdvance(filename); Methods.PopulateMovieInfo.VBM(ref tvInfo, ref Movie); pbFormat.Image = ((System.Drawing.Icon)(rm.GetObject("icon_vbm"))).ToBitmap(); break; case MovieType.M64: Movie = new Mupen64(filename); Methods.PopulateMovieInfo.M64(ref tvInfo, ref Movie); pbFormat.Image = ((System.Drawing.Icon)(rm.GetObject("icon_m64"))).ToBitmap(); break; case MovieType.MMV: Movie = new Dega(filename); Methods.PopulateMovieInfo.MMV(ref tvInfo, ref Movie); pbFormat.Image = ((System.Drawing.Icon)(rm.GetObject("icon_mmv"))).ToBitmap(); break; case MovieType.PJM: Movie = new PCSX(filename); // shares with PXM Methods.PopulateMovieInfo.PXM(ref tvInfo, ref Movie); // shares with PXM pbFormat.Image = ((System.Drawing.Icon)(rm.GetObject("icon_pjm"))).ToBitmap(); //pbFormat.Click += new EventHandler(PCSX.PCSXHelp); break; case MovieType.PXM: Movie = new PCSX(filename); // shares with PJM Methods.PopulateMovieInfo.PXM(ref tvInfo, ref Movie); // shares with PJM pbFormat.Image = ((System.Drawing.Icon)(rm.GetObject("icon_pxm"))).ToBitmap(); //pbFormat.Click += new EventHandler(PCSX.PCSXHelp); break; case MovieType.None: resetApplication(); return; } // destroy the resource manager instance rm = null; // assign the shared input collection to the current movie's FrameData.Input = Movie.Input.FrameData; FrameData.Controllers = Movie.Input.ControllerCount; // set the number of controller columns lvInput.SetColumns(Movie.Input.ControllerCount); lvInput.VirtualMovieType = FrameData.Format; // initialize editing fields bool[] activeControllers = { false, false, false, false, false }; for (int i = 0; i < Movie.Input.ControllerCount; i++) { activeControllers[i] = Movie.Input.Controllers[i]; } Editor.ToggleInputBoxes(activeControllers); // trim the filename and throw it into a text field txtMovieFilename.Text = FilenameFromPath(filename); // enable grayed menu options mnuSave.Enabled = true; mnuSaveAs.Enabled = true; mnuClose.Enabled = true; // populate the virtual listview lvInput.ClearVirtualCache(); lvInput.VirtualListSource = FrameData.Input; lvInput.VirtualListSize = FrameData.Input.Length; // add frame count to statusbar sbarFrameCount.Text = FrameData.Input.Length.ToString(); frd.GotoFrameNumberLabel = getFrameNumberRange(); Editor.LoadSharedObjects(ref lvInput, ref FrameData.Input, ref UndoHistory, ref Msg); Msg.AddMsg("Successfully loaded " + FilenameFromPath(filename)); // show subtitle export option mnuExportSRT.Enabled = true; Methods.AppSettings.Save(filename); populateRecentFiles(); runMovieGeneratorToolStripMenuItem.Enabled = true; } catch { MessageBox.Show(this, filename + " cannot be accessed at the moment.\nEither the file is locked or it doesn't exist.", "File Access Error", MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1); return; } finally { if (fs != null) { fs.Close(); } } }
/// <summary> /// Update the input array with the changed frame data /// </summary> private void btnUpdate_Click(object sender, EventArgs e) { if (lvInput.SelectedIndices.Count == 0) { return; } bool[] updateFlag = { false, false, false, false, false }; TASMovieInput updated = new TASMovieInput(); if (sender == button1) { updated.Controller[0] = txtFrameDataC1.Text; updateFlag[0] = true; } else if (sender == button2) { updated.Controller[1] = txtFrameDataC2.Text; updateFlag[1] = true; } else if (sender == button3) { updated.Controller[2] = txtFrameDataC3.Text; updateFlag[2] = true; } else if (sender == button4) { updated.Controller[3] = txtFrameDataC4.Text; updateFlag[3] = true; } else if (sender == button5) { updated.Controller[4] = txtFrameDataC5.Text; updateFlag[4] = true; } else { if (chkFrameDataC1.Checked) { updated.Controller[0] = txtFrameData.Text; updateFlag[0] = true; } if (chkFrameDataC2.Checked) { updated.Controller[1] = txtFrameData.Text; updateFlag[1] = true; } if (chkFrameDataC3.Checked) { updated.Controller[2] = txtFrameData.Text; updateFlag[2] = true; } if (chkFrameDataC4.Checked) { updated.Controller[3] = txtFrameData.Text; updateFlag[3] = true; } if (chkFrameDataC5.Checked) { updated.Controller[4] = txtFrameData.Text; updateFlag[4] = true; } } // if no controllers were set, return if (!updateFlag[0] && !updateFlag[1] && !updateFlag[2] && !updateFlag[3] && !updateFlag[4]) { return; } // prompt for multiple frame insertion if (lvInput.SelectedIndices.Count > 1 && EditingPrompts) { DialogResult confirmUpdate = MessageBox.Show(MovieSplicer.UI.frmMain.frm, "Are you sure you want to update the " + lvInput.SelectedIndices.Count + " frames with the same input?", "Confirm Multiple Frame Update", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (confirmUpdate != DialogResult.OK) { return; } } UndoBuffer.Add(ref UndoHistory, ref FrameData); int[] selectedIndices = new int[lvInput.SelectedIndices.Count]; lvInput.SelectedIndices.CopyTo(selectedIndices, 0); // append or overwrite check if (chkAppendInput.Checked) { TASMovieInput.UpdatePlus(ref FrameData, updated, updateFlag, AutoFire, selectedIndices); } else { TASMovieInput.Update(ref FrameData, updated, updateFlag, AutoFire, selectedIndices); } lvInput.ClearVirtualCache(); lvInput.Refresh(); Msg.AddMsg("Updated " + lvInput.SelectedIndices.Count + " frame(s)"); }