예제 #1
0
    public SplitEventEditor(IEventVar <T> block, IEnumerable <string> work, IEnumerable <string> flag)
    {
        Block = block;
        // load lines
        var workLines = work.Where(z => !string.IsNullOrWhiteSpace(z) && z.Length > 5);

        Work = EventWorkUtil.GetVars(workLines, (index, t, data) => new EventWork <T>(index, t, data));
        var flagLines = flag.Where(z => !string.IsNullOrWhiteSpace(z) && z.Length > 5);

        Flag = EventWorkUtil.GetVars(flagLines, (index, t, data) => new EventFlag(index, t, data));

        // initialize lines
        foreach (var group in Work)
        {
            foreach (var item in group.Vars)
            {
                item.RawIndex = block.GetWorkRawIndex(item.Type, item.RelativeIndex);
                ((EventWork <T>)item).Value = block.GetWork(item.RawIndex);
            }
        }
        foreach (var group in Flag)
        {
            foreach (var item in group.Vars)
            {
                item.RawIndex          = block.GetFlagRawIndex(item.Type, item.RelativeIndex);
                ((EventFlag)item).Flag = block.GetFlag(item.RawIndex);
            }
        }
    }
        private void DiffSaves()
        {
            if (!File.Exists(TB_OldSAV.Text))
            {
                WinFormsUtil.Alert(string.Format(MsgSaveNumberInvalid, 1)); return;
            }
            if (!File.Exists(TB_NewSAV.Text))
            {
                WinFormsUtil.Alert(string.Format(MsgSaveNumberInvalid, 2)); return;
            }
            if (new FileInfo(TB_OldSAV.Text).Length > 0x100000)
            {
                WinFormsUtil.Alert(string.Format(MsgSaveNumberInvalid, 1)); return;
            }
            if (new FileInfo(TB_NewSAV.Text).Length > 0x100000)
            {
                WinFormsUtil.Alert(string.Format(MsgSaveNumberInvalid, 2)); return;
            }

            var s1 = SaveUtil.GetVariantSAV(TB_OldSAV.Text);
            var s2 = SaveUtil.GetVariantSAV(TB_NewSAV.Text);

            if (s1 == null)
            {
                WinFormsUtil.Alert(string.Format(MsgSaveNumberInvalid, 1)); return;
            }
            if (s2 == null)
            {
                WinFormsUtil.Alert(string.Format(MsgSaveNumberInvalid, 2)); return;
            }

            if (s1.GetType() != s2.GetType())
            {
                WinFormsUtil.Alert(MsgSaveDifferentTypes, $"S1: {s1.GetType().Name}", $"S2: {s2.GetType().Name}"); return;
            }
            if (s1.Version != s2.Version)
            {
                WinFormsUtil.Alert(MsgSaveDifferentVersions, $"S1: {s1.Version}", $"S2: {s2.Version}"); return;
            }

            EventWorkUtil.DiffSavesFlag(((SAV7b)s1).EventWork, ((SAV7b)s2).EventWork, out var on, out var off);
            EventWorkUtil.DiffSavesWork(((SAV7b)s1).EventWork, ((SAV7b)s2).EventWork, out var changed, out var changes);

            var ew = ((SAV7b)s1).EventWork;

            var fOn = on.Select(z => new { Type = ew.GetFlagType(z, out var subIndex), Index = subIndex, Raw = z })