public GradedColumnSettings(LiveSplitState state, string columnName, IList <GradedColumnSettings> columnsList) { InitializeComponent(); Data = new GradedColumnData(columnName, GradedColumnType.Delta, "Current Comparison", "Current Timing Method"); CurrentState = state; ColumnsList = columnsList; }
protected void UpdateColumn(LiveSplitState state, SimpleLabel label, GradedColumnData data) { var comparison = data.Comparison == "Current Comparison" ? state.CurrentComparison : data.Comparison; if (!state.Run.Comparisons.Contains(comparison)) { comparison = state.CurrentComparison; } var timingMethod = state.CurrentTimingMethod; if (data.TimingMethod == "Real Time") { timingMethod = TimingMethod.RealTime; } else if (data.TimingMethod == "Game Time") { timingMethod = TimingMethod.GameTime; } var type = data.Type; var splitIndex = state.Run.IndexOf(Split); if (splitIndex < state.CurrentSplitIndex) { if (type == GradedColumnType.SplitTime || type == GradedColumnType.SegmentTime) { label.ForeColor = Settings.OverrideTimesColor ? Settings.BeforeTimesColor : state.LayoutSettings.TextColor; if (type == GradedColumnType.SplitTime) { label.Text = TimeFormatter.Format(Split.SplitTime[timingMethod]); } else //SegmentTime { var segmentTime = LiveSplitStateHelper.GetPreviousSegmentTime(state, splitIndex, timingMethod); label.Text = TimeFormatter.Format(segmentTime); } } if (type == GradedColumnType.DeltaorSplitTime || type == GradedColumnType.Delta) { var deltaTime = Split.SplitTime[timingMethod] - Split.Comparisons[comparison][timingMethod]; var color = LiveSplitStateHelper.GetSplitColor(state, deltaTime, splitIndex, true, true, comparison, timingMethod); if (color == null) { color = Settings.OverrideTimesColor ? Settings.BeforeTimesColor : state.LayoutSettings.TextColor; } label.ForeColor = color.Value; if (type == GradedColumnType.DeltaorSplitTime) { if (deltaTime != null) { label.Text = DeltaTimeFormatter.Format(deltaTime); } else { label.Text = TimeFormatter.Format(Split.SplitTime[timingMethod]); } } else if (type == GradedColumnType.Delta) { label.Text = DeltaTimeFormatter.Format(deltaTime); } } else if (type == GradedColumnType.SegmentDeltaorSegmentTime || type == GradedColumnType.SegmentDelta) { var segmentDelta = LiveSplitStateHelper.GetPreviousSegmentDelta(state, splitIndex, comparison, timingMethod); var color = LiveSplitStateHelper.GetSplitColor(state, segmentDelta, splitIndex, false, true, comparison, timingMethod); if (color == null) { color = Settings.OverrideTimesColor ? Settings.BeforeTimesColor : state.LayoutSettings.TextColor; } label.ForeColor = color.Value; if (type == GradedColumnType.SegmentDeltaorSegmentTime) { if (segmentDelta != null) { label.Text = DeltaTimeFormatter.Format(segmentDelta); } else { label.Text = TimeFormatter.Format(LiveSplitStateHelper.GetPreviousSegmentTime(state, splitIndex, timingMethod)); } } else if (type == GradedColumnType.SegmentDelta) { label.Text = DeltaTimeFormatter.Format(segmentDelta); } } } else { if (type == GradedColumnType.SplitTime || type == GradedColumnType.SegmentTime || type == GradedColumnType.DeltaorSplitTime || type == GradedColumnType.SegmentDeltaorSegmentTime) { if (Split == state.CurrentSplit) { label.ForeColor = Settings.OverrideTimesColor ? Settings.CurrentTimesColor : state.LayoutSettings.TextColor; } else { label.ForeColor = Settings.OverrideTimesColor ? Settings.AfterTimesColor : state.LayoutSettings.TextColor; } if (type == GradedColumnType.SplitTime || type == GradedColumnType.DeltaorSplitTime) { label.Text = TimeFormatter.Format(Split.Comparisons[comparison][timingMethod]); } else //SegmentTime or SegmentTimeorSegmentDeltaTime { var previousTime = TimeSpan.Zero; for (var index = splitIndex - 1; index >= 0; index--) { var comparisonTime = state.Run[index].Comparisons[comparison][timingMethod]; if (comparisonTime != null) { previousTime = comparisonTime.Value; break; } } label.Text = TimeFormatter.Format(Split.Comparisons[comparison][timingMethod] - previousTime); } } //Live Delta var splitDelta = type == GradedColumnType.DeltaorSplitTime || type == GradedColumnType.Delta; var bestDelta = LiveSplitStateHelper.CheckLiveDelta(state, splitDelta, comparison, timingMethod); if (bestDelta != null && Split == state.CurrentSplit && (type == GradedColumnType.DeltaorSplitTime || type == GradedColumnType.Delta || type == GradedColumnType.SegmentDeltaorSegmentTime || type == GradedColumnType.SegmentDelta)) { label.Text = DeltaTimeFormatter.Format(bestDelta); label.ForeColor = Settings.OverrideDeltasColor ? Settings.DeltasColor : state.LayoutSettings.TextColor; } else if (type == GradedColumnType.Delta || type == GradedColumnType.SegmentDelta) { label.Text = ""; } } }