예제 #1
0
        /// <summary>
        /// Removes lag log and greenzone after this frame
        /// </summary>
        /// <param name="frame">The last frame that can be valid.</param>
        private void InvalidateAfter(int frame)
        {
            var anyInvalidated = _lagLog.RemoveFrom(frame);

            _stateManager.Invalidate(frame + 1);
            Changes = true;             // TODO check if this actually removed anything before flagging changes

            if (anyInvalidated && Global.MovieSession.Movie.IsCountingRerecords)
            {
                Rerecords++;
            }
        }
예제 #2
0
파일: TasMovie.cs 프로젝트: radtek/BizHawk
        /// <summary>
        /// Removes lag log and greenzone after this frame
        /// </summary>
        /// <param name="frame">The last frame that can be valid.</param>
        private void InvalidateAfter(int frame)
        {
            var anyInvalidated = _lagLog.RemoveFrom(frame);

            _stateManager.Invalidate(frame + 1);
            Changes         = anyInvalidated;
            LastEditedFrame = frame;

            if (anyInvalidated && Global.MovieSession.Movie.IsCountingRerecords)
            {
                Rerecords++;
            }
        }
예제 #3
0
        public override void RecordFrame(int frame, IController source)
        {
            if (frame != 0)
            {
                ChangeLog.AddGeneralUndo(frame - 1, frame - 1, $"Record Frame: {frame}");
            }

            base.RecordFrame(frame, source);

            TasLagLog.RemoveFrom(frame);
            TasLagLog[frame] = Global.Emulator.AsInputPollable().IsLagFrame;

            if (this.IsRecording())
            {
                TasStateManager.Invalidate(frame + 1);
            }

            if (frame != 0)
            {
                ChangeLog.SetGeneralRedo();
            }
        }
예제 #4
0
        public override void Truncate(int frame)
        {
            bool endBatch = ChangeLog.BeginNewBatch($"Truncate Movie: {frame}", true);

            ChangeLog.AddGeneralUndo(frame, InputLogLength - 1);

            if (frame < Log.Count - 1)
            {
                Changes = true;
            }

            base.Truncate(frame);

            TasLagLog.RemoveFrom(frame);
            TasStateManager.Invalidate(frame);
            Markers.TruncateAt(frame);

            ChangeLog.SetGeneralRedo();
            if (endBatch)
            {
                ChangeLog.EndBatch();
            }
        }
예제 #5
0
        // TODO: this is 99% copy pasting of bad code
        public override bool ExtractInputLog(TextReader reader, out string errorMessage)
        {
            errorMessage = "";
            int?stateFrame = null;

            var newLog = new List <string>();

            // We are in record mode so replace the movie log with the one from the savestate
            if (!Global.MovieSession.MultiTrack.IsActive)
            {
                _timelineBranchFrame = null;

                if (Global.Config.EnableBackupMovies && MakeBackup && Log.Count != 0)
                {
                    SaveBackup();
                    MakeBackup = false;
                }

                int counter = 0;
                while (true)
                {
                    var line = reader.ReadLine();
                    if (string.IsNullOrEmpty(line))
                    {
                        break;
                    }

                    if (line.Contains("Frame 0x"))                     // NES stores frame count in hex, yay
                    {
                        var split = line.Split('x');
                        try
                        {
                            stateFrame = int.Parse(split[1], NumberStyles.HexNumber);
                        }
                        catch
                        {
                            errorMessage = "Savestate Frame number failed to parse";
                            return(false);
                        }
                    }
                    else if (line.Contains("Frame "))
                    {
                        var split = line.Split(' ');
                        try
                        {
                            stateFrame = int.Parse(split[1]);
                        }
                        catch
                        {
                            errorMessage = "Savestate Frame number failed to parse";
                            return(false);
                        }
                    }
                    else if (line.StartsWith("LogKey:"))
                    {
                        LogKey = line.Replace("LogKey:", "");
                    }
                    else if (line[0] == '|')
                    {
                        newLog.Add(line);
                        if (!_timelineBranchFrame.HasValue && counter < Log.Count && line != Log[counter])
                        {
                            _timelineBranchFrame = counter;
                        }

                        counter++;
                    }
                }

                Log.Clear();
                Log.AddRange(newLog);
            }
            else             // Multitrack mode
            {
                // TODO: consider TimelineBranchFrame here, my thinking is that there's never a scenario to invalidate state/lag data during multitrack
                var i = 0;
                while (true)
                {
                    var line = reader.ReadLine();
                    if (line == null)
                    {
                        break;
                    }

                    if (line.Contains("Frame 0x"))                     // NES stores frame count in hex, yay
                    {
                        var strs = line.Split('x');
                        try
                        {
                            stateFrame = int.Parse(strs[1], NumberStyles.HexNumber);
                        }
                        catch
                        {
                            errorMessage = "Savestate Frame number failed to parse";
                            return(false);
                        }
                    }
                    else if (line.Contains("Frame "))
                    {
                        var strs = line.Split(' ');
                        try
                        {
                            stateFrame = int.Parse(strs[1]);
                        }
                        catch
                        {
                            errorMessage = "Savestate Frame number failed to parse";
                            return(false);
                        }
                    }
                    else if (line.StartsWith("LogKey:"))
                    {
                        LogKey = line.Replace("LogKey:", "");
                    }
                    else if (line.StartsWith("|"))
                    {
                        SetFrame(i, line);
                        i++;
                    }
                }
            }

            if (!stateFrame.HasValue)
            {
                errorMessage = "Savestate Frame number failed to parse";
            }

            var stateFrameValue = stateFrame ?? 0;

            if (stateFrameValue > 0 && stateFrameValue < Log.Count)
            {
                if (!Global.Config.VBAStyleMovieLoadState)
                {
                    Truncate(stateFrameValue);
                }
            }
            else if (stateFrameValue > Log.Count)             // Post movie savestate
            {
                if (!Global.Config.VBAStyleMovieLoadState)
                {
                    Truncate(Log.Count);
                }

                Mode = MovieMode.Finished;
            }

            if (IsCountingRerecords)
            {
                Rerecords++;
            }

            if (_timelineBranchFrame.HasValue)
            {
                TasLagLog.RemoveFrom(_timelineBranchFrame.Value);
                TasStateManager.Invalidate(_timelineBranchFrame.Value);
            }

            return(true);
        }
예제 #6
0
		/// <summary>
		/// Removes lag log and greenzone after this frame
		/// </summary>
		/// <param name="frame">The last frame that can be valid.</param>
		private void InvalidateAfter(int frame)
		{
			LagLog.RemoveFrom(frame);
			StateManager.Invalidate(frame + 1);
			Changes = true; // TODO check if this actually removed anything before flagging changes
		}