public override void Update(IInvalidator invalidator, Model.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 IComponent Create(Model.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.TwitchPredictions 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 TwitchPredictionsComponent(state, createAsLayoutComponent)); }
public void Update(IInvalidator invalidator, Model.LiveSplitState state, float width, float height, LayoutMode mode) { int completedExitCount = 0; if (Settings.AutoTotalCount) { completedExitCount = Math.Max(completedExitCount, state.CurrentSplitIndex); ExitCounterLabel.Text = Settings.ExitCounterText + " " + completedExitCount.ToString() + "/" + state.Run.Count; } else { try { completedExitCount = int.Parse(state.CurrentSplit.Name) - 1; } catch { try { completedExitCount = Math.Max(completedExitCount, state.CurrentSplitIndex); } catch { } } ExitCounterLabel.Text = Settings.ExitCounterText + " " + completedExitCount.ToString() + "/" + Settings.TotalExitCount.ToString(); } Cache.Restart(); Cache["ExitCounterLabel"] = ExitCounterLabel.Text; if (invalidator != null && Cache.HasChanged) { invalidator.Invalidate(0, 0, width, height); } }
public override void Update(UI.IInvalidator invalidator, Model.LiveSplitState state, float width, float height, UI.LayoutMode mode) { if (Scores.Count() != State.Run.Count) { initArrays(); } }
public void Update(IInvalidator invalidator, Model.LiveSplitState state, float width, float height, LayoutMode mode) { try { if (Settings.Hook != null) { Settings.Hook.Poll(); } } catch { } this.state = state; CounterNameLabel.Text = Settings.CounterText; CounterValueLabel.Text = Counter.Count.ToString(); Cache.Restart(); Cache["CounterNameLabel"] = CounterNameLabel.Text; Cache["CounterValueLabel"] = CounterValueLabel.Text; if (invalidator != null && Cache.HasChanged) { invalidator.Invalidate(0, 0, width, height); } }
public virtual void Update(IInvalidator invalidator, Model.LiveSplitState state, float width, float height, LayoutMode mode) { if (!HasInvalidated && invalidator != null) { invalidator.Invalidate(0, 0, width, height); HasInvalidated = true; } }
public void Update(IInvalidator invalidator, Model.LiveSplitState state, float width, float height, LayoutMode mode) { State = state; if (bSettingsShouldInit) { SettingsInit(); } if (Settings.bStatusIconsEnabled) { if (Settings.IconFrameSize != VerticalHeight || Settings.IconFrameSize != HorizontalWidth) { VerticalHeight = Settings.IconFrameSize; HorizontalWidth = Settings.IconFrameSize; } StatusIcons.Update(); Cache.Restart(); Cache["IconFrameSize"] = Settings.IconFrameSize; Cache["IconPadding"] = Settings.IconPadding; Cache["IconMargin"] = Settings.IconMargin; Cache["ConnectionIconColor"] = Settings.ConnectionIconColor; Cache["IncomingDataIconColor"] = Settings.IncomingDataIconColor; Cache["OutgoingDataIconColor"] = Settings.OutgoingDataIconColor; Cache["WarningIconColor"] = Settings.WarningIconColor; Cache["ErrorIconColor"] = Settings.ErrorIconColor; Cache["InactiveIconColor"] = Settings.InactiveIconColor; } /* * if( invalidator != null && ( Cache.HasChanged || Settings.bStatusIconsEnabled && StatusIcons.CacheHasChanged() ) ) * { * invalidator.Invalidate(0, 0, width, height); * } */ if (invalidator != null) { if (Cache.HasChanged) { invalidator.Invalidate(0, 0, width, height); } else if (Settings.bStatusIconsEnabled) { if (StatusIcons.CacheHasChanged()) { invalidator.Invalidate(0, 0, width, height); } } } }
public string Verify(Model.LiveSplitState splitStates) { StringBuilder sbIssues = new StringBuilder(); var segments = splitStates.Run.ToList(); if (segments.Count < EventList.Count) { EventList.RemoveRange(segments.Count, EventList.Count - segments.Count); //TO DO: Test this! sbIssues.AppendLine("- Event list had more positions than splits (the list was trimmed!)"); } else if (segments.Count > EventList.Count) { var splitsToAdd = segments.Where((x, i) => i >= EventList.Count).Select(x => new SplitsToEvents.SplitEvent()); EventList.AddRange(splitsToAdd); sbIssues.AppendLine("- Event list has less positions than splits (new positions were added!)"); } for (int i = 0; i < EventList.Count; i++) { EventList[i].SegmentName = segments[i].Name; } RequiresManualFixing = false; bool predictionRunning = false; for (int i = 0; i < EventList.Count; i++) { if (EventList[i].EventType == SplitEventType.None) { continue; } else if (EventList[i].EventType == SplitEventType.StartPredictionOnSplitStart && !predictionRunning) { predictionRunning = true; } else if (EventList[i].EventType == SplitEventType.StartPredictionOnSplitStart && predictionRunning) { sbIssues.AppendLine($"- Event list tries to start a prediction before the other prediction is closed (Split #{i + 1}.)"); RequiresManualFixing = true; break; } else if (EventList[i].EventType == SplitEventType.FinishPredictionWithOption1 || EventList[i].EventType == SplitEventType.FinishPredictionWithOption2) { predictionRunning = false; } } return(sbIssues.ToString()); }
private void DrawGeneral(Graphics g, Model.LiveSplitState state, float width, float height, LayoutMode mode) { // Set Background colour. if (Settings.BackgroundColor.A > 0 || Settings.BackgroundGradient != GradientType.Plain && Settings.BackgroundColor2.A > 0) { var gradientBrush = new LinearGradientBrush( new PointF(0, 0), Settings.BackgroundGradient == GradientType.Horizontal ? new PointF(width, 0) : new PointF(0, height), Settings.BackgroundColor, Settings.BackgroundGradient == GradientType.Plain ? Settings.BackgroundColor : Settings.BackgroundColor2); g.FillRectangle(gradientBrush, 0, 0, width, height); } // Set Font. CounterFont = Settings.OverrideCounterFont ? Settings.CounterFont : state.LayoutSettings.TextFont; // Calculate Height from Font. var textHeight = g.MeasureString("A", CounterFont).Height; VerticalHeight = 1.2f * textHeight; MinimumHeight = MinimumHeight; PaddingTop = Math.Max(0, ((VerticalHeight - 0.75f * textHeight) / 2f)); PaddingBottom = PaddingTop; HorizontalWidth = ExitCounterLabel.X + ExitCounterLabel.ActualWidth + 5; // Set Counter Label. ExitCounterLabel.HorizontalAlignment = mode == LayoutMode.Horizontal ? StringAlignment.Center : StringAlignment.Center; ExitCounterLabel.VerticalAlignment = StringAlignment.Center; ExitCounterLabel.X = 10; ExitCounterLabel.Y = 0; ExitCounterLabel.Width = (width - 10); ExitCounterLabel.Height = height; ExitCounterLabel.Font = CounterFont; ExitCounterLabel.Brush = new SolidBrush(Settings.OverrideTextColor ? Settings.CounterTextColor : state.LayoutSettings.TextColor); ExitCounterLabel.HasShadow = state.LayoutSettings.DropShadows; ExitCounterLabel.ShadowColor = state.LayoutSettings.ShadowsColor; ExitCounterLabel.OutlineColor = state.LayoutSettings.TextOutlineColor; ExitCounterLabel.Draw(g); }
/* drawing */ private void DrawBase(Graphics g, Model.LiveSplitState state, float width, float height, LayoutMode mode) { DrawBackground(g, width, height); if (Settings.bStatusIconsEnabled) { if (mode == LayoutMode.Vertical) { StatusIcons.DrawStatusVertical(g, Settings, width, VerticalHeight); } else { StatusIcons.DrawStatusHorizontal(g, Settings, HorizontalWidth, height); } } }
public TwitchPredictionsSettings(Model.LiveSplitState splitStates) { InitializeComponent(); DebugLogging._settings = this; DebugLogging.Log("Created settings and set reference", true); this.splitStates = splitStates; _twitchConnection = TwitchConnection.GetInstance(); //Set bindings TB_ServerAdress.DataBindings.Add("Text", this, "Address", false, DataSourceUpdateMode.OnPropertyChanged); NumB_Port.DataBindings.Add("Value", this, "Port", false, DataSourceUpdateMode.OnPropertyChanged); TB_UserName.DataBindings.Add("Text", this, "Username", false, DataSourceUpdateMode.OnPropertyChanged); TB_Oauth.DataBindings.Add("Text", this, "Oauth", false, DataSourceUpdateMode.OnPropertyChanged); TB_Channel.DataBindings.Add("Text", this, "Channel", false, DataSourceUpdateMode.OnPropertyChanged); CB_ConnectOnComponentLaunch.DataBindings.Add("Checked", this, "ConnectOnLaunch", false, DataSourceUpdateMode.OnPropertyChanged); }
public override void PrepareDraw(Model.LiveSplitState state, LayoutMode mode) { NameMeasureLabel.Font = state.LayoutSettings.TextFont; ValueLabel.Font = state.LayoutSettings.TimesFont; NameLabel.Font = state.LayoutSettings.TextFont; if (mode == LayoutMode.Vertical) { NameLabel.VerticalAlignment = StringAlignment.Center; ValueLabel.VerticalAlignment = StringAlignment.Center; } else { NameLabel.VerticalAlignment = StringAlignment.Near; ValueLabel.VerticalAlignment = StringAlignment.Far; } }
public void Update(IInvalidator invalidator, Model.LiveSplitState state, float width, float height, LayoutMode mode) { TimeSpan?tq = state.CurrentTime[state.CurrentTimingMethod]; if (tq.HasValue) { TimeSpan t = tq.Value; int H = ((int)(t.TotalMinutes + 8.25)); int M = ((int)t.TotalSeconds + 495) - H * 60; H = H % 24; M = M % 60; SetTime(H, M); } if (invalidator != null) { invalidator.Invalidate(0, 0, width, height); } }
public IComponent Create(Model.LiveSplitState state) { var result = new Dictionary <int, string[]>(); var pid = Process.GetCurrentProcess().Id; using (var dataTarget = DataTarget.AttachToProcess(pid, 5000, AttachFlag.Passive)) { string dacLocation = dataTarget.ClrVersions[0].TryGetDacLocation(); var runtime = dataTarget.CreateRuntime(dacLocation); foreach (var t in runtime.Threads) { result.Add( t.ManagedThreadId, t.StackTrace.Select(f => { if (f.Method != null) { return(f.Method.Type.Name + "." + f.Method.Name); } return(null); }).ToArray() ); } } foreach (var thread in result) { Debug.WriteLine("Thread #" + thread.Key + ":"); foreach (var method in thread.Value) { Debug.WriteLine(method); } } throw new Exception(); }
public override void Update(UI.IInvalidator invalidator, Model.LiveSplitState state, float width, float height, UI.LayoutMode mode) { base.Update(invalidator, state, width, height, mode); if (!Initialized) { Control.Visible = !Control.Created; Initialized = Control.Created; } else { if (VLC != null && OldMRL != Settings.MRL && !String.IsNullOrEmpty(Settings.MRL)) { InvokeIfNeeded(() => { lock (VLC) { VLC.playlist.items.clear(); VLC.playlist.add(Settings.MRL); } }); } OldMRL = Settings.MRL; if (VLC != null) { InvokeIfNeeded(() => { lock (VLC) { VLC.audio.mute = true; VLC.Volume = 5; } }); } } }
public void Update(IInvalidator invalidator, Model.LiveSplitState state, float width, float height, LayoutMode mode) { try { if (Settings.Hook != null) { Settings.Hook.Poll(); } } catch { } this.state = state; // Set memory value label MemoryReaderTextLabel.Text = Settings.MemReaderText; // Read memory and convert byte[] mem = MemoryReader.ReadMemory(Settings.MemReaderGameTitle, Settings.MemReaderPointer, true); if (mem != null) { MemoryReaderValueLabel.Text = ConvertMemory(mem); } else { MemoryReaderValueLabel.Text = "-"; } Cache.Restart(); Cache["MemoryReaderTextLabel"] = MemoryReaderTextLabel.Text; Cache["MemoryReaderValueLabel"] = MemoryReaderValueLabel.Text; if (invalidator != null && Cache.HasChanged) { invalidator.Invalidate(0, 0, width, height); } }
public abstract void Update(IInvalidator invalidator, Model.LiveSplitState state, float width, float height, LayoutMode mode);
public void DrawVertical(System.Drawing.Graphics g, Model.LiveSplitState state, float width, System.Drawing.Region clipRegion) { }
public void DrawHorizontal(System.Drawing.Graphics g, Model.LiveSplitState state, float height, System.Drawing.Region clipRegion) { }
public void DrawHorizontal(Graphics g, Model.LiveSplitState state, float height, Region clipRegion) { }
public void DrawVertical(System.Drawing.Graphics g, Model.LiveSplitState state, float width, Region clipRegion) { DrawBase(g, state, width, VerticalHeight, LayoutMode.Vertical); }
public override void Update(UI.IInvalidator invalidator, Model.LiveSplitState state, float width, float height, UI.LayoutMode mode) { }
private void DrawGeneral(Graphics g, Model.LiveSplitState state, float width, float height, LayoutMode mode) { // Set Background colour. if (Settings.BackgroundColor.A > 0 || Settings.BackgroundGradient != GradientType.Plain && Settings.BackgroundColor2.A > 0) { var gradientBrush = new LinearGradientBrush( new PointF(0, 0), Settings.BackgroundGradient == GradientType.Horizontal ? new PointF(width, 0) : new PointF(0, height), Settings.BackgroundColor, Settings.BackgroundGradient == GradientType.Plain ? Settings.BackgroundColor : Settings.BackgroundColor2); g.FillRectangle(gradientBrush, 0, 0, width, height); } // Set Font. CounterFont = Settings.OverrideCounterFont ? Settings.CounterFont : state.LayoutSettings.TextFont; // Calculate Height from Font. var textHeight = g.MeasureString("A", CounterFont).Height; VerticalHeight = 1.2f * textHeight; MinimumHeight = MinimumHeight; PaddingTop = Math.Max(0, ((VerticalHeight - 0.75f * textHeight) / 2f)); PaddingBottom = PaddingTop; // Assume most users won't count past four digits (will cause a layout resize in Horizontal Mode). float fourCharWidth = g.MeasureString("1000", CounterFont).Width; HorizontalWidth = CounterNameLabel.X + CounterNameLabel.ActualWidth + (fourCharWidth > CounterValueLabel.ActualWidth ? fourCharWidth : CounterValueLabel.ActualWidth) + 5; // Set Counter Name Label CounterNameLabel.HorizontalAlignment = mode == LayoutMode.Horizontal ? StringAlignment.Near : StringAlignment.Near; CounterNameLabel.VerticalAlignment = StringAlignment.Center; CounterNameLabel.X = 5; CounterNameLabel.Y = 0; CounterNameLabel.Width = (width - fourCharWidth - 5); CounterNameLabel.Height = height; CounterNameLabel.Font = CounterFont; CounterNameLabel.Brush = new SolidBrush(Settings.OverrideTextColor ? Settings.CounterTextColor : state.LayoutSettings.TextColor); CounterNameLabel.HasShadow = state.LayoutSettings.DropShadows; CounterNameLabel.ShadowColor = state.LayoutSettings.ShadowsColor; CounterNameLabel.OutlineColor = state.LayoutSettings.TextOutlineColor; CounterNameLabel.Draw(g); // Set Counter Value Label. CounterValueLabel.HorizontalAlignment = mode == LayoutMode.Horizontal ? StringAlignment.Far : StringAlignment.Far; CounterValueLabel.VerticalAlignment = StringAlignment.Center; CounterValueLabel.X = 5; CounterValueLabel.Y = 0; CounterValueLabel.Width = (width - 10); CounterValueLabel.Height = height; CounterValueLabel.Font = CounterFont; CounterValueLabel.Brush = new SolidBrush(Settings.OverrideTextColor ? Settings.CounterValueColor : state.LayoutSettings.TextColor); CounterValueLabel.HasShadow = state.LayoutSettings.DropShadows; CounterValueLabel.ShadowColor = state.LayoutSettings.ShadowsColor; CounterValueLabel.OutlineColor = state.LayoutSettings.TextOutlineColor; CounterValueLabel.Draw(g); }
private void DrawGeneral(Graphics g, Model.LiveSplitState state, float width, float height, LayoutMode mode) { // Set Background colour. if (Settings.BackgroundColor.ToArgb() != Color.Transparent.ToArgb() || Settings.BackgroundGradient != GradientType.Plain && Settings.BackgroundColor2.ToArgb() != Color.Transparent.ToArgb()) { var gradientBrush = new LinearGradientBrush( new PointF(0, 0), Settings.BackgroundGradient == GradientType.Horizontal ? new PointF(width, 0) : new PointF(0, height), Settings.BackgroundColor, Settings.BackgroundGradient == GradientType.Plain ? Settings.BackgroundColor : Settings.BackgroundColor2); g.FillRectangle(gradientBrush, 0, 0, width, height); } // Set Font. OddsFont = state.LayoutSettings.TextFont; // Calculate Height from Font. var textHeight = g.MeasureString("A", OddsFont).Height; VerticalHeight = 1.2f * textHeight; MinimumHeight = MinimumHeight; PaddingTop = Math.Max(0, ((VerticalHeight - 0.75f * textHeight) / 2f)); PaddingBottom = PaddingTop; // Measure width of max odds float fourCharWidth = g.MeasureString("99.99% / 99.99%", OddsFont).Width; HorizontalWidth = OddsNameLabel.X + OddsNameLabel.ActualWidth + (fourCharWidth > OddsValueLabel.ActualWidth ? fourCharWidth : OddsValueLabel.ActualWidth) + 5; // Set Odds Name Label OddsNameLabel.HorizontalAlignment = mode == LayoutMode.Horizontal ? StringAlignment.Near : StringAlignment.Near; OddsNameLabel.VerticalAlignment = StringAlignment.Center; OddsNameLabel.X = 5; OddsNameLabel.Y = 0; OddsNameLabel.Width = (width - fourCharWidth - 5); OddsNameLabel.Height = height; OddsNameLabel.Font = OddsFont; OddsNameLabel.Brush = new SolidBrush(Settings.OverrideTextColor ? Settings.TextColor : state.LayoutSettings.TextColor); OddsNameLabel.HasShadow = state.LayoutSettings.DropShadows; OddsNameLabel.ShadowColor = state.LayoutSettings.ShadowsColor; OddsNameLabel.Draw(g); // Set Odds Value Label. OddsValueLabel.HorizontalAlignment = mode == LayoutMode.Horizontal ? StringAlignment.Far : StringAlignment.Far; OddsValueLabel.VerticalAlignment = StringAlignment.Center; OddsValueLabel.X = 5; OddsValueLabel.Y = 0; OddsValueLabel.Width = (width - 10); OddsValueLabel.Height = height; OddsValueLabel.Font = OddsFont; OddsValueLabel.Brush = new SolidBrush(Settings.OverrideOddsColor ? Settings.OddsColor : state.LayoutSettings.TextColor); OddsValueLabel.HasShadow = state.LayoutSettings.DropShadows; OddsValueLabel.ShadowColor = state.LayoutSettings.ShadowsColor; OddsValueLabel.Draw(g); }
public void DrawHorizontal(Graphics g, Model.LiveSplitState state, float height, Region clipRegion) { DrawBase(g, state, HorizontalWidth, height, LayoutMode.Horizontal); }
public virtual void DrawHorizontal(System.Drawing.Graphics g, Model.LiveSplitState state, float height, System.Drawing.Region clipRegion) { Reposition(HorizontalWidth, height, g); }
public IComponent Create(Model.LiveSplitState state) { return(new SplitsBetComponent(state)); }
public override void PrepareDraw(Model.LiveSplitState state, LayoutMode mode) { NameMeasureLabel.Font = Settings.OverrideFont1 ? Settings.Font1 : state.LayoutSettings.TextFont; ValueLabel.Font = Settings.OverrideFont2 ? Settings.Font2 : state.LayoutSettings.TextFont; NameLabel.Font = Settings.OverrideFont1 ? Settings.Font1 : state.LayoutSettings.TextFont; }
public IComponent Create(Model.LiveSplitState state) { //cretes a new instance of the component class return(new SpeedRunNotesComponent(state)); }
public virtual void DrawVertical(System.Drawing.Graphics g, Model.LiveSplitState state, float width, System.Drawing.Region clipRegion) { Reposition(width, VerticalHeight, g); }