Fix bad ui because sloth sucx

This commit is contained in:
Atony committed 2026-08-19 15:56:13 -05:00
1 parent a3668b3150
commit 247c765176
3 files changed
+141 -79

No files matched your search

-79
View File
@@ -165,85 +165,6 @@ public static class HudManagerPatches
{
__instance.chatNotifyDot.transform.localPosition = new Vector3(-0.34f, 0.373f, -1f);
}
[HarmonyPrefix]
[HarmonyPriority(Priority.First)]
[HarmonyPatch(typeof(MatchInfoGuide), nameof(MatchInfoGuide.Open))]
public static bool Open(MatchInfoGuide __instance)
{
if (HudManager.Instance.GameMenu.IsOpen || HudManager.Instance.Chat.IsOpenOrOpening)
{
return false;
}
if (Minigame.Instance != null)
{
Minigame.Instance.Close();
}
if (MapBehaviour.Instance)
{
MapBehaviour.Instance.Close();
}
if (HudManager.InstanceExists)
{
ConsoleJoystick.SetMode_MenuAdditive();
}
ControllerManager.Instance.OpenOverlayMenu("MatchInfoGuide", __instance.closeButton);
bool enabled = ActiveInputManager.currentControlType == ActiveInputManager.InputType.Joystick;
__instance.glyphL.enabled = enabled;
__instance.glyphR.enabled = enabled;
if (GameManager.Instance.TryCast<NormalGameManager>() != null)
{
if (__instance.NormalModeSettings.Count == 0)
{
__instance.numOfTabs = 3;
__instance.TabButtons[0].SelectButton(true);
__instance.CreateNormalModeSettings();
}
}
else if (__instance.HnSModeSettings.Count == 0)
{
__instance.numOfTabs = 2;
__instance.TabButtons[0].SelectButton(true);
__instance.CreateHnSModeSettings();
}
PlayerControl.LocalPlayer.NetTransform.Halt();
__instance.MatchInfoParent.SetActive(true);
ControllerManager instance = ControllerManager.Instance;
ControllerUiElementsState currentUiState = ControllerManager.Instance.CurrentUiState;
Il2CppSystem.Collections.Generic.List<UiElement> controllerSelectable = __instance.ControllerSelectable;
instance.SetUpSelectables(currentUiState, controllerSelectable[controllerSelectable.Count - 1], __instance.ControllerSelectable);
ControllerManager instance2 = ControllerManager.Instance;
Il2CppSystem.Collections.Generic.List<UiElement> controllerSelectable2 = __instance.ControllerSelectable;
instance2.SetCurrentSelected(controllerSelectable2[controllerSelectable2.Count - 1]);
__instance.SetActiveTab(0);
return false;
}
[HarmonyPrefix]
[HarmonyPriority(Priority.First)]
[HarmonyPatch(typeof(MatchInfoRolePanel), nameof(MatchInfoRolePanel.SetPanel))]
public static bool SetPanel(MatchInfoRolePanel __instance, RoleBehaviour role, int numPerGame, int chancePerGame)
{
if (role is ICustomRole customRole)
{
__instance.roleName.text = customRole.RoleName;
__instance.roleDescription.text = customRole.RoleDescription;
__instance.roleIcon.sprite = customRole.Configuration.Icon?.LoadAsset();
}
else
{
__instance.roleName.text = role.NiceName;
__instance.roleDescription.text = role.BlurbMed;
__instance.roleIcon.sprite = role.RoleIconColor;
}
__instance.roleIcon.SetSizeLimit(0.13f);
__instance.roleCount.text = string.Format(CultureInfo.InvariantCulture, "{0} at {1}%", numPerGame.ToString(CultureInfo.InvariantCulture), chancePerGame);
__instance.roleIcon.material.SetInt(PlayerMaterial.MaskLayer, 50);
__instance.roleName.fontMaterial.SetFloat(__instance.STENCIL_NAME, 50f);
__instance.roleDescription.fontMaterial.SetFloat(__instance.STENCIL_NAME, 50f);
__instance.roleCount.fontMaterial.SetFloat(__instance.STENCIL_NAME, 50f);
__instance.roleIcon.transform.localScale = new Vector3(4f, 4f, 1f);
return false;
}
/// <summary>
/// Create custom buttons and arrange them on the hud.
+129
View File
@@ -0,0 +1,129 @@
using System.Globalization;
using System.Linq;
using HarmonyLib;
using MiraAPI.Roles;
using MiraAPI.Utilities;
using UnityEngine;
namespace MiraAPI.Patches;
[HarmonyPatch]
public static class RoleGuidePatches
{
[HarmonyPostfix]
[HarmonyPriority(Priority.First)]
[HarmonyPatch(typeof(MatchInfoGuide), nameof(MatchInfoGuide.CreateNormalModeSettings))]
[HarmonyPatch(typeof(MatchInfoGuide), nameof(MatchInfoGuide.CreateHnSModeSettings))]
public static void CreateNormalModeSettings(MatchInfoGuide __instance)
{
__instance.MatchInfoRoleMaskArea.transform.localPosition = new Vector3(-0.0184f, 0.15f, -0.1f);
__instance.matchInfoPlayersMaskArea.transform.localPosition =
__instance.matchInfoSettingsMaskArea.transform.localPosition = new Vector3(1.22f, -0.335f, -0.1f);
__instance.matchInfoPlayersMaskArea.size =
__instance.matchInfoSettingsMaskArea.size =
__instance.MatchInfoRoleMaskArea.size = new Vector2(-6, 1.8f);
__instance.matchInfoPlayersMaskArea.transform.parent.GetAllChildren().First(x => x.name.Contains("BG_Gradient"))
.GetComponent<SpriteRenderer>()
.maskInteraction =
__instance.matchInfoSettingsMaskArea.transform.parent.GetAllChildren()
.First(x => x.name.Contains("BG_Gradient")).GetComponent<SpriteRenderer>()
.maskInteraction =
__instance.MatchInfoRoleMaskArea.transform.parent.GetAllChildren()
.First(x => x.name.Contains("BG_Gradient")).GetComponent<SpriteRenderer>()
.maskInteraction = SpriteMaskInteraction.VisibleInsideMask;
}
[HarmonyPrefix]
[HarmonyPriority(Priority.First)]
[HarmonyPatch(typeof(MatchInfoGuide), nameof(MatchInfoGuide.Awake))]
public static void Awake(MatchInfoGuide __instance)
{
__instance.transitionOpen.targetSize = 1.3f;
}
[HarmonyPrefix]
[HarmonyPriority(Priority.First)]
[HarmonyPatch(typeof(MatchInfoGuide), nameof(MatchInfoGuide.Open))]
public static bool Open(MatchInfoGuide __instance)
{
if (HudManager.Instance.GameMenu.IsOpen || HudManager.Instance.Chat.IsOpenOrOpening)
{
return false;
}
if (Minigame.Instance != null)
{
Minigame.Instance.Close();
}
if (MapBehaviour.Instance)
{
MapBehaviour.Instance.Close();
}
if (HudManager.InstanceExists)
{
ConsoleJoystick.SetMode_MenuAdditive();
}
ControllerManager.Instance.OpenOverlayMenu("MatchInfoGuide", __instance.closeButton);
bool enabled = ActiveInputManager.currentControlType == ActiveInputManager.InputType.Joystick;
__instance.glyphL.enabled = enabled;
__instance.glyphR.enabled = enabled;
if (GameManager.Instance.TryCast<NormalGameManager>() != null)
{
if (__instance.NormalModeSettings.Count == 0)
{
__instance.numOfTabs = 3;
__instance.TabButtons[0].SelectButton(true);
__instance.CreateNormalModeSettings();
}
}
else if (__instance.HnSModeSettings.Count == 0)
{
__instance.numOfTabs = 2;
__instance.TabButtons[0].SelectButton(true);
__instance.CreateHnSModeSettings();
}
PlayerControl.LocalPlayer.NetTransform.Halt();
__instance.MatchInfoParent.SetActive(true);
ControllerManager instance = ControllerManager.Instance;
ControllerUiElementsState currentUiState = ControllerManager.Instance.CurrentUiState;
Il2CppSystem.Collections.Generic.List<UiElement> controllerSelectable = __instance.ControllerSelectable;
instance.SetUpSelectables(currentUiState, controllerSelectable[controllerSelectable.Count - 1], __instance.ControllerSelectable);
ControllerManager instance2 = ControllerManager.Instance;
Il2CppSystem.Collections.Generic.List<UiElement> controllerSelectable2 = __instance.ControllerSelectable;
instance2.SetCurrentSelected(controllerSelectable2[controllerSelectable2.Count - 1]);
__instance.SetActiveTab(0);
return false;
}
[HarmonyPrefix]
[HarmonyPriority(Priority.First)]
[HarmonyPatch(typeof(MatchInfoRolePanel), nameof(MatchInfoRolePanel.SetPanel))]
public static bool SetPanel(MatchInfoRolePanel __instance, RoleBehaviour role, int numPerGame, int chancePerGame)
{
__instance.roleCount.text = string.Format(CultureInfo.InvariantCulture, "{0} at {1}%", numPerGame.ToString(CultureInfo.InvariantCulture), chancePerGame);
if (role is ICustomRole customRole)
{
__instance.roleName.text = customRole.RoleName;
__instance.roleDescription.text = customRole.RoleDescription;
__instance.roleIcon.sprite = customRole.Configuration.Icon?.LoadAsset();
__instance.roleCount.text += $" ({customRole.ParentMod.MiraPlugin.GetAbbreviatedModName()})";
}
else
{
__instance.roleName.text = role.NiceName;
__instance.roleDescription.text = role.BlurbMed;
__instance.roleIcon.sprite = role.RoleIconColor;
__instance.roleCount.text += " (AU)";
}
__instance.roleIcon.SetSizeLimit(0.13f);
__instance.roleIcon.material.SetInt(PlayerMaterial.MaskLayer, 50);
__instance.roleName.fontMaterial.SetFloat(__instance.STENCIL_NAME, 50f);
__instance.roleDescription.fontMaterial.SetFloat(__instance.STENCIL_NAME, 50f);
__instance.roleCount.fontMaterial.SetFloat(__instance.STENCIL_NAME, 50f);
__instance.roleIcon.transform.localScale = new Vector3(4f, 4f, 1f);
return false;
}
}
+12
View File
@@ -378,6 +378,18 @@ public static class Extensions
}
}
/// <summary>
/// Gets all child objects in a parent Transform.
/// </summary>
/// <returns>An <see cref="IEnumerable"/> that contains <see cref="GameObject"/>s.</returns>
public static IEnumerable<GameObject> GetAllChildren(this Transform go)
{
for (var i = 0; i < go.transform.childCount; i++)
{
yield return go.transform.GetChild(i).gameObject;
}
}
/// <summary>
/// Resizes a <see cref="SpriteRenderer"/> appropriate to the maximum pixel size without messing up ratios.
/// </summary>