| | 1 | | using System; |
| | 2 | | using TMPro; |
| | 3 | | using UIComponents.Scripts.Components; |
| | 4 | | using UnityEngine; |
| | 5 | | using UnityEngine.UI; |
| | 6 | |
|
| | 7 | | namespace DCL.Quests |
| | 8 | | { |
| | 9 | | public class QuestStepComponentView : BaseComponentView<QuestStepComponentModel>, IQuestStepComponentView |
| | 10 | | { |
| | 11 | | [SerializeField] internal GameObject completedQuestToggle; |
| | 12 | | [SerializeField] internal GameObject nonCompletedQuestToggle; |
| | 13 | | [SerializeField] internal TMP_Text questStepText; |
| | 14 | | [SerializeField] internal Button jumpInButton; |
| | 15 | |
|
| 119 | 16 | | [SerializeField] internal Color normalTextColor = Color.black; |
| 119 | 17 | | [SerializeField] internal Color completedTextColor = Color.gray; |
| | 18 | |
|
| | 19 | | public event Action<Vector2Int> OnJumpIn; |
| | 20 | |
|
| | 21 | | public override void RefreshControl() |
| | 22 | | { |
| 5 | 23 | | if (model == null) |
| 0 | 24 | | return; |
| | 25 | |
|
| 5 | 26 | | SetIsCompleted(model.isCompleted); |
| 5 | 27 | | SetQuestStepText(model.text); |
| 5 | 28 | | SetSupportsJumpIn(model.supportsJumpIn); |
| 5 | 29 | | SetCoordinates(model.coordinates); |
| 5 | 30 | | } |
| | 31 | |
|
| | 32 | | public void SetIsCompleted(bool isCompleted) |
| | 33 | | { |
| 7 | 34 | | model.isCompleted = isCompleted; |
| | 35 | |
|
| 7 | 36 | | completedQuestToggle.SetActive(isCompleted); |
| 7 | 37 | | nonCompletedQuestToggle.SetActive(!isCompleted); |
| 7 | 38 | | questStepText.color = isCompleted ? completedTextColor : normalTextColor; |
| 7 | 39 | | } |
| | 40 | |
|
| | 41 | | public void SetQuestStepText(string stepText) |
| | 42 | | { |
| 8 | 43 | | model.text = stepText; |
| | 44 | |
|
| 8 | 45 | | questStepText.text = stepText; |
| 8 | 46 | | } |
| | 47 | |
|
| | 48 | | public void SetCoordinates(Vector2Int coordinates) |
| | 49 | | { |
| 5 | 50 | | model.coordinates = coordinates; |
| | 51 | |
|
| 5 | 52 | | jumpInButton.onClick.RemoveAllListeners(); |
| 6 | 53 | | jumpInButton.onClick.AddListener(()=>OnJumpIn?.Invoke(model.coordinates)); |
| 5 | 54 | | } |
| | 55 | |
|
| | 56 | | public void SetSupportsJumpIn(bool supportsJumpIn) |
| | 57 | | { |
| 7 | 58 | | model.supportsJumpIn = supportsJumpIn; |
| 7 | 59 | | jumpInButton.gameObject.SetActive(supportsJumpIn); |
| 7 | 60 | | } |
| | 61 | | } |
| | 62 | | } |