コード例 #1
0
        public string Format(TimeSpan? time)
        {
            var deltaTime = new DeltaTimeFormatter();
            deltaTime.Accuracy = Accuracy;
            deltaTime.DropDecimals = DropDecimals;
            var formattedTime = deltaTime.Format(time);
            if (time == null)
                return "-";

            return formattedTime;
        }
コード例 #2
0
 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;
 }
コード例 #3
0
        public string Format(TimeSpan?time)
        {
            var deltaTime = new DeltaTimeFormatter();

            deltaTime.Accuracy     = Accuracy;
            deltaTime.DropDecimals = false;
            var formattedTime = deltaTime.Format(time);

            if (time == null)
            {
                return("-");
            }

            return(formattedTime);
        }
コード例 #4
0
        public string Format(TimeSpan?time)
        {
            var deltaTime = new DeltaTimeFormatter();

            deltaTime.Accuracy     = Accuracy;
            deltaTime.DropDecimals = DropDecimals;
            var formattedTime = deltaTime.Format(time);

            if (time == null)
            {
                return(TimeFormatConstants.DASH);
            }

            return(formattedTime);
        }
コード例 #5
0
ファイル: Twitch.cs プロジェクト: 0xwas/LiveSplit
        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 = string.Format("{0} - {1} Speedrun", run.GameName, run.CategoryName);

                            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 = string.Format("{0} ({1} on {2})", title, delta, splitname);
                                }
                            }

                            SetStreamTitleAndGame(title);
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex);
                    }
                }).Start();
        }
コード例 #6
0
        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);
        }