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

// Token: 0x020000AA RID: 170
public class GameFeed : MonoBehaviour
{
	// Token: 0x06000F9F RID: 3999 RVA: 0x0012E96C File Offset: 0x0012CB6C
	private void Awake()
	{
		base.gameObject.SetActive(true);
		this.currIndex = -1;
		this.textList.text = "";
		this.textColor = "<color #" + ColorUtility.ToHtmlStringRGB(this.textList.color) + ">";
	}

	// Token: 0x06000FA0 RID: 4000 RVA: 0x0012E9C1 File Offset: 0x0012CBC1
	private void Start()
	{
		Links.x.gameFeed = this;
	}

	// Token: 0x06000FA1 RID: 4001 RVA: 0x0012E9D0 File Offset: 0x0012CBD0
	public void SetState(int gameFeedState)
	{
		if (gameFeedState == 0)
		{
			this.isOn = false;
			base.gameObject.transform.localScale = new Vector3(0f, 0f, 0f);
		}
		else
		{
			this.isOn = true;
			base.gameObject.transform.localScale = new Vector3(1f, 1f, 1f);
		}
		if (gameFeedState == 2)
		{
			Records.x.showRulesetInfo = true;
			return;
		}
		Records.x.showRulesetInfo = false;
	}

	// Token: 0x06000FA2 RID: 4002 RVA: 0x0012EA54 File Offset: 0x0012CC54
	public void ShowNotice(string notice)
	{
		if (this.corout != null)
		{
			base.StopCoroutine(this.corout);
			this.corout = null;
		}
		if (this.corout == null)
		{
			this.corout = this.Notice(notice);
			base.StartCoroutine(this.Notice(notice));
		}
		this.noticeTextShowing = true;
	}

	// Token: 0x06000FA3 RID: 4003 RVA: 0x0012EAA8 File Offset: 0x0012CCA8
	private bool Clicked()
	{
		return Input.GetMouseButtonDown(0) || (Links.x.joy && (Links.x.gameplay.cancelStart || Links.x.gameplay.actionStart || Links.x.gameplay.interactStart));
	}

	// Token: 0x06000FA4 RID: 4004 RVA: 0x0012EB01 File Offset: 0x0012CD01
	private IEnumerator Notice(string notice)
	{
		this.noticeFakeText.text = notice;
		this.contentFitter1.enabled = false;
		this.contentFitter2.enabled = false;
		this.horizGroup.enabled = false;
		this.noticeText.text = "";
		this.noticeText.enabled = true;
		this.noticeFakeText.enabled = true;
		this.noticeBackplate.enabled = true;
		this.noticeBackplate.color = new Color(0f, 0f, 0f, 0f);
		yield return new WaitForSecondsRealtime(0.0001f);
		this.contentFitter1.enabled = true;
		this.horizGroup.enabled = true;
		yield return new WaitForSecondsRealtime(0.0001f);
		this.contentFitter2.enabled = true;
		yield return new WaitForSecondsRealtime(0.0001f);
		this.noticeText.text = notice;
		this.noticeBackplate.color = new Color(1f, 1f, 1f, 1f);
		float timeToLerp = 3f;
		float percentage = 0f;
		float startTime = Time.realtimeSinceStartup;
		while (percentage < 1f && !this.Clicked())
		{
			percentage = (Time.realtimeSinceStartup - startTime) / timeToLerp;
			yield return null;
		}
		this.corout = null;
		this.noticeText.text = "";
		this.noticeText.enabled = false;
		this.noticeFakeText.enabled = false;
		this.noticeBackplate.enabled = false;
		this.noticeTextShowing = false;
		this.contentFitter1.enabled = false;
		this.contentFitter2.enabled = false;
		this.horizGroup.enabled = false;
		yield break;
	}

	// Token: 0x06000FA5 RID: 4005 RVA: 0x0012EB18 File Offset: 0x0012CD18
	public string GetPartyColorText(Character character)
	{
		int partyID = Links.x.GetPartyID(character);
		if (partyID > -1 && partyID < 4)
		{
			return Links.x.GetPartyColor(partyID);
		}
		return this.textColor;
	}

	// Token: 0x06000FA6 RID: 4006 RVA: 0x0012EB4C File Offset: 0x0012CD4C
	public void AddFeed(string txt)
	{
		if (this.entries > 60)
		{
			this.currFeed = "";
			this.str.Clear();
			int count = this.feedEntries.Count;
			this.entries = 0;
			for (int i = 0; i < count; i++)
			{
				if (i >= 10)
				{
					this.str.Append(this.feedEntries[i]);
					this.entries++;
				}
			}
			this.currFeed = this.str.ToString();
			for (int j = 0; j < 10; j++)
			{
				this.feedEntries.RemoveAt(0);
			}
		}
		this.entries++;
		this.str.Clear();
		this.str.Append("\n");
		this.str.Append(txt);
		string text = this.str.ToString();
		this.str.Clear();
		this.str.Append(this.currFeed);
		this.str.Append(text);
		this.feedEntries.Add(text);
		this.currFeed = this.str.ToString();
		this.textList.text = this.str.ToString();
		this.currFeed = this.textList.text;
	}

	// Token: 0x06000FA7 RID: 4007 RVA: 0x0012ECA4 File Offset: 0x0012CEA4
	public void ClearGameFeed()
	{
		this.textList.text = "";
	}

	// Token: 0x06000FA8 RID: 4008 RVA: 0x0012ECB6 File Offset: 0x0012CEB6
	public void ReturnGameFeed()
	{
		if (this.textList)
		{
			this.textList.text = this.currFeed;
		}
	}

	// Token: 0x06000FA9 RID: 4009 RVA: 0x0012ECD6 File Offset: 0x0012CED6
	public void ClearFeed()
	{
		this.textList.text = "";
		this.currFeed = "";
	}

	// Token: 0x040019D2 RID: 6610
	public int currIndex;

	// Token: 0x040019D3 RID: 6611
	public TextMeshProUGUI textList;

	// Token: 0x040019D4 RID: 6612
	public string currFeed;

	// Token: 0x040019D5 RID: 6613
	public int entries;

	// Token: 0x040019D6 RID: 6614
	private StringFast str = new StringFast(64);

	// Token: 0x040019D7 RID: 6615
	private List<string> feedEntries = new List<string>();

	// Token: 0x040019D8 RID: 6616
	private string textColor;

	// Token: 0x040019D9 RID: 6617
	public GameObject noticeObject;

	// Token: 0x040019DA RID: 6618
	public TextMeshProUGUI noticeText;

	// Token: 0x040019DB RID: 6619
	public TextMeshProUGUI noticeFakeText;

	// Token: 0x040019DC RID: 6620
	public Image noticeBackplate;

	// Token: 0x040019DD RID: 6621
	private IEnumerator corout;

	// Token: 0x040019DE RID: 6622
	public bool noticeTextShowing;

	// Token: 0x040019DF RID: 6623
	public ContentSizeFitter contentFitter1;

	// Token: 0x040019E0 RID: 6624
	public ContentSizeFitter contentFitter2;

	// Token: 0x040019E1 RID: 6625
	public HorizontalLayoutGroup horizGroup;

	// Token: 0x040019E2 RID: 6626
	public bool showNotice;

	// Token: 0x040019E3 RID: 6627
	public bool isOn;

	// Token: 0x040019E4 RID: 6628
	public GameObject scrollbar;

	// Token: 0x040019E5 RID: 6629
	public TextMeshProUGUI scrollControllerImg;

	// Token: 0x040019E6 RID: 6630
	public ScrollRect scrollRect;
}
