| | 1 | | using System; |
| | 2 | | using TMPro; |
| | 3 | | using UnityEngine; |
| | 4 | | using UnityEngine.UI; |
| | 5 | |
|
| | 6 | | public class TermsOfServiceHUDView : MonoBehaviour |
| | 7 | | { |
| | 8 | | private const string VIEW_PATH = "TermsOfServiceHUD"; |
| | 9 | |
|
| | 10 | | private const string SCENE_NAME_VAR = "$sceneName"; |
| 1 | 11 | | private static readonly string TITLE = $"Terms of Service - {SCENE_NAME_VAR}"; |
| 1 | 12 | | private static readonly string DESCRIPTION = $"Welcome to {SCENE_NAME_VAR}. Before you proceed, please read carefull |
| | 13 | |
|
| 9 | 14 | | public static TermsOfServiceHUDView CreateView() => Instantiate(Resources.Load<GameObject>(VIEW_PATH)).GetComponent< |
| | 15 | |
|
| | 16 | | [SerializeField] internal GameObject content; |
| | 17 | | [SerializeField] internal TextMeshProUGUI titleText; |
| | 18 | | [SerializeField] internal TextMeshProUGUI descriptionText; |
| | 19 | | [SerializeField] internal GameObject adultContent; |
| | 20 | | [SerializeField] internal GameObject gamblingContent; |
| | 21 | | [SerializeField] internal Button agreedButton; |
| | 22 | | [SerializeField] internal Button declinedButton; |
| | 23 | | [SerializeField] internal Toggle dontShowAgainToggle; |
| | 24 | |
|
| | 25 | | [Header("Hyperlinks")] |
| | 26 | | [SerializeField] internal Button tosLinkButton; |
| | 27 | | [SerializeField] internal Button privacyLinkButton; |
| | 28 | | [SerializeField] internal Button emailLinkButton; |
| | 29 | |
|
| | 30 | | public void Initialize(Action<bool> agreedCallback, Action<bool> declinedCallback, Action tosClickedCallback, Action |
| | 31 | | { |
| 9 | 32 | | agreedButton.onClick.RemoveAllListeners(); |
| 10 | 33 | | agreedButton.onClick.AddListener(() => agreedCallback?.Invoke(dontShowAgainToggle.isOn)); |
| | 34 | |
|
| 9 | 35 | | declinedButton.onClick.RemoveAllListeners(); |
| 10 | 36 | | declinedButton.onClick.AddListener(() => declinedCallback?.Invoke(dontShowAgainToggle.isOn)); |
| | 37 | |
|
| 9 | 38 | | tosLinkButton.onClick.RemoveAllListeners(); |
| 9 | 39 | | tosLinkButton.onClick.AddListener(() => tosClickedCallback?.Invoke()); |
| | 40 | |
|
| 9 | 41 | | privacyLinkButton.onClick.RemoveAllListeners(); |
| 9 | 42 | | privacyLinkButton.onClick.AddListener(() => privacyClickedCallback?.Invoke()); |
| | 43 | |
|
| 9 | 44 | | emailLinkButton.onClick.RemoveAllListeners(); |
| 9 | 45 | | emailLinkButton.onClick.AddListener(() => emailClickedCallback?.Invoke()); |
| | 46 | |
|
| 9 | 47 | | SetVisible(false); |
| 9 | 48 | | } |
| | 49 | |
|
| | 50 | | public void SetVisible(bool visible) |
| | 51 | | { |
| 19 | 52 | | content.SetActive(visible); |
| | 53 | |
|
| 19 | 54 | | if (visible) |
| | 55 | | { |
| 7 | 56 | | AudioScriptableObjects.dialogOpen.Play(true); |
| 7 | 57 | | } |
| | 58 | | else |
| | 59 | | { |
| 12 | 60 | | AudioScriptableObjects.dialogClose.Play(true); |
| | 61 | | } |
| 12 | 62 | | } |
| | 63 | |
|
| | 64 | | public void SetData(string sceneName, bool hasAdultContent, bool hasGamblingContent, bool hasToS, bool hasPrivacyPol |
| | 65 | | { |
| 7 | 66 | | titleText.text = TITLE.Replace(SCENE_NAME_VAR, sceneName); |
| 7 | 67 | | descriptionText.text = DESCRIPTION.Replace(SCENE_NAME_VAR, sceneName); |
| | 68 | |
|
| 7 | 69 | | adultContent.SetActive(hasAdultContent); |
| 7 | 70 | | gamblingContent.SetActive(hasGamblingContent); |
| | 71 | |
|
| 7 | 72 | | tosLinkButton.interactable = hasToS; |
| 7 | 73 | | privacyLinkButton.interactable = hasPrivacyPolicy; |
| 7 | 74 | | emailLinkButton.interactable = hasContactEmail; |
| | 75 | |
|
| 7 | 76 | | dontShowAgainToggle.isOn = false; |
| 7 | 77 | | } |
| | 78 | | } |