using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
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 Crossveil.Core;
using Crossveil.Core.Gui;
using Crossveil.Core.Gui.Components;
using Crossveil.Core.Models;
using Crossveil.Crosshair;
using Crossveil.Crosshair.Collections;
using Crossveil.Utils;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.UI;
using Stunlock.Core;
using Stunlock.Localization;
using TMPro;
using UnityEngine;
using UnityEngine.TextCore;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Crossveil")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A V Rising mod to customize your crosshairs")]
[assembly: AssemblyFileVersion("0.1.4.0")]
[assembly: AssemblyInformationalVersion("0.1.4+1.Branch.master.Sha.f10e06426ee97c465f2ecfe723535e6c802a2e31.f10e06426ee97c465f2ecfe723535e6c802a2e31")]
[assembly: AssemblyProduct("Crossveil")]
[assembly: AssemblyTitle("Crossveil")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.4.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 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]
[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 Crossveil
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "Crossveil";
public const string PLUGIN_NAME = "Crossveil";
public const string PLUGIN_VERSION = "0.1.4";
}
}
namespace Crossveil.Utils
{
public static class HotspotUtils
{
public static Vector2 GetHotspot(int index, Texture2D tex)
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: 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_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_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: 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_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)
float num = ((Texture)tex).width;
float num2 = ((Texture)tex).height;
return (Vector2)(index switch
{
0 => new Vector2(num * 0.5f, num2 * 0.5f),
1 => Vector2.zero,
2 => new Vector2(num - 1f, 0f),
3 => new Vector2(0f, num2 - 1f),
4 => new Vector2(num - 1f, num2 - 1f),
5 => new Vector2(0f, num2 * 0.5f),
6 => new Vector2(num - 1f, num2 * 0.5f),
7 => new Vector2(num * 0.5f, 0f),
8 => new Vector2(num * 0.5f, num2 - 1f),
_ => new Vector2(num * 0.5f, num2 * 0.5f),
});
}
}
public static class TextureUtils
{
public static Texture2D LoadFromFile(string path, bool linear = true)
{
return LoadAndLinearise(File.ReadAllBytes(path), linear);
}
public static Texture2D FromByteArray(this byte[] bytes)
{
return LoadAndLinearise(bytes, linear: true);
}
public static Sprite ToSprite(this Texture2D tex, Rect pixelrect)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
return Sprite.Create(tex, pixelrect, new Vector2(0.5f, 0.5f), 100f);
}
public static Texture2D ScaledCopy(this Texture2D src, float factor)
{
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Expected O, but got Unknown
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: 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_00d5: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: 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_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Expected O, but got Unknown
try
{
if (!Object.op_Implicit((Object)(object)src))
{
Plugin.Log.LogError((object)"[ScaledCopy] Source texture is null.");
return null;
}
int num = Mathf.Max(1, Mathf.RoundToInt((float)((Texture)src).width * factor));
int num2 = Mathf.Max(1, Mathf.RoundToInt((float)((Texture)src).height * factor));
RenderTexture temporary = RenderTexture.GetTemporary(num, num2, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)1);
if (!Object.op_Implicit((Object)(object)temporary))
{
Plugin.Log.LogError((object)"[ScaledCopy] Failed to get temporary RenderTexture.");
return null;
}
Graphics.Blit((Texture)(object)src, temporary);
RenderTexture active = RenderTexture.active;
RenderTexture.active = temporary;
Texture2D val = new Texture2D(num, num2, (TextureFormat)4, false, true);
val.ReadPixels(new Rect(0f, 0f, (float)num, (float)num2), 0, 0);
val.Apply();
RenderTexture.active = active;
RenderTexture.ReleaseTemporary(temporary);
((Object)val).name = ((Object)src).name + "_scaled";
((Texture)val).filterMode = ((Texture)src).filterMode;
((Texture)val).anisoLevel = ((Texture)src).anisoLevel;
((Object)val).hideFlags = (HideFlags)(((Object)val).hideFlags | 0x20);
val.Apply(false, false);
return val;
}
catch (Exception ex)
{
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(39, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ScaledCopy] Exception during scaling: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
}
log.LogError(val2);
return null;
}
}
private static Texture2D LoadAndLinearise(byte[] data, bool linear)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false, linear);
ImageConversion.LoadImage(val, Il2CppStructArray<byte>.op_Implicit(data));
if (linear)
{
AdjustBrightnessInPlace(val, 1.25f);
}
return val;
}
private static void AdjustBrightnessInPlace(Texture2D tex, float factor)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: 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_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
Color[] array = Il2CppArrayBase<Color>.op_Implicit((Il2CppArrayBase<Color>)(object)tex.GetPixels());
for (int i = 0; i < array.Length; i++)
{
Color val = array[i];
val.r = Mathf.Clamp01(val.r * factor);
val.g = Mathf.Clamp01(val.g * factor);
val.b = Mathf.Clamp01(val.b * factor);
array[i] = val;
}
tex.SetPixels(Il2CppStructArray<Color>.op_Implicit(array));
tex.Apply();
}
}
}
namespace Crossveil.Patch
{
[HarmonyPatch]
internal static class HUDMenuPatch
{
[HarmonyPostfix]
[HarmonyPatch(typeof(HUDMenu), "OnEnable")]
private static void OnEnable()
{
Plugin.InMenuState = true;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(HUDMenu), "OnDisable")]
private static void OnDisable()
{
Plugin.InMenuState = false;
}
}
[HarmonyPatch]
internal static class InitializeUIPatch
{
[HarmonyPostfix]
[HarmonyPatch(typeof(InitializeUI), "Start")]
private static void initialize_ui_patch()
{
Plugin.ShouldCollectCache = true;
CrosshairRuntime.Refresh();
}
}
[HarmonyPatch(typeof(OptionsPanel_Interface), "Start")]
internal static class PatchOptionsPanelInterface
{
private static SettingsEntry_Checkbox _hideCrosshairToggle;
private static SettingsEntry_Checkbox _useWindowsCursorToggle;
private static SettingsEntry_Checkbox _changeInMenuToggle;
private static SettingsEntry_Dropdown _crosshairDropdown;
private static SettingsEntry_Dropdown _collectionDropdown;
private static SettingsEntry_Dropdown _hotspotDropdown;
private static SettingsEntry_Checkbox _enableScalingToggle;
private static SettingsEntry_Checkbox _enableScalingInMenus;
private static SettingsEntry_Slider _changeScalingSlider;
[HarmonyPostfix]
private static void Postfix(OptionsPanel_Interface __instance)
{
new CustomHeader().Panel(__instance).Label("Crossveil").Build();
new CustomToggle().Panel(__instance).Label("Mod Enabled").Tooltip("<align=\"center\">Enable or disable the mod.</align>")
.DefaultValue(defaultValue: false)
.InitialValue(Config.ModEnabled.Value)
.OnValueChanged(OnModEnabledToggle)
.Build();
new CustomDivider().Panel(__instance).Label("General Options").Build();
_hideCrosshairToggle = new CustomToggle().Panel(__instance).Label("Hide Crosshair").Tooltip("<align=\"center\">Hide the game crosshair except inside menus.</align>")
.DefaultValue(defaultValue: false)
.InitialValue(Config.HideCrosshair.Value)
.OnValueChanged(OnHideCrosshairToggle)
.Build();
_useWindowsCursorToggle = new CustomToggle().Panel(__instance).Label("Use Windows Cursor").Tooltip("<align=\"center\">Uses your system crosshair as the default crosshair.</align>")
.DefaultValue(defaultValue: false)
.InitialValue(Config.UseWindows.Value)
.OnValueChanged(OnUseWindowsCursor)
.Build();
_changeInMenuToggle = new CustomToggle().Panel(__instance).Label("Change In Menus").Tooltip("<align=\"center\">Show the crosshair inside game menus.</align>")
.DefaultValue(defaultValue: false)
.InitialValue(Config.ChangeInMenus.Value)
.OnValueChanged(OnChangeInMenusToggle)
.Build();
new CustomDivider().Panel(__instance).Label("Crosshair Options").Build();
_collectionDropdown = new CustomDropdown().Panel(__instance).Type(CustomDropdown.DropdownType.COLLECTION).Label("Collection")
.Tooltip("<align=\"center\">Select a crosshair collection.\n\n\n<color=#ecdd1f><b>MANAGE COLLECTIONS</b></color>\n\n<size=75%>Go to the game install folder then open this path:\n<b><color=#e6e6e6>BepInEx\\config\\Crossveil</color></b>\n\nEach folder inside the directory containing <color=#FF0000>at least one <b>.png</b> image</color> will be imported as a unique collection at startup.\n\nFor the best results use evenly sized images like <b>32x32</b>, <b>64x64</b> or <b>128x128</b> for example.</size></align>")
.InitialValue(Config.CollectionIndex.Value)
.DefaultValue(0)
.OnValueChanged(OnCollectionChanged)
.Build();
_crosshairDropdown = new CustomDropdown().Panel(__instance).Type(CustomDropdown.DropdownType.CROSSHAIR).Label("Crosshair")
.Tooltip("<align=\"center\">Select the crosshair you would like to use.</size>")
.InitialValue(Config.CrosshairIndex.Value)
.DefaultValue(0)
.OnValueChanged(OnCrosshairChanged)
.Build();
_hotspotDropdown = new CustomDropdown().Panel(__instance).Type(CustomDropdown.DropdownType.HOTSPOT).Label("Hotspot")
.Tooltip("<align=\"center\">Switch the crosshair hotspot.\n\n\n<color=#ecdd1f><b>INFORMATION</b></color>\n\n<size=75%>The crosshair hotspot defines the exact point used for targeting. For example if set to \"Center\" the clickable area of the loaded crosshair will be in the exact center of the image.\n\nYou can try different hotspots for different crosshairs, as some textures such as ones pointing to a specific corner may work better with one of the other modes.</size></align>")
.InitialValue(Config.HotspotIndex.Value)
.DefaultValue(0)
.OnValueChanged(OnHotspotChanged)
.Build();
new CustomDivider().Panel(__instance).Label("Scaling Options").Build();
_enableScalingToggle = new CustomToggle().Panel(__instance).Label("Enable").Tooltip("<align=\"center\">Scale the crosshair size up or down.\n\n\n<color=#FF0000><b>WARNING</b></color>\n\n<size=75%>This setting forces software-rendering for the crosshair. Which may or may not have a negativeimpact on performance, colouration of the image or hotspot locations.\n\nFor best results only use imported images that are equal in dimensions and preferably ones that point to an obvious hotspot area like the middle of the image or the top left corner.</size></align>")
.InitialValue(Config.ScaleEnabled.Value)
.DefaultValue(defaultValue: false)
.OnValueChanged(OnScalingEnabled)
.Build();
_enableScalingInMenus = new CustomToggle().Panel(__instance).Label("Scale In Menus").Tooltip("<align=\"center\">Enable or disable crosshair scaling inside game menus.</size>")
.InitialValue(Config.ScaleInMenus.Value)
.DefaultValue(defaultValue: false)
.OnValueChanged(OnScalingInMenus)
.Build();
_changeScalingSlider = new CustomSlider().Panel(__instance).Label("Scaling factor").MinValue(0.1f)
.MaxValue(5f)
.InitialValue(Config.ScaleFactor.Value)
.DefaultValue(1f)
.OnValueChanged(OnScaleFactorChanged)
.Build();
}
private static void OnModEnabledToggle(bool value)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
Config.ModEnabled.Value = value;
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(29, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[UI] Mod enabled changed to: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(value);
}
log.LogInfo(val);
CrosshairRuntime.Refresh();
}
private static void OnHideCrosshairToggle(bool value)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
Config.HideCrosshair.Value = value;
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(32, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[UI] Hide crosshair changed to: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(value);
}
log.LogInfo(val);
CrosshairRuntime.Refresh();
}
private static void OnUseWindowsCursor(bool value)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
Config.UseWindows.Value = value;
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(39, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[UI] Use windows crosshair changed to: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(value);
}
log.LogInfo(val);
CrosshairRuntime.Refresh();
}
private static void OnChangeInMenusToggle(bool value)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
Config.ChangeInMenus.Value = value;
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(32, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[UI] Change in menu changed to: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(value);
}
log.LogInfo(val);
CrosshairRuntime.Refresh();
}
private static void OnCollectionChanged(int index)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
Config.CollectionIndex.Value = index;
Config.CrosshairIndex.Value = 0;
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(34, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[UI] Collection index changed to: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(index);
}
log.LogInfo(val);
TMP_Dropdown componentInChildren = ((Component)_crosshairDropdown).GetComponentInChildren<TMP_Dropdown>(true);
if ((Object)(object)componentInChildren != (Object)null)
{
List<string> crosshairOptions = Plugin.Collections.GetCrosshairOptions(Config.CollectionIndex.Value);
componentInChildren.ClearOptions();
componentInChildren.AddOptions(crosshairOptions);
componentInChildren.RefreshShownValue();
}
CrosshairRuntime.Refresh();
}
private static void OnCrosshairChanged(int index)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
Config.CrosshairIndex.Value = index;
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(33, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[UI] Crosshair index changed to: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(index);
}
log.LogInfo(val);
CrosshairRuntime.Refresh();
}
private static void OnHotspotChanged(int index)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
Config.HotspotIndex.Value = index;
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(31, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[UI] Hotspot index changed to: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(index);
}
log.LogInfo(val);
CrosshairRuntime.Refresh();
}
private static void OnScalingEnabled(bool value)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
Config.ScaleEnabled.Value = value;
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(32, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[UI] Enable scaling changed to: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(value);
}
log.LogInfo(val);
CrosshairRuntime.Refresh();
}
private static void OnScalingInMenus(bool value)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
Config.ScaleInMenus.Value = value;
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(32, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[UI] Scale in menus changed to: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(value);
}
log.LogInfo(val);
CrosshairRuntime.Refresh();
}
private static void OnScaleFactorChanged(float value)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
Config.ScaleFactor.Value = value;
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(32, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[UI] Scaling factor changed to: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(value);
}
log.LogInfo(val);
CrosshairRuntime.Refresh();
}
}
[HarmonyPatch(typeof(SetCursorSystem), "OnUpdate")]
internal static class PatchSetCursorSystemOnUpdate
{
private static bool _originalsCached;
private static void Postfix(SetCursorSystem __instance)
{
Il2CppReferenceArray<CursorData> cursorDatas = CursorController._CursorDatas;
if (Plugin.ShouldCollectCache && !_originalsCached)
{
CrosshairCache.CacheOriginals(Il2CppArrayBase<CursorData>.op_Implicit((Il2CppArrayBase<CursorData>)(object)cursorDatas));
_originalsCached = true;
}
CrosshairRuntime.Refresh();
}
}
}
namespace Crossveil.Crosshair
{
public static class CrosshairCache
{
private static readonly Dictionary<(int collectionIndex, int crosshairIndex, float scale), Texture2D> ScaledCrosshairs = new Dictionary<(int, int, float), Texture2D>();
private static readonly Dictionary<CursorType, CursorData> OriginalCrosshairs = new Dictionary<CursorType, CursorData>();
public static void ClearScaled()
{
ScaledCrosshairs.Clear();
}
public static void ClearOriginal()
{
OriginalCrosshairs.Clear();
}
public static Texture2D GetOrAddScaled(int collectionIndex, int crosshairIndex, Texture2D tex, float scale)
{
(int, int, float) key = (collectionIndex, crosshairIndex, scale);
if (ScaledCrosshairs.TryGetValue(key, out var value))
{
if (Object.op_Implicit((Object)(object)value) && ((Texture)value).width != 0)
{
return value;
}
ScaledCrosshairs.Remove(key);
}
Texture2D val = tex.ScaledCopy(scale);
if (!Object.op_Implicit((Object)(object)val))
{
return null;
}
ScaledCrosshairs[key] = val;
return val;
}
public static void CacheOriginals(CursorData[] dataArray)
{
//IL_0010: 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)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: 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_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Expected O, but got Unknown
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
foreach (CursorData val in dataArray)
{
if (!OriginalCrosshairs.ContainsKey(val.CursorType))
{
CursorData value = new CursorData
{
CursorType = val.CursorType,
Hotspot = val.Hotspot,
Texture = val.Texture
};
OriginalCrosshairs[val.CursorType] = value;
}
}
Plugin.Log.LogInfo((object)"Original crosshairs cached.");
}
public static CursorData RestoreOriginal(CursorType type)
{
//IL_0005: 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_0021: Expected O, but got Unknown
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
if (OriginalCrosshairs.TryGetValue(type, out var value))
{
return value;
}
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(32, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Cache not found for CursorType: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<CursorType>(type);
}
log.LogWarning(val);
return null;
}
}
public readonly record struct CrosshairContext
{
public bool ModEnabled { get; init; }
public bool Hide { get; init; }
public bool UseWindows { get; init; }
public bool ChangeInMenus { get; init; }
public bool ScaleEnabled { get; init; }
public bool ScaleInMenus { get; init; }
public float ScaleFactor { get; init; }
public CursorType RequestedType { get; init; }
public bool IsMenuContext { get; init; }
[CompilerGenerated]
private bool PrintMembers(StringBuilder builder)
{
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
builder.Append("ModEnabled = ");
builder.Append(ModEnabled.ToString());
builder.Append(", Hide = ");
builder.Append(Hide.ToString());
builder.Append(", UseWindows = ");
builder.Append(UseWindows.ToString());
builder.Append(", ChangeInMenus = ");
builder.Append(ChangeInMenus.ToString());
builder.Append(", ScaleEnabled = ");
builder.Append(ScaleEnabled.ToString());
builder.Append(", ScaleInMenus = ");
builder.Append(ScaleInMenus.ToString());
builder.Append(", ScaleFactor = ");
builder.Append(ScaleFactor.ToString());
builder.Append(", RequestedType = ");
CursorType requestedType = RequestedType;
builder.Append(((object)(CursorType)(ref requestedType)).ToString());
builder.Append(", IsMenuContext = ");
builder.Append(IsMenuContext.ToString());
return true;
}
}
public readonly record struct CursorDecision(Texture2D Texture, Vector2 Hotspot, CursorMode Mode, bool Visible)
{
[CompilerGenerated]
private bool PrintMembers(StringBuilder builder)
{
//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_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)
builder.Append("Texture = ");
builder.Append(Texture);
builder.Append(", Hotspot = ");
Vector2 hotspot = Hotspot;
builder.Append(((object)(Vector2)(ref hotspot)).ToString());
builder.Append(", Mode = ");
CursorMode mode = Mode;
builder.Append(((object)(CursorMode)(ref mode)).ToString());
builder.Append(", Visible = ");
builder.Append(Visible.ToString());
return true;
}
[CompilerGenerated]
public void Deconstruct(out Texture2D Texture, out Vector2 Hotspot, out CursorMode Mode, out bool Visible)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: 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_001c: Expected I4, but got Unknown
Texture = this.Texture;
Hotspot = this.Hotspot;
Mode = (CursorMode)(int)this.Mode;
Visible = this.Visible;
}
}
public static class CrosshairRules
{
public static CursorDecision Decide(CrosshairContext ctx)
{
//IL_000b: 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_00ed: Expected O, but got Unknown
//IL_0063: 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_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0249: 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_0151: Expected O, but got Unknown
//IL_00a5: 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_0270: Unknown result type (might be due to invalid IL or missing references)
//IL_0267: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_0215: Unknown result type (might be due to invalid IL or missing references)
//IL_021f: Unknown result type (might be due to invalid IL or missing references)
//IL_023c: Unknown result type (might be due to invalid IL or missing references)
//IL_023e: Unknown result type (might be due to invalid IL or missing references)
if (!ctx.ModEnabled)
{
CursorData val = CrosshairCache.RestoreOriginal(ctx.RequestedType);
return new CursorDecision((val != null) ? val.Texture : null, (val != null) ? val.Hotspot : Vector2.zero, (CursorMode)0, Visible: true);
}
if (ctx.UseWindows)
{
bool visible = !ctx.Hide || ctx.IsMenuContext;
return new CursorDecision(null, Vector2.zero, (CursorMode)0, visible);
}
if (ctx.IsMenuContext && !ctx.ChangeInMenus)
{
CursorData val2 = CrosshairCache.RestoreOriginal((CursorType)1);
return new CursorDecision((val2 != null) ? val2.Texture : null, (val2 != null) ? val2.Hotspot : Vector2.zero, (CursorMode)0, Visible: true);
}
CustomCollection customCollection = Plugin.Collections.GetList().ElementAtOrDefault(Config.CollectionIndex.Value);
bool flag = default(bool);
if (customCollection == null || customCollection.Crosshairs.Count == 0)
{
ManualLogSource log = Plugin.Log;
BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(25, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Invalid collection index ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(Config.CollectionIndex.Value);
}
log.LogWarning(val3);
}
else
{
CustomCrosshair customCrosshair = customCollection.Crosshairs.ElementAtOrDefault(Config.CrosshairIndex.Value);
if (customCrosshair == null || !Object.op_Implicit((Object)(object)customCrosshair.Texture))
{
ManualLogSource log2 = Plugin.Log;
BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(39, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Invalid crosshair index ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(Config.CrosshairIndex.Value);
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" in collection ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(customCollection.Name);
}
log2.LogWarning(val3);
}
else
{
Texture2D val4 = customCrosshair.Texture;
bool flag2 = ctx.ScaleEnabled && (!ctx.IsMenuContext || ctx.ScaleInMenus);
if (flag2 && !Mathf.Approximately(ctx.ScaleFactor, 1f))
{
val4 = CrosshairCache.GetOrAddScaled(Config.CollectionIndex.Value, Config.CrosshairIndex.Value, val4, ctx.ScaleFactor) ?? val4;
}
if (Object.op_Implicit((Object)(object)val4))
{
Vector2 hotspot = HotspotUtils.GetHotspot(Config.HotspotIndex.Value, val4);
CursorMode mode = (CursorMode)(flag2 ? 1 : 0);
bool visible = !ctx.Hide || ctx.IsMenuContext;
return new CursorDecision(val4, hotspot, mode, visible);
}
}
}
CursorData val5 = CrosshairCache.RestoreOriginal(ctx.RequestedType);
return new CursorDecision((val5 != null) ? val5.Texture : null, (val5 != null) ? val5.Hotspot : Vector2.zero, (CursorMode)0, Visible: true);
}
}
public static class CrosshairRuntime
{
public static void Refresh()
{
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
if (Plugin.Collections != null && Plugin.Collections.GetList().Count != 0)
{
bool flag = ViewManager.IsInMenu() || Plugin.InMenuState;
CrosshairContext crosshairContext = default(CrosshairContext);
crosshairContext.ModEnabled = Config.ModEnabled.Value;
crosshairContext.Hide = Config.HideCrosshair.Value;
crosshairContext.UseWindows = Config.UseWindows.Value;
crosshairContext.ChangeInMenus = Config.ChangeInMenus.Value;
crosshairContext.ScaleEnabled = Config.ScaleEnabled.Value;
crosshairContext.ScaleInMenus = Config.ScaleInMenus.Value;
crosshairContext.ScaleFactor = Config.ScaleFactor.Value;
crosshairContext.RequestedType = (CursorType)(flag ? 1 : 0);
crosshairContext.IsMenuContext = flag;
CrosshairContext ctx = crosshairContext;
CursorDecision cursorDecision = CrosshairRules.Decide(ctx);
if (!ctx.ScaleEnabled || (ctx.IsMenuContext && !ctx.ScaleInMenus))
{
CrosshairCache.ClearScaled();
}
Cursor.SetCursor(cursorDecision.Texture, cursorDecision.Hotspot, cursorDecision.Mode);
if (!cursorDecision.Visible)
{
Cursor.visible = false;
}
}
}
}
}
namespace Crossveil.Crosshair.Collections
{
public static class CollectionImport
{
public static void Standard()
{
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
Assembly executingAssembly = Assembly.GetExecutingAssembly();
string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
foreach (string text in manifestResourceNames)
{
if (!text.StartsWith("Crossveil.Embedded.") || !text.EndsWith(".png"))
{
continue;
}
using Stream stream = executingAssembly.GetManifestResourceStream(text);
if (stream != null)
{
byte[] bytes;
using (MemoryStream memoryStream = new MemoryStream())
{
stream.CopyTo(memoryStream);
bytes = memoryStream.ToArray();
}
Texture2D val = bytes.FromByteArray();
((Object)val).name = text.Replace("Crossveil.Embedded.", "").Replace(".png", "");
((Object)val).hideFlags = (HideFlags)(((Object)val).hideFlags | 0x20);
Plugin.Collections.Add(val, "Standard");
}
}
}
public static void Custom()
{
//IL_0068: 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)
string path = Path.Combine(Paths.ConfigPath, "Crossveil");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
string[] directories = Directory.GetDirectories(path);
foreach (string path2 in directories)
{
string fileName = Path.GetFileName(path2);
string[] files = Directory.GetFiles(path2, "*.png", SearchOption.TopDirectoryOnly);
foreach (string path3 in files)
{
Texture2D val = TextureUtils.LoadFromFile(path3);
((Object)val).name = Path.GetFileNameWithoutExtension(path3);
((Object)val).hideFlags = (HideFlags)(((Object)val).hideFlags | 0x20);
Plugin.Collections.Add(val, fileName);
}
}
}
}
public class CollectionRegistry
{
private readonly List<CustomCollection> _collections;
public CollectionRegistry()
{
_collections = new List<CustomCollection>();
}
public List<string> GetCrosshairOptions(int collectionIndex)
{
CustomCollection customCollection = Plugin.Collections.GetList()[collectionIndex];
List<string> val = new List<string>();
foreach (CustomCrosshair crosshair in customCollection.Crosshairs)
{
string text = customCollection.Name + "_" + crosshair.Name;
val.Add("<sprite name=\"" + text + "\"> " + crosshair.Name);
}
return val;
}
public List<CustomCollection> GetList()
{
return _collections;
}
public void Add(Texture2D texture, string collection)
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Expected O, but got Unknown
bool flag = default(bool);
if (!_collections.Any((CustomCollection col) => col.Name == collection))
{
_collections.Add(new CustomCollection(collection, new List<CustomCrosshair>()));
ManualLogSource log = Plugin.Log;
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(30, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Created collection with: name=");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(collection);
}
log.LogInfo(val);
}
CustomCollection customCollection = _collections.FirstOrDefault((CustomCollection c) => c.Name.Equals(collection, StringComparison.OrdinalIgnoreCase));
if (customCollection != null)
{
customCollection.Crosshairs.Add(new CustomCrosshair(texture));
ManualLogSource log2 = Plugin.Log;
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(28, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Added texture with name=");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)texture).name);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".png");
}
log2.LogInfo(val);
}
}
}
}
namespace Crossveil.Core
{
public class Config
{
internal static ConfigEntry<bool> ModEnabled;
internal static ConfigEntry<bool> HideCrosshair;
internal static ConfigEntry<bool> UseWindows;
internal static ConfigEntry<bool> ChangeInMenus;
internal static ConfigEntry<int> CollectionIndex;
internal static ConfigEntry<int> CrosshairIndex;
internal static ConfigEntry<int> HotspotIndex;
internal static ConfigEntry<bool> ScaleEnabled;
internal static ConfigEntry<bool> ScaleInMenus;
internal static ConfigEntry<float> ScaleFactor;
internal static void Initialize(ConfigFile config)
{
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Expected O, but got Unknown
config.SaveOnConfigSet = true;
ModEnabled = config.Bind<bool>("Options", "EnableCustomCrosshair", false, "Selected option to enable the mod.");
HideCrosshair = config.Bind<bool>("Options", "HideCrosshair", false, "Hides the game crosshair.");
UseWindows = config.Bind<bool>("Options", "UseWindows", false, "Uses the windows cursor");
ChangeInMenus = config.Bind<bool>("Options", "ChangeInMenus", false, "Selected option to change menu crosshairs.");
ScaleEnabled = config.Bind<bool>("Options", "ScaleEnabled", false, "Selected option to change menu crosshairs.");
ScaleInMenus = config.Bind<bool>("Options", "ScaleInMenus", false, "Scale crosshair in menus.");
CollectionIndex = config.Bind<int>("Variables", "CrosshairCollection", 0, "Selected collection.");
CrosshairIndex = config.Bind<int>("Variables", "CrosshairStyle", 0, "Selected crosshair.");
HotspotIndex = config.Bind<int>("Variables", "HotspotIndex", 0, "Selected hotspot.");
ScaleFactor = config.Bind<float>("Variables", "ScaleFactor", 1f, "Scale factor");
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(30, 0, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Initialized configuration file");
}
log.LogInfo(val);
}
}
[BepInPlugin("Crossveil", "Crossveil", "0.1.4")]
public class Plugin : BasePlugin
{
private static Harmony _harmony;
public static ManualLogSource Log { get; private set; }
public static CollectionRegistry Collections { get; set; }
public static SpriteAtlas SpriteAsset { get; set; }
public static bool InMenuState { get; set; }
public static bool ShouldCollectCache { get; set; }
public override void Load()
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Expected O, but got Unknown
Log = ((BasePlugin)this).Log;
ShouldCollectCache = false;
Config.Initialize(((BasePlugin)this).Config);
Collections = new CollectionRegistry();
CollectionImport.Standard();
CollectionImport.Custom();
SpriteAsset = new SpriteAtlas();
_harmony = new Harmony("Crossveil");
_harmony.PatchAll(Assembly.GetExecutingAssembly());
ManualLogSource log = Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Crossveil");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" version ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("0.1.4");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
}
log.LogInfo(val);
}
public override bool Unload()
{
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
return true;
}
}
}
namespace Crossveil.Core.Models
{
public class CustomCollection
{
public string Name { get; }
public List<CustomCrosshair> Crosshairs { get; }
public CustomCollection(string name, List<CustomCrosshair> items)
{
Name = name;
Crosshairs = items;
}
}
public class CustomCrosshair
{
public Texture2D Texture { get; }
public int Width { get; }
public int Height { get; }
public string Name { get; }
public CustomCrosshair(Texture2D texture)
{
Texture = texture;
Name = ((Object)texture).name;
Width = ((Texture)texture).width;
Height = ((Texture)texture).height;
}
}
}
namespace Crossveil.Core.Gui
{
public sealed class SpriteAtlas
{
private readonly TMP_SpriteAsset _atlas;
public TMP_SpriteAsset Atlas => _atlas;
public SpriteAtlas()
{
//IL_002f: 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)
TMP_SpriteAsset defaultSpriteAsset = TMP_Settings.defaultSpriteAsset;
_atlas = Object.Instantiate<TMP_SpriteAsset>(defaultSpriteAsset);
((Object)_atlas).name = "CrosshairPreviews";
TMP_SpriteAsset atlas = _atlas;
((Object)atlas).hideFlags = (HideFlags)(((Object)atlas).hideFlags | 0x20);
_atlas.spriteInfoList.Clear();
_atlas.spriteGlyphTable.Clear();
_atlas.spriteCharacterTable.Clear();
_atlas.spriteCharacterLookupTable.Clear();
_atlas.fallbackSpriteAssets.Clear();
BuildSpriteAsset();
}
private void BuildSpriteAsset()
{
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Expected O, but got Unknown
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Expected O, but got Unknown
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: 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_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_0201: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Expected O, but got Unknown
//IL_0229: Unknown result type (might be due to invalid IL or missing references)
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: Unknown result type (might be due to invalid IL or missing references)
//IL_0248: Expected O, but got Unknown
//IL_0265: Unknown result type (might be due to invalid IL or missing references)
//IL_026a: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Unknown result type (might be due to invalid IL or missing references)
//IL_0285: Unknown result type (might be due to invalid IL or missing references)
//IL_0297: Unknown result type (might be due to invalid IL or missing references)
//IL_029a: 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_02b1: Expected O, but got Unknown
//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
//IL_02f3: Expected O, but got Unknown
var array = (from col in Plugin.Collections.GetList()
where col != null
select col).SelectMany(delegate(CustomCollection col)
{
IEnumerable<CustomCrosshair> crosshairs = col.Crosshairs;
return from ch in crosshairs ?? Enumerable.Empty<CustomCrosshair>()
where (Object)(object)ch?.Texture != (Object)null
select new
{
Collection = col.Name,
Texture = ch.Texture
};
}).ToArray();
if (array.Length != 0)
{
Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false);
Rect[] array2 = Il2CppArrayBase<Rect>.op_Implicit((Il2CppArrayBase<Rect>)(object)val.PackTextures(Il2CppReferenceArray<Texture2D>.op_Implicit(array.Select(e => e.Texture).ToArray()), 2, 2048));
val.Apply();
_atlas.spriteSheet = (Texture)(object)val;
Material val2 = new Material(Shader.Find("TextMeshPro/Sprite"))
{
mainTexture = (Texture)(object)val
};
((TMP_Asset)_atlas).material = val2;
((TMP_Asset)_atlas).materialHashCode = ((Object)val2).GetInstanceID();
uint num = 57344u;
Rect pixelrect = default(Rect);
GlyphRect glyphRect = default(GlyphRect);
for (int i = 0; i < array.Length; i++)
{
var anon = array[i];
Texture2D texture = anon.Texture;
Rect val3 = array2[i];
((Rect)(ref pixelrect))..ctor(((Rect)(ref val3)).x * (float)((Texture)val).width, ((Rect)(ref val3)).y * (float)((Texture)val).height, ((Rect)(ref val3)).width * (float)((Texture)val).width, ((Rect)(ref val3)).height * (float)((Texture)val).height);
((GlyphRect)(ref glyphRect))..ctor((int)((Rect)(ref pixelrect)).x, (int)((Rect)(ref pixelrect)).y, (int)((Rect)(ref pixelrect)).width, (int)((Rect)(ref pixelrect)).height);
Sprite val4 = val.ToSprite(pixelrect);
((Object)val4).name = anon.Collection + "_" + ((Object)texture).name;
TMP_SpriteGlyph val5 = new TMP_SpriteGlyph
{
index = (uint)i,
glyphRect = glyphRect,
scale = 1f,
sprite = val4,
metrics = new GlyphMetrics((float)(int)((Rect)(ref pixelrect)).width, (float)(int)((Rect)(ref pixelrect)).height, 0f, (float)(int)((Rect)(ref pixelrect)).height * 0.8f, (float)(int)((Rect)(ref pixelrect)).width)
};
_atlas.spriteGlyphTable.Add(val5);
TMP_SpriteCharacter val6 = new TMP_SpriteCharacter((uint)(num + i), val5)
{
name = ((Object)val4).name,
scale = 1f
};
_atlas.spriteCharacterTable.Add(val6);
_atlas.spriteInfoList.Add(new TMP_Sprite
{
name = ((Object)val4).name,
unicode = (int)(num + i),
hashCode = TMP_TextUtilities.GetSimpleHashCode(((Object)val4).name),
pivot = val4.pivot,
sprite = val4
});
}
_atlas.UpdateLookupTables();
_atlas.SortGlyphTable();
_atlas.SortCharacterTable();
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val7 = new BepInExInfoLogInterpolatedStringHandler(42, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val7).AppendLiteral("Built sprite atlas with ");
((BepInExLogInterpolatedStringHandler)val7).AppendFormatted<int>(array.Length);
((BepInExLogInterpolatedStringHandler)val7).AppendLiteral(" imported textures");
}
log.LogInfo(val7);
}
}
}
}
namespace Crossveil.Core.Gui.Components
{
internal class CustomDivider
{
private string _label;
private OptionsPanel_Interface _panel;
public CustomDivider Panel(OptionsPanel_Interface panel)
{
_panel = panel;
return this;
}
public CustomDivider Label(string label)
{
_label = label;
return this;
}
public GameObject Build()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//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_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("Divider");
RectTransform obj = val.AddComponent<RectTransform>();
((Transform)obj).SetParent((Transform)(object)_panel.ContentNode);
((Transform)obj).localScale = Vector3.one;
obj.sizeDelta = new Vector2(0f, 28f);
val.AddComponent<LayoutElement>().preferredHeight = 75f;
GameObject val2 = new GameObject("Text");
RectTransform obj2 = val2.AddComponent<RectTransform>();
((Transform)obj2).SetParent(val.transform);
((Transform)obj2).localScale = Vector3.one;
TextMeshProUGUI obj3 = val2.AddComponent<TextMeshProUGUI>();
TMP_FontAsset font = ((TMP_Text)((IEnumerable<TextMeshProUGUI>)((Component)_panel.ContentNode).GetComponentsInChildren<TextMeshProUGUI>()).First()).font;
((TMP_Text)obj3).alignment = (TextAlignmentOptions)514;
((TMP_Text)obj3).fontStyle = (FontStyles)32;
((TMP_Text)obj3).font = font;
((TMP_Text)obj3).fontSize = 20f;
((Graphic)obj3).color = Color.gray;
((TMP_Text)obj3).SetText(_label, true);
val.SetActive(true);
return val;
}
}
internal class CustomDropdown
{
public enum DropdownType
{
COLLECTION,
CROSSHAIR,
HOTSPOT
}
private OptionsPanel_Interface _panel;
private DropdownType _type;
private string _label;
private string _tooltip;
private readonly List<string> _options = new List<string>();
private int _defaultValue;
private int _initialValue;
private Action<int> _onValueChanged;
public CustomDropdown Panel(OptionsPanel_Interface panel)
{
_panel = panel;
return this;
}
public CustomDropdown Type(DropdownType type)
{
_type = type;
return this;
}
public CustomDropdown Label(string label)
{
_label = label;
return this;
}
public CustomDropdown Tooltip(string tooltip)
{
_tooltip = tooltip;
return this;
}
public CustomDropdown DefaultValue(int defaultValue)
{
_defaultValue = defaultValue;
return this;
}
public CustomDropdown InitialValue(int initialValue)
{
_initialValue = initialValue;
return this;
}
public CustomDropdown OnValueChanged(Action<int> callback)
{
_onValueChanged = callback;
return this;
}
public SettingsEntry_Dropdown Build()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: 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_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: 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_0072: 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_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
AssetGuid val = AssetGuid.NewGuid();
LocalizationKey val2 = default(LocalizationKey);
((LocalizationKey)(ref val2))..ctor(val);
AssetGuid val3 = AssetGuid.NewGuid();
LocalizationKey val4 = default(LocalizationKey);
((LocalizationKey)(ref val4))..ctor(val3);
if (_label != null)
{
Localization.LocalizedStrings.Add(val, _label);
}
if (_tooltip != null)
{
Localization.LocalizedStrings.Add(val3, _tooltip);
}
PopulateOptions(_type);
SettingsEntry_Dropdown val5 = OptionsHelper.AddDropdown(_panel.ContentNode, _panel.DropdownPrefab, false, val2, val4, _options, _defaultValue, _initialValue, Action<int>.op_Implicit(_onValueChanged));
TMP_Dropdown componentInChildren = ((Component)val5).GetComponentInChildren<TMP_Dropdown>(true);
if (!Object.op_Implicit((Object)(object)componentInChildren))
{
return null;
}
RectTransform component = ((Component)componentInChildren).GetComponent<RectTransform>();
component.sizeDelta = new Vector2(-300f, component.sizeDelta.y);
componentInChildren.captionText.richText = true;
componentInChildren.captionText.spriteAsset = Plugin.SpriteAsset.Atlas;
componentInChildren.captionText.alignment = (TextAlignmentOptions)513;
componentInChildren.itemText.richText = true;
componentInChildren.itemText.spriteAsset = Plugin.SpriteAsset.Atlas;
componentInChildren.itemText.alignment = (TextAlignmentOptions)514;
((DatalessSelectionGroupBase<SettingsEntryBase>)(object)_panel.EntriesSelectionGroup).Entries.Add((SettingsEntryBase)(object)val5);
return val5;
}
private void PopulateOptions(DropdownType type)
{
List<CustomCollection> list = Plugin.Collections.GetList();
List<string> crosshairOptions = Plugin.Collections.GetCrosshairOptions(Config.CollectionIndex.Value);
switch (type)
{
case DropdownType.COLLECTION:
{
foreach (CustomCollection item in list)
{
_options.Add(item.Name);
}
break;
}
case DropdownType.CROSSHAIR:
{
Enumerator<string> enumerator = crosshairOptions.GetEnumerator();
while (enumerator.MoveNext())
{
string current = enumerator.Current;
_options.Add(current);
}
break;
}
case DropdownType.HOTSPOT:
_options.Add("Center");
_options.Add("Top Left");
_options.Add("Top Right");
_options.Add("Bottom Left");
_options.Add("Bottom Right");
_options.Add("Center Left");
_options.Add("Center Right");
_options.Add("Top Center");
_options.Add("Bottom Center");
break;
default:
throw new ArgumentOutOfRangeException("type", type, null);
}
}
}
internal class CustomHeader
{
private OptionsPanel_Interface _panel;
private string _label;
public CustomHeader Panel(OptionsPanel_Interface panel)
{
_panel = panel;
return this;
}
public CustomHeader Label(string label)
{
_label = label;
return this;
}
public SettingsEntry_Label Build()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: 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_0035: Unknown result type (might be due to invalid IL or missing references)
AssetGuid val = AssetGuid.NewGuid();
LocalizationKey val2 = default(LocalizationKey);
((LocalizationKey)(ref val2))..ctor(val);
Localization.LocalizedStrings.Add(val, _label);
SettingsEntry_Label obj = OptionsHelper.AddHeader(_panel.ContentNode, _panel.HeaderPrefab, val2);
((TMP_Text)((SettingsEntryBase)obj).HeaderText.Text).text = _label;
return obj;
}
}
internal class CustomSlider
{
private OptionsPanel_Interface _panel;
private string _label;
private float _minvalue;
private float _maxvalue;
private float _defaultvalue;
private float _initialvalue;
private Action<float> _onValueChanged;
public CustomSlider Panel(OptionsPanel_Interface panel)
{
_panel = panel;
return this;
}
public CustomSlider Label(string label)
{
_label = label;
return this;
}
public CustomSlider MinValue(float defaultValue)
{
_minvalue = defaultValue;
return this;
}
public CustomSlider MaxValue(float initialValue)
{
_maxvalue = initialValue;
return this;
}
public CustomSlider DefaultValue(float defaultValue)
{
_defaultvalue = defaultValue;
return this;
}
public CustomSlider InitialValue(float initialValue)
{
_initialvalue = initialValue;
return this;
}
public CustomSlider OnValueChanged(Action<float> callback)
{
_onValueChanged = callback;
return this;
}
public SettingsEntry_Slider Build()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: 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_0041: 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_001b: Unknown result type (might be due to invalid IL or missing references)
AssetGuid val = AssetGuid.NewGuid();
LocalizationKey val2 = default(LocalizationKey);
((LocalizationKey)(ref val2))..ctor(val);
if (_label != null)
{
Localization.LocalizedStrings.Add(val, _label);
}
return OptionsHelper.AddSlider(_panel.ContentNode, _panel.SliderPrefab, false, val2, default(Nullable_Unboxed<LocalizationKey>), _minvalue, _maxvalue, _defaultvalue, _initialvalue, 1, false, Action<float>.op_Implicit(_onValueChanged));
}
}
internal class CustomToggle
{
private bool _defaultValue;
private bool _initialValue;
private string _label;
private Action<bool> _onValueChanged;
private OptionsPanel_Interface _panel;
private RectTransform _parentOverride;
private string _tooltip;
public CustomToggle Panel(OptionsPanel_Interface panel)
{
_panel = panel;
return this;
}
public CustomToggle Parent(RectTransform parent)
{
_parentOverride = parent;
return this;
}
public CustomToggle Label(string label)
{
_label = label;
return this;
}
public CustomToggle Tooltip(string tooltip)
{
_tooltip = tooltip;
return this;
}
public CustomToggle DefaultValue(bool defaultValue)
{
_defaultValue = defaultValue;
return this;
}
public CustomToggle InitialValue(bool initialValue)
{
_initialValue = initialValue;
return this;
}
public CustomToggle OnValueChanged(Action<bool> callback)
{
_onValueChanged = callback;
return this;
}
public SettingsEntry_Checkbox Build()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: 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_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: 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_0066: 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)
AssetGuid val = AssetGuid.NewGuid();
LocalizationKey val2 = default(LocalizationKey);
((LocalizationKey)(ref val2))..ctor(val);
AssetGuid val3 = AssetGuid.NewGuid();
LocalizationKey val4 = default(LocalizationKey);
((LocalizationKey)(ref val4))..ctor(val3);
if (_label != null)
{
Localization.LocalizedStrings.Add(val, _label);
}
if (_tooltip != null)
{
Localization.LocalizedStrings.Add(val3, _tooltip);
}
SettingsEntry_Checkbox val5 = OptionsHelper.AddCheckbox(_panel.ContentNode, _panel.CheckboxPrefab, false, val2, val4, _defaultValue, _initialValue, Action<bool>.op_Implicit(_onValueChanged), (Func<bool>)null);
if (_tooltip != null)
{
((DatalessSelectionGroupBase<SettingsEntryBase>)(object)_panel.EntriesSelectionGroup).Entries.Add((SettingsEntryBase)(object)val5);
}
return val5;
}
}
}