private string previousSegmentComponent()
        {
            var   comparison = State.CurrentComparison;
            var   method     = State.CurrentTimingMethod;
            var   text       = "Previous Segment";
            var   time       = "";
            Color?color      = Color.Transparent;

            TimeSpan?timeChange  = null;
            TimeSpan?timeSave    = null;
            var      liveSegment = LiveSplitStateHelper.CheckLiveDelta(State, false, comparison, method);

            if (State.CurrentPhase != TimerPhase.NotRunning)
            {
                if (liveSegment != null)
                {
                    timeChange = liveSegment;
                    timeSave   = GetPossibleTimeSave(State, State.CurrentSplitIndex, comparison);
                    text       = "Live Segment";
                }
                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)
                    {
                        color = LiveSplitStateHelper.GetSplitColor(State, timeChange, State.CurrentSplitIndex, false, false, comparison, method).Value;
                    }
                    else
                    {
                        color = LiveSplitStateHelper.GetSplitColor(State, timeChange.Value, State.CurrentSplitIndex - 1, false, true, comparison, method).Value;
                    }
                }
                else
                {
                    color = LiveSplitStateHelper.GetSplitColor(State, null, State.CurrentSplitIndex - 1, true, true, comparison, State.CurrentTimingMethod);
                    if (color == null)
                    {
                        color = State.LayoutSettings.TextColor;
                    }
                }
            }
            else
            {
                color = State.LayoutSettings.TextColor;
            }

            var a = DeltaFormatter.Accuracy;

            DeltaFormatter.Accuracy = TimeAccuracy.Tenths;
            time = DeltaFormatter.Format(timeChange);
            DeltaFormatter.Accuracy = a;

            return(formatInfoTextWithColor(text, time, color) + "\n");
        }
        private string splitComponent(ISegment segment, string comparison, TimingMethod method)
        {
            TimeSpan?deltaTime = null;
            Color?   color     = null;
            var      i         = State.Run.IndexOf(segment);
            int      delta     = 9;
            int      time      = 9;
            int      split     = Settings.CharacterWidth - delta - time - 2;
            var      segName   = (segment.Name.Length > split) ? segment.Name.Substring(0, split) : segment.Name;

            if (i < State.CurrentSplitIndex)
            {
                deltaTime = segment.SplitTime[method] - segment.Comparisons[comparison][method];
                color     = LiveSplitStateHelper.GetSplitColor(State, deltaTime, i, true, true, comparison, method);
            }
            else
            {
                //Live Delta
                var bestDelta = LiveSplitStateHelper.CheckLiveDelta(State, true, comparison, method);
                if (bestDelta != null && segment == State.CurrentSplit)
                {
                    deltaTime = bestDelta;
                    color     = State.LayoutSettings.TextColor;
                }
            }

            DeltaFormatter.DropDecimals = Settings.DropDecimals;
            DeltaFormatter.Accuracy     = Settings.DeltasAccuracy;
            SplitTimeFormatter.Accuracy = Settings.SplitAccuracy;

            var splitTime = segment.SplitTime[method];

            if (splitTime == null && State.CurrentSplitIndex <= i)
            {
                splitTime = segment.Comparisons[comparison][method];
            }

            return(String.Format("{0}{1, " + -split + "}<C> {2}{3, " + delta + "}<C> {4, " + time + "}\n",
                                 (State.CurrentSplit == segment) ? "<C8>" : "",
                                 segName,
                                 getColor(color),
                                 DeltaFormatter.Format(deltaTime),
                                 SplitTimeFormatter.Format(splitTime)
                                 ));
        }
Beispiel #3
0
 private void ProcessMessage(String message, Connection clientConnection)
 {
     try
     {
         if (message == "startorsplit")
         {
             if (State.CurrentPhase == TimerPhase.Running)
             {
                 Model.Split();
             }
             else
             {
                 Model.Start();
             }
         }
         else if (message == "split")
         {
             Model.Split();
         }
         else if (message == "unsplit")
         {
             Model.UndoSplit();
         }
         else if (message == "skipsplit")
         {
             Model.SkipSplit();
         }
         else if (message == "pause" && State.CurrentPhase != TimerPhase.Paused)
         {
             Model.Pause();
         }
         else if (message == "resume" && State.CurrentPhase == TimerPhase.Paused)
         {
             Model.Pause();
         }
         else if (message == "reset")
         {
             Model.Reset();
         }
         else if (message == "starttimer")
         {
             Model.Start();
         }
         else if (message.StartsWith("setgametime "))
         {
             var value = message.Split(' ')[1];
             var time  = parseTime(value);
             State.SetGameTime(time);
         }
         else if (message.StartsWith("setloadingtimes "))
         {
             var value = message.Split(' ')[1];
             var time  = parseTime(value);
             State.LoadingTimes = time ?? TimeSpan.Zero;
         }
         else if (message == "pausegametime")
         {
             State.IsGameTimePaused = true;
         }
         else if (message == "unpausegametime")
         {
             AlwaysPauseGameTime    = false;
             State.IsGameTimePaused = false;
         }
         else if (message == "alwayspausegametime")
         {
             AlwaysPauseGameTime    = true;
             State.IsGameTimePaused = true;
         }
         else if (message == "getdelta" || message.StartsWith("getdelta "))
         {
             var comparison = State.CurrentComparison;
             if (message.Contains(" "))
             {
                 comparison = message.Split(new char[] { ' ' }, 2)[1];
             }
             var delta    = LiveSplitStateHelper.GetLastDelta(State, State.CurrentSplitIndex, comparison, State.CurrentTimingMethod);
             var response = DeltaFormatter.Format(delta);
             clientConnection.SendMessage(response);
         }
         else if (message == "getsplitindex")
         {
             var splitindex = State.CurrentSplitIndex;
             var response   = splitindex.ToString();
             clientConnection.SendMessage(response);
         }
         else if (message == "getcurrentsplitname")
         {
             var splitindex       = State.CurrentSplitIndex;
             var currentsplitname = State.CurrentSplit.Name;
             var response         = currentsplitname;
             clientConnection.SendMessage(response);
         }
         else if (message == "getprevioussplitname")
         {
             var previoussplitindex = State.CurrentSplitIndex - 1;
             var previoussplitname  = State.Run[previoussplitindex].Name;
             var response           = previoussplitname;
             clientConnection.SendMessage(response);
         }
         else if (message == "getlastsplittime" && State.CurrentSplitIndex > 0)
         {
             var splittime = State.Run[State.CurrentSplitIndex - 1].SplitTime[State.CurrentTimingMethod];
             var response  = SplitTimeFormatter.Format(splittime);
             clientConnection.SendMessage(response);
         }
         else if (message == "getcomparisonsplittime")
         {
             var splittime = State.CurrentSplit.Comparisons[State.CurrentComparison][State.CurrentTimingMethod];
             var response  = SplitTimeFormatter.Format(splittime);
             clientConnection.SendMessage(response);
         }
         else if (message == "getcurrentrealtime")
         {
             var time     = State.CurrentTime.RealTime;
             var response = SplitTimeFormatter.Format(time);
             clientConnection.SendMessage(response);
         }
         else if (message == "getcurrentgametime")
         {
             var timingMethod = TimingMethod.GameTime;
             if (!State.IsGameTimeInitialized)
             {
                 timingMethod = TimingMethod.RealTime;
             }
             var time     = State.CurrentTime[timingMethod];
             var response = SplitTimeFormatter.Format(time);
             clientConnection.SendMessage(response);
         }
         else if (message == "getcurrenttime")
         {
             var timingMethod = State.CurrentTimingMethod;
             if (timingMethod == TimingMethod.GameTime && !State.IsGameTimeInitialized)
             {
                 timingMethod = TimingMethod.RealTime;
             }
             var time     = State.CurrentTime[timingMethod];
             var response = SplitTimeFormatter.Format(time);
             clientConnection.SendMessage(response);
         }
         else if (message == "getfinaltime" || message.StartsWith("getfinaltime "))
         {
             var comparison = State.CurrentComparison;
             if (message.Contains(" "))
             {
                 comparison = message.Split(new char[] { ' ' }, 2)[1];
             }
             var time = (State.CurrentPhase == TimerPhase.Ended)
                 ? State.CurrentTime[State.CurrentTimingMethod]
                 : State.Run.Last().Comparisons[comparison][State.CurrentTimingMethod];
             var response = SplitTimeFormatter.Format(time);
             clientConnection.SendMessage(response);
         }
         else if (message.StartsWith("getpredictedtime "))
         {
             var comparison = message.Split(new char[] { ' ' }, 2)[1];
             var prediction = PredictTime(State, comparison);
             var response   = SplitTimeFormatter.Format(prediction);
             clientConnection.SendMessage(response);
         }
         else if (message == "getbestpossibletime")
         {
             var comparison = LiveSplit.Model.Comparisons.BestSegmentsComparisonGenerator.ComparisonName;
             var prediction = PredictTime(State, comparison);
             var response   = SplitTimeFormatter.Format(prediction);
             clientConnection.SendMessage(response);
         }
         else if (message == "getcurrenttimerphase")
         {
             var response = State.CurrentPhase.ToString();
             clientConnection.SendMessage(response);
         }
         else if (message.StartsWith("setcomparison "))
         {
             var comparison = message.Split(new char[] { ' ' }, 2)[1];
             State.CurrentComparison = comparison;
         }
         else if (message == "switchto realtime")
         {
             State.CurrentTimingMethod = TimingMethod.RealTime;
         }
         else if (message == "switchto gametime")
         {
             State.CurrentTimingMethod = TimingMethod.GameTime;
         }
         else if (message.StartsWith("setsplitname "))
         {
             int    index = Convert.ToInt32(message.Split(new char[] { ' ' }, 3)[1]);
             string title = message.Split(new char[] { ' ' }, 3)[2];
             State.Run[index].Name = title;
             State.Run.HasChanged  = true;
         }
         else if (message.StartsWith("setcurrentsplitname "))
         {
             string title = message.Split(new char[] { ' ' }, 2)[1];
             State.Run[State.CurrentSplitIndex].Name = title;
             State.Run.HasChanged = true;
         }
     }
     catch (Exception ex)
     {
         Log.Error(ex);
     }
 }
        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);
        }
        void connection_MessageReceived(object sender, MessageEventArgs e)
        {
            if (State == null)
            {
                return;
            }

            try
            {
                var message = e.Message;

                if (message == "split")
                {
                    Model.Split();
                }
                else if (message == "unsplit")
                {
                    Model.UndoSplit();
                }
                else if (message == "skipsplit")
                {
                    Model.SkipSplit();
                }
                else if (message == "pause" && State.CurrentPhase != TimerPhase.Paused)
                {
                    Model.Pause();
                }
                else if (message == "resume" && State.CurrentPhase == TimerPhase.Paused)
                {
                    Model.Pause();
                }
                else if (message == "reset")
                {
                    Model.Reset();
                }
                else if (message == "starttimer")
                {
                    Model.Start();
                }
                else if (message.StartsWith("setgametime "))
                {
                    var value = message.Split(' ')[1];
                    var time  = parseTime(value);
                    State.SetGameTime(time);
                }
                else if (message.StartsWith("setloadingtimes "))
                {
                    var value = message.Split(' ')[1];
                    var time  = parseTime(value);
                    State.LoadingTimes = time ?? TimeSpan.Zero;
                }
                else if (message == "pausegametime")
                {
                    State.IsGameTimePaused = true;
                }
                else if (message == "unpausegametime")
                {
                    State.IsGameTimePaused = false;
                }
                else if (message == "getdelta")
                {
                    var delta    = LiveSplitStateHelper.GetLastDelta(State, State.CurrentSplitIndex, State.CurrentComparison, State.CurrentTimingMethod);
                    var response = DeltaFormatter.Format(delta);
                    e.Connection.SendMessage(response);
                }
                else if (message == "getlastsplittime" && State.CurrentSplitIndex > 0)
                {
                    var splittime = State.Run[State.CurrentSplitIndex - 1].SplitTime[State.CurrentTimingMethod];
                    var response  = SplitTimeFormatter.Format(splittime);
                    e.Connection.SendMessage(response);
                }
                else if (message == "getcomparisonsplittime")
                {
                    var splittime = State.CurrentSplit.Comparisons[State.CurrentComparison][State.CurrentTimingMethod];
                    var response  = SplitTimeFormatter.Format(splittime);
                    e.Connection.SendMessage(response);
                }
                else if (message == "getcurrenttime")
                {
                    var time     = State.CurrentTime[State.CurrentTimingMethod];
                    var response = SplitTimeFormatter.Format(time);
                    e.Connection.SendMessage(response);
                }
                else if (message == "getfinaltime" || message.StartsWith("getfinaltime "))
                {
                    var comparison = State.CurrentComparison;
                    if (message.Contains(" "))
                    {
                        comparison = message.Split(new char[] { ' ' }, 2)[1];
                    }
                    var time = (State.CurrentPhase == TimerPhase.Ended)
                        ? State.CurrentTime[State.CurrentTimingMethod]
                        : State.Run.Last().Comparisons[comparison][State.CurrentTimingMethod];
                    var response = SplitTimeFormatter.Format(time);
                    e.Connection.SendMessage(response);
                }
                else if (message.StartsWith("getpredictedtime "))
                {
                    var comparison = message.Split(new char[] { ' ' }, 2)[1];
                    var prediction = PredictTime(State, comparison);
                    var response   = SplitTimeFormatter.Format(prediction);
                    e.Connection.SendMessage(response);
                }
                else if (message == "getbestpossibletime")
                {
                    var comparison = LiveSplit.Model.Comparisons.BestSegmentsComparisonGenerator.ComparisonName;
                    var prediction = PredictTime(State, comparison);
                    var response   = SplitTimeFormatter.Format(prediction);
                    e.Connection.SendMessage(response);
                }
                else if (message.StartsWith("setcomparison "))
                {
                    var comparison = message.Split(new char[] { ' ' }, 2)[1];
                    State.CurrentComparison = comparison;
                }
                else if (message == "switchto realtime")
                {
                    State.CurrentTimingMethod = TimingMethod.RealTime;
                }
                else if (message == "switchto gametime")
                {
                    State.CurrentTimingMethod = TimingMethod.GameTime;
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
        public void UpdatePresence(LiveSplitState state)
        {
            DeltaFormatter.Accuracy     = Settings.Accuracy;
            DeltaFormatter.DropDecimals = Settings.DropDecimals;

            string GlobalComparison = Settings.Comparison;

            if (GlobalComparison == "Current Comparison")
            {
                GlobalComparison = state.CurrentComparison;
            }

            TimerPhase RunState             = state.CurrentPhase;
            string     CategoryName         = state.Run.CategoryName;
            string     DetailedCategoryName = state.Run.GetExtendedCategoryName();
            string     GameName             = state.Run.GameName;
            string     ShortGameName        = state.Run.GameName.GetAbbreviations().Last();

            TimeSpan?delta = TimeSpan.Zero;

            if (RunState == TimerPhase.NotRunning && Settings.NRClearActivity)
            {
                activityManager.ClearActivity((res) =>
                {
                    if (res != Result.Ok)
                    {
                        throw new ResultException(res);
                    }
                });
                return;
            }

            string RunningImage = "gray_square";
            string SplitName    = "";

            if (RunState == TimerPhase.Running || RunState == TimerPhase.Paused)
            {
                SplitName = state.CurrentSplit.Name;
                // Want to do more with this, maybe more advanced formatting. For now, simple removal.
                if (Settings.SubSplitCount && SplitName.Length > 0)
                {
                    int bracket1 = SplitName.IndexOf("{");
                    int bracket2 = SplitName.IndexOf("}");
                    if (SplitName.Substring(0, 1) == "-")
                    {
                        SplitName = SplitName.Substring(1);
                    }

                    if ((bracket1 != -1 && bracket2 != -1) && SplitName.Length > bracket2)
                    {
                        SplitName = SplitName.Substring(bracket2 + 1);
                    }
                }
            }

            if (RunState != TimerPhase.NotRunning)
            {
                var timestring = "";
                if (state.CurrentSplitIndex > 0)
                {
                    GetDelta(GlobalComparison);
                }

                if (RunState != TimerPhase.Paused && timestring.Length > 0)
                {
                    RunningImage = timestring.Substring(0, 1) == "+" ? "red_square" : "green_square";
                }
            }

            long StartTime = 0;

            if (Settings.DisplayElapsedTimeType == ElapsedTimeType.DisplayAttemptDuration || Settings.DisplayElapsedTimeType == ElapsedTimeType.DisplayADwOffset)
            {
                DateTime sTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

                StartTime = (long)(state.AttemptStarted - sTime).TotalSeconds;

                if (Settings.DisplayElapsedTimeType == ElapsedTimeType.DisplayADwOffset)
                {
                    StartTime -= (long)state.Run.Offset.TotalSeconds;
                }
            }
            else if (Settings.DisplayElapsedTimeType == ElapsedTimeType.DisplayGameTime)
            {
                StartTime = DateTime.UtcNow.Ticks - (long)state.CurrentTime[state.CurrentTimingMethod].Value.TotalSeconds;
            }

            var activity = new Activity
            {
                Details = CheckText("Details"),
                State   = CheckText("State"),
                Assets  =
                {
                    LargeImage = "livesplit_icon",
                    LargeText  = CheckText("largeImage")
                }
            };

            if (Settings.Comparison != NoneComparisonGenerator.ComparisonName)
            {
                activity.Assets.SmallText  = CheckText("smallImage");
                activity.Assets.SmallImage = RunningImage;
            }
            if (RunState == TimerPhase.Running && (int)Settings.DisplayElapsedTimeType >= 1)
            {
                activity.Timestamps.Start = StartTime;
            }

            activityManager.UpdateActivity(activity, (res) =>
            {
                if (res != Result.Ok)
                {
                    throw new ResultException(res);
                }
            });

            string CheckText(string item)
            {
                string text = GetText(item);

                if (text == "%inherit")
                {
                    text = GetText(item, true);

                    if (text.Contains("%delta") || text.Contains("%split"))
                    {
                        if (RunState == TimerPhase.NotRunning)
                        {
                            return("Not Running");
                        }
                        else if (RunState == TimerPhase.Ended)
                        {
                            return("Ended. Final Time: " + TimeFormatter.Format(state.CurrentTime[state.CurrentTimingMethod]));
                        }
                        else if (RunState == TimerPhase.Paused)
                        {
                            return("Paused");
                        }
                        else
                        {
                            text = FindDelta(text);
                            text = text.Replace("%split", SplitName);
                        }
                    }
                }
                else
                {
                    text = FindDelta(text);
                    text = text.Replace("%split", SplitName);
                }

                text = text.Replace("%game_short", ShortGameName);
                text = text.Replace("%game", GameName);
                text = text.Replace("%category_detailed", DetailedCategoryName);
                text = text.Replace("%category", CategoryName);
                text = text.Replace("%attempts", state.Run.AttemptCount.ToString());
                text = text.Replace("%comparison", GlobalComparison);
                text = text.Replace("%time", TimeFormatter.Format(state.CurrentTime[state.CurrentTimingMethod]));

                return(text);
            }

            string GetText(string item, bool GetRunning = false)
            {
                if (RunState == TimerPhase.Running || GetRunning)
                {
                    if (item == "Details")
                    {
                        return(Settings.Details);
                    }

                    else if (item == "State")
                    {
                        return(Settings.State);
                    }

                    else if (item == "largeImage")
                    {
                        return(Settings.largeImageKey);
                    }

                    else
                    {
                        return(Settings.smallImageKey);
                    }
                }

                else if (RunState == TimerPhase.NotRunning)
                {
                    if (item == "Details")
                    {
                        return(Settings.NRDetails);
                    }

                    else if (item == "State")
                    {
                        return(Settings.NRState);
                    }

                    else if (item == "largeImage")
                    {
                        return(Settings.NRlargeImageKey);
                    }

                    else
                    {
                        return(Settings.NRsmallImageKey);
                    }
                }

                else if (RunState == TimerPhase.Ended)
                {
                    if (item == "Details")
                    {
                        return(Settings.EDetails);
                    }

                    else if (item == "State")
                    {
                        return(Settings.EState);
                    }

                    else if (item == "largeImage")
                    {
                        return(Settings.ElargeImageKey);
                    }

                    else
                    {
                        return(Settings.EsmallImageKey);
                    }
                }

                else
                {
                    if (item == "Details")
                    {
                        return(Settings.PDetails);
                    }

                    else if (item == "State")
                    {
                        return(Settings.PState);
                    }

                    else if (item == "largeImage")
                    {
                        return(Settings.PlargeImageKey);
                    }

                    else
                    {
                        return(Settings.PsmallImageKey);
                    }
                }
            }

            string GetDelta(string Comparison)
            {
                int SplitIndex = (RunState == TimerPhase.Ended ? state.CurrentSplitIndex - 1 : state.CurrentSplitIndex);

                delta = LiveSplitStateHelper.GetLastDelta(state, SplitIndex, Comparison, state.CurrentTimingMethod);

                return(DeltaFormatter.Format(delta));
            }

            string FindDelta(string SearchText)
            {
                if (SearchText.IndexOf("%delta_") != -1)
                {
                    SearchText = SearchText.Replace("%delta_cur", GetDelta(state.CurrentComparison));

                    foreach (KeyValuePair <string, string> deltaCheck in ComparisonDict)
                    {
                        SearchText = SearchText.Replace(deltaCheck.Key, GetDelta(deltaCheck.Value));
                    }
                }
                SearchText = SearchText.Replace("%delta", GetDelta(GlobalComparison));
                return(SearchText);
            }
        }