public SplitEventEditor(IEventWork <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 g in Work) { foreach (var item in g.Vars) { item.RawIndex = block.GetWorkRawIndex(item.Type, item.RelativeIndex); ((EventWork <T>)item).Value = block.GetWork(item.RawIndex); } } foreach (var g in Flag) { foreach (var item in g.Vars) { item.RawIndex = block.GetFlagRawIndex(item.Type, item.RelativeIndex); ((EventFlag)item).Flag = block.GetFlag(item.RawIndex); } } }
/// <summary> /// Compares a <see cref="before"/> and <see cref="after"/> <see cref="IEventWork{T}"/> object of the same type to find <see cref="EventWork{T}"/> changes. /// </summary> /// <typeparam name="T">Type of value used by <see cref="EventWork{T}"/></typeparam> /// <param name="before">Data before the event was triggered</param> /// <param name="after">Data after the event was triggered</param> /// <param name="changed"><see cref="EventVar.RawIndex"/> values that changed</param> /// <param name="changes">Summary of the <see cref="EventWork{T}"/> value change</param> public static void DiffSavesWork <T>(IEventWork <T> before, IEventWork <T> after, List <int> changed, List <string> changes) { int max = before.MaxWork; for (int i = 0; i < max; i++) { var b = before.GetWork(i); var a = after.GetWork(i); if (b is null || b.Equals(a)) { continue; } changed.Add(i); changes.Add($"{b} => {a}"); } }
private void ChangeConstantIndex(object sender, EventArgs e) { NUD_Stat.Value = SAV.GetWork(CB_Stats.SelectedIndex); }