public void DrawHorizontal(Graphics g, LiveSplitState state, float height, Region clipRegion) { DrawGeneral(g, state, HorizontalWidth, height); var oldMatrix = g.Transform; InternalComponent.Settings.TimerWidth = HorizontalWidth; InternalComponent.DrawHorizontal(g, state, height * ((100f - Settings.SegmentTimerSizeRatio) / 100f), clipRegion); g.Transform = oldMatrix; g.TranslateTransform(0, height * ((100f - Settings.SegmentTimerSizeRatio) / 100f)); SegmentTimer.DrawHorizontal(g, state, height * (Settings.SegmentTimerSizeRatio / 100f), clipRegion); SegmentTimer.Settings.TimerWidth = HorizontalWidth; g.Transform = oldMatrix; }
public void DrawVertical(Graphics g, LiveSplitState state, float width, Region clipRegion) { DrawGeneral(g, state, width, VerticalHeight); var oldMatrix = g.Transform; InternalComponent.Settings.TimerHeight = VerticalHeight * ((100f - Settings.SegmentTimerSizeRatio) / 100f); InternalComponent.DrawVertical(g, state, width, clipRegion); g.Transform = oldMatrix; g.TranslateTransform(0, VerticalHeight * ((100f - Settings.SegmentTimerSizeRatio) / 100f)); SegmentTimer.Settings.TimerHeight = VerticalHeight * (Settings.SegmentTimerSizeRatio / 100f); SegmentTimer.DrawVertical(g, state, width, clipRegion); g.Transform = oldMatrix; }
public DetailedTimer(LiveSplitState state) { InternalComponent = new LiveSplit.UI.Components.Timer(); SegmentTimer = new SegmentTimer(); Settings = new DetailedTimerSettings() { CurrentState = state }; IconWidth = 0; Cache = new GraphicsCache(); LabelSegment = new SimpleLabel(); LabelBest = new SimpleLabel(); SegmentTime = new SimpleLabel(); BestSegmentTime = new SimpleLabel(); SplitName = new SimpleLabel(); state.ComparisonRenamed += state_ComparisonRenamed; }
public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { var lastSplitOffset = state.CurrentSplitIndex == state.Run.Count ? -1 : 0; var timingMethod = state.CurrentTimingMethod; if (Settings.TimingMethod == "Real Time") { timingMethod = TimingMethod.RealTime; } else if (Settings.TimingMethod == "Game Time") { timingMethod = TimingMethod.GameTime; } var formatter = new SegmentTimesFormatter(Settings.SegmentTimesAccuracy); if (state.CurrentSplitIndex >= 0) { Comparison = Settings.Comparison == "Current Comparison" ? state.CurrentComparison : Settings.Comparison; Comparison2 = Settings.Comparison2 == "Current Comparison" ? state.CurrentComparison : Settings.Comparison2; HideComparison = Settings.HideComparison; if (HideComparison || !state.Run.Comparisons.Contains(Comparison2) || Comparison2 == "None") { HideComparison = true; if (!state.Run.Comparisons.Contains(Comparison) || Comparison == "None") { Comparison = state.CurrentComparison; } } else if (!state.Run.Comparisons.Contains(Comparison) || Comparison == "None") { HideComparison = true; Comparison = Comparison2; } else if (Comparison == Comparison2) { HideComparison = true; } ComparisonName = CompositeComparisons.GetShortComparisonName(Comparison); ComparisonName2 = CompositeComparisons.GetShortComparisonName(Comparison2); TimeSpan?segmentTime = null; if (Comparison == BestSegmentsComparisonGenerator.ComparisonName) { segmentTime = state.Run[state.CurrentSplitIndex + lastSplitOffset].BestSegmentTime[timingMethod]; } else { if (state.CurrentSplitIndex == 0 || (state.CurrentSplitIndex == 1 && lastSplitOffset == -1)) { segmentTime = state.Run[0].Comparisons[Comparison][timingMethod]; } else if (state.CurrentSplitIndex > 0) { segmentTime = state.Run[state.CurrentSplitIndex + lastSplitOffset].Comparisons[Comparison][timingMethod] - state.Run[state.CurrentSplitIndex - 1 + lastSplitOffset].Comparisons[Comparison][timingMethod]; } } LabelSegment.Text = ComparisonName + ":"; LabelBest.Text = ComparisonName2 + ":"; if (Comparison != "None") { if (segmentTime != null) { SegmentTime.Text = formatter.Format(segmentTime); } else { SegmentTime.Text = TimeFormatConstants.DASH; } } if (!HideComparison) { TimeSpan?bestSegmentTime = null; if (Comparison2 == BestSegmentsComparisonGenerator.ComparisonName) { bestSegmentTime = state.Run[state.CurrentSplitIndex + lastSplitOffset].BestSegmentTime[timingMethod]; } else { if (state.CurrentSplitIndex == 0 || (state.CurrentSplitIndex == 1 && lastSplitOffset == -1)) { bestSegmentTime = state.Run[0].Comparisons[Comparison2][timingMethod]; } else if (state.CurrentSplitIndex > 0) { bestSegmentTime = state.Run[state.CurrentSplitIndex + lastSplitOffset].Comparisons[Comparison2][timingMethod] - state.Run[state.CurrentSplitIndex - 1 + lastSplitOffset].Comparisons[Comparison2][timingMethod]; } } if (bestSegmentTime != null) { BestSegmentTime.Text = formatter.Format(bestSegmentTime); } else { BestSegmentTime.Text = TimeFormatConstants.DASH; } } if (state.CurrentSplitIndex >= 0) { SplitName.Text = state.Run[state.CurrentSplitIndex + lastSplitOffset].Name; } else { SplitName.Text = ""; } } SegmentTimer.Settings.TimingMethod = Settings.TimingMethod; InternalComponent.Settings.TimingMethod = Settings.TimingMethod; SegmentTimer.Update(null, state, width, height, mode); InternalComponent.Update(null, state, width, height, mode); var icon = state.CurrentSplitIndex >= 0 ? state.Run[state.CurrentSplitIndex + lastSplitOffset].Icon : null; Cache.Restart(); Cache["SplitIcon"] = icon; if (Cache.HasChanged) { if (icon == null) { FrameCount = 0; } else { FrameCount = icon.GetFrameCount(new FrameDimension(icon.FrameDimensionsList[0])); } } Cache["SplitName"] = SplitName.Text; Cache["LabelSegment"] = LabelSegment.Text; Cache["LabelBest"] = LabelBest.Text; Cache["SegmentTime"] = SegmentTime.Text; Cache["BestSegmentTime"] = BestSegmentTime.Text; Cache["SegmentTimerText"] = SegmentTimer.BigTextLabel.Text + SegmentTimer.SmallTextLabel.Text; Cache["InternalComponentText"] = InternalComponent.BigTextLabel.Text + InternalComponent.SmallTextLabel.Text; if (InternalComponent.BigTextLabel.Brush != null && invalidator != null) { if (InternalComponent.BigTextLabel.Brush is LinearGradientBrush) { Cache["TimerColor"] = ((LinearGradientBrush)InternalComponent.BigTextLabel.Brush).LinearColors.First().ToArgb(); } else { Cache["TimerColor"] = InternalComponent.BigTextLabel.ForeColor.ToArgb(); } } if (invalidator != null && (Cache.HasChanged || FrameCount > 1)) { invalidator.Invalidate(0, 0, width, height); } }