Example #1
0
 /// <summary>
 /// append controller data to an existing TASMovieInput object
 /// </summary>        
 public static TASMovieInput operator +(TASMovieInput left, TASMovieInput right)
 {
     TASMovieInput result = new TASMovieInput();
     for (int i = 0; i < left.Controller.Length; i++)
         result.Controller[i] = left.Controller[i] + right.Controller[i];
     return result;
 }
Example #2
0
        /// <summary>
        /// Remove a given number of frames at the desired position
        /// </summary>
        public static void Remove(ref TASMovieInput[] input, int[] indices)
        {
            TASMovieInput[] temp = new TASMovieInput[input.Length - indices.Length];

            int i = 0;

            for (int j = 0; j < indices.Length;)
            {
                if (i + j != indices[j])
                {
                    temp[i] = input[i + j];
                    i++;
                }
                else
                {
                    j++;
                }
            }

            for (int k = indices[indices.Length - 1] + 1; k < input.Length; i++, k++)
            {
                temp[i] = input[k];
            }

            input = temp;
        }
Example #3
0
 public void LoadSharedObjects(ref TASListView lv, ref TASMovieInput[] movie, ref UndoBuffer undo, ref frmMessages msg)
 {
     lvInput     = lv;
     FrameData   = movie;
     UndoHistory = undo;
     Msg         = msg;
 }
Example #4
0
        /// <summary>
        /// Update the desired frames with the TASMovieInput
        /// updateFlag is a collection of bool values to indicate which controller(s) to update
        ///
        /// NOTE::Autofire update just adds the selected input to alternating frames
        /// </summary>
        public static void UpdatePlus(ref TASMovieInput[] input, TASMovieInput frame, bool[] updateFlag, bool autofireUpdate, int[] indices)
        {
            TASMovieInput[] temp = new TASMovieInput[indices.Length];
            for (int i = 0; i < indices.Length; i++)
            {
                temp[i] = new TASMovieInput();
                for (int j = 0; j < updateFlag.Length; j++)
                {
                    // if autofire is checked, insert a blank frame on alternating frames
                    // NOTE::mod check set to 1 so if option is checked and only 1 frame needs to be updated
                    // the changes won't be skipped :)
                    if (autofireUpdate)
                    {
                        if (i % 2 == 1)
                        {
                            temp[i].Controller[j] = input[indices[i]].Controller[j];
                        }
                        else
                        {
                            temp[i].Controller[j] = (updateFlag[j]) ? input[indices[i]].Controller[j] + frame.Controller[j] : input[indices[i]].Controller[j];
                        }
                    }
                    else
                    {
                        temp[i].Controller[j] = (updateFlag[j]) ? input[indices[i]].Controller[j] + frame.Controller[j] : input[indices[i]].Controller[j];
                    }
                }
            }

            for (int i = 0; i < indices.Length; i++)
            {
                input[indices[i]] = temp[i];
            }
        }
Example #5
0
        /// <summary>
        /// Load the contents of an external file to the copy buffer
        /// Returns the column count
        /// </summary>
        public static void Load(string filename, ref TASMovieInputCollection buffer)
        {
            StreamReader reader = File.OpenText(filename);
            string header = reader.ReadLine();

            int controllers = 0;

            // TODO::This is a weak validation routine
            if (header.Length != 3)
            {
                MessageBox.Show(frmMain.frm, "Buffer file appears to be invalid", "Oops",
                    MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
                return;
            }

            string lineItem = null;
            while ((lineItem = reader.ReadLine()) != null)
            {
                TASMovieInput[] frame = new TASMovieInput[1];
                string[]        split  = lineItem.Split('|');
                for (int i = 0; i < split.Length; i++)
                    frame[0].Controller[i] = split[i];

                TASMovieInput.Insert(ref buffer.Input, ref frame, buffer.Input.Length);
                controllers = split.Length;
            }

            reader.Close(); reader.Dispose();

            buffer.Format      = (TASForm.MovieType)Enum.Parse(typeof(TASForm.MovieType), header);
            buffer.Controllers = controllers;
        }
Example #6
0
        /// <summary>
        /// Return the last buffer value and remove it from the collections
        /// </summary>        
        public static void Undo(ref UndoBuffer buffer)
        {
            TASMovieInput[][] temp = new TASMovieInput[buffer.Changes.Length - 1][];
            for (int i = 0; i < temp.Length; i++)
                temp[i] = buffer.Changes[i];

            buffer.Changes = temp;
        }
Example #7
0
        /// <summary>
        /// append controller data to an existing TASMovieInput object
        /// </summary>
        public static TASMovieInput operator +(TASMovieInput left, TASMovieInput right)
        {
            TASMovieInput result = new TASMovieInput();

            for (int i = 0; i < left.Controller.Length; i++)
            {
                result.Controller[i] = left.Controller[i] + right.Controller[i];
            }
            return(result);
        }
Example #8
0
        /// <summary>
        /// Return the last buffer value and remove it from the collections
        /// </summary>
        public static void Undo(ref UndoBuffer buffer)
        {
            TASMovieInput[][] temp = new TASMovieInput[buffer.Changes.Length - 1][];
            for (int i = 0; i < temp.Length; i++)
            {
                temp[i] = buffer.Changes[i];
            }

            buffer.Changes = temp;
        }
Example #9
0
        /// <summary>
        /// Copy a given number of frames at the desired position by extracting them to a new
        /// array
        /// </summary>
        public static TASMovieInput[] Copy(ref TASMovieInput[] input, int[] indices)
        {
            TASMovieInput[] temp = new TASMovieInput[indices.Length];

            for (int i = 0; i < indices.Length; i++)
            {
                temp[i] = input[indices[i]];
            }

            return(temp);
        }
Example #10
0
        /// <summary>
        /// Add a frame data collection to the undo buffer
        /// </summary>        
        public static void Add(ref UndoBuffer buffer, ref TASMovieInput[] change)
        {
            TASMovieInput[][] temp = new TASMovieInput[buffer.Changes.Length + 1][];

            if (buffer.Changes.Length > 0) buffer.Changes.CopyTo(temp, 0);

            temp[temp.Length - 1] = new TASMovieInput[change.Length];
            change.CopyTo(temp[temp.Length - 1], 0);

            buffer.Changes = temp;
        }
Example #11
0
 public FrameWithInput(int number_inputs)
 {
     if (number_inputs < 1) number_inputs = 7;
     Input = new MovieSplicer.Data.TASMovieInput[number_inputs];
     for( int i = 0; i < number_inputs; i++ )
     {
         Input[i] = new MovieSplicer.Data.TASMovieInput();
     }
     total_input = 0;
     newframeposition = 0;
     originalframeposition = 0;
 }
Example #12
0
        /// <summary>
        /// Add a frame data collection to the undo buffer
        /// </summary>
        public static void Add(ref UndoBuffer buffer, ref TASMovieInput[] change)
        {
            TASMovieInput[][] temp = new TASMovieInput[buffer.Changes.Length + 1][];

            if (buffer.Changes.Length > 0)
            {
                buffer.Changes.CopyTo(temp, 0);
            }

            temp[temp.Length - 1] = new TASMovieInput[change.Length];
            change.CopyTo(temp[temp.Length - 1], 0);

            buffer.Changes = temp;
        }
Example #13
0
        /// <summary>
        /// Insert a given number of assigned frames (TASMovieInput()) at the
        /// desired position
        /// </summary>
        public static void Insert(ref TASMovieInput[] input, TASMovieInput frame, int position, int length)
        {
            TASMovieInput[] temp = new TASMovieInput[input.Length + length];

            for (int i = 0; i < position; i++)
            {
                temp[i] = input[i];
            }
            for (int j = 0; j < length; j++)
            {
                temp[position + j] = frame;
            }
            for (int k = position; k < input.Length; k++)
            {
                temp[k + length] = input[k];
            }

            input = temp;
        }
Example #14
0
        /// <summary>
        /// Insert a given number of frames passed through a buffer at the
        /// desired position
        /// </summary>
        public static void Insert(ref TASMovieInput[] input, ref TASMovieInput[] buffer, int position)
        {
            TASMovieInput[] temp = new TASMovieInput[input.Length + buffer.Length];

            for (int i = 0; i < position; i++)
            {
                temp[i] = input[i];
            }
            for (int j = 0; j < buffer.Length; j++)
            {
                temp[position + j] = buffer[j];
            }
            for (int k = position; k < input.Length; k++)
            {
                temp[k + buffer.Length] = input[k];
            }

            input = temp;
        }
Example #15
0
        /// <summary>
        /// Insert repeatedly a given number of frames passed through a buffer at each
        /// desired position
        /// </summary>
        public static void InsertMultiple(ref TASMovieInput[] input, ref TASMovieInput[] buffer, int[] indices)
        {
            int blockCount = indices.Length;
            int blockSize  = buffer.Length;

            TASMovieInput[] temp = new TASMovieInput[input.Length + blockSize * blockCount];

            bool pastEnd = (indices[blockCount - 1] < input.Length ? false : true);

            int i = 0;

            for (int j = 0; j < blockCount; i++)
            {
                if (i == indices[j])
                {
                    for (int k = 0; k < blockSize; k++)
                    {
                        temp[i + blockSize * j + k] = buffer[k];
                    }
                    j++;

                    // takes care of paste-after
                    if (pastEnd && j == blockCount)
                    {
                        input = temp;
                        return;
                    }
                }
                temp[i + blockSize * j] = input[i];
            }

            for (int k = indices[blockCount - 1] + 1; k < input.Length; k++)
            {
                temp[blockSize * blockCount + k] = input[k];
            }

            input = temp;
        }
Example #16
0
        /// <summary>
        /// Splice two TASMovieInput collections together
        /// </summary>
        public static TASMovieInput[] Splice(ref TASMovieInput[] source, ref TASMovieInput[] target, int sourceStart, int sourceEnd, int targetStart, int targetEnd)
        {
            // NOTE::zero means start from the beginning, but if not, since it's an index, subtract 1
            if (targetStart != 0)
            {
                targetStart--;
            }

            TASMovieInput[] spliced = new TASMovieInput[(sourceEnd - sourceStart) + (targetEnd - targetStart)];
            for (int i = sourceStart; i < sourceEnd; i++)
            {
                spliced[i] = source[i];
            }

            int position = 0;

            for (int j = targetStart; j < targetEnd; j++)
            {
                spliced[sourceEnd + position++] = target[j];
            }

            return(spliced);
        }
Example #17
0
        /// <summary>
        /// Update the desired frames with the TASMovieInput
        /// updateFlag is a collection of bool values to indicate which controller(s) to update
        /// 
        /// NOTE::Autofire update just adds the selected input to alternating frames
        /// </summary>        
        public static void UpdatePlus(ref TASMovieInput[] input, TASMovieInput frame, bool[] updateFlag, bool autofireUpdate, int[] indices)
        {
            TASMovieInput[] temp = new TASMovieInput[indices.Length];
            for (int i = 0; i < indices.Length; i++)
            {
                temp[i] = new TASMovieInput();
                for (int j = 0; j < updateFlag.Length; j++)
                {
                    // if autofire is checked, insert a blank frame on alternating frames
                    // NOTE::mod check set to 1 so if option is checked and only 1 frame needs to be updated
                    // the changes won't be skipped :)
                    if (autofireUpdate)
                    {
                        if (i % 2 == 1)
                            temp[i].Controller[j] = input[indices[i]].Controller[j];
                        else
                            temp[i].Controller[j] = (updateFlag[j]) ? input[indices[i]].Controller[j] + frame.Controller[j] : input[indices[i]].Controller[j];
                    }
                    else
                        temp[i].Controller[j] = (updateFlag[j]) ? input[indices[i]].Controller[j] + frame.Controller[j] : input[indices[i]].Controller[j];
                }
            }

            for (int i = 0; i < indices.Length; i++)
            {
                input[indices[i]] = temp[i];
            }
        }
Example #18
0
        /// <summary>
        /// Splice two TASMovieInput collections together
        /// </summary>        
        public static TASMovieInput[] Splice(ref TASMovieInput[] source, ref TASMovieInput[] target, int sourceStart, int sourceEnd, int targetStart, int targetEnd)
        {
            // NOTE::zero means start from the beginning, but if not, since it's an index, subtract 1
            if (targetStart != 0) targetStart--;

            TASMovieInput[] spliced = new TASMovieInput[(sourceEnd - sourceStart) + (targetEnd - targetStart)];
            for (int i = sourceStart; i < sourceEnd; i++)
                spliced[i] = source[i];

            int position = 0;
            for (int j = targetStart; j < targetEnd; j++)
                spliced[sourceEnd + position++] = target[j];

            return spliced;
        }
Example #19
0
 /// <summary>
 /// Cycle through the input collection returning an index of the first available match
 /// from the given offset
 /// </summary>                
 public static int Search(ref TASMovieInput[] input, string pattern, int startPosition, int endPosition)
 {
     if (startPosition < endPosition)
     {
         for (int i = startPosition; i < endPosition; i++)
             for (int j = 0; j < input[i].Controller.Length; j++)
                 if (input[i].Controller[j] != null)
                     if (input[i].Controller[j] == pattern) return i;
     }
     else
     {
         for (int i = startPosition; i > endPosition; i--)
             for (int j = 0; j < input[i].Controller.Length; j++)
                 if (input[i].Controller[j] != null)
                     if (input[i].Controller[j] == pattern) return i;
     }
     return -1;
 }
Example #20
0
        /// <summary>
        /// Remove a given number of frames at the desired position
        /// </summary>        
        public static void Remove(ref TASMovieInput[] input, int[] indices)
        {
            TASMovieInput[] temp = new TASMovieInput[input.Length - indices.Length];

            int i = 0;
            for (int j = 0; j < indices.Length; )
            {
                if (i + j != indices[j])
                {
                    temp[i] = input[i + j];
                    i++;
                }
                else
                    j++;
            }

            for (int k = indices[indices.Length - 1] + 1; k < input.Length; i++, k++)
                temp[i] = input[k];

            input = temp;
        }
Example #21
0
        /// <summary>
        /// Insert repeatedly a given number of frames passed through a buffer at each
        /// desired position
        /// </summary>        
        public static void InsertMultiple(ref TASMovieInput[] input, ref TASMovieInput[] buffer, int[] indices)
        {
            int blockCount = indices.Length;
            int blockSize  = buffer.Length;
            TASMovieInput[] temp = new TASMovieInput[input.Length + blockSize * blockCount];

            bool pastEnd = (indices[blockCount - 1] < input.Length ? false : true);

            int i = 0;
            for (int j = 0; j < blockCount; i++)
            {
                if (i == indices[j])
                {
                    for (int k = 0; k < blockSize; k++)
                    {
                        temp[i + blockSize * j + k] = buffer[k];
                    }
                    j++;

                    // takes care of paste-after
                    if (pastEnd && j == blockCount)
                    {
                        input = temp;
                        return;
                    }
                }
                temp[i + blockSize * j] = input[i];
            }

            for (int k = indices[blockCount - 1] + 1; k < input.Length; k++)
                temp[blockSize * blockCount + k] = input[k];

            input = temp;
        }
Example #22
0
        /// <summary>
        /// Insert a given number of frames passed through a buffer at the
        /// desired position
        /// </summary>        
        public static void Insert(ref TASMovieInput[] input, ref TASMovieInput[] buffer, int position)
        {
            TASMovieInput[] temp = new TASMovieInput[input.Length + buffer.Length];

            for (int i = 0; i < position; i++)
                temp[i] = input[i];
            for (int j = 0; j < buffer.Length; j++)
                temp[position + j] = buffer[j];
            for (int k = position; k < input.Length; k++)
                temp[k + buffer.Length] = input[k];

            input = temp;
        }
Example #23
0
        /// <summary>
        /// Insert a given number of assigned frames (TASMovieInput()) at the
        /// desired position
        /// </summary>        
        public static void Insert(ref TASMovieInput[] input, TASMovieInput frame, int position, int length)
        {
            TASMovieInput[] temp = new TASMovieInput[input.Length + length];

            for (int i = 0; i < position; i++)
                temp[i] = input[i];
            for (int j = 0; j < length; j++)
                temp[position + j] = frame;
            for (int k = position; k < input.Length; k++)
                temp[k + length] = input[k];

            input = temp;
        }
Example #24
0
        /// <summary>
        /// Perform the splice
        /// </summary>        
        private void btnSplice_Click(object sender, EventArgs e)
        {
            // exit if not enough movies are opened
            if (Movies.Length < 2)
            {
                MessageBox.Show(frmMain.frm, "At least two (2) movies must be loaded for splicing to be performed", "Movie Count Too Low",
                    MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
                return;
            }

            // ensure all loaded movies are of the same type
            for (int i = 0; i < Movies.Length - 1; i++)
            {
                if (Movies[i].MovieType != Movies[i + 1].MovieType)
                {
                    MessageBox.Show(frmMain.frm, "Movies aren't all of the same type", "Type Mismatch",
                        MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
                    return;
                }
            }

            TASMovieInput[] spliced = new TASMovieInput[0];

            for (int i = 0; i < Movies.Length; i++)
            {
                // handle zeroes
                if (Movies[i].End == 0) Movies[i].End = Movies[i].Movie.Header.FrameCount;

                // NOTE::increase VBM by 1 frame since we enumerate from zero
                if (Movies[i].MovieType == MovieType.VBM) Movies[i].End++;

                spliced = TASMovieInput.Splice(ref spliced, ref Movies[i].Movie.Input.FrameData, 0, spliced.Length, Movies[i].Start, Movies[i].End);
            }

            TASMovieInputCollection temp = new TASMovieInputCollection();
            temp.Format = Movies[0].MovieType;
            temp.Input  = spliced;
            frmSaveAs frm = new frmSaveAs(ref Movies[0].Movie, ref temp, "spliced-");
            frm.ShowDialog(); frm.Dispose();
        }
Example #25
0
        public bool Preprocess()
        {
            if (movie == null)
            {
                MessageBox.Show(MovieSplicer.UI.frmMain.frm,
                    "No movie loaded.",
                    "Preprocessing",
                    MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
                return false;
            };

            finishrunning = false;

            //1. Calculate new movie possible length
            //  Removals or replacements ont modify length, only insertion.
            // +1 just in case
            int newmovielen = movie.Input.FrameData.Length + frameinsert_max + 1;

            baseinput = new MovieSplicer.Data.TASMovieInput[newmovielen];
            for (int i=0; i < baseinput.Length; i++)
            {
                baseinput[i] = new MovieSplicer.Data.TASMovieInput();
                for (int j = 0; j < movie.Input.ControllerCount; j++)
                {
                    baseinput[i].Controller[j] = "";
                    //ie. genesis requires two controllers at any time...
                }
            }

            bool inputsearch_insert = false;
            bool inputsearch_remove = false;
            bool inputsearch_replace = false;

            if (frameinsert_frameend < 0)
                frameinsert_frameend = movie.Input.FrameData.Length - 1;
            if (frameremove_frameend < 0)
                frameremove_frameend = movie.Input.FrameData.Length - 1;
            if (inputreplace_frameend < 0)
                inputreplace_frameend = movie.Input.FrameData.Length - 1;
            //@bad - sorry but it complicates stuff
            //you won't be able to remove 20 frames starting frame 0
            if (frameremove_framestart < frameremove_max)
                frameremove_framestart = frameremove_max;

            //IF we have the _onframes variables set, then sort them
            //2. check insert
            if (frameinsert_min < 1 && frameinsert_max < 1)
            {
                frameinsert_do = false;
            };
            if (frameinsert_do)
            {
                if (frameinsert_inputs == null)
                {
                    frameinsert_inputs = new string[0];
                };
                if (frameinsert_onframes.Length == 0)
                {
                    inputsearch_insert = true;
                }
                else
                {
                    SortIntArray(ref frameinsert_onframes);
                }

                //combine inputs if required
                if (frameinsert_combineinputs)
                {
                    GenerateAllInputCombinations(ref frameinsert_inputs);
                }
                else
                {
                    movie.CleanInputList(ref frameinsert_inputs);
                }
            }
            else
            {
                frameinsert_min = 0;
                frameinsert_max = 0;
                frameinsert_onframes = new int[0];
                frameinsert_onframes_original = "";
                frameinsert_framestart = 0;
                frameinsert_frameend = 0;
            }

            //3. check removal
            if (frameremove_min < 1 && frameremove_max < 1)
            {
                frameremove_do = false;
            };
            if (frameremove_do)
            {
                if (frameremove_inputs == null)
                {
                    frameremove_inputs = new string[0];
                };
                if (frameremove_onframes.Length == 0)
                {
                    inputsearch_remove = true;
                }
                else
                {
                    SortIntArray(ref frameremove_onframes);
                }

                //combine inputs if required
                if (frameremove_combineinputs)
                {
                    //any input
                    if (frameremove_inputs.Length == 0)
                    {
                    }
                    else
                    {
                        GenerateAllInputCombinations(ref frameremove_inputs);
                    }
                }
                else
                {
                    movie.CleanInputList(ref frameremove_inputs);
                }
            }
            else
            {
                frameremove_min = 0;
                frameremove_max = 0;
                frameremove_onframes = new int[0];
                frameremove_onframes_original = "";
                frameremove_framestart = 0;
                frameremove_frameend = 0;
            }

            //4. check replacement
            if (inputreplace_do)
            {
                if (inputreplace_inputs == null)
                {
                    inputreplace_inputs = new string[0];
                };

                if (inputreplace_onframes.Length == 0)
                {
                    inputsearch_replace = true;
                }
                else
                {
                    SortIntArray(ref inputreplace_onframes);
                }

                //combine inputs if required
                if (inputreplace_combineinputs)
                {
                    GenerateAllInputCombinations(ref inputreplace_inputs);
                }
                else
                {
                    movie.CleanInputList(ref inputreplace_inputs);
                }
            }
            else
            {
                inputreplace_onframes = new int[0];
                inputreplace_onframes_original = "";
                inputreplace_framestart = 0;
                inputreplace_frameend = 0;
            }

            //5. See possibility of a movie input "header"
            //any input before this should be copied now to base_input
            //since it won't be overwritten
            movieheader_endindex = baseinput.Length;
            if (frameinsert_do)
            {
                if (inputsearch_insert)
                {
                    if (movieheader_endindex > frameinsert_framestart)
                        movieheader_endindex = frameinsert_framestart;
                }
                else
                {
                    if (movieheader_endindex > frameinsert_onframes[0])
                        movieheader_endindex = frameinsert_onframes[0];
                }
            };
            if (frameremove_do)
            {
                if (inputsearch_remove)
                {
                    if (movieheader_endindex > frameremove_framestart)
                        movieheader_endindex = frameremove_framestart-frameremove_max;
                }
                else
                {
                    if (movieheader_endindex > frameremove_onframes[0])
                        movieheader_endindex = frameremove_onframes[0]-frameremove_max;
                }
            };
            if (inputreplace_do)
            {
                if (inputsearch_replace)
                {
                    if (movieheader_endindex > inputreplace_framestart)
                        movieheader_endindex = inputreplace_framestart;
                }
                else
                {
                    if (movieheader_endindex > inputreplace_onframes[0])
                        movieheader_endindex = inputreplace_onframes[0];
                }
            };

            for ( int i = 0; i < movieheader_endindex; i++)
            {
                if( i >= movie.Input.FrameData.Length) break;
                for (int j = 0; j < movie.Input.ControllerCount; j++ )
                {
                    baseinput[i].Controller[j] = movie.Input.FrameData[i].Controller[j];
                }
            }

            //6. Build input list
            /// Just a buffer of input that the generator
            /// must not forget to add back to the movie
            ArrayList framesWithInputArray = new ArrayList();
            FrameWithInput fwi = new FrameWithInput(heldinput_max);
            String lastInput = "";
            int inputheldfor = 0;
            bool fwiset = false;

            //7. Perform input searches
            ArrayList insertCombinationsArray = new ArrayList();
            ArrayList removeCombinationsArray = new ArrayList();
            ArrayList replaceCombinationsArray = new ArrayList();

            //If there is input, add it to our list, we have to push this data
            for (int i = movieheader_endindex; i < movie.Input.FrameData.Length; i++)
            {
                String s = movie.Input.FrameData[i].Controller[0];
                if (s != lastInput)
                {
                    inputheldfor = 1;
                }
                else
                {
                    ++inputheldfor;
                    if (inputheldfor > heldinput_max && heldinput_max > 0 )
                        inputheldfor = 1;
                }
                lastInput = s;

                if (inputheldfor == 1)
                {
                    if (inputsearch_insert)
                    {
                        if (frameinsert_framestart <= i
                            && frameinsert_frameend >= i)
                        {
                            string[] sa = new string[0];
                            if (IsIncludedInInput(ref s, ref sa, true, false))
                            {
                                Combination c = new Combination();
                                c.total_values = frameinsert_max;
                                c.value = 0;
                                c.action = Combination.Actions.INSERT;
                                c.frame = i;
                                insertCombinationsArray.Add(c);
                            };
                        };
                    };
                    if (inputsearch_remove)
                    {
                        if (frameremove_framestart <= i
                            && frameremove_frameend >= i)
                        {
                            if (IsIncludedInInput(ref s, ref frameremove_inputs, true, true))
                            {
                                Combination c = new Combination();
                                c.total_values = frameremove_max;
                                c.value = 0;
                                c.action = Combination.Actions.REMOVE;
                                c.frame = i;
                                removeCombinationsArray.Add(c);
                            };
                        };
                    };
                    if (inputsearch_replace)
                    {
                        if (inputreplace_framestart <= i
                            && inputreplace_frameend >= i)
                        {
                            string[] sa = new string[0];
                            if (IsIncludedInInput(ref s, ref sa, true, inputreplace_includeidleframes_onsearch))
                            {
                                Combination c = new Combination();
                                c.total_values = inputreplace_inputs.Length;
                                c.value = 0;
                                c.action = Combination.Actions.REPLACE;
                                c.frame = i;
                                replaceCombinationsArray.Add(c);
                            };
                        };
                    };
                };

                if (s == "") continue;

                if (inputheldfor == 1 || fwi.total_input == fwi.Input.Length)
                {
                    if (fwiset) framesWithInputArray.Add(fwi);
                    fwi = new FrameWithInput(heldinput_max);
                    fwi.newframeposition = 0;
                    fwi.originalframeposition = i;
                    fwiset = true;
                };

                fwi.Input[fwi.total_input].Controller[0] = s;
                fwi.Input[fwi.total_input].Controller[1] = "";
                fwi.total_input++;
            }
            if (fwiset) framesWithInputArray.Add(fwi);
            framesWithInput = (FrameWithInput[]) framesWithInputArray.ToArray(typeof(FrameWithInput));

            if (!inputsearch_insert)
            {
                for ( int i = 0; i< frameinsert_onframes.Length ; i++ )
                {
                    Combination c = new Combination();
                    c.total_values = frameinsert_max;
                    c.value = 0;
                    c.action = Combination.Actions.INSERT;
                    c.frame = frameinsert_onframes[i];
                    insertCombinationsArray.Add(c);
                }
            };
            if (!inputsearch_remove)
            {
                for (int i = 0; i < frameremove_onframes.Length; i++)
                {
                    Combination c = new Combination();
                    c.total_values = frameremove_max;
                    c.value = 0;
                    c.action = Combination.Actions.REMOVE;
                    c.frame = frameremove_onframes[i];
                    removeCombinationsArray.Add(c);
                };
            };
            if (!inputsearch_replace)
            {
                for (int i = 0; i < inputreplace_onframes.Length; i++)
                {
                    Combination c = new Combination();
                    c.total_values = inputreplace_inputs.Length;
                    c.value = 0;
                    c.action = Combination.Actions.REPLACE;
                    c.frame = inputreplace_onframes[i];
                    replaceCombinationsArray.Add(c);
                };
            };

            insertCombinations = (Combination[])insertCombinationsArray.ToArray(typeof(Combination));
            removeCombinations = (Combination[])removeCombinationsArray.ToArray(typeof(Combination));
            replaceCombinations = (Combination[])replaceCombinationsArray.ToArray(typeof(Combination));

            if (!frameinsert_do && !frameremove_do && !inputreplace_do)
            {
                MessageBox.Show(MovieSplicer.UI.frmMain.frm,
                        "Open generator.config and edit the values, you do not want to do any generation according to the file. In any case use the real tas-movie-editor if you want to edit movies as usual, this program only generates random movies.",
                        "Couldn't generate movies",
                        MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);

                return false;
            };

            return true;
        }
Example #26
0
        /// <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)");
        }
Example #27
0
 /// <summary>
 /// Check if two TASMovieInput instances are equal
 /// </summary>        
 private bool areFramesEqual(TASMovieInput left, TASMovieInput right, int controllers)
 {
     for (int i = 0; i < controllers; i++)
         if (left.Controller[i] == null && right.Controller[i] == null) return true;
         else if (left.Controller[i] == right.Controller[i]) return true;
     return false;
 }
Example #28
0
 /// <summary>
 /// Convert an input's controller values to a string
 /// </summary>        
 private string frameEncode(TASMovieInput input, int controllers)
 {
     string temp = "";
     for (int i = 0; i < controllers; i++)
     {
         temp += "Controller #" + (i + 1) + ": ";
         for (int j = 0; j < inputIn.Length; j++)
             if(input.Controller[i] != null)
                 if (input.Controller[i].Contains(inputIn[j])) temp += inputOut[j] + " ";
         temp += "\n";
     }
     return temp;
 }
Example #29
0
        /// <summary>
        /// Copy a given number of frames at the desired position by extracting them to a new
        /// array
        /// </summary>        
        public static TASMovieInput[] Copy(ref TASMovieInput[] input, int[] indices)
        {
            TASMovieInput[] temp = new TASMovieInput[indices.Length];

            for (int i = 0; i < indices.Length; i++)
                temp[i] = input[indices[i]];

            return temp;
        }
Example #30
0
 /// <summary>
 /// overriden base method for saving back out to file
 /// </summary>        
 public virtual void Save(string filename, ref TASMovieInput[] input)
 {
     byte[] empty = null;
     WriteByteArrayToFile(ref empty, filename, -1, -1);
 }