| | 1 | | using MainScripts.DCL.Controllers.HUD.CharacterPreview; |
| | 2 | | using System; |
| | 3 | | using UIComponents.Scripts.Components; |
| | 4 | | using UnityEngine; |
| | 5 | | using UnityEngine.UI; |
| | 6 | |
|
| | 7 | | namespace DCL.Social.Passports |
| | 8 | | { |
| | 9 | | public class PassportPlayerPreviewComponentView : BaseComponentView<PassportPlayerPreviewModel>, IPassportPlayerPrev |
| | 10 | | { |
| | 11 | | [field: SerializeField] |
| 0 | 12 | | public RawImage CharacterPreviewImage { get; private set; } |
| | 13 | | public event Action<double> OnEndDragEvent; |
| | 14 | |
|
| 0 | 15 | | public PreviewCameraRotationController PreviewCameraRotationController => (PreviewCameraRotationController) avat |
| | 16 | | private IPreviewCameraRotationController avatarPreviewRotationController; |
| | 17 | |
|
| | 18 | | [SerializeField] private ShowHideAnimator tutorialShowHide; |
| | 19 | | [SerializeField] private GameObject loadingSpinner; |
| | 20 | |
|
| | 21 | | [Header("MOUSE INPUT CONFIGURATION")] |
| | 22 | | [SerializeField] private CharacterPreviewInputDetector characterPreviewInputDetector; |
| | 23 | | [SerializeField] private InputAction_Hold firstClickAction; |
| | 24 | |
|
| | 25 | | [Header("ROTATE CONFIGURATION")] |
| 0 | 26 | | [SerializeField] private float rotationFactor = -30f; |
| 0 | 27 | | [SerializeField] private float slowDownTime = 0.5f; |
| | 28 | |
|
| | 29 | | public void Initialize(IPreviewCameraRotationController avatarPreviewRotationController) |
| | 30 | | { |
| 0 | 31 | | this.avatarPreviewRotationController = avatarPreviewRotationController; |
| 0 | 32 | | this.avatarPreviewRotationController.Configure( |
| | 33 | | firstClickAction, |
| | 34 | | rotationFactor, |
| | 35 | | slowDownTime, |
| | 36 | | characterPreviewInputDetector, |
| | 37 | | null); |
| | 38 | |
|
| 0 | 39 | | this.avatarPreviewRotationController.OnEndDragEvent += EndPreviewDrag; |
| 0 | 40 | | } |
| | 41 | |
|
| | 42 | | public override void Dispose() |
| | 43 | | { |
| 0 | 44 | | base.Dispose(); |
| | 45 | |
|
| 0 | 46 | | avatarPreviewRotationController.OnEndDragEvent -= EndPreviewDrag; |
| 0 | 47 | | avatarPreviewRotationController.Dispose(); |
| 0 | 48 | | } |
| | 49 | |
|
| | 50 | | public void HideTutorial() |
| | 51 | | { |
| 0 | 52 | | tutorialShowHide.Hide(); |
| 0 | 53 | | } |
| | 54 | |
|
| | 55 | | public void SetAsLoading(bool isLoading) |
| | 56 | | { |
| 0 | 57 | | loadingSpinner.SetActive(isLoading); |
| 0 | 58 | | CharacterPreviewImage.gameObject.SetActive(!isLoading); |
| 0 | 59 | | } |
| | 60 | |
|
| | 61 | | public override void RefreshControl() |
| | 62 | | { |
| 0 | 63 | | if (model.TutorialEnabled) |
| | 64 | | { |
| 0 | 65 | | tutorialShowHide.gameObject.SetActive(true); |
| | 66 | | } |
| | 67 | | else |
| | 68 | | { |
| 0 | 69 | | HideTutorial(); |
| | 70 | | } |
| 0 | 71 | | } |
| | 72 | |
|
| | 73 | | private void EndPreviewDrag(double dragTime) |
| | 74 | | { |
| 0 | 75 | | OnEndDragEvent?.Invoke(dragTime); |
| 0 | 76 | | } |
| | 77 | |
|
| 0 | 78 | | RenderTexture IPassportPlayerPreviewComponentView.CharacterPreviewTexture => (RenderTexture) CharacterPreviewIma |
| | 79 | | } |
| | 80 | | } |