示例#1
0
        private void AddTasProjLumps(ZipStateSaver bs, bool isBackup = false)
        {
            var settings = JsonConvert.SerializeObject(TasStateManager.Settings);

            bs.PutLump(BinaryStateLump.StateHistorySettings, tw => tw.WriteLine(settings));
            bs.PutLump(BinaryStateLump.LagLog, tw => LagLog.Save(tw));
            bs.PutLump(BinaryStateLump.Markers, tw => tw.WriteLine(Markers.ToString()));

            if (ClientSettingsForSave != null)
            {
                var clientSettingsJson = ClientSettingsForSave();
                bs.PutLump(BinaryStateLump.ClientSettings, (TextWriter tw) => tw.Write(clientSettingsJson));
            }

            if (VerificationLog.Any())
            {
                bs.PutLump(BinaryStateLump.VerificationLog, tw => tw.WriteLine(VerificationLog.ToInputLog()));
            }

            if (Branches.Any())
            {
                Branches.Save(bs);
            }

            bs.PutLump(BinaryStateLump.Session, tw => tw.WriteLine(JsonConvert.SerializeObject(TasSession)));

            if (TasStateManager.Settings.SaveStateHistory && !isBackup)
            {
                bs.PutLump(BinaryStateLump.StateHistory, bw => TasStateManager.Save(bw));
            }
        }
示例#2
0
            private bool IsEndOfDifferentColor(Point p, Point d, int color)
            {
                return(false);

                Point p2 = Grid.NeigbourCoordinates(p, d);

                return(Branches.Any(b => b.Color != color && b.Last() == p2));
            }
示例#3
0
        private void GetBranches()
        {
            using (var unitOfWork = new UnitOfWork())
            {
                if (!Branches.Any())
                {
                    Branches.Clear();
                    Branches.Add(new Branch()
                    {
                        branch_name = ""
                    });
                    Branches.AddRange(unitOfWork.BranchRepository.GetAll());
                }

                branchBindingSource.DataSource = Branches;
            }
        }
示例#4
0
        private void LoadBranches(string branchType)
        {
            cbManageType.Enabled = false;
            btnFinish.Enabled    = false;

            cbBranches.DataSource = new List <string> {
                _loading.Text
            };
            if (!Branches.ContainsKey(branchType))
            {
                _task.LoadAsync(() => GetBranches(branchType), branches =>
                {
                    Branches.Add(branchType, branches);
                    DisplayBranchData();
                });
            }
            else
            {
                DisplayBranchData();
            }

            btnFinish.Enabled = Branches.Any();
        }
示例#5
0
 public bool ContainsEdge(INode source, INode target)
 {
     return(Branches.Any(b => b.Source == source && b.Target == target));
 }
示例#6
0
        protected override void Write(string fn, bool backup = false)
        {
            var file = new FileInfo(fn);

            if (!file.Directory.Exists)
            {
                Directory.CreateDirectory(file.Directory.ToString());
            }

            using (var bs = new BinaryStateSaver(fn, false))
            {
                bs.PutLump(BinaryStateLump.Movieheader, tw => tw.WriteLine(Header.ToString()));
                bs.PutLump(BinaryStateLump.Comments, tw => tw.WriteLine(CommentsString()));
                bs.PutLump(BinaryStateLump.Subtitles, tw => tw.WriteLine(Subtitles.ToString()));
                bs.PutLump(BinaryStateLump.SyncSettings, tw => tw.WriteLine(SyncSettingsJson));
                bs.PutLump(BinaryStateLump.Input, tw => WriteInputLog(tw));

                // TasProj extras
                bs.PutLump(BinaryStateLump.StateHistorySettings, tw => tw.WriteLine(StateManager.Settings.ToString()));

                bs.PutLump(BinaryStateLump.LagLog, (BinaryWriter bw) => LagLog.Save(bw));
                bs.PutLump(BinaryStateLump.Markers, tw => tw.WriteLine(Markers.ToString()));

                if (StartsFromSavestate)
                {
                    if (TextSavestate != null)
                    {
                        bs.PutLump(BinaryStateLump.CorestateText, (TextWriter tw) => tw.Write(TextSavestate));
                    }
                    else
                    {
                        bs.PutLump(BinaryStateLump.Corestate, (BinaryWriter bw) => bw.Write(BinarySavestate));
                    }
                }
                else if (StartsFromSaveRam)
                {
                    bs.PutLump(BinaryStateLump.MovieSaveRam, (BinaryWriter bw) => bw.Write(SaveRam));
                }

                if (ClientSettingsForSave != null)
                {
                    var clientSettingsJson = ClientSettingsForSave();
                    bs.PutLump(BinaryStateLump.ClientSettings, (TextWriter tw) => tw.Write(clientSettingsJson));
                }

                if (VerificationLog.Any())
                {
                    bs.PutLump(BinaryStateLump.VerificationLog, tw => tw.WriteLine(InputLogToString(VerificationLog)));
                }

                if (Branches.Any())
                {
                    Branches.Save(bs);
                    if (StateManager.Settings.BranchStatesInTasproj)
                    {
                        bs.PutLump(BinaryStateLump.BranchStateHistory, (BinaryWriter bw) => StateManager.SaveBranchStates(bw));
                    }
                }

                bs.PutLump(BinaryStateLump.Session, tw => tw.WriteLine(Session.ToString()));

                if (StateManager.Settings.SaveStateHistory)
                {
                    bs.PutLump(BinaryStateLump.StateHistory, (BinaryWriter bw) => StateManager.Save(bw));
                }
            }

            if (!backup)
            {
                Changes = false;
            }
        }
示例#7
0
 public bool HasBranches()
 {
     return(Branches.Any(x => x.IsDefault == false));
 }
示例#8
0
        protected override void Write(string fn, bool isBackup = false)
        {
            if (Emulator is Emulation.Cores.Nintendo.SubNESHawk.SubNESHawk subNes)
            {
                Header[HeaderKeys.VBlankCount] = subNes.VblankCount.ToString();
            }
            else if (Emulator is Emulation.Cores.Nintendo.Gameboy.Gameboy gameboy)
            {
                Header[HeaderKeys.CycleCount] = gameboy.CycleCount.ToString();
            }
            else if (Emulator is Emulation.Cores.Nintendo.SubGBHawk.SubGBHawk subGb)
            {
                Header[HeaderKeys.CycleCount] = subGb.CycleCount.ToString();
            }

            var file = new FileInfo(fn);

            if (file.Directory != null && !file.Directory.Exists)
            {
                Directory.CreateDirectory(file.Directory.ToString());
            }

            using var bs = new ZipStateSaver(fn, Global.Config.Savestates.MovieCompressionLevel);
            bs.PutLump(BinaryStateLump.Movieheader, tw => tw.WriteLine(Header.ToString()));
            bs.PutLump(BinaryStateLump.Comments, tw => tw.WriteLine(CommentsString()));
            bs.PutLump(BinaryStateLump.Subtitles, tw => tw.WriteLine(Subtitles.ToString()));
            bs.PutLump(BinaryStateLump.SyncSettings, tw => tw.WriteLine(SyncSettingsJson));
            bs.PutLump(BinaryStateLump.Input, WriteInputLog);

            // TasProj extras
            var settings = JsonConvert.SerializeObject(TasStateManager.Settings);

            bs.PutLump(BinaryStateLump.StateHistorySettings, tw => tw.WriteLine(settings));

            bs.PutLump(BinaryStateLump.LagLog, tw => LagLog.Save(tw));
            bs.PutLump(BinaryStateLump.Markers, tw => tw.WriteLine(Markers.ToString()));

            if (StartsFromSavestate)
            {
                if (TextSavestate != null)
                {
                    bs.PutLump(BinaryStateLump.CorestateText, (TextWriter tw) => tw.Write(TextSavestate));
                }
                else
                {
                    bs.PutLump(BinaryStateLump.Corestate, (BinaryWriter bw) => bw.Write(BinarySavestate));
                }
            }
            else if (StartsFromSaveRam)
            {
                bs.PutLump(BinaryStateLump.MovieSaveRam, (BinaryWriter bw) => bw.Write(SaveRam));
            }

            if (ClientSettingsForSave != null)
            {
                var clientSettingsJson = ClientSettingsForSave();
                bs.PutLump(BinaryStateLump.ClientSettings, (TextWriter tw) => tw.Write(clientSettingsJson));
            }

            if (VerificationLog.Any())
            {
                bs.PutLump(BinaryStateLump.VerificationLog, tw => tw.WriteLine(VerificationLog.ToInputLog()));
            }

            if (Branches.Any())
            {
                Branches.Save(bs);
            }

            bs.PutLump(BinaryStateLump.Session, tw => tw.WriteLine(JsonConvert.SerializeObject(TasSession)));

            if (TasStateManager.Settings.SaveStateHistory && !isBackup)
            {
                bs.PutLump(BinaryStateLump.StateHistory, bw => TasStateManager.Save(bw));
            }

            if (!isBackup)
            {
                Changes = false;
            }
        }
示例#9
0
 public bool HasConditionalBranches(string condition)
 {
     return(null != Branches && Branches.Any(x => x.ConditionId.ToLower() == condition.ToLower()));
 }