Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of REPONativeUltrawide v1.0.0
plugins/com.github.NEDOSTUPN0.REPONativeUltrawide.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.Rendering.PostProcessing; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("NEDOSTUPN0")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+d1fe80efb96e57fdeb8beec5d85bfc4f9cd6101f")] [assembly: AssemblyProduct("REPONativeUltrawide")] [assembly: AssemblyTitle("com.github.NEDOSTUPN0.REPONativeUltrawide")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace RepoNativeUltrawide { [HarmonyPatch(typeof(SemiFunc), "UIMousePosToUIPos")] internal static class UIMousePosToUIPosPatch { private const float BaseAspect = 1.7777778f; private static bool Prefix(ref Vector2 __result) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) if (!UltrawideHud.EnabledForPatch || (Object)(object)HUDCanvas.instance == (Object)null) { return true; } float num = (float)Screen.width / (float)Screen.height; if (num <= 1.7787778f) { return true; } Vector2 sizeDelta = ((Component)HUDCanvas.instance).GetComponent<RectTransform>().sizeDelta; float num2 = Input.mousePosition.x / (float)Screen.width; float num3 = Input.mousePosition.y / (float)Screen.height; float num4 = sizeDelta.x * 0.5f + (num2 - 0.5f) * sizeDelta.y * num; float num5 = sizeDelta.y * 0.5f + (num3 - 0.5f) * sizeDelta.y; __result = new Vector2(num4, num5); return false; } } [HarmonyPatch(typeof(GraphicsManager), "Update")] internal static class GameTickPatch { private static void Postfix() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) bool value = Plugin.Enabled.Value; UltrawideHud.Tick(value); MenuAdjust.Tick(value); PostProcessAdjust.Tick(value && Plugin.LensDistortionFix.Value); if ((int)Plugin.DumpKey.Value != 0 && Input.GetKeyDown(Plugin.DumpKey.Value)) { Plugin.DumpHierarchy(); } } } internal static class MenuAdjust { private const float BaseAspect = 1.7777778f; private static readonly Dictionary<RectTransform, Vector2> _originalSizes = new Dictionary<RectTransform, Vector2>(); private static readonly Dictionary<Transform, float> _originalLocalX = new Dictionary<Transform, float>(); internal static void Tick(bool enabled) { float num = (float)Screen.width / (float)Screen.height; bool active = enabled && num > 1.7787778f; float targetWidth = 400f * num + 40f; float shift = 200f * (num - 1.7777778f); MenuPage[] array = Object.FindObjectsOfType<MenuPage>(); foreach (MenuPage val in array) { Transform transform = ((Component)val).transform; RectTransform val2 = (RectTransform)(object)((transform is RectTransform) ? transform : null); if (!((Object)(object)val2 == (Object)null)) { WidenBackdrops(val, val2, active, targetWidth); if ((Object)(object)((Component)val).GetComponent<MenuPageMain>() != (Object)null || (Object)(object)((Component)val).GetComponent<MenuPageLobby>() != (Object)null || (Object)(object)((Component)val).GetComponent<MenuPageEsc>() != (Object)null || (Object)(object)((Component)val).GetComponent<MenuPageSettings>() != (Object)null || (Object)(object)((Component)val).GetComponent<MenuPageSettingsPage>() != (Object)null) { ShiftElements(val, val2, active, shift); } } } } private static void WidenBackdrops(MenuPage page, RectTransform pageRt, bool active, float targetWidth) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) Rect rect = pageRt.rect; float width = ((Rect)(ref rect)).width; rect = pageRt.rect; float height = ((Rect)(ref rect)).height; foreach (Transform item in ((Component)page).transform) { Transform val = item; RectTransform val2 = (RectTransform)(object)((val is RectTransform) ? val : null); if (val2 == null || (Object)(object)((Component)val2).GetComponent<Graphic>() == (Object)null) { continue; } rect = val2.rect; if (((Rect)(ref rect)).width < width * 0.9f) { continue; } rect = val2.rect; if (((Rect)(ref rect)).height < height * 0.9f) { continue; } Vector2 val3 = OriginalSize(val2); if (!active) { if (val2.sizeDelta != val3) { val2.sizeDelta = val3; } continue; } float num = val2.anchorMax.x - val2.anchorMin.x; float num2 = targetWidth - num * width; if (!Mathf.Approximately(val2.sizeDelta.x, num2)) { val2.sizeDelta = new Vector2(num2, val3.y); } } } private static void ShiftElements(MenuPage page, RectTransform pageRt, bool active, float shift) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) Rect rect = pageRt.rect; float width = ((Rect)(ref rect)).width; rect = pageRt.rect; float height = ((Rect)(ref rect)).height; int num = 0; Transform val = ((Component)page).transform.Find("Panel"); if ((Object)(object)val != (Object)null) { num = ClassifyDirection(val, pageRt, width); } foreach (Transform item in ((Component)page).transform) { Transform val2 = item; RectTransform val3 = (RectTransform)(object)((val2 is RectTransform) ? val2 : null); if (val3 != null && (Object)(object)((Component)val3).GetComponent<Graphic>() != (Object)null) { rect = val3.rect; if (((Rect)(ref rect)).width >= width * 0.9f) { rect = val3.rect; if (((Rect)(ref rect)).height >= height * 0.9f) { continue; } } } if ((Object)(object)((Component)val2).GetComponent<MenuSelectionBox>() != (Object)null) { continue; } int num2 = ClassifyDirection(val2, pageRt, width); if (num2 == 0 && (Object)(object)((Component)val2).GetComponent<MenuScrollBox>() != (Object)null) { num2 = num; } if (num2 != 0) { float num3 = OriginalLocalX(val2); float num4 = (active ? (num3 + (float)num2 * shift) : num3); Vector3 localPosition = val2.localPosition; if (!Mathf.Approximately(localPosition.x, num4)) { val2.localPosition = new Vector3(num4, localPosition.y, localPosition.z); } } } } private static int ClassifyDirection(Transform c, RectTransform pageRt, float pageW) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) if (((Object)c).name == "Menu Element Player Avatar") { return 1; } RectTransform val = (RectTransform)(object)((c is RectTransform) ? c : null); Vector3 val2; if (val == null) { val2 = c.position; } else { Rect rect = val.rect; val2 = ((Transform)val).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect)).center)); } Vector3 val3 = val2; float x = ((Transform)pageRt).InverseTransformPoint(val3).x; float num = pageW * 0.5f; float num2 = pageW * 0.12f; if (x < num - num2) { return -1; } if (x > num + num2) { return 1; } return 0; } private static float OriginalLocalX(Transform t) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (!_originalLocalX.TryGetValue(t, out var value)) { value = t.localPosition.x; _originalLocalX[t] = value; } return value; } private static Vector2 OriginalSize(RectTransform rt) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) if (!_originalSizes.TryGetValue(rt, out var value)) { value = rt.sizeDelta; _originalSizes[rt] = value; } return value; } } [BepInPlugin("com.github.NEDOSTUPN0.REPONativeUltrawide", "REPONativeUltrawide", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string Guid = "com.github.NEDOSTUPN0.REPONativeUltrawide"; public const string Name = "REPONativeUltrawide"; public const string Version = "1.0.0"; internal static ManualLogSource Log; internal static ConfigEntry<KeyCode> DumpKey; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<bool> LensDistortionFix; private void Awake() { //IL_0070: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Adapt the game and UI to ultrawide instead of stretching them. Spreads HUD/menu elements to the real screen edges."); LensDistortionFix = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Lens Distortion Fix", true, "Reduce the 'old TV' lens distortion and chromatic aberration on ultrawide so the edges/corners stay as moderate and readable as they are at 16:9."); DumpKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Debug", "Dump UI Hierarchy Key", (KeyCode)0, "Bind a key to dump the full UI (Canvas/RectTransform) hierarchy + cameras to a file. Unbound by default."); new Harmony("com.github.NEDOSTUPN0.REPONativeUltrawide").PatchAll(); Log.LogInfo((object)string.Format("{0} {1} loaded (enabled={2}).", "REPONativeUltrawide", "1.0.0", Enabled.Value)); } internal static void DumpHierarchy() { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("=== REPONativeUltrawide UI dump ==="); stringBuilder.AppendLine($"Time: {DateTime.Now:yyyy-MM-dd HH:mm:ss}"); stringBuilder.AppendLine($"Screen: {Screen.width}x{Screen.height} aspect={(float)Screen.width / (float)Screen.height:0.0000}"); stringBuilder.AppendLine($"Fullscreen: {Screen.fullScreenMode}"); stringBuilder.AppendLine(); Canvas[] array = Resources.FindObjectsOfTypeAll<Canvas>(); int num = 0; Canvas[] array2 = array; foreach (Canvas val in array2) { if (!((Object)(object)val == (Object)null)) { Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).IsValid() && (!((Object)(object)((Component)val).transform.parent != (Object)null) || !((Object)(object)((Component)((Component)val).transform.parent).GetComponentInParent<Canvas>() != (Object)null))) { object[] obj = new object[4] { ((Object)val).name, null, null, null }; scene = ((Component)val).gameObject.scene; obj[1] = ((Scene)(ref scene)).name; obj[2] = val.renderMode; obj[3] = val.sortingOrder; stringBuilder.AppendLine(string.Format("########## CANVAS '{0}' scene='{1}' renderMode={2} sortingOrder={3}", obj)); DumpNode(((Component)val).transform, 0, stringBuilder); stringBuilder.AppendLine(); num++; } } } DumpCameras(stringBuilder); DumpPostProcessing(stringBuilder); string bepInExRootPath = Paths.BepInExRootPath; string text = Path.Combine(bepInExRootPath, $"ultrawide-ui-dump-{DateTime.Now:yyyyMMdd-HHmmss}.txt"); try { File.WriteAllText(text, stringBuilder.ToString()); Log.LogMessage((object)$"Dumped {num} root canvas/canvases → {text}"); } catch (Exception arg) { Log.LogError((object)$"Failed to write dump file: {arg}"); Log.LogInfo((object)stringBuilder.ToString()); } } private static void DumpCameras(StringBuilder sb) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) sb.AppendLine(); sb.AppendLine("########## CAMERAS"); Camera[] array = Resources.FindObjectsOfTypeAll<Camera>(); Camera[] array2 = array; Scene scene; foreach (Camera val in array2) { if ((Object)(object)val == (Object)null) { continue; } scene = ((Component)val).gameObject.scene; if (!((Scene)(ref scene)).IsValid()) { continue; } RenderTexture targetTexture = val.targetTexture; string text = (((Object)(object)targetTexture == (Object)null) ? "targetTexture=NULL (renders to screen)" : $"targetTexture='{((Object)targetTexture).name}' {((Texture)targetTexture).width}x{((Texture)targetTexture).height} fmt={targetTexture.format}"); sb.AppendLine("[" + (((Behaviour)val).enabled ? "+" : "-") + "] CAM '" + FullPath(((Component)val).transform) + "'" + $" depth={val.depth} ortho={val.orthographic} orthoSize={val.orthographicSize:0.##}" + $" aspect={val.aspect:0.0000} fov={val.fieldOfView:0.#}" + $" rect={R(val.rect)} clear={val.clearFlags} cullMask=0x{val.cullingMask:X8}"); sb.AppendLine(" " + text); StringBuilder stringBuilder = new StringBuilder(); Component[] components = ((Component)val).GetComponents<Component>(); foreach (Component val2 in components) { if (!((Object)(object)val2 == (Object)null) && !(val2 is Transform) && !(val2 is Camera)) { stringBuilder.Append(((object)val2).GetType().Name).Append(' '); } } if (stringBuilder.Length > 0) { sb.AppendLine($" components: {stringBuilder}"); } } sb.AppendLine(); sb.AppendLine("########## DISPLAY QUAD MATERIALS"); RawImage[] array3 = Resources.FindObjectsOfTypeAll<RawImage>(); foreach (RawImage val3 in array3) { if ((Object)(object)val3 == (Object)null) { continue; } scene = ((Component)val3).gameObject.scene; if (!((Scene)(ref scene)).IsValid()) { continue; } string name = ((Object)val3).name; if (name.Contains("Render Texture")) { Material material = ((Graphic)val3).material; sb.AppendLine(" RawImage '" + name + "' material='" + (((Object)(object)material != (Object)null) ? ((Object)material).name : "null") + "' shader='" + (((Object)(object)material != (Object)null && (Object)(object)material.shader != (Object)null) ? ((Object)material.shader).name : "null") + "'"); if ((Object)(object)material != (Object)null && (Object)(object)material.shader != (Object)null) { DumpMaterialProps(material, sb); } } } sb.AppendLine(); sb.AppendLine("########## RENDER TEXTURES (loaded)"); RenderTexture[] array4 = Resources.FindObjectsOfTypeAll<RenderTexture>(); foreach (RenderTexture val4 in array4) { if (!((Object)(object)val4 == (Object)null)) { sb.AppendLine($" RT '{((Object)val4).name}' {((Texture)val4).width}x{((Texture)val4).height} fmt={val4.format} created={val4.IsCreated()}"); } } } private static void DumpPostProcessing(StringBuilder sb) { //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) sb.AppendLine(); sb.AppendLine("########## POST-PROCESS EFFECTS (all loaded instances)"); ChromaticAberration[] array = Resources.FindObjectsOfTypeAll<ChromaticAberration>(); foreach (ChromaticAberration val in array) { if ((Object)(object)val != (Object)null) { sb.AppendLine($" ChromaticAberration active={((PostProcessEffectSettings)val).active} enabled={((PostProcessEffectSettings)val).enabled} intensity={((ParameterOverride<float>)(object)val.intensity).value:0.###} (override={((ParameterOverride)val.intensity).overrideState})"); } } Grain[] array2 = Resources.FindObjectsOfTypeAll<Grain>(); foreach (Grain val2 in array2) { if ((Object)(object)val2 != (Object)null) { sb.AppendLine($" Grain active={((PostProcessEffectSettings)val2).active} intensity={((ParameterOverride<float>)(object)val2.intensity).value:0.###} size={((ParameterOverride<float>)(object)val2.size).value:0.###}"); } } Vignette[] array3 = Resources.FindObjectsOfTypeAll<Vignette>(); foreach (Vignette val3 in array3) { if ((Object)(object)val3 != (Object)null) { sb.AppendLine($" Vignette active={((PostProcessEffectSettings)val3).active} intensity={((ParameterOverride<float>)(object)val3.intensity).value:0.###} smoothness={((ParameterOverride<float>)(object)val3.smoothness).value:0.###}"); } } Bloom[] array4 = Resources.FindObjectsOfTypeAll<Bloom>(); foreach (Bloom val4 in array4) { if ((Object)(object)val4 != (Object)null) { sb.AppendLine($" Bloom active={((PostProcessEffectSettings)val4).active} intensity={((ParameterOverride<float>)(object)val4.intensity).value:0.###}"); } } LensDistortion[] array5 = Resources.FindObjectsOfTypeAll<LensDistortion>(); foreach (LensDistortion val5 in array5) { if ((Object)(object)val5 != (Object)null) { sb.AppendLine($" LensDistortion active={((PostProcessEffectSettings)val5).active} intensity={((ParameterOverride<float>)(object)val5.intensity).value:0.###} X={((ParameterOverride<float>)(object)val5.intensityX).value:0.###} Y={((ParameterOverride<float>)(object)val5.intensityY).value:0.###} scale={((ParameterOverride<float>)(object)val5.scale).value:0.###}"); } } sb.AppendLine(); sb.AppendLine("########## POST-PROCESS VOLUMES + LAYERS"); PostProcessVolume[] array6 = Resources.FindObjectsOfTypeAll<PostProcessVolume>(); Scene scene; ChromaticAberration val8 = default(ChromaticAberration); LensDistortion val9 = default(LensDistortion); foreach (PostProcessVolume val6 in array6) { if ((Object)(object)val6 == (Object)null) { continue; } scene = ((Component)val6).gameObject.scene; if (!((Scene)(ref scene)).IsValid()) { continue; } PostProcessProfile val7 = (((Object)(object)val6.sharedProfile != (Object)null) ? val6.sharedProfile : val6.profile); string text = "-"; string text2 = "-"; if ((Object)(object)val7 != (Object)null) { if (val7.TryGetSettings<ChromaticAberration>(ref val8)) { text = $"{((ParameterOverride<float>)(object)val8.intensity).value:0.##}(ov={((ParameterOverride)val8.intensity).overrideState})"; } if (val7.TryGetSettings<LensDistortion>(ref val9)) { text2 = $"int={((ParameterOverride<float>)(object)val9.intensity).value:0.#},X={((ParameterOverride<float>)(object)val9.intensityX).value:0.##}"; } } sb.AppendLine(string.Format(" VOL '{0}' global={1} prio={2:0.#} layer={3} profile='{4}' CA={5} LD={6}", FullPath(((Component)val6).transform), val6.isGlobal, val6.priority, ((Component)val6).gameObject.layer, ((Object)(object)val7 != (Object)null) ? ((Object)val7).name : "null", text, text2)); } PostProcessLayer[] array7 = Resources.FindObjectsOfTypeAll<PostProcessLayer>(); foreach (PostProcessLayer val10 in array7) { if (!((Object)(object)val10 == (Object)null)) { scene = ((Component)val10).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { sb.AppendLine($" LAYER on '{FullPath(((Component)val10).transform)}' volumeLayer.mask=0x{((LayerMask)(ref val10.volumeLayer)).value:X8}"); } } } } private static void DumpMaterialProps(Material mat, StringBuilder sb) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected I4, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) Shader shader = mat.shader; int propertyCount = shader.GetPropertyCount(); for (int i = 0; i < propertyCount; i++) { string propertyName = shader.GetPropertyName(i); ShaderPropertyType propertyType = shader.GetPropertyType(i); string arg = (int)propertyType switch { 2 => mat.GetFloat(propertyName).ToString("0.###"), 3 => mat.GetFloat(propertyName).ToString("0.###"), 0 => ((object)mat.GetColor(propertyName)/*cast due to .constrained prefix*/).ToString(), 1 => ((object)mat.GetVector(propertyName)/*cast due to .constrained prefix*/).ToString(), 4 => "<tex>", _ => "?", }; sb.AppendLine($" {propertyType} {propertyName} = {arg}"); } } private static string FullPath(Transform t) { string text = ((Object)t).name; while ((Object)(object)t.parent != (Object)null) { t = t.parent; text = ((Object)t).name + "/" + text; } return text; } private static string R(Rect r) { return $"({((Rect)(ref r)).x:0.##},{((Rect)(ref r)).y:0.##},{((Rect)(ref r)).width:0.##},{((Rect)(ref r)).height:0.##})"; } private static void DumpNode(Transform t, int depth, StringBuilder sb) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) string value = new string(' ', depth * 2); RectTransform val = (RectTransform)(object)((t is RectTransform) ? t : null); sb.Append(value); sb.Append(((Component)t).gameObject.activeSelf ? "[+] " : "[-] "); sb.Append(((Object)t).name); if ((Object)(object)val != (Object)null) { sb.Append(" aMin=" + V2(val.anchorMin) + " aMax=" + V2(val.anchorMax) + " pivot=" + V2(val.pivot) + " pos=" + V2(val.anchoredPosition) + " size=" + V2(val.sizeDelta) + " scale=" + V3(((Transform)val).localScale)); } Component[] components = ((Component)t).GetComponents<Component>(); foreach (Component val2 in components) { if ((Object)(object)val2 == (Object)null || val2 is Transform) { continue; } string name = ((object)val2).GetType().Name; CanvasScaler val3 = (CanvasScaler)(object)((val2 is CanvasScaler) ? val2 : null); if (val3 != null) { sb.Append($" {{CanvasScaler mode={val3.uiScaleMode} ref={V2(val3.referenceResolution)}" + $" match={val3.matchWidthOrHeight:0.##} scaleFactor={val3.scaleFactor:0.##}}}"); continue; } Canvas val4 = (Canvas)(object)((val2 is Canvas) ? val2 : null); if (val4 != null && (Object)(object)((Component)val4).transform != (Object)(object)t) { sb.Append($" {{Canvas {val4.renderMode}}}"); } else if (val2 is Image || val2 is RawImage || val2 is Canvas || val2 is CanvasGroup) { sb.Append(" <" + name + ">"); } else { sb.Append(" <" + name + ">"); } } sb.AppendLine(); for (int j = 0; j < t.childCount; j++) { DumpNode(t.GetChild(j), depth + 1, sb); } } private static string V2(Vector2 v) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) return $"({v.x:0.#},{v.y:0.#})"; } private static string V3(Vector3 v) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) return $"({v.x:0.##},{v.y:0.##},{v.z:0.##})"; } } internal static class PostProcessAdjust { private const float BaseAspect = 1.7777778f; private static readonly Dictionary<LensDistortion, float> _baseLensX = new Dictionary<LensDistortion, float>(); private static readonly Dictionary<ChromaticAberration, float> _baseCa = new Dictionary<ChromaticAberration, float>(); private static LensDistortion[]? _lenses; private static ChromaticAberration[]? _aberrations; internal static void Tick(bool enabled) { if (_lenses == null || HasNull<LensDistortion>(_lenses)) { _lenses = Resources.FindObjectsOfTypeAll<LensDistortion>(); } if (_aberrations == null || HasNull<ChromaticAberration>(_aberrations)) { _aberrations = Resources.FindObjectsOfTypeAll<ChromaticAberration>(); } float num = (float)Screen.width / (float)Screen.height; bool flag = enabled && num > 1.7787778f; float num2 = 1.7777778f / num; LensDistortion[] lenses = _lenses; foreach (LensDistortion val in lenses) { if (!((Object)(object)val == (Object)null)) { if (!_baseLensX.TryGetValue(val, out var value)) { value = ((ParameterOverride<float>)(object)val.intensityX).value; _baseLensX[val] = value; } float num3 = (flag ? (value * num2) : value); if (!Mathf.Approximately(((ParameterOverride<float>)(object)val.intensityX).value, num3)) { ((ParameterOverride<float>)(object)val.intensityX).value = num3; ((ParameterOverride)val.intensityX).overrideState = true; } } } ChromaticAberration[] aberrations = _aberrations; foreach (ChromaticAberration val2 in aberrations) { if (!((Object)(object)val2 == (Object)null)) { if (!_baseCa.TryGetValue(val2, out var value2)) { value2 = ((ParameterOverride<float>)(object)val2.intensity).value; _baseCa[val2] = value2; } float num4 = (flag ? (value2 * num2) : value2); if (!Mathf.Approximately(((ParameterOverride<float>)(object)val2.intensity).value, num4)) { ((ParameterOverride<float>)(object)val2.intensity).value = num4; ((ParameterOverride)val2.intensity).overrideState = true; } } } } private static bool HasNull<T>(T[] arr) where T : Object { foreach (T val in arr) { if ((Object)(object)val == (Object)null) { return true; } } return false; } } [HarmonyPatch(typeof(SemiUI), "Start")] internal static class SemiUiStartPatch { private static void Postfix(SemiUI __instance) { UltrawideHud.OffsetHudElement(__instance); } } internal static class UltrawideHud { private const float BaseAspect = 1.7777778f; private static RectTransform? _mainDisplay; private static RawImage? _overlayDisplay; private static RenderTexture? _overlayRt; private static Camera? _hudCamera; private static RectTransform? _gameHud; private static RectTransform? _fade; private static RectTransform? _vignette; private static RectTransform? _video; private static RectTransform? _loading; private static RectTransform? _splash; private static Transform? _tutorial; private static readonly Dictionary<RectTransform, Vector2> _originalSizes = new Dictionary<RectTransform, Vector2>(); private static int _overlayRtBaseHeight; private static int _overlayRtBaseWidth; private static FieldInfo? _texWidthField; private static FieldInfo? _texHeightField; private static float _mainTexBaseWidth; private static bool _wasModified; internal static bool EnabledForPatch; internal static void Tick(bool enabled) { EnabledForPatch = enabled; AcquireReferences(); float num = (float)Screen.width / (float)Screen.height; if (!enabled || num <= 1.7787778f) { if (_wasModified) { Restore(); _wasModified = false; } } else { Apply(num); _wasModified = true; } } private static void AcquireReferences() { if ((Object)(object)_mainDisplay == (Object)null && (Object)(object)RenderTextureMain.instance != (Object)null) { _mainDisplay = ((Component)RenderTextureMain.instance).GetComponent<RectTransform>(); } if ((Object)(object)_overlayDisplay == (Object)null && (Object)(object)RenderTextureMain.instance != (Object)null) { _overlayDisplay = RenderTextureMain.instance.overlayRawImage; } if ((Object)(object)_overlayRt == (Object)null && (Object)(object)_overlayDisplay != (Object)null) { Texture texture = _overlayDisplay.texture; _overlayRt = (RenderTexture?)(object)((texture is RenderTexture) ? texture : null); } if ((Object)(object)_overlayRt != (Object)null && ((Object)(object)_hudCamera == (Object)null || (Object)(object)_hudCamera.targetTexture != (Object)(object)_overlayRt)) { _hudCamera = FindCameraTargeting(_overlayRt); } if ((Object)(object)_gameHud == (Object)null && (Object)(object)HUDCanvas.instance != (Object)null) { Transform obj = ((Component)HUDCanvas.instance).transform.Find("HUD/Game Hud"); _gameHud = (RectTransform?)(object)((obj is RectTransform) ? obj : null); } if ((Object)(object)_fade == (Object)null) { _fade = GetRect((Component?)(object)FindComponent<FadeOverlay>()); } if ((Object)(object)_vignette == (Object)null) { _vignette = GetRect((Component?)(object)FindComponent<HurtVignette>()); } if ((Object)(object)_video == (Object)null) { _video = GetRect((Component?)(object)FindComponent<VideoOverlay>()); } if ((Object)(object)_loading == (Object)null && (Object)(object)LoadingUI.instance != (Object)null) { _loading = ((Component)LoadingUI.instance).GetComponent<RectTransform>(); } if ((Object)(object)_splash == (Object)null) { _splash = GetRect((Component?)(object)FindComponent<SplashScreenUI>()); } if ((Object)(object)_tutorial == (Object)null) { TutorialUI? obj2 = FindComponent<TutorialUI>(); _tutorial = ((obj2 != null) ? ((Component)obj2).transform : null); } } private static void Apply(float aspect) { float factor = aspect / 1.7777778f; if ((Object)(object)_overlayRt != (Object)null) { if (_overlayRtBaseHeight == 0) { _overlayRtBaseHeight = ((Texture)_overlayRt).height; _overlayRtBaseWidth = ((Texture)_overlayRt).width; } int num = Mathf.RoundToInt((float)_overlayRtBaseHeight * aspect); if (((Texture)_overlayRt).width != num || ((Texture)_overlayRt).height != _overlayRtBaseHeight) { ResizeRenderTexture(_overlayRt, num, _overlayRtBaseHeight, _hudCamera); } if ((Object)(object)_hudCamera != (Object)null) { _hudCamera.aspect = (float)((Texture)_overlayRt).width / (float)((Texture)_overlayRt).height; } } FixMainTextureAspect(aspect); if ((Object)(object)_mainDisplay != (Object)null) { SetWidthFill(_mainDisplay, aspect); } if ((Object)(object)_overlayDisplay != (Object)null) { SetWidthFill(((Graphic)_overlayDisplay).rectTransform, aspect); } SetWidthScaled(_gameHud, factor); SetWidthScaled(_fade, factor); SetWidthScaled(_vignette, factor); SetWidthScaled(_video, factor); SetWidthScaled(_loading, factor); SetWidthScaled(_splash, factor); if ((Object)(object)_tutorial != (Object)null) { Transform obj = _tutorial.Find("Tutorial Text Container"); SetWidthScaled((RectTransform?)(object)((obj is RectTransform) ? obj : null), factor); Transform obj2 = _tutorial.Find("Dummy Text Transform"); SetWidthScaled((RectTransform?)(object)((obj2 is RectTransform) ? obj2 : null), factor); } } private static void Restore() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<RectTransform, Vector2> originalSize in _originalSizes) { if ((Object)(object)originalSize.Key != (Object)null) { originalSize.Key.sizeDelta = originalSize.Value; } } RestoreMainTextureAspect(); if ((Object)(object)_overlayRt != (Object)null && _overlayRtBaseHeight != 0 && (((Texture)_overlayRt).width != _overlayRtBaseWidth || ((Texture)_overlayRt).height != _overlayRtBaseHeight)) { ResizeRenderTexture(_overlayRt, _overlayRtBaseWidth, _overlayRtBaseHeight, _hudCamera); if ((Object)(object)_hudCamera != (Object)null) { _hudCamera.aspect = (float)((Texture)_overlayRt).width / (float)((Texture)_overlayRt).height; } } } private static void SetWidthScaled(RectTransform? rt, float factor) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)rt == (Object)null)) { Vector2 val = OriginalSize(rt); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(val.x * factor, val.y); if (rt.sizeDelta != val2) { rt.sizeDelta = val2; } } } private static void SetWidthFill(RectTransform rt, float aspect) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) Vector2 val = OriginalSize(rt); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(val.y * aspect, val.y); if (rt.sizeDelta != val2) { rt.sizeDelta = val2; } } private static Vector2 OriginalSize(RectTransform rt) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) if (!_originalSizes.TryGetValue(rt, out var value)) { value = rt.sizeDelta; _originalSizes[rt] = value; } return value; } private static void FixMainTextureAspect(float aspect) { RenderTextureMain instance = RenderTextureMain.instance; if ((Object)(object)instance == (Object)null) { return; } if (_texWidthField == null) { Type typeFromHandle = typeof(RenderTextureMain); _texWidthField = typeFromHandle.GetField("textureWidthOriginal", BindingFlags.Instance | BindingFlags.NonPublic); _texHeightField = typeFromHandle.GetField("textureHeightOriginal", BindingFlags.Instance | BindingFlags.NonPublic); } if (_texWidthField == null || _texHeightField == null) { return; } float num = (float)_texHeightField.GetValue(instance); float num2 = (float)_texWidthField.GetValue(instance); if (!(num <= 0f)) { if (_mainTexBaseWidth == 0f) { _mainTexBaseWidth = num2; } float num3 = Mathf.Round(num * aspect); if (Mathf.Abs(num2 - num3) > 0.5f) { _texWidthField.SetValue(instance, num3); } } } private static void RestoreMainTextureAspect() { if (_texWidthField == null || _mainTexBaseWidth == 0f) { return; } RenderTextureMain instance = RenderTextureMain.instance; if (!((Object)(object)instance == (Object)null)) { float num = (float)_texWidthField.GetValue(instance); if (Mathf.Abs(num - _mainTexBaseWidth) > 0.5f) { _texWidthField.SetValue(instance, _mainTexBaseWidth); } } } private static void ResizeRenderTexture(RenderTexture rt, int width, int height, Camera? cam) { bool flag = (Object)(object)cam != (Object)null && (Object)(object)cam.targetTexture == (Object)(object)rt; if (flag) { cam.targetTexture = null; } rt.Release(); ((Texture)rt).width = width; ((Texture)rt).height = height; rt.Create(); if (flag) { cam.targetTexture = rt; ((Behaviour)cam).enabled = false; ((Behaviour)cam).enabled = true; } } private static Camera? FindCameraTargeting(RenderTexture rt) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) Camera[] array = Resources.FindObjectsOfTypeAll<Camera>(); foreach (Camera val in array) { if ((Object)(object)val != (Object)null && (Object)(object)val.targetTexture == (Object)(object)rt) { Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { return val; } } } return null; } private static T? FindComponent<T>() where T : Component { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) T[] array = Resources.FindObjectsOfTypeAll<T>(); foreach (T val in array) { if ((Object)(object)val != (Object)null) { Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { return val; } } } return default(T); } private static RectTransform? GetRect(Component? c) { if (!((Object)(object)c != (Object)null)) { return null; } return c.GetComponent<RectTransform>(); } internal static void OffsetHudElement(SemiUI ui) { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) if (!EnabledForPatch || (Object)(object)ui == (Object)null) { return; } float num = (float)Screen.width / (float)Screen.height; if (num <= 1.7787778f || (Object)(object)HUDCanvas.instance == (Object)null) { return; } Transform val = ((Component)HUDCanvas.instance).transform.Find("HUD/Game Hud"); if ((Object)(object)val == (Object)null) { return; } Transform obj = (ui.animateTheEntireObject ? ((Component)ui).transform : ui.textRectTransform); RectTransform val2 = (RectTransform)(object)((obj is RectTransform) ? obj : null); if (!((Object)(object)val2 == (Object)null) && ((Transform)val2).IsChildOf(val)) { float num2 = 200f * (num - 1.7777778f); float num3 = (val2.anchorMin.x - 0.5f) * 2f * num2; if (!Mathf.Approximately(num3, 0f)) { Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(num3, 0f); ui.showPosition += val3; ui.hidePosition += val3; } } } } }