| | 1 | | using DCL.Interface; |
| | 2 | | using System; |
| | 3 | |
|
| | 4 | | public class TermsOfServiceHUDController : IHUD |
| | 5 | | { |
| | 6 | | [Serializable] |
| | 7 | | public class Model |
| | 8 | | { |
| | 9 | | public string sceneId; |
| | 10 | | public string sceneName; |
| | 11 | | public bool adultContent; |
| | 12 | | public bool gamblingContent; |
| | 13 | | public string tosURL; |
| | 14 | | public string privacyPolicyURL; |
| | 15 | | public string emailContactURL; |
| | 16 | | } |
| | 17 | |
|
| | 18 | | internal TermsOfServiceHUDView view; |
| | 19 | | internal Model model; |
| | 20 | |
|
| 9 | 21 | | public TermsOfServiceHUDController() |
| | 22 | | { |
| 9 | 23 | | view = TermsOfServiceHUDView.CreateView(); |
| 9 | 24 | | view.Initialize(SendAgreed, SendDeclined, OpenToS, OpenPrivacyPolicy, OpenContactEmail); |
| 9 | 25 | | } |
| | 26 | |
|
| | 27 | | public void ShowTermsOfService(Model model) |
| | 28 | | { |
| 8 | 29 | | this.model = model; |
| | 30 | |
|
| 8 | 31 | | if (this.model == null) |
| | 32 | | { |
| 1 | 33 | | view.SetVisible(false); |
| 1 | 34 | | return; |
| | 35 | | } |
| | 36 | |
|
| 7 | 37 | | view.SetData(model.sceneName, model.adultContent, model.gamblingContent, !string.IsNullOrEmpty(model.tosURL), !s |
| 7 | 38 | | view.SetVisible(true); |
| 7 | 39 | | } |
| | 40 | |
|
| | 41 | | private void SendAgreed(bool dontShowAgain) |
| | 42 | | { |
| 1 | 43 | | WebInterface.SendTermsOfServiceResponse(model.sceneId, true, dontShowAgain); |
| 1 | 44 | | view.SetVisible(false); |
| 1 | 45 | | } |
| | 46 | |
|
| | 47 | | private void SendDeclined(bool dontShowAgain) |
| | 48 | | { |
| 1 | 49 | | WebInterface.SendTermsOfServiceResponse(model.sceneId, false, dontShowAgain); |
| 1 | 50 | | view.SetVisible(false); |
| 1 | 51 | | } |
| | 52 | |
|
| | 53 | | private void OpenToS() |
| | 54 | | { |
| 0 | 55 | | if (!string.IsNullOrEmpty(model.tosURL)) |
| 0 | 56 | | WebInterface.OpenURL(model.tosURL); |
| 0 | 57 | | } |
| | 58 | |
|
| | 59 | | private void OpenPrivacyPolicy() |
| | 60 | | { |
| 0 | 61 | | if (!string.IsNullOrEmpty(model.privacyPolicyURL)) |
| 0 | 62 | | WebInterface.OpenURL(model.privacyPolicyURL); |
| 0 | 63 | | } |
| | 64 | |
|
| | 65 | | private void OpenContactEmail() |
| | 66 | | { |
| 0 | 67 | | if (!string.IsNullOrEmpty(model.emailContactURL)) |
| 0 | 68 | | WebInterface.OpenURL($"mailto:{model.emailContactURL}"); |
| 0 | 69 | | } |
| | 70 | |
|
| 2 | 71 | | public void SetVisibility(bool visible) { view.gameObject.SetActive(visible); } |
| | 72 | |
|
| | 73 | | public void Dispose() |
| | 74 | | { |
| 9 | 75 | | if (view != null) |
| | 76 | | { |
| 9 | 77 | | UnityEngine.Object.Destroy(view.gameObject); |
| | 78 | | } |
| 9 | 79 | | } |
| | 80 | | } |