using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

// Token: 0x020000BB RID: 187
public class Journal : MonoBehaviour
{
	// Token: 0x060011C1 RID: 4545 RVA: 0x0015CB10 File Offset: 0x0015AD10
	private void Start()
	{
		Links.x.journal = this;
		this.noteAnimator.speed = 1.5f;
		if (!Records.x.windows)
		{
			this.scrollRectLeft.scrollSensitivity = 9f;
			this.scrollRectRight.scrollSensitivity = 9f;
		}
		this.anim.enabled = false;
		this.CloseMenu();
	}

	// Token: 0x060011C2 RID: 4546 RVA: 0x0015CB78 File Offset: 0x0015AD78
	public void ClearNotes()
	{
		for (int i = 0; i < this.playerNotes.Count; i++)
		{
			if (this.playerNotes[i])
			{
				Object.Destroy(this.playerNotes[i].gameObject);
			}
		}
		for (int j = 0; j < this.itemNotes.Count; j++)
		{
			if (this.itemNotes[j])
			{
				Object.Destroy(this.itemNotes[j].gameObject);
			}
		}
		this.itemNotes.Clear();
		this.playerNotes.Clear();
		this.playerScrolls.Clear();
		this.playerScrollLabels.Clear();
		this.playerScrollIDs.Clear();
		this.itemScrollInventory.Clear();
		this.itemScrollIDs.Clear();
		this.noteCount = 0;
	}

	// Token: 0x060011C3 RID: 4547 RVA: 0x0015CC57 File Offset: 0x0015AE57
	public void NewGame()
	{
		base.StartCoroutine(this.WaitForNewGame());
	}

	// Token: 0x060011C4 RID: 4548 RVA: 0x0015CC66 File Offset: 0x0015AE66
	private IEnumerator WaitForNewGame()
	{
		yield return new WaitForSecondsRealtime(0.1f);
		this.AddNote("", "Conversation Notes", Random.Range(0, 6), true, "", "Scroll", -1, -1);
		yield break;
	}

	// Token: 0x060011C5 RID: 4549 RVA: 0x0015CC78 File Offset: 0x0015AE78
	public void DoSave()
	{
		string text = Records.x.openBook + "/Records.es3";
		this.playerScrolls.Clear();
		this.playerScrollLabels.Clear();
		this.playerScrollIDs.Clear();
		this.itemScrollInventory.Clear();
		this.itemScrollIDs.Clear();
		this.saveFile = new ES3File(text);
		for (int i = 0; i < this.playerNotes.Count; i++)
		{
			this.playerScrolls.Add(this.playerNotes[i].note);
			this.playerScrollLabels.Add(this.playerNotes[i].label);
			this.playerScrollIDs.Add(this.playerNotes[i].ID);
			this.itemScrollIDs.Add(this.playerNotes[i].uniqueID);
		}
		this.saveFile.Save<List<string>>("Player Scrolls", this.playerScrolls);
		this.saveFile.Save<List<string>>("Item Scroll Inventory Names", this.itemScrollInventory);
		this.saveFile.Save<List<int>>("Player Scroll ID", this.playerScrollIDs);
		this.saveFile.Save<List<int>>("Item Scroll ID", this.itemScrollIDs);
		this.saveFile.Save<List<string>>("Player Scroll Labels", this.playerScrollLabels);
		this.saveFile.Save<string>("Pinned Note Text", Links.x.hudControl.savedNoteText);
		this.saveFile.Save<string>("Pinned Note Image", Links.x.hudControl.savedNoteImage);
		this.saveFile.Save<string>("Pinned Note Rune", Links.x.hudControl.savedNoteRune);
		this.saveFile.Save<int>("Note Count", this.noteCount);
		this.saveFile.Sync();
	}

	// Token: 0x060011C6 RID: 4550 RVA: 0x0015CE54 File Offset: 0x0015B054
	public void StartMenu()
	{
		if (this.open)
		{
			return;
		}
		this.pinButton.SetActive(false);
		if (Links.x.diorama.sceneName == "F4_BanquetIsle")
		{
			this.pavuraNote.SetActive(false);
		}
		else
		{
			this.pavuraNote.SetActive(true);
		}
		Links.x.gameplay.lastMenu = "Journal";
		this.anim.enabled = true;
		Links.x.gameplay.openingAnotherMenu = true;
		Links.x.gameplay.CloseAllMenus();
		if (!Records.x.inMenus && Links.x.gaia.sceneLoaded)
		{
			Links.x.gameplay.OpenDock();
		}
		this.removeScrollMenu.SetActive(false);
		this.canvas.enabled = true;
		this.contents1.SetActive(true);
		this.contents2.SetActive(true);
		bool flag = false;
		if (Links.x.joy && (Links.x.gameplay.dockStart || Links.x.gameplay.itemsStart))
		{
			flag = true;
		}
		if (flag)
		{
			this.anim.Play("Open", 0, 1f);
		}
		else
		{
			this.anim.Play("Open");
		}
		Records.x.AddMenu(base.gameObject);
		this.open = true;
		this.closeNoteBtn.interactable = false;
		this.UpdateWithCloseButton();
		if (Links.x.joy)
		{
			Links.x.hudControl.UpdateMenuSwitcher("Journal");
		}
		Links.x.gameplay.SetInteractableSelected(EventSystem.current, this.playerNotes[0].gameObject);
		this.UpdateButtonNavs(this.playerNotes[0]);
		if (Links.x.joy)
		{
			this.UpdateScrollNav(true, this.playerNotes[0], true);
		}
		this.inputFieldBorderTitle.color = new Color(0f, 0f, 0f, 0f);
		this.inputFieldBorderNote.color = new Color(0f, 0f, 0f, 0f);
	}

	// Token: 0x060011C7 RID: 4551 RVA: 0x0015D08C File Offset: 0x0015B28C
	public void LoadScrolls()
	{
		this.ClearNotes();
		this.playerScrolls.Clear();
		this.playerScrollLabels.Clear();
		this.playerScrollIDs.Clear();
		this.itemScrollInventory.Clear();
		this.itemScrollIDs.Clear();
		string text = Records.x.openBook + "/Records.es3";
		this.saveFile = new ES3File(text);
		if (this.saveFile.KeyExists("Player Scrolls"))
		{
			this.playerScrolls = this.saveFile.Load<List<string>>("Player Scrolls");
			this.itemScrollInventory = this.saveFile.Load<List<string>>("Item Scroll Inventory Names");
			this.playerScrollIDs = this.saveFile.Load<List<int>>("Player Scroll ID");
			this.itemScrollIDs = this.saveFile.Load<List<int>>("Item Scroll ID");
			this.playerScrollLabels = this.saveFile.Load<List<string>>("Player Scroll Labels");
			Links.x.hudControl.savedNoteText = this.saveFile.Load<string>("Pinned Note Text");
			Links.x.hudControl.savedNoteImage = this.saveFile.Load<string>("Pinned Note Image");
			Links.x.hudControl.savedNoteRune = this.saveFile.Load<string>("Pinned Note Rune");
			Links.x.hudControl.SetPinnedNoteFromLoad();
		}
		bool flag = false;
		if (this.saveFile.KeyExists("Note Count"))
		{
			this.noteCount = this.saveFile.Load<int>("Note Count");
		}
		else
		{
			this.noteCount = 0;
			flag = true;
		}
		for (int i = 0; i < this.playerScrolls.Count; i++)
		{
			this.playerNotes.Add(null);
			if (flag)
			{
				this.itemScrollIDs.Add(this.noteCount);
				this.noteCount++;
			}
			this.AddNote(this.playerScrolls[i], this.playerScrollLabels[i], this.playerScrollIDs[i], true, "", "Scroll", i, this.itemScrollIDs[i]);
		}
	}

	// Token: 0x060011C8 RID: 4552 RVA: 0x0015D2A4 File Offset: 0x0015B4A4
	public void AddNoteFromButton()
	{
		this.AddNote("", "", Random.Range(0, 6), true, "", "Scroll", -1, -1);
	}

	// Token: 0x060011C9 RID: 4553 RVA: 0x0015D2D8 File Offset: 0x0015B4D8
	public void AddNote(string text, string label, int id, bool userCreated, string inventoryName, string tag, int index, int uniqueID)
	{
		JournalScroll journalScroll = null;
		if (userCreated)
		{
			journalScroll = Object.Instantiate<GameObject>(this.scrollsVariationsLeft[id], new Vector3(0f, 0f, 0f), Quaternion.identity, this.leftScrollParent).GetComponent<JournalScroll>();
			if (index == -1)
			{
				this.playerNotes.Add(journalScroll);
				this.playerScrolls.Add(journalScroll.note);
				this.playerScrollLabels.Add(journalScroll.label);
				this.playerScrollIDs.Add(journalScroll.ID);
				uniqueID = this.noteCount;
				this.itemScrollIDs.Add(this.noteCount);
				this.noteCount++;
			}
			else
			{
				this.playerNotes[index] = journalScroll;
				this.playerScrolls[index] = journalScroll.note;
				this.playerScrollLabels[index] = journalScroll.label;
				this.playerScrollIDs[index] = journalScroll.ID;
			}
		}
		journalScroll.gameObject.transform.localPosition = new Vector3(0f, 0f, 0f);
		journalScroll.userCreated = userCreated;
		journalScroll.inventoryName = inventoryName;
		journalScroll.note = text;
		journalScroll.label = label;
		journalScroll.textLabel.text = label;
		journalScroll.uniqueID = uniqueID;
		this.UpdateScrollNav(userCreated, journalScroll, true);
		if (this.playerNotes.Count == 0 || userCreated)
		{
			this.UpdateButtonNavs(journalScroll);
		}
	}

	// Token: 0x060011CA RID: 4554 RVA: 0x0015D454 File Offset: 0x0015B654
	private void UpdateButtonNavs(JournalScroll scroll)
	{
		if (Links.x.joy)
		{
			if (!scroll.button)
			{
				scroll.button = scroll.gameObject.GetComponent<Button>();
			}
			Navigation navigation = this.addNoteBtn.navigation;
			navigation.selectOnUp = scroll.button;
			this.addNoteBtn.navigation = navigation;
			navigation = this.closeNoteBtn.navigation;
			navigation.selectOnUp = scroll.button;
			this.closeNoteBtn.navigation = navigation;
		}
	}

	// Token: 0x060011CB RID: 4555 RVA: 0x0015D4D8 File Offset: 0x0015B6D8
	private void UpdateWithCloseButton()
	{
		if (Links.x.joy)
		{
			Navigation navigation = this.addNoteBtn.navigation;
			if (this.closeNoteBtn.interactable)
			{
				navigation.selectOnRight = this.closeNoteBtn;
			}
			else
			{
				navigation.selectOnRight = navigation.selectOnUp;
			}
			this.addNoteBtn.navigation = navigation;
		}
	}

	// Token: 0x060011CC RID: 4556 RVA: 0x0015D534 File Offset: 0x0015B734
	public void UpdateLastNoteOpened(JournalScroll scroll)
	{
		if (Links.x.joy)
		{
			this.noteLabelField.navigation.selectOnLeft = scroll.button;
			this.noteInputField.navigation.selectOnLeft = scroll.button;
			scroll.button.navigation.selectOnRight = this.noteLabelField;
			this.lastNote = scroll;
			this.StartTyping();
		}
	}

	// Token: 0x060011CD RID: 4557 RVA: 0x0015D5A5 File Offset: 0x0015B7A5
	public void ReturnLastNoteOpened()
	{
		base.StartCoroutine(this.ReturningNote());
	}

	// Token: 0x060011CE RID: 4558 RVA: 0x0015D5B4 File Offset: 0x0015B7B4
	private IEnumerator ReturningNote()
	{
		if (Links.x.joy)
		{
			JournalScroll journalScroll = this.lastNote;
			if (this.lastNote)
			{
				Button component = journalScroll.gameObject.GetComponent<Button>();
				Navigation navigation = component.navigation;
				if (this.itemNotes.Count > 0)
				{
					navigation.selectOnRight = this.itemNotes[0].button;
				}
				else
				{
					navigation.selectOnRight = null;
				}
				component.navigation = navigation;
			}
			yield return new WaitForSecondsRealtime(0.1f);
			EventSystem.current.SetSelectedGameObject(this.lastNote.gameObject);
			this.lastNote = null;
		}
		yield break;
	}

	// Token: 0x060011CF RID: 4559 RVA: 0x0015D5C4 File Offset: 0x0015B7C4
	private void UpdateScrollNav(bool userCreated, JournalScroll scroll, bool all)
	{
		if (Links.x.joy)
		{
			if (userCreated || all)
			{
				for (int i = 0; i < this.playerNotes.Count; i++)
				{
					scroll = this.playerNotes[i];
					if (!scroll.button)
					{
						scroll.button = scroll.gameObject.GetComponent<Button>();
					}
					Button button = scroll.button;
					Navigation navigation = button.navigation;
					if (this.itemNotes.Count > 0)
					{
						navigation.selectOnRight = this.itemNotes[0].button;
					}
					else
					{
						navigation.selectOnRight = null;
					}
					int num = this.playerNotes.IndexOf(scroll);
					if (num > 0 && num < this.playerNotes.Count - 1)
					{
						navigation.selectOnUp = this.playerNotes[num - 1].button;
						navigation.selectOnDown = this.playerNotes[num + 1].button;
					}
					else if (num < 1)
					{
						navigation.selectOnUp = null;
						if (num + 1 < this.playerNotes.Count)
						{
							navigation.selectOnDown = this.playerNotes[num + 1].button;
						}
						else
						{
							navigation.selectOnDown = this.addNoteBtn;
						}
					}
					else
					{
						navigation.selectOnUp = this.playerNotes[num - 1].button;
						navigation.selectOnDown = this.addNoteBtn;
					}
					button.navigation = navigation;
				}
			}
			if (!userCreated || all)
			{
				for (int j = 0; j < this.itemNotes.Count; j++)
				{
					scroll = this.itemNotes[j];
					if (!scroll.button)
					{
						scroll.button = scroll.gameObject.GetComponent<Button>();
					}
					Button button2 = scroll.button;
					Navigation navigation2 = button2.navigation;
					if (this.playerNotes.Count > 0)
					{
						navigation2.selectOnLeft = this.playerNotes[0].button;
					}
					else
					{
						navigation2.selectOnRight = null;
					}
					int num2 = this.itemNotes.IndexOf(scroll);
					if (num2 > 0 && num2 < this.itemNotes.Count - 1)
					{
						navigation2.selectOnUp = this.itemNotes[num2 - 1].button;
						navigation2.selectOnDown = this.itemNotes[num2 + 1].button;
					}
					else if (num2 < 1)
					{
						navigation2.selectOnUp = null;
						if (num2 + 1 < this.itemNotes.Count)
						{
							navigation2.selectOnDown = this.itemNotes[num2 + 1].button;
						}
						else
						{
							navigation2.selectOnDown = this.addNoteBtn;
						}
					}
					else
					{
						navigation2.selectOnUp = this.itemNotes[num2 - 1].button;
						navigation2.selectOnDown = this.addNoteBtn;
					}
					button2.navigation = navigation2;
				}
			}
		}
	}

	// Token: 0x060011D0 RID: 4560 RVA: 0x0015D8A0 File Offset: 0x0015BAA0
	public void SaveSelectedScroll()
	{
		if (!this.selectedScroll)
		{
			return;
		}
		if (this.selectedScroll.userCreated)
		{
			this.selectedScroll.note = this.noteInputField.text;
			this.selectedScroll.label = this.noteLabelField.text;
			this.selectedScroll.textLabel.text = this.selectedScroll.label;
		}
	}

	// Token: 0x060011D1 RID: 4561 RVA: 0x0015D910 File Offset: 0x0015BB10
	public void OpenNote(JournalScroll scroll)
	{
		if (this.removingNote)
		{
			this.selectedScroll = scroll;
			this.RemoveNote();
			return;
		}
		if (this.coroutine == null)
		{
			this.coroutine = this.StartOpen(scroll);
			base.StartCoroutine(this.coroutine);
		}
		this.closeNoteBtn.interactable = true;
		this.UpdateWithCloseButton();
		this.UpdateDockNote();
		if (this.selectedScroll)
		{
			string text = "Jrnl" + this.selectedScroll.uniqueID.ToString();
			if (Links.x.hudControl.savedNoteImage == text)
			{
				this.pinText.text = "Pinned";
				return;
			}
			this.pinText.text = "Pin to dock";
		}
	}

	// Token: 0x060011D2 RID: 4562 RVA: 0x0015D9CD File Offset: 0x0015BBCD
	private IEnumerator StartOpen(JournalScroll scroll)
	{
		if (this.selectedScroll != null)
		{
			this.CloseNote();
			yield return new WaitForSecondsRealtime(0.1f);
		}
		this.noteAnimator.Play("OpenMiddleScroll");
		this.noteInputField.text = "";
		this.noteLabelField.text = "";
		scroll.SetImageColor();
		if (scroll.userCreated)
		{
			this.noteInputField.gameObject.SetActive(true);
			this.noteLabelField.gameObject.SetActive(true);
			this.itemNoteText.gameObject.SetActive(false);
			this.itemNoteImage.gameObject.SetActive(false);
			this.noteInputField.text = scroll.note;
			this.noteLabelField.text = scroll.label;
			this.selectedScroll = scroll;
			this.closeNoteBtn.interactable = true;
			if (this.playerNotes.IndexOf(scroll) == 0)
			{
				this.noteLabelField.interactable = false;
			}
			else
			{
				this.noteLabelField.interactable = true;
			}
			this.UpdateWithCloseButton();
		}
		else
		{
			this.noteInputField.gameObject.SetActive(false);
			this.noteLabelField.gameObject.SetActive(false);
			if (scroll.type == JournalScroll.noteContentTypes.picture)
			{
				this.itemNoteText.gameObject.SetActive(false);
				this.itemNoteImage.gameObject.SetActive(true);
			}
			else
			{
				this.itemNoteText.gameObject.SetActive(true);
				this.itemNoteImage.gameObject.SetActive(false);
				this.itemNoteText.text = scroll.note;
			}
			this.selectedScroll = scroll;
			this.closeNoteBtn.interactable = false;
			this.UpdateWithCloseButton();
		}
		this.coroutine = null;
		yield break;
	}

	// Token: 0x060011D3 RID: 4563 RVA: 0x0015D9E3 File Offset: 0x0015BBE3
	public void ClickedOpenNote()
	{
		if (this.removingNote)
		{
			return;
		}
		this.itemNoteText.text = "";
		if (this.selectedScroll != null)
		{
			Debug.Log("Save scroll");
			this.SaveSelectedScroll();
		}
		this.UpdateWithCloseButton();
	}

	// Token: 0x060011D4 RID: 4564 RVA: 0x0015DA24 File Offset: 0x0015BC24
	public void CloseNote()
	{
		if (this.removingNote)
		{
			return;
		}
		this.noteAnimator.Play("CloseMiddleScroll");
		this.itemNoteText.text = "";
		if (this.selectedScroll != null)
		{
			this.SaveSelectedScroll();
		}
		JournalScroll journalScroll = this.selectedScroll;
		this.selectedScroll = null;
		if (journalScroll)
		{
			journalScroll.SetImageColor();
		}
		this.closeNoteBtn.interactable = false;
		this.UpdateWithCloseButton();
		this.UpdateDockNote();
	}

	// Token: 0x060011D5 RID: 4565 RVA: 0x0015DAA4 File Offset: 0x0015BCA4
	public void EndRemoveNoteMode()
	{
		this.removingNote = false;
		Records.x.RemoveCloseButtonMenu(this.closeButton);
		for (int i = 0; i < this.removingButtonsOff.Count; i++)
		{
			this.removingButtonsOff[i].interactable = true;
		}
		for (int j = 0; j < this.removingButtonsOn.Count; j++)
		{
			this.removingButtonsOn[j].interactable = false;
		}
		this.noteInputField.interactable = true;
		this.noteLabelField.interactable = true;
	}

	// Token: 0x060011D6 RID: 4566 RVA: 0x0015DB30 File Offset: 0x0015BD30
	public void RemoveNote()
	{
		if (this.playerNotes.IndexOf(this.selectedScroll) == 0)
		{
			this.removeScrollMenu.SetActive(true);
			this.removeNoteText.text = "Cannot remove 'Conversation Notes' scroll";
			this.removeScrollMenuBtnText.text = "Return";
			this.selectedScroll = null;
			return;
		}
		if (this.selectedScroll && this.selectedScroll.userCreated)
		{
			this.removeScrollMenu.SetActive(true);
			if (this.selectedScroll.label != "")
			{
				this.removeNoteText.text = "Delete '" + this.selectedScroll.label + "' scroll?";
			}
			else
			{
				this.removeNoteText.text = "Delete empty scroll?";
			}
			if (this.playerNotes.Count == 0 && this.itemNotes.Count > 0)
			{
				this.UpdateButtonNavs(this.itemNotes[0]);
			}
			this.removeScrollMenuBtnText.text = "Yes, remove scroll";
		}
	}

	// Token: 0x060011D7 RID: 4567 RVA: 0x0015DC3C File Offset: 0x0015BE3C
	public void RemoveNoteConfirmed()
	{
		if (this.selectedScroll)
		{
			if (this.selectedScroll.userCreated)
			{
				int num = this.playerNotes.IndexOf(this.selectedScroll);
				this.playerNotes.RemoveAt(num);
				this.playerScrolls.RemoveAt(num);
				this.playerScrollIDs.RemoveAt(num);
				this.playerScrollLabels.RemoveAt(num);
				if (Links.x.joy)
				{
					this.UpdateScrollNav(true, null, true);
				}
			}
			else
			{
				int num2 = this.itemNotes.IndexOf(this.selectedScroll);
				this.itemScrollInventory.RemoveAt(num2);
				this.itemScrollIDs.RemoveAt(num2);
				if (Links.x.joy)
				{
					this.UpdateScrollNav(false, null, true);
				}
			}
			Object.Destroy(this.selectedScroll.gameObject);
			this.CloseNote();
			if (this.playerNotes.Count > 0)
			{
				this.UpdateButtonNavs(this.playerNotes[this.playerNotes.Count - 1]);
			}
		}
		this.CloseRemoveScrollMenu();
		EventSystem.current.SetSelectedGameObject(this.addNoteBtn.gameObject);
	}

	// Token: 0x060011D8 RID: 4568 RVA: 0x0015DD5B File Offset: 0x0015BF5B
	public void CloseRemoveScrollMenu()
	{
		this.removeScrollMenu.SetActive(false);
	}

	// Token: 0x060011D9 RID: 4569 RVA: 0x0015DD69 File Offset: 0x0015BF69
	public void StartScrollHover(JournalScroll scroll)
	{
	}

	// Token: 0x060011DA RID: 4570 RVA: 0x0015DD6B File Offset: 0x0015BF6B
	public void EndScrollHover(JournalScroll scroll)
	{
	}

	// Token: 0x060011DB RID: 4571 RVA: 0x0015DD70 File Offset: 0x0015BF70
	public JournalScroll GetClosestDragging(bool userCreated, Transform tr)
	{
		float num = float.PositiveInfinity;
		int num2 = -1;
		JournalScroll journalScroll = null;
		Vector3 vector = Links.x.menuCamera.ScreenToWorldPoint(Input.mousePosition);
		if (userCreated)
		{
			for (int i = 0; i < this.playerNotes.Count; i++)
			{
				if (this.currentDraggingScroll != this.playerNotes[i])
				{
					float sqrMagnitude = (vector - this.playerNotes[i].tr.position).sqrMagnitude;
					if (sqrMagnitude < num)
					{
						num = sqrMagnitude;
						num2 = i;
					}
				}
			}
			if (num2 > -1)
			{
				journalScroll = this.playerNotes[num2];
			}
		}
		else
		{
			for (int j = 0; j < this.itemNotes.Count; j++)
			{
				if (this.currentDraggingScroll != this.itemNotes[j])
				{
					float sqrMagnitude2 = (vector - this.itemNotes[j].tr.position).sqrMagnitude;
					if (sqrMagnitude2 < num)
					{
						num = sqrMagnitude2;
						num2 = j;
					}
				}
			}
			if (num2 > -1)
			{
				journalScroll = this.itemNotes[num2];
			}
		}
		return journalScroll;
	}

	// Token: 0x060011DC RID: 4572 RVA: 0x0015DE98 File Offset: 0x0015C098
	public void PinToDock()
	{
		if (this.selectedScroll)
		{
			Links.x.itemPickupFX.gameObject.SetActive(true);
			Links.x.itemPickupFX.gameObject.GetComponent<HannahAnimator>().Play("Idle");
			Links.x.itemPickupFX.position = this.pinButton.transform.position;
			string text = this.noteInputField.text;
			Links.x.hudControl.PinToDock("Jrnl" + this.selectedScroll.uniqueID.ToString(), "", text);
			this.pinText.text = "Pinned";
		}
	}

	// Token: 0x060011DD RID: 4573 RVA: 0x0015DF54 File Offset: 0x0015C154
	public void UpdateDockNote()
	{
		if (Links.x.hudControl.savedNoteImage.Contains("Jrnl"))
		{
			int num;
			int.TryParse(Links.x.hudControl.savedNoteImage.Replace("Jrnl", ""), out num);
			if (num > -1 && num < this.itemScrollIDs.Count)
			{
				string text = this.playerNotes[num].note;
				if (this.selectedScroll == this.playerNotes[num])
				{
					text = this.noteInputField.text;
				}
				if (text != "")
				{
					Links.x.hudControl.PinToDock("Jrnl" + num.ToString(), "", text);
				}
			}
		}
	}

	// Token: 0x060011DE RID: 4574 RVA: 0x0015E024 File Offset: 0x0015C224
	private void Update()
	{
		if (this.open)
		{
			if (this.dragging && this.currentDraggingScroll && Input.GetMouseButtonUp(0))
			{
				this.currentDraggingScroll.OnPointerUp();
				this.dragging = false;
			}
			if (Links.x.joy)
			{
				if (this.removingNote && Links.x.gameplay.cancelStart)
				{
					this.EndRemoveNoteMode();
				}
				GameObject currentSelectedGameObject = EventSystem.current.currentSelectedGameObject;
				bool flag = false;
				if (currentSelectedGameObject == null)
				{
					Links.x.gameplay.SetInteractableSelected(EventSystem.current, this.playerNotes[0].gameObject);
					flag = true;
				}
				if (!flag)
				{
					if (currentSelectedGameObject.transform.parent != this.contentPanel.transform)
					{
						flag = true;
					}
					if (!flag)
					{
						if (currentSelectedGameObject.name.Contains("Player Scroll"))
						{
							Links.x.hudControl.JoyBounds(currentSelectedGameObject.GetComponent<UITriggerButton>().rt, currentSelectedGameObject.GetComponent<UITriggerButton>().boxOffset, false);
						}
						if (currentSelectedGameObject == this.lastSelected)
						{
							flag = true;
						}
						if (!flag)
						{
							if (currentSelectedGameObject.GetComponent<JournalScroll>().userCreated)
							{
								this.selectedRectTransform = currentSelectedGameObject.GetComponent<RectTransform>();
								float num = Mathf.Abs(this.selectedRectTransform.anchoredPosition.y) + this.selectedRectTransform.rect.height;
								float y = this.contentPanel.anchoredPosition.y;
								float num2 = this.contentPanel.anchoredPosition.y + this.scrollRectTransform.rect.height;
								if (num > num2)
								{
									float num3 = num - this.scrollRectTransform.rect.height;
									this.contentPanel.anchoredPosition = new Vector2(this.contentPanel.anchoredPosition.x, num3);
								}
								else if (Mathf.Abs(this.selectedRectTransform.anchoredPosition.y) < y)
								{
									this.contentPanel.anchoredPosition = new Vector2(this.contentPanel.anchoredPosition.x, Mathf.Abs(this.selectedRectTransform.anchoredPosition.y + 60f));
								}
								this.lastSelected = currentSelectedGameObject;
								return;
							}
							this.selectedRectTransform = currentSelectedGameObject.GetComponent<RectTransform>();
							float num4 = Mathf.Abs(this.selectedRectTransform.anchoredPosition.y) + this.selectedRectTransform.rect.height;
							float y2 = this.contentPanel2.anchoredPosition.y;
							float num5 = this.contentPanel2.anchoredPosition.y + this.scrollRectTransform2.rect.height;
							if (num4 > num5)
							{
								float num6 = num4 - this.scrollRectTransform2.rect.height;
								this.contentPanel2.anchoredPosition = new Vector2(this.contentPanel2.anchoredPosition.x, num6);
							}
							else if (Mathf.Abs(this.selectedRectTransform.anchoredPosition.y) < y2)
							{
								this.contentPanel2.anchoredPosition = new Vector2(this.contentPanel2.anchoredPosition.x, Mathf.Abs(this.selectedRectTransform.anchoredPosition.y + 60f));
							}
							this.lastSelected = currentSelectedGameObject;
						}
					}
				}
			}
		}
	}

	// Token: 0x060011DF RID: 4575 RVA: 0x0015E379 File Offset: 0x0015C579
	public void UpdateDialogueNote()
	{
		if (this.playerNotes.Count > 0)
		{
			this.playerNotes[0].note = Links.x.dialogue.journalNoteField.text;
		}
	}

	// Token: 0x060011E0 RID: 4576 RVA: 0x0015E3B0 File Offset: 0x0015C5B0
	public string GetDialogueNoteText()
	{
		if (this.playerNotes.Count == 0)
		{
			this.AddNote("", "Conversation Notes", Random.Range(0, 6), true, "", "Scroll", -1, -1);
		}
		if (this.playerNotes.Count > 0)
		{
			return this.playerNotes[0].note;
		}
		return "";
	}

	// Token: 0x060011E1 RID: 4577 RVA: 0x0015E414 File Offset: 0x0015C614
	public void StartTyping()
	{
		Records.x.SetTypingState(true);
		if (Links.x.joy)
		{
			Debug.Log(this.lastNote.label);
			if (this.lastNote.label == "Conversation Notes")
			{
				Links.x.keyboardScript.StartMenu(this.noteInputField, null, base.gameObject, "JournalInput");
				this.inputFieldBorderTitle.color = new Color(0f, 0f, 0f, 0f);
				this.inputFieldBorderNote.color = new Color(0f, 0f, 0f, 0.5f);
			}
			else
			{
				Links.x.keyboardScript.StartMenu(this.noteLabelField, null, base.gameObject, "JournalLabel");
				this.inputFieldBorderNote.color = new Color(0f, 0f, 0f, 0f);
				this.inputFieldBorderTitle.color = new Color(0f, 0f, 0f, 0.5f);
			}
			this.canvasGroup.interactable = false;
			if (Links.x.joy)
			{
				this.closeText.SetActive(false);
			}
		}
	}

	// Token: 0x060011E2 RID: 4578 RVA: 0x0015E55C File Offset: 0x0015C75C
	public void EndTypingLabel()
	{
		if (Links.x.mk)
		{
			EventSystem.current.SetSelectedGameObject(this.noteInputField.gameObject);
			return;
		}
		Links.x.keyboardScript.StartMenu(this.noteInputField, null, base.gameObject, "JournalInput");
		this.inputFieldBorderTitle.color = new Color(0f, 0f, 0f, 0f);
		this.inputFieldBorderNote.color = new Color(0f, 0f, 0f, 0.5f);
	}

	// Token: 0x060011E3 RID: 4579 RVA: 0x0015E5F4 File Offset: 0x0015C7F4
	public void EndTypingField()
	{
		if (Links.x.joy)
		{
			this.ReturnLastNoteOpened();
			this.canvasGroup.interactable = true;
			if (this.selectedScroll)
			{
				EventSystem.current.SetSelectedGameObject(this.selectedScroll.gameObject);
			}
			else
			{
				EventSystem.current.SetSelectedGameObject(this.addNoteBtn.gameObject);
			}
		}
		this.inputFieldBorderTitle.color = new Color(0f, 0f, 0f, 0f);
		this.inputFieldBorderNote.color = new Color(0f, 0f, 0f, 0f);
		this.EndTyping();
	}

	// Token: 0x060011E4 RID: 4580 RVA: 0x0015E6A6 File Offset: 0x0015C8A6
	public void EndTyping()
	{
		Records.x.SetTypingState(false);
		if (this.selectedScroll != null)
		{
			this.SaveSelectedScroll();
		}
		if (Links.x.joy)
		{
			this.closeText.SetActive(true);
		}
	}

	// Token: 0x060011E5 RID: 4581 RVA: 0x0015E6E0 File Offset: 0x0015C8E0
	public void StartEndMenu(bool fromCloseButton)
	{
		Records.x.RemoveMenu(base.gameObject);
		if (fromCloseButton)
		{
			Links.x.gameplay.CloseDock();
		}
		this.CloseNote();
		bool flag = false;
		if (Links.x.joy && (Links.x.gameplay.dockStart || Links.x.gameplay.itemsStart))
		{
			flag = true;
		}
		if (flag)
		{
			this.anim.Play("Close", 0, 1f);
		}
		else
		{
			this.anim.Play("Close");
		}
		Links.x.hudControl.JoyBox(false);
		this.UpdateDockNote();
	}

	// Token: 0x060011E6 RID: 4582 RVA: 0x0015E788 File Offset: 0x0015C988
	public void CloseMenu()
	{
		this.canvas.enabled = false;
		this.open = false;
		this.contents1.SetActive(false);
		this.contents2.SetActive(false);
		this.anim.enabled = false;
	}

	// Token: 0x04001D5C RID: 7516
	[Header("INFO")]
	public bool open;

	// Token: 0x04001D5D RID: 7517
	public Canvas canvas;

	// Token: 0x04001D5E RID: 7518
	public Animator anim;

	// Token: 0x04001D5F RID: 7519
	public Animator noteAnimator;

	// Token: 0x04001D60 RID: 7520
	public GameObject contents1;

	// Token: 0x04001D61 RID: 7521
	public GameObject contents2;

	// Token: 0x04001D62 RID: 7522
	public GameObject middle;

	// Token: 0x04001D63 RID: 7523
	public List<GameObject> scrollsVariationsLeft = new List<GameObject>();

	// Token: 0x04001D64 RID: 7524
	public List<GameObject> scrollsVariationsRight = new List<GameObject>();

	// Token: 0x04001D65 RID: 7525
	public GameObject removeScrollMenu;

	// Token: 0x04001D66 RID: 7526
	public TMP_InputField noteInputField;

	// Token: 0x04001D67 RID: 7527
	public TMP_InputField noteLabelField;

	// Token: 0x04001D68 RID: 7528
	public TextMeshProUGUI itemNoteText;

	// Token: 0x04001D69 RID: 7529
	public TextMeshProUGUI removeScrollMenuBtnText;

	// Token: 0x04001D6A RID: 7530
	public TextMeshProUGUI pinText;

	// Token: 0x04001D6B RID: 7531
	public Image itemNoteImage;

	// Token: 0x04001D6C RID: 7532
	public TextMeshProUGUI removeNoteText;

	// Token: 0x04001D6D RID: 7533
	public ScrollRectNoDragging scrollRectLeft;

	// Token: 0x04001D6E RID: 7534
	public ScrollRectNoDragging scrollRectRight;

	// Token: 0x04001D6F RID: 7535
	public RectTransform scrollRectTransform;

	// Token: 0x04001D70 RID: 7536
	public RectTransform contentPanel;

	// Token: 0x04001D71 RID: 7537
	public RectTransform scrollRectTransform2;

	// Token: 0x04001D72 RID: 7538
	public RectTransform contentPanel2;

	// Token: 0x04001D73 RID: 7539
	public RectTransform selectedRectTransform;

	// Token: 0x04001D74 RID: 7540
	public GameObject lastSelected;

	// Token: 0x04001D75 RID: 7541
	public GameObject closeText;

	// Token: 0x04001D76 RID: 7542
	public Button addNoteBtn;

	// Token: 0x04001D77 RID: 7543
	public Button closeNoteBtn;

	// Token: 0x04001D78 RID: 7544
	public CanvasGroup canvasGroup;

	// Token: 0x04001D79 RID: 7545
	public GameObject pavuraNote;

	// Token: 0x04001D7A RID: 7546
	public Image inputFieldBorderTitle;

	// Token: 0x04001D7B RID: 7547
	public Image inputFieldBorderNote;

	// Token: 0x04001D7C RID: 7548
	public GameObject pinButton;

	// Token: 0x04001D7D RID: 7549
	public int noteCount;

	// Token: 0x04001D7E RID: 7550
	[Header("SAVING")]
	public List<JournalScroll> playerNotes = new List<JournalScroll>();

	// Token: 0x04001D7F RID: 7551
	public List<JournalScroll> itemNotes = new List<JournalScroll>();

	// Token: 0x04001D80 RID: 7552
	private List<string> playerScrolls = new List<string>();

	// Token: 0x04001D81 RID: 7553
	private List<string> playerScrollLabels = new List<string>();

	// Token: 0x04001D82 RID: 7554
	private List<int> playerScrollIDs = new List<int>();

	// Token: 0x04001D83 RID: 7555
	private List<string> itemScrollInventory = new List<string>();

	// Token: 0x04001D84 RID: 7556
	private List<int> itemScrollIDs = new List<int>();

	// Token: 0x04001D85 RID: 7557
	[Header("DRAGGING")]
	public JournalScroll currentDragOverScroll;

	// Token: 0x04001D86 RID: 7558
	public JournalScroll currentDraggingScroll;

	// Token: 0x04001D87 RID: 7559
	public JournalScroll selectedScroll;

	// Token: 0x04001D88 RID: 7560
	public JournalScroll lastNote;

	// Token: 0x04001D89 RID: 7561
	public bool dragging;

	// Token: 0x04001D8A RID: 7562
	public Transform rightScrollParent;

	// Token: 0x04001D8B RID: 7563
	public Transform leftScrollParent;

	// Token: 0x04001D8C RID: 7564
	[Header("CONTROLLER")]
	public bool removingNote;

	// Token: 0x04001D8D RID: 7565
	public UITriggerButton closeButton;

	// Token: 0x04001D8E RID: 7566
	public List<Button> removingButtonsOn = new List<Button>();

	// Token: 0x04001D8F RID: 7567
	public List<Button> removingButtonsOff = new List<Button>();

	// Token: 0x04001D90 RID: 7568
	private ES3File saveFile;

	// Token: 0x04001D91 RID: 7569
	private IEnumerator coroutine;
}
