| | 1 | | using DCL; |
| | 2 | | using TMPro; |
| | 3 | | using UnityEngine; |
| | 4 | | using UnityEngine.UI; |
| | 5 | |
|
| | 6 | | public class MinimapHUDView : MonoBehaviour |
| | 7 | | { |
| | 8 | | public const string VIEW_PATH = "MinimapHUD"; |
| | 9 | | public const string VIEW_OBJECT_NAME = "_MinimapHUD"; |
| | 10 | |
|
| | 11 | | [Header("Information")] [SerializeField] |
| | 12 | | private TextMeshProUGUI sceneNameText; |
| | 13 | |
|
| | 14 | | [SerializeField] private TextMeshProUGUI playerPositionText; |
| | 15 | |
|
| | 16 | | [Header("Options")] [SerializeField] private Button optionsButton; |
| | 17 | | [SerializeField] private GameObject optionsPanel; |
| | 18 | | [SerializeField] private Button addBookmarkButton; |
| | 19 | | [SerializeField] private Button reportSceneButton; |
| | 20 | | [SerializeField] internal UsersAroundListHUDButtonView usersAroundListHudButton; |
| | 21 | |
|
| | 22 | | [Header("Map Renderer")] public RectTransform mapRenderContainer; |
| | 23 | | public RectTransform mapViewport; |
| | 24 | | [SerializeField] private Button openNavmapButton; |
| | 25 | |
|
| | 26 | | public static System.Action<MinimapHUDModel> OnUpdateData; |
| | 27 | | public static System.Action OnOpenNavmapClicked; |
| | 28 | | public InputAction_Trigger toggleNavMapAction; |
| | 29 | | [SerializeField] internal ShowHideAnimator mainShowHideAnimator; |
| | 30 | |
|
| | 31 | | [Header("Tutorial Configuration")] |
| | 32 | | [SerializeField] internal RectTransform minimapTooltipReference; |
| | 33 | | [SerializeField] internal RectTransform usersAroundTooltipReference; |
| | 34 | |
|
| | 35 | | private void Initialize(MinimapHUDController controller) |
| | 36 | | { |
| 9 | 37 | | gameObject.name = VIEW_OBJECT_NAME; |
| 9 | 38 | | optionsPanel.SetActive(false); |
| | 39 | |
|
| 9 | 40 | | optionsButton.onClick.AddListener(controller.ToggleOptions); |
| 9 | 41 | | addBookmarkButton.onClick.AddListener(controller.AddBookmark); |
| 9 | 42 | | reportSceneButton.onClick.AddListener(controller.ReportScene); |
| 9 | 43 | | openNavmapButton.onClick.AddListener(toggleNavMapAction.RaiseOnTriggered); |
| | 44 | |
|
| 9 | 45 | | var renderer = MapRenderer.i; |
| | 46 | |
|
| 9 | 47 | | if (renderer != null) |
| | 48 | | { |
| 9 | 49 | | renderer.atlas.viewport = mapViewport; |
| 9 | 50 | | renderer.transform.SetParent(mapRenderContainer); |
| 9 | 51 | | renderer.transform.SetAsFirstSibling(); |
| | 52 | | } |
| 9 | 53 | | usersAroundListHudButton.gameObject.SetActive(false); |
| 9 | 54 | | } |
| | 55 | |
|
| | 56 | | internal static MinimapHUDView Create(MinimapHUDController controller) |
| | 57 | | { |
| 9 | 58 | | var view = Instantiate(Resources.Load<GameObject>(VIEW_PATH)).GetComponent<MinimapHUDView>(); |
| 9 | 59 | | view.Initialize(controller); |
| 9 | 60 | | return view; |
| | 61 | | } |
| | 62 | |
|
| | 63 | | internal void UpdateData(MinimapHUDModel model) |
| | 64 | | { |
| 14 | 65 | | sceneNameText.text = string.IsNullOrEmpty(model.sceneName) ? "Unnamed" : model.sceneName; |
| 14 | 66 | | playerPositionText.text = model.playerPosition; |
| 14 | 67 | | } |
| | 68 | |
|
| 0 | 69 | | public void ToggleOptions() { optionsPanel.SetActive(!optionsPanel.activeSelf); } |
| | 70 | |
|
| | 71 | | public void SetVisibility(bool visible) |
| | 72 | | { |
| 1 | 73 | | if (visible && !mainShowHideAnimator.isVisible) |
| 0 | 74 | | mainShowHideAnimator.Show(); |
| 1 | 75 | | else if (!visible && mainShowHideAnimator.isVisible) |
| 0 | 76 | | mainShowHideAnimator.Hide(); |
| 1 | 77 | | } |
| | 78 | | } |