| | 1 | | using DCL.Interface; |
| | 2 | | using UnityEngine; |
| | 3 | | using UnityEngine.UI; |
| | 4 | |
|
| | 5 | | namespace DCL.HelpAndSupportHUD |
| | 6 | | { |
| | 7 | | public class HelpAndSupportHUDView : MonoBehaviour |
| | 8 | | { |
| 0 | 9 | | public bool isOpen { get; private set; } = false; |
| | 10 | |
|
| | 11 | | public event System.Action OnClose; |
| | 12 | |
|
| | 13 | | private const string PATH = "HelpAndSupportHUD"; |
| | 14 | | private const string VIEW_OBJECT_NAME = "_HelpAndSupportHUD"; |
| | 15 | | private const string JOIN_DISCORD_URL = "https://dcl.gg/discord"; |
| | 16 | | private const string FAQ_URL = "https://docs.decentraland.org/decentraland/faq/"; |
| | 17 | |
|
| | 18 | | [SerializeField] private ShowHideAnimator helpAndSupportAnimator; |
| | 19 | | [SerializeField] private Button joinDiscordButton; |
| | 20 | | [SerializeField] private Button visitFAQButton; |
| | 21 | | [SerializeField] private Button closeButton; |
| | 22 | | [SerializeField] internal InputAction_Trigger closeAction; |
| | 23 | |
|
| | 24 | | private InputAction_Trigger.Triggered closeActionDelegate; |
| | 25 | |
|
| 8 | 26 | | private void Awake() { closeActionDelegate = (x) => SetVisibility(false); } |
| | 27 | |
|
| | 28 | | private void Initialize() |
| | 29 | | { |
| 4 | 30 | | gameObject.name = VIEW_OBJECT_NAME; |
| | 31 | |
|
| 4 | 32 | | joinDiscordButton.onClick.AddListener(() => |
| | 33 | | { |
| 0 | 34 | | WebInterface.OpenURL(JOIN_DISCORD_URL); |
| 0 | 35 | | }); |
| | 36 | |
|
| 4 | 37 | | visitFAQButton.onClick.AddListener(() => |
| | 38 | | { |
| 0 | 39 | | WebInterface.OpenURL(FAQ_URL); |
| 0 | 40 | | }); |
| | 41 | |
|
| 4 | 42 | | closeButton.onClick.AddListener(() => |
| | 43 | | { |
| 0 | 44 | | SetVisibility(false); |
| 0 | 45 | | }); |
| 4 | 46 | | } |
| | 47 | |
|
| | 48 | | public static HelpAndSupportHUDView Create() |
| | 49 | | { |
| 4 | 50 | | HelpAndSupportHUDView view = Instantiate(Resources.Load<GameObject>(PATH)).GetComponent<HelpAndSupportHUDVie |
| 4 | 51 | | view.Initialize(); |
| 4 | 52 | | return view; |
| | 53 | | } |
| | 54 | |
|
| | 55 | | public void SetVisibility(bool visible) |
| | 56 | | { |
| 3 | 57 | | DataStore.i.exploreV2.isSomeModalOpen.Set(visible); |
| | 58 | |
|
| 3 | 59 | | closeAction.OnTriggered -= closeActionDelegate; |
| 3 | 60 | | if (visible) |
| | 61 | | { |
| 2 | 62 | | helpAndSupportAnimator.Show(); |
| 2 | 63 | | closeAction.OnTriggered += closeActionDelegate; |
| 2 | 64 | | } |
| | 65 | | else |
| 1 | 66 | | helpAndSupportAnimator.Hide(); |
| | 67 | |
|
| 3 | 68 | | if (!visible && isOpen) |
| 0 | 69 | | OnClose?.Invoke(); |
| | 70 | |
|
| 3 | 71 | | isOpen = visible; |
| 3 | 72 | | } |
| | 73 | | } |
| | 74 | | } |