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