| | 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 | |
|
| 35 | 20 | | acceptButton.onClick.RemoveAllListeners(); |
| 35 | 21 | | rejectButton.onClick.RemoveAllListeners(); |
| 35 | 22 | | cancelButton.onClick.RemoveAllListeners(); |
| 36 | 23 | | acceptButton.onClick.AddListener(() => OnAccepted?.Invoke(this)); |
| 38 | 24 | | rejectButton.onClick.AddListener(() => OnRejected?.Invoke(this)); |
| 38 | 25 | | cancelButton.onClick.AddListener(() => OnCancelled?.Invoke(this)); |
| 35 | 26 | | } |
| | 27 | |
|
| | 28 | | public void SetReceived(bool value) |
| | 29 | | { |
| 14 | 30 | | isReceived = value; |
| | 31 | |
|
| 14 | 32 | | if (isReceived) |
| 9 | 33 | | PopulateReceived(); |
| | 34 | | else |
| 5 | 35 | | PopulateSent(); |
| 5 | 36 | | } |
| | 37 | |
|
| | 38 | | void PopulateReceived() |
| | 39 | | { |
| 9 | 40 | | isReceived = true; |
| 9 | 41 | | cancelButton.gameObject.SetActive(false); |
| 9 | 42 | | acceptButton.gameObject.SetActive(true); |
| 9 | 43 | | rejectButton.gameObject.SetActive(true); |
| 9 | 44 | | } |
| | 45 | |
|
| | 46 | | void PopulateSent() |
| | 47 | | { |
| 5 | 48 | | isReceived = false; |
| 5 | 49 | | cancelButton.gameObject.SetActive(true); |
| 5 | 50 | | acceptButton.gameObject.SetActive(false); |
| 5 | 51 | | rejectButton.gameObject.SetActive(false); |
| 5 | 52 | | } |
| | 53 | | } |