public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { InternalComponent.LongestString = InternalComponent.InformationName; InternalComponent.InformationValue = state.CurrentComparison; InternalComponent.Update(invalidator, state, width, height, mode); }
public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { if (invalidator != null) { InternalComponent.Update(invalidator, state, width, height, mode == LayoutMode.Vertical ? LayoutMode.Horizontal : LayoutMode.Vertical); } }
public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { var skipCount = Math.Min( Math.Max( 0, state.CurrentSplitIndex - (visualSplitCount - 2 - Settings.SplitPreviewCount + (Settings.AlwaysShowLastSplit ? 0 : 1))), state.Run.Count - visualSplitCount); ScrollOffset = Math.Min(Math.Max(ScrollOffset, -skipCount), state.Run.Count - skipCount - visualSplitCount); skipCount += ScrollOffset; var i = 0; if (SplitComponents.Count >= visualSplitCount) { foreach (var split in state.Run.Skip(skipCount).Take(visualSplitCount - 1 + (Settings.AlwaysShowLastSplit ? 0 : 1))) { SplitComponents[i].Split = split; i++; } if (Settings.AlwaysShowLastSplit) { SplitComponents[i].Split = state.Run.Last(); } } if (invalidator != null) { InternalComponent.Update(invalidator, state, width, height, mode); } }
public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { Cache.Restart(); Cache["Game"] = state.Run.GameName; Cache["Category"] = state.Run.CategoryName; Cache["PlatformID"] = Settings.FilterPlatform ? state.Run.Metadata.PlatformName : null; Cache["RegionID"] = Settings.FilterRegion ? state.Run.Metadata.RegionName : null; Cache["UsesEmulator"] = Settings.FilterPlatform ? (bool?)state.Run.Metadata.UsesEmulator : null; Cache["Variables"] = Settings.FilterVariables ? string.Join(",", state.Run.Metadata.VariableValueNames.Values) : null; if (Cache.HasChanged) { IsLoading = true; PersonalRecord = null; ShowPersonalRecord(mode); Task.Factory.StartNew(RefreshPersonalRecord); } else if (LastUpdate != null && TimeStamp.Now - LastUpdate >= RefreshInterval) { Task.Factory.StartNew(RefreshPersonalRecord); } else { Cache["CenteredText"] = Settings.CenteredText && !Settings.Display2Rows && mode == LayoutMode.Vertical; Cache["RealPBTime"] = GetPBTime(Model.TimingMethod.RealTime); Cache["GamePBTime"] = GetPBTime(Model.TimingMethod.GameTime); if (Cache.HasChanged) { ShowPersonalRecord(mode); } } InternalComponent.Update(invalidator, state, width, height, mode); }
public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { GameLoader.game?.Update(state); if (invalidator != null && (GameLoader.game?.IsRunning() ?? false)) { InternalComponent.Update(invalidator, state, width, height, mode); } }
public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { var comparison = Settings.Comparison == "Current Comparison" ? state.CurrentComparison : Settings.Comparison; if (!state.Run.Comparisons.Contains(comparison)) { comparison = state.CurrentComparison; } var comparisonName = CompositeComparisons.GetShortComparisonName(comparison); var componentName = (Settings.TotalTimeSave ? "Total " : "") + "Possible Time Save" + (Settings.Comparison == "Current Comparison" ? "" : " (" + comparisonName + ")"); if (InternalComponent.InformationName != componentName) { InternalComponent.AlternateNameText.Clear(); if (componentName.Contains("Total")) { InternalComponent.AlternateNameText.Add("Total Possible Time Save"); } InternalComponent.AlternateNameText.Add("Possible Time Save"); InternalComponent.AlternateNameText.Add("Poss. Time Save"); InternalComponent.AlternateNameText.Add("Time Save"); } InternalComponent.LongestString = componentName; InternalComponent.InformationName = componentName; if (Settings.TotalTimeSave) { if (state.CurrentPhase == TimerPhase.Ended) { InternalComponent.TimeValue = TimeSpan.Zero; } else { var totalPossibleTimeSave = state.Run .Skip(state.CurrentSplitIndex) .Select(x => GetPossibleTimeSave(state, x, comparison, true)) .Where(x => x.HasValue) .Aggregate((TimeSpan?)TimeSpan.Zero, (a, b) => a + b); InternalComponent.TimeValue = totalPossibleTimeSave; } } else { if (state.CurrentPhase == TimerPhase.Running || state.CurrentPhase == TimerPhase.Paused) { InternalComponent.TimeValue = GetPossibleTimeSave(state, state.CurrentSplit, comparison); } else { InternalComponent.TimeValue = null; } } InternalComponent.Update(invalidator, state, width, height, mode); }
public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { InternalComponent.InformationName = Settings.Text1; InternalComponent.InformationValue = Settings.Text2; InternalComponent.LongestString = Settings.Text1.Length > Settings.Text2.Length ? Settings.Text1 : Settings.Text2; InternalComponent.Update(invalidator, state, width, height, mode); }
public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { if (CheckIfRunChanged(state)) { UpdateSumOfBestValue(state); } InternalComponent.TimeValue = SumOfBestValue; InternalComponent.Update(invalidator, state, width, height, mode); }
public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { string textPercentage = (tracker.IsRunning) ? PercentageFormatter.Format(progress.Percentage, Settings.Accuracy) : "-"; if (invalidator != null && this.InternalComponent.InformationValue != textPercentage) { this.InternalComponent.InformationValue = textPercentage; invalidator.Invalidate(0f, 0f, width, height); InternalComponent.Update(invalidator, state, width, height, mode); } }
public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { if (CheckIfRunChanged(state)) { UpdateStreakValue(state); } InternalComponent.InformationValue = StreakText; InternalComponent.Update(invalidator, state, width, height, mode); }
void IComponent.Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { string newCategory = State.Run.GameName + State.Run.CategoryName; if (newCategory != category) { Recalculate(); category = newCategory; } InternalComponent.Update(invalidator, state, width, height, mode); }
void IComponent.Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { string newCategory = State.Run.GameName + State.Run.CategoryName; if (newCategory != category) { resetOrNotCalculator.OnCategoryChanged(newCategory); UpdateShouldResetText(); category = newCategory; } InternalComponent.Update(invalidator, state, width, height, mode); }
public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { var comparison = Settings.Comparison; if (!state.Run.Comparisons.Contains(comparison)) { // #1682: Currently, support "Best Segments" comparison only ("Current Comparison" not supported) InternalComponent.InformationName = "Split #" + Settings.VisualCompareSplitNumber + " comparison not available"; InternalComponent.TimeValue = null; } else { if (Settings.VisualCompareSplitNumber > state.Run.Count) { InternalComponent.InformationName = "Split #" + Settings.VisualCompareSplitNumber + " not available"; InternalComponent.TimeValue = null; } else // get information for Settings.VisualCompareSplitNumber { ISegment visualCompareSplitNumberSegment = state.Run[Settings.VisualCompareSplitNumber - 1]; if (state.CurrentSplitIndex > Settings.VisualCompareSplitNumber - 1) { InternalComponent.InformationName = "Time (" + visualCompareSplitNumberSegment.Name + ")"; InternalComponent.TimeValue = visualCompareSplitNumberSegment.SplitTime[state.CurrentTimingMethod].GetValueOrDefault(); } else { InternalComponent.InformationName = "Best Possible Time (" + visualCompareSplitNumberSegment.Name + ")"; if (state.CurrentPhase == TimerPhase.Running || state.CurrentPhase == TimerPhase.Paused) { TimeSpan?delta = LiveSplitStateHelper.GetLastDelta(state, state.CurrentSplitIndex, comparison, state.CurrentTimingMethod) ?? TimeSpan.Zero; var liveDelta = state.CurrentTime[state.CurrentTimingMethod] - state.CurrentSplit.Comparisons[comparison][state.CurrentTimingMethod]; if (liveDelta > delta) { delta = liveDelta; } InternalComponent.TimeValue = delta + visualCompareSplitNumberSegment.Comparisons[comparison][state.CurrentTimingMethod]; } else { TimeSpan?timeValue = visualCompareSplitNumberSegment.Comparisons[comparison][state.CurrentTimingMethod]; InternalComponent.TimeValue = timeValue; } } } } InternalComponent.Update(invalidator, state, width, height, mode); }
public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { var comparison = Settings.Comparison == "Current Comparison" ? state.CurrentComparison : Settings.Comparison; if (!state.Run.Comparisons.Contains(comparison)) { comparison = state.CurrentComparison; } var comparisonName = comparison.StartsWith("[Race] ") ? comparison.Substring(7) : comparison; if (InternalComponent.InformationName != comparisonName) { InternalComponent.AlternateNameText.Clear(); InternalComponent.AlternateNameText.Add(CompositeComparisons.GetShortComparisonName(comparison)); } InternalComponent.LongestString = comparisonName; InternalComponent.InformationName = comparisonName; var useLiveDelta = false; if (state.CurrentPhase == TimerPhase.Running || state.CurrentPhase == TimerPhase.Paused) { TimeSpan?delta = LiveSplitStateHelper.GetLastDelta(state, state.CurrentSplitIndex, comparison, state.CurrentTimingMethod); var liveDelta = state.CurrentTime[state.CurrentTimingMethod] - state.CurrentSplit.Comparisons[comparison][state.CurrentTimingMethod]; if (liveDelta > delta || (delta == null && liveDelta > TimeSpan.Zero)) { delta = liveDelta; useLiveDelta = true; } InternalComponent.TimeValue = delta; } else if (state.CurrentPhase == TimerPhase.Ended) { InternalComponent.TimeValue = state.Run.Last().SplitTime[state.CurrentTimingMethod] - state.Run.Last().Comparisons[comparison][state.CurrentTimingMethod]; } else { InternalComponent.TimeValue = null; } var color = LiveSplitStateHelper.GetSplitColor(state, InternalComponent.TimeValue, state.CurrentSplitIndex - (useLiveDelta ? 0 : 1), true, false, comparison, state.CurrentTimingMethod); if (color == null) { color = Settings.OverrideTextColor ? Settings.TextColor : state.LayoutSettings.TextColor; } InternalComponent.ValueLabel.ForeColor = color.Value; InternalComponent.Update(invalidator, state, width, height, mode); }
public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { var timingMethod = state.CurrentTimingMethod; if (Settings.TimingMethod == "Real Time") { timingMethod = TimingMethod.RealTime; } else if (Settings.TimingMethod == "Game Time") { timingMethod = TimingMethod.GameTime; } var formatter = new AlternateTimeFormatter(Settings.AlternateTimeAccuracy); TimeSpan?altTime = null; if (AlternateTimer != null) { altTime = AlternateTimer.GetTime(state, timingMethod); } AlternateTimer.Settings.TimingMethod = Settings.TimingMethod; InternalComponent.Settings.TimingMethod = Settings.TimingMethod; AlternateTimer.Update(null, state, width, height, mode); InternalComponent.Update(null, state, width, height, mode); Cache.Restart(); Cache["AlternateTimerText"] = AlternateTimer.BigTextLabel.Text + AlternateTimer.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); } }
public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { InternalComponent.Formatter = Settings.ShowTotalHours ? HoursTimeFormatter : DaysTimeFormatter; if (LastAttemptCount != state.Run.AttemptHistory.Count || LastPhase != state.CurrentPhase || LastRun != state.Run || state.CurrentPhase == TimerPhase.Running || state.CurrentPhase == TimerPhase.Paused) { InternalComponent.TimeValue = CalculateTotalPlaytime(state); LastAttemptCount = state.Run.AttemptHistory.Count; LastPhase = state.CurrentPhase; LastRun = state.Run; } InternalComponent.Update(invalidator, state, width, height, mode); }
public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { var comparison = Settings.Comparison == "Current Comparison" ? state.CurrentComparison : Settings.Comparison; if (!state.Run.Comparisons.Contains(comparison)) { comparison = state.CurrentComparison; } InternalComponent.InformationName = InternalComponent.LongestString = GetDisplayedName(comparison); if (InternalComponent.InformationName != PreviousInformationName) { SetAlternateText(comparison); PreviousInformationName = InternalComponent.InformationName; } if (InternalComponent.InformationName.StartsWith("Current Pace") && state.CurrentPhase == TimerPhase.NotRunning) { InternalComponent.TimeValue = null; } else if (state.CurrentPhase == TimerPhase.Running || state.CurrentPhase == TimerPhase.Paused) { TimeSpan?delta = LiveSplitStateHelper.GetLastDelta(state, state.CurrentSplitIndex, comparison, state.CurrentTimingMethod) ?? TimeSpan.Zero; var liveDelta = state.CurrentTime[state.CurrentTimingMethod] - state.CurrentSplit.Comparisons[comparison][state.CurrentTimingMethod]; if (liveDelta > delta) { delta = liveDelta; } InternalComponent.TimeValue = delta + state.Run.Last().Comparisons[comparison][state.CurrentTimingMethod]; } else if (state.CurrentPhase == TimerPhase.Ended) { InternalComponent.TimeValue = state.Run.Last().SplitTime[state.CurrentTimingMethod]; } else { InternalComponent.TimeValue = state.Run.Last().Comparisons[comparison][state.CurrentTimingMethod]; } InternalComponent.Update(invalidator, state, width, height, mode); }
public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { // If the actual comparison or timing method have changed, we'll need to invalidate the // data structures. if (!GetActualComparison(state).Equals(ActualComparison) || !GetActualTimingMethod(state).Equals(ActualTimingMethod)) { SplitCompletionsValid = false; } // If the underlying data structures have been invalidated by the start of a new run, // or the timing method changing, we need to re-initialize. if (!SplitCompletionsValid) { Initialize(state); } float newProgress = GetProgress(state) * 100; if (CurrentProgress != newProgress) { CurrentProgress = newProgress; InternalComponent.LongestString = InternalComponent.InformationName; string completionFormat = $"{CurrentProgress:0}%"; if (Settings.Accuracy.Equals(CompletionEstimateSettings.CompletionAccuracy.OneDecimal)) { completionFormat = Settings.ShowTrailingZeroes ? $"{CurrentProgress:0.0}%" : $"{CurrentProgress:0.#}%"; } else if (Settings.Accuracy.Equals(CompletionEstimateSettings.CompletionAccuracy.TwoDecimal)) { completionFormat = Settings.ShowTrailingZeroes ? $"{CurrentProgress:0.00}%" : $"{CurrentProgress:0.##}%"; } // If we can't make an estimate, just display "?". InternalComponent.InformationValue = CurrentProgress >= 0 ? completionFormat : "?"; } InternalComponent.Update(invalidator, state, width, height, mode); }
public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { if (state.Run != previousRun) { sectionList.UpdateSplits(state.Run); previousRun = state.Run; } var runningSectionIndex = Math.Min(Math.Max(state.CurrentSplitIndex, 0), state.Run.Count - 1); ScrollOffset = Math.Min(Math.Max(ScrollOffset, -runningSectionIndex), state.Run.Count - runningSectionIndex - 1); var currentSplit = ScrollOffset + runningSectionIndex; var currentSection = sectionList.getSection(currentSplit); runningSectionIndex = sectionList.getSection(runningSectionIndex); if (sectionList.Sections[currentSection].getSubsplitCount() > 0) { lastSplitOfSection = sectionList.Sections[currentSection].endIndex; } else { lastSplitOfSection = -1; } if (Settings.HideSubsplits) { if (ScrollOffset != 0) { currentSplit = sectionList.getMajorSplit(currentSplit); SplitsSettings.HilightSplit = state.Run[currentSplit]; } else { SplitsSettings.HilightSplit = null; } SplitsSettings.SectionSplit = state.Run[sectionList.Sections[runningSectionIndex].endIndex]; } else { if (ScrollOffset != 0) { SplitsSettings.HilightSplit = state.Run[currentSplit]; } else { SplitsSettings.HilightSplit = null; } if (currentSection == runningSectionIndex) { SplitsSettings.SectionSplit = null; } else { SplitsSettings.SectionSplit = state.Run[sectionList.Sections[runningSectionIndex].endIndex]; } } bool addLast = (Settings.AlwaysShowLastSplit || currentSplit == state.Run.Count() - 1); bool addHeader = (Settings.ShowHeader && (sectionList.Sections[currentSection].getSubsplitCount() > 0)); int freeSplits = visualSplitCount - (addLast ? 1 : 0) - (addHeader ? 1 : 0); int topSplit = currentSplit - 1; int bottomSplit = currentSplit + 1; var majorSplitsToAdd = (!Settings.ShowSubsplits && !Settings.HideSubsplits) ? Math.Min(currentSection, Settings.MinimumMajorSplits) : 0; List <int> visibleSplits = new List <int>(); if ((currentSplit < state.Run.Count() - 1) && (freeSplits > 0) && (!Settings.HideSubsplits || sectionList.isMajorSplit(currentSplit))) { visibleSplits.Add(currentSplit); freeSplits--; } int previewCount = 0; while ((previewCount < Settings.SplitPreviewCount) && (bottomSplit < state.Run.Count() - (addLast ? 1 : 0)) && (freeSplits > majorSplitsToAdd)) { if (ShouldIncludeSplit(currentSection, bottomSplit)) { if (bottomSplit == state.Run.Count - 1) { addLast = true; } else { visibleSplits.Add(bottomSplit); previewCount++; } freeSplits--; } bottomSplit++; } while ((topSplit >= 0) && (freeSplits > 0)) { var isMajor = sectionList.isMajorSplit(topSplit); if (ShouldIncludeSplit(currentSection, topSplit) && (freeSplits > majorSplitsToAdd || sectionList.isMajorSplit(topSplit))) { visibleSplits.Insert(0, topSplit); freeSplits--; if (isMajor) { majorSplitsToAdd--; } } topSplit--; } while ((bottomSplit < state.Run.Count() - (addLast ? 1 : 0)) && (freeSplits > 0)) { if (ShouldIncludeSplit(currentSection, bottomSplit)) { if (bottomSplit == state.Run.Count - 1) { addLast = true; } else { visibleSplits.Add(bottomSplit); } freeSplits--; } bottomSplit++; } foreach (var component in Components) { if (component is SeparatorComponent) { var separator = (SeparatorComponent)component; var index = Components.IndexOf(separator); if (Settings.AlwaysShowLastSplit && Settings.SeparatorLastSplit && index == LastSplitSeparatorIndex) { int lastIndex = state.Run.Count() - 1; if (freeSplits > 0 || visibleSplits.Any() && (visibleSplits.Last() == lastIndex - 1)) { if (Settings.ShowThinSeparators) { separator.DisplayedSize = 1f; } else { separator.DisplayedSize = 0f; } separator.UseSeparatorColor = false; } else { int prevSection = sectionList.getSection(lastIndex) - 1; if (visibleSplits.Any() && (prevSection <= 0 || visibleSplits.Last() == sectionList.Sections[prevSection].endIndex)) { if (Settings.ShowThinSeparators) { separator.DisplayedSize = 1f; } else { separator.DisplayedSize = 0f; } separator.UseSeparatorColor = false; } else { separator.DisplayedSize = 2f; separator.UseSeparatorColor = true; } } } } } if (!Settings.LockLastSplit && addLast) { visibleSplits.Add(state.Run.Count() - 1); } for (; freeSplits > 0; freeSplits--) { visibleSplits.Add(int.MinValue); } if (Settings.LockLastSplit && addLast) { visibleSplits.Add(state.Run.Count() - 1); } if (addHeader) { int insertIndex = 0; if (currentSection > 0) { insertIndex = visibleSplits.IndexOf(sectionList.Sections[currentSection - 1].endIndex) + 1; } visibleSplits.Insert(insertIndex, -(currentSection + 1)); } int i = 0; foreach (int split in visibleSplits) { if (i < SplitComponents.Count) { SplitComponents[i].ForceIndent = !Settings.ShowSubsplits && !Settings.HideSubsplits && Settings.IndentSectionSplit && split == lastSplitOfSection; if (split == int.MinValue) { SplitComponents[i].Header = false; SplitComponents[i].CollapsedSplit = false; SplitComponents[i].Split = null; SplitComponents[i].oddSplit = true; } else if (split < 0) { SplitComponents[i].Header = true; SplitComponents[i].CollapsedSplit = false; SplitComponents[i].TopSplit = sectionList.Sections[-split - 1].startIndex; SplitComponents[i].Split = state.Run[sectionList.Sections[-split - 1].endIndex]; SplitComponents[i].oddSplit = ((((-split - 1) + (Settings.ShowColumnLabels ? 1 : 0)) % 2) == 0); } else { SplitComponents[i].Header = false; SplitComponents[i].Split = state.Run[split]; SplitComponents[i].oddSplit = (((sectionList.getSection(split) + (Settings.ShowColumnLabels ? 1 : 0)) % 2) == 0); if ((Settings.HideSubsplits || sectionList.getSection(split) != currentSection) && sectionList.Sections[sectionList.getSection(split)].getSubsplitCount() > 0 && !Settings.ShowSubsplits) { SplitComponents[i].CollapsedSplit = true; SplitComponents[i].TopSplit = sectionList.Sections[sectionList.getSection(split)].startIndex; } else { SplitComponents[i].CollapsedSplit = false; } } } i++; } if (invalidator != null) { InternalComponent.Update(invalidator, state, width, height, mode); } }
public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { InternalComponent.Update(invalidator, state, width, height, mode); }
public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { var comparison = Settings.Comparison == "Current Comparison" ? state.CurrentComparison : Settings.Comparison; if (!state.Run.Comparisons.Contains(comparison)) { comparison = state.CurrentComparison; } var comparisonName = CompositeComparisons.GetShortComparisonName(comparison); var componentName = "Previous Segment" + (Settings.Comparison == "Current Comparison" ? "" : " (" + comparisonName + ")"); InternalComponent.LongestString = componentName; InternalComponent.InformationName = componentName; DeltaFormatter.Accuracy = Settings.DeltaAccuracy; DeltaFormatter.DropDecimals = Settings.DropDecimals; TimeSaveFormatter.Accuracy = Settings.TimeSaveAccuracy; TimeSpan?timeChange = null; TimeSpan?timeSave = null; var liveSegment = LiveSplitStateHelper.CheckLiveDelta(state, false, comparison, state.CurrentTimingMethod, false); if (state.CurrentPhase != TimerPhase.NotRunning) { if (liveSegment != null) { timeChange = liveSegment; timeSave = GetPossibleTimeSave(state, state.CurrentSplitIndex, comparison); InternalComponent.InformationName = "Live Segment" + (Settings.Comparison == "Current Comparison" ? "" : " (" + comparisonName + ")"); } else if (state.CurrentSplitIndex > 0) { timeChange = LiveSplitStateHelper.GetPreviousSegmentDelta(state, state.CurrentSplitIndex - 1, comparison, state.CurrentTimingMethod); timeSave = GetPossibleTimeSave(state, state.CurrentSplitIndex - 1, comparison); } if (timeChange != null) { if (liveSegment != null) { InternalComponent.ValueLabel.ForeColor = LiveSplitStateHelper.GetSplitColor(state, timeChange, state.CurrentSplitIndex, false, false, comparison, state.CurrentTimingMethod).Value; } else { InternalComponent.ValueLabel.ForeColor = LiveSplitStateHelper.GetSplitColor(state, timeChange.Value, state.CurrentSplitIndex - 1, false, true, comparison, state.CurrentTimingMethod).Value; } } else { var color = LiveSplitStateHelper.GetSplitColor(state, null, state.CurrentSplitIndex - 1, true, true, comparison, state.CurrentTimingMethod); if (color == null) { color = Settings.OverrideTextColor ? Settings.TextColor : state.LayoutSettings.TextColor; } InternalComponent.ValueLabel.ForeColor = color.Value; } } else { InternalComponent.ValueLabel.ForeColor = Settings.OverrideTextColor ? Settings.TextColor : state.LayoutSettings.TextColor; } if (InternalComponent.InformationName != previousNameText) { InternalComponent.AlternateNameText.Clear(); if (liveSegment != null) { InternalComponent.AlternateNameText.Add("Live Segment"); InternalComponent.AlternateNameText.Add("Live Seg."); } else { InternalComponent.AlternateNameText.Add("Previous Segment"); InternalComponent.AlternateNameText.Add("Prev. Segment"); InternalComponent.AlternateNameText.Add("Prev. Seg."); } previousNameText = InternalComponent.InformationName; } InternalComponent.InformationValue = DeltaFormatter.Format(timeChange) + (Settings.ShowPossibleTimeSave ? " / " + TimeSaveFormatter.Format(timeSave) : ""); InternalComponent.Update(invalidator, state, width, height, mode); }
public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { if (Settings.RacerCount != Components.Count) { Components.Clear(); for (int i = 0; i < Settings.RacerCount; i++) { Components.Add(new RaceLabels(this, i + 1, Settings, null)); } } if (state.Run.Count == 0) { return; } Watcher.CheckRace(); List <RaceSplit> raceComparisons = new List <RaceSplit>(); bool inRace = false; foreach (string comp in state.Run.Comparisons) { if (comp.StartsWith("[Race] ")) { string racerName = comp.Substring(7); RaceSplit split = null; if (!Watcher.RaceSplits.TryGetValue(racerName, out split)) { split = new RaceSplit() { Name = racerName, SplitIndex = -1, SplitName = string.Empty, SplitTime = new Time(), SubSplitIndex = int.MaxValue }; Watcher.RaceSplits.Add(racerName, split); } raceComparisons.Add(split); inRace = true; } } if (Watcher.UserName != null) { RaceSplit split = null; if (!Watcher.RaceSplits.TryGetValue(Watcher.UserName, out split)) { split = new RaceSplit() { Name = Watcher.UserName, SplitIndex = -1, SplitName = string.Empty, SplitTime = new Time(), SubSplitIndex = int.MaxValue }; Watcher.RaceSplits.Add(Watcher.UserName, split); } raceComparisons.Add(split); if (Settings.CompareAgainst == RacerComparison.Yourself) { Comparison = split; } inRace = true; } if (!inRace) { Watcher.Clear(); Comparison.Clear(); } raceComparisons.Sort(delegate(RaceSplit one, RaceSplit two) { return(one.SplitIndex > two.SplitIndex ? -1 : one.SplitIndex <two.SplitIndex ? 1 : one.SubSplitIndex> two.SubSplitIndex ? -1 : one.SubSplitIndex < two.SubSplitIndex ? 1 : !one.SplitTime.RealTime.HasValue ? 1 : !two.SplitTime.RealTime.HasValue ? -1 : one.SplitTime.RealTime.Value.CompareTo(two.SplitTime.RealTime.Value)); }); if (Settings.CompareAgainst == RacerComparison.First && raceComparisons.Count > 0) { Comparison = raceComparisons[0]; } for (int i = 0; i < Settings.RacerCount; i++) { RaceLabels labels = Components[i] as RaceLabels; if (i < raceComparisons.Count) { labels.Split = raceComparisons[i]; } else { labels.Split = null; } } InternalComponent.Update(invalidator, state, width, height, mode); }
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); } }