350 lines
8.9 KiB
C#
350 lines
8.9 KiB
C#
using System;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
// Token: 0x020000BC RID: 188
|
|
public class JournalScroll : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IPointerDownHandler
|
|
{
|
|
// Token: 0x060011E8 RID: 4584 RVA: 0x0015E850 File Offset: 0x0015CA50
|
|
private void Awake()
|
|
{
|
|
this.tr = base.transform;
|
|
this.timer2 = -1f;
|
|
this.img = base.gameObject.GetComponent<Image>();
|
|
this.button = base.gameObject.GetComponent<Button>();
|
|
this.scrollImg = base.gameObject.transform.GetChild(0).gameObject.GetComponent<Image>();
|
|
this.maskImg = base.gameObject.transform.GetChild(2).gameObject.GetComponent<Image>();
|
|
this.btn = base.gameObject.GetComponent<Button>();
|
|
this.dragImg = base.gameObject.transform.GetChild(3).gameObject.GetComponent<Image>();
|
|
this.dragImg.enabled = false;
|
|
}
|
|
|
|
// Token: 0x060011E9 RID: 4585 RVA: 0x0015E918 File Offset: 0x0015CB18
|
|
private void OnDisable()
|
|
{
|
|
if (this.dragging)
|
|
{
|
|
this.dragging = false;
|
|
if (Links.x.journal.currentDragOverScroll != null)
|
|
{
|
|
Links.x.journal.currentDragOverScroll.dragImg.enabled = false;
|
|
}
|
|
Links.x.journal.scrollRectLeft.enabled = true;
|
|
Links.x.journal.scrollRectRight.enabled = true;
|
|
}
|
|
this.img.raycastTarget = true;
|
|
this.timer2 = -1f;
|
|
this.btn.interactable = true;
|
|
this.hovering = false;
|
|
this.dragImg.enabled = false;
|
|
}
|
|
|
|
// Token: 0x060011EA RID: 4586 RVA: 0x0015E9C5 File Offset: 0x0015CBC5
|
|
private void Start()
|
|
{
|
|
this.dragImg.enabled = false;
|
|
this.SetImageColor();
|
|
}
|
|
|
|
// Token: 0x060011EB RID: 4587 RVA: 0x0015E9D9 File Offset: 0x0015CBD9
|
|
public void OnPointerEnter(PointerEventData eventData)
|
|
{
|
|
if (Links.x.journal.dragging)
|
|
{
|
|
return;
|
|
}
|
|
if (!this.dragging)
|
|
{
|
|
Links.x.journal.StartScrollHover(this);
|
|
}
|
|
this.hovering = true;
|
|
this.SetImageColor();
|
|
}
|
|
|
|
// Token: 0x060011EC RID: 4588 RVA: 0x0015EA12 File Offset: 0x0015CC12
|
|
public void OnPointerExit(PointerEventData eventData)
|
|
{
|
|
Links.x.journal.EndScrollHover(this);
|
|
this.hovering = false;
|
|
this.SetImageColor();
|
|
}
|
|
|
|
// Token: 0x060011ED RID: 4589 RVA: 0x0015EA34 File Offset: 0x0015CC34
|
|
public void OnPointerDown(PointerEventData eventData)
|
|
{
|
|
if (!Links.x.journal.dragging)
|
|
{
|
|
this.timer2 = Time.realtimeSinceStartup;
|
|
this.img.raycastTarget = true;
|
|
this.btn.interactable = true;
|
|
this.startDragPosition = this.tr.position;
|
|
this.offset = this.tr.position - Links.x.menuCamera.ScreenToWorldPoint(Input.mousePosition);
|
|
this.offset.z = 100f;
|
|
}
|
|
}
|
|
|
|
// Token: 0x060011EE RID: 4590 RVA: 0x0015EAC0 File Offset: 0x0015CCC0
|
|
public void PointerUpFromTrigger()
|
|
{
|
|
if (!this.dragging)
|
|
{
|
|
if (this.userCreated && Links.x.journal.selectedScroll != this)
|
|
{
|
|
Links.x.journal.UpdateLastNoteOpened(this);
|
|
}
|
|
this.OnPointerUp();
|
|
this.timer2 = -1f;
|
|
}
|
|
}
|
|
|
|
// Token: 0x060011EF RID: 4591 RVA: 0x0015EB18 File Offset: 0x0015CD18
|
|
public void OnPointerUp()
|
|
{
|
|
if (this.dragging)
|
|
{
|
|
if (this.userCreated)
|
|
{
|
|
this.tr.SetParent(Links.x.journal.leftScrollParent);
|
|
}
|
|
else
|
|
{
|
|
this.tr.SetParent(Links.x.journal.rightScrollParent);
|
|
}
|
|
if (Links.x.journal.currentDragOverScroll != null)
|
|
{
|
|
int siblingIndex = Links.x.journal.currentDragOverScroll.tr.GetSiblingIndex();
|
|
this.tr.SetSiblingIndex(siblingIndex + 1);
|
|
Links.x.journal.currentDragOverScroll.dragImg.enabled = false;
|
|
}
|
|
if (this.empty)
|
|
{
|
|
Object.Destroy(this.empty);
|
|
}
|
|
Links.x.journal.currentDragOverScroll = null;
|
|
}
|
|
else if (Links.x.journal.selectedScroll == this)
|
|
{
|
|
if (Links.x.mk)
|
|
{
|
|
Links.x.journal.CloseNote();
|
|
}
|
|
else
|
|
{
|
|
Links.x.journal.ClickedOpenNote();
|
|
Links.x.journal.OpenNote(this);
|
|
Links.x.journal.UpdateLastNoteOpened(this);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Links.x.journal.OpenNote(this);
|
|
}
|
|
this.tr.localPosition = new Vector3(this.tr.localPosition.x, this.tr.localPosition.y, 0f);
|
|
Links.x.journal.currentDraggingScroll = null;
|
|
Links.x.journal.dragging = false;
|
|
if (Links.x.journal.currentDragOverScroll != null)
|
|
{
|
|
Links.x.journal.currentDragOverScroll.dragImg.enabled = false;
|
|
}
|
|
this.img.raycastTarget = true;
|
|
this.btn.interactable = true;
|
|
this.dragging = false;
|
|
Links.x.journal.scrollRectLeft.enabled = true;
|
|
Links.x.journal.scrollRectRight.enabled = true;
|
|
this.SetImageColor();
|
|
this.timer2 = -1f;
|
|
}
|
|
|
|
// Token: 0x060011F0 RID: 4592 RVA: 0x0015ED48 File Offset: 0x0015CF48
|
|
public void SetImageColor()
|
|
{
|
|
if (this == Links.x.journal.selectedScroll || this.dragging)
|
|
{
|
|
if (this.dragging)
|
|
{
|
|
this.scrollImg.color = Color.white;
|
|
this.maskImg.color = this.scrollImg.color;
|
|
this.scrollImg.material = this.hoverMaterial;
|
|
this.maskImg.material = this.scrollImg.material;
|
|
return;
|
|
}
|
|
if (this.hovering)
|
|
{
|
|
this.scrollImg.color = Color.white;
|
|
this.maskImg.color = this.scrollImg.color;
|
|
this.scrollImg.material = this.hoverMaterial;
|
|
this.maskImg.material = this.scrollImg.material;
|
|
return;
|
|
}
|
|
this.scrollImg.color = Color.white;
|
|
this.maskImg.color = this.scrollImg.color;
|
|
this.scrollImg.material = this.normalMaterial;
|
|
this.maskImg.material = this.scrollImg.material;
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
if (this.hovering)
|
|
{
|
|
this.scrollImg.color = Color.white;
|
|
this.maskImg.color = this.scrollImg.color;
|
|
this.scrollImg.material = this.hoverMaterial;
|
|
this.maskImg.material = this.scrollImg.material;
|
|
return;
|
|
}
|
|
this.scrollImg.color = new Color(0.7f, 0.7f, 0.7f, 1f);
|
|
this.maskImg.color = this.scrollImg.color;
|
|
this.scrollImg.material = this.normalMaterial;
|
|
this.maskImg.material = this.scrollImg.material;
|
|
return;
|
|
}
|
|
}
|
|
|
|
// Token: 0x060011F1 RID: 4593 RVA: 0x0015EF28 File Offset: 0x0015D128
|
|
private void Update()
|
|
{
|
|
if (Links.x.joy)
|
|
{
|
|
if (base.gameObject == Links.x.gameplay.currentEventObject)
|
|
{
|
|
if (!this.hovering)
|
|
{
|
|
this.OnPointerEnter(null);
|
|
}
|
|
}
|
|
else if (this.hovering)
|
|
{
|
|
this.OnPointerExit(null);
|
|
}
|
|
}
|
|
if (this.dragging || this.timer2 > -1f)
|
|
{
|
|
if (Input.GetMouseButtonUp(0) && !this.dragging)
|
|
{
|
|
this.OnPointerUp();
|
|
this.timer2 = -1f;
|
|
}
|
|
else
|
|
{
|
|
if (Links.x.journal.dragging)
|
|
{
|
|
this.tr.position = Links.x.menuCamera.ScreenToWorldPoint(Input.mousePosition) + this.offset;
|
|
}
|
|
if (Time.realtimeSinceStartup > this.timer2 + 0.3f && !Links.x.journal.dragging && this.timer2 > -1f)
|
|
{
|
|
this.tr.SetParent(Links.x.journal.contents2.transform);
|
|
Links.x.journal.currentDraggingScroll = this;
|
|
Links.x.journal.dragging = true;
|
|
this.dragging = true;
|
|
Links.x.journal.scrollRectLeft.enabled = false;
|
|
Links.x.journal.scrollRectRight.enabled = false;
|
|
this.SetImageColor();
|
|
this.timer2 = -1f;
|
|
this.img.raycastTarget = false;
|
|
Links.x.journal.EndScrollHover(this);
|
|
this.btn.interactable = false;
|
|
this.tr.position = Links.x.menuCamera.ScreenToWorldPoint(Input.mousePosition) + this.offset;
|
|
}
|
|
}
|
|
if (this.dragging)
|
|
{
|
|
JournalScroll currentDragOverScroll = Links.x.journal.currentDragOverScroll;
|
|
Links.x.journal.currentDragOverScroll = Links.x.journal.GetClosestDragging(this.userCreated, this.tr);
|
|
if (Links.x.journal.currentDragOverScroll)
|
|
{
|
|
Links.x.journal.currentDragOverScroll.dragImg.enabled = true;
|
|
}
|
|
if (currentDragOverScroll && currentDragOverScroll != Links.x.journal.currentDragOverScroll)
|
|
{
|
|
currentDragOverScroll.dragImg.enabled = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Token: 0x04001D92 RID: 7570
|
|
[Header("Info")]
|
|
public int ID;
|
|
|
|
// Token: 0x04001D93 RID: 7571
|
|
public int uniqueID;
|
|
|
|
// Token: 0x04001D94 RID: 7572
|
|
public string note;
|
|
|
|
// Token: 0x04001D95 RID: 7573
|
|
public string label;
|
|
|
|
// Token: 0x04001D96 RID: 7574
|
|
public bool userCreated;
|
|
|
|
// Token: 0x04001D97 RID: 7575
|
|
public string inventoryName;
|
|
|
|
// Token: 0x04001D98 RID: 7576
|
|
public TextMeshProUGUI textLabel;
|
|
|
|
// Token: 0x04001D99 RID: 7577
|
|
public JournalScroll.noteContentTypes type;
|
|
|
|
// Token: 0x04001D9A RID: 7578
|
|
public bool hovering;
|
|
|
|
// Token: 0x04001D9B RID: 7579
|
|
public Material normalMaterial;
|
|
|
|
// Token: 0x04001D9C RID: 7580
|
|
public Material hoverMaterial;
|
|
|
|
// Token: 0x04001D9D RID: 7581
|
|
public Button button;
|
|
|
|
// Token: 0x04001D9E RID: 7582
|
|
[Header("Dragging")]
|
|
public bool dragging;
|
|
|
|
// Token: 0x04001D9F RID: 7583
|
|
private float timer2;
|
|
|
|
// Token: 0x04001DA0 RID: 7584
|
|
private Vector3 startDragPosition;
|
|
|
|
// Token: 0x04001DA1 RID: 7585
|
|
public Transform tr;
|
|
|
|
// Token: 0x04001DA2 RID: 7586
|
|
private Vector3 offset;
|
|
|
|
// Token: 0x04001DA3 RID: 7587
|
|
public float threshhold = 0.05f;
|
|
|
|
// Token: 0x04001DA4 RID: 7588
|
|
private Image img;
|
|
|
|
// Token: 0x04001DA5 RID: 7589
|
|
private Image scrollImg;
|
|
|
|
// Token: 0x04001DA6 RID: 7590
|
|
private Image maskImg;
|
|
|
|
// Token: 0x04001DA7 RID: 7591
|
|
private Image dragImg;
|
|
|
|
// Token: 0x04001DA8 RID: 7592
|
|
private Button btn;
|
|
|
|
// Token: 0x04001DA9 RID: 7593
|
|
private GameObject empty;
|
|
|
|
// Token: 0x02000232 RID: 562
|
|
public enum noteContentTypes
|
|
{
|
|
// Token: 0x040033B6 RID: 13238
|
|
picture,
|
|
// Token: 0x040033B7 RID: 13239
|
|
text
|
|
}
|
|
}
|