private void TryConnect(LiveSplit.UI.Components.LiveSplitState state) { _game = null; var state_process = _states.Keys.Select(proccessName => new { // default to the state with no version specified, if it exists State = _states[proccessName].FirstOrDefault(s => s.GameVersion == "") ?? _states[proccessName].First(), Process = Process.GetProcessesByName(proccessName).OrderByDescending(x => x.StartTime) .FirstOrDefault(x => !x.HasExited) }).FirstOrDefault(x => x.Process != null); if (state_process == null) { return; } _init_completed = false; _game = state_process.Process; State = state_process.State; if (State.GameVersion == "") { Debug("Connected to game: {0} (using default state descriptor)", _game.ProcessName); } else { Debug("Connected to game: {0} (state descriptor for version '{1}' chosen as default)", _game.ProcessName, State.GameVersion); } DoInit(state); }
// Update the script public void Update(LiveSplit.UI.Components.LiveSplitState state) { if (_game == null) { if (_timer == null) { _timer = new TimerModel() { CurrentState = state } } ; TryConnect(state); } else if (_game.HasExited) { DoExit(state); } else { if (!_init_completed) { DoInit(state); } else { DoUpdate(state); } } }
// Run method without counting on being connected to the game (startup/shutdown). private void RunNoProcessMethod(ASLMethod method, LiveSplit.UI.Components.LiveSplitState state, bool is_startup = false) { var refresh_rate = RefreshRate; var version = GameVersion; method.Call(state, Vars, ref version, ref refresh_rate, is_startup ? _settings.Builder : (object)_settings.Reader); RefreshRate = refresh_rate; }
private dynamic RunMethod(ASLMethod method, LiveSplit.UI.Components.LiveSplitState state, ref string version) { var refresh_rate = RefreshRate; var result = method.Call(state, Vars, ref version, ref refresh_rate, _settings.Reader, OldState?.Data, State?.Data, _game); RefreshRate = refresh_rate; return(result); }
// This is executed repeatedly as long as the game is connected and initialized. private void DoUpdate(LiveSplit.UI.Components.LiveSplitState state) { OldState = State.RefreshValues(_game); if (!(RunMethod(_methods.update, state) ?? true)) { // If Update explicitly returns false, don't run anything else return; } if (state.CurrentPhase == TimerPhase.Running || state.CurrentPhase == TimerPhase.Paused) { if (_uses_game_time && !state.IsGameTimeInitialized) { _timer.InitializeGameTime(); } var is_paused = RunMethod(_methods.isLoading, state); if (is_paused != null) { state.IsGameTimePaused = is_paused; } var game_time = RunMethod(_methods.gameTime, state); if (game_time != null) { state.SetGameTime(game_time); } if (RunMethod(_methods.reset, state) ?? false) { if (_settings.GetBasicSettingValue("reset")) { _timer.Reset(); } } else if (RunMethod(_methods.split, state) ?? false) { if (_settings.GetBasicSettingValue("split")) { _timer.Split(); } } } if (state.CurrentPhase == TimerPhase.NotRunning) { if (RunMethod(_methods.start, state) ?? false) { if (_settings.GetBasicSettingValue("start")) { _timer.Start(); } } } }
// This is executed each time after connecting to the game (usually just once, // unless an error occurs before the method finishes). private void DoInit(LiveSplit.UI.Components.LiveSplitState state) { Debug("Initializing"); State.RefreshValues(_game); OldState = State; GameVersion = string.Empty; // Fetch version from init-method var ver = string.Empty; RunMethod(_methods.init, state, ref ver); if (ver != GameVersion) { GameVersion = ver; var version_state = _states.Where(kv => kv.Key.ToLower() == _game.ProcessName.ToLower()) .Select(kv => kv.Value) .First() // states .FirstOrDefault(s => s.GameVersion == ver); if (version_state != null) { // This state descriptor may already be selected if (version_state != State) { State = version_state; State.RefreshValues(_game); OldState = State; Debug($"Switched to state descriptor for version '{GameVersion}'"); } } else { Debug($"No state descriptor for version '{GameVersion}' (will keep using default one)"); } } _init_completed = true; Debug("Init completed, running main methods"); }
public void DrawVertical(Graphics g, LiveSplitState state, float width, Region clipRegion) { DrawGeneral(g, state, width, VerticalHeight); }
public void DrawHorizontal(Graphics graphics, LiveSplitState state, float height, Region clipRegion) { VerticalHeight = height; HorizontalWidth = 3; }
public USB2SNESComponent(LiveSplitState state) { Init(state, new USB2SnesW.USB2SnesW()); }
public void DrawHorizontal(Graphics g, LiveSplitState state, float height, Region clipRegion) { }
public void DrawVertical(Graphics g, LiveSplitState state, float width, Region clipRegion) { DrawBackground(g, state, width, VerticalHeight); PrepareDraw(state, LayoutMode.Vertical); InternalComponent.DrawVertical(g, state, width, clipRegion); }
public void DrawHorizontal(System.Drawing.Graphics g, LiveSplitState state, float height, Region clipRegion) { InternalComponent.DrawHorizontal(g, state, height, clipRegion); }
public IComponent Create(LiveSplitState state) => new SplitsComponent(state);
public IComponent Create(LiveSplitState state) => new RunPrediction(state);
public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { if (state.Run != previousRun) { sectionList.UpdateSplits(state.Run); previousRun = state.Run; } var runningSectionIndex = Math.Min(Math.Max(state.CurrentSplitIndex, 0), state.Run.Count - 1); ScrollOffset = Math.Min(Math.Max(ScrollOffset, -runningSectionIndex), state.Run.Count - runningSectionIndex - 1); var currentSplit = ScrollOffset + runningSectionIndex; var currentSection = sectionList.getSection(currentSplit); runningSectionIndex = sectionList.getSection(runningSectionIndex); if (sectionList.Sections[currentSection].getSubsplitCount() > 0) { lastSplitOfSection = sectionList.Sections[currentSection].endIndex; } else { lastSplitOfSection = -1; } if (Settings.HideSubsplits) { if (ScrollOffset != 0) { currentSplit = sectionList.getMajorSplit(currentSplit); SplitsSettings.HilightSplit = state.Run[currentSplit]; } else { SplitsSettings.HilightSplit = null; } SplitsSettings.SectionSplit = state.Run[sectionList.Sections[runningSectionIndex].endIndex]; } else { if (ScrollOffset != 0) { SplitsSettings.HilightSplit = state.Run[currentSplit]; } else { SplitsSettings.HilightSplit = null; } if (currentSection == runningSectionIndex) { SplitsSettings.SectionSplit = null; } else { SplitsSettings.SectionSplit = state.Run[sectionList.Sections[runningSectionIndex].endIndex]; } } bool addLast = (Settings.AlwaysShowLastSplit || currentSplit == state.Run.Count() - 1); bool addHeader = (Settings.ShowHeader && (sectionList.Sections[currentSection].getSubsplitCount() > 0)); int freeSplits = visualSplitCount - (addLast ? 1 : 0) - (addHeader ? 1 : 0); int topSplit = currentSplit - 1; int bottomSplit = currentSplit + 1; var majorSplitsToAdd = (!Settings.ShowSubsplits && !Settings.HideSubsplits) ? Math.Min(currentSection, Settings.MinimumMajorSplits) : 0; List <int> visibleSplits = new List <int>(); if ((currentSplit < state.Run.Count() - 1) && (freeSplits > 0) && (!Settings.HideSubsplits || sectionList.isMajorSplit(currentSplit))) { visibleSplits.Add(currentSplit); freeSplits--; } int previewCount = 0; while ((previewCount < Settings.SplitPreviewCount) && (bottomSplit < state.Run.Count() - (addLast ? 1 : 0)) && (freeSplits > majorSplitsToAdd)) { if (ShouldIncludeSplit(currentSection, bottomSplit)) { if (bottomSplit == state.Run.Count - 1) { addLast = true; } else { visibleSplits.Add(bottomSplit); previewCount++; } freeSplits--; } bottomSplit++; } while ((topSplit >= 0) && (freeSplits > 0)) { var isMajor = sectionList.isMajorSplit(topSplit); if (ShouldIncludeSplit(currentSection, topSplit) && (freeSplits > majorSplitsToAdd || sectionList.isMajorSplit(topSplit))) { visibleSplits.Insert(0, topSplit); freeSplits--; if (isMajor) { majorSplitsToAdd--; } } topSplit--; } while ((bottomSplit < state.Run.Count() - (addLast ? 1 : 0)) && (freeSplits > 0)) { if (ShouldIncludeSplit(currentSection, bottomSplit)) { if (bottomSplit == state.Run.Count - 1) { addLast = true; } else { visibleSplits.Add(bottomSplit); } freeSplits--; } bottomSplit++; } foreach (var component in Components) { if (component is SeparatorComponent) { var separator = (SeparatorComponent)component; var index = Components.IndexOf(separator); if (Settings.AlwaysShowLastSplit && Settings.SeparatorLastSplit && index == LastSplitSeparatorIndex) { int lastIndex = state.Run.Count() - 1; if (freeSplits > 0 || visibleSplits.Any() && (visibleSplits.Last() == lastIndex - 1)) { if (Settings.ShowThinSeparators) { separator.DisplayedSize = 1f; } else { separator.DisplayedSize = 0f; } separator.UseSeparatorColor = false; } else { int prevSection = sectionList.getSection(lastIndex) - 1; if (visibleSplits.Any() && (prevSection <= 0 || visibleSplits.Last() == sectionList.Sections[prevSection].endIndex)) { if (Settings.ShowThinSeparators) { separator.DisplayedSize = 1f; } else { separator.DisplayedSize = 0f; } separator.UseSeparatorColor = false; } else { separator.DisplayedSize = 2f; separator.UseSeparatorColor = true; } } } } } if (!Settings.LockLastSplit && addLast) { visibleSplits.Add(state.Run.Count() - 1); } for (; freeSplits > 0; freeSplits--) { visibleSplits.Add(int.MinValue); } if (Settings.LockLastSplit && addLast) { visibleSplits.Add(state.Run.Count() - 1); } if (addHeader) { int insertIndex = 0; if (currentSection > 0) { insertIndex = visibleSplits.IndexOf(sectionList.Sections[currentSection - 1].endIndex) + 1; } visibleSplits.Insert(insertIndex, -(currentSection + 1)); } int i = 0; foreach (int split in visibleSplits) { if (i < SplitComponents.Count) { SplitComponents[i].ForceIndent = !Settings.ShowSubsplits && !Settings.HideSubsplits && Settings.IndentSectionSplit && split == lastSplitOfSection; if (split == int.MinValue) { SplitComponents[i].Header = false; SplitComponents[i].CollapsedSplit = false; SplitComponents[i].Split = null; SplitComponents[i].oddSplit = true; } else if (split < 0) { SplitComponents[i].Header = true; SplitComponents[i].CollapsedSplit = false; SplitComponents[i].TopSplit = sectionList.Sections[-split - 1].startIndex; SplitComponents[i].Split = state.Run[sectionList.Sections[-split - 1].endIndex]; SplitComponents[i].oddSplit = ((((-split - 1) + (Settings.ShowColumnLabels ? 1 : 0)) % 2) == 0); } else { SplitComponents[i].Header = false; SplitComponents[i].Split = state.Run[split]; SplitComponents[i].oddSplit = (((sectionList.getSection(split) + (Settings.ShowColumnLabels ? 1 : 0)) % 2) == 0); if ((Settings.HideSubsplits || sectionList.getSection(split) != currentSection) && sectionList.Sections[sectionList.getSection(split)].getSubsplitCount() > 0 && !Settings.ShowSubsplits) { SplitComponents[i].CollapsedSplit = true; SplitComponents[i].TopSplit = sectionList.Sections[sectionList.getSection(split)].startIndex; } else { SplitComponents[i].CollapsedSplit = false; } } } i++; } if (invalidator != null) { InternalComponent.Update(invalidator, state, width, height, mode); } }
public virtual void DrawVertical(Graphics g, LiveSplitState state, float width, Region clipRegion) { Reposition(width, VerticalHeight, g); }
public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { if (Game == null || Game.HasExited) { Game = null; var process = Process.GetProcessesByName("SuperMeatBoy").FirstOrDefault(); if (process != null) { Game = process; } OldTitleScreenShowing = false; } if (Model == null) { Model = new TimerModel() { CurrentState = state }; state.OnStart += state_OnStart; } if (Game != null) { float time; TimeSpan levelTime = OldLevelTime ?? TimeSpan.Zero; bool isInALevel; IsInALevel.Deref <bool>(Game, out isInALevel); if (isInALevel) { try { LevelTimer.Deref <float>(Game, out time); levelTime = TimeSpan.FromSeconds(time); } catch { } } //AliveTimer.Deref<float>(Game, out time); //var aliveTime = TimeSpan.FromSeconds(time); //int deathCounter; //DeathCounter.Deref<int>(Game, out deathCounter); int levelID; LevelID.Deref <int>(Game, out levelID); int chapterID; ChapterID.Deref <int>(Game, out chapterID); int levelType; LevelType.Deref <int>(Game, out levelType); int chapterSelectID; ChapterSelectID.Deref <int>(Game, out chapterSelectID); bool creditsPlaying; CreditsPlaying.Deref <bool>(Game, out creditsPlaying); bool isAtLevelSelect; IsAtLevelSelect.Deref <bool>(Game, out isAtLevelSelect); bool isNotAtLevelEnd; IsNotAtLevelEnd.Deref <bool>(Game, out isNotAtLevelEnd); if (!WasAtLevelEnd && !isNotAtLevelEnd) { WasAtLevelEnd = true; FinishedLevelTime = levelTime; } bool titleScreenShowing; bool couldFetch = TitleScreenShowing.Deref <bool>(Game, out titleScreenShowing); if (!couldFetch) { titleScreenShowing = true; } //bool isTimeRunning = OldLevelTime != levelTime; if (OldLevelTime != null)// && OldLevelTime != null) { if (state.CurrentPhase == TimerPhase.NotRunning && !titleScreenShowing && OldTitleScreenShowing) { Model.Start(); } else if (state.CurrentPhase == TimerPhase.Running) { if (chapterID == 6 && levelID == 99) { if (creditsPlaying && !OldCreditsPlaying) { Model.Split(); //The End } } else { if ((levelType != 0 && levelType != 10) || chapterID == 7) { if (((levelType <= 1) ? (levelID == 20) : true) && !isInALevel && (levelID == 20 && state.CurrentSplitIndex == state.Run.Count - 1 ? WasInALevel //Split earlier for Cotton Alley if it's the last split : (!isAtLevelSelect && WasAtLevelSelect))) { Model.Split(); //Dark World or Cotton Alley } } else if (!creditsPlaying && OldCreditsPlaying) { Model.Split(); //Chapter Splits } } if (titleScreenShowing && !creditsPlaying) { Model.Reset(); } } if (OldLevelTime > levelTime) { //OldDeathCounter = deathCounter; GameTime += (WasAtLevelEnd ? FinishedLevelTime : OldLevelTime ?? TimeSpan.Zero); WasAtLevelEnd = false; } } #if GAME_TIME state.IsLoading = true; var currentGameTime = GameTime + (WasAtLevelEnd ? FinishedLevelTime : levelTime); state.SetGameTime(currentGameTime < TimeSpan.Zero ? TimeSpan.Zero : currentGameTime); #endif //WasTimeRunning = isTimeRunning; //OldLevelTime = levelTime; OldLevelTime = levelTime; OldLevelID = levelID; OldChapterSelectID = chapterSelectID; OldCreditsPlaying = creditsPlaying; WasAtLevelSelect = isAtLevelSelect; WasInALevel = isInALevel; OldTitleScreenShowing = titleScreenShowing; } }
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); } }
public void DrawVertical(System.Drawing.Graphics g, LiveSplitState state, float width, Region clipRegion) { InternalComponent.DrawVertical(g, state, width, clipRegion); }
public static void DrawBackground(Graphics g, LiveSplitState state, Color timerColor, Color settingsColor1, Color settingsColor2, float width, float height, DeltasGradientType gradientType, Color tickColor1, Color tickColor2, String timeMethod) { var background1 = settingsColor1; var background2 = settingsColor2; RectangleF[] clockData = new RectangleF[24]; var tickColor = tickColor1; var backgroundTickColor = tickColor2; // Width / by 6 // Height / by 4m // 1 px around all for (int x = 0; x < 6; x++) { for (int y = 0; y < 4; y++) { clockData[(x * 4) + y] = new RectangleF { Y = 1 + (((height / 4f) - 0f) * y), X = 1 + (((width / 6f) - 0f) * x), Width = ((width / 6f) - 2f), Height = (height / 4f) - 2f }; } } var test = numCalculator(state, timeMethod); var tickBrush = new SolidBrush(tickColor); var backgroundTickBrush = new SolidBrush(backgroundTickColor); g.FillRectangles(backgroundTickBrush, clockData); foreach (int i in test) { g.FillRectangle(tickBrush, clockData[i]); } if (gradientType == DeltasGradientType.PlainWithDeltaColor || gradientType == DeltasGradientType.HorizontalWithDeltaColor || gradientType == DeltasGradientType.VerticalWithDeltaColor) { double h, s, v; timerColor.ToHSV(out h, out s, out v); var newColor = ColorExtensions.FromHSV(h, s * 0.5, v * 0.25); if (gradientType == DeltasGradientType.PlainWithDeltaColor) { background1 = Color.FromArgb(timerColor.A * 7 / 12, newColor); } else { background1 = Color.FromArgb(timerColor.A / 6, newColor); background2 = Color.FromArgb(timerColor.A, newColor); } } if (background1.A > 0 || gradientType != DeltasGradientType.Plain && background2.A > 0) { var gradientBrush = new LinearGradientBrush( new PointF(0, 0), gradientType == DeltasGradientType.Horizontal || gradientType == DeltasGradientType.HorizontalWithDeltaColor ? new PointF(width, 0) : new PointF(0, height), background1, gradientType == DeltasGradientType.Plain || gradientType == DeltasGradientType.PlainWithDeltaColor ? background1 : background2); g.FillRectangle(gradientBrush, 0, 0, width, height); //g.FillRectangles(Brushes.Green, clockData); } }
public void DrawHorizontal(Graphics g, LiveSplitState state, float height, Region clipRegion) { DrawBackground(g, state, HorizontalWidth, height); PrepareDraw(state, LayoutMode.Horizontal); InternalComponent.DrawHorizontal(g, state, height, clipRegion); }
private static List <int> numCalculator(LiveSplitState state, String timeMethod) { var timingMethod = state.CurrentTimingMethod; if (timeMethod == "Real Time") { timingMethod = TimingMethod.RealTime; } else if (timeMethod == "Game Time") { timingMethod = TimingMethod.GameTime; } var timeValue = state.CurrentTime[timingMethod]; if (timeValue == null && timingMethod == TimingMethod.GameTime) { timeValue = state.CurrentTime[TimingMethod.RealTime]; } var mill = Math.Abs(timeValue.Value.Milliseconds); var seconds = timeValue.Value.Seconds; var mins = timeValue.Value.Minutes; var hour = timeValue.Value.Hours; int printMil; // Just be extra super careful here if (mill <= 99) { printMil = 0; } else if (mill > 900) { printMil = 9; } else { printMil = mill / 100; } int printSecond = Math.Abs(seconds) % 10; int printTenSeconds = (seconds < 10) ? 0 : Math.Abs(seconds); while (printTenSeconds >= 10) { printTenSeconds /= 10; } int printMins = Math.Abs(mins) % 10; int printTenMins = (mins < 10) ? 0 : Math.Abs(mins); while (printTenMins >= 10) { printTenMins /= 10; } int printHour = Math.Abs(hour) % 10; var finalToShow = new List <int>(); finalToShow.AddRange(switchCheck(printMil, 20)); // Add 20 finalToShow.AddRange(switchCheck(printSecond, 16)); // Add 16 finalToShow.AddRange(switchCheck(printTenSeconds, 12)); // Add 12 finalToShow.AddRange(switchCheck(printMins, 8)); // Add 8 finalToShow.AddRange(switchCheck(printTenMins, 4)); // Add 4 finalToShow.AddRange(switchCheck(printHour, 0)); return(finalToShow); }
public void DrawVertical(Graphics g, LiveSplitState state, float width, Region clipRegion) { }
public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { Cache.Restart(); var timingMethod = state.CurrentTimingMethod; if (Settings.TimingMethod == "Real Time") { timingMethod = TimingMethod.RealTime; } else if (Settings.TimingMethod == "Game Time") { timingMethod = TimingMethod.GameTime; } var timeValue = GetTime(state, timingMethod); if (timeValue == null && timingMethod == TimingMethod.GameTime) { timeValue = GetTime(state, TimingMethod.RealTime); } if (timeValue != null) { var timeString = Formatter.Format(timeValue, CurrentTimeFormat); int dotIndex = timeString.IndexOf("."); BigTextLabel.Text = timeString.Substring(0, dotIndex); if (CurrentAccuracy == TimeAccuracy.Hundredths) { SmallTextLabel.Text = timeString.Substring(dotIndex); } else if (CurrentAccuracy == TimeAccuracy.Tenths) { SmallTextLabel.Text = timeString.Substring(dotIndex, 2); } else { SmallTextLabel.Text = ""; } } else { SmallTextLabel.Text = TimeFormatConstants.DASH; BigTextLabel.Text = ""; } if (state.CurrentPhase == TimerPhase.NotRunning || state.CurrentTime[timingMethod] < TimeSpan.Zero) { TimerColor = state.LayoutSettings.NotRunningColor; } else if (state.CurrentPhase == TimerPhase.Paused) { TimerColor = state.LayoutSettings.PausedColor; } else if (state.CurrentPhase == TimerPhase.Ended) { if (state.Run.Last().Comparisons[state.CurrentComparison][timingMethod] == null || state.CurrentTime[timingMethod] < state.Run.Last().Comparisons[state.CurrentComparison][timingMethod]) { TimerColor = state.LayoutSettings.PersonalBestColor; } else { TimerColor = state.LayoutSettings.BehindLosingTimeColor; } } else if (state.CurrentPhase == TimerPhase.Running) { if (state.CurrentSplit.Comparisons[state.CurrentComparison][timingMethod] != null) { TimerColor = LiveSplitStateHelper.GetSplitColor(state, state.CurrentTime[timingMethod] - state.CurrentSplit.Comparisons[state.CurrentComparison][timingMethod], state.CurrentSplitIndex, true, false, state.CurrentComparison, timingMethod) ?? state.LayoutSettings.AheadGainingTimeColor; } else { TimerColor = state.LayoutSettings.AheadGainingTimeColor; } } if (Settings.OverrideSplitColors) { BigTextLabel.ForeColor = Settings.TimerColor; SmallTextLabel.ForeColor = Settings.TimerColor; } else { BigTextLabel.ForeColor = TimerColor; SmallTextLabel.ForeColor = TimerColor; } Cache["TimerText"] = BigTextLabel.Text + SmallTextLabel.Text; if (BigTextLabel.Brush != null && invalidator != null) { Cache["TimerColor"] = BigTextLabel.ForeColor.ToArgb(); } if (invalidator != null && Cache.HasChanged) { invalidator.Invalidate(0, 0, width, height); } }
internal USB2SNESComponent(LiveSplitState state, USB2SnesW.USB2SnesW usb2snesw) { Init(state, usb2snesw); }
public SplitsSettings(LiveSplitState state) { InitializeComponent(); CurrentState = state; StartingSize = Size; StartingTableLayoutSize = tableColumns.Size; VisualSplitCount = 8; SplitPreviewCount = 1; DisplayIcons = true; IconShadows = true; ShowThinSeparators = true; AlwaysShowLastSplit = true; ShowBlankSplits = true; LockLastSplit = true; SeparatorLastSplit = true; SplitTimesAccuracy = TimeAccuracy.Seconds; CurrentSplitTopColor = Color.FromArgb(51, 115, 244); CurrentSplitBottomColor = Color.FromArgb(21, 53, 116); SplitWidth = 20; SplitHeight = 3.6f; IconSize = 24f; AutomaticAbbreviations = false; BeforeNamesColor = Color.FromArgb(255, 255, 255); CurrentNamesColor = Color.FromArgb(255, 255, 255); AfterNamesColor = Color.FromArgb(255, 255, 255); OverrideTextColor = false; BeforeTimesColor = Color.FromArgb(255, 255, 255); CurrentTimesColor = Color.FromArgb(255, 255, 255); AfterTimesColor = Color.FromArgb(255, 255, 255); OverrideTimesColor = false; CurrentSplitGradient = GradientType.Vertical; cmbSplitGradient.SelectedIndexChanged += cmbSplitGradient_SelectedIndexChanged; BackgroundColor = Color.Transparent; BackgroundColor2 = Color.FromArgb(1, 255, 255, 255); BackgroundGradient = ExtendedGradientType.Alternating; DropDecimals = true; DeltasAccuracy = TimeAccuracy.Tenths; OverrideDeltasColor = false; DeltasColor = Color.FromArgb(255, 255, 255); Display2Rows = false; ShowColumnLabels = false; LabelsColor = Color.FromArgb(255, 255, 255); dmnTotalSegments.DataBindings.Add("Value", this, "VisualSplitCount", false, DataSourceUpdateMode.OnPropertyChanged); dmnUpcomingSegments.DataBindings.Add("Value", this, "SplitPreviewCount", false, DataSourceUpdateMode.OnPropertyChanged); btnTopColor.DataBindings.Add("BackColor", this, "CurrentSplitTopColor", false, DataSourceUpdateMode.OnPropertyChanged); btnBottomColor.DataBindings.Add("BackColor", this, "CurrentSplitBottomColor", false, DataSourceUpdateMode.OnPropertyChanged); chkAutomaticAbbreviations.DataBindings.Add("Checked", this, "AutomaticAbbreviations", false, DataSourceUpdateMode.OnPropertyChanged); btnBeforeNamesColor.DataBindings.Add("BackColor", this, "BeforeNamesColor", false, DataSourceUpdateMode.OnPropertyChanged); btnCurrentNamesColor.DataBindings.Add("BackColor", this, "CurrentNamesColor", false, DataSourceUpdateMode.OnPropertyChanged); btnAfterNamesColor.DataBindings.Add("BackColor", this, "AfterNamesColor", false, DataSourceUpdateMode.OnPropertyChanged); btnBeforeTimesColor.DataBindings.Add("BackColor", this, "BeforeTimesColor", false, DataSourceUpdateMode.OnPropertyChanged); btnCurrentTimesColor.DataBindings.Add("BackColor", this, "CurrentTimesColor", false, DataSourceUpdateMode.OnPropertyChanged); btnAfterTimesColor.DataBindings.Add("BackColor", this, "AfterTimesColor", false, DataSourceUpdateMode.OnPropertyChanged); chkDisplayIcons.DataBindings.Add("Checked", this, "DisplayIcons", false, DataSourceUpdateMode.OnPropertyChanged); chkIconShadows.DataBindings.Add("Checked", this, "IconShadows", false, DataSourceUpdateMode.OnPropertyChanged); chkThinSeparators.DataBindings.Add("Checked", this, "ShowThinSeparators", false, DataSourceUpdateMode.OnPropertyChanged); chkLastSplit.DataBindings.Add("Checked", this, "AlwaysShowLastSplit", false, DataSourceUpdateMode.OnPropertyChanged); chkOverrideTextColor.DataBindings.Add("Checked", this, "OverrideTextColor", false, DataSourceUpdateMode.OnPropertyChanged); chkOverrideTimesColor.DataBindings.Add("Checked", this, "OverrideTimesColor", false, DataSourceUpdateMode.OnPropertyChanged); chkShowBlankSplits.DataBindings.Add("Checked", this, "ShowBlankSplits", false, DataSourceUpdateMode.OnPropertyChanged); chkLockLastSplit.DataBindings.Add("Checked", this, "LockLastSplit", false, DataSourceUpdateMode.OnPropertyChanged); chkSeparatorLastSplit.DataBindings.Add("Checked", this, "SeparatorLastSplit", false, DataSourceUpdateMode.OnPropertyChanged); chkDropDecimals.DataBindings.Add("Checked", this, "DropDecimals", false, DataSourceUpdateMode.OnPropertyChanged); chkOverrideDeltaColor.DataBindings.Add("Checked", this, "OverrideDeltasColor", false, DataSourceUpdateMode.OnPropertyChanged); btnDeltaColor.DataBindings.Add("BackColor", this, "DeltasColor", false, DataSourceUpdateMode.OnPropertyChanged); btnLabelColor.DataBindings.Add("BackColor", this, "LabelsColor", false, DataSourceUpdateMode.OnPropertyChanged); trkIconSize.DataBindings.Add("Value", this, "IconSize", false, DataSourceUpdateMode.OnPropertyChanged); cmbSplitGradient.DataBindings.Add("SelectedItem", this, "SplitGradientString", false, DataSourceUpdateMode.OnPropertyChanged); cmbGradientType.DataBindings.Add("SelectedItem", this, "GradientString", false, DataSourceUpdateMode.OnPropertyChanged); btnColor1.DataBindings.Add("BackColor", this, "BackgroundColor", false, DataSourceUpdateMode.OnPropertyChanged); btnColor2.DataBindings.Add("BackColor", this, "BackgroundColor2", false, DataSourceUpdateMode.OnPropertyChanged); ColumnsList = new List <ColumnSettings>(); ColumnsList.Add(new ColumnSettings(CurrentState, "+/-", ColumnsList) { Data = new ColumnData("+/-", ColumnType.Delta, "Current Comparison", "Current Timing Method") }); ColumnsList.Add(new ColumnSettings(CurrentState, "Time", ColumnsList) { Data = new ColumnData("Time", ColumnType.SplitTime, "Current Comparison", "Current Timing Method") }); }
private void AddGraphNode(Graphics g, LiveSplitState state, string comparison, Pen pen, List <PointF> circleList, float heightOne, float heightTwo, float widthOne, float widthTwo, int y) { circleList.Add(new PointF(widthTwo, heightTwo)); }
public override void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { }
public void DrawHorizontal(Graphics g, LiveSplitState state, float height, Region clipRegion) { DrawGeneral(g, state, HorizontalWidth, height); }
public virtual void DrawHorizontal(Graphics g, LiveSplitState state, float height, Region clipRegion) { Reposition(HorizontalWidth, height, g); }