mirror of
https://github.com/NuclearPowered/Reactor.git
synced 2026-10-20 01:46:21 +00:00
2021.3.5
This commit is contained in:
1 parent
e9896edd07
commit
62892456d8
11 files changed
+15
-406
No files matched your search
+4
-4
@@ -1,20 +1,20 @@
|
|||||||
<Project>
|
<Project>
|
||||||
<PropertyGroup Condition="'$(GamePlatform)' == 'Steam'">
|
<PropertyGroup Condition="'$(GamePlatform)' == 'Steam'">
|
||||||
<GameVersion>2020.12.9s</GameVersion>
|
<GameVersion>2021.3.5s</GameVersion>
|
||||||
<DefineConstants>$(DefineConstants);STEAM</DefineConstants>
|
<DefineConstants>$(DefineConstants);STEAM</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(GamePlatform)' == 'Itch'">
|
<PropertyGroup Condition="'$(GamePlatform)' == 'Itch'">
|
||||||
<GameVersion>2020.11.17i</GameVersion>
|
<GameVersion>2021.3.5i</GameVersion>
|
||||||
<DefineConstants>$(DefineConstants);ITCH</DefineConstants>
|
<DefineConstants>$(DefineConstants);ITCH</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Mappings>NuclearPowered/Mappings:0.1.1</Mappings>
|
<Mappings>NuclearPowered/Mappings:0.2.0</Mappings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Reactor.OxygenFilter.MSBuild" Version="0.2.4" />
|
<PackageReference Include="Reactor.OxygenFilter.MSBuild" Version="0.2.9" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="Copy" AfterTargets="Reobfuscate">
|
<Target Name="Copy" AfterTargets="Reobfuscate">
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using BepInEx;
|
|||||||
using BepInEx.IL2CPP;
|
using BepInEx.IL2CPP;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using Hazel;
|
using Hazel;
|
||||||
|
using InnerNet;
|
||||||
using Reactor.Net;
|
using Reactor.Net;
|
||||||
|
|
||||||
namespace Reactor
|
namespace Reactor
|
||||||
@@ -45,7 +46,6 @@ namespace Reactor
|
|||||||
public void UnsafeSend(InnerNetObject netObject, object data, bool immediately = false, int targetClientId = -1)
|
public void UnsafeSend(InnerNetObject netObject, object data, bool immediately = false, int targetClientId = -1)
|
||||||
{
|
{
|
||||||
if (netObject == null) throw new ArgumentNullException(nameof(netObject));
|
if (netObject == null) throw new ArgumentNullException(nameof(netObject));
|
||||||
if (data == null) throw new ArgumentNullException(nameof(data));
|
|
||||||
|
|
||||||
if (Id == null)
|
if (Id == null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ using UnityEngine;
|
|||||||
using UnityEngine.Events;
|
using UnityEngine.Events;
|
||||||
using UnityEngine.Networking;
|
using UnityEngine.Networking;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
using Object = UnityEngine.Object;
|
using Il2CppType = UnhollowerRuntimeLib.Il2CppType;
|
||||||
|
|
||||||
namespace Reactor.Extensions
|
namespace Reactor.Extensions
|
||||||
{
|
{
|
||||||
@@ -18,18 +18,6 @@ namespace Reactor.Extensions
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static class Extensions
|
public static class Extensions
|
||||||
{
|
{
|
||||||
[Obsolete]
|
|
||||||
public static T DontDestroy<T>(T obj) where T : Object
|
|
||||||
{
|
|
||||||
return UnityObjectExtensions.DontDestroy(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Obsolete]
|
|
||||||
public static T DontUnload<T>(T obj) where T : Object
|
|
||||||
{
|
|
||||||
return UnityObjectExtensions.DontUnload(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds a delegate to get one notification when a scene has loaded.
|
/// Adds a delegate to get one notification when a scene has loaded.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -122,16 +110,9 @@ namespace Reactor.Extensions
|
|||||||
return type.GetMethods(AccessTools.all).Where(x => x.ReturnType == returnType && x.GetParameters().Select(x => x.ParameterType).SequenceEqual(parameterTypes));
|
return type.GetMethods(AccessTools.all).Where(x => x.ReturnType == returnType && x.GetParameters().Select(x => x.ParameterType).SequenceEqual(parameterTypes));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Obsolete("Use Rpc<TCustomRpc>.Instance.Send", true)]
|
public static T LoadAsset<T>(this AssetBundle assetBundle, string name) where T : UnityEngine.Object
|
||||||
public static void Send<TCustomRpc>(this InnerNetObject netObject, object data, bool immediately = false) where TCustomRpc : UnsafeCustomRpc
|
|
||||||
{
|
{
|
||||||
Rpc<TCustomRpc>.Instance.UnsafeSend(netObject, data, immediately);
|
return assetBundle.LoadAsset(name, Il2CppType.Of<T>())?.Cast<T>();
|
||||||
}
|
|
||||||
|
|
||||||
[Obsolete("Use Rpc<TCustomRpc>.Instance.SendTo", true)]
|
|
||||||
public static void SendTo<TCustomRpc>(this InnerNetObject netObject, int targetId, object data) where TCustomRpc : UnsafeCustomRpc
|
|
||||||
{
|
|
||||||
Rpc<TCustomRpc>.Instance.UnsafeSend(netObject, data, true, targetId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@ using System.Reflection;
|
|||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using Hazel;
|
using Hazel;
|
||||||
using Hazel.Udp;
|
using Hazel.Udp;
|
||||||
|
using InnerNet;
|
||||||
using Reactor.Extensions;
|
using Reactor.Extensions;
|
||||||
using Reactor.Net;
|
using Reactor.Net;
|
||||||
using UnhollowerBaseLib;
|
using UnhollowerBaseLib;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace Reactor.Patches
|
|||||||
|
|
||||||
TextRendererExtensions.Prefab ??= new TextRendererPrefab(original.gameObject.GetComponentInChildren<TextRenderer>());
|
TextRendererExtensions.Prefab ??= new TextRendererPrefab(original.gameObject.GetComponentInChildren<TextRenderer>());
|
||||||
|
|
||||||
var gameObject = new GameObject("ReactorVersion");
|
var gameObject = new GameObject("ReactorVersion " + Guid.NewGuid());
|
||||||
gameObject.transform.parent = original.transform.parent;
|
gameObject.transform.parent = original.transform.parent;
|
||||||
|
|
||||||
var aspectPosition = gameObject.AddComponent<AspectPosition>();
|
var aspectPosition = gameObject.AddComponent<AspectPosition>();
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace Reactor.Patches
|
|||||||
{
|
{
|
||||||
Watcher = new FileSystemWatcher(
|
Watcher = new FileSystemWatcher(
|
||||||
string.IsNullOrEmpty(Application.persistentDataPath) ? Directory.GetCurrentDirectory() : Application.persistentDataPath,
|
string.IsNullOrEmpty(Application.persistentDataPath) ? Directory.GetCurrentDirectory() : Application.persistentDataPath,
|
||||||
"regionInfo.dat"
|
"regionInfo.json"
|
||||||
);
|
);
|
||||||
|
|
||||||
Watcher.Changed += (s, e) =>
|
Watcher.Changed += (s, e) =>
|
||||||
|
|||||||
@@ -10,15 +10,7 @@ namespace Reactor
|
|||||||
|
|
||||||
public static T Instance
|
public static T Instance
|
||||||
{
|
{
|
||||||
get
|
get => _instance ??= IL2CPPChainloader.Instance.Plugins.Values.Select(x => x.Instance).OfType<T>().Single();
|
||||||
{
|
|
||||||
if (_instance == null)
|
|
||||||
{
|
|
||||||
_instance = IL2CPPChainloader.Instance.Plugins.Values.Select(x => x.Instance).OfType<T>().Single();
|
|
||||||
}
|
|
||||||
|
|
||||||
return _instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,77 +0,0 @@
|
|||||||
// https://github.com/sinai-dev/UnityExplorer/blob/master/src/Unstrip/AssetBundleUnstrip.cs
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using UnhollowerBaseLib;
|
|
||||||
using UnhollowerRuntimeLib;
|
|
||||||
|
|
||||||
namespace Reactor.Unstrip
|
|
||||||
{
|
|
||||||
public class AssetBundle : IDisposable
|
|
||||||
{
|
|
||||||
private delegate IntPtr d_LoadFromFile(IntPtr path, uint crc, ulong offset);
|
|
||||||
|
|
||||||
private static readonly d_LoadFromFile i_LoadFromFile = IL2CPP.ResolveICall<d_LoadFromFile>("UnityEngine.AssetBundle::LoadFromFile_Internal");
|
|
||||||
|
|
||||||
public static AssetBundle LoadFromFile(string path, uint crc = 0, ulong offset = 0)
|
|
||||||
{
|
|
||||||
return new AssetBundle(i_LoadFromFile.Invoke(IL2CPP.ManagedStringToIl2Cpp(path), crc, offset));
|
|
||||||
}
|
|
||||||
|
|
||||||
private delegate IntPtr d_LoadFromMemory(IntPtr binary, uint crc);
|
|
||||||
|
|
||||||
private static readonly d_LoadFromMemory i_LoadFromMemory = IL2CPP.ResolveICall<d_LoadFromMemory>("UnityEngine.AssetBundle::LoadFromMemory_Internal");
|
|
||||||
|
|
||||||
public static AssetBundle LoadFromMemory(byte[] binary, uint crc = 0)
|
|
||||||
{
|
|
||||||
return new AssetBundle(i_LoadFromMemory(((Il2CppStructArray<byte>) binary).Pointer, crc));
|
|
||||||
}
|
|
||||||
|
|
||||||
public IntPtr Pointer { get; }
|
|
||||||
|
|
||||||
public AssetBundle(IntPtr ptr)
|
|
||||||
{
|
|
||||||
Pointer = ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
private delegate IntPtr d_LoadAssetWithSubAssets_Internal(IntPtr __instance, IntPtr name, IntPtr type);
|
|
||||||
|
|
||||||
private static readonly d_LoadAssetWithSubAssets_Internal i_LoadAssetWithSubAssets_Internal = IL2CPP.ResolveICall<d_LoadAssetWithSubAssets_Internal>("UnityEngine.AssetBundle::LoadAssetWithSubAssets_Internal");
|
|
||||||
|
|
||||||
public UnityEngine.Object[] LoadAllAssets()
|
|
||||||
{
|
|
||||||
var ptr = i_LoadAssetWithSubAssets_Internal.Invoke(Pointer, IL2CPP.ManagedStringToIl2Cpp(string.Empty), Il2CppType.Of<UnityEngine.Object>().Pointer);
|
|
||||||
|
|
||||||
if (ptr == IntPtr.Zero)
|
|
||||||
{
|
|
||||||
return new UnityEngine.Object[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Il2CppReferenceArray<UnityEngine.Object>(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
private delegate IntPtr d_LoadAsset_Internal(IntPtr __instance, IntPtr name, IntPtr type);
|
|
||||||
|
|
||||||
private static readonly d_LoadAsset_Internal i_LoadAsset_Internal = IL2CPP.ResolveICall<d_LoadAsset_Internal>("UnityEngine.AssetBundle::LoadAsset_Internal");
|
|
||||||
|
|
||||||
public T LoadAsset<T>(string name) where T : UnityEngine.Object
|
|
||||||
{
|
|
||||||
var ptr = i_LoadAsset_Internal.Invoke(Pointer, IL2CPP.ManagedStringToIl2Cpp(name), Il2CppType.Of<T>().Pointer);
|
|
||||||
|
|
||||||
return ptr == IntPtr.Zero ? null : new UnityEngine.Object(ptr).TryCast<T>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private delegate IntPtr d_Unload(IntPtr __instance, bool unloadAllLoadedObjects);
|
|
||||||
|
|
||||||
private static readonly d_Unload i_Unload = IL2CPP.ResolveICall<d_Unload>("UnityEngine.AssetBundle::Unload");
|
|
||||||
|
|
||||||
public void Unload(bool unloadAllLoadedObjects = false)
|
|
||||||
{
|
|
||||||
i_Unload.Invoke(Pointer, unloadAllLoadedObjects);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
Unload();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,7 +8,7 @@ namespace Reactor.Unstrip
|
|||||||
{
|
{
|
||||||
public static void Load()
|
public static void Load()
|
||||||
{
|
{
|
||||||
using var bundle = AssetBundle.LoadFromMemory(typeof(ReactorPlugin).Assembly.GetManifestResourceStream("Reactor.Assets.default.bundle").ReadFully());
|
var bundle = AssetBundle.LoadFromMemory(typeof(ReactorPlugin).Assembly.GetManifestResourceStream("Reactor.Assets.default.bundle").ReadFully());
|
||||||
|
|
||||||
var backupShader = bundle.LoadAsset<Shader>("UI-Default");
|
var backupShader = bundle.LoadAsset<Shader>("UI-Default");
|
||||||
|
|
||||||
@@ -27,6 +27,8 @@ namespace Reactor.Unstrip
|
|||||||
standard = bundle.LoadAsset<Sprite>("UISprite").DontUnload(),
|
standard = bundle.LoadAsset<Sprite>("UISprite").DontUnload(),
|
||||||
inputField = bundle.LoadAsset<Sprite>("InputFieldBackground").DontUnload()
|
inputField = bundle.LoadAsset<Sprite>("InputFieldBackground").DontUnload()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bundle.Unload(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
using System;
|
|
||||||
using UnhollowerBaseLib;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace Reactor.Unstrip
|
|
||||||
{
|
|
||||||
public static class ImageConversion
|
|
||||||
{
|
|
||||||
private delegate bool d_LoadImage(IntPtr tex, IntPtr data, bool markNonReadable);
|
|
||||||
|
|
||||||
private static readonly d_LoadImage i_LoadImage = IL2CPP.ResolveICall<d_LoadImage>("UnityEngine.ImageConversion::LoadImage");
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Load image from <paramref name="data"/> to <paramref name="tex"/>
|
|
||||||
/// </summary>
|
|
||||||
public static bool LoadImage(this Texture2D tex, byte[] data, bool markNonReadable = false)
|
|
||||||
{
|
|
||||||
return i_LoadImage(tex.Pointer, ((Il2CppStructArray<byte>) data).Pointer, markNonReadable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,269 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using HarmonyLib;
|
|
||||||
using UnhollowerBaseLib;
|
|
||||||
using UnityEngine;
|
|
||||||
using Object = Il2CppSystem.Object;
|
|
||||||
using Type = Il2CppSystem.Type;
|
|
||||||
|
|
||||||
namespace Reactor.Unstrip
|
|
||||||
{
|
|
||||||
internal static class Patches
|
|
||||||
{
|
|
||||||
[HarmonyPatch(typeof(GUIUtility), nameof(GUIUtility.HasKeyFocus))]
|
|
||||||
public static class HasKeyFocusPatch
|
|
||||||
{
|
|
||||||
public static bool Prefix(int controlID, out bool __result)
|
|
||||||
{
|
|
||||||
__result = controlID == GUIUtility.keyboardControl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch(typeof(GUILayout), nameof(GUILayout.DoWindow), typeof(int), typeof(Rect), typeof(GUI.WindowFunction), typeof(GUIContent), typeof(GUIStyle), typeof(Il2CppReferenceArray<GUILayoutOption>))]
|
|
||||||
public static class DoWindowPatch
|
|
||||||
{
|
|
||||||
private sealed class LayoutedWindow
|
|
||||||
{
|
|
||||||
internal LayoutedWindow(GUI.WindowFunction f, Rect screenRect, GUIContent content, GUILayoutOption[] options, GUIStyle style)
|
|
||||||
{
|
|
||||||
this.m_Func = f;
|
|
||||||
this.m_ScreenRect = screenRect;
|
|
||||||
this.m_Options = options;
|
|
||||||
this.m_Style = style;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DoWindow(int windowID)
|
|
||||||
{
|
|
||||||
var topLevel = GUILayoutUtility.current.topLevel;
|
|
||||||
var type = Event.current.type;
|
|
||||||
if (type != EventType.Layout)
|
|
||||||
{
|
|
||||||
topLevel.ResetCursor();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
topLevel.resetCoords = true;
|
|
||||||
topLevel.rect = this.m_ScreenRect;
|
|
||||||
var flag = this.m_Options != null;
|
|
||||||
if (flag)
|
|
||||||
{
|
|
||||||
topLevel.ApplyOptions(this.m_Options);
|
|
||||||
}
|
|
||||||
|
|
||||||
topLevel.isWindow = true;
|
|
||||||
topLevel.windowID = windowID;
|
|
||||||
topLevel.style = this.m_Style;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.m_Func.Invoke(windowID);
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly GUI.WindowFunction m_Func;
|
|
||||||
private readonly Rect m_ScreenRect;
|
|
||||||
private readonly GUILayoutOption[] m_Options;
|
|
||||||
private readonly GUIStyle m_Style;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool Prefix(int id, Rect screenRect, GUI.WindowFunction func, GUIContent content, GUIStyle style, Il2CppReferenceArray<GUILayoutOption> options, out Rect __result)
|
|
||||||
{
|
|
||||||
GUIUtility.CheckOnGUI();
|
|
||||||
var @object = new LayoutedWindow(func, screenRect, content, options, style);
|
|
||||||
__result = GUI.Window(id, screenRect, (GUI.WindowFunction) @object.DoWindow, content, style);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch(typeof(GUILayoutGroup), nameof(GUILayoutGroup.Add))]
|
|
||||||
public static class AddPatch
|
|
||||||
{
|
|
||||||
public static bool Prefix(GUILayoutGroup __instance, GUILayoutEntry e)
|
|
||||||
{
|
|
||||||
__instance.entries.Add(e);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch(typeof(GUILayoutGroup), nameof(GUILayoutGroup.GetNext))]
|
|
||||||
public static class GetNextPatch
|
|
||||||
{
|
|
||||||
public static bool Prefix(GUILayoutGroup __instance, ref GUILayoutEntry __result)
|
|
||||||
{
|
|
||||||
if (__instance.m_Cursor < __instance.entries.Count)
|
|
||||||
{
|
|
||||||
__result = __instance.entries[__instance.m_Cursor];
|
|
||||||
__instance.m_Cursor++;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new ArgumentException(string.Concat("Getting control ", __instance.m_Cursor, "'s position in a group with only ", __instance.entries.Count, " controls when doing ", Event.current.rawType, "\nAborting"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// [HarmonyPatch(typeof(GUILayoutEntry), nameof(GUILayoutEntry.CalcWidth))]
|
|
||||||
public static class CalcWidthPatch
|
|
||||||
{
|
|
||||||
public static bool Prefix(GUILayoutEntry __instance)
|
|
||||||
{
|
|
||||||
var cast = __instance?.TryCast<GUIWordWrapSizer>();
|
|
||||||
if (cast != null)
|
|
||||||
{
|
|
||||||
cast.CalcWidth();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// [HarmonyPatch(typeof(GUILayoutEntry), nameof(GUILayoutEntry.CalcHeight))]
|
|
||||||
public static class CalcHeightPatch
|
|
||||||
{
|
|
||||||
public static bool Prefix(GUILayoutEntry __instance)
|
|
||||||
{
|
|
||||||
var cast = __instance?.TryCast<GUIWordWrapSizer>();
|
|
||||||
if (cast != null)
|
|
||||||
{
|
|
||||||
cast.CalcHeight();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[RegisterInIl2Cpp]
|
|
||||||
internal sealed class GUIWordWrapSizer : GUILayoutEntry
|
|
||||||
{
|
|
||||||
private readonly GUIContent m_Content;
|
|
||||||
private readonly float m_ForcedMinHeight;
|
|
||||||
private readonly float m_ForcedMaxHeight;
|
|
||||||
|
|
||||||
public GUIWordWrapSizer(IntPtr ptr) : base(ptr)
|
|
||||||
{
|
|
||||||
CalcWidth();
|
|
||||||
CalcHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
public GUIWordWrapSizer(GUIStyle style, GUIContent content, GUILayoutOption[] options)
|
|
||||||
: base(0.0f, 0.0f, 0.0f, 0.0f, style)
|
|
||||||
{
|
|
||||||
m_Content = new GUIContent(content.text, content.image, content.tooltip);
|
|
||||||
ApplyOptions(options);
|
|
||||||
m_ForcedMinHeight = minHeight;
|
|
||||||
m_ForcedMaxHeight = maxHeight;
|
|
||||||
|
|
||||||
CalcWidth();
|
|
||||||
CalcHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
public new void CalcWidth()
|
|
||||||
{
|
|
||||||
if (this.minWidth != 0.0 && this.maxWidth != 0.0)
|
|
||||||
return;
|
|
||||||
float minWidth;
|
|
||||||
float maxWidth;
|
|
||||||
style.CalcMinMaxWidth(m_Content, out minWidth, out maxWidth);
|
|
||||||
minWidth = Mathf.Ceil(minWidth);
|
|
||||||
maxWidth = Mathf.Ceil(maxWidth);
|
|
||||||
if (this.minWidth == 0.0)
|
|
||||||
this.minWidth = minWidth;
|
|
||||||
if (this.maxWidth == 0.0)
|
|
||||||
this.maxWidth = maxWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
public new void CalcHeight()
|
|
||||||
{
|
|
||||||
if (m_ForcedMinHeight != 0.0 && m_ForcedMaxHeight != 0.0)
|
|
||||||
return;
|
|
||||||
var num = style.CalcHeight(m_Content, rect.width);
|
|
||||||
if (m_ForcedMinHeight == 0.0)
|
|
||||||
minHeight = num;
|
|
||||||
else
|
|
||||||
minHeight = m_ForcedMinHeight;
|
|
||||||
if (m_ForcedMaxHeight == 0.0)
|
|
||||||
maxHeight = num;
|
|
||||||
else
|
|
||||||
maxHeight = m_ForcedMaxHeight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch(typeof(GUILayoutUtility), nameof(GUILayoutUtility.DoGetRect), typeof(GUIContent), typeof(GUIStyle), typeof(Il2CppReferenceArray<GUILayoutOption>))]
|
|
||||||
public static class DoGetRectPatch
|
|
||||||
{
|
|
||||||
public static bool Prefix(GUIContent content, GUIStyle style, Il2CppReferenceArray<GUILayoutOption> options, ref Rect __result)
|
|
||||||
{
|
|
||||||
GUIUtility.CheckOnGUI();
|
|
||||||
var type = Event.current.type;
|
|
||||||
if (type != EventType.Layout)
|
|
||||||
{
|
|
||||||
if (type != EventType.Used)
|
|
||||||
{
|
|
||||||
var next = GUILayoutUtility.current.topLevel.GetNext();
|
|
||||||
__result = next.rect;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
__result = GUILayoutUtility.kDummyRect;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var isHeightDependantOnWidth = style.isHeightDependantOnWidth;
|
|
||||||
if (isHeightDependantOnWidth)
|
|
||||||
{
|
|
||||||
GUILayoutUtility.current.topLevel.Add(new GUIWordWrapSizer(style, content, options));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var constraints = new Vector2(0f, 0f);
|
|
||||||
if (options != null)
|
|
||||||
{
|
|
||||||
foreach (var guilayoutOption in options)
|
|
||||||
{
|
|
||||||
var type2 = guilayoutOption.type;
|
|
||||||
if (type2 != GUILayoutOption.Type.maxWidth)
|
|
||||||
{
|
|
||||||
if (type2 == GUILayoutOption.Type.maxHeight)
|
|
||||||
{
|
|
||||||
constraints.y = guilayoutOption.value.Unbox<float>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
constraints.x = guilayoutOption.value.Unbox<float>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var vector = style.CalcSizeWithConstraints(content, constraints);
|
|
||||||
vector.x = Mathf.Ceil(vector.x);
|
|
||||||
vector.y = Mathf.Ceil(vector.y);
|
|
||||||
GUILayoutUtility.current.topLevel.Add(new GUILayoutEntry(vector.x, vector.x, vector.y, vector.y, style));
|
|
||||||
}
|
|
||||||
|
|
||||||
__result = GUILayoutUtility.kDummyRect;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch(typeof(GUIUtility), nameof(GUIUtility.GetStateObject))]
|
|
||||||
public static class GetStateObjectPatch
|
|
||||||
{
|
|
||||||
private static Dictionary<int, Object> s_StateCache = new Dictionary<int, Object>();
|
|
||||||
|
|
||||||
public static bool Prefix(Type t, int controlID, out Object __result)
|
|
||||||
{
|
|
||||||
if (!s_StateCache.TryGetValue(controlID, out __result) || __result.GetIl2CppType() != t)
|
|
||||||
{
|
|
||||||
s_StateCache[controlID] = __result = t.GetConstructor(new Il2CppReferenceArray<Type>(0)).Invoke(null, new Il2CppReferenceArray<Object>(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user