From 85cb824c3b96905d4e991946db61802a24e350c9 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 20 Dec 2020 22:34:59 -0500 Subject: update for draw changes That includes child menus, UI draw mode, and UI scaling. --- src/SMAPI/Framework/InternalExtensions.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/SMAPI/Framework/InternalExtensions.cs') diff --git a/src/SMAPI/Framework/InternalExtensions.cs b/src/SMAPI/Framework/InternalExtensions.cs index b6704f26..ba1879da 100644 --- a/src/SMAPI/Framework/InternalExtensions.cs +++ b/src/SMAPI/Framework/InternalExtensions.cs @@ -1,11 +1,13 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Reflection; using System.Threading; using Microsoft.Xna.Framework.Graphics; using StardewModdingAPI.Framework.Events; using StardewModdingAPI.Framework.Reflection; using StardewValley; +using StardewValley.Menus; namespace StardewModdingAPI.Framework { @@ -153,6 +155,22 @@ namespace StardewModdingAPI.Framework } } + /**** + ** IActiveClickableMenu + ****/ + /// Get a string representation of the menu chain to the given menu (including the specified menu), in parent to child order. + /// The menu whose chain to get. + public static string GetMenuChainLabel(this IClickableMenu menu) + { + static IEnumerable GetAncestors(IClickableMenu menu) + { + for (; menu != null; menu = menu.GetParentMenu()) + yield return menu; + } + + return string.Join(" > ", GetAncestors(menu).Reverse().Select(p => p.GetType().FullName)); + } + /**** ** Sprite batch ****/ -- cgit