public void GreenzoneCurrentFrame()
        {
            LagLog[Global.Emulator.Frame] = Global.Emulator.AsInputPollable().IsLagFrame;

            if (!StateManager.HasState(Global.Emulator.Frame))
            {
                StateManager.Capture();
            }
        }
Exemple #2
0
        // TODO: try not to need this, or at least use GetInputState and then a log entry generator
        public string GetInputLogEntry(int frame)
        {
            if (Global.Emulator.Frame == frame && !StateManager.HasState(frame))
            {
                StateManager.Capture();
            }

            if (Global.Emulator.Frame == frame && frame >= LagLog.Count)
            {
                LagLog.Add(Global.Emulator.IsLagFrame);
            }

            if (frame < FrameCount && frame >= 0)
            {
                int getframe;

                if (LoopOffset.HasValue)
                {
                    if (frame < _log.Count)
                    {
                        getframe = frame;
                    }
                    else
                    {
                        getframe = ((frame - LoopOffset.Value) % (_log.Count - LoopOffset.Value)) + LoopOffset.Value;
                    }
                }
                else
                {
                    getframe = frame;
                }

                return(_log[getframe]);
            }

            return(string.Empty);
        }
Exemple #3
0
        public void GreenzoneCurrentFrame()
        {
            if (Global.Emulator.Frame > LastValidFrame)
            {
                // emulated a new frame, current editing segment may change now. taseditor logic
                LastPositionStable = false;
            }

            _lagLog[Global.Emulator.Frame] = Global.Emulator.AsInputPollable().IsLagFrame;

            if (!_stateManager.HasState(Global.Emulator.Frame))
            {
                _stateManager.Capture(Global.Emulator.Frame == LastEditedFrame - 1);
            }
        }
Exemple #4
0
        public void GreenzoneCurrentFrame()
        {
            // todo: this isn't working quite right when autorestore is off and we're editing while seeking
            // but accounting for that requires access to Mainform.IsSeeking
            if (Global.Emulator.Frame > LastEditedFrame)
            {
                // emulated a new frame, current editing segment may change now. taseditor logic
                LastPositionStable = false;
            }

            _lagLog[Global.Emulator.Frame] = Global.Emulator.AsInputPollable().IsLagFrame;

            if (!_stateManager.HasState(Global.Emulator.Frame))
            {
                _stateManager.Capture(Global.Emulator.Frame == LastEditedFrame - 1);
            }
        }
Exemple #5
0
        public override bool Load(bool preload)
        {
            var file = new FileInfo(Filename);

            if (!file.Exists)
            {
                return(false);
            }

            using (var bl = BinaryStateLoader.LoadAndDetect(Filename, true))
            {
                if (bl == null)
                {
                    return(false);
                }

                ClearBeforeLoad();
                ClearTasprojExtras();

                bl.GetLump(BinaryStateLump.Movieheader, true, delegate(TextReader tr)
                {
                    string line;
                    while ((line = tr.ReadLine()) != null)
                    {
                        if (!string.IsNullOrWhiteSpace(line))
                        {
                            var pair = line.Split(new[] { ' ' }, 2, StringSplitOptions.RemoveEmptyEntries);

                            if (pair.Length > 1)
                            {
                                Header.Add(pair[0], pair[1]);
                            }
                        }
                    }
                });

                bl.GetLump(BinaryStateLump.Comments, true, delegate(TextReader tr)
                {
                    string line;
                    while ((line = tr.ReadLine()) != null)
                    {
                        if (!string.IsNullOrWhiteSpace(line))
                        {
                            Comments.Add(line);
                        }
                    }
                });

                bl.GetLump(BinaryStateLump.Subtitles, true, delegate(TextReader tr)
                {
                    string line;
                    while ((line = tr.ReadLine()) != null)
                    {
                        if (!string.IsNullOrWhiteSpace(line))
                        {
                            Subtitles.AddFromString(line);
                        }
                    }
                });

                bl.GetLump(BinaryStateLump.SyncSettings, true, delegate(TextReader tr)
                {
                    string line;
                    while ((line = tr.ReadLine()) != null)
                    {
                        if (!string.IsNullOrWhiteSpace(line))
                        {
                            SyncSettingsJson = line;
                        }
                    }
                });

                bl.GetLump(BinaryStateLump.Input, true, delegate(TextReader tr)                 // Note: ExtractInputLog will clear Lag and State data potentially, this must come before loading those
                {
                    IsCountingRerecords = false;
                    ExtractInputLog(tr, out _);
                    IsCountingRerecords = true;
                });

                if (StartsFromSavestate)
                {
                    bl.GetCoreState(
                        delegate(BinaryReader br, long length)
                    {
                        BinarySavestate = br.ReadBytes((int)length);
                    },
                        delegate(TextReader tr)
                    {
                        TextSavestate = tr.ReadToEnd();
                    });
                }
                else if (StartsFromSaveRam)
                {
                    bl.GetLump(BinaryStateLump.MovieSaveRam, false,
                               delegate(BinaryReader br, long length)
                    {
                        SaveRam = br.ReadBytes((int)length);
                    });
                }

                // TasMovie enhanced information
                bl.GetLump(BinaryStateLump.LagLog, false, delegate(TextReader tr)
                {
                    TasLagLog.Load(tr);
                });

                bl.GetLump(BinaryStateLump.StateHistorySettings, false, delegate(TextReader tr)
                {
                    var json = tr.ReadToEnd();
                    try
                    {
                        TasStateManager.Settings = JsonConvert.DeserializeObject <TasStateManagerSettings>(json);
                    }
                    catch
                    {
                        // Do nothing, and use default settings instead
                    }
                });

                bl.GetLump(BinaryStateLump.Markers, false, delegate(TextReader tr)
                {
                    string line;
                    while ((line = tr.ReadLine()) != null)
                    {
                        if (!string.IsNullOrWhiteSpace(line))
                        {
                            Markers.Add(new TasMovieMarker(line));
                        }
                    }
                });

                if (GetClientSettingsOnLoad != null)
                {
                    string clientSettings = "";
                    bl.GetLump(BinaryStateLump.ClientSettings, false, delegate(TextReader tr)
                    {
                        string line;
                        while ((line = tr.ReadLine()) != null)
                        {
                            if (!string.IsNullOrWhiteSpace(line))
                            {
                                clientSettings = line;
                            }
                        }
                    });

                    if (!string.IsNullOrWhiteSpace(clientSettings))
                    {
                        GetClientSettingsOnLoad(clientSettings);
                    }
                }

                bl.GetLump(BinaryStateLump.VerificationLog, false, delegate(TextReader tr)
                {
                    VerificationLog.Clear();
                    while (true)
                    {
                        var line = tr.ReadLine();
                        if (string.IsNullOrEmpty(line))
                        {
                            break;
                        }

                        if (line.StartsWith("|"))
                        {
                            VerificationLog.Add(line);
                        }
                    }
                });

                Branches.Load(bl, this);

                bl.GetLump(BinaryStateLump.Session, false, delegate(TextReader tr)
                {
                    var json = tr.ReadToEnd();
                    try
                    {
                        Session = JsonConvert.DeserializeObject <TasSession>(json);
                    }
                    catch
                    {
                        // Do nothing, and use default settings instead
                    }
                });

                if (!preload)
                {
                    if (TasStateManager.Settings.SaveStateHistory)
                    {
                        bl.GetLump(BinaryStateLump.StateHistory, false, delegate(BinaryReader br, long length)
                        {
                            TasStateManager.Load(br);
                        });
                    }

                    // Movie should always have a state at frame 0.
                    if (!StartsFromSavestate && Global.Emulator.Frame == 0)
                    {
                        TasStateManager.Capture();
                    }
                }
            }

            Changes = false;
            return(true);
        }