mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-11-19 13:17:10 +00:00
Add ui resizing + wiki in the lobby
This commit is contained in:
1 parent
6b774500dd
commit
cb0afe3095
10 files changed
+523
-15
No files matched your search
@@ -0,0 +1,203 @@
|
||||
using BepInEx.Unity.IL2CPP.Utils.Collections;
|
||||
using InnerNet;
|
||||
using MiraAPI.LocalSettings;
|
||||
using MiraAPI.Modifiers.ModifierDisplay;
|
||||
using Reactor.Utilities.Attributes;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Hud;
|
||||
|
||||
[RegisterInIl2Cpp]
|
||||
public sealed class MiraHudHelper(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
{
|
||||
public static MiraHudHelper Instance { get; private set; }
|
||||
public static GameObject ModifierDisplayObject;
|
||||
public static GameObject VanillaMatchInfoButton;
|
||||
public static bool ModifierDisplayOnRight;
|
||||
public static GameObject ClonedChatButton;
|
||||
public static GameObject ExtraUiTopRight;
|
||||
public static GridArrange ExtraUiGrid;
|
||||
public static AspectPosition ExtraUiAspectPos;
|
||||
public static GameObject UiTopRight;
|
||||
public static GridArrange UiGrid;
|
||||
public static AspectPosition UiAspectPos;
|
||||
public static GameObject SubmergedFloorButton;
|
||||
public static SpriteRenderer SubmergedFloorButtonRenderer;
|
||||
public static SpriteRenderer SubmergedFloorButtonRendererHover;
|
||||
public void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
MiraApiSettings.OldButtonScaleFactor =
|
||||
LocalSettingsTabSingleton<MiraApiSettings>.Instance.TopRightButtonsFactorSlider.Value;
|
||||
StartCoroutine(MiraApiSettings.CoResizeSettingsUI().WrapToIl2Cpp());
|
||||
}
|
||||
#pragma warning disable S2325
|
||||
#pragma warning disable CA1822
|
||||
public void FixedUpdate()
|
||||
{
|
||||
if (!HudManager.InstanceExists || !PlayerControl.LocalPlayer || !PlayerControl.LocalPlayer.Data)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var instance = HudManager.Instance;
|
||||
|
||||
CreateUiRow(instance);
|
||||
CreateNewUiRow(instance);
|
||||
AdjustModifierTab();
|
||||
|
||||
if (!PlayerControl.LocalPlayer || !PlayerControl.LocalPlayer.Data || !PlayerControl.LocalPlayer.Data.Role ||
|
||||
!ShipStatus.Instance ||
|
||||
(AmongUsClient.Instance.GameState != InnerNetClient.GameStates.Started &&
|
||||
!TutorialManager.InstanceExists))
|
||||
{
|
||||
return;
|
||||
}
|
||||
UpdateSubmergedButtons(instance);
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
#pragma warning restore S2325
|
||||
|
||||
public static Vector3 BelowOptionPos = new(0.435f, 1.25f, 0f);
|
||||
public static Vector3 FullTopPos = new(0.435f, 0.475f, 0f);
|
||||
public static void CreateUiRow(HudManager instance)
|
||||
{
|
||||
if (!UiTopRight)
|
||||
{
|
||||
UiTopRight = instance.MapButton.transform.parent.gameObject;
|
||||
|
||||
UiGrid = UiTopRight.AddComponent<GridArrange>();
|
||||
UiAspectPos = UiTopRight.AddComponent<AspectPosition>();
|
||||
|
||||
UiGrid.Alignment = GridArrange.StartAlign.Left;
|
||||
UiGrid.CellSize = new Vector2(0.85f, 0.85f);
|
||||
UiGrid.MaxColumns = 6;
|
||||
UiAspectPos.Alignment = AspectPosition.EdgeAlignments.RightTop;
|
||||
UiGrid.Start();
|
||||
UiAspectPos.DistanceFromEdge = FullTopPos;
|
||||
var mapButton = instance.MapButton.gameObject;
|
||||
mapButton.GetComponent<AspectPosition>().Destroy();
|
||||
var settingsButton = instance.SettingsButton;
|
||||
settingsButton.GetComponent<AspectPosition>().Destroy();
|
||||
VanillaMatchInfoButton = instance.MatchInfoButton.gameObject;
|
||||
VanillaMatchInfoButton.GetComponent<AspectPosition>().Destroy();
|
||||
var oldPos = settingsButton.transform.localPosition;
|
||||
settingsButton.transform.localPosition = new Vector3(oldPos.x, oldPos.y, -100);
|
||||
var chatButton = instance.Chat.chatButton.gameObject;
|
||||
ClonedChatButton = Object.Instantiate(chatButton, chatButton.transform.parent);
|
||||
ClonedChatButton.SetActive(false);
|
||||
instance.Chat.chatButtonAspectPosition = ClonedChatButton.GetComponent<AspectPosition>();
|
||||
chatButton.GetComponent<AspectPosition>().Destroy();
|
||||
var inactivePos = settingsButton.transform.GetChild(1).transform.localPosition;
|
||||
var bg = settingsButton.transform.GetChild(2).gameObject;
|
||||
var bgPos = bg.transform.localPosition;
|
||||
var bgSprite = bg.GetComponent<SpriteRenderer>().sprite;
|
||||
var activePos = settingsButton.transform.GetChild(3).transform.localPosition;
|
||||
var selectedPos = settingsButton.transform.GetChild(4).transform.localPosition;
|
||||
chatButton.transform.GetChild(2).transform.localPosition = inactivePos;
|
||||
var chatBg = chatButton.transform.GetChild(3);
|
||||
chatBg.transform.localPosition = bgPos;
|
||||
chatBg.GetComponent<SpriteRenderer>().sprite = bgSprite;
|
||||
chatButton.transform.GetChild(4).transform.localPosition = activePos;
|
||||
chatButton.transform.GetChild(5).transform.localPosition = selectedPos;
|
||||
var collider = chatButton.GetComponent<BoxCollider2D>();
|
||||
collider.size = new Vector2(0.4354f, 0.4003f);
|
||||
collider.offset = new Vector2(0.0025f, 0.0254f);
|
||||
if (FriendsListManager.InstanceExists && !TutorialManager.InstanceExists)
|
||||
{
|
||||
var listButton = FriendsListManager.Instance.FriendsListButton.transform.GetChild(0);
|
||||
listButton.transform.SetParent(UiTopRight.transform, false);
|
||||
FriendsListManager.Instance.FriendsListButton = listButton.GetComponent<FriendsListButton>();
|
||||
listButton.GetComponent<AspectPosition>().Destroy();
|
||||
listButton.localPosition = new Vector3(0, 0, 0);
|
||||
}
|
||||
settingsButton.transform.SetAsLastSibling();
|
||||
chatButton.transform.SetParent(UiTopRight.transform, false);
|
||||
instance.Chat.chatButton = chatButton.GetComponent<PassiveButton>();
|
||||
var iconContainer = new GameObject("iconContainer")
|
||||
{
|
||||
layer = LayerMask.NameToLayer("UI"),
|
||||
};
|
||||
iconContainer.transform.SetParent(chatButton.transform, false);
|
||||
iconContainer.transform.localPosition = new Vector3(0.1f, -0.1f, 0);
|
||||
instance.Chat.chatNotifyDot.transform.SetParent(iconContainer.transform, false);
|
||||
instance.Chat.chatNotifyDot = iconContainer.transform.GetChild(0).GetComponent<SpriteRenderer>();
|
||||
}
|
||||
|
||||
if (UiTopRight && UiGrid)
|
||||
{
|
||||
var isChatButtonVisible = HudManager.Instance.Chat.isActiveAndEnabled;
|
||||
instance.Chat.chatButton.gameObject.SetActive(isChatButtonVisible);
|
||||
if (VanillaMatchInfoButton)
|
||||
{
|
||||
VanillaMatchInfoButton.SetActive(!GameSettingMenu.Instance && !Minigame.Instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void UpdateSubmergedButtons(HudManager instance)
|
||||
{
|
||||
if (ModCompatibility.IsSubmerged() && !SubmergedFloorButton && ExtraUiTopRight)
|
||||
{
|
||||
if (!SubmergedFloorButton && ExtraUiTopRight)
|
||||
{
|
||||
var transform = instance.MapButton.transform.parent.Find(instance.MapButton.name + "(Clone)");
|
||||
if (transform != null)
|
||||
{
|
||||
SubmergedFloorButton = transform.gameObject;
|
||||
SubmergedFloorButton.transform.SetParent(ExtraUiTopRight.transform, false);
|
||||
|
||||
SubmergedFloorButtonRenderer =
|
||||
SubmergedFloorButton.transform.Find("Inactive").GetComponent<SpriteRenderer>();
|
||||
SubmergedFloorButtonRendererHover =
|
||||
SubmergedFloorButton.transform.Find("Active").GetComponent<SpriteRenderer>();
|
||||
|
||||
MiraApiSettings.SetUpButtonPositions();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void AdjustModifierTab()
|
||||
{
|
||||
if (!ModifierDisplayObject && UiTopRight && ExtraUiTopRight && ModifierDisplayComponent.Instance)
|
||||
{
|
||||
ModifierDisplayObject = ModifierDisplayComponent.Instance?.gameObject ?? null!;
|
||||
ModifierDisplayOnRight = !LocalSettingsTabSingleton<MiraApiSettings>.Instance.ModifiersHudLeftSide.Value;
|
||||
if (ModifierDisplayOnRight)
|
||||
{
|
||||
ModifierDisplayObject.transform.SetParent(ExtraUiTopRight.transform, false);
|
||||
ModifierDisplayObject.GetComponent<AspectPosition>().Destroy();
|
||||
var oldPos = ModifierDisplayObject.transform.GetChild(0).localPosition;
|
||||
ModifierDisplayObject.transform.GetChild(0).localPosition = new Vector3(-1.1757f, -2.1633f, oldPos.z);
|
||||
oldPos = ModifierDisplayObject.transform.GetChild(1).localPosition;
|
||||
ModifierDisplayObject.transform.GetChild(1).localPosition = new Vector3(-0.45f, 0.3f, oldPos.z);
|
||||
}
|
||||
MiraApiSettings.SetUpButtonPositions();
|
||||
}
|
||||
}
|
||||
public static void CreateNewUiRow(HudManager instance)
|
||||
{
|
||||
if (!ExtraUiTopRight && UiTopRight)
|
||||
{
|
||||
ExtraUiTopRight = new GameObject("ExtraUiTopRight")
|
||||
{
|
||||
layer = UiTopRight.layer
|
||||
};
|
||||
ExtraUiTopRight.transform.SetParent(instance.MapButton.transform.parent.parent, false);
|
||||
|
||||
ExtraUiGrid = ExtraUiTopRight.AddComponent<GridArrange>();
|
||||
ExtraUiAspectPos = ExtraUiTopRight.AddComponent<AspectPosition>();
|
||||
|
||||
ExtraUiGrid.Alignment = GridArrange.StartAlign.Left;
|
||||
ExtraUiGrid.CellSize = new Vector2(0.85f, 0.85f);
|
||||
ExtraUiAspectPos.Alignment = AspectPosition.EdgeAlignments.RightTop;
|
||||
ExtraUiAspectPos.DistanceFromEdge = BelowOptionPos;
|
||||
ExtraUiGrid.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,6 @@ namespace MiraAPI;
|
||||
[BepInAutoPlugin("mira.api", "MiraAPI")]
|
||||
[BepInProcess("Among Us.exe")]
|
||||
[BepInDependency(ReactorPlugin.Id)]
|
||||
[BepInDependency(ModCompatibility.SubmergedId, BepInDependency.DependencyFlags.SoftDependency)]
|
||||
[ReactorModFlags(ModFlags.RequireOnAllClients)]
|
||||
public partial class MiraApiPlugin : BasePlugin
|
||||
{
|
||||
@@ -56,5 +55,9 @@ public partial class MiraApiPlugin : BasePlugin
|
||||
|
||||
PluginManager = new MiraPluginManager();
|
||||
PluginManager.Initialize();
|
||||
|
||||
IL2CPPChainloader.Instance.Finished +=
|
||||
ModCompatibility
|
||||
.Initialize; // Initialise AFTER the mods are loaded to ensure maximum parity (no need for the soft dependency either then)
|
||||
}
|
||||
}
|
||||
+163
-3
@@ -1,4 +1,6 @@
|
||||
using BepInEx.Configuration;
|
||||
using System.Collections;
|
||||
using BepInEx.Configuration;
|
||||
using MiraAPI.Hud;
|
||||
using MiraAPI.LocalSettings;
|
||||
using MiraAPI.LocalSettings.Attributes;
|
||||
using MiraAPI.Patches;
|
||||
@@ -25,15 +27,21 @@ public class MiraApiSettings(ConfigFile config) : LocalSettingsTab(config)
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value stored for scaling buttons properly.
|
||||
/// Gets or sets the value stored for scaling ability buttons properly.
|
||||
/// </summary>
|
||||
public static float OldButtonScaleFactor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value stored for scaling UI buttons properly.
|
||||
/// </summary>
|
||||
public static float OldUiButtonScaleFactor { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Open()
|
||||
{
|
||||
base.Open();
|
||||
OldButtonScaleFactor = ButtonUIFactorSlider.Value;
|
||||
OldUiButtonScaleFactor = TopRightButtonsFactorSlider.Value;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -49,12 +57,153 @@ public class MiraApiSettings(ConfigFile config) : LocalSettingsTab(config)
|
||||
}
|
||||
OldButtonScaleFactor = ButtonUIFactorSlider.Value;
|
||||
}
|
||||
else if (configEntry == TopRightButtonsFactorSlider)
|
||||
{
|
||||
if (MiraHudHelper.Instance)
|
||||
{
|
||||
ResizeUI(TopRightButtonsFactorSlider.Value);
|
||||
}
|
||||
OldUiButtonScaleFactor = TopRightButtonsFactorSlider.Value;
|
||||
}
|
||||
else if (configEntry == WikiOnBottomRow)
|
||||
{
|
||||
SetUpButtonPositions();
|
||||
}
|
||||
else if (configEntry == SetFpsSlider)
|
||||
{
|
||||
Application.targetFrameRate = (int)SetFpsSlider.Value;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetUpButtonPositions()
|
||||
{
|
||||
var topUi = MiraHudHelper.UiTopRight;
|
||||
var extraTopUi = MiraHudHelper.ExtraUiTopRight;
|
||||
var wikiButton = MiraHudHelper.VanillaMatchInfoButton;
|
||||
var subButton = MiraHudHelper.SubmergedFloorButton;
|
||||
var modDisplay = MiraHudHelper.ModifierDisplayOnRight ? MiraHudHelper.ModifierDisplayObject : null!;
|
||||
ResetButtonPositions();
|
||||
if (topUi && extraTopUi)
|
||||
{
|
||||
var opts = LocalSettingsTabSingleton<MiraApiSettings>.Instance;
|
||||
if (wikiButton)
|
||||
{
|
||||
wikiButton.transform.SetParent(opts.WikiOnBottomRow.Value ? extraTopUi.transform : topUi.transform);
|
||||
}
|
||||
if (subButton)
|
||||
{
|
||||
subButton.transform.SetParent(extraTopUi.transform);
|
||||
}
|
||||
if (modDisplay)
|
||||
{
|
||||
modDisplay.transform.SetParent(extraTopUi.transform);
|
||||
}
|
||||
MiraHudHelper.UiGrid.ArrangeChilds();
|
||||
MiraHudHelper.ExtraUiGrid.ArrangeChilds();
|
||||
}
|
||||
}
|
||||
|
||||
public static void ResetButtonPositions()
|
||||
{
|
||||
var topUi = MiraHudHelper.UiTopRight;
|
||||
var extraTopUi = MiraHudHelper.ExtraUiTopRight;
|
||||
var subButton = MiraHudHelper.SubmergedFloorButton;
|
||||
var modDisplay = MiraHudHelper.ModifierDisplayOnRight ? MiraHudHelper.ModifierDisplayObject : null!;
|
||||
if (topUi && extraTopUi)
|
||||
{
|
||||
var wikiButton = MiraHudHelper.VanillaMatchInfoButton;
|
||||
if (wikiButton)
|
||||
{
|
||||
wikiButton.transform.SetParent(null);
|
||||
}
|
||||
if (subButton)
|
||||
{
|
||||
subButton.transform.SetParent(null);
|
||||
}
|
||||
if (modDisplay)
|
||||
{
|
||||
modDisplay.transform.SetParent(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerator CoResizeSettingsUI()
|
||||
{
|
||||
while (!HudManager.Instance || !MiraHudHelper.UiGrid || !MiraHudHelper.ExtraUiGrid)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
|
||||
yield return new WaitForSeconds(0.01f);
|
||||
ResizeUI(LocalSettingsTabSingleton<MiraApiSettings>.Instance.TopRightButtonsFactorSlider.Value);
|
||||
}
|
||||
|
||||
public static void ResizeUI(float scaleFactor)
|
||||
{
|
||||
var alteredScale = scaleFactor * 0.85f;
|
||||
var actualScaleVal = scaleFactor * 1.176470588235294f;
|
||||
var actualScale = new Vector3(actualScaleVal, actualScaleVal, 1);
|
||||
var baseAspect = MiraHudHelper.UiAspectPos;
|
||||
var baseGrid = MiraHudHelper.UiGrid;
|
||||
var baseUi = MiraHudHelper.UiTopRight;
|
||||
if (baseUi && baseAspect && baseGrid)
|
||||
{
|
||||
baseAspect.DistanceFromEdge = new Vector2(0.435f * scaleFactor, 0.475f * scaleFactor);
|
||||
|
||||
foreach (var button in baseUi.GetComponentsInChildren<PassiveButton>(true))
|
||||
{
|
||||
if (button.gameObject == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (button.transform.name.Contains("Friends List Button"))
|
||||
{
|
||||
button.gameObject.transform.localScale = new Vector3(0.2675f * actualScaleVal, 0.2675f * actualScaleVal, 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
button.gameObject.transform.localScale = actualScale;
|
||||
}
|
||||
|
||||
baseGrid.CellSize = new Vector2(alteredScale, alteredScale);
|
||||
if (baseGrid.gameObject.transform.childCount != 0)
|
||||
{
|
||||
baseGrid.ArrangeChilds();
|
||||
}
|
||||
baseAspect.AdjustPosition();
|
||||
}
|
||||
|
||||
var extraAspect = MiraHudHelper.ExtraUiAspectPos;
|
||||
var extraGrid = MiraHudHelper.ExtraUiGrid;
|
||||
var extraUi = MiraHudHelper.ExtraUiTopRight;
|
||||
if (extraUi && extraAspect && extraGrid)
|
||||
{
|
||||
extraAspect.DistanceFromEdge = new Vector3(0.435f * scaleFactor, 1.25f * scaleFactor, 0f);
|
||||
|
||||
foreach (var button in extraUi.GetAllChildren())
|
||||
{
|
||||
if (button.gameObject == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (button.transform.name.Contains("Modifiers"))
|
||||
{
|
||||
button.gameObject.transform.localScale = new Vector3(0.65f * scaleFactor, 0.65f * scaleFactor, 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
button.gameObject.transform.localScale = actualScale;
|
||||
}
|
||||
|
||||
extraGrid.CellSize = new Vector2(alteredScale, alteredScale);
|
||||
if (extraGrid.gameObject.transform.childCount != 0)
|
||||
{
|
||||
extraGrid.ArrangeChilds();
|
||||
}
|
||||
extraAspect.AdjustPosition();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the modifiers hud should be on the left side of the screen (under roles/task tab). Recommended for streamers.
|
||||
/// </summary>
|
||||
@@ -68,12 +217,19 @@ public class MiraApiSettings(ConfigFile config) : LocalSettingsTab(config)
|
||||
public ConfigEntry<bool> ShowKeybinds { get; private set; } = config.Bind("Visuals/UI", "Show Keybinds on Buttons", true);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the scale of the buttons.
|
||||
/// Gets the scale of the ability buttons.
|
||||
/// </summary>
|
||||
[LocalSliderSetting(min: 0.5f, max: 1.5f, suffixType: MiraNumberSuffixes.Multiplier, formatString: "0.00", displayValue: true)]
|
||||
public ConfigEntry<float> ButtonUIFactorSlider { get; private set; } =
|
||||
config.Bind("Visuals/UI", "Button Scale Factor", 0.75f);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the scale of the UI buttons.
|
||||
/// </summary>
|
||||
[LocalSliderSetting(min: 0.3f, max: 2f, suffixType: MiraNumberSuffixes.Multiplier, formatString: "0.00", displayValue: true)]
|
||||
public ConfigEntry<float> TopRightButtonsFactorSlider { get; private set; } =
|
||||
config.Bind("Visuals/UI", "Top-Right UI Scale Factor", 1f);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the fps specified by the player.
|
||||
/// </summary>
|
||||
@@ -81,6 +237,10 @@ public class MiraApiSettings(ConfigFile config) : LocalSettingsTab(config)
|
||||
public ConfigEntry<float> SetFpsSlider { get; private set; } =
|
||||
config.Bind("Visuals/UI", "Max FPS", 120f);
|
||||
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> WikiOnBottomRow { get; private set; } =
|
||||
config.Bind("Visuals/UI", "Display Wiki on Bottom Row", true);
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether to apply cosmetic changes to the TaskAdder.
|
||||
/// </summary>
|
||||
|
||||
+32
-11
@@ -1,6 +1,6 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Reflection;
|
||||
using System.Reflection;
|
||||
using BepInEx.Unity.IL2CPP;
|
||||
using SemanticVersioning;
|
||||
|
||||
namespace MiraAPI;
|
||||
|
||||
@@ -14,15 +14,36 @@ public static class ModCompatibility
|
||||
/// </summary>
|
||||
public const string SubmergedId = "Submerged";
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the Submerged mod is loaded.
|
||||
/// </summary>
|
||||
/// <param name="submergedAssembly">Submerged mod assembly if loaded, <see langword="null"/> otherwise.</param>
|
||||
/// <returns><see langword="true"/> if the Submerged mod is loaded, <see langword="false"/> otherwise.</returns>
|
||||
public static bool SubmergedLoaded([NotNullWhen(true)] out Assembly? submergedAssembly)
|
||||
public static Version SubVersion { get; private set; }
|
||||
public static bool SubLoaded { get; private set; }
|
||||
public static BasePlugin SubPlugin { get; private set; }
|
||||
public static Assembly SubAssembly { get; private set; }
|
||||
|
||||
public const ShipStatus.MapType SubmergedMapType = (ShipStatus.MapType)6;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
var result = IL2CPPChainloader.Instance.Plugins.TryGetValue(SubmergedId, out var plugin);
|
||||
submergedAssembly = result ? plugin?.Instance.GetType().Assembly : null;
|
||||
return result;
|
||||
InitSubmerged();
|
||||
}
|
||||
|
||||
public static void InitSubmerged()
|
||||
{
|
||||
if (!IL2CPPChainloader.Instance.Plugins.TryGetValue(SubmergedId, out var plugin))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SubPlugin = (plugin!.Instance as BasePlugin)!;
|
||||
SubVersion = plugin.Metadata.Version;
|
||||
|
||||
SubAssembly = SubPlugin.GetType().Assembly;
|
||||
|
||||
SubLoaded = true;
|
||||
Message("Submerged was detected");
|
||||
}
|
||||
|
||||
public static bool IsSubmerged()
|
||||
{
|
||||
return SubLoaded && ShipStatus.Instance && ShipStatus.Instance.Type == SubmergedMapType;
|
||||
}
|
||||
}
|
||||
@@ -123,6 +123,99 @@ public static class HudManagerPatches
|
||||
CustomGameModeManager.ActiveMode?.HudStart(__instance);
|
||||
}*/
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPriority(Priority.First)]
|
||||
[HarmonyPatch(typeof(FriendsListManager), nameof(FriendsListManager.SetFriendButtonColor))]
|
||||
public static bool SetFriendButtonColor(FriendsListManager __instance, bool isGrayedOut)
|
||||
{
|
||||
__instance.FriendsListButton?.SetGlyphColor(isGrayedOut);
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPriority(Priority.First)]
|
||||
[HarmonyPatch(typeof(ChatController), nameof(ChatController.Toggle))]
|
||||
[HarmonyPatch(typeof(ChatController), nameof(ChatController.Close))]
|
||||
public static void TogglePrefix(ChatController __instance)
|
||||
{
|
||||
if (!MiraHudHelper.ClonedChatButton)
|
||||
{
|
||||
return;
|
||||
}
|
||||
__instance.chatButton.transform.localPosition = MiraHudHelper.ClonedChatButton.transform.localPosition + new Vector3(-0.3f, 0);
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPriority(Priority.First)]
|
||||
[HarmonyPatch(typeof(ChatController), nameof(ChatController.Toggle))]
|
||||
[HarmonyPatch(typeof(ChatController), nameof(ChatController.Close))]
|
||||
public static void TogglePostfix(ChatController __instance)
|
||||
{
|
||||
MiraHudHelper.UiGrid.ArrangeChilds();
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPriority(Priority.First)]
|
||||
[HarmonyPatch(typeof(ChatController), nameof(ChatController.AddChatNote))]
|
||||
[HarmonyPatch(typeof(ChatController), nameof(ChatController.AddChat))]
|
||||
[HarmonyPatch(typeof(ChatController), nameof(ChatController.AddChatWarning))]
|
||||
public static void ChatBubbleUpdatePrefix(ChatController __instance)
|
||||
{
|
||||
__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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create custom buttons and arrange them on the hud.
|
||||
/// </summary>
|
||||
@@ -131,6 +224,7 @@ public static class HudManagerPatches
|
||||
[HarmonyPatch(nameof(HudManager.Start))]
|
||||
public static void StartPostfix(HudManager __instance)
|
||||
{
|
||||
__instance.gameObject.AddComponent<MiraHudHelper>();
|
||||
if (Buttons == null)
|
||||
{
|
||||
Buttons = __instance.transform.Find("Buttons");
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 6.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 6.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 6.1 KiB |
@@ -135,5 +135,20 @@ public static class MiraAssets
|
||||
/// </summary>
|
||||
public static LoadableResourceAsset TimedModifierFile { get; } = new("MiraAPI.Resources.TimedModifierFile.png");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sprite used for the new chat button while hovering.
|
||||
/// </summary>
|
||||
public static LoadableResourceAsset ChatHoverSprite { get; } = new("MiraAPI.Resources.NormalChatHover.png");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sprite used for the new chat button while hovering.
|
||||
/// </summary>
|
||||
public static LoadableResourceAsset ChatIdleSprite { get; } = new("MiraAPI.Resources.NormalChatIdle.png");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sprite used for the new chat button while hovering.
|
||||
/// </summary>
|
||||
public static LoadableResourceAsset ChatOpenSprite { get; } = new("MiraAPI.Resources.NormalChatOpen.png");
|
||||
|
||||
internal static LoadableResourceAsset BlankSprite { get; } = new("MiraAPI.Resources.BlankSprite.png");
|
||||
}
|
||||
@@ -366,6 +366,18 @@ public static class Extensions
|
||||
GC.Collect();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all child objects in a parent object.
|
||||
/// </summary>
|
||||
/// <returns>An <see cref="IEnumerable"/> that contains <see cref="GameObject"/>s.</returns>
|
||||
public static IEnumerable<GameObject> GetAllChildren(this GameObject go)
|
||||
{
|
||||
for (var i = 0; i < go.transform.childCount; i++)
|
||||
{
|
||||
yield return go.transform.GetChild(i).gameObject;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a cache of <see cref="PlayerControl"/>'s <see cref="PlayerVoteData"/> to improve performance.
|
||||
/// </summary>
|
||||
|
||||
Reference in new issue
Block a user