Example #1
0
 private void RunOnReset(object sender, TimerPhase e) => RunMethod(_methods.onReset, (LiveSplitState)sender);
Example #2
0
 private void State_OnReset(object sender, TimerPhase value)
 {
     Debug.WriteLine($"Reset");
     resetSplitStates();
 }
 private void OnReset(object sender, TimerPhase value)
 {
     updateSplitImage(settings.resetImage);
 }
Example #4
0
 void state_OnReset(object sender, TimerPhase e)
 {
     ScrollOffset = 0;
 }
Example #5
0
 protected void OnReset(object sender, TimerPhase value)
 {
     Recalculate();
 }
		public void OnReset(object sender, TimerPhase e) {
			currentSplit = 0;
			lastLevelComplete = 0;
			state = 0;
			levelTimes = 0;
			lastYP2 = 0;
			startFrameCount = 0;
			lastMenu = MenuScreen.MainMenu;
			Model.CurrentState.IsGameTimePaused = true;
			WriteLog("---------Reset----------------------------------");
		}
Example #7
0
 protected void OnReset(object sender, TimerPhase value)
 {
     updateText();
 }
Example #8
0
        private void DoUpdate(LiveSplitState state, DeltaOutput d)
        {
            var updateState = RunMethod(Methods.update, state, d);

            // If Update explicitly returns false, don't run anything else
            if (updateState is bool && updateState == false)
            {
                return;
            }

            var offsetTime = TimeStamp.CurrentDateTime.Time - d.History[d.FrameIndex].FrameEnd;

            // Enable regardless to keep track of offseting for now.
            if (!state.IsGameTimeInitialized)
            {
                Timer.InitializeGameTime();
            }

            if (state.CurrentPhase == TimerPhase.Running || state.CurrentPhase == TimerPhase.Paused)
            {
                if (UsesGameTime)
                {
                    if (UsesIsLoading)
                    {
                        var isPausedState = RunMethod(Methods.isLoading, state, d);

                        if (isPausedState is bool)
                        {
                            var prevPauseState = state.IsGameTimePaused;

                            state.IsGameTimePaused = isPausedState;

                            if (prevPauseState != isPausedState)
                            {
                                if (isPausedState)
                                {
                                    state.GameTimePauseTime -= offsetTime;
                                }
                                else
                                {
                                    state.GameTimePauseTime += offsetTime;
                                }
                            }
                        }
                    }

                    if (UsesGameTime)
                    {
                        var gameTimeState = RunMethod(Methods.gameTime, state, d);

                        if (gameTimeState is TimeSpan)
                        {
                            state.SetGameTime(gameTimeState);
                        }
                    }
                }

                if (Settings.GetBasicSettingValue("reset"))
                {
                    var resetState = RunMethod(Methods.reset, state, d);

                    if (resetState is bool && resetState == true)
                    {
                        Timer.Reset();
                    }
                }

                if (Settings.GetBasicSettingValue("split"))
                {
                    var splitState = RunMethod(Methods.split, state, d);

                    if (splitState is bool && splitState == true)
                    {
                        splitState = TimeSpan.Zero;
                    }

                    if (splitState is TimeSpan)
                    {
                        AdjustGameTime(state, splitState.Negate());
                        if (!UsesCustomGameTime)
                        {
                            AdjustGameTime(state, offsetTime.Negate());
                        }

                        Timer.Split();

                        if (state.CurrentPhase != TimerPhase.Ended)
                        {
                            AdjustGameTime(state, splitState);
                            if (!UsesCustomGameTime)
                            {
                                AdjustGameTime(state, offsetTime);
                            }
                        }
                        else
                        {
                            LastSplitOffset = splitState;
                            if (!UsesCustomGameTime)
                            {
                                LastSplitOffset += offsetTime;
                            }
                        }
                    }
                }
                // @TODO: Add undo and skip;
            }
            else if (state.CurrentPhase == TimerPhase.NotRunning && Settings.GetBasicSettingValue("start"))
            {
                var startState = RunMethod(Methods.start, state, d);

                if ((startState is bool && startState == true) || startState is TimeSpan)
                {
                    Timer.Start();

                    if (!state.IsGameTimeInitialized)
                    {
                        Timer.InitializeGameTime();
                    }

                    LastSplitOffset = TimeSpan.Zero;

                    TimeSpan startOffset = (startState is TimeSpan) ? startState : TimeSpan.Zero;

                    AdjustGameTime(state, startOffset);
                    if (!UsesCustomGameTime)
                    {
                        AdjustGameTime(state, offsetTime);
                    }
                }
            }

            PreviousPhase = state.CurrentPhase;
        }
 void state_OnReset(object sender, TimerPhase e)
 {
     UpdateHistoryValue((LiveSplitState)sender);
 }
 void state_OnReset(object sender, TimerPhase t)
 {
     this.EngineHook.Unload();
 }
Example #11
0
 void Model_OnReset(object sender, TimerPhase e)
 {
     if (RaceState == RaceState.RaceStarted)
         QuitRace();
 }
Example #12
0
 void state_OnReset(object sender, TimerPhase t)
 {
     _deaths = 0;
 }
 public void OnReset(object sender, TimerPhase e)
 {
     // Reset the autosplitter state whenever LiveSplit is reset
     LogWriter.WriteLine("[LiveSplit] Reset.");
     process.StandardInput.WriteLine("reset");
 }
 void state_OnReset(object sender, TimerPhase e)
 {
     UpdateSumOfBestValue((LiveSplitState)sender);
 }
Example #15
0
 // Reset the odds calculations
 void state_OnReset(object sender, TimerPhase e)
 {
     CalculateOdds();
 }
Example #16
0
        void CurrentState_OnReset(object sender, TimerPhase e)
        {
            RegenerateComparisons();

            this.InvokeIfRequired(() =>
            {
                if (InTimerOnlyMode)
                {
                    var timerOnlyRun = new StandardRunFactory().Create(ComparisonGeneratorsFactory);
                    timerOnlyRun.Offset = CurrentState.Run.Offset;

                    SetRun(timerOnlyRun);
                }
                resetMenuItem.Enabled = false;
                pauseMenuItem.Enabled = false;
                undoSplitMenuItem.Enabled = false;
                skipSplitMenuItem.Enabled = false;
                splitMenuItem.Enabled = true;
                splitMenuItem.Text = "Start";
            });
        }
 public void OnReset(object sender, TimerPhase e)
 {
     currentSplit   = -1;
     lastHasPointer = mem.HasPointer();
     WriteLog("---------Reset----------------------------------");
 }
Example #18
0
 public void OnReset(object sender, TimerPhase e)
 {
     currentSplit = 0;
     WriteLog("---------Reset----------------------------------");
 }
Example #19
0
 private void UpdatePb(object sender, TimerPhase e)
 {
     PersonalBest = GetPbFromState(CurrentState);
 }
 void state_OnReset(object sender, TimerPhase t)
 {
     _count = 0;
 }
        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);
            }
        }
 void state_OnReset(object sender, TimerPhase e)
 {
     UpdateSumOfBestValue((LiveSplitState)sender);
 }
Example #23
0
        private void DoReset(object sender, TimerPhase value)
        {
            LiveSplitState state = (LiveSplitState)sender;

            CurrentNote = new Note("", ComponentName);
        }
Example #24
0
 public void OnReset(object sender, TimerPhase e) {
     currentSplit = 0;
     startOfBomb = DateTime.MinValue;
     endOfBomb = DateTime.MinValue;
     bestTimeRTA = 0;
     bestTime = 0;
 }
Example #25
0
 public void OnReset(object sender, TimerPhase e)
 {
     LogWriter.WriteLine("[LiveSplit] Reset.");
     oriState.Reset();
     oriState.oriTriggers.timerRunning = (Model.CurrentState.CurrentPhase == TimerPhase.Running);
 }
Example #26
0
 void state_OnReset(object sender, TimerPhase e)
 {
     ScrollOffset = 0;
 }
Example #27
0
 void state_OnReset(object sender, TimerPhase t)
 {
     MapTimesForm.Instance.Reset();
     _waitingForDelay = false;
 }
Example #28
0
        void CurrentState_OnReset(object sender, TimerPhase e)
        {
            RegenerateComparisons();
            Action x = () =>
            {
                if (InTimerOnlyMode)
                {
                    var offset = CurrentState.Run.Offset;
                    TimerOnlyRun = new StandardRunFactory().Create(ComparisonGeneratorsFactory);
                    TimerOnlyRun.Offset = offset;
                    var run = TimerOnlyRun;

                    SetRun(run);
                }
                resetMenuItem.Enabled = false;
                pauseMenuItem.Enabled = false;
                undoSplitMenuItem.Enabled = false;
                skipSplitMenuItem.Enabled = false;
                splitMenuItem.Enabled = true;
                splitMenuItem.Text = "Start";
            };

            if (InvokeRequired)
                Invoke(x);
            else
                x();
        }
Example #29
0
 private void OnReset(object sender, TimerPhase timerPhase)
 {
     timer.CurrentState.Run.Offset = TimeSpan.Zero;
 }
Example #30
0
 public void OnSplitReset(object sender, TimerPhase timerPhase)
 {
     //SharedDataManager.Parse
     SendTargetData();
 }
Example #31
0
 private void State_OnReset(object sender, TimerPhase value)
 {
     this.resetIndexesLatch = false;
     this.model.Reset();
 }
 void state_OnReset(object sender, TimerPhase e)
 {
     GameTimeForm.Close();
     PreviousLocation = GameTimeForm.Location;
 }
Example #33
0
 void state_OnReset(object sender, TimerPhase e)
 {
     InvokeIfNeeded(() =>
     {
         lock (VLC)
         {
             VLC.playlist.stop();
             if (activated)
                 Control.Visible = false;
         }
     });
 }
Example #34
0
 void State_OnReset(object sender, TimerPhase e)
 {
     UpdateBearCartPB();
 }
Example #35
0
        // Making the phase nullable makes testing easier.
        public void Refresh(TimerPhase?nullablePhase = null)
        {
            // In theory, the first IGT frame of a run should have a time value of about 32 milliseconds (i.e. one
            // frame at 30 fps). In practice, though, the first non-zero time value tends to be a bit bigger than that.
            // This threshold is arbitrary, but is meant to be big enough to cover that variation in start time, but
            // small enough that later loads into a file don't autostart the timer.
            const int TimerAutostartThreshold = 150;

            if (!Hook())
            {
                return;
            }

            // This will only be true while testing (through a console program).
            if (nullablePhase == null)
            {
                return;
            }

            if (waitingOnFirstLoad)
            {
                if (!memory.IsPlayerLoaded())
                {
                    return;
                }

                InitializeItems();
                UpdateRunState();

                waitingOnFirstLoad = false;
            }

            TimerPhase phase = nullablePhase.Value;

            // Someone might want to disable timer autostart if using real time and starting their timer from the main
            // menu (or some other reason).
            if (phase == TimerPhase.NotRunning && masterControl.StartTimerAutomatically)
            {
                int time = memory.GetGameTimeInMilliseconds();

                // The timer should autostart on a new game, but not every time you load into a file. Note that
                // if someone resets their timer manually immediately as the run begins, the timer may
                // autostart again if game time is still less than the threshold value. This is fixable, but
                // likely not worth the effort.
                if (run.GameTime == 0 && time > 0 && time < TimerAutostartThreshold)
                {
                    timer.Start();
                }
            }

            // Quitout splits (below) are detected using game time (specifically, when IGT is reset back to zero). As
            // such, the current IGT value needs to be stored here before it's reset while updating game time.
            int previousGameTime = run.GameTime;
            int newGameTime      = memory.GetGameTimeInMilliseconds();

            // The timer is intentionally updated before an autosplit occurs (to ensure the split time is as accurate
            // as possible).
            if (masterControl.UseGameTime)
            {
                UpdateGameTime(newGameTime);
            }
            else
            {
                // Game time must be tracked even if "Use game time" is disabled (in order to accomodate quitout
                // splits).
                run.GameTime = newGameTime;
            }

            // This is called each tick regardless of whether the current split is an item split (to ensure that the
            // inventory state is accurate by the time an item split crops up).
            if (itemsEnabled)
            {
                memory.RefreshItems();
            }

            // This check is intentionally done relatively far down in the function. The reason is that an ended timer
            // can be undone, and if that happens, I'd like all splits to continue working properly. Specifically, that
            // means that items and IGT (if applicable) are tracked even when the timer has ended.
            if (phase == TimerPhase.Ended)
            {
                return;
            }

            Split split = splitCollection.CurrentSplit;

            // It's possible for the current split to be null if no splits were configured at all.
            if (split == null || split.Type == SplitTypes.Manual || !split.IsFinished)
            {
                return;
            }

            // This condition covers all split types with warping as an option.
            if (preparedForWarp)
            {
                if (isBonfireWarpSplitActive)
                {
                    int[] leaveValues =
                    {
                        (int)AnimationFlags.BonfireLeave1,
                        (int)AnimationFlags.BonfireLeave2,
                        (int)AnimationFlags.BonfireLeave3
                    };

                    int animation = memory.GetForcedAnimation();

                    // Without this check, the player could rest at a target bonfire (without warping), then warp from
                    // another bonfire and have the tool incorrectly split.
                    if (leaveValues.Contains(animation))
                    {
                        preparedForWarp = false;

                        return;
                    }
                }
                else if (isItemWarpSplitActive && !IsTargetItemSatisfied())
                {
                    preparedForWarp = false;

                    return;
                }

                if (CheckWarp())
                {
                    timer.Split();
                }

                return;
            }

            // Similar to warping, this covers all splits with quitouts as a timing option (and Quitout splits
            // themselves, of course).
            if (waitingOnQuitout)
            {
                // Game time is reset to zero on the title screen, but not on regular loading screens.
                if (newGameTime == 0 && previousGameTime > 0)
                {
                    if (splitCollection.CurrentSplit.Type == SplitTypes.Quitout)
                    {
                        run.Data++;

                        // Quitout splits track quitout count. If that target hasn't yet been satisfied, the function
                        // can just return immediately (which leaves the waitingOnQuitout variable intact).
                        if (run.Data < run.Target)
                        {
                            return;
                        }
                    }

                    // On quitout splits, the actual split occurs on the loading screen following a reload
                    // (specifically when the player is loaded). This is done to account for any potential IGT drift
                    // between quitout and reload. In theory, this drift shouldn't exist, but it seems to happen anyway
                    // in practice.
                    waitingOnUnload  = true;
                    waitingOnQuitout = false;
                }

                return;
            }

            if (waitingOnUnload)
            {
                // When the load screen appears following a quitout, the player isn't unloaded instantly.
                if (!memory.IsPlayerLoaded())
                {
                    waitingOnUnload = false;
                    waitingOnReload = true;
                }

                return;
            }

            if (waitingOnReload)
            {
                // By the time this point in the code is reached, the player must already be unloaded (due to quitting
                // to the title screen).
                if (memory.IsPlayerLoaded())
                {
                    waitingOnReload = false;
                    timer.Split();
                }

                return;
            }

            if (splitFunctions[split.Type](split.Data))
            {
                timer.Split();
            }
        }
 void state_OnReset(object sender, TimerPhase t)
 {
     MapTimesForm.Instance.Reset();
     _waitingForDelay = false;
 }
 public void OnReset(object sender, TimerPhase e)
 {
     currentSplit = -1;
     Model.CurrentState.IsGameTimePaused = true;
     WriteLog("---------Reset----------------------------------");
 }
Example #38
0
 private void State_OnReset(object sender, TimerPhase e)
 {
     if (e != TimerPhase.Ended)
         PlaySound(Settings.Reset, Settings.ResetVolume);
 }
Example #39
0
 public void OnBaseReset(object sender, TimerPhase timerPhase)
 {
     OnReset?.Invoke(sender, timerPhase);
 }
Example #40
0
 void state_OnReset(object sender, TimerPhase t)
 {
 }
		public void OnReset(object sender, TimerPhase e) {
			currentSplit = 0;
			Model.CurrentState.IsGameTimePaused = true;
			WriteLog("---------Reset----------------------------------");
		}
 void state_OnReset(object sender, TimerPhase e)
 {
     GameTimeForm.Close();
     PreviousLocation = GameTimeForm.Location;
 }
 public void OnReset(object sender, TimerPhase e) {
     LogWriter.WriteLine("[LiveSplit] Reset.");
     oriState.Reset();
     oriState.oriTriggers.timerRunning = (Model.CurrentState.CurrentPhase == TimerPhase.Running);
 }