using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Newtonsoft.Json;
using SuperFantasyKingdom;
using SuperFantasyKingdom.TitleScreen;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.UI;
using UnityEngine.InputSystem.Utilities;
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("RelicLoadoutJournal")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.2.0")]
[assembly: AssemblyInformationalVersion("0.1.2+4c7954552e84b61eff55d75be580dcf7ccbd9c09")]
[assembly: AssemblyProduct("RelicLoadoutJournal")]
[assembly: AssemblyTitle("RelicLoadoutJournal")]
[assembly: AssemblyVersion("0.1.2.0")]
namespace RelicLoadoutJournal;
internal sealed class ControlHint
{
private readonly Image icon;
private readonly TextMeshProUGUI label;
private readonly string verb;
private string lastPath;
private InputDevice lastDevice;
internal ControlHint(RectTransform parent, string verb, float x, Func<Transform, string, float, Color, TextMeshProUGUI> makeLabel)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
this.verb = verb;
icon = ((Component)JournalScreen.Box((Transform)(object)parent, verb + " prompt", Color.white)).GetComponent<Image>();
icon.preserveAspect = true;
((Graphic)icon).raycastTarget = false;
JournalScreen.Place(((Graphic)icon).rectTransform, x, 465f, 35f, 34f);
label = makeLabel((Transform)(object)parent, verb, 20f, Color.white);
((TMP_Text)label).alignment = (TextAlignmentOptions)4097;
JournalScreen.Place(((TMP_Text)label).rectTransform, x + 40f, 462f, 150f, 40f);
}
internal void Refresh(InputAction action, bool pad)
{
//IL_0007: 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)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: 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_0087: Unknown result type (might be due to invalid IL or missing references)
if (action != null)
{
Enumerator<InputControl> enumerator = action.controls.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
InputControl current = enumerator.Current;
if ((pad ? (!(current.device is Gamepad)) : (!(current.device is Keyboard))) || (pad && Gamepad.current != null && (object)current.device != Gamepad.current))
{
continue;
}
int bindingIndexForControl = InputActionRebindingExtensions.GetBindingIndexForControl(action, current);
if (bindingIndexForControl < 0)
{
continue;
}
InputBinding val = action.bindings[bindingIndexForControl];
string text = ((InputBinding)(ref val)).effectivePath;
if (!string.IsNullOrEmpty(((InputBinding)(ref val)).effectiveProcessors))
{
text += "Processor";
}
if (!(lastPath == text) || lastDevice != current.device)
{
lastPath = text;
lastDevice = current.device;
Sprite buttonPrompt = GamepadManager.Instance.GetButtonPrompt(text, false);
if ((Object)(object)buttonPrompt == (Object)null)
{
string text2 = (pad ? "Gamepad" : "Keyboard");
buttonPrompt = GamepadManager.Instance.GetButtonPrompt("<" + text2 + ">/" + current.name, false);
}
((Behaviour)icon).enabled = (Object)(object)buttonPrompt != (Object)null;
icon.sprite = buttonPrompt;
((TMP_Text)label).text = (((Object)(object)buttonPrompt != (Object)null) ? verb : ((current.shortDisplayName ?? current.displayName) + " " + verb));
}
return;
}
}
finally
{
((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
}
}
lastPath = null;
lastDevice = null;
((Behaviour)icon).enabled = false;
((TMP_Text)label).text = "";
}
}
internal sealed class CompletedRun
{
public Guid RunId { get; set; }
public DateTime CompletedUtc { get; set; }
public int Kingdom { get; set; }
public string Hero { get; set; }
public int FinalDay { get; set; }
public string[] Relics { get; set; }
internal bool IsValid
{
get
{
if (RunId != Guid.Empty && FinalDay >= 1 && CompletedUtc != default(DateTime) && !string.IsNullOrWhiteSpace(Hero) && Relics != null)
{
return Array.TrueForAll(Relics, (string id) => !string.IsNullOrWhiteSpace(id));
}
return false;
}
}
}
internal sealed class Journal
{
private readonly string directory;
internal Journal(string root, int profile)
{
directory = Path.Combine(root, "profile-" + profile.ToString(CultureInfo.InvariantCulture));
}
internal bool Append(CompletedRun run)
{
if (!run.IsValid)
{
throw new InvalidDataException("Incomplete run summary.");
}
Directory.CreateDirectory(directory);
string text = Path.Combine(directory, run.RunId.ToString("D") + ".json");
if (File.Exists(text))
{
return false;
}
string text2 = Path.Combine(directory, Guid.NewGuid().ToString("N") + ".tmp");
try
{
File.WriteAllText(text2, JsonConvert.SerializeObject((object)run, (Formatting)1));
try
{
File.Move(text2, text);
}
catch (IOException) when (File.Exists(text))
{
return false;
}
return true;
}
finally
{
File.Delete(text2);
}
}
internal List<CompletedRun> Read(Action<string> warn)
{
List<CompletedRun> list = new List<CompletedRun>();
if (!Directory.Exists(directory))
{
return list;
}
string[] files = Directory.GetFiles(directory, "*.json");
foreach (string path in files)
{
try
{
CompletedRun completedRun = JsonConvert.DeserializeObject<CompletedRun>(File.ReadAllText(path));
if (completedRun == null || !completedRun.IsValid || !Guid.TryParse(Path.GetFileNameWithoutExtension(path), out var result) || result != completedRun.RunId)
{
throw new InvalidDataException("Invalid run summary.");
}
list.Add(completedRun);
}
catch (Exception ex) when (ex is JsonException || ex is IOException || ex is UnauthorizedAccessException || ex is InvalidDataException)
{
warn(Path.GetFileName(path) + ": " + ex.Message);
}
}
list.Sort(delegate(CompletedRun a, CompletedRun b)
{
int num = b.CompletedUtc.CompareTo(a.CompletedUtc);
return (num == 0) ? a.RunId.CompareTo(b.RunId) : num;
});
return list;
}
}
public sealed class JournalButton : Button
{
private TextMeshProUGUI caption;
internal void SetCaption(TextMeshProUGUI value)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
caption = value;
Paint(((Selectable)this).currentSelectionState);
}
protected override void DoStateTransition(SelectionState state, bool instant)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
((Selectable)this).DoStateTransition(state, instant);
Paint(state);
}
private void Paint(SelectionState state)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected I4, but got Unknown
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: 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_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)caption == (Object)null))
{
switch (state - 1)
{
case 0:
case 2:
((Graphic)caption).color = Color32.op_Implicit(new Color32((byte)47, (byte)32, (byte)24, byte.MaxValue));
break;
case 3:
((Graphic)caption).color = Color32.op_Implicit(new Color32((byte)191, (byte)175, (byte)159, byte.MaxValue));
break;
default:
((Graphic)caption).color = Color.white;
break;
}
}
}
}
public sealed class JournalScreen : MonoBehaviour
{
private static readonly Color Gold = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)217, (byte)146, byte.MaxValue));
private static readonly Color Parchment = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)239, (byte)202, byte.MaxValue));
private TextMeshProUGUI style;
private TextMeshProUGUI page;
private TextMeshProUGUI summary;
private TextMeshProUGUI count;
private TextMeshProUGUI relicName;
private TextMeshProUGUI description;
private Image buttonStyle;
private Image icon;
private Image crest;
private TextMeshProUGUI day;
private TextMeshProUGUI completed;
private const int StripSize = 5;
private readonly Button[] slots = (Button[])(object)new Button[5];
private readonly Image[] slotIcons = (Image[])(object)new Image[5];
private readonly GameObject[] markers = (GameObject[])(object)new GameObject[5];
private readonly Dictionary<string, RelicDetail> details = new Dictionary<string, RelicDetail>();
private int stripStart;
private int visibleSlots;
private RectTransform overlay;
private RectTransform sheet;
private RectTransform play;
private RectTransform viewport;
private Button launcher;
private Button newer;
private Button older;
private Button previous;
private Button next;
private Button back;
private ControlHint submitHint;
private ControlHint cancelHint;
private Action<TitleScreenManager> openOverlay;
private Action<TitleScreenManager> closeOverlay;
private TitleScreenManager title;
private List<CompletedRun> runs;
private int runIndex;
private int relicIndex;
private bool readFailed;
private static readonly Vector2 PageSize = new Vector2(780f, 520f);
internal static JournalScreen Current { get; private set; }
internal bool IsOpen
{
get
{
if ((Object)(object)overlay != (Object)null)
{
return ((Component)overlay).gameObject.activeSelf;
}
return false;
}
}
internal void Attach(TitleScreenManager manager, GameObject first, GameObject settings, GameObject continueOverlay)
{
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Expected O, but got Unknown
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Expected O, but got Unknown
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: 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_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: 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_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: 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_01e0: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
//IL_027d: Unknown result type (might be due to invalid IL or missing references)
//IL_029d: Unknown result type (might be due to invalid IL or missing references)
//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
//IL_0301: Unknown result type (might be due to invalid IL or missing references)
//IL_0346: Unknown result type (might be due to invalid IL or missing references)
//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
//IL_0435: Unknown result type (might be due to invalid IL or missing references)
//IL_0466: Unknown result type (might be due to invalid IL or missing references)
//IL_04bf: Unknown result type (might be due to invalid IL or missing references)
//IL_04c4: Unknown result type (might be due to invalid IL or missing references)
//IL_04f0: Unknown result type (might be due to invalid IL or missing references)
//IL_054d: Unknown result type (might be due to invalid IL or missing references)
//IL_0591: Unknown result type (might be due to invalid IL or missing references)
//IL_060b: Unknown result type (might be due to invalid IL or missing references)
//IL_0256: Unknown result type (might be due to invalid IL or missing references)
//IL_026d: Unknown result type (might be due to invalid IL or missing references)
//IL_069f: Unknown result type (might be due to invalid IL or missing references)
//IL_06e8: Unknown result type (might be due to invalid IL or missing references)
title = manager;
openOverlay = AccessTools.MethodDelegate<Action<TitleScreenManager>>(AccessTools.Method(typeof(TitleScreenManager), "OpenOverlay", (Type[])null, (Type[])null), (object)null, true);
closeOverlay = AccessTools.MethodDelegate<Action<TitleScreenManager>>(AccessTools.Method(typeof(TitleScreenManager), "CloseOverlay", (Type[])null, (Type[])null), (object)null, true);
style = first.GetComponentInChildren<TextMeshProUGUI>(true);
buttonStyle = first.GetComponent<Image>();
Canvas rootCanvas = first.GetComponentInParent<Canvas>(true).rootCanvas;
RectTransform val = (play = (RectTransform)first.transform);
viewport = (RectTransform)((Component)rootCanvas).transform;
launcher = MakeButton(((Transform)val).parent, "Relic Journal", Open);
RectTransform val2 = (RectTransform)((Component)launcher).transform;
val2.anchorMin = val.anchorMin;
val2.anchorMax = val.anchorMax;
val2.pivot = val.pivot;
val2.sizeDelta = val.sizeDelta;
Vector2 anchoredPosition = val.anchoredPosition;
Vector2 right = Vector2.right;
Rect rect = val.rect;
val2.anchoredPosition = anchoredPosition - right * (((Rect)(ref rect)).width + 12f);
((Transform)val2).SetSiblingIndex(settings.transform.GetSiblingIndex());
FitLauncher();
Current = this;
overlay = Box(((Component)rootCanvas).transform, "Relic Loadout Journal", Color32.op_Implicit(new Color32((byte)20, (byte)14, (byte)12, (byte)237)));
Stretch(overlay);
((Component)overlay).gameObject.SetActive(false);
sheet = Box((Transform)(object)overlay, "Journal", Color32.op_Implicit(new Color32((byte)94, (byte)67, (byte)46, byte.MaxValue)));
RectTransform obj = sheet;
RectTransform obj2 = sheet;
RectTransform obj3 = sheet;
Vector2 val3 = default(Vector2);
((Vector2)(ref val3))..ctor(0.5f, 0.5f);
obj3.pivot = val3;
Vector2 anchorMin = (obj2.anchorMax = val3);
obj.anchorMin = anchorMin;
sheet.anchoredPosition = Vector2.zero;
Transform obj4 = continueOverlay.transform.Find("Panel");
Image val5 = ((obj4 != null) ? ((Component)obj4).GetComponent<Image>() : null);
if ((Object)(object)val5 != (Object)null && (Object)(object)val5.sprite != (Object)null)
{
Image component = ((Component)sheet).GetComponent<Image>();
component.sprite = val5.sprite;
component.type = val5.type;
component.pixelsPerUnitMultiplier = val5.pixelsPerUnitMultiplier;
((Graphic)component).color = ((Graphic)val5).color;
}
sheet.sizeDelta = PageSize;
Stretch(Box((Transform)(object)sheet, "Page", Color32.op_Implicit(new Color32((byte)52, (byte)38, (byte)32, byte.MaxValue))), 10f);
Place(((TMP_Text)Label((Transform)(object)sheet, "Relic Loadout Journal", 38f, Gold)).rectTransform, 24f, 12f, 732f, 54f);
page = Label((Transform)(object)sheet, "", 23f, Parchment);
Place(((TMP_Text)page).rectTransform, 205f, 74f, 370f, 29f);
completed = Label((Transform)(object)sheet, "", 20f, Parchment);
Place(((TMP_Text)completed).rectTransform, 205f, 103f, 370f, 26f);
newer = PageButton("Newer run", 30f, 80f, delegate
{
ChangeRun(-1);
});
older = PageButton("Older run", 570f, 80f, delegate
{
ChangeRun(1);
});
crest = ((Component)Box((Transform)(object)sheet, "Kingdom crest", Color.white)).GetComponent<Image>();
crest.preserveAspect = true;
((Graphic)crest).raycastTarget = false;
Place(((Graphic)crest).rectTransform, 44f, 142f, 42f, 42f);
summary = Label((Transform)(object)sheet, "", 31f, Gold);
((TMP_Text)summary).alignment = (TextAlignmentOptions)4097;
day = Label((Transform)(object)sheet, "", 29f, Parchment);
((TMP_Text)day).alignment = (TextAlignmentOptions)4100;
Place(((TMP_Text)day).rectTransform, 550f, 137f, 186f, 50f);
RectTransform val6 = Box((Transform)(object)sheet, "Held relic", Color32.op_Implicit(new Color32((byte)37, (byte)28, (byte)25, byte.MaxValue)));
Place(val6, 28f, 195f, 724f, 190f);
icon = ((Component)Box((Transform)(object)val6, "Relic icon", Color.white)).GetComponent<Image>();
((Graphic)icon).raycastTarget = false;
icon.preserveAspect = true;
Place(((Graphic)icon).rectTransform, 24f, 48f, 90f, 90f);
relicName = Label((Transform)(object)val6, "", 32f, Gold);
((TMP_Text)relicName).alignment = (TextAlignmentOptions)4097;
((TMP_Text)relicName).overflowMode = (TextOverflowModes)1;
((TMP_Text)relicName).parseCtrlCharacters = false;
description = Label((Transform)(object)val6, "", 30f, Parchment);
((TMP_Text)description).alignment = (TextAlignmentOptions)4097;
previous = PageButton("Previous relic", 30f, 398f, delegate
{
ChangeRelic(-1);
});
next = PageButton("Next relic", 570f, 398f, delegate
{
ChangeRelic(1);
});
count = Label((Transform)(object)val6, "", 21f, Parchment);
((TMP_Text)count).alignment = (TextAlignmentOptions)4097;
for (int num = 0; num < 5; num++)
{
int slot = num;
Button val7 = MakeButton((Transform)(object)sheet, "?", delegate
{
InspectSlot(slot);
});
((Object)val7).name = "Held relic " + (num + 1);
slots[num] = val7;
Image component2 = ((Component)Box(((Component)val7).transform, "Icon", Color.white)).GetComponent<Image>();
((Graphic)component2).raycastTarget = false;
component2.preserveAspect = true;
Stretch(((Graphic)component2).rectTransform, 7f);
slotIcons[num] = component2;
RectTransform val8 = Box(((Component)val7).transform, "Inspected relic", Parchment);
((Graphic)((Component)val8).GetComponent<Image>()).raycastTarget = false;
Place(val8, 7f, 50f, 34f, 3f);
markers[num] = ((Component)val8).gameObject;
}
back = PageButton("Back", 300f, 460f, Close);
submitHint = new ControlHint(sheet, "Select", 30f, Label);
cancelHint = new ControlHint(sheet, "Back", 540f, Label);
}
private void Open()
{
if (IsOpen || !title.IsOpen())
{
return;
}
readFailed = false;
try
{
runs = Plugin.CurrentJournal().Read(delegate(string message)
{
readFailed = true;
Plugin.Warn(message);
});
}
catch (Exception ex)
{
Plugin.Warn("Could not read history: " + ex.Message);
runs = new List<CompletedRun>();
readFailed = true;
}
runIndex = (relicIndex = 0);
details.Clear();
openOverlay(title);
((Transform)overlay).SetAsLastSibling();
((Component)overlay).gameObject.SetActive(true);
Fit();
Render();
Focus((visibleSlots > 0) ? slots[0] : (((Selectable)older).interactable ? older : back));
}
internal void Close()
{
if (IsOpen)
{
((Component)overlay).gameObject.SetActive(false);
closeOverlay(title);
Focus(launcher);
}
}
private static void Focus(Button button)
{
GamepadManager.Instance.SetGameObjectToSelect(((Component)button).gameObject, true);
EventSystem current = EventSystem.current;
if (current != null)
{
current.SetSelectedGameObject(((Component)button).gameObject);
}
}
private void Update()
{
if (!IsOpen)
{
if ((Object)(object)launcher != (Object)null && ((Component)launcher).gameObject.activeInHierarchy)
{
FitLauncher();
}
return;
}
Fit();
EventSystem current = EventSystem.current;
BaseInputModule obj = ((current != null) ? current.currentInputModule : null);
InputSystemUIInputModule val = (InputSystemUIInputModule)(object)((obj is InputSystemUIInputModule) ? obj : null);
bool flag = GamepadManager.Instance.IsGamepadInUse();
ControlHint controlHint = submitHint;
object action;
if (val == null)
{
action = null;
}
else
{
InputActionReference submit = val.submit;
action = ((submit != null) ? submit.action : null);
}
controlHint.Refresh((InputAction)action, flag);
ControlHint controlHint2 = cancelHint;
object action2;
if (val == null)
{
action2 = null;
}
else
{
InputActionReference cancel = val.cancel;
action2 = ((cancel != null) ? cancel.action : null);
}
controlHint2.Refresh((InputAction)action2, flag);
if (flag && (Object)(object)EventSystem.current != (Object)null)
{
GameObject currentSelectedGameObject = EventSystem.current.currentSelectedGameObject;
Button val2 = default(Button);
if ((Object)(object)currentSelectedGameObject == (Object)null || !currentSelectedGameObject.transform.IsChildOf((Transform)(object)overlay) || !currentSelectedGameObject.activeInHierarchy || (currentSelectedGameObject.TryGetComponent<Button>(ref val2) && !((Selectable)val2).IsInteractable()))
{
Focus((visibleSlots > 0) ? slots[relicIndex - stripStart] : back);
}
}
}
private void FitLauncher()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: 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_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: 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_0059: 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_007a: 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_009a: Expected O, but got Unknown
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
RectTransform obj = viewport;
Rect rect = viewport.rect;
float xMin = ((Rect)(ref rect)).xMin;
rect = viewport.rect;
Vector3 val = ((Transform)obj).TransformPoint(new Vector3(xMin, ((Rect)(ref rect)).center.y));
rect = play.rect;
float num = ((Rect)(ref rect)).xMin - ((Transform)play).InverseTransformPoint(val).x - 22f;
rect = play.rect;
float num2 = Mathf.Clamp(num, 1f, ((Rect)(ref rect)).width);
RectTransform val2 = (RectTransform)((Component)launcher).transform;
rect = val2.rect;
if (!Mathf.Approximately(((Rect)(ref rect)).width, num2))
{
val2.SetSizeWithCurrentAnchors((Axis)0, num2);
}
Vector2 anchoredPosition = play.anchoredPosition;
ref float x = ref anchoredPosition.x;
float num3 = x;
rect = play.rect;
x = num3 + (((Rect)(ref rect)).xMin - 12f - (1f - val2.pivot.x) * num2);
if (val2.anchoredPosition != anchoredPosition)
{
val2.anchoredPosition = anchoredPosition;
}
}
private void Fit()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: 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)
RectTransform obj = sheet;
Vector3 one = Vector3.one;
Rect rect = overlay.rect;
((Transform)obj).localScale = one * FitScale(((Rect)(ref rect)).size);
}
internal static float FitScale(Vector2 available)
{
//IL_0000: 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)
return Mathf.Clamp(Mathf.Min(available.x / (PageSize.x + 20f), available.y / (PageSize.y + 20f)), 0f, 1f);
}
private void ChangeRun(int delta)
{
runIndex = Mathf.Clamp(runIndex + delta, 0, runs.Count - 1);
relicIndex = 0;
details.Clear();
Render();
if (delta > 0 && !((Selectable)older).interactable)
{
Focus(newer);
}
if (delta < 0 && !((Selectable)newer).interactable)
{
Focus(older);
}
}
private void ChangeRelic(int delta)
{
relicIndex = Mathf.Clamp(relicIndex + delta, 0, runs[runIndex].Relics.Length - 1);
Render();
if (delta > 0 && !((Selectable)next).interactable)
{
Focus(previous);
}
if (delta < 0 && !((Selectable)previous).interactable)
{
Focus(next);
}
}
private void InspectSlot(int slot)
{
relicIndex = stripStart + slot;
Render();
Focus(slots[slot]);
}
private RelicDetail Detail(string id)
{
if (!details.TryGetValue(id, out var value))
{
value = (details[id] = RelicDetail.Resolve(id));
}
return value;
}
private void Render()
{
//IL_0372: Unknown result type (might be due to invalid IL or missing references)
//IL_03aa: Expected O, but got Unknown
CompletedRun completedRun = ((runs.Count == 0) ? null : runs[runIndex]);
int num = ((completedRun != null) ? completedRun.Relics.Length : 0);
((Selectable)newer).interactable = runIndex > 0;
((Selectable)older).interactable = runIndex + 1 < runs.Count;
((Selectable)previous).interactable = relicIndex > 0;
((Selectable)next).interactable = relicIndex + 1 < num;
((TMP_Text)page).text = ((completedRun == null) ? "" : $"Run {runs.Count - runIndex} of {runs.Count}");
((TMP_Text)count).text = ((num == 0) ? "" : $"Relic {relicIndex + 1} of {num}");
ShowRun(completedRun);
string text = ((num == 0) ? null : completedRun.Relics[relicIndex]);
RelicDetail relicDetail = ((text == null) ? null : Detail(text));
icon.sprite = relicDetail?.Icon;
((Behaviour)icon).enabled = (Object)(object)icon.sprite != (Object)null;
((TMP_Text)relicName).fontSizeMin = 21f;
if (((Behaviour)icon).enabled)
{
Place(((TMP_Text)count).rectTransform, 138f, 12f, 560f, 27f);
Place(((TMP_Text)relicName).rectTransform, 138f, 42f, 560f, 47f);
Place(((TMP_Text)description).rectTransform, 138f, 91f, 560f, 86f);
}
else
{
Place(((TMP_Text)count).rectTransform, 22f, 10f, 680f, 27f);
Place(((TMP_Text)relicName).rectTransform, 22f, 39f, 680f, 80f);
Place(((TMP_Text)description).rectTransform, 22f, 119f, 680f, 61f);
}
if (num == 0)
{
Place(((TMP_Text)description).rectTransform, 22f, 22f, 680f, 145f);
}
((TMP_Text)relicName).text = relicDetail?.Name ?? "";
((TMP_Text)description).richText = relicDetail != null;
((TMP_Text)description).text = relicDetail?.Description?.Replace("<color=blue>", "<color=#9DC4FF>").Replace("<color=purple>", "<color=#D7A4FF>") ?? ((completedRun != null) ? "No relics held." : (readFailed ? "See the BepInEx log for details." : "Finish a run to see its relics here."));
stripStart = relicIndex / 5 * 5;
visibleSlots = Math.Min(num - stripStart, 5);
for (int i = 0; i < 5; i++)
{
((Component)slots[i]).gameObject.SetActive(i < visibleSlots);
if (i < visibleSlots)
{
Place((RectTransform)((Component)slots[i]).transform, 390f - (float)(visibleSlots * 56 - 8) / 2f + (float)(i * 56), 396f, 48f, 48f);
Sprite val = Detail(completedRun.Relics[stripStart + i]).Icon;
slotIcons[i].sprite = val;
((Behaviour)slotIcons[i]).enabled = (Object)(object)val != (Object)null;
((Behaviour)((Component)slots[i]).GetComponentInChildren<TextMeshProUGUI>(true)).enabled = (Object)(object)val == (Object)null;
markers[i].SetActive(stripStart + i == relicIndex);
}
}
WireNavigation();
}
private unsafe void ShowRun(CompletedRun run)
{
//IL_0093: 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)
((TMP_Text)completed).text = ((run == null) ? "" : run.CompletedUtc.ToLocalTime().ToString("d"));
((TMP_Text)day).text = ((run == null) ? "" : $"Day {run.FinalDay}");
crest.sprite = null;
if (run == null)
{
((TMP_Text)summary).text = (readFailed ? "History unavailable" : "No completed runs yet");
}
else
{
Races val = (Races)run.Kingdom;
((TMP_Text)summary).text = ((object)(*(Races*)(&val))/*cast due to .constrained prefix*/).ToString() + " / " + run.Hero;
try
{
PrefabsManager instance = PrefabsManager.Instance;
KingdomData val2 = ((instance != null) ? instance.GetKingdomData(val) : null);
AddressablesManager instance2 = AddressablesManager.Instance;
Hero val3 = ((instance2 != null) ? instance2.GetHero(run.Hero) : null);
crest.sprite = (((Object)(object)val2 != (Object)null) ? val2.GetIcon() : null);
((TMP_Text)summary).text = (((Object)(object)val2 != (Object)null) ? val2.GetTitle() : ((object)(*(Races*)(&val))/*cast due to .constrained prefix*/).ToString()) + " / " + (((Object)(object)val3 != (Object)null) ? ((Entity)val3).GetName(true) : run.Hero);
}
catch (Exception ex)
{
Plugin.Warn("Could not display run details: " + ex.Message);
}
}
((Behaviour)crest).enabled = (Object)(object)crest.sprite != (Object)null;
Place(((TMP_Text)summary).rectTransform, ((Behaviour)crest).enabled ? 100 : 44, 136f, ((Behaviour)crest).enabled ? 444 : 500, 54f);
}
private void WireNavigation()
{
//IL_01e0: 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)
Button val = Available(newer, older);
Button val2 = Available(older, newer);
Button val3 = Available(previous, next);
Button val4 = Available(next, previous);
Link(newer, older, back, val3 ?? back);
Link(older, newer, back, val4 ?? back);
Link(previous, next, val ?? back, back);
Link(next, previous, val2 ?? back, back);
Link(back, back, val3 ?? val ?? back, val ?? val3 ?? back);
if (visibleSlots != 0)
{
Button val5 = slots[relicIndex - stripStart];
Link(newer, older, back, val5);
Link(older, newer, back, val5);
Link(back, back, val5, val ?? val5);
for (int i = 0; i < visibleSlots; i++)
{
Button val6 = slots[i];
Button selectOnLeft = ((i > 0) ? slots[i - 1] : (((Selectable)previous).interactable ? previous : val6));
Button selectOnRight = ((i + 1 < visibleSlots) ? slots[i + 1] : (((Selectable)next).interactable ? next : val6));
Navigation navigation = default(Navigation);
((Navigation)(ref navigation)).mode = (Mode)4;
((Navigation)(ref navigation)).selectOnLeft = (Selectable)(object)selectOnLeft;
((Navigation)(ref navigation)).selectOnRight = (Selectable)(object)selectOnRight;
((Navigation)(ref navigation)).selectOnUp = (Selectable)(object)(val ?? back);
((Navigation)(ref navigation)).selectOnDown = (Selectable)(object)back;
((Selectable)val6).navigation = navigation;
}
Link(previous, slots[0], val ?? back, back);
Link(next, slots[visibleSlots - 1], val2 ?? back, back);
}
}
private static Button Available(Button first, Button second)
{
if (!((Selectable)first).interactable)
{
if (!((Selectable)second).interactable)
{
return null;
}
return second;
}
return first;
}
private static void Link(Button button, Button across, Button up, Button down)
{
//IL_0010: 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)
Button val = (((Selectable)across).interactable ? across : button);
Navigation navigation = default(Navigation);
((Navigation)(ref navigation)).mode = (Mode)4;
((Navigation)(ref navigation)).selectOnLeft = (Selectable)(object)val;
((Navigation)(ref navigation)).selectOnRight = (Selectable)(object)val;
((Navigation)(ref navigation)).selectOnUp = (Selectable)(object)up;
((Navigation)(ref navigation)).selectOnDown = (Selectable)(object)down;
((Selectable)button).navigation = navigation;
}
private Button PageButton(string caption, float x, float y, Action click)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
Button obj = MakeButton((Transform)(object)sheet, caption, click);
Place((RectTransform)((Component)obj).transform, x, y, 180f, 44f);
return obj;
}
private Button MakeButton(Transform parent, string caption, Action click)
{
//IL_000f: 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_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: 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_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Expected O, but got Unknown
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
RectTransform val = Box(parent, caption, Color.white);
Image component = ((Component)val).GetComponent<Image>();
component.sprite = buttonStyle.sprite;
component.type = buttonStyle.type;
component.pixelsPerUnitMultiplier = buttonStyle.pixelsPerUnitMultiplier;
JournalButton journalButton = ((Component)val).gameObject.AddComponent<JournalButton>();
((Selectable)journalButton).targetGraphic = (Graphic)(object)component;
ColorBlock colors = ((Selectable)journalButton).colors;
((ColorBlock)(ref colors)).normalColor = Color32.op_Implicit(new Color32((byte)115, (byte)84, (byte)60, byte.MaxValue));
Color selectedColor = (((ColorBlock)(ref colors)).highlightedColor = Gold);
((ColorBlock)(ref colors)).selectedColor = selectedColor;
((ColorBlock)(ref colors)).disabledColor = Color32.op_Implicit(new Color32((byte)85, (byte)74, (byte)68, (byte)190));
((Selectable)journalButton).colors = colors;
((UnityEvent)((Button)journalButton).onClick).AddListener((UnityAction)delegate
{
click();
});
TextMeshProUGUI val2 = Label((Transform)(object)val, caption, 28f, Color.white);
journalButton.SetCaption(val2);
Stretch(((TMP_Text)val2).rectTransform, 3f);
return (Button)(object)journalButton;
}
private TextMeshProUGUI Label(Transform parent, string caption, float size, Color color)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("Text", new Type[1] { typeof(RectTransform) });
val.transform.SetParent(parent, false);
TextMeshProUGUI obj = val.AddComponent<TextMeshProUGUI>();
((TMP_Text)obj).font = ((TMP_Text)style).font;
((TMP_Text)obj).fontSharedMaterial = ((TMP_Text)style).fontSharedMaterial;
((TMP_Text)obj).spriteAsset = ((TMP_Text)style).spriteAsset;
((TMP_Text)obj).alignment = (TextAlignmentOptions)514;
((TMP_Text)obj).fontSize = size;
((TMP_Text)obj).enableWordWrapping = true;
((TMP_Text)obj).enableAutoSizing = true;
((TMP_Text)obj).fontSizeMin = 13f;
((TMP_Text)obj).fontSizeMax = size;
((Graphic)obj).color = color;
((Graphic)obj).raycastTarget = false;
((TMP_Text)obj).richText = false;
((TMP_Text)obj).text = caption;
return obj;
}
internal static RectTransform Box(Transform parent, string name, Color color)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: 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_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Expected O, but got Unknown
GameObject val = new GameObject(name, new Type[2]
{
typeof(RectTransform),
typeof(Image)
});
val.transform.SetParent(parent, false);
((Graphic)val.GetComponent<Image>()).color = color;
return (RectTransform)val.transform;
}
private static void Stretch(RectTransform rect, float margin = 0f)
{
//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)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0033: Unknown result type (might be due to invalid IL or missing references)
rect.anchorMin = Vector2.zero;
rect.anchorMax = Vector2.one;
rect.offsetMin = Vector2.one * margin;
rect.offsetMax = -Vector2.one * margin;
}
internal static void Place(RectTransform rect, float x, float y, float width, float height)
{
//IL_0003: 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_0009: 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_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: 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_002f: Unknown result type (might be due to invalid IL or missing references)
Vector2 val = (rect.pivot = Vector2.up);
Vector2 anchorMin = (rect.anchorMax = val);
rect.anchorMin = anchorMin;
rect.anchoredPosition = new Vector2(x, 0f - y);
rect.sizeDelta = new Vector2(width, height);
}
private void OnDestroy()
{
if ((Object)(object)Current == (Object)(object)this)
{
Current = null;
}
if (IsOpen && (Object)(object)title != (Object)null)
{
Close();
}
if ((Object)(object)launcher != (Object)null)
{
Object.Destroy((Object)(object)((Component)launcher).gameObject);
}
if ((Object)(object)overlay != (Object)null)
{
Object.Destroy((Object)(object)((Component)overlay).gameObject);
}
}
}
[BepInPlugin("sfk.relicloadoutjournal", "Relic Loadout Journal", "0.1.2")]
public sealed class Plugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(MainManager), "LoadTitleScene")]
private static class Complete
{
private static void Prefix(bool runComplete)
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected I4, but got Unknown
if (!runComplete)
{
return;
}
try
{
CompletedRun run = new CompletedRun
{
RunId = Guid.Parse(GameDataManager.Instance.GetRunID()),
CompletedUtc = DateTime.UtcNow,
Kingdom = (int)RaceManager.Instance.GetRace(),
Hero = ((Entity)UnitManager.Instance.GetHero()).GetEntityIdentifier(),
FinalDay = DaytimeManager.Instance.CurrentDay(),
Relics = (from r in RelicManager.Instance.GetRelics()
where (Object)(object)r != (Object)null
select ((Object)r).name).ToArray()
};
CurrentJournal().Append(run);
}
catch (Exception ex)
{
Warn("Could not record completed run: " + ex.Message);
}
}
}
[HarmonyPatch(typeof(TitleScreenManager), "Start")]
private static class TitleMenu
{
private static void Postfix(TitleScreenManager __instance, GameObject ___firstButton, GameObject ___settingsButton, GameObject ___continueOverlay)
{
try
{
((Component)__instance).gameObject.AddComponent<JournalScreen>().Attach(__instance, ___firstButton, ___settingsButton, ___continueOverlay);
}
catch (Exception ex)
{
Warn("Could not attach journal: " + ex.Message);
}
}
}
[HarmonyPatch(typeof(TitleScreenManager), "Close", new Type[] { })]
private static class Back
{
private static bool Prefix()
{
if ((Object)(object)JournalScreen.Current == (Object)null || !JournalScreen.Current.IsOpen)
{
return true;
}
JournalScreen.Current.Close();
return false;
}
}
internal const string Id = "sfk.relicloadoutjournal";
private static Plugin instance;
private Harmony patches;
private void Awake()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected O, but got Unknown
instance = this;
patches = new Harmony("sfk.relicloadoutjournal");
patches.PatchAll(typeof(Plugin).Assembly);
}
private void OnDestroy()
{
Harmony obj = patches;
if (obj != null)
{
obj.UnpatchSelf();
}
instance = null;
if ((Object)(object)JournalScreen.Current != (Object)null)
{
Object.Destroy((Object)(object)JournalScreen.Current);
}
}
internal static void Warn(string message)
{
Plugin plugin = instance;
if (plugin != null)
{
((BaseUnityPlugin)plugin).Logger.LogWarning((object)message);
}
}
internal static Journal CurrentJournal()
{
return new Journal(Path.Combine(Application.persistentDataPath, "RelicLoadoutJournal"), SettingsManager.Instance.GetProfile() + 1);
}
}
internal sealed class RelicDetail
{
internal string Name;
internal string Description;
internal Sprite Icon;
internal static RelicDetail Resolve(string id)
{
RelicDetail relicDetail = new RelicDetail
{
Name = id,
Description = "Relic unavailable in this installation."
};
try
{
AddressablesManager instance = AddressablesManager.Instance;
Relic val = ((instance != null) ? instance.GetRelic(id) : null);
if ((Object)(object)val == (Object)null)
{
return relicDetail;
}
relicDetail.Icon = ((Item)val).GetIcon();
string title = ((Item)val).GetTitle();
if (!string.IsNullOrWhiteSpace(title))
{
relicDetail.Name = title;
}
relicDetail.Description = ((Item)val).GetDescription();
}
catch (Exception ex)
{
relicDetail.Description = "Relic details unavailable.";
Plugin.Warn("Could not display relic " + id + ": " + ex.Message);
}
return relicDetail;
}
}