using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SoDCaseboardExpanded")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("SoDCaseboardExpanded")]
[assembly: AssemblyTitle("SoDCaseboardExpanded")]
[assembly: AssemblyVersion("0.1.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace SoDCaseboardExpanded
{
[BepInPlugin("sm3gm.sod.caseboardexpanded", "Caseboard Expanded", "1.0.0")]
public sealed class Plugin : BasePlugin
{
public const string VER = "1.0.0";
internal static ManualLogSource L;
internal static ConfigEntry<int> MaxCases;
internal static ConfigEntry<float> MinButtonWidth;
internal static ConfigEntry<string> SortOrder;
internal static ConfigEntry<KeyCode> PinKey;
internal static ConfigEntry<KeyCode> PinModifier;
internal static int Limit
{
get
{
if (MaxCases.Value > 0)
{
return Mathf.Clamp(MaxCases.Value, 1, 999);
}
return 999;
}
}
public override void Load()
{
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Expected O, but got Unknown
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Invalid comparison between Unknown and I4
//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_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Expected O, but got Unknown
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Invalid comparison between Unknown and I4
L = ((BasePlugin)this).Log;
MaxCases = ((BasePlugin)this).Config.Bind<int>("Cases", "MaxOpenCases", 0, "How many cases you can have open at once. 0 means no limit (vanilla 5).");
SortOrder = ((BasePlugin)this).Config.Bind<string>("CaseBar", "SortOrder", "Newest", new ConfigDescription("Order of the cases in the bar: Newest first, Oldest first, or Vanilla (as the game adds them). Pinned cases always come first.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[3] { "Newest", "Oldest", "Vanilla" }), Array.Empty<object>()));
PinKey = ((BasePlugin)this).Config.Bind<KeyCode>("CaseBar", "PinKey", (KeyCode)112, "Pins or unpins the open case while the case board is shown (Alt plus P). A pinned case starts with * and stays at the front.");
PinModifier = ((BasePlugin)this).Config.Bind<KeyCode>("CaseBar", "PinModifier", (KeyCode)308, "Held with PinKey. None means PinKey alone. (Control plus P is taken by the game.)");
if ((int)PinModifier.Value == 306 && (int)PinKey.Value == 112)
{
PinModifier.Value = (KeyCode)308;
}
MinButtonWidth = ((BasePlugin)this).Config.Bind<float>("CaseBar", "MinButtonWidth", 130f, "Case buttons never get narrower than this, so their names stay readable. When they no longer fit, the case bar scrolls.");
Harmony val = new Harmony("sm3gm.sod.caseboardexpanded");
val.PatchAll(typeof(ShoulderPatch));
val.PatchAll(typeof(JobMessagePatch));
((BasePlugin)this).AddComponent<Keeper>();
ManualLogSource l = L;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(26, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Caseboard Expanded ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("1.0.0");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" loaded");
}
l.LogInfo(val2);
}
}
public class Keeper : MonoBehaviour
{
private float next;
public Keeper(IntPtr ptr)
: base(ptr)
{
}
private void Update()
{
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Expected O, but got Unknown
try
{
JobWatch.Tick();
}
catch
{
}
try
{
if ((Object)(object)InterfaceController.Instance != (Object)null && InterfaceController.Instance.desktopMode)
{
CaseBar.Tick(CasePanelController.Instance);
}
}
catch (Exception e)
{
CaseBar.Fail(e);
}
if (Time.unscaledTime < next)
{
return;
}
next = Time.unscaledTime + 2f;
try
{
GameplayControls instance = GameplayControls.Instance;
if ((Object)(object)instance == (Object)null)
{
return;
}
int limit = Plugin.Limit;
if (instance.maxCases != limit)
{
ManualLogSource l = Plugin.L;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(23, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[CASES] case limit ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(instance.maxCases);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" -> ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(limit);
}
l.LogInfo(val);
instance.maxCases = limit;
}
}
catch
{
}
}
}
[HarmonyPatch(typeof(CasePanelController), "ShoulderNavigate")]
internal static class ShoulderPatch
{
private static bool Prefix(CasePanelController __instance, bool right)
{
try
{
return CaseBar.Shoulder(__instance, right);
}
catch (Exception e)
{
CaseBar.Fail(e);
return true;
}
}
}
[HarmonyPatch(typeof(InterfaceController), "NewGameMessage")]
internal static class JobMessagePatch
{
private static void Prefix(ref string newMessage)
{
try
{
newMessage = JobInfo.Name(newMessage);
}
catch
{
}
}
}
internal static class Keys
{
private static MethodInfo? down;
private static MethodInfo? held;
private static bool looked;
private static void Find()
{
if (!looked)
{
looked = true;
Type type = Type.GetType("UnityEngine.Input, UnityEngine.InputLegacyModule");
down = type?.GetMethod("GetKeyDown", new Type[1] { typeof(KeyCode) });
held = type?.GetMethod("GetKey", new Type[1] { typeof(KeyCode) });
if (down == null)
{
Plugin.L.LogWarning((object)"[ORDER] keyboard not found, the pin key is off");
}
}
}
internal static bool Down(KeyCode k)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
Find();
if (down != null)
{
return (bool)down.Invoke(null, new object[1] { k });
}
return false;
}
internal static bool Held(KeyCode k)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
Find();
if (held != null)
{
return (bool)held.Invoke(null, new object[1] { k });
}
return false;
}
}
internal static class Order
{
internal const string Mark = "* ";
internal static bool IsPinned(Case? c)
{
if (c != null && c.name != null)
{
return c.name.StartsWith("*");
}
return false;
}
internal static void Pin(CasePanelController cp)
{
//IL_0005: 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_0022: 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_010a: Expected O, but got Unknown
if (!Keys.Down(Plugin.PinKey.Value) || ((int)Plugin.PinModifier.Value != 0 && !Keys.Held(Plugin.PinModifier.Value)))
{
return;
}
EventSystem current = EventSystem.current;
GameObject val = ((current != null) ? current.currentSelectedGameObject : null);
if ((Object)(object)val != (Object)null && (Object)(object)val.GetComponent<TMP_InputField>() != (Object)null)
{
return;
}
Case activeCase = cp.activeCase;
if (activeCase == null)
{
return;
}
activeCase.name = (IsPinned(activeCase) ? activeCase.name.TrimStart('*', ' ') : ("* " + activeCase.name));
List<CaseButtonController> spawnedCaseButtons = cp.spawnedCaseButtons;
int num = 0;
while (spawnedCaseButtons != null && num < spawnedCaseButtons.Count)
{
CaseButtonController obj = spawnedCaseButtons[num];
if (((obj != null) ? obj.thisCase : null) != null && ((Il2CppObjectBase)spawnedCaseButtons[num].thisCase).Pointer == ((Il2CppObjectBase)activeCase).Pointer)
{
spawnedCaseButtons[num].UpdateVisuals();
}
num++;
}
ManualLogSource l = Plugin.L;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(11, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ORDER] ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(IsPinned(activeCase) ? "pinned" : "unpinned");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" '");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(activeCase.name);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'");
}
l.LogInfo(val2);
}
private static int Rank(CaseButtonController b)
{
if (!IsPinned(b.thisCase))
{
if (!Failed.IsFailed(b.thisCase))
{
return 1;
}
return 2;
}
return 0;
}
internal static void Sort(RectTransform row, List<CaseButtonController>? buttons)
{
if (buttons == null || buttons.Count < 2)
{
return;
}
string value = Plugin.SortOrder.Value;
List<CaseButtonController> list = new List<CaseButtonController>();
List<int> list2 = new List<int>();
for (int i = 0; i < buttons.Count; i++)
{
CaseButtonController val = buttons[i];
if (!((Object)(object)val == (Object)null) && val.thisCase != null && !((Object)(object)((Component)val).transform.parent == (Object)null) && !(((Il2CppObjectBase)((Component)val).transform.parent).Pointer != ((Il2CppObjectBase)row).Pointer))
{
list.Add(val);
list2.Add(((Component)val).transform.GetSiblingIndex());
}
}
if (list.Count < 2)
{
return;
}
list2.Sort();
List<(int, int, int, CaseButtonController)> list3 = new List<(int, int, int, CaseButtonController)>();
for (int j = 0; j < list.Count; j++)
{
int id = list[j].thisCase.id;
int item = ((value == "Newest") ? (-id) : ((value == "Oldest") ? id : 0));
list3.Add((Rank(list[j]), item, j, list[j]));
}
list3.Sort(((int rank, int age, int pos, CaseButtonController b) x, (int rank, int age, int pos, CaseButtonController b) y) => (x.rank == y.rank) ? ((x.age == y.age) ? x.pos.CompareTo(y.pos) : x.age.CompareTo(y.age)) : x.rank.CompareTo(y.rank));
for (int num = 0; num < list3.Count; num++)
{
Transform transform = ((Component)list3[num].Item4).transform;
if (transform.GetSiblingIndex() != list2[num])
{
transform.SetSiblingIndex(list2[num]);
}
}
}
}
internal static class JobWatch
{
private static float next;
internal static void Tick()
{
if (Time.unscaledTime < next)
{
return;
}
next = Time.unscaledTime + 1f;
CasePanelController instance = CasePanelController.Instance;
if (((instance != null) ? instance.activeCases : null) == null)
{
return;
}
for (int i = 0; i < instance.activeCases.Count; i++)
{
Case val = instance.activeCases[i];
if (((val != null) ? val.job : null) != null)
{
Failed.Check(val, val.job);
JobInfo.Snapshot(val);
}
}
}
}
internal static class Failed
{
internal const string Tag = " (failed)";
internal const string DoneTag = " (finished)";
internal static bool IsFailed(Case? c)
{
if (c != null && c.name != null)
{
if (!c.name.EndsWith(" (failed)"))
{
return c.name.EndsWith(" (finished)");
}
return true;
}
return false;
}
internal static void Check(Case c, SideJob j)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Invalid comparison between Unknown and I4
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Expected O, but got Unknown
if (IsFailed(c))
{
return;
}
string text = (j.failed ? " (failed)" : (((int)j.state == 2) ? " (finished)" : ""));
if (text.Length == 0)
{
return;
}
c.name = (Order.IsPinned(c) ? c.name.TrimStart('*', ' ') : (c.name ?? "Case")) + text;
CasePanelController instance = CasePanelController.Instance;
List<CaseButtonController> val = ((instance != null) ? instance.spawnedCaseButtons : null);
int num = 0;
while (val != null && num < val.Count)
{
CaseButtonController obj = val[num];
if (((obj != null) ? obj.thisCase : null) != null && ((Il2CppObjectBase)val[num].thisCase).Pointer == ((Il2CppObjectBase)c).Pointer)
{
val[num].UpdateVisuals();
}
num++;
}
ManualLogSource l = Plugin.L;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(29, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ORDER] job ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(j.failed ? "failed" : "finished");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", case renamed '");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(c.name);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'");
}
l.LogInfo(val2);
}
}
internal static class JobInfo
{
private static readonly Dictionary<IntPtr, int> seen = new Dictionary<IntPtr, int>();
private static int logs;
private static int Count(Case c)
{
return (c.currentActiveObjectives?.Count ?? 0) + (c.inactiveCurrentObjectives?.Count ?? 0) + (c.endedObjectives?.Count ?? 0) + (c.caseElements?.Count ?? 0);
}
internal static void Snapshot(Case c)
{
seen[((Il2CppObjectBase)c).Pointer] = Count(c);
}
internal static string Name(string msg)
{
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Expected O, but got Unknown
if (msg == null || !msg.StartsWith("Job information updated"))
{
return msg;
}
CasePanelController instance = CasePanelController.Instance;
if (((instance != null) ? instance.activeCases : null) == null)
{
return msg;
}
Case val = null;
int num = 0;
for (int i = 0; i < instance.activeCases.Count; i++)
{
Case val2 = instance.activeCases[i];
if (((val2 != null) ? val2.job : null) != null)
{
int num2 = Count(val2);
if (seen.TryGetValue(((Il2CppObjectBase)val2).Pointer, out var value) && value != num2)
{
val = val2;
num++;
}
seen[((Il2CppObjectBase)val2).Pointer] = num2;
}
}
if (logs++ < 10)
{
ManualLogSource l = Plugin.L;
bool flag = default(bool);
BepInExDebugLogInterpolatedStringHandler val3 = new BepInExDebugLogInterpolatedStringHandler(51, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[JOBINFO] job information message, ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(num);
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" case(s) changed");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>((val != null) ? (": '" + val.name + "'") : "");
}
l.LogDebug(val3);
}
if (num != 1 || val == null || val.name == null)
{
return msg;
}
return msg.TrimEnd('!') + ": " + val.name;
}
}
internal static class CaseBar
{
private static RectTransform? row;
private static RectTransform? view;
private static ScrollRect? scroll;
private static IntPtr lastActive;
private static int lastCount = -1;
private static bool failed;
internal static readonly List<RectTransform> left = new List<RectTransform>();
private static int shoulderLogs;
internal static void Fail(Exception e)
{
if (!failed)
{
failed = true;
Plugin.L.LogError((object)("[CASEBAR] " + e));
}
}
internal static void Tick(CasePanelController? cp)
{
//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_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Expected O, but got Unknown
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
if (failed || (Object)(object)cp == (Object)null || (Object)(object)cp.caseButtonParent == (Object)null)
{
return;
}
if ((Object)(object)row == (Object)null || ((Il2CppObjectBase)row).Pointer != ((Il2CppObjectBase)cp.caseButtonParent).Pointer || (Object)(object)view == (Object)null)
{
Build(cp.caseButtonParent);
}
if ((Object)(object)row == (Object)null || (Object)(object)view == (Object)null)
{
return;
}
float num = Mathf.Max(40f, Plugin.MinButtonWidth.Value);
List<CaseButtonController> spawnedCaseButtons = cp.spawnedCaseButtons;
int num2 = spawnedCaseButtons?.Count ?? 0;
for (int i = 0; i < num2; i++)
{
CaseButtonController val = spawnedCaseButtons[i];
if (!((Object)(object)val == (Object)null))
{
LayoutElement component = ((Component)val).GetComponent<LayoutElement>();
if ((Object)(object)component != (Object)null && component.minWidth < num)
{
component.minWidth = num;
}
}
}
Order.Pin(cp);
Order.Sort(row, spawnedCaseButtons);
Rect rect = view.rect;
float width = ((Rect)(ref rect)).width;
float num3 = NeededWidth(num);
float num4 = Mathf.Max(width, num3);
if (Mathf.Abs(row.sizeDelta.x - num4) > 0.5f)
{
row.sizeDelta = new Vector2(num4, row.sizeDelta.y);
}
if (num4 <= width + 0.5f && row.anchoredPosition.x != 0f)
{
row.anchoredPosition = new Vector2(0f, row.anchoredPosition.y);
}
if (num2 != lastCount)
{
ManualLogSource l = Plugin.L;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(47, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[CASEBAR] ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num2);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" case buttons, row ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(num4, "0");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" wide in a ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(width, "0");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" window");
}
l.LogInfo(val2);
lastCount = num2;
}
Case activeCase = cp.activeCase;
IntPtr intPtr = ((activeCase == null) ? IntPtr.Zero : ((Il2CppObjectBase)activeCase).Pointer);
if (!(intPtr != lastActive))
{
return;
}
lastActive = intPtr;
int num5 = 0;
while (activeCase != null && num5 < num2)
{
CaseButtonController val3 = spawnedCaseButtons[num5];
if (((val3 != null) ? val3.thisCase : null) != null && !(((Il2CppObjectBase)val3.thisCase).Pointer != intPtr))
{
ShowButton(((Il2CppObjectBase)((Component)val3).transform).TryCast<RectTransform>(), width, num4);
break;
}
num5++;
}
}
private static float NeededWidth(float min)
{
HorizontalLayoutGroup component = ((Component)row).GetComponent<HorizontalLayoutGroup>();
float num = (((Object)(object)component != (Object)null) ? ((float)(((LayoutGroup)component).padding.left + ((LayoutGroup)component).padding.right)) : 0f);
float num2 = (((Object)(object)component != (Object)null) ? ((HorizontalOrVerticalLayoutGroup)component).spacing : 0f);
int num3 = 0;
for (int i = 0; i < ((Transform)row).childCount; i++)
{
RectTransform val = ((Il2CppObjectBase)((Transform)row).GetChild(i)).TryCast<RectTransform>();
if (!((Object)(object)val == (Object)null) && ((Component)val).gameObject.activeSelf)
{
LayoutElement component2 = ((Component)val).GetComponent<LayoutElement>();
if (!((Object)(object)component2 != (Object)null) || !component2.ignoreLayout)
{
float num4 = (((Object)(object)component2 != (Object)null && component2.minWidth > 0f) ? component2.minWidth : 0f);
num4 = ((!((Object)(object)((Component)val).GetComponent<CaseButtonController>() != (Object)null)) ? Mathf.Max(num4, LayoutUtility.GetPreferredWidth(val)) : Mathf.Max(num4, min));
num += num4;
num3++;
}
}
}
return num + num2 * (float)Mathf.Max(0, num3 - 1);
}
private static void ShowButton(RectTransform? b, float viewW, float width)
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: 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_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: 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)
if (!((Object)(object)b == (Object)null) && !((Object)(object)row == (Object)null) && !(width <= viewW) && !((Object)(object)((Transform)b).parent == (Object)null) && !(((Il2CppObjectBase)((Transform)b).parent).Pointer != ((Il2CppObjectBase)row).Pointer))
{
LayoutRebuilder.ForceRebuildLayoutImmediate(row);
float x = b.anchoredPosition.x;
Rect rect = b.rect;
float num = ((Rect)(ref rect)).width / 2f;
float num2 = 0f - row.anchoredPosition.x;
if (x - num < num2)
{
num2 = x - num;
}
else if (x + num > num2 + viewW)
{
num2 = x + num - viewW;
}
num2 = Mathf.Clamp(num2, 0f, width - viewW);
row.anchoredPosition = new Vector2(0f - num2, row.anchoredPosition.y);
}
}
private static void PinNewCaseButton(RectTransform v)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: 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_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Expected O, but got Unknown
CasePanelController instance = CasePanelController.Instance;
object obj;
if (instance == null)
{
obj = null;
}
else
{
ButtonController newCaseButton = instance.newCaseButton;
obj = ((newCaseButton != null) ? ((Il2CppObjectBase)((Component)newCaseButton).transform).TryCast<RectTransform>() : null);
}
RectTransform val = (RectTransform)obj;
if (!((Object)(object)val == (Object)null))
{
Rect rect = val.rect;
float num = Mathf.Clamp(((Rect)(ref rect)).width, 64f, 200f);
Vector2 offsetMax = v.offsetMax;
((Transform)val).SetParent(((Transform)v).parent, false);
val.anchorMin = v.anchorMax;
val.anchorMax = v.anchorMax;
val.pivot = new Vector2(1f, 1f);
rect = v.rect;
val.sizeDelta = new Vector2(num, ((Rect)(ref rect)).height);
val.anchoredPosition = offsetMax;
v.offsetMax = new Vector2(offsetMax.x - num - 4f, offsetMax.y);
ManualLogSource l = Plugin.L;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(53, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[CASEBAR] new case button pinned on the right (");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(num, "0");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" wide)");
}
l.LogInfo(val2);
}
}
private static void PinLeftButtons(RectTransform v, RectTransform area)
{
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: 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_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Expected O, but got Unknown
CasePanelController instance = CasePanelController.Instance;
List<RectTransform> list = new List<RectTransform>();
ButtonController[] array = (ButtonController[])(object)new ButtonController[2]
{
(instance != null) ? instance.selectNoCaseButton : null,
(instance != null) ? instance.stickNoteButton : null
};
foreach (ButtonController obj in array)
{
RectTransform val = ((obj != null) ? ((Il2CppObjectBase)((Component)obj).transform).TryCast<RectTransform>() : null);
if ((Object)(object)val != (Object)null && (Object)(object)((Transform)val).parent != (Object)null && ((Il2CppObjectBase)((Transform)val).parent).Pointer == ((Il2CppObjectBase)area).Pointer)
{
list.Add(val);
}
}
if (list.Count == 0)
{
return;
}
list.Sort((RectTransform a, RectTransform b) => ((Transform)a).GetSiblingIndex().CompareTo(((Transform)b).GetSiblingIndex()));
HorizontalLayoutGroup component = ((Component)area).GetComponent<HorizontalLayoutGroup>();
float num = (((Object)(object)component != (Object)null) ? ((HorizontalOrVerticalLayoutGroup)component).spacing : 4f);
float num2 = v.offsetMin.x;
float y = v.offsetMax.y;
Vector2 val2 = default(Vector2);
((Vector2)(ref val2))..ctor(v.anchorMin.x, v.anchorMax.y);
foreach (RectTransform item in list)
{
Rect rect = item.rect;
float num3 = Mathf.Clamp(((Rect)(ref rect)).width, 32f, 200f);
((Transform)item).SetParent(((Transform)v).parent, false);
item.anchorMin = val2;
item.anchorMax = val2;
item.pivot = new Vector2(0f, 1f);
rect = v.rect;
item.sizeDelta = new Vector2(num3, ((Rect)(ref rect)).height);
item.anchoredPosition = new Vector2(num2, y);
num2 += num3 + num;
}
v.offsetMin = new Vector2(num2, v.offsetMin.y);
left.Clear();
left.AddRange(list);
ManualLogSource l = Plugin.L;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(37, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[CASEBAR] ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(list.Count);
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" buttons pinned on the left");
}
l.LogInfo(val3);
}
internal static bool Shoulder(CasePanelController cp, bool right)
{
//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_023f: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Expected O, but got Unknown
if ((Object)(object)row == (Object)null || (Object)(object)view == (Object)null)
{
return true;
}
List<ButtonController> list = new List<ButtonController>();
foreach (RectTransform item in left)
{
ButtonController component = ((Component)item).GetComponent<ButtonController>();
if ((Object)(object)component != (Object)null)
{
list.Add(component);
}
}
for (int i = 0; i < ((Transform)row).childCount; i++)
{
Transform child = ((Transform)row).GetChild(i);
if (((Component)child).gameObject.activeSelf)
{
CaseButtonController component2 = ((Component)child).GetComponent<CaseButtonController>();
if ((Object)(object)component2 != (Object)null && component2.thisCase != null)
{
list.Add((ButtonController)(object)component2);
}
}
}
ButtonController newCaseButton = cp.newCaseButton;
if ((Object)(object)newCaseButton != (Object)null)
{
list.Add(newCaseButton);
}
if (list.Count == 0)
{
return true;
}
ButtonController selectedTopBarButton = cp.selectedTopBarButton;
int num = -1;
int num2 = 0;
while ((Object)(object)selectedTopBarButton != (Object)null && num2 < list.Count)
{
if (((Il2CppObjectBase)list[num2]).Pointer == ((Il2CppObjectBase)selectedTopBarButton).Pointer)
{
num = num2;
break;
}
num2++;
}
if (num < 0 && cp.activeCase != null)
{
for (int j = 0; j < list.Count; j++)
{
CaseButtonController val = ((Il2CppObjectBase)list[j]).TryCast<CaseButtonController>();
if (((val != null) ? val.thisCase : null) != null && ((Il2CppObjectBase)val.thisCase).Pointer == ((Il2CppObjectBase)cp.activeCase).Pointer)
{
num = j;
break;
}
}
}
int num3 = ((num >= 0) ? ((num + (right ? 1 : (-1)) + list.Count) % list.Count) : 0);
ButtonController val2 = (cp.selectedTopBarButton = list[num3]);
CaseButtonController val4 = ((Il2CppObjectBase)val2).TryCast<CaseButtonController>();
if (((val4 != null) ? val4.thisCase : null) != null)
{
cp.SetActiveCase(val4.thisCase);
}
Rect rect = view.rect;
float width = ((Rect)(ref rect)).width;
ShowButton(((Il2CppObjectBase)((Component)val2).transform).TryCast<RectTransform>(), width, Mathf.Max(width, row.sizeDelta.x));
if (shoulderLogs++ < 6)
{
ManualLogSource l = Plugin.L;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(34, 5, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("[CASEBAR] shoulder ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(right ? "right" : "left");
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(": ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(num);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" -> ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(num3);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" of ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(list.Count);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" ('");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(((Object)val2).name);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("')");
}
l.LogInfo(val5);
}
return false;
}
private static void Build(RectTransform area)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: 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_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: 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)
//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_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Expected O, but got Unknown
//IL_01b1: 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)
row = null;
view = null;
scroll = null;
Transform parent = ((Transform)area).parent;
if (!((Object)(object)parent == (Object)null))
{
GameObject val = new GameObject("CaseBarView");
RectTransform val2 = val.AddComponent<RectTransform>();
((Transform)val2).SetParent(parent, false);
((Transform)val2).SetSiblingIndex(((Transform)area).GetSiblingIndex());
val2.anchorMin = area.anchorMin;
val2.anchorMax = area.anchorMax;
val2.pivot = area.pivot;
val2.anchoredPosition = area.anchoredPosition;
val2.sizeDelta = area.sizeDelta;
val.AddComponent<RectMask2D>();
((Graphic)val.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0f);
((Transform)area).SetParent((Transform)(object)val2, false);
area.anchorMin = new Vector2(0f, 1f);
area.anchorMax = new Vector2(0f, 1f);
area.pivot = new Vector2(0f, 1f);
area.anchoredPosition = Vector2.zero;
Rect rect = val2.rect;
float width = ((Rect)(ref rect)).width;
rect = val2.rect;
area.sizeDelta = new Vector2(width, ((Rect)(ref rect)).height);
ScrollRect obj = val.AddComponent<ScrollRect>();
obj.content = area;
obj.viewport = val2;
obj.horizontal = true;
obj.vertical = false;
obj.movementType = (MovementType)2;
obj.inertia = false;
obj.scrollSensitivity = 40f;
PinNewCaseButton(val2);
PinLeftButtons(val2, area);
row = area;
view = val2;
scroll = obj;
lastCount = -1;
lastActive = IntPtr.Zero;
ManualLogSource l = Plugin.L;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(41, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[CASEBAR] case bar can scroll now (");
rect = val2.rect;
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<float>(((Rect)(ref rect)).width, "0");
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" wide)");
}
l.LogInfo(val3);
}
}
}
}