diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2020-12-20 22:35:58 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2020-12-20 22:35:58 -0500 |
commit | 77002d3e9965d9afa843a95129c6acb5d1c4a283 (patch) | |
tree | b4f4a338945cd3f2cc5881e46fb0dd2b075a79ce /src/SMAPI/Framework/InternalExtensions.cs | |
parent | 1c70736c00e6e70f46f539cb26b5fd253f4eff3b (diff) | |
parent | 5e2f6f565d6ef5330ea2e8c6a5e796f937289255 (diff) | |
download | SMAPI-77002d3e9965d9afa843a95129c6acb5d1c4a283.tar.gz SMAPI-77002d3e9965d9afa843a95129c6acb5d1c4a283.tar.bz2 SMAPI-77002d3e9965d9afa843a95129c6acb5d1c4a283.zip |
Merge branch 'stardew-valley-1.5' into develop
# Conflicts:
# docs/release-notes.md
Diffstat (limited to 'src/SMAPI/Framework/InternalExtensions.cs')
-rw-r--r-- | src/SMAPI/Framework/InternalExtensions.cs | 18 |
1 files changed, 18 insertions, 0 deletions
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 { @@ -154,6 +156,22 @@ namespace StardewModdingAPI.Framework } /**** + ** IActiveClickableMenu + ****/ + /// <summary>Get a string representation of the menu chain to the given menu (including the specified menu), in parent to child order.</summary> + /// <param name="menu">The menu whose chain to get.</param> + public static string GetMenuChainLabel(this IClickableMenu menu) + { + static IEnumerable<IClickableMenu> 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 ****/ /// <summary>Get whether the sprite batch is between a begin and end pair.</summary> |