| | 1 | | using System; |
| | 2 | | using DCL.Helpers; |
| | 3 | | using TMPro; |
| | 4 | | using UnityEngine; |
| | 5 | | using UnityEngine.UI; |
| | 6 | |
|
| | 7 | | internal class SectionSceneGeneralSettingsView : MonoBehaviour |
| | 8 | | { |
| | 9 | | public event Action OnApplyChanges; |
| | 10 | |
|
| | 11 | | [SerializeField] internal TMP_InputField nameInputField; |
| | 12 | | [SerializeField] internal TMP_InputField descriptionInputField; |
| | 13 | | [SerializeField] internal TMP_Text nameCharCount; |
| | 14 | | [SerializeField] internal TMP_Text descriptionCharCount; |
| | 15 | | [SerializeField] internal GameObject configurationContainer; |
| | 16 | | [SerializeField] internal GameObject permissionsContainer; |
| | 17 | | [SerializeField] internal Toggle toggleVoiceChat; |
| | 18 | | [SerializeField] internal Toggle toggleEmotes; |
| | 19 | | [SerializeField] internal Toggle toggleMatureContent; |
| | 20 | | [SerializeField] internal Toggle toggleMovePlayer; |
| | 21 | | [SerializeField] internal Button applyButton; |
| | 22 | |
|
| | 23 | | public void SetParent(Transform parent) |
| | 24 | | { |
| 0 | 25 | | transform.SetParent(parent); |
| 0 | 26 | | transform.ResetLocalTRS(); |
| 0 | 27 | | } |
| | 28 | |
|
| 0 | 29 | | public void SetActive(bool active) { gameObject.SetActive(active); } |
| | 30 | |
|
| 6 | 31 | | public void SetName(string sceneName) { nameInputField.text = sceneName; } |
| | 32 | |
|
| 6 | 33 | | public void SetDescription(string sceneDescription) { descriptionInputField.text = sceneDescription; } |
| | 34 | |
|
| 6 | 35 | | public void SetConfigurationActive(bool active) { configurationContainer.SetActive(active); } |
| | 36 | |
|
| 6 | 37 | | public void SetPermissionsActive(bool active) { permissionsContainer.SetActive(active); } |
| | 38 | |
|
| 4 | 39 | | public void SetAllowVoiceChat(bool allow) { toggleVoiceChat.isOn = allow; } |
| | 40 | |
|
| 4 | 41 | | public void SetAllowTriggerEmotes(bool allow) { toggleEmotes.isOn = allow; } |
| | 42 | |
|
| 4 | 43 | | public void SetAllowMovePlayer(bool allow) { toggleMovePlayer.isOn = allow; } |
| | 44 | |
|
| 4 | 45 | | public void SetMatureContent(bool mature) { toggleMatureContent.isOn = mature; } |
| | 46 | |
|
| 0 | 47 | | public string GetName() { return nameInputField.text; } |
| | 48 | |
|
| 0 | 49 | | public string GetDescription() { return descriptionInputField.text; } |
| | 50 | |
|
| 0 | 51 | | public bool GetAllowVoiceChat() { return toggleVoiceChat.isOn; } |
| | 52 | |
|
| 0 | 53 | | public bool GetAllowTriggerEmotes() { return toggleEmotes.isOn; } |
| | 54 | |
|
| 0 | 55 | | public bool GetAllowMovePlayer() { return toggleMovePlayer.isOn; } |
| | 56 | |
|
| 0 | 57 | | public bool GetMatureContent() { return toggleMatureContent.isOn; } |
| | 58 | |
|
| | 59 | | private void Awake() |
| | 60 | | { |
| 3 | 61 | | nameInputField.onValueChanged.AddListener(value => |
| | 62 | | { |
| 3 | 63 | | nameCharCount.text = $"{value.Length}/{nameInputField.characterLimit}"; |
| 3 | 64 | | }); |
| 3 | 65 | | descriptionInputField.onValueChanged.AddListener(value => |
| | 66 | | { |
| 3 | 67 | | descriptionCharCount.text = $"{value.Length}/{descriptionInputField.characterLimit}"; |
| 3 | 68 | | }); |
| 3 | 69 | | applyButton.onClick.AddListener(() => OnApplyChanges?.Invoke()); |
| 3 | 70 | | } |
| | 71 | | } |