diff --git a/Reactor/Patches/ReactorVersionShower.cs b/Reactor/Patches/ReactorVersionShower.cs index 0eed15b..57917cc 100644 --- a/Reactor/Patches/ReactorVersionShower.cs +++ b/Reactor/Patches/ReactorVersionShower.cs @@ -25,6 +25,13 @@ public static class ReactorVersionShower /// public static event Action? TextUpdated; + private static readonly Il2CppSystem.Action _setMainMenuPositionFromAspect = (Action) (aspect => + { + if (Text == null) return; + var pos = new Vector3(-1.2287f * aspect + 10.9f, -0.57f, 4.5f); + Text.transform.position = pos; + }); + internal static void Initialize() { SceneManager.add_sceneLoaded((Action) ((scene, _) => @@ -38,40 +45,41 @@ internal static void Initialize() var gameObject = new GameObject("ReactorVersion"); - var aspectPosition = gameObject.AddComponent(); + Text = gameObject.AddComponent(); + Text.font = originalText.font; + Text.fontMaterial = originalText.fontMaterial; + Text.UpdateFontAsset(); + Text.overflowMode = TextOverflowModes.Overflow; + Text.fontSize = 2; + Text.outlineWidth = 0.1f; + Text.enableWordWrapping = false; + Text.alignment = TextAlignmentOptions.TopLeft; if (scene.name == "MainMenu") { - aspectPosition.Alignment = AspectPosition.EdgeAlignments.Left; - aspectPosition.DistanceFromEdge = new Vector3(5f, 1.55f, 2f); + ResolutionManager.add_ResolutionChanged(_setMainMenuPositionFromAspect); + _setMainMenuPositionFromAspect.Invoke(Screen.width / (float) Screen.height); } else { - var distanceFromEdge = new Vector3(1, 0.4f, -1); + ResolutionManager.remove_ResolutionChanged(_setMainMenuPositionFromAspect); + var aspectPosition = gameObject.AddComponent(); + var distanceFromEdge = new Vector3(10.13f, 2.55f, -1); if (originalAspectPosition.Alignment == AspectPosition.EdgeAlignments.LeftTop) { - distanceFromEdge += new Vector3(0.05f, 0.15f, 0); + distanceFromEdge.y += 0.2f; } else if (AccountManager.Instance.isActiveAndEnabled) { - distanceFromEdge += new Vector3(0.2f, 0.6f, 0); + distanceFromEdge.x += 0.2f; + distanceFromEdge.y += 0.575f; } aspectPosition.Alignment = AspectPosition.EdgeAlignments.LeftTop; aspectPosition.DistanceFromEdge = distanceFromEdge; + aspectPosition.AdjustPosition(); } - aspectPosition.AdjustPosition(); - - Text = gameObject.AddComponent(); - Text.font = originalText.font; - Text.fontMaterial = originalText.fontMaterial; - Text.UpdateFontAsset(); - Text.alignment = TextAlignmentOptions.TopLeft; - Text.autoSizeTextContainer = true; - Text.fontSize = 2; - Text.outlineWidth = 0.1f; - UpdateText(); })); }