using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UIElements;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("FM26UltrawideFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+50aa5e2acebab9d6eec3c515597d60b6b388b84b")]
[assembly: AssemblyProduct("FM26UltrawideFix")]
[assembly: AssemblyTitle("FM26UltrawideFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NativeIntegerAttribute : Attribute
{
public readonly bool[] TransformFlags;
public NativeIntegerAttribute()
{
TransformFlags = new bool[1] { true };
}
public NativeIntegerAttribute(bool[] P_0)
{
TransformFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.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 FM26UltrawideFix
{
public class PanelScaler : MonoBehaviour
{
private bool _resolutionApplied;
private int _cameraPollFrame;
private int _uiExpandFrame;
private static float _lastHeightRatio = 1f;
private static float _lastRefResWidth = 0f;
private static readonly HashSet<string> s_skipExact = new HashSet<string>();
private static readonly List<string> s_skipPrefixes = new List<string>();
private static readonly List<string> s_expansionLog = new List<string>();
private static readonly List<string> s_skipLog = new List<string>();
private static readonly Dictionary<long, float> s_tileOriginalWidths = new Dictionary<long, float>();
private static readonly Dictionary<long, float> s_tileOriginalLefts = new Dictionary<long, float>();
private int _veDumpFrame;
public PanelScaler(nint ptr)
: base((IntPtr)ptr)
{
}
private void Start()
{
ForceResolution();
if (Plugin.DiagnosticDump.Value)
{
SceneManager.sceneLoaded += UnityAction<Scene, LoadSceneMode>.op_Implicit((Action<Scene, LoadSceneMode>)OnSceneLoaded);
}
}
private void Update()
{
if (!_resolutionApplied)
{
ForceResolution();
}
}
private void LateUpdate()
{
if (Plugin.PatchMatchCamera.Value)
{
FixCameraAspects();
}
if (++_uiExpandFrame >= 30)
{
_uiExpandFrame = 0;
ExpandUIDocumentRoots();
}
if (Plugin.DiagnosticDump.Value)
{
RunDiagnostics();
}
}
private void ForceResolution()
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Expected O, but got Unknown
int value = Plugin.TargetWidth.Value;
int value2 = Plugin.TargetHeight.Value;
if (value <= 0 || value2 <= 0)
{
_resolutionApplied = true;
return;
}
if (Screen.width == value && Screen.height == value2)
{
_resolutionApplied = true;
return;
}
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(28, 4, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Setting resolution ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(value);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("x");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(value2);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (was ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(Screen.width);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("x");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(Screen.height);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
}
log.LogInfo(val);
Screen.SetResolution(value, value2, (FullScreenMode)1);
_resolutionApplied = true;
}
private void FixCameraAspects()
{
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Expected O, but got Unknown
if (++_cameraPollFrame < 30)
{
return;
}
_cameraPollFrame = 0;
float num = (float)Screen.width / (float)Screen.height;
bool flag = default(bool);
foreach (Camera item in (Il2CppArrayBase<Camera>)(object)Camera.allCameras)
{
if (!((Object)(object)item == (Object)null) && !(Math.Abs(item.aspect - num) < 0.005f))
{
if (!item.orthographic && item.aspect > 0f)
{
float num2 = item.fieldOfView * ((float)Math.PI / 180f);
float num3 = 2f * (float)Math.Atan(Math.Tan(num2 / 2f) * (double)(item.aspect / num));
item.fieldOfView = num3 * 57.29578f;
}
item.aspect = num;
ManualLogSource log = Plugin.Log;
BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(19, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Camera '");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)item).name);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' aspect → ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(num, "F4");
}
log.LogDebug(val);
}
}
}
internal static void ApplyScaling(PanelSettings settings)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)settings == (Object)null)
{
return;
}
float num = Screen.width;
float num2 = Screen.height;
Vector2Int referenceResolution = settings.referenceResolution;
if (!((float)((Vector2Int)(ref referenceResolution)).x <= 0f) && !((float)((Vector2Int)(ref referenceResolution)).y <= 0f))
{
float num3 = num / num2;
float num4 = (float)((Vector2Int)(ref referenceResolution)).x / (float)((Vector2Int)(ref referenceResolution)).y;
if (!(num3 <= num4 + 0.01f))
{
float scale = (_lastHeightRatio = num2 / (float)((Vector2Int)(ref referenceResolution)).y);
_lastRefResWidth = ((Vector2Int)(ref referenceResolution)).x;
settings.scaleMode = (PanelScaleMode)0;
settings.scale = scale;
}
}
}
private static void RefreshSkipNames()
{
s_skipExact.Clear();
s_skipPrefixes.Clear();
string[] array = (Plugin.SkipExpansionElements?.Value ?? "").Split(',');
for (int i = 0; i < array.Length; i++)
{
string text = array[i].Trim();
if (text.Length != 0)
{
if (text.EndsWith("*"))
{
s_skipPrefixes.Add(text.Substring(0, text.Length - 1));
}
else
{
s_skipExact.Add(text);
}
}
}
}
private static bool IsSkipped(string name)
{
return false;
}
private static void ExpandUIDocumentRoots()
{
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Expected O, but got Unknown
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Expected O, but got Unknown
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Expected O, but got Unknown
if ((float)Screen.width / (float)Screen.height < 1.9f)
{
return;
}
RefreshSkipNames();
bool value = Plugin.LogExpansions.Value;
bool value2 = Plugin.LogSkipped.Value;
if (value)
{
s_expansionLog.Clear();
}
if (value2)
{
s_skipLog.Clear();
}
float threshold = (float)Screen.width / _lastHeightRatio * 0.4f;
UIDocument[] array = null;
bool flag = default(bool);
try
{
array = Il2CppArrayBase<UIDocument>.op_Implicit(Object.FindObjectsOfType<UIDocument>());
UIDocument[] array2 = array;
foreach (UIDocument val in array2)
{
if (!((Object)(object)val == (Object)null))
{
VisualElement rootVisualElement = val.rootVisualElement;
if (rootVisualElement != null)
{
ExpandElement(rootVisualElement, 0, threshold);
}
}
}
}
catch (Exception ex)
{
ManualLogSource log = Plugin.Log;
BepInExDebugLogInterpolatedStringHandler val2 = new BepInExDebugLogInterpolatedStringHandler(37, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[PanelScaler] ExpandUIDocumentRoots: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
}
log.LogDebug(val2);
}
if (array != null)
{
try
{
UIDocument[] array2 = array;
foreach (UIDocument val3 in array2)
{
if (!((Object)(object)val3 == (Object)null))
{
VisualElement rootVisualElement2 = val3.rootVisualElement;
if (rootVisualElement2 != null)
{
ExpandCardTemplates(rootVisualElement2, 0);
}
}
}
}
catch (Exception ex2)
{
ManualLogSource log2 = Plugin.Log;
BepInExDebugLogInterpolatedStringHandler val2 = new BepInExDebugLogInterpolatedStringHandler(35, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[PanelScaler] ExpandCardTemplates: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex2.Message);
}
log2.LogDebug(val2);
}
}
if (array != null)
{
try
{
UIDocument[] array2 = array;
foreach (UIDocument val4 in array2)
{
if (!((Object)(object)val4 == (Object)null))
{
VisualElement rootVisualElement3 = val4.rootVisualElement;
if (rootVisualElement3 != null)
{
ScanForGridLayouts(rootVisualElement3, 0);
}
}
}
}
catch (Exception ex3)
{
ManualLogSource log3 = Plugin.Log;
BepInExDebugLogInterpolatedStringHandler val2 = new BepInExDebugLogInterpolatedStringHandler(34, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[PanelScaler] ScanForGridLayouts: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex3.Message);
}
log3.LogDebug(val2);
}
}
if (value && s_expansionLog.Count > 0)
{
Plugin.Log.LogInfo((object)("[EXP] " + string.Join(" | ", s_expansionLog)));
}
if (value2 && s_skipLog.Count > 0)
{
Plugin.Log.LogInfo((object)("[SKIP] " + string.Join(" | ", s_skipLog)));
}
}
private static void ExpandElement(VisualElement ve, int depth, float threshold, bool skipExpansion = false)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
//IL_0203: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_021e: Unknown result type (might be due to invalid IL or missing references)
//IL_0223: Unknown result type (might be due to invalid IL or missing references)
if (ve == null || depth > 100)
{
return;
}
bool skipExpansion2 = skipExpansion;
if (!skipExpansion)
{
if (depth <= 1)
{
ForceFullWidth(ve);
if (depth == 0)
{
ve.style.height = new StyleLength(new Length(100f, (LengthUnit)1));
}
if (Plugin.LogExpansions.Value)
{
s_expansionLog.Add($"d={depth} \"{ve.name ?? "(null)"}\" forced");
}
if (ve.name != null && IsSkipped(ve.name))
{
skipExpansion2 = true;
if (Plugin.LogSkipped.Value)
{
s_skipLog.Add($"d={depth} \"{ve.name}\" skip-list[no-recurse]");
}
}
}
else if (ve.name != null && IsSkipped(ve.name))
{
skipExpansion2 = true;
if (Plugin.LogSkipped.Value && depth <= 8)
{
s_skipLog.Add($"d={depth} \"{ve.name}\" skip-list");
}
}
else
{
float num = TryGetLayoutWidth(ve);
bool flag = ParentIsRowFlex(ve);
if (num >= threshold && !flag)
{
ve.style.maxWidth = StyleLength.op_Implicit((StyleKeyword)3);
ve.style.width = new StyleLength(new Length(100f, (LengthUnit)1));
ve.style.marginLeft = new StyleLength(new Length(0f, (LengthUnit)0));
ve.style.marginRight = new StyleLength(new Length(0f, (LengthUnit)0));
if (Plugin.LogExpansions.Value)
{
s_expansionLog.Add($"d={depth} \"{ve.name ?? "(null)"}\" w={num:F0}");
}
}
else if (Plugin.LogSkipped.Value && depth <= 8 && !string.IsNullOrEmpty(ve.name))
{
string value = ((num < 0f) ? "w=unknown" : (flag ? $"row-flex w={num:F0}" : $"w={num:F0}<thr={threshold:F0}"));
s_skipLog.Add($"d={depth} \"{ve.name}\" {value}");
}
}
}
for (int i = 0; i < ve.childCount; i++)
{
ExpandElement(ve[i], depth + 1, threshold, skipExpansion2);
}
}
private static void ExpandCardTemplates(VisualElement ve, int depth)
{
if (ve == null || depth > 50)
{
return;
}
if (LooksLikeCardTemplate(ve))
{
float pixelWidth = ((_lastHeightRatio > 0f) ? ((float)Screen.width / _lastHeightRatio) : ((float)Screen.width));
ApplyExplicitWidth(ve, pixelWidth);
for (int i = 0; i < ve.childCount; i++)
{
VisualElement val = ve[i];
if (val != null)
{
ApplyExplicitWidth(val, pixelWidth);
}
}
}
else
{
for (int j = 0; j < ve.childCount; j++)
{
ExpandCardTemplates(ve[j], depth + 1);
}
}
}
private static bool LooksLikeCardTemplate(VisualElement ve)
{
if (ve.childCount < 2)
{
return false;
}
for (int i = 0; i < ve.childCount; i++)
{
VisualElement val = ve[i];
if (val != null && val.name == "Border")
{
return true;
}
}
return false;
}
private static void ApplyExplicitWidth(VisualElement ve, float pixelWidth)
{
//IL_000c: 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_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_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: 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_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
try
{
ve.style.paddingLeft = new StyleLength(new Length(0f, (LengthUnit)0));
ve.style.paddingRight = new StyleLength(new Length(0f, (LengthUnit)0));
ve.style.marginLeft = new StyleLength(new Length(0f, (LengthUnit)0));
ve.style.marginRight = new StyleLength(new Length(0f, (LengthUnit)0));
ve.style.width = new StyleLength(new Length(pixelWidth, (LengthUnit)0));
ve.style.maxWidth = StyleLength.op_Implicit((StyleKeyword)3);
ve.style.overflow = StyleEnum<Overflow>.op_Implicit((Overflow)0);
}
catch
{
}
}
private static void ScanForGridLayouts(VisualElement ve, int depth)
{
if (ve != null && depth <= 35)
{
if (ve.name == "GridLayoutElementContent")
{
ScaleGridTiles(ve);
}
for (int i = 0; i < ve.childCount; i++)
{
ScanForGridLayouts(ve[i], depth + 1);
}
}
}
private static void ScaleGridTiles(VisualElement container)
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Invalid comparison between Unknown and I4
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: 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_011d: 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_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_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_01de: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_020a: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_024f: Unknown result type (might be due to invalid IL or missing references)
//IL_0254: Unknown result type (might be due to invalid IL or missing references)
//IL_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_0235: Unknown result type (might be due to invalid IL or missing references)
if (_lastRefResWidth <= 0f || _lastHeightRatio <= 0f)
{
return;
}
float num = (float)Screen.width / _lastHeightRatio / _lastRefResWidth;
if (num < 1.05f)
{
return;
}
VisualElement val = null;
float num2 = 0f;
Length value;
for (int i = 0; i < container.childCount; i++)
{
VisualElement val2 = container[i];
if (val2 == null)
{
continue;
}
try
{
StyleLength width = val2.style.width;
if ((int)((StyleLength)(ref width)).keyword != 0)
{
continue;
}
value = ((StyleLength)(ref width)).value;
if ((int)((Length)(ref value)).unit == 1 && val == null)
{
val = val2;
continue;
}
value = ((StyleLength)(ref width)).value;
if ((int)((Length)(ref value)).unit == 0)
{
value = ((StyleLength)(ref width)).value;
if (((Length)(ref value)).value > num2)
{
value = ((StyleLength)(ref width)).value;
num2 = ((Length)(ref value)).value;
}
}
}
catch
{
}
}
if (val != null)
{
return;
}
for (int j = 0; j < container.childCount; j++)
{
VisualElement val3 = container[j];
if (val3 == null)
{
continue;
}
try
{
long key = ((Il2CppObjectBase)val3).Pointer.ToInt64();
StyleLength width2 = val3.style.width;
if ((int)((StyleLength)(ref width2)).keyword == 0)
{
value = ((StyleLength)(ref width2)).value;
if ((int)((Length)(ref value)).unit == 0)
{
value = ((StyleLength)(ref width2)).value;
if (((Length)(ref value)).value > 0f)
{
float num3;
if (!s_tileOriginalWidths.TryGetValue(key, out var value2))
{
value = ((StyleLength)(ref width2)).value;
num3 = ((Length)(ref value)).value;
}
else
{
num3 = value2;
}
float num4 = num3;
if (!s_tileOriginalWidths.ContainsKey(key))
{
Dictionary<long, float> dictionary = s_tileOriginalWidths;
value = ((StyleLength)(ref width2)).value;
dictionary[key] = ((Length)(ref value)).value;
}
val3.style.width = new StyleLength(new Length(num4 * num, (LengthUnit)0));
}
}
}
StyleLength left = val3.style.left;
if ((int)((StyleLength)(ref left)).keyword != 0)
{
continue;
}
value = ((StyleLength)(ref left)).value;
if ((int)((Length)(ref value)).unit != 0)
{
continue;
}
value = ((StyleLength)(ref left)).value;
if (((Length)(ref value)).value > 0f)
{
float num5;
if (!s_tileOriginalLefts.TryGetValue(key, out var value3))
{
value = ((StyleLength)(ref left)).value;
num5 = ((Length)(ref value)).value;
}
else
{
num5 = value3;
}
float num6 = num5;
if (!s_tileOriginalLefts.ContainsKey(key))
{
Dictionary<long, float> dictionary2 = s_tileOriginalLefts;
value = ((StyleLength)(ref left)).value;
dictionary2[key] = ((Length)(ref value)).value;
}
val3.style.left = new StyleLength(new Length(num6 * num, (LengthUnit)0));
}
}
catch
{
}
}
}
private static bool ParentIsRowFlex(VisualElement ve)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Invalid comparison between Unknown and I4
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//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_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Invalid comparison between Unknown and I4
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
try
{
VisualElement parent = ve.parent;
if (parent == null)
{
return false;
}
return (int)parent.resolvedStyle.flexDirection == 2;
}
catch
{
}
try
{
VisualElement parent2 = ve.parent;
if (parent2 == null)
{
return false;
}
StyleEnum<FlexDirection> flexDirection = parent2.style.flexDirection;
if ((int)flexDirection.keyword == 0)
{
return (int)flexDirection.value == 2;
}
}
catch
{
}
try
{
VisualElement parent3 = ve.parent;
if (parent3 == null)
{
return false;
}
Rect layout = ve.layout;
float y = ((Rect)(ref layout)).y;
long num = ((Il2CppObjectBase)ve).Pointer.ToInt64();
for (int i = 0; i < parent3.childCount; i++)
{
VisualElement val = parent3[i];
if (val == null || ((Il2CppObjectBase)val).Pointer.ToInt64() == num)
{
continue;
}
layout = val.layout;
if (!(((Rect)(ref layout)).width <= 1f))
{
layout = val.layout;
if (Math.Abs(((Rect)(ref layout)).y - y) < 2f)
{
return true;
}
}
}
}
catch
{
}
return false;
}
private static float TryGetLayoutWidth(VisualElement ve)
{
//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_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: 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_0081: 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)
try
{
Rect layout = ve.layout;
float width = ((Rect)(ref layout)).width;
if (!float.IsNaN(width) && width > 0f)
{
return width;
}
}
catch
{
}
try
{
float width2 = ve.resolvedStyle.width;
if (!float.IsNaN(width2) && width2 > 0f)
{
return width2;
}
}
catch
{
}
try
{
StyleLength width3 = ve.style.width;
if ((int)((StyleLength)(ref width3)).keyword == 0)
{
Length value = ((StyleLength)(ref width3)).value;
if ((int)((Length)(ref value)).unit == 0)
{
value = ((StyleLength)(ref width3)).value;
if (((Length)(ref value)).value > 0f)
{
value = ((StyleLength)(ref width3)).value;
return ((Length)(ref value)).value;
}
}
}
}
catch
{
}
return -1f;
}
private static void ForceFullWidth(VisualElement ve)
{
//IL_000c: 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_0022: Unknown result type (might be due to invalid IL or missing references)
//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_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
ve.style.width = new StyleLength(new Length(100f, (LengthUnit)1));
ve.style.maxWidth = StyleLength.op_Implicit((StyleKeyword)3);
ve.style.marginLeft = new StyleLength(new Length(0f, (LengthUnit)0));
ve.style.marginRight = new StyleLength(new Length(0f, (LengthUnit)0));
}
private void RunDiagnostics()
{
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Expected O, but got Unknown
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected O, but got Unknown
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Expected O, but got Unknown
if (++_veDumpFrame < 300)
{
return;
}
_veDumpFrame = 0;
Plugin.Log.LogInfo((object)"=== VE hierarchy dump (UIDocuments) ===");
bool flag = default(bool);
try
{
Il2CppArrayBase<UIDocument> val = Object.FindObjectsOfType<UIDocument>();
ManualLogSource log = Plugin.Log;
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(20, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" UIDocument count: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(val.Length);
}
log.LogInfo(val2);
foreach (UIDocument item in val)
{
if (!((Object)(object)item == (Object)null))
{
ManualLogSource log2 = Plugin.Log;
val2 = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" [UIDocument] GO=");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)((Component)item).gameObject).name);
}
log2.LogInfo(val2);
VisualElement rootVisualElement = item.rootVisualElement;
if (rootVisualElement != null)
{
DumpVE(rootVisualElement, 0, 25);
}
}
}
}
catch (Exception ex)
{
ManualLogSource log3 = Plugin.Log;
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(17, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" VE dump error: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
}
log3.LogInfo(val2);
}
Plugin.Log.LogInfo((object)"=== end VE dump ===");
}
private static void DumpVE(VisualElement ve, int depth, int maxDepth)
{
//IL_038c: Unknown result type (might be due to invalid IL or missing references)
//IL_0393: Expected O, but got Unknown
//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_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Invalid comparison between Unknown and I4
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
//IL_02ae: Invalid comparison between Unknown and I4
//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
//IL_02f1: Invalid comparison between Unknown and I4
//IL_0337: Unknown result type (might be due to invalid IL or missing references)
//IL_033c: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: 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_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Invalid comparison between Unknown and I4
//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
//IL_0310: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Invalid comparison between Unknown and I4
if (ve == null || depth > maxDepth)
{
return;
}
string text = new string(' ', depth * 2);
float num = -1f;
float num2 = -1f;
float num3 = -1f;
try
{
num = ve.resolvedStyle.width;
}
catch
{
}
Rect layout;
try
{
layout = ve.layout;
num2 = ((Rect)(ref layout)).width;
}
catch
{
}
try
{
layout = ve.layout;
num3 = ((Rect)(ref layout)).x;
}
catch
{
}
string text2 = "(none)";
try
{
StyleLength width = ve.style.width;
string text3;
if ((int)((StyleLength)(ref width)).keyword != 0)
{
StyleKeyword keyword = ((StyleLength)(ref width)).keyword;
text3 = ((object)(StyleKeyword)(ref keyword)).ToString();
}
else
{
DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(0, 2);
Length value = ((StyleLength)(ref width)).value;
defaultInterpolatedStringHandler.AppendFormatted(((Length)(ref value)).value);
value = ((StyleLength)(ref width)).value;
defaultInterpolatedStringHandler.AppendFormatted<LengthUnit>(((Length)(ref value)).unit);
text3 = defaultInterpolatedStringHandler.ToStringAndClear();
}
text2 = text3;
}
catch
{
}
float num4 = -1f;
float num5 = -1f;
try
{
num4 = ve.resolvedStyle.paddingLeft;
}
catch
{
}
try
{
num5 = ve.resolvedStyle.paddingRight;
}
catch
{
}
string text4 = ((num4 > 0f || num5 > 0f) ? $" pad={num4:F0}/{num5:F0}" : "");
string text5 = "";
try
{
FlexDirection flexDirection = ve.resolvedStyle.flexDirection;
if ((int)flexDirection == 2 || (int)flexDirection == 3)
{
text5 = " flex=row";
}
}
catch
{
}
string text6 = "";
try
{
if ((int)ve.resolvedStyle.position == 1)
{
text6 = " abs";
}
}
catch
{
}
string text7 = "";
StyleFloat val;
try
{
val = ve.resolvedStyle.maxWidth;
float value2 = ((StyleFloat)(ref val)).value;
if (value2 > 0f && value2 < 9999f)
{
text7 = $" max={value2:F0}";
}
}
catch
{
}
string text8 = "";
try
{
float borderLeftWidth = ve.resolvedStyle.borderLeftWidth;
float borderRightWidth = ve.resolvedStyle.borderRightWidth;
if (borderLeftWidth > 0f || borderRightWidth > 0f)
{
text8 = $" bord={borderLeftWidth:F0}/{borderRightWidth:F0}";
}
}
catch
{
}
string text9 = "";
try
{
Align alignItems = ve.resolvedStyle.alignItems;
if ((int)alignItems != 4 && (int)alignItems != 0)
{
text9 = $" ai={alignItems}";
}
}
catch
{
}
try
{
Align alignSelf = ve.resolvedStyle.alignSelf;
if ((int)alignSelf != 4 && (int)alignSelf != 0)
{
text9 += $" as={alignSelf}";
}
}
catch
{
}
string text10 = "";
try
{
val = ve.resolvedStyle.minWidth;
float value3 = ((StyleFloat)(ref val)).value;
if (value3 > 0f)
{
text10 = $" min={value3:F0}";
}
}
catch
{
}
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(47, 15, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(depth);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] name=");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ve.name ?? "(null)");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("children=");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(ve.childCount);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("resolved=");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(num, "F0");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" layout=");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(num2, "F0");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" x=");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(num3, "F0");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" inline=");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text2);
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text4);
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text5);
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text6);
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text7);
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text8);
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text9);
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text10);
}
log.LogInfo(val2);
for (int i = 0; i < ve.childCount; i++)
{
DumpVE(ve[i], depth + 1, maxDepth);
}
}
private static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Expected O, but got Unknown
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(32, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("=== Scene loaded: '");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Scene)(ref scene)).name);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' (mode=");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<LoadSceneMode>(mode);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") ===");
}
log.LogInfo(val);
foreach (GameObject item in (Il2CppArrayBase<GameObject>)(object)((Scene)(ref scene)).GetRootGameObjects())
{
Il2CppArrayBase<Component> components = item.GetComponents<Component>();
StringBuilder stringBuilder = new StringBuilder();
foreach (Component item2 in components)
{
if (stringBuilder.Length > 0)
{
stringBuilder.Append(", ");
}
try
{
stringBuilder.Append(((object)item2).GetType().Name);
}
catch
{
stringBuilder.Append("?");
}
}
ManualLogSource log2 = Plugin.Log;
val = new BepInExInfoLogInterpolatedStringHandler(11, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" GO: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)item).name);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" | ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<StringBuilder>(stringBuilder);
}
log2.LogInfo(val);
}
}
}
[BepInPlugin("com.fm26ultrawidefix", "FM26 Ultrawide Fix", "1.0.0")]
public class Plugin : BasePlugin
{
internal static ManualLogSource Log;
public static ConfigEntry<bool> Enabled;
public static ConfigEntry<int> TargetWidth;
public static ConfigEntry<int> TargetHeight;
public static ConfigEntry<bool> PatchMatchCamera;
public static ConfigEntry<bool> DiagnosticDump;
public static ConfigEntry<bool> LogExpansions;
public static ConfigEntry<bool> LogSkipped;
public static ConfigEntry<string> SkipExpansionElements;
public override void Load()
{
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Expected O, but got Unknown
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Expected O, but got Unknown
Log = ((BasePlugin)this).Log;
Enabled = ((BasePlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable ultrawide fix");
TargetWidth = ((BasePlugin)this).Config.Bind<int>("Resolution", "Width", 0, "Override width (0 = auto-detect from primary display)");
TargetHeight = ((BasePlugin)this).Config.Bind<int>("Resolution", "Height", 0, "Override height (0 = auto-detect from primary display)");
PatchMatchCamera = ((BasePlugin)this).Config.Bind<bool>("Patches", "PatchMatchCamera", true, "Correct aspect ratio on match-engine cameras");
SkipExpansionElements = ((BasePlugin)this).Config.Bind<string>("Patches", "SkipExpansionElements", "ModalDialog,GenericModalDialog,Card,ExternalNewsDynamicCard", "Comma-separated element names whose subtrees are excluded from width expansion. Enable DiagnosticDump to find names, then add problem elements here.");
DiagnosticDump = ((BasePlugin)this).Config.Bind<bool>("Debug", "DiagnosticDump", false, "Log all root GameObjects and components on scene load");
LogExpansions = ((BasePlugin)this).Config.Bind<bool>("Debug", "LogExpansions", false, "Log every element our code expands each cycle — use to identify elements being incorrectly widened");
LogSkipped = ((BasePlugin)this).Config.Bind<bool>("Debug", "LogSkipped", false, "Log named elements that were NOT expanded and why (skip-list / unreadable / below-threshold / row-flex)");
if (!Enabled.Value)
{
Log.LogInfo((object)"FM26 Ultrawide Fix disabled via config.");
return;
}
try
{
Harmony.CreateAndPatchAll(typeof(UltrawidePatches), "com.fm26ultrawidefix");
Log.LogInfo((object)"Harmony patches applied.");
}
catch (Exception ex)
{
ManualLogSource log = Log;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(25, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Harmony patching failed: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
}
log.LogError(val);
}
ClassInjector.RegisterTypeInIl2Cpp<PanelScaler>();
GameObject val2 = new GameObject("FM26UltrawideFix_PanelScaler");
Object.DontDestroyOnLoad((Object)val2);
val2.AddComponent<PanelScaler>();
Log.LogInfo((object)"FM26 Ultrawide Fix loaded.");
}
}
[HarmonyPatch]
internal static class UltrawidePatches
{
[HarmonyPatch(typeof(PanelSettings), "ApplyPanelSettings")]
[HarmonyPostfix]
private static void PanelSettings_ApplyPanelSettings_Postfix(PanelSettings __instance)
{
PanelScaler.ApplyScaling(__instance);
}
[HarmonyPatch(typeof(Screen), "SetResolution", new Type[]
{
typeof(int),
typeof(int),
typeof(FullScreenMode)
})]
[HarmonyPrefix]
private static void Screen_SetResolution_Prefix(ref int width, ref int height, ref FullScreenMode fullscreenMode)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
int value = Plugin.TargetWidth.Value;
int value2 = Plugin.TargetHeight.Value;
if (value > 0 && value2 > 0 && (width != value || height != value2))
{
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(40, 4, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Intercepted SetResolution(");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(width);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("x");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(height);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") → forcing ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(value);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("x");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(value2);
}
log.LogDebug(val);
width = value;
height = value2;
fullscreenMode = (FullScreenMode)1;
}
}
}
}