void UpdateTwitch(object sender, EventArgs e) { new Thread(() => { try { if (IsLoggedIn) { var state = AutoUpdateModel.CurrentState; var phase = state.CurrentPhase; var run = state.Run; var deltaFormatter = new DeltaTimeFormatter(); var title = $"{run.GameName} - {run.CategoryName} Speedrun"; if (phase == TimerPhase.Running) { if (state.CurrentSplitIndex > 0) { var lastSplit = run[state.CurrentSplitIndex - 1]; var delta = deltaFormatter.Format(lastSplit.SplitTime[state.CurrentTimingMethod] - lastSplit.PersonalBestSplitTime[state.CurrentTimingMethod]); var splitname = lastSplit.Name; title = $"{title} ({delta} on {splitname})"; } } SetStreamTitleAndGame(title); } } catch (Exception ex) { Log.Error(ex); } }).Start(); }
public void TestMagnitudeSeconds2() { var entry = new DeltaTimeFormatter(TimeSpan.FromSeconds(2)); entry.ToString().Should().Be("+2 sec"); entry = new DeltaTimeFormatter(-TimeSpan.FromSeconds(2)); entry.ToString().Should().Be("-2 sec"); }
public void TestMagnitudeHours2() { var entry = new DeltaTimeFormatter(TimeSpan.FromHours(2)); entry.ToString().Should().Be("+2 hours"); entry = new DeltaTimeFormatter(-TimeSpan.FromHours(2)); entry.ToString().Should().Be("-2 hours"); }
public void TestMagnitudeMinutes2() { var entry = new DeltaTimeFormatter(TimeSpan.FromMinutes(2)); entry.ToString().Should().Be("+2 min"); entry = new DeltaTimeFormatter(-TimeSpan.FromMinutes(2)); entry.ToString().Should().Be("-2 min"); }
public void TestMagnitudeDays1() { var entry = new DeltaTimeFormatter(TimeSpan.FromDays(1)); entry.ToString().Should().Be("+1 day"); entry = new DeltaTimeFormatter(-TimeSpan.FromDays(1)); entry.ToString().Should().Be("-1 day"); }
public void TestMagnitudeMilliseconds1() { var entry = new DeltaTimeFormatter(TimeSpan.FromMilliseconds(1)); entry.ToString().Should().Be("+1 ms"); entry = new DeltaTimeFormatter(-TimeSpan.FromMilliseconds(1)); entry.ToString().Should().Be("-1 ms"); }
public PreviousSegment(LiveSplitState state) { DeltaFormatter = new DeltaTimeFormatter(); TimeSaveFormatter = new PossibleTimeSaveFormatter(); Settings = new PreviousSegmentSettings() { CurrentState = state }; InternalComponent = new InfoTimeComponent(null, null, DeltaFormatter); state.ComparisonRenamed += state_ComparisonRenamed; }
public void DeltaTimeFormatterFormatsTimeAsDash_WhenTimeIsNullAndAccuracyIsInHundredths() { var sut = new DeltaTimeFormatter { Accuracy = TimeAccuracy.Hundredths, DropDecimals = false }; var formattedTime = sut.Format(null); Assert.Equal(TimeFormatConstants.DASH, formattedTime); }
public void DeltaTimeFormatterFormatsTimeInGivenAccuracy_WhenTimeIsValid(string timespanText, TimeAccuracy timeAccuracy, bool dropDecimals, string expectedDelta) { var sut = new DeltaTimeFormatter { Accuracy = timeAccuracy, DropDecimals = dropDecimals }; var time = TimeSpan.Parse(timespanText); var formattedDelta = sut.Format(time); Assert.Equal(expectedDelta, formattedDelta); }
private string FormatNotes(string notePlaceholder) { var timeFormatter = new RegularTimeFormatter(TimeAccuracy.Seconds); var deltaTimeFormatter = new DeltaTimeFormatter(); var game = Run.GameName ?? ""; var category = Run.GetExtendedCategoryName(); var pb = timeFormatter.Format(Run.Last().PersonalBestSplitTime[State.CurrentTimingMethod]) ?? ""; var title = Run.GetExtendedName(); var splitName = ""; var splitTime = "-"; var deltaTime = "-"; if ((State.CurrentPhase == TimerPhase.Running || State.CurrentPhase == TimerPhase.Paused) && State.CurrentSplitIndex > 0) { var lastSplit = Run[State.CurrentSplitIndex - 1]; splitName = lastSplit.Name ?? ""; splitTime = timeFormatter.Format(lastSplit.SplitTime[State.CurrentTimingMethod]); deltaTime = deltaTimeFormatter.Format(lastSplit.SplitTime[State.CurrentTimingMethod] - lastSplit.PersonalBestSplitTime[State.CurrentTimingMethod]); } var streamLink = ""; if (notePlaceholder.Contains("$stream")) { try { if (Twitch.Instance.IsLoggedIn || Twitch.Instance.VerifyLogin()) { var userName = Twitch.Instance.ChannelName; streamLink = string.Format("http://twitch.tv/{0}", userName); } } catch { } } return(notePlaceholder .Replace("$game", game) .Replace("$category", category) .Replace("$title", title) .Replace("$pb", pb) .Replace("$splitname", splitName) .Replace("$splittime", splitTime) .Replace("$delta", deltaTime) .Replace("$stream", streamLink)); }
public string Format(TimeSpan?time) { var deltaTime = new DeltaTimeFormatter(); deltaTime.Accuracy = Accuracy; deltaTime.DropDecimals = DropDecimals; var formattedTime = deltaTime.Format(time); if (time == null) { return("-"); } else { return(formattedTime); } }
public CommandServer(LiveSplitState state) { Model = new TimerModel(); Connections = new List <Connection>(); DeltaFormatter = new DeltaTimeFormatter() { Accuracy = TimeAccuracy.Hundredths, DropDecimals = false }; SplitTimeFormatter = new RegularTimeFormatter(TimeAccuracy.Hundredths); State = state; Form = state.Form; Model.CurrentState = State; State.OnStart += State_OnStart; }
public void TestDeltaTimeFormatter(string timespanText, TimeAccuracy timeAccuracy, bool dropDecimals, string expected) { var formatter = new DeltaTimeFormatter { Accuracy = timeAccuracy, DropDecimals = dropDecimals }; TimeSpan?time = null; if (timespanText != null) { time = TimeSpan.Parse(timespanText); } string formatted = formatter.Format(time); Assert.AreEqual(expected, formatted); }
private void DrawGeneral(Graphics g, LiveSplitState state, float width, float height, LayoutMode mode) { if (Settings.BackgroundGradient == ExtendedGradientType.Alternating) { g.FillRectangle(new SolidBrush( Settings.BackgroundColor ), 0, 0, width, height); } MeasureTimeLabel.Text = TimeFormatter.Format(new TimeSpan(24, 0, 0)); MeasureDeltaLabel.Text = DeltaTimeFormatter.Format(new TimeSpan(0, 9, 0, 0)); MeasureTimeLabel.Font = state.LayoutSettings.TimesFont; MeasureTimeLabel.IsMonospaced = true; MeasureDeltaLabel.Font = state.LayoutSettings.TimesFont; MeasureDeltaLabel.IsMonospaced = true; MeasureTimeLabel.SetActualWidth(g); MeasureDeltaLabel.SetActualWidth(g); if (Settings.SplitTimesAccuracy != CurrentAccuracy) { TimeFormatter = new RegularSplitTimeFormatter(Settings.SplitTimesAccuracy); CurrentAccuracy = Settings.SplitTimesAccuracy; } if (Settings.DeltasAccuracy != CurrentDeltaAccuracy || Settings.DropDecimals != CurrentDropDecimals) { DeltaTimeFormatter = new DeltaSplitTimeFormatter(Settings.DeltasAccuracy, Settings.DropDecimals); CurrentDeltaAccuracy = Settings.DeltasAccuracy; CurrentDropDecimals = Settings.DropDecimals; } foreach (var label in LabelsList) { label.ShadowColor = state.LayoutSettings.ShadowsColor; label.Y = 0; label.Height = height; } MinimumWidth = 10f; if (ColumnsList.Count() == LabelsList.Count) { var curX = width - 7; foreach (var label in LabelsList.Reverse()) { var column = ColumnsList.ElementAt(LabelsList.IndexOf(label)); var labelWidth = 0f; if (column.Type == ColumnType.DeltaorSplitTime || column.Type == ColumnType.SegmentDeltaorSegmentTime) { labelWidth = Math.Max(MeasureDeltaLabel.ActualWidth, MeasureTimeLabel.ActualWidth); } else if (column.Type == ColumnType.Delta || column.Type == ColumnType.SegmentDelta) { labelWidth = MeasureDeltaLabel.ActualWidth; } else { labelWidth = MeasureTimeLabel.ActualWidth; } curX -= labelWidth + 5; label.Width = labelWidth; label.X = curX + 5; label.Font = state.LayoutSettings.TextFont; label.HasShadow = state.LayoutSettings.DropShadows; label.Draw(g); } } }
protected void UpdateColumn(LiveSplitState state, SimpleLabel label, ColumnData 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 == ColumnType.SplitTime || type == ColumnType.SegmentTime) { label.ForeColor = Settings.OverrideTimesColor ? Settings.BeforeTimesColor : state.LayoutSettings.TextColor; if (type == ColumnType.SplitTime) { label.Text = TimeFormatter.Format(Split.SplitTime[timingMethod]); } else //SegmentTime { var segmentTime = LiveSplitStateHelper.GetPreviousSegmentTime(state, splitIndex, timingMethod); label.Text = TimeFormatter.Format(segmentTime); } } if (type == ColumnType.DeltaorSplitTime || type == ColumnType.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 == ColumnType.DeltaorSplitTime) { if (deltaTime != null) { label.Text = DeltaTimeFormatter.Format(deltaTime); } else { label.Text = TimeFormatter.Format(Split.SplitTime[timingMethod]); } } else if (type == ColumnType.Delta) { label.Text = DeltaTimeFormatter.Format(deltaTime); } } else 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); if (color == null) { color = Settings.OverrideTimesColor ? Settings.BeforeTimesColor : state.LayoutSettings.TextColor; } label.ForeColor = color.Value; if (type == ColumnType.SegmentDeltaorSegmentTime) { if (segmentDelta != null) { label.Text = DeltaTimeFormatter.Format(segmentDelta); } else { label.Text = TimeFormatter.Format(LiveSplitStateHelper.GetPreviousSegmentTime(state, splitIndex, timingMethod)); } } else if (type == ColumnType.SegmentDelta) { label.Text = DeltaTimeFormatter.Format(segmentDelta); } } } else { if (type == ColumnType.SplitTime || type == ColumnType.SegmentTime || type == ColumnType.DeltaorSplitTime || type == ColumnType.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 == ColumnType.SplitTime || type == ColumnType.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 == ColumnType.DeltaorSplitTime || type == ColumnType.Delta; var bestDelta = LiveSplitStateHelper.CheckLiveDelta(state, splitDelta, comparison, timingMethod); if (bestDelta != null && Split == state.CurrentSplit && (type == ColumnType.DeltaorSplitTime || type == ColumnType.Delta || type == ColumnType.SegmentDeltaorSegmentTime || type == ColumnType.SegmentDelta)) { if (splitDelta) //DeltaorSplitTime or Delta { label.Text = DeltaTimeFormatter.Format(bestDelta); } else //SegmentDeltaorSegmentTime or SegmentDelta { label.Text = DeltaTimeFormatter.Format(LiveSplitStateHelper.GetLiveSegmentDelta(state, splitIndex, comparison, timingMethod)); } label.ForeColor = Settings.OverrideDeltasColor ? Settings.DeltasColor : state.LayoutSettings.TextColor; } else if (type == ColumnType.Delta || type == ColumnType.SegmentDelta) { label.Text = ""; } } }
private void DrawGeneral(Graphics g, LiveSplitState state, float width, float height, LayoutMode mode) { if (NeedUpdateAll) { UpdateAll(state); } if (Settings.BackgroundGradient == ExtendedGradientType.Alternating) { g.FillRectangle(new SolidBrush( state.Run.IndexOf(Split) % 2 + (Settings.ShowColumnLabels ? 1 : 0) == 1 ? Settings.BackgroundColor2 : Settings.BackgroundColor ), 0, 0, width, height); } MeasureTimeLabel.Text = TimeFormatter.Format(new TimeSpan(24, 0, 0)); MeasureDeltaLabel.Text = DeltaTimeFormatter.Format(new TimeSpan(0, 9, 0, 0)); MeasureTimeLabel.Font = state.LayoutSettings.TimesFont; MeasureTimeLabel.IsMonospaced = true; MeasureDeltaLabel.Font = state.LayoutSettings.TimesFont; MeasureDeltaLabel.IsMonospaced = true; MeasureTimeLabel.SetActualWidth(g); MeasureDeltaLabel.SetActualWidth(g); NameLabel.ShadowColor = state.LayoutSettings.ShadowsColor; foreach (var label in LabelsList) { label.SetActualWidth(g); label.ShadowColor = state.LayoutSettings.ShadowsColor; } MinimumWidth = CalculateLabelsWidth() + IconWidth + 10; MinimumHeight = 0.85f * (g.MeasureString("A", state.LayoutSettings.TimesFont).Height + g.MeasureString("A", state.LayoutSettings.TextFont).Height); if (Settings.SplitTimesAccuracy != CurrentAccuracy) { TimeFormatter = new RegularSplitTimeFormatter(Settings.SplitTimesAccuracy); CurrentAccuracy = Settings.SplitTimesAccuracy; } if (Settings.DeltasAccuracy != CurrentDeltaAccuracy || Settings.DropDecimals != CurrentDropDecimals) { DeltaTimeFormatter = new DeltaSplitTimeFormatter(Settings.DeltasAccuracy, Settings.DropDecimals); CurrentDeltaAccuracy = Settings.DeltasAccuracy; CurrentDropDecimals = Settings.DropDecimals; } if (Split != null) { if (mode == LayoutMode.Vertical) { NameLabel.VerticalAlignment = StringAlignment.Center; NameLabel.Y = 0; NameLabel.Height = height; foreach (var label in LabelsList) { label.VerticalAlignment = StringAlignment.Center; label.Y = 0; label.Height = height; } } else { NameLabel.VerticalAlignment = StringAlignment.Near; NameLabel.Y = 0; NameLabel.Height = 50; foreach (var label in LabelsList) { label.VerticalAlignment = StringAlignment.Far; label.Y = height - 50; label.Height = 50; } } if (IsActive) { var currentSplitBrush = new LinearGradientBrush( new PointF(0, 0), Settings.CurrentSplitGradient == GradientType.Horizontal ? new PointF(width, 0) : new PointF(0, height), Settings.CurrentSplitTopColor, Settings.CurrentSplitGradient == GradientType.Plain ? Settings.CurrentSplitTopColor : Settings.CurrentSplitBottomColor); g.FillRectangle(currentSplitBrush, 0, 0, width, height); } if (DisplayIcon) { var icon = Split.Icon ?? NoIconImage; var shadow = (Split.Icon != null) ? ShadowImage : NoIconShadow; /*if (DateTime.Now.Date.Month == 4 && DateTime.Now.Date.Day == 1) * { * icon = LiveSplit.Web.Share.TwitchEmoteResolver.Resolve("Kappa", true, false, false); * shadow = null; * }*/ if (OldImage != icon) { ImageAnimator.Animate(icon, (s, o) => { }); ImageAnimator.Animate(shadow, (s, o) => { }); OldImage = icon; } var drawWidth = Settings.IconSize; var drawHeight = Settings.IconSize; var shadowWidth = Settings.IconSize * (5 / 4f); var shadowHeight = Settings.IconSize * (5 / 4f); if (icon.Width > icon.Height) { var ratio = icon.Height / (float)icon.Width; drawHeight *= ratio; shadowHeight *= ratio; } else { var ratio = icon.Width / (float)icon.Height; drawWidth *= ratio; shadowWidth *= ratio; } ImageAnimator.UpdateFrames(shadow); if (Settings.IconShadows && shadow != null) { g.DrawImage( shadow, 7 + (Settings.IconSize * (5 / 4f) - shadowWidth) / 2 - 0.7f, (height - Settings.IconSize) / 2.0f + (Settings.IconSize * (5 / 4f) - shadowHeight) / 2 - 0.7f, shadowWidth, shadowHeight); } ImageAnimator.UpdateFrames(icon); g.DrawImage( icon, 7 + (Settings.IconSize - drawWidth) / 2, (height - Settings.IconSize) / 2.0f + (Settings.IconSize - drawHeight) / 2, drawWidth, drawHeight); } NameLabel.Font = state.LayoutSettings.TextFont; NameLabel.X = 5 + IconWidth; NameLabel.HasShadow = state.LayoutSettings.DropShadows; if (ColumnsList.Count() == LabelsList.Count) { var curX = width - 7; var nameX = width - 7; foreach (var label in LabelsList.Reverse()) { var column = ColumnsList.ElementAt(LabelsList.IndexOf(label)); var labelWidth = 0f; if (column.Type == ColumnType.DeltaorSplitTime || column.Type == ColumnType.SegmentDeltaorSegmentTime) { labelWidth = Math.Max(MeasureDeltaLabel.ActualWidth, MeasureTimeLabel.ActualWidth); } else if (column.Type == ColumnType.Delta || column.Type == ColumnType.SegmentDelta) { labelWidth = MeasureDeltaLabel.ActualWidth; } else { labelWidth = MeasureTimeLabel.ActualWidth; } label.Width = labelWidth + 20; curX -= labelWidth + 5; label.X = curX - 15; label.Font = state.LayoutSettings.TimesFont; label.HasShadow = state.LayoutSettings.DropShadows; label.IsMonospaced = true; label.Draw(g); if (!String.IsNullOrEmpty(label.Text)) { nameX = curX + labelWidth + 5 - label.ActualWidth; } } NameLabel.Width = (mode == LayoutMode.Horizontal ? width - 10 : nameX) - IconWidth; NameLabel.Draw(g); } } else { DisplayIcon = Settings.DisplayIcons; } }
private void DrawGeneral(Graphics g, LiveSplitState state, float width, float height, LayoutMode mode) { if (NeedUpdateAll) { UpdateAll(state); } int splitIndex = state.Run.IndexOf(Split) % 7; if (IsActive) { switch (splitIndex) { case 0: img = Properties.Resources.row_0_s; break; case 1: img = Properties.Resources.row_1_s; break; case 2: img = Properties.Resources.row_2_s; break; case 3: img = Properties.Resources.row_3_s; break; case 4: img = Properties.Resources.row_4_s; break; case 5: img = Properties.Resources.row_5_s; break; case 6: img = Properties.Resources.row_6_s; break; default: img = Properties.Resources.row_0_s; break; } } else { switch (splitIndex) { case 0: img = Properties.Resources.row_0; break; case 1: img = Properties.Resources.row_1; break; case 2: img = Properties.Resources.row_2; break; case 3: img = Properties.Resources.row_3; break; case 4: img = Properties.Resources.row_4; break; case 5: img = Properties.Resources.row_5; break; case 6: img = Properties.Resources.row_6; break; default: img = Properties.Resources.row_0; break; } } g.DrawImage(img, 0, 0, width, height); MeasureTimeLabel.Text = TimeFormatter.Format(new TimeSpan(24, 0, 0)); MeasureDeltaLabel.Text = DeltaTimeFormatter.Format(new TimeSpan(0, 9, 0, 0)); MeasureTimeLabel.Font = state.LayoutSettings.TimesFont; MeasureTimeLabel.IsMonospaced = true; MeasureDeltaLabel.Font = state.LayoutSettings.TimesFont; MeasureDeltaLabel.IsMonospaced = true; MeasureTimeLabel.SetActualWidth(g); MeasureDeltaLabel.SetActualWidth(g); NameLabel.ShadowColor = state.LayoutSettings.ShadowsColor; NameLabel.OutlineColor = state.LayoutSettings.TextOutlineColor; foreach (var label in LabelsList) { label.ShadowColor = state.LayoutSettings.ShadowsColor; label.OutlineColor = state.LayoutSettings.TextOutlineColor; } if (Settings.SplitTimesAccuracy != CurrentAccuracy) { TimeFormatter = new RegularSplitTimeFormatter(Settings.SplitTimesAccuracy); CurrentAccuracy = Settings.SplitTimesAccuracy; } if (Settings.DeltasAccuracy != CurrentDeltaAccuracy || Settings.DropDecimals != CurrentDropDecimals) { DeltaTimeFormatter = new DeltaSplitTimeFormatter(Settings.DeltasAccuracy, Settings.DropDecimals); CurrentDeltaAccuracy = Settings.DeltasAccuracy; CurrentDropDecimals = Settings.DropDecimals; } if (Split != null) { if (mode == LayoutMode.Vertical) { NameLabel.VerticalAlignment = StringAlignment.Center; NameLabel.Y = 0; NameLabel.Height = height; foreach (var label in LabelsList) { label.VerticalAlignment = StringAlignment.Center; label.Y = 0; label.Height = height; } } else { NameLabel.VerticalAlignment = StringAlignment.Near; NameLabel.Y = 0; NameLabel.Height = 50; foreach (var label in LabelsList) { label.VerticalAlignment = StringAlignment.Far; label.Y = height - 50; label.Height = 50; } } if (IsActive) { g.DrawImage(SplitCursor, 2, ((height - 24f) / 2.0f), 30f, 24f); } NameLabel.Font = state.LayoutSettings.TextFont; NameLabel.X = IsActive ? 35 : 5; NameLabel.HasShadow = state.LayoutSettings.DropShadows; if (ColumnsList.Count() == LabelsList.Count) { var curX = width - 12; var nameX = width - 7; foreach (var label in LabelsList.Reverse()) { var column = ColumnsList.ElementAt(LabelsList.IndexOf(label)); var labelWidth = 0f; if (column.Type == ColumnType.DeltaorSplitTime || column.Type == ColumnType.SegmentDeltaorSegmentTime) { labelWidth = Math.Max(MeasureDeltaLabel.ActualWidth, MeasureTimeLabel.ActualWidth); } else if (column.Type == ColumnType.Delta || column.Type == ColumnType.SegmentDelta) { labelWidth = MeasureDeltaLabel.ActualWidth; } else { labelWidth = MeasureTimeLabel.ActualWidth; } label.Width = labelWidth + 20; curX -= labelWidth + 5; label.X = curX - 15; label.Font = state.LayoutSettings.TimesFont; label.HasShadow = state.LayoutSettings.DropShadows; label.OutlineColor = state.LayoutSettings.TextOutlineColor; label.IsMonospaced = true; label.Draw(g); if (!string.IsNullOrEmpty(label.Text)) { nameX = curX + labelWidth + 5 - label.ActualWidth; } } NameLabel.Width = (mode == LayoutMode.Horizontal ? width - 10 : width * 0.4f); NameLabel.Draw(g); } } }
protected void UpdateAll(LiveSplitState state) { if (Split == null) { RacerName.Text = RaceIndex + ": N/A"; RacerSplit.Text = ""; RacerTime.Text = TimeFormatter.Format(null); } else { RacerName.Text = RaceIndex + ": " + Split.Name; RacerSplit.Text = Split.SplitName + (Split.SubSplitIndex == int.MaxValue ? "" : " - " + Split.SubSplitIndex); RacerTime.Text = TimeFormatter.Format(Split.SplitTime.RealTime); } RacerName.ForeColor = Settings.TextColor; RacerSplit.ForeColor = Settings.TextColor; RacerTime.ForeColor = Settings.TextColor; TimeSpan?delta = null; Color color = state.LayoutSettings.TextColor; if (Split != null && Split != Parent.Comparison && Split.SplitTime.RealTime.HasValue && state.CurrentTime.RealTime.HasValue) { if (Split.SplitIndex == Parent.Comparison.SplitIndex && Split.SubSplitIndex == Parent.Comparison.SubSplitIndex) { delta = Split.SplitTime.RealTime.Value - Parent.Comparison.SplitTime.RealTime.GetValueOrDefault(state.CurrentTime.RealTime.Value); } else if (Split.SplitIndex > Parent.Comparison.SplitIndex || (Split.SplitIndex == Parent.Comparison.SplitIndex && Split.SubSplitIndex > Parent.Comparison.SubSplitIndex)) { RaceSplit history = null; if (Parent.Watcher.RaceSplits.TryGetValue(Split.Name + "|" + Parent.Comparison.SplitIndex + "|" + Parent.Comparison.SubSplitIndex, out history)) { delta = history.SplitTime.RealTime.Value - Parent.Comparison.SplitTime.RealTime.Value; } } else if (Split.SplitIndex < Parent.Comparison.SplitIndex || (Split.SplitIndex == Parent.Comparison.SplitIndex && Split.SubSplitIndex < Parent.Comparison.SubSplitIndex)) { RaceSplit history = null; if (Parent.Watcher.RaceSplits.TryGetValue(Parent.Comparison.Name + "|" + Split.SplitIndex + "|" + Split.SubSplitIndex, out history)) { delta = Split.SplitTime.RealTime.Value - history.SplitTime.RealTime.Value; } } if (delta != null) { if (delta.Value.Ticks < 0) { color = state.LayoutSettings.AheadGainingTimeColor; } else { color = state.LayoutSettings.BehindLosingTimeColor; } } } RacerDelta.Text = DeltaTimeFormatter.Format(delta); int currentIndex = 0; for (int i = 0; i < state.Run.Count; i++) { if (state.Run[i] == state.CurrentSplit) { currentIndex = i; } } if (currentIndex > 0) { currentIndex--; } RacerDelta.ForeColor = color; }