| | 1 | | using DCL.Interface; |
| | 2 | | using Analytics; |
| | 3 | | using DCL.Browser; |
| | 4 | | using System.Runtime.InteropServices; |
| | 5 | | using UnityEngine; |
| | 6 | | using UnityEngine.Events; |
| | 7 | |
|
| | 8 | | namespace DCL.HelpAndSupportHUD |
| | 9 | | { |
| | 10 | | public class HelpAndSupportHUDController : IHUD |
| | 11 | | { |
| | 12 | | internal const string CONTACT_SUPPORT_URL = "https://decentraland.org/help"; |
| | 13 | | internal const string JOIN_DISCORD_URL = "https://dcl.gg/discord"; |
| | 14 | | internal const string FAQ_URL = "https://docs.decentraland.org/decentraland/faq/"; |
| 16 | 15 | | public IHelpAndSupportHUDView view { get; } |
| | 16 | |
|
| | 17 | | private ISupportAnalytics analytics; |
| | 18 | | internal readonly IBrowserBridge browserBridge; |
| | 19 | |
|
| 3 | 20 | | public HelpAndSupportHUDController(IHelpAndSupportHUDView view, ISupportAnalytics analytics, IBrowserBridge brow |
| | 21 | | { |
| 3 | 22 | | this.view = view; |
| 3 | 23 | | this.analytics = analytics; |
| 3 | 24 | | this.browserBridge = browserBridge; |
| 3 | 25 | | view.Initialize(); |
| | 26 | |
|
| 3 | 27 | | view.OnDiscordButtonPressed += OpenDiscord; |
| 3 | 28 | | view.OnFaqButtonPressed += OpenFaqs; |
| 3 | 29 | | view.OnSupportButtonPressed += OpenSupport; |
| 3 | 30 | | } |
| | 31 | |
|
| | 32 | | public void SetVisibility(bool visible) |
| | 33 | | { |
| 3 | 34 | | view.SetVisibility(visible); |
| 3 | 35 | | } |
| | 36 | |
|
| | 37 | | private void OpenDiscord() |
| | 38 | | { |
| 0 | 39 | | OpenURL(JOIN_DISCORD_URL); |
| 0 | 40 | | } |
| | 41 | |
|
| | 42 | | private void OpenFaqs() |
| | 43 | | { |
| 0 | 44 | | OpenURL(FAQ_URL); |
| 0 | 45 | | } |
| | 46 | |
|
| | 47 | | private void OpenSupport() |
| | 48 | | { |
| 0 | 49 | | analytics.SendOpenSupport(OpenSupportSource.ExploreHUD); |
| 0 | 50 | | OpenIntercom(); |
| 0 | 51 | | } |
| | 52 | |
|
| | 53 | | internal void OpenURL(string url) |
| | 54 | | { |
| 0 | 55 | | browserBridge.OpenUrl(url); |
| 0 | 56 | | } |
| | 57 | |
|
| | 58 | | public void Dispose() |
| | 59 | | { |
| 3 | 60 | | view.OnDiscordButtonPressed -= OpenDiscord; |
| 3 | 61 | | view.OnFaqButtonPressed -= OpenFaqs; |
| 3 | 62 | | view.OnSupportButtonPressed -= OpenSupport; |
| | 63 | |
|
| 3 | 64 | | view.Dispose(); |
| 3 | 65 | | } |
| | 66 | |
|
| | 67 | |
|
| | 68 | | #if UNITY_WEBGL |
| | 69 | | [DllImport("__Internal")] |
| | 70 | | private static extern void OpenIntercom(); |
| | 71 | | #else |
| | 72 | | private void OpenIntercom() |
| | 73 | | { |
| 0 | 74 | | OpenURL(CONTACT_SUPPORT_URL); |
| 0 | 75 | | } |
| | 76 | | #endif |
| | 77 | | } |
| | 78 | | } |