diff --git a/MiraAPI/Hud/CustomMultiSelectMenu.cs b/MiraAPI/Hud/CustomMultiSelectMenu.cs index d54afa3..50e2ff5 100644 --- a/MiraAPI/Hud/CustomMultiSelectMenu.cs +++ b/MiraAPI/Hud/CustomMultiSelectMenu.cs @@ -70,9 +70,10 @@ public abstract class CustomMultiSelectMenu : CustomPhoneMenu(); button.OnClick.RemoveAllListeners(); - button.OnClick.AddListener((UnityAction)customMenu.OnCompleteSelection); + button.OnClick.AddListener((UnityAction)customMenu.OnCompleteSelection);*/ customMenu.activeColor = activeColor; diff --git a/MiraAPI/Hud/CustomPhoneMenu.cs b/MiraAPI/Hud/CustomPhoneMenu.cs index f8af46c..85bfd14 100644 --- a/MiraAPI/Hud/CustomPhoneMenu.cs +++ b/MiraAPI/Hud/CustomPhoneMenu.cs @@ -172,6 +172,14 @@ public abstract class CustomPhoneMenu : ICustomMenu Component.Close(); } + /// + /// Forcibly closes the menu. + /// + public void ForceClose() + { + Component.ForceClose(); + } + /// /// Creates a . /// diff --git a/MiraAPI/Hud/CustomPlayerMenu.cs b/MiraAPI/Hud/CustomPlayerMenu.cs index a0b57a2..26c3b94 100644 --- a/MiraAPI/Hud/CustomPlayerMenu.cs +++ b/MiraAPI/Hud/CustomPlayerMenu.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; +using MiraAPI.Utilities.Assets; using UnityEngine; namespace MiraAPI.Hud; @@ -28,6 +29,36 @@ public class CustomPlayerMenu : CustomMultiSelectMenu return Create(); } + /// + /// Creates a . + /// + /// New object. + /// The to use when an entry is selected but not hovered over. + /// The to use when an entry is hovered over while not selected. + /// The to use when an entry is hovered over while not selected. + /// The to use when an entry is hovered over while selected. + /// The to use when an entry is hovered over while selected. + /// Function that can optionally be run when the mouse is moved outside a menu panel. + /// Function that can optionally be run when the mouse is moved over a menu panel. + public static CustomPlayerMenu Create( + Color? activeColor, + LoadableAsset? hoverSelectSprite = null, + Color? hoverSelectColor = null, + LoadableAsset? hoverDeselectSprite = null, + Color? hoverDeselectColor = null, + PanelButtonOnMouse? onMouseOut = null, + PanelButtonOnMouse? onMouseOver = null) + { + return Create( + activeColor, + hoverSelectSprite, + hoverSelectColor, + hoverDeselectSprite, + hoverDeselectColor, + onMouseOut, + onMouseOver); + } + /// /// Begins/opens the custom player menu. /// diff --git a/MiraAPI/Patches/Options/NotificationPopperPatch.cs b/MiraAPI/Patches/Options/NotificationPopperPatch.cs index 18c7796..f0b472e 100644 --- a/MiraAPI/Patches/Options/NotificationPopperPatch.cs +++ b/MiraAPI/Patches/Options/NotificationPopperPatch.cs @@ -30,7 +30,7 @@ public static class NotificationPopperPatch icon, "", textColor, - TranslationController.Instance.GetString(key), + customRole.RoleName, ""), "" + roleCount + "", "" + roleChance + "%"); diff --git a/MiraAPI/Roles/ICustomRole.cs b/MiraAPI/Roles/ICustomRole.cs index e7e34c6..403b414 100644 --- a/MiraAPI/Roles/ICustomRole.cs +++ b/MiraAPI/Roles/ICustomRole.cs @@ -48,7 +48,7 @@ public interface ICustomRole : IOptionable /// /// Gets the medium description of the role. Used in the role guide and options menu. /// - string RoleMedDescription => MiraLocaleManager.Get(RoleMedDescriptionLocale); + string RoleMedDescription => MiraLocaleManager.Get(RoleMedDescriptionLocale, RoleLongDescription); /// /// Gets the role's medium description id for localization. diff --git a/MiraAPI/Utilities/Assets/TmpSpriteUtils.cs b/MiraAPI/Utilities/Assets/TmpSpriteUtils.cs index 435e250..542bc0b 100644 --- a/MiraAPI/Utilities/Assets/TmpSpriteUtils.cs +++ b/MiraAPI/Utilities/Assets/TmpSpriteUtils.cs @@ -56,6 +56,10 @@ public static class TmpSpriteUtils spriteAsset.name = assetName; spriteAsset.spriteSheet = sourceTexture; + var spriteAssetMasked = ScriptableObject.CreateInstance(); + spriteAssetMasked.name = assetName + ".Masked"; + spriteAssetMasked.spriteSheet = sourceTexture; + if (!_spriteShader) { // ReSharper disable once ShaderLabShaderReferenceNotResolved (Justification: Unnecessary.) @@ -67,10 +71,6 @@ public static class TmpSpriteUtils name = assetName + " Material", }; material.SetTexture(ShaderUtilities.ID_MainTex, sourceTexture); - - // TODO: Using these values, the icons will NOT clip through chat boxes. However, this breaks quite literally every other tmp text that isn't masked. Please fix this if a good solution is found. - /*material.SetFloat(ShaderUtilities.ID_StencilComp, 4); - material.SetFloat(ShaderUtilities.ID_StencilID, 1);*/ material.SetFloat(ShaderUtilities.ID_StencilComp, 0); material.SetFloat(ShaderUtilities.ID_StencilID, 0); material.SetFloat(ShaderUtilities.ID_StencilOp, 0); @@ -81,15 +81,36 @@ public static class TmpSpriteUtils spriteAsset.spriteInfoList = new CppCollections.List(); + var maskedMaterial = new Material(_spriteShader) + { + name = assetName + " Masked Material", + }; + maskedMaterial.SetTexture(ShaderUtilities.ID_MainTex, sourceTexture); + maskedMaterial.SetFloat(ShaderUtilities.ID_StencilComp, 4); + maskedMaterial.SetFloat(ShaderUtilities.ID_StencilID, 1); + maskedMaterial.SetFloat(ShaderUtilities.ID_StencilOp, 0); + maskedMaterial.SetFloat(ShaderUtilities.ID_StencilWriteMask, 255); + maskedMaterial.SetFloat(ShaderUtilities.ID_StencilReadMask, 255); + maskedMaterial.SetFloat(ShaderUtilities.ShaderTag_CullMode, 0); + spriteAssetMasked.material = maskedMaterial; + + spriteAssetMasked.spriteInfoList = new CppCollections.List(); + AddSpriteToAsset(spriteAsset, rect, assetName, scale); + AddSpriteToAsset(spriteAssetMasked, rect, assetName + ".Masked", scale); spriteAsset.DontUnload().DontDestroy(); spriteAsset.UpdateLookupTables(); spriteAsset.fallbackSpriteAssets = new(); + spriteAssetMasked.DontUnload().DontDestroy(); + spriteAssetMasked.UpdateLookupTables(); + spriteAssetMasked.fallbackSpriteAssets = new(); AssetHolder.fallbackSpriteAssets.Add(spriteAsset); + AssetHolder.fallbackSpriteAssets.Add(spriteAssetMasked); AssetHolder.UpdateLookupTables(); LoadedSprites.Add(assetName, spriteAsset); + LoadedSprites.Add(assetName + ".Masked", spriteAssetMasked); return spriteAsset; }