Decompiled source of Journal Aventure v0.20.2
plugins/OutwardJournal.dll
Decompiled 19 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("OutwardJournal")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("OutwardJournal")] [assembly: AssemblyTitle("OutwardJournal")] [assembly: AssemblyVersion("1.0.0.0")] namespace OutwardJournal; internal class KillInfo { public string Name; public string Key; public int Count; } internal static class AutoEntries { private class Group { public string Name; public string Key; public int Count; } private static readonly List<Group> _pending = new List<Group>(); private static float _last; private static string _place = ""; private static string _time = ""; private static int _day; private static readonly Random Rnd = new Random(); public static void OnKill(string name, string obj, string locKey) { if (string.IsNullOrEmpty(name)) { name = "ennemi"; } Group obj2 = _pending.Find((Group x) => x.Name == name); if (obj2 == null) { obj2 = new Group(); obj2.Name = name; obj2.Key = (NotebookView.HasCreature(locKey) ? ("k_" + locKey) : SketchKey(name, obj)); _pending.Add(obj2); } obj2.Count++; _last = Time.unscaledTime; _place = Rx.GetPlaceName(); _time = Rx.GetGameTime(); _day = Rx.GetGameDay(); } public static void Tick() { if (_pending.Count != 0 && !(Time.unscaledTime < _last + 12f)) { try { Flush(); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Journal : entrée automatique : " + ex.Message)); } _pending.Clear(); } } private static void Flush() { if ((Object)(object)Plugin.Instance == (Object)null) { return; } object localCharacter = Rx.GetLocalCharacter(); if (localCharacter == null) { return; } string text = Convert.ToString(Rx.Get(localCharacter, "UID")); if (string.IsNullOrEmpty(text)) { text = Convert.ToString(Rx.Get(localCharacter, "Name")); } if (string.IsNullOrEmpty(text) || !Plugin.Instance.AutoEntriesEnabled(text)) { return; } List<KillInfo> list = new List<KillInfo>(); List<string> list2 = new List<string>(); foreach (Group item in _pending) { KillInfo killInfo = new KillInfo(); killInfo.Name = item.Name; killInfo.Key = item.Key; killInfo.Count = item.Count; list.Add(killInfo); list2.Add((item.Count > 1) ? (item.Count + " x " + item.Name) : item.Name); } List<string> list3 = new List<string>(); if (_day > 0) { list3.Add("Jour " + _day); } if (_place.Length > 0) { list3.Add(_place); } string when = ((list3.Count > 0) ? string.Join(", ", list3.ToArray()) : "?"); Plugin.Instance.RecordKills(text, list, when); Plugin.NotifyPlayer(localCharacter, "Carnet : victoire notée (" + string.Join(", ", list2.ToArray()) + ")."); Plugin.Log.LogInfo((object)("[Diag] victoires notées : " + string.Join(", ", list2.ToArray()))); } private static string NewBlock(KillInfo k, string when) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("§ ").Append(k.Name).Append('\n'); stringBuilder.Append("Vaincus : ").Append(k.Count).Append('\n'); stringBuilder.Append("Première victoire : ").Append(when).Append('\n'); stringBuilder.Append("Dernière victoire : ").Append(when).Append('\n'); stringBuilder.Append("[dessin:").Append(k.Key).Append("]"); for (int i = 0; i < 7; i++) { stringBuilder.Append("\n\u00a0"); } return stringBuilder.ToString(); } public static string ApplyKills(string book, List<KillInfo> kills, string when) { book = book ?? ""; foreach (KillInfo kill in kills) { Match match = new Regex("^§ " + Regex.Escape(kill.Name) + "[ \\t]*$", RegexOptions.Multiline).Match(book); if (!match.Success) { book = NotebookView.Append(book, NewBlock(kill, when)); continue; } string text = book.Substring(0, match.Index); string input = book.Substring(match.Index); int add = kill.Count; input = new Regex("^Vaincus : (\\d+)", RegexOptions.Multiline).Replace(input, delegate(Match m) { int.TryParse(m.Groups[1].Value, out var result); return "Vaincus : " + (result + add); }, 1); string w = when; input = new Regex("^Dernière victoire : .*$", RegexOptions.Multiline).Replace(input, (Match m) => "Dernière victoire : " + w, 1); book = text + input; } return book; } private static string Plain(string t) { StringBuilder stringBuilder = new StringBuilder(); string text = (t ?? "").Normalize(NormalizationForm.FormD); foreach (char c in text) { if (CharUnicodeInfo.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark) { stringBuilder.Append(char.IsLetterOrDigit(c) ? char.ToLowerInvariant(c) : ' '); } } return " " + stringBuilder.ToString() + " "; } private static string SketchKey(string name, string obj) { string s = Plain(name) + Plain(obj); Func<string, bool> func = (string w) => s.Contains(w); Func<string, bool> func2 = (string w) => s.Contains(" " + w + " "); if (func("troglodyte")) { return "creature"; } if (func("oiseau") || func("bird")) { return "oiseau"; } if (func("bandit")) { if (!func("elite") && !func("lieutenant") && !func("chef")) { return "b_bandit"; } return "b_bandit_elite"; } if (func("pillard") || func("raider")) { if (!func("elite") && !func("lieutenant") && !func("chef")) { return "b_pillard"; } return "b_pillard_elite"; } if (func("garou") || func("werewolf")) { return "b_loup_garou"; } if (func("loup") || func("wolf")) { if (!func("neige") && !func("snow") && !func("blanc")) { return "b_loup"; } return "b_loup_neiges"; } if (func("hyen") || func("hyena")) { return "hyene"; } if (func("cerf") || func("deer")) { return "b_cerf"; } if (func("sanglier") || func("boar")) { return "b_sanglier"; } if (func2("ours") || func2("bear")) { return "b_ours"; } if (func("geant") || func("giant")) { return "b_geant_pierre"; } if (func("golem")) { if (!func("cuivre") && !func("copper") && !func("bronze")) { return "b_golem_pierre"; } return "b_golem_cuivre"; } if (func("squelette") || func("skeleton")) { if (!func("archer")) { if (!func("guerrier") && !func("warrior")) { return "b_squelette"; } return "b_squelette_guerrier"; } return "b_squelette_archer"; } if (func("machefer") || func("ashen") || func("immaculate")) { return "b_machefer"; } if (func("wendigo")) { return "b_wendigo"; } if (func("troll")) { if (!func("marais") && !func("swamp")) { return "b_troll"; } return "b_troll_marais"; } if (func("chaman") || func("shaman")) { return "b_chaman"; } if (func("maraudeur") || func("marauder")) { return "b_maraudeur"; } if (func("defenseur") || func("antre") || func("lair")) { return "b_defenseur"; } if (func("elementaire") || func("elemental")) { if (func("terre") || func("earth")) { return "b_elem_terre"; } if (func("glace") || func("ice")) { return "b_elem_glace"; } if (func("feu") || func("fire")) { return "b_elem_feu"; } return "b_elem_vent"; } if (func("araignee") || func("spider")) { if (!func("venim") && !func("poison")) { return "b_araignee"; } return "b_araignee_venimeuse"; } if (func("scorpion")) { return "b_scorpion"; } if (func("harpy") || func("harpie")) { return "b_harpye"; } if (func("chauve") || func("bat ")) { return "b_chauve_souris"; } if (func("guepe") || func("wasp")) { return "b_guepe"; } if (func("mante") || func("mantis")) { return "b_mante"; } if (func("tortue") || func("turtle")) { return "b_tortue"; } if (func("crabe") || func("crab")) { return "b_crabe"; } if (func2("ver") || func("worm")) { if (!func("cendre") && !func("ash")) { return "b_ver_sables"; } return "b_ver_cendre"; } if (func("goule") || func("ghoul")) { return "b_goule"; } if (func("spectre") || func("ghost") || func("phantom")) { return "b_spectre"; } if (func("vampire")) { return "b_vampire"; } if (func("liche") || func("lich")) { return "b_liche"; } if (func("djinn")) { return "b_djinn"; } if (func("archonte") || func("archon")) { return "b_archonte"; } if (func("garde") || func("guard")) { return "b_garde_cour"; } if (func("soldat") || func("soldier")) { return "b_soldat_imperial"; } if (func("mage")) { return "b_mage_cour"; } if (func("emissaire") || func("emissary")) { if (!func("maudit") && !func("cursed")) { return "b_emissaire"; } return "b_emissaire_maudit"; } return "crane"; } } internal static class Campfire { private static string _path; private static float _lastEvent = -100f; private static float _askUntil; public static void Install() { Type type = Rx.FindType("HarmonyLib.Harmony"); Type type2 = Rx.FindType("HarmonyLib.HarmonyMethod"); Type type3 = Rx.FindType("Deployable"); if (type == null || type2 == null || type3 == null) { Plugin.Log.LogWarning((object)"Journal : détection du feu de camp impossible (Harmony ou Deployable introuvable)."); return; } try { string text = Path.Combine(Paths.ConfigPath, "OutwardJournal"); Directory.CreateDirectory(text); _path = Path.Combine(text, "deploy.log"); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Journal : deploy.log : " + ex.Message)); return; } object obj = Activator.CreateInstance(type, "outwardjournal.adventurer.camp"); object obj2 = Activator.CreateInstance(type2, typeof(Campfire).GetMethod("Postfix", BindingFlags.Static | BindingFlags.Public)); MethodInfo methodInfo = null; MethodInfo[] methods = type.GetMethods(); foreach (MethodInfo methodInfo2 in methods) { if (!(methodInfo2.Name != "Patch")) { ParameterInfo[] parameters = methodInfo2.GetParameters(); if (parameters.Length >= 3 && parameters[0].ParameterType == typeof(MethodBase) && parameters[1].ParameterType == type2) { methodInfo = methodInfo2; break; } } } if (methodInfo == null) { return; } int num = 0; List<string> list = new List<string>(); methods = type3.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo3 in methods) { list.Add(methodInfo3.Name); if (!(methodInfo3.Name != "OnReceiveDeploy") || !(methodInfo3.Name != "StartDeployAnimation")) { try { object[] array = new object[methodInfo.GetParameters().Length]; array[0] = methodInfo3; array[2] = obj2; methodInfo.Invoke(obj, array); num++; } catch (Exception ex2) { Plugin.Log.LogWarning((object)("Journal : patch " + methodInfo3.Name + " : " + ex2.Message)); } } } Plugin.Log.LogInfo((object)("Journal : détection du feu de camp installée (" + num + " méthode(s)) ; méthodes de Deployable : " + string.Join(", ", list.ToArray()))); } public static void Postfix(object __instance) { //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) try { if (__instance == null) { return; } float unscaledTime = Time.unscaledTime; if (unscaledTime < _lastEvent + 3f) { return; } _lastEvent = unscaledTime; Component val = (Component)((__instance is Component) ? __instance : null); Type type = Rx.FindType("Item"); object obj = (((Object)(object)val != (Object)null && type != null) ? val.GetComponent(type) : null); if (obj == null) { obj = Rx.Get(__instance, "ParentItem"); } string text = Convert.ToString(Rx.Get(obj, "Name")); string text2 = Convert.ToString(Rx.Get(obj, "ItemID")); string text3 = (((Object)(object)val != (Object)null) ? ((Object)val.gameObject).name : ""); string text4 = (text + " " + text3).ToLowerInvariant(); bool flag = (text4.Contains("campfire") || text4.Contains("camp fire") || text4.Contains("feu de camp") || text4.Contains("camp_fire")) && !text4.Contains("tent") && !text4.Contains("tente"); try { File.AppendAllText(_path, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " | id=" + text2 + " | nom=" + text + " | objet=" + text3 + " | feu_de_camp=" + (flag ? "oui" : "non") + "\r\n", Encoding.UTF8); } catch { } if (flag) { object localCharacter = Rx.GetLocalCharacter(); if (localCharacter != null && Plugin.CampAsk.Value && ((Rx.Call(Rx.Get(localCharacter, "Inventory"), "ItemCount", 9810001) is int num && num != 0) ? 1 : 0) > (false ? 1 : 0)) { _askUntil = unscaledTime + 45f; Plugin.NotifyPlayer(localCharacter, "Voulez-vous consigner votre voyage ? Appuyez sur " + ((object)Plugin.CampKey.Value/*cast due to .constrained prefix*/).ToString() + " pour ouvrir le carnet."); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Journal : feu de camp : " + ex.Message)); } } public static void Tick() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (_askUntil <= 0f) { return; } if (Time.unscaledTime > _askUntil) { _askUntil = 0f; } else { if (!Input.GetKeyDown(Plugin.CampKey.Value)) { return; } foreach (NotebookView item in Plugin.Instance.ViewsForCamp()) { if (item.Alive && (item.BlocksHotkey || item.IsOpen)) { return; } } _askUntil = 0f; Plugin.Instance.OpenNewEntry(); } } } internal static class KillLog { private static readonly Dictionary<string, float> _recent = new Dictionary<string, float>(); private static string _path; public static void Install() { Type type = Rx.FindType("HarmonyLib.Harmony"); Type type2 = Rx.FindType("HarmonyLib.HarmonyMethod"); Type type3 = Rx.FindType("Character"); if (type == null || type2 == null || type3 == null) { Plugin.Log.LogWarning((object)"Journal : suivi des combats impossible (Harmony ou Character introuvable)."); return; } try { string text = Path.Combine(Paths.ConfigPath, "OutwardJournal"); Directory.CreateDirectory(text); _path = Path.Combine(text, "kills.log"); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Journal : kills.log : " + ex.Message)); return; } object obj = Activator.CreateInstance(type, "outwardjournal.adventurer.kills"); object obj2 = Activator.CreateInstance(type2, typeof(KillLog).GetMethod("Postfix", BindingFlags.Static | BindingFlags.Public)); MethodInfo methodInfo = null; MethodInfo[] methods = type.GetMethods(); foreach (MethodInfo methodInfo2 in methods) { if (!(methodInfo2.Name != "Patch")) { ParameterInfo[] parameters = methodInfo2.GetParameters(); if (parameters.Length >= 3 && parameters[0].ParameterType == typeof(MethodBase) && parameters[1].ParameterType == type2) { methodInfo = methodInfo2; break; } } } if (methodInfo == null) { return; } int num = 0; methods = type3.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo3 in methods) { if (!(methodInfo3.Name != "Die") || !(methodInfo3.Name != "SendDeathRPC")) { try { object[] array = new object[methodInfo.GetParameters().Length]; array[0] = methodInfo3; array[2] = obj2; methodInfo.Invoke(obj, array); num++; } catch (Exception ex2) { Plugin.Log.LogWarning((object)("Journal : patch " + methodInfo3.Name + " : " + ex2.Message)); } } } Plugin.Log.LogInfo((object)("Journal : suivi des combats installé (" + num + " méthode(s)) -> " + _path)); } public static void Postfix(object __instance) { //IL_00c7: Unknown result type (might be due to invalid IL or missing references) try { if (__instance == null || _path == null) { return; } string key = Convert.ToString(Rx.Get(__instance, "UID")); float unscaledTime = Time.unscaledTime; if (_recent.TryGetValue(key, out var value) && unscaledTime < value + 5f) { return; } _recent[key] = unscaledTime; object obj = Rx.Get(__instance, "IsAI"); bool flag = default(bool); int num; if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } bool flag2 = (byte)((uint)num & (flag ? 1u : 0u)) != 0; obj = Rx.Get(__instance, "IsLocalPlayer"); bool flag3 = default(bool); int num2; if (obj is bool) { flag3 = (bool)obj; num2 = 1; } else { num2 = 0; } bool flag4 = (byte)((uint)num2 & (flag3 ? 1u : 0u)) != 0; string text = Convert.ToString(Rx.Get(__instance, "Name")); string text2 = (((Object)((__instance is Component) ? __instance : null) != (Object)null) ? ((Object)((Component)__instance).gameObject).name : ""); string value2 = Convert.ToString(Rx.Get(__instance, "Faction")); string text3 = Convert.ToString(Rx.Get(Rx.GetLocalCharacter(), "UID")); List<string> list = new List<string>(); bool flag5 = false; if (Rx.Get(__instance, "m_lastDealers") is IEnumerable enumerable && !(enumerable is string)) { foreach (object item in enumerable) { object obj2 = Rx.Get(item, "Key"); string text4 = Convert.ToString((obj2 != null) ? obj2 : item); object obj3 = Rx.Get(item, "Value"); list.Add(text4 + ((obj3 != null) ? (":" + Convert.ToString(obj3)) : "")); if (text3.Length > 0 && text4 == text3) { flag5 = true; } } } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")).Append(" | "); stringBuilder.Append("Jour ").Append(Rx.GetGameDay()).Append(' ') .Append(Rx.GetGameTime()) .Append(" | "); stringBuilder.Append(Rx.GetPlaceName()).Append(" | "); stringBuilder.Append("cle=").Append(Convert.ToString(Rx.Get(__instance, "m_nameLocKey"))).Append(" | "); stringBuilder.Append("nom=").Append(text).Append(" | objet=") .Append(text2) .Append(" | faction=") .Append(value2); stringBuilder.Append(" | ia=").Append(flag2 ? "oui" : "non").Append(" | joueur=") .Append(flag4 ? "oui" : "non"); stringBuilder.Append(" | tué_par_moi=").Append(flag5 ? "oui" : "non"); stringBuilder.Append(" | touché_par=").Append(string.Join(",", list.ToArray())); File.AppendAllText(_path, stringBuilder.ToString() + Environment.NewLine, Encoding.UTF8); if (flag5 && flag2 && !flag4) { AutoEntries.OnKill(text, text2, Convert.ToString(Rx.Get(__instance, "m_nameLocKey"))); } } catch (Exception ex) { Plugin.Log.LogDebug((object)("KillLog : " + ex.Message)); } } } internal static class LocDump { private static bool _done; private static float _next; public static void Tick() { if (_done || Time.unscaledTime < _next) { return; } _next = Time.unscaledTime + 5f; try { object obj = Rx.GetStatic(Rx.FindType("LocalizationManager"), "Instance"); if (obj == null) { return; } object obj2 = Rx.Get(obj, "m_generalLocalizationLoaded"); if (!(obj2 is bool) || !(bool)obj2 || !(Rx.Get(obj, "m_generalLocalization") is IDictionary { Count: >=100 } dictionary)) { return; } string text = Convert.ToString(Rx.Get(obj, "CurrentLanguage")); StringBuilder stringBuilder = new StringBuilder(); string text2 = (string.IsNullOrEmpty(text) ? "inconnue" : text); foreach (char c in text2) { stringBuilder.Append(char.IsLetterOrDigit(c) ? c : '_'); } string text3 = Path.Combine(Paths.ConfigPath, "OutwardJournal"); Directory.CreateDirectory(text3); string text4 = Path.Combine(text3, "localisation_" + stringBuilder?.ToString() + ".txt"); _done = true; if (File.Exists(text4)) { return; } StringBuilder stringBuilder2 = new StringBuilder(); foreach (DictionaryEntry item in dictionary) { string text5 = Convert.ToString(item.Value) ?? ""; stringBuilder2.Append(item.Key).Append('\t').Append(text5.Replace("\r", "").Replace("\n", "\\n")) .Append('\n'); } File.WriteAllText(text4, stringBuilder2.ToString(), new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)); Plugin.Log.LogInfo((object)("[Diag] textes du jeu écrits : " + text4 + " (" + dictionary.Count + " entrées)")); } catch (Exception ex) { _done = true; Plugin.Log.LogWarning((object)("Journal : export des textes : " + ex.Message)); } } } internal class NotebookView { private class Slot { public InputField Field; public Text Number; public string Last = ""; public Text Deco; public string DecoSrc = "\u0001"; public readonly List<Image> Pics = new List<Image>(); } private class Leaf { public RectTransform Rt; public Image Img; public Text Txt; public PageCurlMesh ImgFx; public PageCurlMesh TxtFx; public readonly List<Image> Pics = new List<Image>(); public readonly List<PageCurlMesh> PicFx = new List<PageCurlMesh>(); } private class Atlas { public Texture2D Tex; public Dictionary<string, Rect> Rects = new Dictionary<string, Rect>(); } private struct Svf { public float Low; public float Band; public float Process(float x, float fc, float q, int sr) { float num = 2f * Mathf.Sin((float)Math.PI * Mathf.Min(fc, 7000f) / (float)sr); Low += num * Band; float num2 = x - Low - q * Band; Band += num * num2; return Band; } } private const float ImgW = 1024f; private const float ImgH = 700f; private const float WinW = 900f; private const float WinH = 615f; private const float LX0 = 84f; private const float LX1 = 486f; private const float RX0 = 538f; private const float RX1 = 940f; private const float TY0 = 106f; private const float TY1 = 584f; private const float PageX0 = 44f; private const float PageGut = 512f; private const float PageX1 = 980f; private const float PageY0 = 80f; private const float PageY1 = 632f; private static readonly Color Ink = new Color(0.17f, 0.11f, 0.06f, 1f); private static readonly Color InkSoft = new Color(0.42f, 0.32f, 0.2f, 1f); private static readonly Color Gold = new Color(0.93f, 0.78f, 0.45f, 1f); private const string Intro = "§ Ton carnet\nÉcris sur la page de droite ; Échap termine la saisie. « + Nouvelle entrée » ajoute le jour, l'heure et le lieu.\n\n§ Bestiaire\nChaque ennemi vaincu y est noté avec son croquis et un compteur.\n\n§ Raccourcis\nK (par défaut) : ouvre ou ferme le carnet.\nY (par défaut) : au feu de camp, consigner ton voyage."; private const string Sep = "\n\n- - - - - - - - - - - - - - - - -\n\n"; private readonly PageCurlState _curl = new PageCurlState(); private Component _qld; private Font _font; private Canvas _canvas; private GameObject _window; private RectTransform _winRt; private Text _head; private Text _counter; private Text _autoLabel; private Text _keyLabel; private bool _rebinding; private readonly Slot[] _slots = new Slot[2] { new Slot(), new Slot() }; private Leaf _leafL; private Leaf _leafR; private AudioSource _audio; private CanvasGroup _hostGroup; private float _hostAlpha = 1f; private bool _hostBlocks = true; private bool _hostHidden; private object _char; private string _charId; private string _charName; private JournalData _data = new JournalData(); private string _book = ""; private int _tab; private readonly Text[] _tabLabel = (Text[])(object)new Text[2]; private readonly List<int> _starts = new List<int> { 0 }; private int _spread; private bool _dirty; private bool _animating; private int _fixCaretFrame = -1; private Slot _fixCaretSlot; private int _fixCaretPos = -1; private bool _lockApplied; private float _nextLock; private float _lastTyping; private float _openRequestUntil; private float _nextHostCheck; private bool _hostDisplayed; private float _openedAt; private static Texture2D _bookTex; private static bool _bookTried; private static AudioClip _pageClip; private bool _newEntryOnOpen; private static Texture2D _sketchTex; private static bool _sketchTried; private static readonly Dictionary<string, Sprite> _sketches = new Dictionary<string, Sprite>(); private static readonly Dictionary<string, Atlas> _atlases = new Dictionary<string, Atlas>(); private static readonly Regex CountRx = new Regex("^Vaincus : \\d+$"); private static readonly Regex HeaderRx = new Regex("^(Jour \\d+|\\d{1,2}h\\d{2})( - .*)?$"); private static readonly Regex PicRx = new Regex("\\[dessin:(\\w+)\\]((?:\n\u00a0)*)"); private static readonly Regex PicLineRx = new Regex("^\\[dessin:\\w+\\]$"); private static readonly KeyCode[] AllKeys = (KeyCode[])Enum.GetValues(typeof(KeyCode)); private const float FlipTime = 0.6f; private int IntroLen { get { if (_tab != 0) { return 0; } return "§ Ton carnet\nÉcris sur la page de droite ; Échap termine la saisie. « + Nouvelle entrée » ajoute le jour, l'heure et le lieu.\n\n§ Bestiaire\nChaque ennemi vaincu y est noté avec son croquis et un compteur.\n\n§ Raccourcis\nK (par défaut) : ouvre ou ferme le carnet.\nY (par défaut) : au feu de camp, consigner ton voyage.".Length; } } public bool Alive => (Object)(object)_window != (Object)null; public object CharacterUI => Rx.Get(_qld, "m_characterUI"); public bool IsOpen { get { if ((Object)(object)_window != (Object)null) { return _window.activeSelf; } return false; } } public bool BlocksHotkey { get { if (!_rebinding) { if ((Object)(object)_window != (Object)null && _window.activeInHierarchy) { return AnySlotFocused(); } return false; } return true; } } public bool AutoOn => !_data.AutoOff; public void RequestOpen(bool newEntry = false) { _openRequestUntil = Time.unscaledTime + 4f; _newEntryOnOpen = newEntry; } public static NotebookView Create(Component qld) { Canvas componentInParent = qld.GetComponentInParent<Canvas>(); if ((Object)(object)componentInParent == (Object)null) { return null; } componentInParent = componentInParent.rootCanvas; NotebookView notebookView = new NotebookView(); notebookView._qld = qld; notebookView._canvas = componentInParent; object obj = Rx.Get(qld, "m_lblQuestTitle"); Text val = (Text)((obj is Text) ? obj : null); notebookView._font = (((Object)(object)val != (Object)null && (Object)(object)val.font != (Object)null) ? val.font : Resources.GetBuiltinResource<Font>("Arial.ttf")); Transform transform = ((Component)componentInParent).transform; notebookView.Build((RectTransform)(object)((transform is RectTransform) ? transform : null)); return notebookView; } private static RectTransform ImgRect(string name, Transform parent, float x0, float y0, float x1, float y1) { //IL_0014: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_005c: 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_007c: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_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_009e: Expected O, but got Unknown RectTransform val = (RectTransform)new GameObject(name, new Type[1] { typeof(RectTransform) }) { layer = ((Component)parent).gameObject.layer }.transform; ((Transform)val).SetParent(parent, false); val.anchorMin = new Vector2(x0 / 1024f, 1f - y1 / 700f); val.anchorMax = new Vector2(x1 / 1024f, 1f - y0 / 700f); val.offsetMin = Vector2.zero; val.offsetMax = Vector2.zero; ((Transform)val).localScale = Vector3.one; return val; } private static Texture2D BookTexture() { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown if (_bookTried) { return _bookTex; } _bookTried = true; try { string text = Path.Combine(Path.GetDirectoryName(typeof(Plugin).Assembly.Location), "book.png"); if (!File.Exists(text)) { Plugin.Log.LogWarning((object)("Journal : image du livre introuvable : " + text)); return null; } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); ((Object)val).hideFlags = (HideFlags)61; if (!ImageConversion.LoadImage(val, File.ReadAllBytes(text))) { return null; } ((Texture)val).filterMode = (FilterMode)1; _bookTex = val; } catch (Exception ex) { Plugin.Log.LogWarning((object)("Journal : chargement de l'image du livre : " + ex.Message)); } return _bookTex; } private static Atlas LoadAtlas(string name) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_012c: Unknown result type (might be due to invalid IL or missing references) if (_atlases.TryGetValue(name, out var value)) { return value; } value = null; try { string? directoryName = Path.GetDirectoryName(typeof(Plugin).Assembly.Location); string text = Path.Combine(directoryName, name + ".png"); string path = Path.Combine(directoryName, name + ".txt"); if (File.Exists(text) && File.Exists(path)) { Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); ((Object)val).hideFlags = (HideFlags)61; if (ImageConversion.LoadImage(val, File.ReadAllBytes(text))) { ((Texture)val).filterMode = (FilterMode)1; value = new Atlas(); value.Tex = val; string[] array = File.ReadAllLines(path); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Trim().Split(new char[1] { ' ' }); if (array2.Length == 5) { float num = float.Parse(array2[1], CultureInfo.InvariantCulture); float num2 = float.Parse(array2[2], CultureInfo.InvariantCulture); float num3 = float.Parse(array2[3], CultureInfo.InvariantCulture); float num4 = float.Parse(array2[4], CultureInfo.InvariantCulture); value.Rects[array2[0]] = new Rect(num, (float)((Texture)val).height - num2 - num4, num3, num4); } } } } else { Plugin.Log.LogWarning((object)("Journal : planche de croquis introuvable : " + text)); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Journal : planche " + name + " : " + ex.Message)); value = null; } _atlases[name] = value; return value; } public static bool HasCreature(string key) { Atlas atlas = LoadAtlas("creatures"); if (atlas != null && !string.IsNullOrEmpty(key)) { return atlas.Rects.ContainsKey(key); } return false; } private static Sprite AtlasSprite(string atlas, string name) { //IL_0022: 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) Atlas atlas2 = LoadAtlas(atlas); if (atlas2 == null || !atlas2.Rects.TryGetValue(name, out var value)) { return null; } return Sprite.Create(atlas2.Tex, value, new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0); } private static Sprite SketchSprite(string key) { //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown //IL_01c2: 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) if (_sketches.TryGetValue(key, out var value)) { return value; } value = null; if (key.StartsWith("b_", StringComparison.Ordinal) || key.StartsWith("k_", StringComparison.Ordinal)) { value = ((key[0] == 'k') ? AtlasSprite("creatures", key.Substring(2)) : AtlasSprite("bestiary", key.Substring(2))); if ((Object)(object)value == (Object)null) { value = SketchSprite("crane"); } _sketches[key] = value; return value; } try { if (!_sketchTried) { _sketchTried = true; string text = Path.Combine(Path.GetDirectoryName(typeof(Plugin).Assembly.Location), "sketches.png"); if (File.Exists(text)) { Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); ((Object)val).hideFlags = (HideFlags)61; if (ImageConversion.LoadImage(val, File.ReadAllBytes(text))) { ((Texture)val).filterMode = (FilterMode)1; _sketchTex = val; } } else { Plugin.Log.LogWarning((object)("Journal : planche de croquis introuvable : " + text)); } } if ((Object)(object)_sketchTex != (Object)null) { int num; int num2; switch (key) { case "oiseau": num = 0; num2 = 0; break; case "bandit": num = 1; num2 = 0; break; case "hyene": num = 2; num2 = 0; break; case "loup": num = 0; num2 = 1; break; case "creature": num = 2; num2 = 1; break; default: num = 1; num2 = 1; break; } float num3 = (float)((Texture)_sketchTex).width / 3f; float num4 = (float)((Texture)_sketchTex).height / 2f; value = Sprite.Create(_sketchTex, new Rect((float)num * num3, (float)((Texture)_sketchTex).height - (float)(num2 + 1) * num4, num3, num4), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Journal : croquis : " + ex.Message)); } _sketches[key] = value; return value; } private static Sprite SpriteOf(Texture2D tex, float x0, float y0, float x1, float y1) { //IL_003e: 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) float num = (float)((Texture)tex).width / 1024f; float num2 = (float)((Texture)tex).height / 700f; Rect val = default(Rect); ((Rect)(ref val))..ctor(x0 * num, (float)((Texture)tex).height - y1 * num2, (x1 - x0) * num, (y1 - y0) * num2); return Sprite.Create(tex, val, new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0); } private void Build(RectTransform canvasRt) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_006a: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Expected O, but got Unknown //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Expected O, but got Unknown //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Expected O, but got Unknown //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Expected O, but got Unknown //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Expected O, but got Unknown //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Expected O, but got Unknown //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Expected O, but got Unknown //IL_0451: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Expected O, but got Unknown //IL_0494: Unknown result type (might be due to invalid IL or missing references) //IL_049e: Expected O, but got Unknown //IL_0504: Unknown result type (might be due to invalid IL or missing references) //IL_0539: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("OJ_Book", new Type[1] { typeof(RectTransform) }); val.layer = ((Component)canvasRt).gameObject.layer; _winRt = (RectTransform)val.transform; ((Transform)_winRt).SetParent((Transform)(object)canvasRt, false); RectTransform winRt = _winRt; RectTransform winRt2 = _winRt; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0.5f, 0.5f); winRt2.anchorMax = val2; winRt.anchorMin = val2; _winRt.pivot = new Vector2(0.5f, 0.5f); _winRt.sizeDelta = new Vector2(900f, 615f); _winRt.anchoredPosition = Vector2.zero; ((Transform)_winRt).localScale = Vector3.one; _window = val; _audio = val.AddComponent<AudioSource>(); _audio.playOnAwake = false; _audio.spatialBlend = 0f; Texture2D val3 = BookTexture(); Image val4 = val.AddComponent<Image>(); if ((Object)(object)val3 != (Object)null) { val4.sprite = SpriteOf(val3, 0f, 0f, 1024f, 700f); ((Graphic)val4).color = Color.white; } else { ((Graphic)val4).color = new Color(0.55f, 0.4f, 0.25f, 1f); } ((Graphic)val4).raycastTarget = true; RectTransform obj = ImgRect("Drag", (Transform)(object)_winRt, 0f, 0f, 860f, 76f); ((Graphic)((Component)obj).gameObject.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0f); EventTrigger obj2 = ((Component)obj).gameObject.AddComponent<EventTrigger>(); Entry val5 = new Entry { eventID = (EventTriggerType)5 }; ((UnityEvent<BaseEventData>)(object)val5.callback).AddListener((UnityAction<BaseEventData>)delegate(BaseEventData d) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0056: Unknown result type (might be due to invalid IL or missing references) PointerEventData val6 = (PointerEventData)(object)((d is PointerEventData) ? d : null); if (val6 != null) { float num = (((Object)(object)_canvas != (Object)null && _canvas.scaleFactor > 0.01f) ? _canvas.scaleFactor : 1f); RectTransform winRt3 = _winRt; winRt3.anchoredPosition += val6.delta / num; } }); obj2.triggers.Add(val5); _head = NewText(ImgRect("Head", (Transform)(object)_winRt, 312f, 16f, 712f, 68f), "Carnet", 26, (TextAnchor)4, Gold); _head.resizeTextForBestFit = true; _head.resizeTextMinSize = 16; _head.resizeTextMaxSize = 26; NewPlateButton(ImgRect("Close", (Transform)(object)_winRt, 868f, 16f, 932f, 68f), "X", out var labelText, 22, (UnityAction)delegate { CloseWindow(userClose: true); }); NewPlateButton(ImgRect("New", (Transform)(object)_winRt, 84f, 644f, 320f, 686f), "+ Nouvelle entrée", out labelText, 20, new UnityAction(NewEntry)); NewPlateButton(ImgRect("Prev", (Transform)(object)_winRt, 404f, 644f, 452f, 686f), "<", out labelText, 22, (UnityAction)delegate { GoSpread(_spread - 1); }); _counter = NewText(ImgRect("Counter", (Transform)(object)_winRt, 458f, 644f, 566f, 686f), "1-2 / 2", 18, (TextAnchor)4, Gold); NewPlateButton(ImgRect("Next", (Transform)(object)_winRt, 572f, 644f, 620f, 686f), ">", out labelText, 22, (UnityAction)delegate { GoSpread(_spread + 1); }); NewPlateButton(ImgRect("Key", (Transform)(object)_winRt, 736f, 20f, 856f, 64f), "Touche", out _keyLabel, 18, new UnityAction(StartRebind)); NewPlateButton(ImgRect("TabJ", (Transform)(object)_winRt, 60f, 20f, 170f, 64f), "Journal", out _tabLabel[0], 20, (UnityAction)delegate { SetTab(0); }); NewPlateButton(ImgRect("TabC", (Transform)(object)_winRt, 176f, 20f, 286f, 64f), "Bestiaire", out _tabLabel[1], 18, (UnityAction)delegate { SetTab(1); }); NewPlateButton(ImgRect("Auto", (Transform)(object)_winRt, 700f, 644f, 940f, 686f), "Bestiaire : oui", out _autoLabel, 18, new UnityAction(ToggleAuto)); BuildPage(0, 84f, 106f, 486f, 584f, "Écris ici..."); BuildPage(1, 538f, 106f, 940f, 584f, ""); _leafL = BuildLeaf("LeafL", val3, 44f, 512f, 84f, 486f, new Vector2(1f, 0.5f)); _leafR = BuildLeaf("LeafR", val3, 512f, 980f, 538f, 940f, new Vector2(0f, 0.5f)); _window.SetActive(false); } private void BuildPage(int i, float x0, float y0, float x1, float y1, string placeholder) { //IL_008d: Unknown result type (might be due to invalid IL or missing references) Slot slot = _slots[i]; slot.Field = NewPageInput(ImgRect("Page" + (i + 1), (Transform)(object)_winRt, x0, y0, x1, y1), placeholder, out slot.Deco); slot.Number = NewText(ImgRect("Num" + (i + 1), (Transform)(object)_winRt, x0, y1 + 4f, x1, y1 + 40f), "", 16, (TextAnchor)4, InkSoft); int idx = i; ((UnityEvent<string>)(object)slot.Field.onValueChanged).AddListener((UnityAction<string>)delegate(string s) { OnEdited(idx, s); }); ((UnityEvent<string>)(object)slot.Field.onEndEdit).AddListener((UnityAction<string>)delegate(string s) { OnEndEdit(idx, s); }); } private Leaf BuildLeaf(string name, Texture2D tex, float ax0, float ax1, float tx0, float tx1, Vector2 pivot) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_00c9: 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_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0173: 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) Leaf leaf = new Leaf(); leaf.Rt = ImgRect(name, (Transform)(object)_winRt, ax0, 80f, ax1, 632f); leaf.Rt.pivot = pivot; leaf.Img = ((Component)leaf.Rt).gameObject.AddComponent<Image>(); if ((Object)(object)tex != (Object)null) { leaf.Img.sprite = SpriteOf(tex, ax0, 80f, ax1, 632f); ((Graphic)leaf.Img).color = Color.white; } else { ((Graphic)leaf.Img).color = new Color(0.9f, 0.82f, 0.62f, 1f); } ((Graphic)leaf.Img).raycastTarget = true; Transform transform = new GameObject("Text", new Type[1] { typeof(RectTransform) }).transform; RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null); ((Component)val).gameObject.layer = ((Component)leaf.Rt).gameObject.layer; ((Transform)val).SetParent((Transform)(object)leaf.Rt, false); float num = ax1 - ax0; float num2 = 552f; val.anchorMin = new Vector2((tx0 - ax0) / num, 1f - 504f / num2); val.anchorMax = new Vector2((tx1 - ax0) / num, 1f - 26f / num2); val.offsetMin = new Vector2(6f, 6f); val.offsetMax = new Vector2(-6f, -6f); ((Transform)val).localScale = Vector3.one; leaf.Txt = StyleText(((Component)val).gameObject.AddComponent<Text>(), "", 20, (TextAnchor)0, Ink); leaf.Txt.verticalOverflow = (VerticalWrapMode)0; leaf.Txt.supportRichText = true; leaf.ImgFx = ((Component)leaf.Rt).gameObject.AddComponent<PageCurlMesh>(); leaf.ImgFx.State = _curl; leaf.ImgFx.LeafRt = leaf.Rt; leaf.ImgFx.IsText = false; leaf.TxtFx = ((Component)val).gameObject.AddComponent<PageCurlMesh>(); leaf.TxtFx.State = _curl; leaf.TxtFx.LeafRt = leaf.Rt; leaf.TxtFx.IsText = true; ((Component)leaf.Rt).gameObject.SetActive(false); return leaf; } private void OpenWindow() { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) try { _tab = 0; _charId = null; RefreshCharacter(); _window.SetActive(true); ((Transform)_winRt).SetAsLastSibling(); Canvas.ForceUpdateCanvases(); _animating = false; SetInteractable(!string.IsNullOrEmpty(_charId)); RebuildPages(); _spread = int.MaxValue; ClampSpread(); RefreshSlots(); HideHost(hide: true); _openedAt = Time.unscaledTime; ManualLogSource log = Plugin.Log; string[] obj = new string[7] { "[Diag] carnet ouvert (", null, null, null, null, null, null }; Rect rect = _winRt.rect; obj[1] = ((Rect)(ref rect)).width.ToString("0"); obj[2] = "x"; rect = _winRt.rect; obj[3] = ((Rect)(ref rect)).height.ToString("0"); obj[4] = ", "; obj[5] = _starts.Count.ToString(); obj[6] = " page(s))."; log.LogInfo((object)string.Concat(obj)); } catch (Exception ex) { Plugin.Log.LogError((object)("Journal : ouverture du carnet : " + ex)); } } private void CloseWindow(bool userClose) { SaveIfDirty(); Deselect(); HideHost(hide: false); _animating = false; ((Component)_leafL.Rt).gameObject.SetActive(false); ((Component)_leafR.Rt).gameObject.SetActive(false); _window.SetActive(false); if (userClose) { HideGameMenu(); } } private void HideHost(bool hide) { try { if ((Object)(object)_hostGroup == (Object)null) { Transform val = null; Transform val2 = _qld.transform; while ((Object)(object)val2 != (Object)null) { if (((Object)val2).name == "CharacterMenus") { val = val2; break; } val2 = val2.parent; } if ((Object)(object)val == (Object)null) { return; } _hostGroup = ((Component)val).GetComponent<CanvasGroup>() ?? ((Component)val).gameObject.AddComponent<CanvasGroup>(); } if (hide) { if (!_hostHidden) { _hostAlpha = _hostGroup.alpha; _hostBlocks = _hostGroup.blocksRaycasts; } _hostGroup.alpha = 0f; _hostGroup.blocksRaycasts = false; _hostHidden = true; } else if (_hostHidden) { _hostGroup.alpha = ((_hostAlpha <= 0.01f) ? 1f : _hostAlpha); _hostGroup.blocksRaycasts = _hostBlocks; _hostHidden = false; } } catch (Exception ex) { Plugin.Log.LogDebug((object)("HideHost : " + ex.Message)); } } private static Type MenuScreensType(object ui) { MethodInfo[] methods = ui.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (!(methodInfo.Name != "ShowMenu")) { ParameterInfo[] parameters = methodInfo.GetParameters(); if (parameters.Length == 1 && parameters[0].ParameterType.IsEnum) { return parameters[0].ParameterType; } } } return null; } private void HideGameMenu() { try { object characterUI = CharacterUI; Type type = ((characterUI == null) ? null : MenuScreensType(characterUI)); if (!(type == null)) { Rx.Call(characterUI, "HideMenu", Enum.Parse(type, "QuestLog"), false); } } catch (Exception ex) { Plugin.Log.LogDebug((object)("HideGameMenu : " + ex.Message)); } } private bool IsHostDisplayed() { if (Time.unscaledTime >= _nextHostCheck) { _nextHostCheck = Time.unscaledTime + 0.15f; try { object characterUI = CharacterUI; Type type = ((characterUI == null) ? null : MenuScreensType(characterUI)); if (type != null && Rx.Call(characterUI, "GetIsMenuDisplayed", Enum.Parse(type, "QuestLog")) is bool hostDisplayed) { _hostDisplayed = hostDisplayed; } } catch { } } return _hostDisplayed; } private void RefreshCharacter() { object obj = (_char = Rx.Get(Rx.Get(_qld, "m_characterUI"), "TargetCharacter") ?? Rx.GetLocalCharacter()); if (obj == null) { _charId = null; _charName = null; _data = new JournalData(); _book = ""; return; } string text = Rx.Get(obj, "UID")?.ToString(); string text2 = Rx.Get(obj, "Name") as string; if (string.IsNullOrEmpty(text)) { text = text2 ?? "inconnu"; } if (text != _charId) { _charId = text; _charName = (string.IsNullOrEmpty(text2) ? "Aventurier" : text2); _data = Store.Load(_charId); MigrateOldEntries(); _book = "§ Ton carnet\nÉcris sur la page de droite ; Échap termine la saisie. « + Nouvelle entrée » ajoute le jour, l'heure et le lieu.\n\n§ Bestiaire\nChaque ennemi vaincu y est noté avec son croquis et un compteur.\n\n§ Raccourcis\nK (par défaut) : ouvre ou ferme le carnet.\nY (par défaut) : au feu de camp, consigner ton voyage." + _data.Book; } } private void MigrateOldEntries() { if (!string.IsNullOrEmpty(_data.Book) || _data.Entries == null || _data.Entries.Count == 0) { return; } StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < _data.Entries.Count; i++) { if (i > 0) { stringBuilder.Append("\n\n- - - - - - - - - - - - - - - - -\n\n"); } stringBuilder.Append(_data.Entries[i].Text ?? ""); } _data.Book = stringBuilder.ToString(); _data.Entries = new List<JournalEntry>(); _dirty = true; Plugin.Log.LogInfo((object)"[Diag] anciennes entrées converties dans le nouveau format."); } private float PageHeight() { //IL_0017: 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) Rect rect = ((Graphic)_slots[0].Field.textComponent).rectTransform.rect; float height = ((Rect)(ref rect)).height; if (!(height > 50f)) { return 407.95715f; } return height; } private float TextHeight(string t) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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) Text textComponent = _slots[0].Field.textComponent; Rect rect = ((Graphic)textComponent).rectTransform.rect; float num = ((Rect)(ref rect)).width; if (num < 50f) { num = 341.3203f; } TextGenerator cachedTextGeneratorForLayout = textComponent.cachedTextGeneratorForLayout; TextGenerationSettings generationSettings = textComponent.GetGenerationSettings(new Vector2(num, 0f)); return cachedTextGeneratorForLayout.GetPreferredHeight(t, generationSettings) / textComponent.pixelsPerUnit; } private int FitLength(int pos) { int num = _book.Length - pos; if (num <= 0) { return 0; } if (pos == 0 && IntroLen > 0 && num >= IntroLen) { return IntroLen; } float num2 = PageHeight() - 4f; if (TextHeight(_book.Substring(pos, num)) <= num2) { return num; } int num3 = 1; int num4 = num; while (num3 < num4) { int num5 = (num3 + num4 + 1) / 2; if (TextHeight(_book.Substring(pos, num5)) <= num2) { num3 = num5; } else { num4 = num5 - 1; } } int num6 = pos + num3 - 1; while (num6 > pos + num3 / 2 && num6 > pos) { char c = _book[num6]; if (c == ' ' || c == '\n') { return num6 + 1 - pos; } num6--; } return num3; } private void RebuildPages() { _starts.Clear(); _starts.Add(0); Reflow(0); if (_tab == 0 && TextHeight("§ Ton carnet\nÉcris sur la page de droite ; Échap termine la saisie. « + Nouvelle entrée » ajoute le jour, l'heure et le lieu.\n\n§ Bestiaire\nChaque ennemi vaincu y est noté avec son croquis et un compteur.\n\n§ Raccourcis\nK (par défaut) : ouvre ou ferme le carnet.\nY (par défaut) : au feu de camp, consigner ton voyage.") > PageHeight() - 4f) { Plugin.Log.LogWarning((object)"Journal : le mode d'emploi est trop long pour une page."); } } private void Reflow(int from) { if (from > _starts.Count - 1) { from = _starts.Count - 1; } if (from < 0) { from = 0; } _starts.RemoveRange(from + 1, _starts.Count - (from + 1)); int num = _starts[from]; while (true) { int num2 = FitLength(num); num += num2; if (num2 > 0 && num < _book.Length) { _starts.Add(num); continue; } break; } } private int PageStart(int p) { if (p >= _starts.Count) { return _book.Length; } return _starts[p]; } private int PageEnd(int p) { if (p + 1 >= _starts.Count) { return _book.Length; } return _starts[p + 1]; } private string PageText(int p) { if (p >= _starts.Count) { return ""; } return _book.Substring(_starts[p], PageEnd(p) - _starts[p]); } private int PageOfOffset(int off) { int result = 0; for (int i = 1; i < _starts.Count && _starts[i] < off; i++) { result = i; } return result; } private int SpreadCount() { return Mathf.Max(1, (_starts.Count + 1) / 2); } private void ClampSpread() { int num = SpreadCount(); if (_spread > num - 1) { _spread = num - 1; } if (_spread < 0) { _spread = 0; } } private void SetInteractable(bool on) { ((Selectable)_slots[0].Field).interactable = on && (_tab != 0 || _spread != 0); ((Selectable)_slots[1].Field).interactable = on; } private void RefreshSlots() { bool flag = !string.IsNullOrEmpty(_charId); _head.text = (flag ? ("Carnet de " + _charName) : "Carnet"); int num = SpreadCount(); _counter.text = _spread + 1 + " / " + num; UpdateAutoLabel(); UpdateTabs(); for (int i = 0; i < 2; i++) { Slot slot = _slots[i]; int num2 = _spread * 2 + i; string text = (flag ? PageText(num2) : ""); if (slot.Field.text != text) { slot.Field.SetTextWithoutNotify(text); } slot.Last = text; slot.Field.readOnly = _tab == 0 && num2 == 0; if (!_animating) { ((Selectable)slot.Field).interactable = flag && !slot.Field.readOnly; } slot.Number.text = "- " + (num2 + 1) + " -"; } SyncDeco(); } private void SyncDeco() { for (int i = 0; i < 2; i++) { Slot slot = _slots[i]; if (!((Object)(object)slot.Deco == (Object)null)) { string text = slot.Field.text; if (!(text == slot.DecoSrc)) { slot.DecoSrc = text; slot.Deco.text = Decorate(text); PlacePics(((Graphic)slot.Deco).rectTransform, text, slot.Pics, null); } } } } private static string Decorate(string t) { if (string.IsNullOrEmpty(t)) { return ""; } StringBuilder stringBuilder = new StringBuilder(t.Length + 64); string[] array = t.Split(new char[1] { '\n' }); for (int i = 0; i < array.Length; i++) { string text = array[i]; string text2 = text.Trim(); if (!PicLineRx.IsMatch(text2)) { if (text2.Length >= 11 && text2.Replace("-", "").Replace(" ", "").Length == 0) { stringBuilder.Append("<color=#7A2A1C>~ ~ ~ ~ ~ ~ † ~ ~ ~ ~ ~ ~</color>"); } else if (text2.StartsWith("§ ", StringComparison.Ordinal)) { stringBuilder.Append("<b><color=#6B1E14>").Append(text.Replace("§ ", "").Replace("<", "<\u200b")).Append("</color></b>"); } else if (CountRx.IsMatch(text2)) { stringBuilder.Append("<b>").Append(text).Append("</b>"); } else if (HeaderRx.IsMatch(text2)) { stringBuilder.Append("<b><color=#6B1E14>").Append(text.Replace("<", "<\u200b")).Append("</color></b>"); } else { stringBuilder.Append(text.Replace("<", "<\u200b")); } } if (i < array.Length - 1) { stringBuilder.Append('\n'); } } return stringBuilder.ToString(); } private void PlacePics(RectTransform area, string pageText, List<Image> pool, Leaf leaf) { //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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0276: 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_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Expected O, but got Unknown int num = 0; try { if (!string.IsNullOrEmpty(pageText) && pageText.IndexOf("[dessin:", StringComparison.Ordinal) >= 0) { float num2 = TextHeight("M"); float num3 = TextHeight("M\nM") - num2; Rect rect = area.rect; float num4 = ((Rect)(ref rect)).width; rect = area.rect; float num5 = ((Rect)(ref rect)).height; if (num4 < 50f) { num4 = 341.3203f; } if (num5 < 50f) { num5 = PageHeight(); } foreach (Match item in PicRx.Matches(pageText)) { if (num >= 3) { break; } float num6 = TextHeight(pageText.Substring(0, item.Index) + "M") - num2; int num7 = 1 + item.Groups[2].Value.Length / 2; if (num7 < 3) { num7 = 3; } float num8 = num3 * (float)num7 * 0.95f; float num9 = num5 - num6; if (num9 < num8 * 0.6f) { continue; } if (num9 < num8) { num8 = num9; } Sprite val = SketchSprite(item.Groups[1].Value); if ((Object)(object)val == (Object)null) { continue; } rect = val.rect; float width = ((Rect)(ref rect)).width; rect = val.rect; float num10 = width / Mathf.Max(1f, ((Rect)(ref rect)).height); float num11 = num8 * num10; if (num11 > num4) { num11 = num4; num8 = num11 / num10; } Image val2 = ((num < pool.Count) ? pool[num] : null); if ((Object)(object)val2 == (Object)null) { GameObject val3 = new GameObject("Pic", new Type[1] { typeof(RectTransform) }); val3.layer = ((Component)area).gameObject.layer; val3.transform.SetParent((Transform)(object)area, false); val2 = val3.AddComponent<Image>(); ((Graphic)val2).raycastTarget = false; pool.Add(val2); if (leaf != null) { PageCurlMesh pageCurlMesh = val3.AddComponent<PageCurlMesh>(); pageCurlMesh.State = _curl; pageCurlMesh.LeafRt = leaf.Rt; pageCurlMesh.IsText = true; leaf.PicFx.Add(pageCurlMesh); } } RectTransform rectTransform = ((Graphic)val2).rectTransform; rectTransform.anchorMin = new Vector2(0f, 1f); rectTransform.anchorMax = new Vector2(0f, 1f); rectTransform.pivot = new Vector2(0f, 1f); rectTransform.sizeDelta = new Vector2(num11, num8); rectTransform.anchoredPosition = new Vector2((num4 - num11) * 0.5f, 0f - (num6 + num3 * 0.15f)); ((Transform)rectTransform).localScale = Vector3.one; val2.sprite = val; ((Graphic)val2).color = Color.white; ((Component)val2).gameObject.SetActive(true); num++; } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Journal : croquis : " + ex.Message)); } for (int i = num; i < pool.Count; i++) { ((Component)pool[i]).gameObject.SetActive(false); } } private void StoreBook() { if (_tab == 0) { _data.Book = (_book.StartsWith("§ Ton carnet\nÉcris sur la page de droite ; Échap termine la saisie. « + Nouvelle entrée » ajoute le jour, l'heure et le lieu.\n\n§ Bestiaire\nChaque ennemi vaincu y est noté avec son croquis et un compteur.\n\n§ Raccourcis\nK (par défaut) : ouvre ou ferme le carnet.\nY (par défaut) : au feu de camp, consigner ton voyage.", StringComparison.Ordinal) ? _book.Substring("§ Ton carnet\nÉcris sur la page de droite ; Échap termine la saisie. « + Nouvelle entrée » ajoute le jour, l'heure et le lieu.\n\n§ Bestiaire\nChaque ennemi vaincu y est noté avec son croquis et un compteur.\n\n§ Raccourcis\nK (par défaut) : ouvre ou ferme le carnet.\nY (par défaut) : au feu de camp, consigner ton voyage.".Length) : _book); } else { _data.Combat = _book; } } private void SetTab(int t) { if (!string.IsNullOrEmpty(_charId) && !_animating && t != _tab) { StoreBook(); SaveIfDirty(); Deselect(); _tab = t; _book = ((_tab == 0) ? ("§ Ton carnet\nÉcris sur la page de droite ; Échap termine la saisie. « + Nouvelle entrée » ajoute le jour, l'heure et le lieu.\n\n§ Bestiaire\nChaque ennemi vaincu y est noté avec son croquis et un compteur.\n\n§ Raccourcis\nK (par défaut) : ouvre ou ferme le carnet.\nY (par défaut) : au feu de camp, consigner ton voyage." + _data.Book) : (_data.Combat ?? "")); RebuildPages(); _spread = 0; ClampSpread(); RefreshSlots(); } } public void CloseFromHotkey() { CloseWindow(userClose: true); } private void StartRebind() { _rebinding = true; UpdateKeyLabel(); } private void UpdateKeyLabel() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_keyLabel == (Object)null)) { _keyLabel.text = (_rebinding ? "Appuie..." : ("Touche : " + ((Plugin.Hotkey != null) ? ((object)Plugin.Hotkey.Value/*cast due to .constrained prefix*/).ToString() : "?"))); } } private void PollRebind() { //IL_0016: 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_0020: Invalid comparison between Unknown and I4 //IL_002a: 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_0028: Invalid comparison between Unknown and I4 //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) if (!_rebinding) { return; } KeyCode[] allKeys = AllKeys; foreach (KeyCode val in allKeys) { if ((int)val != 0 && ((int)val < 323 || (int)val > 329) && Input.GetKeyDown(val)) { if ((int)val != 27 && Plugin.Hotkey != null) { Plugin.Hotkey.Value = val; } _rebinding = false; UpdateKeyLabel(); break; } } } private void UpdateTabs() { //IL_0046: 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) UpdateKeyLabel(); for (int i = 0; i < 2; i++) { if (!((Object)(object)_tabLabel[i] == (Object)null)) { ((Graphic)_tabLabel[i]).color = (Color)((i == _tab) ? Gold : new Color(0.6f, 0.5f, 0.38f, 0.8f)); _tabLabel[i].fontStyle = (FontStyle)((i == _tab) ? 1 : 0); } } Graphic placeholder = _slots[0].Field.placeholder; Text val = (Text)(object)((placeholder is Text) ? placeholder : null); if ((Object)(object)val != (Object)null) { val.text = ((_tab == 0) ? "Écris ici..." : "Aucun combat noté pour l'instant."); } } public void ApplyCombat(List<KillInfo> kills, string when) { if (_tab == 1) { _book = AutoEntries.ApplyKills(_book, kills, when); StoreBook(); _dirty = true; SaveIfDirty(); RebuildPages(); ClampSpread(); if (!_animating) { RefreshSlots(); } } else { _data.Combat = AutoEntries.ApplyKills(_data.Combat, kills, when); _dirty = true; SaveIfDirty(); } } private void ToggleAuto() { if (!string.IsNullOrEmpty(_charId)) { _data.AutoOff = !_data.AutoOff; _dirty = true; SaveIfDirty(); UpdateAutoLabel(); } } private void UpdateAutoLabel() { if ((Object)(object)_autoLabel != (Object)null) { _autoLabel.text = "Bestiaire : " + (_data.AutoOff ? "non" : "oui"); } } public bool IsOpenFor(string id) { if ((Object)(object)_window != (Object)null && _window.activeSelf && !string.IsNullOrEmpty(_charId)) { return _charId == id; } return false; } public static string Append(string book, string entry) { if (book == null) { book = ""; } if (book.Length > 0) { book = book.TrimEnd('\n', ' ') + "\n\n- - - - - - - - - - - - - - - - -\n\n"; } return book + entry; } public void AppendRaw(string entry) { _book = Append(_book, entry); StoreBook(); _dirty = true; SaveIfDirty(); RebuildPages(); ClampSpread(); if (!_animating) { RefreshSlots(); } } private void GoSpread(int spread) { if (!string.IsNullOrEmpty(_charId) && !_animating) { spread = Mathf.Clamp(spread, 0, SpreadCount() - 1); if (spread != _spread) { SaveIfDirty(); Deselect(); StartFlip(spread, -1, 0); } } } private void FocusPage(int page, int caretInPage) { Slot slot = _slots[page % 2]; if ((Object)(object)EventSystem.current != (Object)null) { EventSystem.current.SetSelectedGameObject(((Component)slot.Field).gameObject); } slot.Field.ActivateInputField(); _fixCaretSlot = slot; _fixCaretPos = caretInPage; _fixCaretFrame = Time.frameCount + 2; } private void NewEntry() { if (!string.IsNullOrEmpty(_charId) && !_animating) { string placeName = Rx.GetPlaceName(); string gameTime = Rx.GetGameTime(); int gameDay = Rx.GetGameDay(); string text = ((gameDay > 0) ? ("Jour " + gameDay) : ""); List<string> list = new List<string>(); if (text.Length > 0) { list.Add(text); } if (gameTime.Length > 0) { list.Add(gameTime); } if (placeName.Length > 0) { list.Add(placeName); } string text2 = ((list.Count > 0) ? (string.Join(" - ", list.ToArray()) + "\n\n") : ""); Plugin.Log.LogInfo((object)("[Diag] nouvelle entrée : " + Rx.DescribeTime())); if (_book.Length > IntroLen) { _book = _book.TrimEnd('\n', ' ') + "\n\n- - - - - - - - - - - - - - - - -\n\n"; } _book += text2; StoreBook(); _dirty = true; SaveIfDirty(); RebuildPages(); int num = PageOfOffset(_book.Length); int caretInPage = _book.Length - PageStart(num); int num2 = num / 2; if (num2 != _spread) { Deselect(); StartFlip(num2, num, caretInPage); } else { RefreshSlots(); FocusPage(num, caretInPage); } } } private void OnEdited(int idx, string s) { if (_animating || string.IsNullOrEmpty(_charId)) { return; } Slot slot = _slots[idx]; int num = _spread * 2 + idx; if (_tab == 0 && num == 0) { slot.Field.SetTextWithoutNotify(PageText(0)); return; } slot.Last = s; int num2 = PageStart(num); int startIndex = PageEnd(num); int num3 = Mathf.Clamp(slot.Field.caretPosition, 0, s.Length); _book = _book.Substring(0, num2) + s + _book.Substring(startIndex); StoreBook(); _dirty = true; int num4 = num2 + num3; Reflow(Mathf.Min(num, _starts.Count - 1)); int num5 = PageOfOffset(num4); int num6 = num5 / 2; if (num6 == _spread) { RefreshSlots(); if (num5 != num) { FocusPage(num5, num4 - PageStart(num5)); } } else { RefreshSlots(); StartFlip(num6, num5, num4 - PageStart(num5)); } } private void OnEndEdit(int idx, string s) { Slot slot = _slots[idx]; if (!_animating) { if (s != slot.Last) { slot.Field.SetTextWithoutNotify(slot.Last); } SaveIfDirty(); } } public void SaveIfDirty() { if (_dirty && !string.IsNullOrEmpty(_charId) && Store.Save(_charId, _data)) { _dirty = false; } } private void StartFlip(int newSpread, int focusPage, int caretInPage) { if ((Object)(object)Plugin.Instance == (Object)null || !_window.activeInHierarchy) { _spread = newSpread; RefreshSlots(); if (focusPage >= 0) { FocusPage(focusPage, caretInPage); } } else { ((MonoBehaviour)Plugin.Instance).StartCoroutine(Flip(newSpread, focusPage, caretInPage)); } } private void UseLeaves(Leaf front, Leaf back) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) front.ImgFx.Front = true; front.TxtFx.Front = true; back.ImgFx.Front = false; back.TxtFx.Front = false; ((Graphic)front.Img).color = Color.white; ((Graphic)back.Img).color = Color.white; foreach (PageCurlMesh item in front.PicFx) { item.Front = true; } foreach (PageCurlMesh item2 in back.PicFx) { item2.Front = false; } ((Component)front.Rt).gameObject.SetActive(true); ((Component)back.Rt).gameObject.SetActive(true); ((Transform)front.Rt).SetAsLastSibling(); ((Transform)back.Rt).SetAsLastSibling(); } private static void DirtyLeaf(Leaf l) { ((Graphic)l.Img).SetVerticesDirty(); ((Graphic)l.Txt).SetVerticesDirty(); foreach (Image pic in l.Pics) { if ((Object)(object)pic != (Object)null && ((Component)pic).gameObject.activeSelf) { ((Graphic)pic).SetVerticesDirty(); } } } private void CurlTo(Leaf front, Leaf back, float theta) { _curl.Compute(theta); DirtyLeaf(front); DirtyLeaf(back); } private IEnumerator Flip(int newSpread, int focusPage, int caretInPage) { _animating = true; SetInteractable(on: false); PlayPageSound(); bool forward = newSpread > _spread; string text = _slots[0].Field.text; string text2 = _slots[1].Field.text; string newL = PageText(newSpread * 2); string newR = PageText(newSpread * 2 + 1); Leaf front = (forward ? _leafR : _leafL); Leaf back = (forward ? _leafL : _leafR); front.Txt.text = Decorate(forward ? text2 : text); back.Txt.text = Decorate(forward ? newL : newR); if (forward) { _slots[1].Field.SetTextWithoutNotify(newR); } else { _slots[0].Field.SetTextWithoutNotify(newL); } SyncDeco(); _curl.Dir = (forward ? 1f : (-1f)); PageCurlState curl = _curl; Rect rect = front.Rt.rect; curl.W = ((Rect)(ref rect)).width; PageCurlState curl2 = _curl; rect = front.Rt.rect; curl2.H = ((Rect)(ref rect)).height; _curl.Active = true; UseLeaves(front, back); PlacePics(((Graphic)front.Txt).rectTransform, forward ? text2 : text, front.Pics, front); PlacePics(((Graphic)back.Txt).rectTransform, forward ? newL : newR, back.Pics, back); foreach (PageCurlMesh item in front.PicFx) { item.Front = true; } foreach (PageCurlMesh item2 in back.PicFx) { item2.Front = false; } CurlTo(front, back, 0f); yield return null; for (float t = 0f; t < 0.6f; t += Time.unscaledDeltaTime) { float num = Mathf.Clamp01(t / 0.6f); float num2 = num * num * (3f - 2f * num); CurlTo(front, back, num2 * (float)Math.PI); yield return null; } CurlTo(front, back, (float)Math.PI); yield return null; if (forward) { _slots[0].Field.SetTextWithoutNotify(newL); } else { _slots[1].Field.SetTextWithoutNotify(newR); } SyncDeco(); _curl.Active = false; ((Component)_leafL.Rt).gameObject.SetActive(false); ((Component)_leafR.Rt).gameObject.SetActive(false); _spread = newSpread; ClampSpread(); _animating = false; SetInteractable(!string.IsNullOrEmpty(_charId)); RefreshSlots(); if (focusPage >= 0) { FocusPage(focusPage, caretInPage); } } private void PlayPageSound() { try { if ((Object)(object)_pageClip == (Object)null) { _pageClip = MakePageClip(); } if ((Object)(object)_audio != (Object)null && (Object)(object)_pageClip != (Object)null) { _audio.pitch = 0.96f + 0.08f * Random.value; _audio.PlayOneShot(_pageClip, 0.8f); } } catch (Exception ex) { Plugin.Log.LogDebug((object)("PlayPageSound : " + ex.Message)); } } private static AudioClip MakePageClip() { float num = 0.8f; int num2 = (int)(44100f * num); float[] array = new float[num2]; Random random = new Random(11); Svf svf = default(Svf); Svf svf2 = default(Svf); Svf svf3 = default(Svf); float num3 = 0f; float num4 = 0f; float num5 = 0.558f; for (int i = 0; i < num2; i++) { float num6 = (float)i / 44100f; float num7 = (float)(random.NextDouble() * 2.0 - 1.0); float num8 = 0f; if (num6 < 0.28f) { float num9 = Mathf.Sin((float)Math.PI * Mathf.Clamp01(num6 / 0.28f)); num9 *= num9; float num10 = 0.6f + 0.4f * Mathf.Sin(num6 * 95f + 0.7f) * Mathf.Sin(num6 * 41f); num8 += svf.Process(num7, 1800f + 900f * Mathf.Sin(num6 * 30f), 0.9f, 44100) * num9 * num10 * 0.45f; } if (num6 > 0.08f && num6 < num5) { float num11 = (num6 - 0.08f) / (num5 - 0.08f); float num12 = Mathf.Sin((float)Math.PI * num11); num12 *= num12; float fc = 1200f + 3300f * Mathf.Sin((float)Math.PI * Mathf.Pow(num11, 0.8f)); num8 += svf2.Process(num7, fc, 0.55f, 44100) * num12 * 0.55f; } float num13 = ((num6 < 0.35f) ? 0.0016f : 0.0004f); if (num6 < num5 && random.NextDouble() < (double)num13) { num3 = 0.5f + (float)random.NextDouble() * 0.7f; } num3 *= 0.9965f; float num14 = num7 * num3; num4 += (num14 - num4) * 0.35f; num8 += (num14 - num4) * 0.6f; float num15 = num6 - num5; if (num15 >= 0f && num15 < 0.22f) { float num16 = Mathf.Sin((float)Math.PI * 2f * (95f - 280f * num15) * num15) * Mathf.Exp((0f - num15) * 38f); float num17 = svf3.Process(num7, 2400f, 1.1f, 44100) * Mathf.Exp((0f - num15) * 24f); num8 += num16 * 0.55f + num17 * 0.5f; } float num18 = Mathf.Clamp01((num - num6) / 0.05f); array[i] = num8 * num18; } float num19 = 0.0001f; for (int j = 0; j < num2; j++) { num19 = Mathf.Max(num19, Mathf.Abs(array[j])); } float num20 = 0.85f / num19; for (int k = 0; k < num2; k++) { array[k] *= num20; } AudioClip obj = AudioClip.Create("OJ_page", num2, 1, 44100, false); obj.SetData(array, 0); return obj; } public void Tick() { if ((Object)(object)_window == (Object)null) { return; } if (_openRequestUntil > 0f) { if (Time.unscaledTime > _openRequestUntil) { _openRequestUntil = 0f; Plugin.Log.LogInfo((object)"[Diag] le menu Journal ne s'est pas affiché à temps : carnet non ouvert."); } else if (!_window.activeSelf && IsHostDisplayed()) { _openRequestUntil = 0f; OpenWindow(); if (_newEntryOnOpen) { _newEntryOnOpen = false; NewEntry(); } } } bool activeSelf = _window.activeSelf; if (!activeSelf && _rebinding) { _rebinding = false; UpdateKeyLabel(); } if (activeSelf) { PollRebind(); SyncDeco(); ((Transform)_winRt).SetAsLastSibling(); HideHost(hide: true); if (Time.unscaledTime > _openedAt + 0.5f && !IsHostDisplayed() && !AnySlotFocused() && !_animating) { CloseWindow(userClose: false); } InputField field = _slots[1].Field; if (!_animating && field.isFocused && Input.GetKeyDown((KeyCode)8) && field.caretPosition == 0 && field.selectionAnchorPosition == field.selectionFocusPosition && _spread * 2 < _starts.Count && (_tab != 0 || _spread != 0)) { FocusPage(_spread * 2, PageText(_spread * 2).Length); } } if (_fixCaretFrame >= 0 && Time.frameCount >= _fixCaretFrame) { _fixCaretFrame = -1; InputField val = ((_fixCaretSlot != null) ? _fixCaretSlot.Field : null); if ((Object)(object)val != (Object)null && val.isFocused) { int selectionFocusPosition = (val.selectionAnchorPosition = (val.caretPosition = ((_fixCaretPos < 0) ? val.text.Length : Mathf.Clamp(_fixCaretPos, 0, val.text.Length)))); val.selectionFocusPosition = selectionFocusPosition; } } bool activeInHierarchy = _window.activeInHierarchy; bool flag = activeInHierarchy && AnySlotFocused(); if (!activeInHierarchy) { SaveIfDirty(); } if (flag) { _lastTyping = Time.unscaledTime; if (!_lockApplied || Time.unscaledTime >= _nextLock) { Rx.LockGameInput(_char, locked: true); _lockApplied = true; _nextLock = Time.unscaledTime + 0.2f; } } else if (_lockApplied && Time.unscaledTime > _lastTyping + 0.25f) { Rx.LockGameInput(_char, locked: false); _lockApplied = false; } } private bool AnySlotFocused() { if (!((Object)(object)_slots[0].Field != (Object)null) || !_slots[0].Field.isFocused) { if ((Object)(object)_slots[1].Field != (Object)null) { return _slots[1].Field.isFocused; } return false; } return true; } private static void Deselect() { if ((Object)(object)EventSystem.current != (Object)null) { EventSystem.current.SetSelectedGameObject((GameObject)null); } } private Text NewText(RectTransform rt, string text, int size, TextAnchor anchor, Color color) { //IL_000e: 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) return StyleText(((Component)rt).gameObject.AddComponent<Text>(), text, size, anchor, color); } private Text StyleText(Text t, string text, int size, TextAnchor anchor, Color color) { //IL_0014: 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) t.font = _font; t.fontSize = size; t.alignment = anchor; ((Graphic)t).color = color; t.text = text; t.supportRichText = false; ((Graphic)t).raycastTarget = false; t.horizontalOverflow = (HorizontalWrapMode)0; t.verticalOverflow = (VerticalWrapMode)1; return t; } private static RectTransform Child(string name, Transform parent) { //IL_0014: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0053: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown RectTransform val = (RectTransform)new GameObject(name, new Type[1] { typeof(RectTransform) }) { layer = ((Component)parent).gameObject.layer }.transform; ((Transform)val).SetParent(parent, false); val.anchorMin = Vector2.zero; val.anchorMax = Vector2.one; val.offsetMin = Vector2.zero; val.offsetMax = Vector2.zero; ((Transform)val).localScale = Vector3.one; return val; } private void NewPlateButton(RectTransform rt, string label, out Text labelText, int size, UnityAction onClick) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0046: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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_00d1: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) Image val = ((Component)rt).gameObject.AddComponent<Image>(); ((Graphic)val).color = Color.white; Button obj = ((Component)rt).gameObject.AddComponent<Button>(); ((Selectable)obj).targetGraphic = (Graphic)(object)val; ColorBlock colors = ((Selectable)obj).colors; ((ColorBlock)(ref colors)).normalColor = new Color(1f, 1f, 1f, 0f); ((ColorBlock)(ref colors)).highlightedColor = new Color(1f, 0.85f, 0.5f, 0.22f); ((ColorBlock)(ref colors)).pressedColor = new Color(1f, 0.8f, 0.4f, 0.4f); ((ColorBlock)(ref colors)).selectedColor = new Color(1f, 1f, 1f, 0f); ((ColorBlock)(ref colors)).disabledColor = new Color(1f, 1f, 1f, 0f); ((Selectable)obj).colors = colors; Navigation navigation = default(Navigation); ((Navigation)(ref navigation)).mode = (Mode)0; ((Selectable)obj).navigation = navigation; ((UnityEvent)obj.onClick).AddListener(onClick); RectTransform val2 = Child("Label", (Transform)(object)rt); labelText = StyleText(((Component)val2).gameObject.AddComponent<Text>(), label, size, (TextAnchor)4, Gold); labelText.horizontalOverflow = (HorizontalWrapMode)1; } private InputField NewPageInput(RectTransform rt, string placeholder, out Text deco) { //IL_0021: 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_0057: 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_009e: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) Image val = ((Component)rt).gameObject.AddComponent<Image>(); ((Graphic)val).color = new Color(0f, 0f, 0f, 0f); RectTransform val2 = Child("Text", (Transform)(object)rt); val2.offsetMin = new Vector2(6f, 6f); val2.offsetMax = new Vector2(-6f, -6f); Text val3 = StyleText(((Component)val2).gameObject.AddComponent<Text>(), "", 20, (TextAnchor)0, Ink); val3.verticalOverflow = (VerticalWrapMode)0; RectTransform val4 = Child("Placeholder", (Transform)(object)rt); val4.offsetMin = new Vector2(6f, 6f); val4.offsetMax = new Vector2(-6f, -6f); Text val5 = StyleText(((Component)val4).gameObject.AddComponent<Text>(), placeholder, 20, (TextAnchor)0, InkSoft); val5.fontStyle = (FontStyle)2; ((Graphic)val3).color = new Color(Ink.r, Ink.g, Ink.b, 0f); RectTransform val6 = Child("Deco", (Transform)(object)rt); val6.offsetMin = new Vector2(6f, 6f); val6.offsetMax = new Vector2(-6f, -6f); deco = StyleText(((Component)val6).gameObject.AddComponent<Text>(), "", 20, (TextAnchor)0, Ink); deco.verticalOverflow = (VerticalWrapMode)0; deco.supportRichText = true; ((Graphic)deco).raycastTarget = false; InputField obj = ((Component)rt).gameObject.AddComponent<InputField>(); ((Selectable)obj).targetGraphic = (Graphic)(object)val; obj.textComponent = val3; obj.placeholder = (Graphic)(object)val5; obj.lineType = (LineType)2; obj.characterLimit = 0; obj.caretColor = Ink; obj.customCaretColor = true; obj.selectionColor = new Color(0.55f, 0.4f, 0.15f, 0.45f); Navigation navigation = default(Navigation); ((Navigation)(ref navigation)).mode = (Mode)0; ((Selectable)obj).navigation = navigation; return obj; } } internal class PageCurlState { public const int Cols = 28; public const int Rows = 10; public const float DepthK = 0.1f; public bool Active; public float W = 468f; public float H = 552f; public float Dir = 1f; public readonly float[,] X = new float[11, 29]; public readonly float[,] Z = new float[11, 29]; public readonly float[,] Phi = new float[11, 29]; public void Compute(float theta) { float num = W / 28f; float num2 = Mathf.Sin(theta); for (int i = 0; i <= 10; i++) { float num3 = (float)i / 10f; float num4 = 0.35f + 1.35f * num3; float num5 = 0f; float num6 = 0f; for (int j = 0; j <= 28; j++) { float num7 = (float)j / 28f; float num8 = theta + num4 * num2 * Mathf.Pow(num7, 1.5f); num8 = Mathf.Clamp(num8, 0f, (float)Math.PI); if (j > 0) { float num9 = 0.5f * (num8 + Phi[i, j - 1]); num5 += Mathf.Cos(num9) * num; num6 += Mathf.Sin(num9) * num; } Phi[i, j] = num8; X[i, j] = num5; Z[i, j] = num6; } } } public void Map(float s, float v, out float x, out float z, out float phi) { float num = Mathf.Clamp(s / W * 28f, 0f, 28f); float num2 = Mathf.Clamp(v * 10f, 0f, 10f); int num3 = Mathf.Min((int)num, 27); int num4 = Mathf.Min((int)num2, 9); float tj = num - (float)num3; float ti = num2 - (float)num4; x = Bil(X, num4, num3, ti, tj); z = Bil(Z, num4, num3, ti, tj); phi = Bil(Phi, num4, num3, ti, tj); } private static float Bil(float[,] a, int i, int j, float ti, float tj) { float num = Mathf.Lerp(a[i, j], a[i, j + 1], tj); float num2 = Mathf.Lerp(a[i + 1, j], a[i + 1, j + 1], tj); return Mathf.Lerp(num, num2, ti); } public static float Shade(float phi) { return 1f - 0.42f * Mathf.Sin(phi); } } internal class PageCurlMesh : BaseMeshEffect { public PageCurlState State; public bool Front; public bool IsText; public RectTransform LeafRt; public override void ModifyMesh(VertexHelper vh) { if (State != null && State.Active && !((Object)(object)LeafRt == (Object)null) && ((UIBehaviour)this).IsActive()) { if (IsText) { ModifyText(vh); } else { ModifyImage(vh); } } } private void ModifyImage(VertexHelper vh) { //IL_000c: 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_0032: 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_005b: 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_0066: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015a: 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_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: 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_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020c: 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_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) if (vh.currentVertCount < 4) { return; } UIVertex val = default(UIVertex); UIVertex val2 = default(UIVertex); vh.PopulateUIVertex(ref val, 0); vh.PopulateUIVertex(ref val2, 2); Rect rect = LeafRt.rect; float xMin = ((Rect)(ref rect)).xMin; float xMax = ((Rect)(ref rect)).xMax; float yMin = ((Rect)(ref rect)).yMin; float yMax = ((Rect)(ref rect)).yMax; Vector2 val3 = Vector4.op_Implicit(val.uv0); Vector2 val4 = Vector4.op_Implicit(val2.uv0); float num = Mathf.Min(val3.x, val4.x); float num2 = Mathf.Max(val3.x, val4.x); float num3 = Mathf.Min(val3.y, val4.y); float num4 = Mathf.Max(val3.y, val4.y); float num5 = Mathf.Max(0.001f, xMax - xMin); float num6 = Mathf.Max(0.001f, yMax - yMin); float num7 = (((xMin + xMax) * 0.5f < 0f) ? (-1f) : 1f); vh.Clear(); int num8 = 28; int num9 = 10; for (int i = 0; i <= num9; i++) { float num10 = (float)i / (float)num9; float num11 = yMax - num10 * num6; for (int j = 0; j <= num8; j++) { float num12 = State.W * (float)j / (float)num8; float num13 = Mathf.Clamp01((num7 * num12 - xMin) / num5); UIVertex val5 = val; float num14 = 1f + 0.1f * State.Z[i, j] / State.W; val5.position = new Vector3(State.Dir * State.X[i, j], num11 * num14, 0f); val5.uv0 = Vector4.op_Implicit(new Vector2(Mathf.Lerp(num, num2, num13), Mathf.Lerp(num4, num3, num10))); float num15 = PageCurlState.Shade(State.Phi[i, j]); Color32 color = val.color; color.r = (byte)((float)(int)color.r * num15); color.g = (byte)((float)(int)color.g * num15); color.b = (byte)((float)(int)color.b * num15); val5.color = color; vh.AddVert(val5); } } float num16 = (float)Math.PI / 2f; for (int k = 0; k < num9; k++) { for (int l = 0; l < num8; l++) { if ((!Front) ? (Mathf.Max(State.Phi[k, l + 1], State.Phi[k + 1, l + 1]) > num16) : (Mathf.Min(State.Phi[k, l], State.Phi[k + 1, l]) < num16)) { int num17 = k * (num8 + 1) + l; vh.AddTriangle(num17, num17 + 1, num17 + num8 + 1); vh.AddTriangle(num17 + 1, num17 + num8 + 2, num17 + num8 + 1); } } } } private void ModifyText(VertexHelper vh) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012a: 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_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_0202: 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_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) int currentVertCount = vh.currentVertCount; Transform transform = ((Component)this).transform; RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null); if ((Object)(object)val == (Object)null) { return; } UIVertex[] array = (UIVertex[])(object)new UIVertex[4]; Vector3[] array2 = (Vector3[])(object)new Vector3[4]; float num = (float)Math.PI / 2f; Vector3 val3 = default(Vector3); for (int i = 0; i + 3 < currentVertCount; i += 4) { float num2 = 0f; float num3 = 0f; for (int j = 0; j < 4; j++) { array[j] = default(UIVertex); vh.PopulateUIVertex(ref array[j], i + j); array2[j] = ((Transform)LeafRt).InverseTransformPoint(((Transform)val).TransformPoint(array[j].position)); num2 += array2[j].x * 0.25f; num3 += array2[j].y * 0.25f; } State.Map(Mathf.Abs(num2), 0.5f - num3 / State.H, out var _, out var _, out var phi); bool flag = (Front ? (phi < num) : (phi > num)); for (int k = 0; k < 4; k++) { UIVertex val2 = array[k]; Color32 color = val2.color; if (!flag) { color.a = 0; } else { State.Map(Mathf.Abs(array2[k].x), 0.5f - array2[k].y / State.H, out var x2, out var z2, out var phi2); float num4 = 1f + 0.1f * z2 / State.W; ((Vector3)(ref val3))..ctor(State.Dir * x2, array2[k].y * num4, 0f); val2.position = ((Transform)val).InverseTransformPoint(((Transform)LeafRt).TransformPoint(val3)); float num5 = PageCurlState.Shade(phi2); color.r = (byte)((float)(int)color.r * num5); color.g = (byte)((float)(int)color.g * num5); color.b = (byte)((float)(int)color.b * num5); } val2.color = color; vh.SetUIVertex(val2, i + k); } } } } [Serializable] public class JournalEntry { public string Title = ""; public string Text = ""; public string GameTime = ""; public string Place = ""; public string RealDate = ""; public int Day; } [Serializable] public class JournalData { public List<JournalEntry> Entries = new List<JournalEntry>(); public string Book = ""; public string Combat = ""; public bool AutoOff; } internal static class Store { private static string Dir => Path.Combine(Paths.ConfigPath, "OutwardJournal"); private static string FilePath(string id) { StringBuilder stringBuilder = new StringBuilder(); foreach (char c in id) { stringBuilder.Append((char.IsLetterOrDigit(c) || c == '-' || c == '_') ? c : '_'); } return Path.Combine(Dir, stringBuilder?.ToString() + ".json"); } public static string MarkerPath(string id) { StringBuilder stringBuilder = new StringBuilder(); foreach (char c in id) { stringBuilder.Append((char.IsLetterOrDigit(c) || c == '-' || c == '_') ? c : '_'); } return Path.Combine(Dir, stringBuilder?.ToString() + ".carried"); } public static JournalData Load(string id) { try { string path = FilePath(id); if (File.Exists(path)) { JournalData journalData = JsonUtility.FromJson<JournalData>(File.ReadAllText(path, Encoding.UTF8)); if (journalData != null && journalData.Entries != null) { return journalData; } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Journal : lecture impossible : " + ex.Message)); } return new JournalData(); } public static bool Save(string id, JournalData data) { try { Directory.CreateDirectory(Dir); File.WriteAllText(FilePath(id), JsonUtility.ToJson((object)data, true), Encoding.UTF8); return true; } catch (Exception ex) { Plugin.Log.LogError((object)("Journal : sauvegarde impossible : " + ex)); return false; } } } [BepInPlugin("outwardjournal.adventurer", "Journal d'Aventure", "0.20.1")] public class Plugin : BaseUnityPlugin { public const string GUID = "outwardjournal.adventurer"; public const string NAME = "Journal d'Aventure"; public const string VERSION = "0.20.1"; internal static ManualLogSource Log; internal static ConfigEntry<KeyCode> Hotkey; internal static ConfigEntry<KeyCode> CampKey; internal static ConfigEntry<bool> CampAsk; private readonly List<NotebookView> _views = new List<NotebookView>(); private readonly HashSet<int> _known = new HashSet<int>(); private float _nextPoll; private bool _warnedType; internal const int ItemId = 9810001; internal static Plugin Instance; private float _nextGive; private string _giveChar; private float _giveSince; private bool _givePending; private int _giveTries; private float _carriedSince = -1f; private string _lastDiag = ""; private int _missingPolls; private static string SpawnPath => Path.Combine(Path.Combine(Paths.ConfigPath, "OutwardJournal"), "spawn.txt"); internal void Awake() { Log = ((BaseUnityPlugin)this).Logger; Instance = this; Hotkey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Raccourci", "Touche", (KeyCode)107, "Touche qui ouvre et ferme le carnet (il faut avoir le Journal d'aventurier sur soi). Se change aussi dans le carnet, avec le bouton « Touche »."); CampAsk = ((BaseUnityPlugin)this).Config.Bind<bool>("Feu de camp", "Question", true, "Quand tu déploies un feu de camp, le jeu te demande si tu veux consigner ton voyage dans le carnet."); CampKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Feu de camp", "Touche", (KeyCode)121, "Touche qui répond « oui » à la question du feu de camp (ouvre le carnet sur une nouvelle entrée)."); try { Campfire.Install(); } catch (Exception ex) { Log.LogWarning((object)("Journal : feu de camp impossible : " + ex.Message)); } try { ItemHook.Install(); } catch (Exception ex2) { Log.LogWarning((object)("Journal : lien avec l'objet impossible : " + ex2.Message)); } try { KillLog.Install(); } catch (Exception ex3) { Log.LogWarning((object)("Journal : suivi des combats impossible : " + ex3.Message)); } L