| | 1 | | using UnityEngine; |
| | 2 | | using UnityEngine.UI; |
| | 3 | |
|
| | 4 | | public class FriendRequestEntry : FriendEntryBase |
| | 5 | | { |
| | 6 | | [SerializeField] internal Button acceptButton; |
| | 7 | | [SerializeField] internal Button rejectButton; |
| | 8 | | [SerializeField] internal Button cancelButton; |
| | 9 | |
|
| 0 | 10 | | public bool isReceived { get; private set; } |
| | 11 | |
|
| | 12 | | public event System.Action<FriendRequestEntry> OnAccepted; |
| | 13 | | public event System.Action<FriendRequestEntry> OnRejected; |
| | 14 | | public event System.Action<FriendRequestEntry> OnCancelled; |
| | 15 | |
|
| | 16 | | public override void Awake() |
| | 17 | | { |
| 35 | 18 | | base.Awake(); |
| | 19 | |
|
| 36 | 20 | | acceptButton.onClick.AddListener(() => OnAccepted?.Invoke(this)); |
| 38 | 21 | | rejectButton.onClick.AddListener(() => OnRejected?.Invoke(this)); |
| 38 | 22 | | cancelButton.onClick.AddListener(() => OnCancelled?.Invoke(this)); |
| 35 | 23 | | } |
| | 24 | |
|
| | 25 | | public void SetReceived(bool value) |
| | 26 | | { |
| 14 | 27 | | isReceived = value; |
| | 28 | |
|
| 14 | 29 | | if (isReceived) |
| 9 | 30 | | PopulateReceived(); |
| | 31 | | else |
| 5 | 32 | | PopulateSent(); |
| 5 | 33 | | } |
| | 34 | |
|
| | 35 | | void PopulateReceived() |
| | 36 | | { |
| 9 | 37 | | isReceived = true; |
| 9 | 38 | | cancelButton.gameObject.SetActive(false); |
| 9 | 39 | | acceptButton.gameObject.SetActive(true); |
| 9 | 40 | | rejectButton.gameObject.SetActive(true); |
| 9 | 41 | | } |
| | 42 | |
|
| | 43 | | void PopulateSent() |
| | 44 | | { |
| 5 | 45 | | isReceived = false; |
| 5 | 46 | | cancelButton.gameObject.SetActive(true); |
| 5 | 47 | | acceptButton.gameObject.SetActive(false); |
| 5 | 48 | | rejectButton.gameObject.SetActive(false); |
| 5 | 49 | | } |
| | 50 | | } |