| | 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 | | private MouseCatcher mouseCatcher; |
| | 26 | |
|
| | 27 | | public static PlayerPassportHUDView CreateView() => |
| 0 | 28 | | Instantiate(Resources.Load<GameObject>("PlayerPassport")).GetComponent<PlayerPassportHUDView>(); |
| | 29 | |
|
| | 30 | | public void Initialize() |
| | 31 | | { |
| 0 | 32 | | hideCardButton.onClick.RemoveAllListeners(); |
| 0 | 33 | | hideCardButton.onClick.AddListener(ClosePassport); |
| 0 | 34 | | mouseCatcher = DCL.SceneReferences.i.mouseCatcher; |
| | 35 | |
|
| 0 | 36 | | if (mouseCatcher != null) |
| 0 | 37 | | mouseCatcher.OnMouseDown += ClosePassport; |
| 0 | 38 | | } |
| | 39 | |
|
| | 40 | | public void SetVisibility(bool visible) |
| | 41 | | { |
| 0 | 42 | | gameObject.SetActive(visible); |
| 0 | 43 | | } |
| | 44 | |
|
| | 45 | | public void SetPassportPanelVisibility(bool visible) |
| | 46 | | { |
| 0 | 47 | | if (visible && mouseCatcher != null) |
| | 48 | | { |
| 0 | 49 | | mouseCatcher.UnlockCursor(); |
| | 50 | | } |
| 0 | 51 | | container.SetActive(visible); |
| 0 | 52 | | CommonScriptableObjects.playerInfoCardVisibleState.Set(visible); |
| 0 | 53 | | } |
| | 54 | |
|
| | 55 | | public override void RefreshControl() |
| | 56 | | { |
| 0 | 57 | | } |
| | 58 | |
|
| | 59 | | public override void Dispose() |
| | 60 | | { |
| 0 | 61 | | if (mouseCatcher != null) |
| 0 | 62 | | mouseCatcher.OnMouseDown -= ClosePassport; |
| 0 | 63 | | } |
| | 64 | |
|
| | 65 | | private void ClosePassport() |
| | 66 | | { |
| 0 | 67 | | mouseCatcher.LockCursor(); |
| 0 | 68 | | OnClose?.Invoke(); |
| 0 | 69 | | } |
| | 70 | | } |
| | 71 | | } |