Exemplo n.º 1
0
        /// <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);
            }
            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();
            }

            try
            {
                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;

                // initialize editing fields
                bool[] activeControllers = { false, false, false, false, false };
                int[]  activeSubItems = new int[Movie.Input.ControllerCount];
                int j = 0;
                for (int i = 0; i < Movie.Input.Controllers.Length; i++)
                    if (Movie.Input.Controllers[i])
                    {
                        activeControllers[i] = true;
                        activeSubItems[j++]    = 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.VirtualSubItemsActive = activeControllers;
                lvInput.VirtualActiveSubItems = activeSubItems;
                lvInput.VirtualSubItemNames   = Movie.ControllerNames;
                lvInput.VirtualListSource     = FrameData.Input;
                lvInput.VirtualListSize       = FrameData.Input.Length;

                // set the number of controller columns
                lvInput.SetColumns(Movie.Input.ControllerCount);
                lvInput.VirtualMovieType = FrameData.Format;

                // 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 + "An unknown error occurred.",
                    "Unknown Error",
                    MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
                return;
            }
            finally
            {
                if (fs != null) fs.Close();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Reset all objects and controls to their default state
        /// </summary>
        private void resetApplication()
        {
            // disable menu commands that require a movie to be loaded in order to operate
            mnuSave.Enabled   = false;
            mnuSaveAs.Enabled = false;
            mnuClose.Enabled  = false;
            mnuExportSRT.Enabled = true;

            // reset the input list
            lvInput.SetColumns(0);
            lvInput.VirtualListSize = 0;

            // clear the movie treeview
            tvInfo.Nodes.Clear();

            // nullify the input data reference
            FrameData.Input  = null;
            FrameData.Format = MovieType.None;

            // reset the editor
            if (Editor != null)
                Editor.Close();
            Editor = null;
            mnuEditing.Enabled = false;

            // clear the undo history
            UndoHistory.Changes = new TASMovieInput[0][];
            mnuUndoChange.Enabled = false;

            Movie = null;

            // clear the icon
            pbFormat.Image = null;

            runMovieGeneratorToolStripMenuItem.Enabled = false;

            // reset filename
            txtMovieFilename.Text = "";
            sbarFrameCount.Text = "0";
            frd.GotoFrameNumberLabel = getFrameNumberRange();
        }