| | 1 | | using System; |
| | 2 | | using System.Collections; |
| | 3 | | using System.Collections.Generic; |
| | 4 | | using TMPro; |
| | 5 | | using UnityEngine; |
| | 6 | | using UnityEngine.UI; |
| | 7 | |
|
| | 8 | | namespace DCL.Builder |
| | 9 | | { |
| | 10 | | public interface IPublishProjectSuccesView |
| | 11 | | { |
| | 12 | | /// <summary> |
| | 13 | | /// Called when view is closed |
| | 14 | | /// </summary> |
| | 15 | | event Action OnViewClose; |
| | 16 | |
|
| | 17 | | /// <summary> |
| | 18 | | /// Hide the view |
| | 19 | | /// </summary> |
| | 20 | | void Hide(); |
| | 21 | |
|
| | 22 | | /// <summary> |
| | 23 | | /// Shows the view with the project data |
| | 24 | | /// </summary> |
| | 25 | | /// <param name="publishedProject"></param> |
| | 26 | | void ProjectPublished(BuilderScene publishedProject); |
| | 27 | |
|
| | 28 | | /// <summary> |
| | 29 | | /// Dispose the view |
| | 30 | | /// </summary> |
| | 31 | | void Dispose(); |
| | 32 | | } |
| | 33 | |
|
| | 34 | | public class PublishProjectSuccesView : BaseComponentView, IPublishProjectSuccesView |
| | 35 | | { |
| | 36 | | private const string SUB_TITLE_TEXT = @"{0} is now a live place in {1},{2} ready to be visited!"; |
| | 37 | |
|
| | 38 | | public event Action OnViewClose; |
| | 39 | |
|
| | 40 | | [SerializeField] internal Button okButton; |
| | 41 | | [SerializeField] internal TMP_Text subTitleTextView; |
| | 42 | |
|
| | 43 | | [SerializeField] internal RawImage screenshotImage; |
| | 44 | |
|
| | 45 | | [SerializeField] internal ModalComponentView modal; |
| | 46 | |
|
| 0 | 47 | | public override void RefreshControl() { } |
| | 48 | |
|
| | 49 | | public override void Awake() |
| | 50 | | { |
| 0 | 51 | | base.Awake(); |
| 0 | 52 | | okButton.onClick.AddListener(OkButtonPressed); |
| 0 | 53 | | modal.OnCloseAction += Close; |
| 0 | 54 | | } |
| | 55 | |
|
| | 56 | | public override void Dispose() |
| | 57 | | { |
| 0 | 58 | | base.Dispose(); |
| 0 | 59 | | okButton.onClick.RemoveAllListeners(); |
| 0 | 60 | | modal.OnCloseAction -= Close; |
| 0 | 61 | | } |
| | 62 | |
|
| | 63 | | internal void OkButtonPressed() |
| | 64 | | { |
| 0 | 65 | | Hide(); |
| 0 | 66 | | Close(); |
| 0 | 67 | | } |
| | 68 | |
|
| 0 | 69 | | public void Close() { OnViewClose?.Invoke(); } |
| | 70 | |
|
| | 71 | | public void ProjectPublished(BuilderScene publishedProject) |
| | 72 | | { |
| 0 | 73 | | modal.Show(); |
| | 74 | |
|
| 0 | 75 | | subTitleTextView.text = GetSubTitleText(publishedProject); |
| 0 | 76 | | screenshotImage.texture = publishedProject.sceneScreenshotTexture; |
| 0 | 77 | | } |
| | 78 | |
|
| 0 | 79 | | public void Hide() { modal.Hide(); } |
| | 80 | |
|
| | 81 | | internal string GetSubTitleText(BuilderScene scene) |
| | 82 | | { |
| 0 | 83 | | string title = scene.manifest.project.title; |
| 0 | 84 | | string posX = scene.scene.sceneData.basePosition.x.ToString(); |
| 0 | 85 | | string posY = scene.scene.sceneData.basePosition.y.ToString(); |
| | 86 | |
|
| 0 | 87 | | return string.Format(SUB_TITLE_TEXT, title, posX, posY); |
| | 88 | | } |
| | 89 | | } |
| | 90 | | } |