From 3c637785cb5f541911d254553981ffc53ce3d3e0 Mon Sep 17 00:00:00 2001 From: ooterness Date: Mon, 17 Feb 2020 15:47:30 -0800 Subject: [PATCH 1/2] Added a new column type: "Completed Splits" --- UI/ColumnType.cs | 2 +- UI/Components/ColumnSettings.Designer.cs | 13 +++++-------- UI/Components/ColumnSettings.cs | 2 ++ UI/Components/SplitComponent.cs | 12 +++++++----- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/UI/ColumnType.cs b/UI/ColumnType.cs index 3d32ce6..0ad51c0 100644 --- a/UI/ColumnType.cs +++ b/UI/ColumnType.cs @@ -2,6 +2,6 @@ { public enum ColumnType { - Delta, SplitTime, DeltaorSplitTime, SegmentDelta, SegmentTime, SegmentDeltaorSegmentTime + Delta, SplitTime, CompletedSplits, DeltaorSplitTime, SegmentDelta, SegmentTime, SegmentDeltaorSegmentTime } } diff --git a/UI/Components/ColumnSettings.Designer.cs b/UI/Components/ColumnSettings.Designer.cs index 5c3a4d7..39c9214 100644 --- a/UI/Components/ColumnSettings.Designer.cs +++ b/UI/Components/ColumnSettings.Designer.cs @@ -1,4 +1,6 @@ -namespace LiveSplit.UI.Components +using System.Linq; + +namespace LiveSplit.UI.Components { partial class ColumnSettings { @@ -127,17 +129,12 @@ private void InitializeComponent() // // cmbColumnType // + System.Collections.IEnumerable colNames = from ColumnType type in System.Enum.GetValues(typeof(ColumnType)) select ColumnSettings.GetColumnType(type); this.cmbColumnType.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); this.tableLayoutPanel1.SetColumnSpan(this.cmbColumnType, 3); this.cmbColumnType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbColumnType.FormattingEnabled = true; - this.cmbColumnType.Items.AddRange(new object[] { - "Delta", - "Split Time", - "Delta or Split Time", - "Segment Delta", - "Segment Time", - "Segment Delta or Segment Time"}); + this.cmbColumnType.Items.AddRange(colNames.Cast().ToArray()); this.cmbColumnType.Location = new System.Drawing.Point(93, 33); this.cmbColumnType.Name = "cmbColumnType"; this.cmbColumnType.Size = new System.Drawing.Size(325, 21); diff --git a/UI/Components/ColumnSettings.cs b/UI/Components/ColumnSettings.cs index c70a8c1..bdacc04 100644 --- a/UI/Components/ColumnSettings.cs +++ b/UI/Components/ColumnSettings.cs @@ -106,6 +106,8 @@ private static string GetColumnType(ColumnType type) { if (type == ColumnType.SplitTime) return "Split Time"; + else if (type == ColumnType.CompletedSplits) + return "Completed Splits"; else if (type == ColumnType.Delta) return "Delta"; else if (type == ColumnType.DeltaorSplitTime) diff --git a/UI/Components/SplitComponent.cs b/UI/Components/SplitComponent.cs index cdf6f9f..7774807 100644 --- a/UI/Components/SplitComponent.cs +++ b/UI/Components/SplitComponent.cs @@ -369,11 +369,12 @@ protected void UpdateColumn(LiveSplitState state, SimpleLabel label, ColumnData var splitIndex = state.Run.IndexOf(Split); if (splitIndex < state.CurrentSplitIndex) { - if (type == ColumnType.SplitTime || type == ColumnType.SegmentTime) + // Formatting for each completed segment. + if (type == ColumnType.SplitTime || type == ColumnType.CompletedSplits || type == ColumnType.SegmentTime) { label.ForeColor = Settings.OverrideTimesColor ? Settings.BeforeTimesColor : state.LayoutSettings.TextColor; - if (type == ColumnType.SplitTime) + if (type == ColumnType.SplitTime || type == ColumnType.CompletedSplits) { label.Text = TimeFormatter.Format(Split.SplitTime[timingMethod]); } @@ -404,7 +405,7 @@ protected void UpdateColumn(LiveSplitState state, SimpleLabel label, ColumnData label.Text = DeltaTimeFormatter.Format(deltaTime); } - else if (type == ColumnType.SegmentDeltaorSegmentTime || type == ColumnType.SegmentDelta) + if (type == ColumnType.SegmentDeltaorSegmentTime || type == ColumnType.SegmentDelta) { var segmentDelta = LiveSplitStateHelper.GetPreviousSegmentDelta(state, splitIndex, comparison, timingMethod); var color = LiveSplitStateHelper.GetSplitColor(state, segmentDelta, splitIndex, false, true, comparison, timingMethod); @@ -427,6 +428,7 @@ protected void UpdateColumn(LiveSplitState state, SimpleLabel label, ColumnData } else { + // Formatting for each active or upcoming segment. if (type == ColumnType.SplitTime || type == ColumnType.SegmentTime || type == ColumnType.DeltaorSplitTime || type == ColumnType.SegmentDeltaorSegmentTime) { if (Split == state.CurrentSplit) @@ -441,7 +443,7 @@ protected void UpdateColumn(LiveSplitState state, SimpleLabel label, ColumnData else //SegmentTime or SegmentTimeorSegmentDeltaTime { var previousTime = TimeSpan.Zero; - for (var index = splitIndex - 1; index >= 0; index --) + for (var index = splitIndex - 1; index >= 0; index--) { var comparisonTime = state.Run[index].Comparisons[comparison][timingMethod]; if (comparisonTime != null) @@ -463,7 +465,7 @@ protected void UpdateColumn(LiveSplitState state, SimpleLabel label, ColumnData label.Text = DeltaTimeFormatter.Format(bestDelta); label.ForeColor = Settings.OverrideDeltasColor ? Settings.DeltasColor : state.LayoutSettings.TextColor; } - else if (type == ColumnType.Delta || type == ColumnType.SegmentDelta) + else if (type == ColumnType.Delta || type == ColumnType.SegmentDelta || type == ColumnType.CompletedSplits) { label.Text = ""; } From 5077230e0b044334d58954832a053e837887ed8d Mon Sep 17 00:00:00 2001 From: ooterness Date: Mon, 17 Feb 2020 16:36:00 -0800 Subject: [PATCH 2/2] Added a new column type: "Reference Splits" Moved column-type enumeration to avoid breaking auto-generated code. --- UI/ColumnType.cs | 2 +- UI/Components/ColumnSettings.Designer.cs | 6 +----- UI/Components/ColumnSettings.cs | 6 ++++++ UI/Components/SplitComponent.cs | 7 +++++++ 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/UI/ColumnType.cs b/UI/ColumnType.cs index 0ad51c0..80f830d 100644 --- a/UI/ColumnType.cs +++ b/UI/ColumnType.cs @@ -2,6 +2,6 @@ { public enum ColumnType { - Delta, SplitTime, CompletedSplits, DeltaorSplitTime, SegmentDelta, SegmentTime, SegmentDeltaorSegmentTime + Delta, SplitTime, CompletedSplits, ReferenceSplits, DeltaorSplitTime, SegmentDelta, SegmentTime, SegmentDeltaorSegmentTime } } diff --git a/UI/Components/ColumnSettings.Designer.cs b/UI/Components/ColumnSettings.Designer.cs index 39c9214..18a0ebc 100644 --- a/UI/Components/ColumnSettings.Designer.cs +++ b/UI/Components/ColumnSettings.Designer.cs @@ -1,6 +1,4 @@ -using System.Linq; - -namespace LiveSplit.UI.Components +namespace LiveSplit.UI.Components { partial class ColumnSettings { @@ -129,12 +127,10 @@ private void InitializeComponent() // // cmbColumnType // - System.Collections.IEnumerable colNames = from ColumnType type in System.Enum.GetValues(typeof(ColumnType)) select ColumnSettings.GetColumnType(type); this.cmbColumnType.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); this.tableLayoutPanel1.SetColumnSpan(this.cmbColumnType, 3); this.cmbColumnType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbColumnType.FormattingEnabled = true; - this.cmbColumnType.Items.AddRange(colNames.Cast().ToArray()); this.cmbColumnType.Location = new System.Drawing.Point(93, 33); this.cmbColumnType.Name = "cmbColumnType"; this.cmbColumnType.Size = new System.Drawing.Size(325, 21); diff --git a/UI/Components/ColumnSettings.cs b/UI/Components/ColumnSettings.cs index bdacc04..aa7bcf5 100644 --- a/UI/Components/ColumnSettings.cs +++ b/UI/Components/ColumnSettings.cs @@ -37,6 +37,10 @@ public ColumnSettings(LiveSplitState state, string columnName, IList().ToArray()); + Data = new ColumnData(columnName, ColumnType.Delta, "Current Comparison", "Current Timing Method"); CurrentState = state; @@ -108,6 +112,8 @@ private static string GetColumnType(ColumnType type) return "Split Time"; else if (type == ColumnType.CompletedSplits) return "Completed Splits"; + else if (type == ColumnType.ReferenceSplits) + return "Reference Splits"; else if (type == ColumnType.Delta) return "Delta"; else if (type == ColumnType.DeltaorSplitTime) diff --git a/UI/Components/SplitComponent.cs b/UI/Components/SplitComponent.cs index 7774807..fa3ab47 100644 --- a/UI/Components/SplitComponent.cs +++ b/UI/Components/SplitComponent.cs @@ -366,6 +366,13 @@ protected void UpdateColumn(LiveSplitState state, SimpleLabel label, ColumnData var type = data.Type; + if (type == ColumnType.ReferenceSplits) + { + label.ForeColor = state.LayoutSettings.TextColor; + label.Text = TimeFormatter.Format(Split.Comparisons[comparison][timingMethod]); + return; + } + var splitIndex = state.Run.IndexOf(Split); if (splitIndex < state.CurrentSplitIndex) {