Decompiled source of JournalNotebook v0.5.0

plugins/JournalNotebook.dll

Decompiled 4 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using SideLoader;
using SideLoader.SaveData;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("OutwardModTemplate")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OutwardModTemplate")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c5450fe0-edcf-483f-b9ea-4b1ef9d36da7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace JournalNotebook;

public static class Helper
{
	public static GameObject FindChildByName(GameObject parent, string childName)
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Expected O, but got Unknown
		if ((Object)(object)parent == (Object)null || string.IsNullOrEmpty(childName))
		{
			return null;
		}
		foreach (Transform item in parent.transform)
		{
			Transform val = item;
			if (((Object)val).name == childName)
			{
				return ((Component)val).gameObject;
			}
			GameObject val2 = FindChildByName(((Component)val).gameObject, childName);
			if ((Object)(object)val2 != (Object)null)
			{
				return val2;
			}
		}
		return null;
	}

	public static GameObject FindObjectByName(GameObject parent, string childName)
	{
		Transform transform = parent.transform;
		Transform val = transform.Find(childName);
		if ((Object)(object)val != (Object)null)
		{
			return ((Component)val).gameObject;
		}
		JournalNotebookPlugin.Instance.FlexibleLogger("Child not found in parent.");
		return null;
	}

	public static GameObject AttachReferenceAsClone(GameObject reference, Transform newParent)
	{
		if ((Object)(object)reference == (Object)null || (Object)(object)newParent == (Object)null)
		{
			if ((Object)(object)reference == (Object)null)
			{
				JournalNotebookPlugin.Instance.FlexibleLogger("Reference is null, cannot attach reference as clone.", forceLogging: true, JournalNotebookPlugin.LoggingType.Error);
			}
			if ((Object)(object)newParent == (Object)null)
			{
				JournalNotebookPlugin.Instance.FlexibleLogger("New parent is null, cannot attach reference as clone.", forceLogging: true, JournalNotebookPlugin.LoggingType.Error);
			}
			return null;
		}
		return Object.Instantiate<GameObject>(reference, newParent);
	}

	public static Transform FindTransformByPath(Transform root, string path)
	{
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Expected O, but got Unknown
		if ((Object)(object)root == (Object)null || string.IsNullOrEmpty(path))
		{
			return null;
		}
		string[] array = path.Split(new char[1] { '/' });
		Transform val = root;
		for (int i = 0; i < array.Length; i++)
		{
			Transform val2 = null;
			foreach (Transform item in val)
			{
				Transform val3 = item;
				if (((Object)val3).name == array[i])
				{
					val2 = val3;
					break;
				}
			}
			if ((Object)(object)val2 == (Object)null)
			{
				string text = ((i == 0) ? ((Object)root).name : (((Object)root).name + "/" + string.Join("/", array, 0, i)));
				JournalNotebookPlugin.Instance.FlexibleLogger("FindTransformByPath: Reached '" + text + "' but could not find '" + array[i] + "'", forceLogging: true, JournalNotebookPlugin.LoggingType.Error);
				return null;
			}
			val = val2;
		}
		return val;
	}

	public static void RemoveComponentAtPath(Transform root, string path, Type componentType)
	{
		Transform val = FindTransformByPath(root, path);
		if ((Object)(object)val == (Object)null)
		{
			JournalNotebookPlugin.Instance.FlexibleLogger("RemoveComponentAtPath: Could not find target transform at path '" + path + "'", forceLogging: true, JournalNotebookPlugin.LoggingType.Warning);
			return;
		}
		Component component = ((Component)val).GetComponent(componentType);
		if ((Object)(object)component != (Object)null)
		{
			Object.Destroy((Object)(object)component);
			return;
		}
		JournalNotebookPlugin.Instance.FlexibleLogger("RemoveComponentAtPath: No component of type '" + componentType.Name + "' found at '" + path + "'", forceLogging: true, JournalNotebookPlugin.LoggingType.Warning);
	}

	public static T GetComponentAtPath<T>(Transform root, string path) where T : Component
	{
		Transform val = FindTransformByPath(root, path);
		if ((Object)(object)val == (Object)null)
		{
			JournalNotebookPlugin.Instance.FlexibleLogger("GetComponentAtPath: Could not find target transform at path '" + path + "'", forceLogging: true, JournalNotebookPlugin.LoggingType.Warning);
			return default(T);
		}
		T component = ((Component)val).GetComponent<T>();
		if ((Object)(object)component == (Object)null)
		{
			JournalNotebookPlugin.Instance.FlexibleLogger("GetComponentAtPath: No component of type '" + typeof(T).Name + "' found at '" + path + "'", forceLogging: true, JournalNotebookPlugin.LoggingType.Warning);
		}
		return component;
	}

	public static GameObject AddChild(GameObject parent, string childName)
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Expected O, but got Unknown
		//IL_003b: 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_005d: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)parent == (Object)null || string.IsNullOrEmpty(childName))
		{
			return null;
		}
		GameObject val = new GameObject(childName);
		val.transform.SetParent(parent.transform);
		val.transform.localPosition = Vector3.zero;
		val.transform.localRotation = Quaternion.identity;
		val.transform.localScale = Vector3.one;
		return val;
	}
}
[RequireComponent(typeof(InputField))]
public class InputFieldEscapeFix : MonoBehaviour
{
	[CompilerGenerated]
	private sealed class <RestoreTextNextFrame>d__6 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public string textToRestore;

		public InputFieldEscapeFix <>4__this;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <RestoreTextNextFrame>d__6(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = null;
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<>4__this._isRestoring = true;
				<>4__this._inputField.text = textToRestore;
				<>4__this._inputField.DeactivateInputField();
				<>4__this._isRestoring = false;
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	private InputField _inputField;

	private string _lastKnownText;

	private bool _isRestoring = false;

	private void Awake()
	{
		_inputField = ((Component)this).GetComponent<InputField>();
		if ((Object)(object)_inputField == (Object)null)
		{
			JournalNotebookPlugin.Instance.FlexibleLogger("InputFieldEscapeFix: No InputField found on " + ((Object)((Component)this).gameObject).name, forceLogging: true, JournalNotebookPlugin.LoggingType.Error);
			return;
		}
		((UnityEvent<string>)(object)_inputField.onValueChanged).AddListener((UnityAction<string>)OnValueChanged);
		((UnityEvent<string>)(object)_inputField.onEndEdit).AddListener((UnityAction<string>)OnEndEdit);
		JournalNotebookPlugin.Instance.FlexibleLogger("InputFieldEscapeFix: Successfully initialized on " + ((Object)((Component)this).gameObject).name);
	}

	private void OnValueChanged(string value)
	{
		if (!_isRestoring && _inputField.isFocused)
		{
			_lastKnownText = value;
		}
	}

	private void OnEndEdit(string value)
	{
		if (value != _lastKnownText)
		{
			((MonoBehaviour)this).StartCoroutine(RestoreTextNextFrame(_lastKnownText));
		}
	}

	[IteratorStateMachine(typeof(<RestoreTextNextFrame>d__6))]
	private IEnumerator RestoreTextNextFrame(string textToRestore)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <RestoreTextNextFrame>d__6(0)
		{
			<>4__this = this,
			textToRestore = textToRestore
		};
	}

	private void OnDestroy()
	{
		if ((Object)(object)_inputField != (Object)null)
		{
			((UnityEvent<string>)(object)_inputField.onValueChanged).RemoveListener((UnityAction<string>)OnValueChanged);
			((UnityEvent<string>)(object)_inputField.onEndEdit).RemoveListener((UnityAction<string>)OnEndEdit);
		}
	}
}
public class JournalNotebookManager
{
	public Dictionary<string, string> notebookData;

	public JournalNotebookManager()
	{
		notebookData = new Dictionary<string, string>();
	}

	public void RegisterNote(Character character, string note)
	{
		//IL_000f: 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_002a: Unknown result type (might be due to invalid IL or missing references)
		string value = string.Copy(note);
		if (notebookData.ContainsKey(UID.op_Implicit(character.UID)))
		{
			notebookData[UID.op_Implicit(character.UID)] = value;
		}
		else
		{
			notebookData.Add(UID.op_Implicit(character.UID), value);
		}
	}

	public void RegisterFromSave(Character character, string note)
	{
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)character == (Object)null)
		{
			JournalNotebookPlugin.Instance.FlexibleLogger("Notebook manager can't register note. Character instance is null.", forceLogging: true, JournalNotebookPlugin.LoggingType.Error);
			return;
		}
		if (note == null)
		{
			note = "";
		}
		string value = string.Copy(note);
		if (notebookData.ContainsKey(UID.op_Implicit(character.UID)))
		{
			notebookData[UID.op_Implicit(character.UID)] = value;
		}
		else
		{
			notebookData.Add(UID.op_Implicit(character.UID), value);
		}
		JournalNotebookPlugin.Instance.FlexibleLogger("Notebook manager registered load data of " + ((Object)character).name + " (" + UID.op_Implicit(character.UID) + "): " + note);
	}

	public string GetNote(Character character)
	{
		//IL_0008: 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_0029: Unknown result type (might be due to invalid IL or missing references)
		if (notebookData.TryGetValue(UID.op_Implicit(character.UID), out var value))
		{
			JournalNotebookPlugin.Instance.FlexibleLogger("Retrieved note for character " + UID.op_Implicit(character.UID) + ": " + value);
			return value;
		}
		JournalNotebookPlugin.Instance.FlexibleLogger("No note found for character " + UID.op_Implicit(character.UID), forceLogging: false, JournalNotebookPlugin.LoggingType.Warning);
		return "";
	}
}
[BepInPlugin("johbenji.journalnotebook", "Journal Notebook", "1.0.0")]
public class JournalNotebookPlugin : BaseUnityPlugin
{
	public enum LoggingType
	{
		Message,
		Warning,
		Error,
		Info
	}

	[CompilerGenerated]
	private sealed class <DoAfterDelay>d__20 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public Action OnAfterDelay;

		public float DelayTime;

		public JournalNotebookPlugin <>4__this;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <DoAfterDelay>d__20(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(DelayTime);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				OnAfterDelay();
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	public const string GUID = "johbenji.journalnotebook";

	public const string NAME = "Journal Notebook";

	public const string VERSION = "1.0.0";

	public string SLPackName = "johbenji-journalnotebook";

	internal static ManualLogSource Log;

	public AssetBundle SpritesAssetBundle;

	public bool debugMode = false;

	public static JournalNotebookPlugin Instance { get; private set; }

	public static JournalNotebookManager journalNotebookManager { get; private set; }

	internal void Awake()
	{
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		Instance = this;
		journalNotebookManager = new JournalNotebookManager();
		NotebookSaveExtension notebookSaveExtension = new NotebookSaveExtension();
		Log = ((BaseUnityPlugin)this).Logger;
		FlexibleLogger("Hello world from Journal Notebook 1.0.0!");
		SL.OnPacksLoaded += OnPacksLoaded;
		new Harmony("johbenji.journalnotebook").PatchAll();
	}

	public void FlexibleLogger(string logMessage, bool forceLogging = false, LoggingType? type = null)
	{
		if (!type.HasValue)
		{
			type = LoggingType.Message;
		}
		if (debugMode || forceLogging)
		{
			if (type == LoggingType.Message)
			{
				Log.LogMessage((object)logMessage);
			}
			else if (type.GetValueOrDefault() == LoggingType.Warning)
			{
				Log.LogWarning((object)logMessage);
			}
			else if (type.GetValueOrDefault() == LoggingType.Error)
			{
				Log.LogError((object)logMessage);
			}
			else if (type.GetValueOrDefault() == LoggingType.Info)
			{
				Log.LogInfo((object)logMessage);
			}
		}
	}

	internal void OnPacksLoaded()
	{
		FlexibleLogger("Packs loaded, loading assetbundles into the plugin.");
		LoadSprites();
	}

	public void DelayDo(Action OnAfterDelay, float DelayTime)
	{
		((MonoBehaviour)this).StartCoroutine(DoAfterDelay(OnAfterDelay, DelayTime));
	}

	[IteratorStateMachine(typeof(<DoAfterDelay>d__20))]
	public IEnumerator DoAfterDelay(Action OnAfterDelay, float DelayTime)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <DoAfterDelay>d__20(0)
		{
			<>4__this = this,
			OnAfterDelay = OnAfterDelay,
			DelayTime = DelayTime
		};
	}

	private void LoadSprites()
	{
		SLPack sLPack = SL.GetSLPack(SLPackName);
		SpritesAssetBundle = sLPack.AssetBundles["sprites"];
	}
}
public class NotebookCrafter : MonoBehaviour
{
	private CharacterUI characterUI;

	private Character character;

	private Transform rootUI;

	private Transform questPanel;

	private Transform notebookToggle;

	public Transform notebookPanel;

	public NotesPanelManager notesPanelManager;

	private bool ErrorState = false;

	private bool hasNotebookToggle = false;

	internal void Awake()
	{
		string text = "Awake";
		if (ErrorState)
		{
			JournalNotebookPlugin.Instance.FlexibleLogger("NotebookCrafter (" + text + "): Already in error state. Skipping initialization.", forceLogging: true, JournalNotebookPlugin.LoggingType.Warning);
			return;
		}
		try
		{
			JournalNotebookPlugin.Instance.FlexibleLogger("NotebookCrafter (" + text + "): called on GameObject " + ((Object)((Component)this).gameObject).name);
			rootUI = ((Component)this).transform;
			characterUI = ((Component)rootUI).GetComponent<CharacterUI>();
			character = characterUI.TargetCharacter;
			questPanel = Helper.FindTransformByPath(rootUI, "Canvas/GameplayPanels/Menus/CharacterMenus/MainPanel/Content/MiddlePanel/Quest - Panel");
			CreateNotebookToggle();
			CreateNotebook();
			JournalNotebookPlugin.Instance.FlexibleLogger("NotebookCrafter (" + text + "): finished successfully");
		}
		catch (Exception ex)
		{
			JournalNotebookPlugin.Instance.FlexibleLogger("NotebookCrafter (" + text + "): Exception - " + ex.Message, forceLogging: true, JournalNotebookPlugin.LoggingType.Error);
			ErrorState = true;
		}
	}

	internal void Start()
	{
		string text = "Start";
		if (ErrorState)
		{
			JournalNotebookPlugin.Instance.FlexibleLogger("NotebookCrafter (" + text + "): Already in error state. Skipping initialization.", forceLogging: true, JournalNotebookPlugin.LoggingType.Warning);
			return;
		}
		try
		{
			JournalNotebookPlugin.Instance.FlexibleLogger("NotebookCrafter (" + text + "): called on GameObject " + ((Object)((Component)this).gameObject).name);
			JournalNotebookPlugin.Instance.FlexibleLogger("NotebookCrafter (" + text + "): finished successfully");
		}
		catch (Exception ex)
		{
			JournalNotebookPlugin.Instance.FlexibleLogger("NotebookCrafter (" + text + "): Exception - " + ex.Message, forceLogging: true, JournalNotebookPlugin.LoggingType.Error);
			ErrorState = true;
		}
	}

	private void CreateNotebookToggle()
	{
		string text = "CreateNotebookToggle";
		if (ErrorState)
		{
			JournalNotebookPlugin.Instance.FlexibleLogger("NotebookCrafter (" + text + "): Already in error state. Skipping initialization.", forceLogging: true, JournalNotebookPlugin.LoggingType.Warning);
			return;
		}
		try
		{
			JournalNotebookPlugin.Instance.FlexibleLogger("NotebookCrafter (" + text + "): called on GameObject " + ((Object)((Component)this).gameObject).name);
			GameObject gameObject = ((Component)Helper.FindTransformByPath(questPanel, "Filters/chkSideQuest")).gameObject;
			GameObject val = Object.Instantiate<GameObject>(gameObject, Helper.FindTransformByPath(questPanel, "Filters"));
			notebookToggle = val.transform;
			((Object)notebookToggle).name = "chkNotebook";
			Helper.RemoveComponentAtPath(notebookToggle, "Name/lblText", typeof(UILocalize));
			Text componentAtPath = Helper.GetComponentAtPath<Text>(notebookToggle, "Name/lblText");
			componentAtPath.text = "Notebook";
			Image componentAtPath2 = Helper.GetComponentAtPath<Image>(notebookToggle, "Background");
			Image componentAtPath3 = Helper.GetComponentAtPath<Image>(notebookToggle, "Background/Checkmark");
			componentAtPath2.sprite = JournalNotebookPlugin.Instance.SpritesAssetBundle.LoadAsset<Sprite>("tex_men_journaltabdeactivatedside");
			componentAtPath3.sprite = JournalNotebookPlugin.Instance.SpritesAssetBundle.LoadAsset<Sprite>("tex_men_journaltabactivatedside");
			JournalNotebookPlugin.Instance.FlexibleLogger("NotebookCrafter (" + text + "): finished successfully");
		}
		catch (Exception ex)
		{
			JournalNotebookPlugin.Instance.FlexibleLogger("NotebookCrafter (" + text + "): Exception - " + ex.Message, forceLogging: true, JournalNotebookPlugin.LoggingType.Error);
			ErrorState = true;
		}
	}

	private void CreateNotebook()
	{
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		string text = "CreateNotebook";
		if (ErrorState)
		{
			JournalNotebookPlugin.Instance.FlexibleLogger("NotebookCrafter (" + text + "): Already in error state. Skipping initialization.", forceLogging: true, JournalNotebookPlugin.LoggingType.Warning);
			return;
		}
		try
		{
			JournalNotebookPlugin.Instance.FlexibleLogger("NotebookCrafter (" + text + "): called on GameObject " + ((Object)((Component)this).gameObject).name);
			notesPanelManager = new NotesPanelManager();
			notesPanelManager.CreatePanel(questPanel, character);
			notebookPanel = Helper.FindTransformByPath(questPanel, "NotepadPanel");
			((Component)notebookPanel).gameObject.SetActive(false);
			Transform val = Helper.FindTransformByPath(questPanel, "Filters/Input_Next");
			val.SetAsLastSibling();
			RectTransform val2 = (RectTransform)(object)((val is RectTransform) ? val : null);
			val2.anchoredPosition = new Vector2(1.3f, -212f);
			JournalNotebookPlugin.Instance.FlexibleLogger("NotebookCrafter (" + text + "): finished successfully");
		}
		catch (Exception ex)
		{
			JournalNotebookPlugin.Instance.FlexibleLogger("NotebookCrafter (" + text + "): Exception - " + ex.Message, forceLogging: true, JournalNotebookPlugin.LoggingType.Error);
			ErrorState = true;
		}
	}

	public void Destroy()
	{
		if ((Object)(object)((Component)notebookPanel).gameObject != (Object)null)
		{
			GameObject gameObject = ((Component)notebookPanel).gameObject;
			Object.Destroy((Object)(object)gameObject);
		}
		if ((Object)(object)((Component)notebookToggle).gameObject != (Object)null)
		{
			GameObject gameObject2 = ((Component)notebookToggle).gameObject;
			Object.Destroy((Object)(object)gameObject2);
		}
	}
}
public class NotebookSaveExtension : PlayerSaveExtension
{
	public string NotebookText;

	public override void Save(Character character, bool isWorldHost)
	{
		if (isWorldHost)
		{
			NotebookText = JournalNotebookPlugin.journalNotebookManager.GetNote(character);
			SL.Log("Saving Notebook Text: " + NotebookText);
		}
	}

	public override void ApplyLoadedSave(Character character, bool isWorldHost)
	{
		SL.Log("Loading previous notebook text...");
		if (NotebookText == null)
		{
			SL.Log("No notebook text found in save data for character " + ((Object)character).name);
			return;
		}
		SL.Log("Applying loaded notebook text of character " + ((Object)character).name + " to the Notebook Manager.");
		JournalNotebookPlugin.journalNotebookManager.RegisterFromSave(character, NotebookText);
	}
}
public class NotesPanelManager
{
	public enum map
	{
		Chersonese,
		Enmerkar,
		Abrassar,
		Hallowed,
		Antique,
		Caldera
	}

	[CompilerGenerated]
	private sealed class <SaveAfterDelay>d__21 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public NotesPanelManager <>4__this;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <SaveAfterDelay>d__21(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(1f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				JournalNotebookPlugin.Instance.FlexibleLogger("Saving note for character " + ((Object)<>4__this.targetCharacter).name + ". Note content: " + <>4__this._savedText);
				if ((Object)(object)<>4__this.targetCharacter != (Object)null)
				{
					if (<>4__this._savedText == null)
					{
						<>4__this._savedText = "";
					}
					JournalNotebookPlugin.journalNotebookManager.RegisterNote(<>4__this.targetCharacter, <>4__this._savedText);
				}
				<>4__this._saveCoroutine = null;
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	private GameObject _panel;

	private InputField _inputField;

	private string _savedText = "";

	private int _currentDay = 1;

	public map _currentMap = map.Chersonese;

	private Character targetCharacter;

	private Transform dayObjectTransform;

	private Transform mapObjectTransform;

	private Coroutine _saveCoroutine;

	public void CreatePanel(Transform root, Character character)
	{
		JournalNotebookPlugin.Instance.FlexibleLogger("Creating panel.");
		string text = string.Copy(JournalNotebookPlugin.journalNotebookManager.GetNote(character));
		targetCharacter = character;
		if ((Object)(object)character == (Object)null)
		{
			JournalNotebookPlugin.Instance.FlexibleLogger("Target character is null. Cannot create notes panel.", forceLogging: true, JournalNotebookPlugin.LoggingType.Error);
			return;
		}
		if ((Object)(object)_panel != (Object)null)
		{
			JournalNotebookPlugin.Instance.FlexibleLogger("Panel already added.", forceLogging: false, JournalNotebookPlugin.LoggingType.Warning);
			OverrideText(targetCharacter, JournalNotebookPlugin.journalNotebookManager.GetNote(targetCharacter));
			return;
		}
		_panel = CreateRootPanel(root);
		GameObject val = CreateLeftPanel(_panel.transform);
		GameObject val2 = CreateRightPanel(_panel.transform);
		PopulateLeftPanel(val.transform);
		PopulateRightPanel(val2.transform);
		_panel.SetActive(false);
		if (text != null && text != "")
		{
			OverrideText(targetCharacter, text);
			JournalNotebookPlugin.journalNotebookManager.RegisterNote(targetCharacter, text);
		}
		JournalNotebookPlugin.Instance.FlexibleLogger("Finished creating panel.");
	}

	private GameObject CreateRootPanel(Transform root)
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Expected O, but got Unknown
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Expected O, but got Unknown
		GameObject val = new GameObject("NotepadPanel", new Type[2]
		{
			typeof(RectTransform),
			typeof(Image)
		});
		val.transform.SetParent(root, false);
		RectTransform component = val.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(0f, 1f);
		component.anchorMax = new Vector2(0f, 1f);
		((Graphic)val.GetComponent<Image>()).color = new Color(0f, 0f, 0f, 0f);
		HorizontalLayoutGroup val2 = val.AddComponent<HorizontalLayoutGroup>();
		((HorizontalOrVerticalLayoutGroup)val2).childControlWidth = true;
		((HorizontalOrVerticalLayoutGroup)val2).childControlHeight = true;
		((HorizontalOrVerticalLayoutGroup)val2).childForceExpandWidth = false;
		((HorizontalOrVerticalLayoutGroup)val2).childForceExpandHeight = false;
		((LayoutGroup)val2).childAlignment = (TextAnchor)2;
		((HorizontalOrVerticalLayoutGroup)val2).spacing = 0f;
		((LayoutGroup)val2).padding = new RectOffset(15, 20, 15, 0);
		return val;
	}

	private GameObject CreateLeftPanel(Transform parent)
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		//IL_0031: 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_005d: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("LeftPanel", new Type[1] { typeof(RectTransform) });
		RectTransform component = val.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(0f, 1f);
		component.anchorMax = new Vector2(0f, 1f);
		component.pivot = new Vector2(0.5f, 0.5f);
		val.transform.SetParent(parent, false);
		VerticalLayoutGroup val2 = val.AddComponent<VerticalLayoutGroup>();
		((HorizontalOrVerticalLayoutGroup)val2).childControlWidth = true;
		((HorizontalOrVerticalLayoutGroup)val2).childControlHeight = true;
		((HorizontalOrVerticalLayoutGroup)val2).childForceExpandWidth = true;
		((HorizontalOrVerticalLayoutGroup)val2).childForceExpandHeight = false;
		((HorizontalOrVerticalLayoutGroup)val2).spacing = 10f;
		((LayoutGroup)val2).childAlignment = (TextAnchor)0;
		LayoutElement val3 = val.AddComponent<LayoutElement>();
		val3.flexibleWidth = 3f;
		return val;
	}

	private GameObject CreateRightPanel(Transform parent)
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		//IL_0031: 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_005d: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("RightPanel", new Type[1] { typeof(RectTransform) });
		RectTransform component = val.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(0f, 1f);
		component.anchorMax = new Vector2(0f, 1f);
		component.pivot = new Vector2(0.5f, 0.5f);
		val.transform.SetParent(parent, false);
		LayoutElement val2 = val.AddComponent<LayoutElement>();
		val2.flexibleWidth = 1f;
		val2.flexibleHeight = 1f;
		return val;
	}

	private void PopulateLeftPanel(Transform parent)
	{
		CreateTitle(parent);
		CreateScrollableInput(parent);
	}

	private void CreateTitle(Transform parent)
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		//IL_0031: 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)
		GameObject val = new GameObject("Title", new Type[1] { typeof(RectTransform) });
		RectTransform component = val.GetComponent<RectTransform>();
		component.pivot = new Vector2(0.5f, 0.5f);
		val.transform.SetParent(parent, false);
		Text val2 = val.AddComponent<Text>();
		val2.text = "Notes";
		val2.font = UIUtilities.RegularFont;
		val2.fontSize = 18;
		((Graphic)val2).color = new Color(0.8392f, 0.6353f, 0.3765f, 1f);
		val2.alignment = (TextAnchor)4;
		LayoutElement val3 = val.AddComponent<LayoutElement>();
		val3.minWidth = 40f;
		val3.minHeight = 40f;
		val3.preferredHeight = 20f;
		CreateLine(val.transform);
	}

	private void CreateLine(Transform parent)
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		//IL_0031: 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_005d: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("Line", new Type[1] { typeof(RectTransform) });
		RectTransform component = val.GetComponent<RectTransform>();
		component.pivot = new Vector2(0.5f, 0f);
		component.anchoredPosition = new Vector2(5f, -5f);
		component.anchorMin = new Vector2(0f, 0f);
		component.anchorMax = new Vector2(1f, 0f);
		val.transform.SetParent(parent, false);
		Image val2 = val.AddComponent<Image>();
		val2.sprite = JournalNotebookPlugin.Instance.SpritesAssetBundle.LoadAsset<Sprite>("tex_men_separatorGold");
		LayoutElement val3 = val.AddComponent<LayoutElement>();
		AspectRatioFitter val4 = val.AddComponent<AspectRatioFitter>();
		val4.aspectMode = (AspectMode)1;
		val4.aspectRatio = 36.090908f;
		((Transform)component).localScale = new Vector3(0.87f, 0.87f, 0.87f);
	}

	private void CreateScrollableInput(Transform parent)
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Expected O, but got Unknown
		//IL_00b8: 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)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Expected O, but got Unknown
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c5: Expected O, but got Unknown
		//IL_01e5: 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)
		//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0225: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Unknown result type (might be due to invalid IL or missing references)
		//IL_024f: Expected O, but got Unknown
		//IL_026f: Unknown result type (might be due to invalid IL or missing references)
		//IL_027c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0289: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_039b: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a2: Expected O, but got Unknown
		//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0410: Unknown result type (might be due to invalid IL or missing references)
		//IL_041d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0473: Unknown result type (might be due to invalid IL or missing references)
		//IL_047a: Expected O, but got Unknown
		//IL_049a: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_04eb: Expected O, but got Unknown
		//IL_053b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0551: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("NotepadScroll", new Type[1] { typeof(RectTransform) });
		val.transform.SetParent(parent, false);
		LayoutElement val2 = val.AddComponent<LayoutElement>();
		val2.flexibleHeight = 1f;
		val2.flexibleWidth = 1f;
		ScrollRect val3 = val.AddComponent<ScrollRect>();
		val3.horizontal = false;
		val3.vertical = true;
		GameObject val4 = new GameObject("Viewport", new Type[3]
		{
			typeof(RectTransform),
			typeof(Image),
			typeof(Mask)
		});
		val4.transform.SetParent(val.transform, false);
		RectTransform component = val4.GetComponent<RectTransform>();
		component.anchorMin = Vector2.zero;
		component.anchorMax = Vector2.one;
		component.sizeDelta = new Vector2(-20f, 0f);
		component.anchoredPosition = Vector2.zero;
		val4.GetComponent<Mask>().showMaskGraphic = false;
		GameObject val5 = new GameObject("Content", new Type[1] { typeof(RectTransform) });
		val5.transform.SetParent(val4.transform, false);
		RectTransform component2 = val5.GetComponent<RectTransform>();
		component2.anchorMin = new Vector2(0f, 1f);
		component2.anchorMax = new Vector2(1f, 1f);
		component2.pivot = new Vector2(0.5f, 1f);
		component2.sizeDelta = new Vector2(0f, 400f);
		GameObject val6 = new GameObject("NotepadInput", new Type[2]
		{
			typeof(RectTransform),
			typeof(Image)
		});
		val6.transform.SetParent(val5.transform, false);
		RectTransform component3 = val6.GetComponent<RectTransform>();
		component3.anchorMin = Vector2.zero;
		component3.anchorMax = Vector2.one;
		component3.sizeDelta = Vector2.zero;
		((Graphic)val6.GetComponent<Image>()).color = new Color(0f, 0f, 0f, 0.5f);
		GameObject val7 = new GameObject("Text", new Type[1] { typeof(RectTransform) });
		val7.transform.SetParent(val6.transform, false);
		RectTransform component4 = val7.GetComponent<RectTransform>();
		component4.anchorMin = Vector2.zero;
		component4.anchorMax = Vector2.one;
		component4.sizeDelta = Vector2.zero;
		component4.offsetMin = new Vector2(5f, 5f);
		component4.offsetMax = new Vector2(-5f, -5f);
		Text val8 = val7.AddComponent<Text>();
		val8.font = UIUtilities.RegularFont;
		val8.fontSize = 19;
		((Graphic)val8).color = Color.white;
		val8.supportRichText = false;
		val8.horizontalOverflow = (HorizontalWrapMode)0;
		val8.verticalOverflow = (VerticalWrapMode)0;
		_inputField = val6.AddComponent<InputField>();
		_inputField.textComponent = val8;
		_inputField.lineType = (LineType)2;
		_inputField.text = _savedText;
		((UnityEvent<string>)(object)_inputField.onValueChanged).AddListener((UnityAction<string>)OnTextChanged);
		_inputField.characterLimit = 0;
		val6.AddComponent<InputFieldEscapeFix>();
		GameObject val9 = new GameObject("Scrollbar", new Type[2]
		{
			typeof(RectTransform),
			typeof(Image)
		});
		val9.transform.SetParent(val.transform, false);
		RectTransform component5 = val9.GetComponent<RectTransform>();
		component5.anchorMin = new Vector2(1f, 0f);
		component5.anchorMax = new Vector2(1f, 1f);
		component5.pivot = new Vector2(1f, 0.5f);
		component5.sizeDelta = new Vector2(20f, 0f);
		component5.anchoredPosition = Vector2.zero;
		val9.GetComponent<Image>().sprite = JournalNotebookPlugin.Instance.SpritesAssetBundle.LoadAsset<Sprite>("tex_men_scrollbarGoldWide");
		Scrollbar val10 = val9.AddComponent<Scrollbar>();
		val10.direction = (Direction)2;
		GameObject val11 = new GameObject("Sliding Area", new Type[1] { typeof(RectTransform) });
		val11.transform.SetParent(val9.transform, false);
		RectTransform component6 = val11.GetComponent<RectTransform>();
		component6.anchorMin = Vector2.zero;
		component6.anchorMax = Vector2.one;
		component6.sizeDelta = Vector2.zero;
		GameObject val12 = new GameObject("Handle", new Type[2]
		{
			typeof(RectTransform),
			typeof(Image)
		});
		val12.transform.SetParent(val11.transform, false);
		Image component7 = val12.GetComponent<Image>();
		component7.sprite = JournalNotebookPlugin.Instance.SpritesAssetBundle.LoadAsset<Sprite>("NewHandle");
		((Graphic)component7).color = new Color(1f, 1f, 1f, 1f);
		RectTransform component8 = val12.GetComponent<RectTransform>();
		component8.sizeDelta = Vector2.zero;
		val10.handleRect = component8;
		val3.viewport = component;
		val3.content = component2;
		val3.verticalScrollbar = val10;
		val3.verticalScrollbarVisibility = (ScrollbarVisibility)2;
	}

	private void PopulateRightPanel(Transform parent)
	{
		Transform parent2 = CreatePicture(parent);
		CreateDescription(parent2);
	}

	private Transform CreatePicture(Transform parent)
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Expected O, but got Unknown
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: 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_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("QuestPicture", new Type[2]
		{
			typeof(RectTransform),
			typeof(Image)
		});
		mapObjectTransform = val.transform;
		RectTransform component = val.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(1f, 0f);
		component.anchorMax = new Vector2(1f, 1f);
		component.anchoredPosition = Vector2.zero;
		component.pivot = new Vector2(1f, 0f);
		component.offsetMin = new Vector2(0f, 0f);
		component.offsetMax = new Vector2(0f, 0f);
		component.sizeDelta = new Vector2(138.2179f, 0f);
		val.transform.SetParent(parent, false);
		Image component2 = val.GetComponent<Image>();
		((Graphic)component2).color = Color.white;
		component2.type = (Type)0;
		component2.preserveAspect = false;
		component2.sprite = JournalNotebookPlugin.Instance.SpritesAssetBundle.LoadAsset<Sprite>("Chersonese");
		LayoutElement val2 = val.AddComponent<LayoutElement>();
		val2.flexibleHeight = 1f;
		AspectRatioFitter val3 = val.AddComponent<AspectRatioFitter>();
		val3.aspectMode = (AspectMode)2;
		val3.aspectRatio = 0.5143185f;
		return val.transform;
	}

	private void CreateDescription(Transform parent)
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		//IL_003d: 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_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("DayTimer", new Type[1] { typeof(RectTransform) });
		dayObjectTransform = val.transform;
		RectTransform component = val.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(0f, 1f);
		component.anchorMax = new Vector2(0f, 1f);
		component.anchoredPosition = new Vector2(10f, -10f);
		component.pivot = new Vector2(0f, 1f);
		val.transform.SetParent(parent, false);
		Text val2 = val.AddComponent<Text>();
		val2.fontSize = 19;
		val2.font = UIUtilities.RegularFont;
		val2.alignment = (TextAnchor)0;
		val2.horizontalOverflow = (HorizontalWrapMode)0;
		val2.verticalOverflow = (VerticalWrapMode)1;
		val2.text = "Day: " + _currentDay;
	}

	private void OnTextChanged(string value)
	{
		_savedText = value;
		if (_saveCoroutine != null)
		{
			((MonoBehaviour)JournalNotebookPlugin.Instance).StopCoroutine(_saveCoroutine);
		}
		_saveCoroutine = ((MonoBehaviour)JournalNotebookPlugin.Instance).StartCoroutine(SaveAfterDelay());
	}

	[IteratorStateMachine(typeof(<SaveAfterDelay>d__21))]
	private IEnumerator SaveAfterDelay()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <SaveAfterDelay>d__21(0)
		{
			<>4__this = this
		};
	}

	public void OverrideText(Character character, string newText)
	{
		JournalNotebookPlugin.Instance.FlexibleLogger("NotesPanelManager: Attempting to override text for character " + ((Object)character).name + ". New text: " + newText);
		if ((Object)(object)character == (Object)(object)targetCharacter)
		{
			_savedText = newText;
			if ((Object)(object)_inputField != (Object)null)
			{
				_inputField.text = newText;
			}
			else
			{
				JournalNotebookPlugin.Instance.FlexibleLogger("NotesPanelManager: InputField is null. Cannot override text.", forceLogging: true, JournalNotebookPlugin.LoggingType.Error);
			}
		}
		else
		{
			JournalNotebookPlugin.Instance.FlexibleLogger("NotesPanelManager: Character mismatch when trying to override text. Target character: " + ((Object)targetCharacter).name + ", provided character: " + ((Object)character).name, forceLogging: true, JournalNotebookPlugin.LoggingType.Warning);
		}
	}

	private void FetchDay()
	{
		float num = (float)EnvironmentConditions.GameTime;
		int day = Mathf.FloorToInt(num / 24f) + 1;
		UpdateDay(day);
	}

	public void UpdateDay(int day)
	{
		_currentDay = day;
		if ((Object)(object)_panel != (Object)null)
		{
			Text component = ((Component)dayObjectTransform).GetComponent<Text>();
			if ((Object)(object)component != (Object)null)
			{
				component.text = "Day: " + _currentDay;
			}
		}
	}

	private void FetchMap()
	{
		int iD = AreaManager.Instance.CurrentArea.ID;
		UpdateMap(iD);
	}

	public void UpdateMap(int mapID)
	{
		_currentMap = map.Chersonese;
		if ((Object)(object)mapObjectTransform != (Object)null)
		{
			if ((mapID <= 100 && mapID < 200) || mapID == 552)
			{
				_currentMap = map.Chersonese;
			}
			else if (mapID >= 200 && mapID < 300)
			{
				_currentMap = map.Hallowed;
			}
			else if (mapID >= 300 && mapID < 400)
			{
				_currentMap = map.Abrassar;
			}
			else if (mapID >= 400 && mapID < 500)
			{
				_currentMap = map.Antique;
			}
			else if (mapID >= 500 && mapID < 600 && mapID != 552)
			{
				_currentMap = map.Enmerkar;
			}
			else if (mapID >= 600 && mapID < 700)
			{
				_currentMap = map.Caldera;
			}
		}
		string spriteName = _currentMap.ToString();
		ChangeSprite(mapObjectTransform, spriteName);
	}

	private void ChangeSprite(Transform transform, string spriteName)
	{
		if (!((Object)(object)transform != (Object)null))
		{
			return;
		}
		Image component = ((Component)transform).GetComponent<Image>();
		if ((Object)(object)component != (Object)null)
		{
			Sprite val = JournalNotebookPlugin.Instance.SpritesAssetBundle.LoadAsset<Sprite>(spriteName);
			if ((Object)(object)val != (Object)null)
			{
				component.sprite = val;
			}
		}
	}

	public void Show()
	{
		if ((Object)(object)_panel != (Object)null)
		{
			FetchDay();
			FetchMap();
			_panel.SetActive(true);
			Helper.FindObjectByName(((Component)_panel.transform.parent).gameObject, "QuestList").SetActive(false);
			Helper.FindObjectByName(((Component)_panel.transform.parent).gameObject, "QuestDetails").SetActive(false);
		}
	}

	public void Hide()
	{
		if ((Object)(object)_panel != (Object)null)
		{
			_panel.SetActive(false);
			Helper.FindObjectByName(((Component)_panel.transform.parent).gameObject, "QuestList").SetActive(true);
			Helper.FindObjectByName(((Component)_panel.transform.parent).gameObject, "QuestDetails").SetActive(true);
		}
	}
}
public class patches
{
	[HarmonyPatch(typeof(Character), "Awake")]
	public static class CharacterAwakePatch
	{
		private static void Postfix(Character __instance)
		{
			JournalNotebookPlugin.Instance.DelayDo(delegate
			{
				if (__instance.IsLocalPlayer)
				{
					JournalNotebookPlugin.Instance.FlexibleLogger("Adding Notebook Crafter to the character.");
					if ((Object)(object)__instance == (Object)null)
					{
						JournalNotebookPlugin.Instance.FlexibleLogger("Character instance is null.", forceLogging: true, JournalNotebookPlugin.LoggingType.Error);
					}
					else if ((Object)(object)__instance.CharacterUI == (Object)null)
					{
						JournalNotebookPlugin.Instance.FlexibleLogger("CharacterUI is null for character " + ((Object)__instance).name, forceLogging: true, JournalNotebookPlugin.LoggingType.Error);
					}
					else
					{
						CharacterUI characterUI = __instance.CharacterUI;
						NotebookCrafter component = ((Component)characterUI).GetComponent<NotebookCrafter>();
						if ((Object)(object)component != (Object)null)
						{
							JournalNotebookPlugin.Instance.FlexibleLogger("Notebook crafter already exists on the character, destroying previous one.", forceLogging: false, JournalNotebookPlugin.LoggingType.Warning);
							component.Destroy();
							Object.Destroy((Object)(object)component);
						}
						NotebookCrafter notebookCrafter = ((Component)characterUI).gameObject.AddComponent<NotebookCrafter>();
					}
				}
			}, 3f);
		}
	}

	[HarmonyPatch(typeof(Toggle), "Set")]
	public class Toggle_Set_Patch
	{
		private static void Postfix(Toggle __instance, bool value)
		{
			if (!(((Object)__instance).name != "chkNotebook"))
			{
				JournalNotebookPlugin.Instance.FlexibleLogger("Notebook Toggle Set to " + value);
				NotesPanelManager notesPanelManager = GetNotesPanelManager(__instance);
				if (notesPanelManager == null)
				{
					JournalNotebookPlugin.Instance.FlexibleLogger("NotesPanelManager instance is null.", forceLogging: true, JournalNotebookPlugin.LoggingType.Error);
				}
				else if (value)
				{
					notesPanelManager.Show();
				}
				else
				{
					notesPanelManager.Hide();
				}
			}
		}

		private static NotesPanelManager GetNotesPanelManager(Toggle component)
		{
			InventorySectionButton component2 = ((Component)component).GetComponent<InventorySectionButton>();
			if ((Object)(object)component2 == (Object)null)
			{
				JournalNotebookPlugin.Instance.FlexibleLogger("Could not find InventorySectionButton component on the toggle.", forceLogging: true, JournalNotebookPlugin.LoggingType.Error);
				return null;
			}
			CharacterUI characterUI = ((UIElement)component2).CharacterUI;
			if ((Object)(object)characterUI == (Object)null)
			{
				JournalNotebookPlugin.Instance.FlexibleLogger("Could not find CharacterUI reference on InventorySectionButton.", forceLogging: true, JournalNotebookPlugin.LoggingType.Error);
				return null;
			}
			NotebookCrafter component3 = ((Component)characterUI).GetComponent<NotebookCrafter>();
			if ((Object)(object)component3 == (Object)null)
			{
				JournalNotebookPlugin.Instance.FlexibleLogger("Could not find NotebookCrafter component on CharacterUI.", forceLogging: true, JournalNotebookPlugin.LoggingType.Error);
				return null;
			}
			return component3.notesPanelManager;
		}
	}
}