public override void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { if (state.CurrentPhase == TimerPhase.NotRunning) { if (AutoSplitter.ShouldStart(state)) { Model.Start(); } } else if (state.CurrentPhase == TimerPhase.Running || state.CurrentPhase == TimerPhase.Paused) { if (AutoSplitter.ShouldReset(state)) { Model.Reset(); return; } else if (AutoSplitter.ShouldSplit(state)) { Model.Split(); } state.IsGameTimePaused = AutoSplitter.IsGameTimePaused(state); var gameTime = AutoSplitter.GetGameTime(state); if (gameTime != null) state.SetGameTime(gameTime); } }
public RunHighlighterComponent(LiveSplitState state) { this._state = state; this.Settings = new RunHighlighterSettings(); this.ContextMenuControls = new Dictionary<string, Action>(); this.ContextMenuControls.Add("Run Highlighter...", new Action(() => { MessageBox.Show(_state.Form, "This component is now obsolete and has been replaced by this website:\nhttps://dalet.github.io/run-highlighter/" + "\n\nThe website has new features such as individual segment highlighting and multi-part detection." + "\n\nThe URL will be opened after you close this message.", "Run Highlighter", MessageBoxButtons.OK, MessageBoxIcon.Information); System.Diagnostics.Process.Start("https://dalet.github.io/run-highlighter/"); /*if (_state.CurrentPhase == TimerPhase.Ended) { MessageBox.Show(_state.Form, "The timer needs to be resetted in order to update the Attempt History.", "Run Highlighter"); return; } var originalTopMost = _state.Form.TopMost; _state.Form.TopMost = false; //to ensure our Internet Explorer window isn't covered using (var form = new RunHighlighterForm(state.Run, Settings)) form.ShowDialog(state.Form); _state.Form.TopMost = originalTopMost;*/ })); }
private static TimeSpan? GetSegmentTimeOrSegmentDelta(LiveSplitState state, int splitNumber, bool useCurrentTime, bool segmentTime, string comparison, TimingMethod method) { TimeSpan? currentTime; if (useCurrentTime) currentTime = state.CurrentTime[method]; else currentTime = state.Run[splitNumber].SplitTime[method]; if (currentTime == null) return null; for (int x = splitNumber - 1; x >= 0; x--) { var splitTime = state.Run[x].SplitTime[method]; if (splitTime != null) { if (segmentTime) return currentTime - splitTime; else if (state.Run[x].Comparisons[comparison][method] != null) return (currentTime - state.Run[splitNumber].Comparisons[comparison][method]) - (splitTime - state.Run[x].Comparisons[comparison][method]); } } if (segmentTime) return currentTime; else return currentTime - state.Run[splitNumber].Comparisons[comparison][method]; }
public void DrawHorizontal(Graphics g, LiveSplitState state, float height, Region clipRegion) { using (var solidBrush = new SolidBrush(LineColor)) { g.FillRectangle(solidBrush, 0.0f, 0.0f, HorizontalWidth, height); } }
public IComponent Create(LiveSplitState state) { // workaround for livesplit 1.4 oversight where components can be loaded from two places at once // remove all this junk when they fix it string caller = new StackFrame(1).GetMethod().Name; string callercaller = new StackFrame(2).GetMethod().Name; bool createAsLayoutComponent = (caller == "LoadLayoutComponent" || caller == "AddComponent"); // if component is already loaded somewhere else if (_instance != null && !_instance.Disposed) { // "autosplit components" can't throw exceptions for some reason, so return a dummy component if (callercaller == "CreateAutoSplitter") { return new DummyComponent(); } MessageBox.Show( "LiveSplit.RedFaction is already loaded in the " + (_instance.IsLayoutComponent ? "Layout Editor" : "Splits Editor") + "!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); throw new Exception("Component already loaded."); } return (_instance = new RedFactionComponent(state, createAsLayoutComponent)); }
private void PrepareDraw(LiveSplitState state, LayoutMode mode) { InternalComponent.DisplayTwoRows = Settings.Display2Rows; InternalComponent.NameLabel.HasShadow = InternalComponent.ValueLabel.HasShadow = state.LayoutSettings.DropShadows; if (String.IsNullOrEmpty(Settings.Text1) || String.IsNullOrEmpty(Settings.Text2)) { InternalComponent.NameLabel.HorizontalAlignment = StringAlignment.Center; InternalComponent.ValueLabel.HorizontalAlignment = StringAlignment.Center; InternalComponent.NameLabel.VerticalAlignment = StringAlignment.Center; InternalComponent.ValueLabel.VerticalAlignment = StringAlignment.Center; } else { InternalComponent.NameLabel.HorizontalAlignment = StringAlignment.Near; InternalComponent.ValueLabel.HorizontalAlignment = StringAlignment.Far; InternalComponent.NameLabel.VerticalAlignment = mode == LayoutMode.Horizontal || Settings.Display2Rows ? StringAlignment.Near : StringAlignment.Center; InternalComponent.ValueLabel.VerticalAlignment = mode == LayoutMode.Horizontal || Settings.Display2Rows ? StringAlignment.Far : StringAlignment.Center; } InternalComponent.NameLabel.ForeColor = Settings.OverrideTextColor ? Settings.TextColor : state.LayoutSettings.TextColor; InternalComponent.ValueLabel.ForeColor = Settings.OverrideTimeColor ? Settings.TimeColor : state.LayoutSettings.TextColor; }
public void DrawVertical(Graphics g, LiveSplitState state, float width, Region clipRegion) { using (var solidBrush = new SolidBrush(LineColor)) { g.FillRectangle(solidBrush, 0.0f, 0.0f, width, VerticalHeight); } }
public void Activate(LiveSplitState state) { if (!IsActivated) { try { if (!IsDownloaded || Type == AutoSplitterType.Script) DownloadFiles(); if (Type == AutoSplitterType.Component) { Factory = ComponentManager.ComponentFactories[FileName]; Component = Factory.Create(state); } else { Factory = ComponentManager.ComponentFactories["LiveSplit.ScriptableAutoSplit.dll"]; Component = ((dynamic)Factory).Create(state, LocalPath); } } catch (Exception ex) { Log.Error(ex); MessageBox.Show(state.Form, "The Auto Splitter could not be activated. (" + ex.Message + ")", "Activation Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void PrepareDraw(LiveSplitState state) { InternalComponent.DisplayTwoRows = Settings.Display2Rows; InternalComponent.NameLabel.HasShadow = InternalComponent.ValueLabel.HasShadow = state.LayoutSettings.DropShadows; InternalComponent.NameLabel.ForeColor = Settings.OverrideTextColor ? Settings.TextColor : state.LayoutSettings.TextColor; }
public TextComponent(LiveSplitState state) { Settings = new TextComponentSettings() { CurrentState = state }; InternalComponent = new TextTextComponent(Settings); }
public ManualGameTimeComponent(LiveSplitState state) { Settings = new ManualGameTimeSettings(); GameTimeForm = new ShitSplitter(state, Settings); state.OnStart += state_OnStart; state.OnReset += state_OnReset; CurrentState = state; }
public Component(LiveSplitState state) { model = new TimerModel() { CurrentState = state }; model.CurrentState.OnStart += State_OnStart; eventList = settings.GetEventList(); settings.EventsChanged += settings_EventsChanged; }
public void DrawVertical(Graphics g, LiveSplitState state, float width, Region clipRegion) { var component = queuedComponents.FirstOrDefault(); if (component != null) { component.DrawVertical(g, state, width, clipRegion); } }
public void DrawHorizontal(Graphics g, LiveSplitState state, float height, Region clipRegion) { var component = queuedComponents.FirstOrDefault(); if (component != null) { component.DrawHorizontal(g, state, height, clipRegion); } }
public Component(LiveSplitState state, string scriptPath) : this(state) { Settings = new ComponentSettings() { ScriptPath = scriptPath }; }
public ShitSplitter(LiveSplitState state, ManualGameTimeSettings settings) { InitializeComponent(); Model = new TimerModel() { CurrentState = state }; Settings = settings; }
public ColumnSettings(LiveSplitState state, string columnName, IList<ColumnSettings> columnsList) { InitializeComponent(); Data = new ColumnData(columnName, ColumnType.Delta, "Current Comparison", "Current Timing Method"); CurrentState = state; ColumnsList = columnsList; }
public Component(LiveSplitState state) { Settings = new ComponentSettings(); FSWatcher = new FileSystemWatcher(); FSWatcher.Changed += (sender, args) => DoReload = true; UpdateTimer = new Timer() { Interval = 15 }; // run a little faster than 60hz UpdateTimer.Tick += (sender, args) => UpdateScript(state); UpdateTimer.Enabled = true; }
public void DrawHorizontal(Graphics g, LiveSplitState state, float height, Region clipRegion) { if (Settings.showMapDisplay) { if (state.LayoutSettings.BackgroundColor.ToArgb() != Color.Transparent.ToArgb()) { g.FillRectangle(new SolidBrush(state.LayoutSettings.BackgroundColor), 0, 0, HorizontalWidth, height); } PrepareDraw(state, LayoutMode.Horizontal); textInfo.DrawHorizontal(g, state, height, clipRegion); } }
public DragonAgeInquisitionComponent(LiveSplitState state) { _timer = new TimerModel { CurrentState = state }; _gameMemory = new GameMemory(); _gameMemory.OnLoadStarted += gameMemory_OnLoadStarted; _gameMemory.OnLoadFinished += gameMemory_OnLoadFinished; _gameMemory.StartMonitoring(); }
/// <summary> /// Gets the last non-live delta in the run starting from splitNumber. /// </summary> /// <param name="state">The current state.</param> /// <param name="splitNumber">The split number to start checking deltas from.</param> /// <param name="comparison">The comparison that you are comparing with.</param> /// <param name="method">The timing method that you are using.</param> /// <returns>Returns the last non-live delta or null if there have been no deltas yet.</returns> public static TimeSpan? GetLastDelta(LiveSplitState state, int splitNumber, string comparison, TimingMethod method) { for (var x = splitNumber; x >= 0; x--) { if (state.Run[x].Comparisons[comparison][method] != null && state.Run[x].SplitTime[method] != null) return state.Run[x].SplitTime[method] - state.Run[x].Comparisons[comparison][method]; } return null; }
public TotalPlaytimeComponent(LiveSplitState state) { TimeFormatter = new RegularTimeFormatter(TimeAccuracy.Seconds); InternalComponent = new InfoTimeComponent("Total Playtime", TimeSpan.Zero, TimeFormatter); Settings = new TotalPlaytimeSettings() { CurrentState = state }; }
public LoadTimer(LiveSplitState state) { Formatter = new PossibleTimeSaveFormatter(); InternalComponent = new InfoTimeComponent(null, null, Formatter); Cache = new GraphicsCache(); Settings = new AlternateTimingMethodSettings() { CurrentState = state }; }
public RunPrediction(LiveSplitState state) { Settings = new RunPredictionSettings() { CurrentState = state }; Formatter = new RunPredictionFormatter(Settings.Accuracy); InternalComponent = new InfoTimeComponent(null, null, Formatter); state.ComparisonRenamed += state_ComparisonRenamed; }
public DeltaComponent(LiveSplitState state) { Settings = new DeltaSettings() { CurrentState = state }; Formatter = new DeltaComponentFormatter(Settings.Accuracy, Settings.DropDecimals); InternalComponent = new InfoTimeComponent(null, null, Formatter); state.ComparisonRenamed += state_ComparisonRenamed; }
public dynamic Run(LiveSplitState timer, ASLState old, ASLState current, ExpandoObject vars, Process game, ref string version, ref double refreshRate) { // dynamic args can't be ref or out, this is a workaround CompiledCode.version = version; CompiledCode.refreshRate = refreshRate; var ret = CompiledCode.Execute(timer, old.Data, current.Data, vars, game); version = CompiledCode.version; refreshRate = CompiledCode.refreshRate; return ret; }
private bool CheckIfRunChanged(LiveSplitState state) { if (PreviousCalculationMode != state.Settings.SimpleSumOfBest) return true; if (PreviousTimingMethod != state.CurrentTimingMethod) return true; return false; }
public ContextualSlideshowComponent(LiveSplitState state) { this.state = state; slideshowComponents = new List<SlideshowComponent> { new SlideshowComponent(new PossibleTimeSave(state)), new SlideshowComponent(new PreviousSegment(state)), new SlideshowComponent(new RunPrediction(state)) }; queuedComponents = new Queue<IComponent>(); }
public AmnesiaComponent(LiveSplitState state) { _timer = new TimerModel() { CurrentState = state }; _timer.OnStart += timer_OnStart; _updateTimer = new Timer() { Interval = 15, Enabled = true }; _updateTimer.Tick += updateTimer_Tick; _gameMemory = new GameMemory(); _gameMemory.OnLoadingChanged += gameMemory_OnLoadingChanged; }
private void DrawGeneral(Graphics g, LiveSplitState state, float width, float height) { var oldMatrix = g.Transform; if (Settings.FlipGraph) { g.ScaleTransform(1, -1); g.TranslateTransform(0, -height); } DrawGraph(g, state, width, height); g.Transform = oldMatrix; }
/// <summary> /// Gets the length of the last segment that leads up to a certain split, using the live segment time if the split is not completed yet. /// </summary> /// <param name="state">The current state.</param> /// <param name="splitNumber">The index of the split that represents the end of the segment.</param> /// <param name="method">The timing method that you are using.</param> /// <returns>Returns the length of the segment leading up to splitNumber, returning the live segment time if the split is not completed yet.</returns> public static TimeSpan?GetLiveSegmentTime(LiveSplitState state, int splitNumber, TimingMethod method) { return(GetSegmentTimeOrSegmentDelta(state, splitNumber, true, true, Run.PersonalBestComparisonName, method)); }
/// <summary> /// Gets the amount of time lost or gained on a certain split. /// </summary> /// <param name="state">The current state.</param> /// <param name="splitNumber">The index of the split for which the delta is calculated.</param> /// <param name="comparison">The comparison that you are comparing with.</param> /// <param name="method">The timing method that you are using.</param> /// <returns>Returns the segment delta for a certain split, returning null if the split is not completed yet.</returns> public static TimeSpan?GetPreviousSegmentDelta(LiveSplitState state, int splitNumber, string comparison, TimingMethod method) { return(GetSegmentTimeOrSegmentDelta(state, splitNumber, false, false, comparison, method)); }