| | 1 | | using System; |
| | 2 | | using System.Collections; |
| | 3 | | using System.Collections.Generic; |
| | 4 | | using UnityEngine; |
| | 5 | | using UnityEngine.UI; |
| | 6 | | using UnityEngine.Events; |
| | 7 | | using DCL; |
| | 8 | | using DCL.Helpers; |
| | 9 | |
|
| | 10 | | namespace DCL.Social.Passports |
| | 11 | | { |
| | 12 | | public class PlayerPassportHUDView : BaseComponentView, IPlayerPassportHUDView |
| | 13 | | { |
| | 14 | | [SerializeField] private PassportPlayerInfoComponentView playerInfoView; |
| | 15 | | [SerializeField] private PassportPlayerPreviewComponentView playerPreviewView; |
| | 16 | | [SerializeField] private PassportNavigationComponentView passportNavigationView; |
| | 17 | | [SerializeField] internal Button hideCardButton; |
| | 18 | | [SerializeField] internal GameObject container; |
| | 19 | |
|
| 0 | 20 | | public IPassportPlayerInfoComponentView PlayerInfoView => playerInfoView; |
| 0 | 21 | | public IPassportPlayerPreviewComponentView PlayerPreviewView => playerPreviewView; |
| 0 | 22 | | public IPassportNavigationComponentView PassportNavigationView => passportNavigationView; |
| | 23 | | public event Action OnClose; |
| | 24 | |
|
| | 25 | | internal MouseCatcher mouseCatcher; |
| | 26 | |
|
| | 27 | | public static PlayerPassportHUDView CreateView() |
| | 28 | | { |
| 4 | 29 | | return Instantiate(Resources.Load<GameObject>("PlayerPassport")).GetComponent<PlayerPassportHUDView>(); |
| | 30 | | } |
| | 31 | |
|
| | 32 | | public void Initialize() |
| | 33 | | { |
| 4 | 34 | | hideCardButton?.onClick.RemoveAllListeners(); |
| 4 | 35 | | hideCardButton?.onClick.AddListener(ClosePassport); |
| 4 | 36 | | mouseCatcher = DCL.SceneReferences.i.mouseCatcher; |
| | 37 | |
|
| 4 | 38 | | if (mouseCatcher != null) |
| 0 | 39 | | mouseCatcher.OnMouseDown += ClosePassport; |
| 4 | 40 | | } |
| | 41 | |
|
| | 42 | | public void SetVisibility(bool visible) |
| | 43 | | { |
| 4 | 44 | | gameObject.SetActive(visible); |
| 4 | 45 | | } |
| | 46 | |
|
| | 47 | | public void SetPassportPanelVisibility(bool visible) |
| | 48 | | { |
| 2 | 49 | | if (visible && mouseCatcher != null) |
| | 50 | | { |
| 0 | 51 | | mouseCatcher.UnlockCursor(); |
| | 52 | | } |
| 2 | 53 | | container.SetActive(visible); |
| 2 | 54 | | CommonScriptableObjects.playerInfoCardVisibleState.Set(visible); |
| 2 | 55 | | } |
| | 56 | |
|
| | 57 | | public override void RefreshControl() |
| | 58 | | { |
| 0 | 59 | | } |
| | 60 | |
|
| | 61 | | public override void Dispose() |
| | 62 | | { |
| 8 | 63 | | if (mouseCatcher != null) |
| 0 | 64 | | mouseCatcher.OnMouseDown -= ClosePassport; |
| 8 | 65 | | } |
| | 66 | |
|
| | 67 | | private void ClosePassport() |
| | 68 | | { |
| 0 | 69 | | mouseCatcher.LockCursor(); |
| 0 | 70 | | OnClose?.Invoke(); |
| 0 | 71 | | } |
| | 72 | | } |
| | 73 | | } |