예제 #1
0
        /// <summary>Show the lookup UI for the current target.</summary>
        /// <param name="lookupMode">The lookup target mode.</param>
        private void ShowLookup(LookupMode lookupMode)
        {
            // disable lookups if metadata is invalid
            if (!this.IsDataValid)
            {
                GameHelper.ShowErrorMessage("The mod doesn't seem to be installed correctly: its data.json file is missing or corrupt.");
                return;
            }

            // show menu
            StringBuilder logMessage = new StringBuilder("Received a lookup request...");

            this.Monitor.InterceptErrors("looking that up", () =>
            {
                try
                {
                    // get target
                    ISubject subject = this.GetSubject(logMessage, lookupMode);
                    if (subject == null)
                    {
                        this.Monitor.Log($"{logMessage} no target found.", LogLevel.Trace);
                        return;
                    }

                    // show lookup UI
                    this.Monitor.Log(logMessage.ToString(), LogLevel.Trace);
                    this.ShowLookupFor(subject);
                }
                catch
                {
                    this.Monitor.Log($"{logMessage} an error occurred.", LogLevel.Trace);
                    throw;
                }
            });
        }
예제 #2
0
        /// <summary>Show the lookup UI for the current target.</summary>
        /// <param name="lookupMode">The lookup target mode.</param>
        private void ShowLookup(LookupMode lookupMode)
        {
            // disable lookups if metadata is invalid
            if (!this.IsDataValid)
            {
                GameHelper.ShowErrorMessage("The mod doesn't seem to be installed correctly: its data.json file is missing or corrupt.");
                return;
            }

            // show menu
            StringBuilder logMessage = new StringBuilder("Received a lookup request...");

            this.Monitor.InterceptErrors("looking that up", () =>
            {
                try
                {
                    // get target
                    ISubject subject = this.GetSubject(logMessage, lookupMode);
                    if (subject == null)
                    {
                        this.Monitor.Log($"{logMessage} no target found.", LogLevel.Trace);
                        return;
                    }

                    // show lookup UI
                    this.Monitor.Log($"{logMessage} showing {subject.GetType().Name}::{subject.Type}::{subject.Name}.", LogLevel.Trace);
                    this.PreviousMenu         = Game1.activeClickableMenu;
                    Game1.activeClickableMenu = new LookupMenu(subject, this.Metadata, this.Monitor, this.Helper.Reflection, this.Config.ScrollAmount, showDebugFields: this.Config.ShowDataMiningFields);
                }
                catch
                {
                    this.Monitor.Log($"{logMessage} an error occurred.", LogLevel.Trace);
                    throw;
                }
            });
        }