/********* ** Private methods *********/ /**** ** Event handlers ****/ /// <summary>The method invoked when the player loads the game.</summary> private void ReceiveGameLoaded() { // check for an updated version if (this.Config.CheckForUpdates) { Task.Factory.StartNew(() => { GameHelper.InterceptErrors("checking for a newer version", () => { using (ICumulativeLog log = this.GetTaskLog()) { log.Append("Lookup Anything checking for update... "); GitRelease release = UpdateHelper.GetLatestReleaseAsync("Pathoschild/LookupAnything").Result; if (release.IsNewerThan(this.CurrentVersion)) { log.AppendLine($"update to version {release.Name} available."); this.NewRelease = release; } else { log.AppendLine("no update available."); } } }); }); } }
/// <summary>Show the lookup UI for the current target.</summary> private void ShowLookup() { GameHelper.InterceptErrors("looking that up", () => { using (ICumulativeLog log = this.GetTaskLog()) { log.Append("Lookup Anything received a lookup request. "); // validate version string versionError = GameHelper.ValidateGameVersion(); if (versionError != null) { GameHelper.ShowErrorMessage(versionError); Log.Error(versionError); return; } // get target ISubject subject = null; if (Game1.activeClickableMenu != null) { log.Append($"Searching the open '{Game1.activeClickableMenu.GetType().Name}' menu... "); subject = this.TargetFactory.GetSubjectFrom(Game1.activeClickableMenu, GameHelper.GetScreenCoordinatesFromCursor()); } else { log.Append("Searching the world... "); subject = this.TargetFactory.GetSubjectFrom(Game1.currentLocation, Game1.currentCursorTile, GameHelper.GetScreenCoordinatesFromCursor()); } if (subject == null) { log.AppendLine("no target found."); return; } // show lookup UI log.AppendLine($"showing {subject.GetType().Name}::{subject.Type}::{subject.Name}."); this.PreviousMenu = Game1.activeClickableMenu; Game1.activeClickableMenu = new LookupMenu(subject, this.Metadata); } }); }