| | 1 | | using DCL; |
| | 2 | | using DCL.Helpers; |
| | 3 | | using System; |
| | 4 | | using TMPro; |
| | 5 | | using UnityEngine; |
| | 6 | | using UnityEngine.UI; |
| | 7 | |
|
| | 8 | | public interface IEventCardComponentView |
| | 9 | | { |
| | 10 | | /// <summary> |
| | 11 | | /// Event that will be triggered when the jumpIn button is clicked. |
| | 12 | | /// </summary> |
| | 13 | | Button.ButtonClickedEvent onJumpInClick { get; } |
| | 14 | | Button.ButtonClickedEvent onSecondaryJumpInClick { get; } |
| | 15 | |
|
| | 16 | | /// <summary> |
| | 17 | | /// Event that will be triggered when the info button is clicked. |
| | 18 | | /// </summary> |
| | 19 | | Button.ButtonClickedEvent onInfoClick { get; } |
| | 20 | |
|
| | 21 | | /// <summary> |
| | 22 | | /// Event that will be triggered when the background button is clicked. |
| | 23 | | /// </summary> |
| | 24 | | Button.ButtonClickedEvent onBackgroundClick { get; } |
| | 25 | |
|
| | 26 | | /// <summary> |
| | 27 | | /// Event that will be triggered when the subscribe event button is clicked. |
| | 28 | | /// </summary> |
| | 29 | | Button.ButtonClickedEvent onSubscribeClick { get; } |
| | 30 | |
|
| | 31 | | /// <summary> |
| | 32 | | /// Event that will be triggered when the unsubscribe event button is clicked. |
| | 33 | | /// </summary> |
| | 34 | | Button.ButtonClickedEvent onUnsubscribeClick { get; } |
| | 35 | |
|
| | 36 | | /// <summary> |
| | 37 | | /// Set the event picture directly from a sprite. |
| | 38 | | /// </summary> |
| | 39 | | /// <param name="sprite">Event picture (sprite).</param> |
| | 40 | | void SetEventPicture(Sprite sprite); |
| | 41 | |
|
| | 42 | | /// <summary> |
| | 43 | | /// Set the event picture from a 2D texture. |
| | 44 | | /// </summary> |
| | 45 | | /// <param name="texture">Event picture (url).</param> |
| | 46 | | void SetEventPicture(Texture2D texture); |
| | 47 | |
|
| | 48 | | /// <summary> |
| | 49 | | /// Set the event picture from an uri. |
| | 50 | | /// </summary> |
| | 51 | | /// <param name="uri"></param> |
| | 52 | | void SetEventPicture(string uri); |
| | 53 | |
|
| | 54 | | /// <summary> |
| | 55 | | /// Set the event card as live mode. |
| | 56 | | /// </summary> |
| | 57 | | /// <param name="isLive">True to set the event as live.</param> |
| | 58 | | void SetEventAsLive(bool isLive); |
| | 59 | |
|
| | 60 | | /// <summary> |
| | 61 | | /// Set the the number of users in the event. |
| | 62 | | /// </summary> |
| | 63 | | /// <param name="newNumberOfUsers">Number of users.</param> |
| | 64 | | void SetNumberOfUsers(int newNumberOfUsers); |
| | 65 | |
|
| | 66 | | /// <summary> |
| | 67 | | /// Set the live tag text. |
| | 68 | | /// </summary> |
| | 69 | | /// <param name="newText">New text.</param> |
| | 70 | | void SetLiveTagText(string newText); |
| | 71 | |
|
| | 72 | | /// <summary> |
| | 73 | | /// Set the event date. |
| | 74 | | /// </summary> |
| | 75 | | /// <param name="newDate">The new date showed in the event card.</param> |
| | 76 | | void SetEventDate(string newDate); |
| | 77 | |
|
| | 78 | | /// <summary> |
| | 79 | | /// Set the event name in the card. |
| | 80 | | /// </summary> |
| | 81 | | /// <param name="newText">New event name.</param> |
| | 82 | | void SetEventName(string newText); |
| | 83 | |
|
| | 84 | | /// <summary> |
| | 85 | | /// Set the event description in the card. |
| | 86 | | /// </summary> |
| | 87 | | /// <param name="newText">New event description.</param> |
| | 88 | | void SetEventDescription(string newText); |
| | 89 | |
|
| | 90 | | /// <summary> |
| | 91 | | /// Set the event started time in the card. |
| | 92 | | /// </summary> |
| | 93 | | /// <param name="newText">New event started time.</param> |
| | 94 | | void SetEventStartedIn(string newText); |
| | 95 | |
|
| | 96 | | /// <summary> |
| | 97 | | /// Set the event dates range in the card. |
| | 98 | | /// </summary> |
| | 99 | | /// <param name="newText">New event date range.</param> |
| | 100 | | void SetEventStartsInFromTo(string newText); |
| | 101 | |
|
| | 102 | | /// <summary> |
| | 103 | | /// Set the event organizer in the card. |
| | 104 | | /// </summary> |
| | 105 | | /// <param name="newText">New event organizer.</param> |
| | 106 | | void SetEventOrganizer(string newText); |
| | 107 | |
|
| | 108 | | /// <summary> |
| | 109 | | /// Set the event place in the card. |
| | 110 | | /// </summary> |
| | 111 | | /// <param name="newText">New event place.</param> |
| | 112 | | /// <param name="isWorld">True for setting the place as world.</param> |
| | 113 | | void SetEventPlace(string newText, bool isWorld); |
| | 114 | |
|
| | 115 | | /// <summary> |
| | 116 | | /// Set the the number of users subscribed to the event. |
| | 117 | | /// </summary> |
| | 118 | | /// <param name="newNumberOfUsers">Number of users subscribed.</param> |
| | 119 | | void SetSubscribersUsers(int newNumberOfUsers); |
| | 120 | |
|
| | 121 | | /// <summary> |
| | 122 | | /// Set the event coords. |
| | 123 | | /// </summary> |
| | 124 | | /// <param name="newCoords">Event coords.</param> |
| | 125 | | /// <param name="worldAddress">World address (for world's events)</param> |
| | 126 | | void SetCoords(Vector2Int newCoords, string worldAddress); |
| | 127 | |
|
| | 128 | | /// <summary> |
| | 129 | | /// Active or deactive the loading indicator. |
| | 130 | | /// </summary> |
| | 131 | | /// <param name="isVisible">True for showing the loading indicator and hiding the card info.</param> |
| | 132 | | void SetLoadingIndicatorVisible(bool isVisible); |
| | 133 | | } |
| | 134 | |
|
| | 135 | | public class EventCardComponentView : BaseComponentView, IEventCardComponentView, IComponentModelConfig<EventCardCompone |
| | 136 | | { |
| | 137 | | internal const string USERS_CONFIRMED_MESSAGE = "{0} interested"; |
| | 138 | | internal const string NOBODY_CONFIRMED_MESSAGE = "Nobody confirmed yet"; |
| | 139 | | private const string NO_DESCRIPTION_TEXT = "No description."; |
| | 140 | | private const int EVENT_TITLE_LENGTH_LIMIT = 65; |
| | 141 | |
|
| | 142 | | [Header("Assets References")] |
| | 143 | | [SerializeField] internal UserProfile ownUserProfile; |
| | 144 | |
|
| | 145 | | [Header("Prefab References")] |
| | 146 | | [SerializeField] internal ImageComponentView eventImage; |
| | 147 | | [SerializeField] internal GameObject numberOfUsersContainer; |
| | 148 | | [SerializeField] internal TMP_Text numberOfUsersText; |
| | 149 | | [SerializeField] internal TagComponentView liveTag; |
| | 150 | | [SerializeField] internal TMP_Text eventDateText; |
| | 151 | | [SerializeField] internal TMP_Text eventDateTextOnFocus; |
| | 152 | | [SerializeField] internal TMP_Text eventNameText; |
| | 153 | | [SerializeField] internal TMP_Text eventNameTextOnFocus; |
| | 154 | | [SerializeField] internal TMP_Text eventDescText; |
| | 155 | | [SerializeField] internal TMP_Text eventStartedInTitleForLive; |
| | 156 | | [SerializeField] internal TMP_Text eventStartedInTitleForLiveOnFocus; |
| | 157 | | [SerializeField] internal TMP_Text eventStartedInTitleForNotLive; |
| | 158 | | [SerializeField] internal TMP_Text eventStartedInText; |
| | 159 | | [SerializeField] internal TMP_Text eventStartsInFromToText; |
| | 160 | | [SerializeField] internal TMP_Text eventOrganizerText; |
| | 161 | | [SerializeField] internal TMP_Text eventPlaceText; |
| | 162 | | [SerializeField] internal TMP_Text subscribedUsersTitleForLive; |
| | 163 | | [SerializeField] internal TMP_Text subscribedUsersTitleForNotLive; |
| | 164 | | [SerializeField] internal GameObject goingUsersGameObject; |
| | 165 | | [SerializeField] internal TMP_Text subscribedUsersText; |
| | 166 | | [SerializeField] internal Button modalBackgroundButton; |
| | 167 | | [SerializeField] internal ButtonComponentView closeCardButton; |
| | 168 | | [SerializeField] internal InputAction_Trigger closeAction; |
| | 169 | | [SerializeField] internal ButtonComponentView backgroundButton; |
| | 170 | | [SerializeField] internal ButtonComponentView infoButton; |
| | 171 | | [SerializeField] internal ButtonComponentView jumpinButton; |
| | 172 | | [SerializeField] internal ButtonComponentView secondaryJumpinButton; |
| | 173 | | [SerializeField] internal ButtonComponentView subscribeEventButton; |
| | 174 | | [SerializeField] internal ButtonComponentView unsubscribeEventButton; |
| | 175 | | [SerializeField] internal GameObject imageContainer; |
| | 176 | | [SerializeField] internal GameObject eventInfoContainer; |
| | 177 | | [SerializeField] internal GameObject loadingSpinner; |
| | 178 | | [SerializeField] internal GameObject cardSelectionFrame; |
| | 179 | | [SerializeField] internal VerticalLayoutGroup contentVerticalLayout; |
| | 180 | | [SerializeField] internal VerticalLayoutGroup infoVerticalLayout; |
| | 181 | | [SerializeField] internal HorizontalLayoutGroup timeAndPlayersHorizontalLayout; |
| | 182 | | [SerializeField] internal EventCardAnimator cardAnimator; |
| | 183 | | [SerializeField] internal ScrollRect scroll; |
| | 184 | | [SerializeField] internal GameObject placeIcon; |
| | 185 | | [SerializeField] internal GameObject worldIcon; |
| | 186 | |
|
| | 187 | | [Header("Configuration")] |
| | 188 | | [SerializeField] internal Sprite defaultPicture; |
| | 189 | | [SerializeField] internal bool isEventCardModal; |
| | 190 | | [SerializeField] internal EventCardComponentModel model; |
| | 191 | |
|
| 24 | 192 | | public Button.ButtonClickedEvent onJumpInClick => jumpinButton?.onClick; |
| 24 | 193 | | public Button.ButtonClickedEvent onSecondaryJumpInClick => secondaryJumpinButton?.onClick; |
| 24 | 194 | | public Button.ButtonClickedEvent onInfoClick => infoButton?.onClick; |
| 24 | 195 | | public Button.ButtonClickedEvent onBackgroundClick => backgroundButton?.onClick; |
| 697 | 196 | | public Button.ButtonClickedEvent onSubscribeClick => subscribeEventButton?.onClick; |
| 697 | 197 | | public Button.ButtonClickedEvent onUnsubscribeClick => unsubscribeEventButton?.onClick; |
| | 198 | |
|
| | 199 | | public void Start() |
| | 200 | | { |
| 70 | 201 | | if (cardSelectionFrame != null) |
| 31 | 202 | | cardSelectionFrame.SetActive(false); |
| | 203 | |
|
| 70 | 204 | | if (closeCardButton != null) |
| 39 | 205 | | closeCardButton.onClick.AddListener(CloseModal); |
| | 206 | |
|
| 70 | 207 | | if (closeAction != null) |
| 39 | 208 | | closeAction.OnTriggered += OnCloseActionTriggered; |
| | 209 | |
|
| 70 | 210 | | if (modalBackgroundButton != null) |
| 39 | 211 | | modalBackgroundButton.onClick.AddListener(CloseModal); |
| | 212 | |
|
| 70 | 213 | | if (secondaryJumpinButton != null) |
| 39 | 214 | | secondaryJumpinButton.onClick.AddListener(CloseModal); |
| | 215 | |
|
| 70 | 216 | | onSubscribeClick.AddListener(PressedSubscribe); |
| 70 | 217 | | onUnsubscribeClick.AddListener(PressedUnsubscribe); |
| 70 | 218 | | } |
| | 219 | |
|
| | 220 | | private void PressedSubscribe() |
| | 221 | | { |
| 0 | 222 | | if (ownUserProfile.isGuest) |
| 0 | 223 | | return; |
| | 224 | |
|
| 0 | 225 | | model.isSubscribed = true; |
| 0 | 226 | | model.eventFromAPIInfo.attending = true; |
| 0 | 227 | | RefreshControl(); |
| 0 | 228 | | } |
| | 229 | |
|
| | 230 | | private void PressedUnsubscribe() |
| | 231 | | { |
| 0 | 232 | | if (ownUserProfile.isGuest) |
| 0 | 233 | | return; |
| | 234 | |
|
| 0 | 235 | | model.isSubscribed = false; |
| 0 | 236 | | model.eventFromAPIInfo.attending = false; |
| 0 | 237 | | RefreshControl(); |
| 0 | 238 | | } |
| | 239 | |
|
| | 240 | | public void Configure(EventCardComponentModel newModel) |
| | 241 | | { |
| 9 | 242 | | model = newModel; |
| 9 | 243 | | RefreshControl(); |
| 9 | 244 | | } |
| | 245 | |
|
| | 246 | | public override void RefreshControl() |
| | 247 | | { |
| 13 | 248 | | if (model == null) |
| 0 | 249 | | return; |
| | 250 | |
|
| 13 | 251 | | if (model.eventPictureSprite != null) |
| 9 | 252 | | SetEventPicture(model.eventPictureSprite); |
| 4 | 253 | | else if (model.eventPictureTexture != null) |
| 0 | 254 | | SetEventPicture(model.eventPictureTexture); |
| 4 | 255 | | else if (!string.IsNullOrEmpty(model.eventPictureUri)) |
| 0 | 256 | | SetEventPicture(model.eventPictureUri); |
| | 257 | | else |
| 4 | 258 | | SetEventPicture(sprite: null); |
| | 259 | |
|
| 13 | 260 | | SetEventAsLive(model.isLive); |
| 13 | 261 | | SetNumberOfUsers(model.numberOfUsers); |
| 13 | 262 | | SetLiveTagText(model.liveTagText); |
| 13 | 263 | | SetEventDate(model.eventDateText); |
| 13 | 264 | | SetEventName(model.eventName); |
| 13 | 265 | | SetEventDescription(model.eventDescription); |
| 13 | 266 | | SetEventStartedIn(model.eventStartedIn); |
| 13 | 267 | | SetEventStartsInFromTo(model.eventStartsInFromTo); |
| 13 | 268 | | SetEventOrganizer(model.eventOrganizer); |
| 13 | 269 | | SetEventPlace(model.eventPlace, !string.IsNullOrEmpty(model.worldAddress)); |
| 13 | 270 | | SetSubscribersUsers(model.subscribedUsers); |
| 13 | 271 | | SetCoords(model.coords, model.worldAddress); |
| 13 | 272 | | ResetScrollPosition(); |
| 13 | 273 | | RebuildCardLayouts(); |
| 13 | 274 | | } |
| | 275 | |
|
| | 276 | | public override void OnFocus() |
| | 277 | | { |
| 31 | 278 | | base.OnFocus(); |
| | 279 | |
|
| 31 | 280 | | if (cardSelectionFrame != null) |
| 31 | 281 | | cardSelectionFrame.SetActive(true); |
| | 282 | |
|
| 31 | 283 | | cardAnimator?.Focus(); |
| 31 | 284 | | } |
| | 285 | |
|
| | 286 | | public override void OnLoseFocus() |
| | 287 | | { |
| 518 | 288 | | base.OnLoseFocus(); |
| | 289 | |
|
| 518 | 290 | | if (cardSelectionFrame != null) |
| 408 | 291 | | cardSelectionFrame.SetActive(false); |
| | 292 | |
|
| 518 | 293 | | cardAnimator?.Idle(); |
| 469 | 294 | | } |
| | 295 | |
|
| | 296 | | public override void Show(bool instant = false) |
| | 297 | | { |
| 3 | 298 | | base.Show(instant); |
| | 299 | |
|
| 3 | 300 | | DataStore.i.exploreV2.isSomeModalOpen.Set(true); |
| 3 | 301 | | } |
| | 302 | |
|
| | 303 | | public override void Hide(bool instant = false) |
| | 304 | | { |
| 96 | 305 | | base.Hide(instant); |
| | 306 | |
|
| 96 | 307 | | DataStore.i.exploreV2.isSomeModalOpen.Set(false); |
| 96 | 308 | | } |
| | 309 | |
|
| | 310 | | public override void Dispose() |
| | 311 | | { |
| 611 | 312 | | base.Dispose(); |
| | 313 | |
|
| 611 | 314 | | if (eventImage != null) |
| 610 | 315 | | eventImage.Dispose(); |
| | 316 | |
|
| 611 | 317 | | if (closeCardButton != null) |
| 158 | 318 | | closeCardButton.onClick.RemoveAllListeners(); |
| | 319 | |
|
| 611 | 320 | | if (closeAction != null) |
| 159 | 321 | | closeAction.OnTriggered -= OnCloseActionTriggered; |
| | 322 | |
|
| 611 | 323 | | if (modalBackgroundButton != null) |
| 158 | 324 | | modalBackgroundButton.onClick.RemoveAllListeners(); |
| | 325 | |
|
| 611 | 326 | | if (secondaryJumpinButton != null) |
| 158 | 327 | | secondaryJumpinButton.onClick.RemoveAllListeners(); |
| | 328 | |
|
| 611 | 329 | | onSubscribeClick.RemoveAllListeners(); |
| 611 | 330 | | onUnsubscribeClick.RemoveAllListeners(); |
| 611 | 331 | | } |
| | 332 | |
|
| | 333 | | public void SetEventPicture(Sprite sprite) |
| | 334 | | { |
| 14 | 335 | | if (sprite == null && defaultPicture != null) |
| 4 | 336 | | sprite = defaultPicture; |
| | 337 | |
|
| 14 | 338 | | model.eventPictureSprite = sprite; |
| | 339 | |
|
| 14 | 340 | | if (eventImage == null) |
| 0 | 341 | | return; |
| | 342 | |
|
| 14 | 343 | | eventImage.SetImage(sprite); |
| 14 | 344 | | } |
| | 345 | |
|
| | 346 | | public void SetEventPicture(Texture2D texture) |
| | 347 | | { |
| 1 | 348 | | if (texture == null && defaultPicture != null) |
| | 349 | | { |
| 0 | 350 | | SetEventPicture(defaultPicture); |
| 0 | 351 | | return; |
| | 352 | | } |
| | 353 | |
|
| 1 | 354 | | model.eventPictureTexture = texture; |
| | 355 | |
|
| 1 | 356 | | if (!Application.isPlaying) |
| 0 | 357 | | return; |
| | 358 | |
|
| 1 | 359 | | if (eventImage == null) |
| 0 | 360 | | return; |
| | 361 | |
|
| 1 | 362 | | eventImage.SetImage(texture); |
| 1 | 363 | | } |
| | 364 | |
|
| | 365 | | public void SetEventPicture(string uri) |
| | 366 | | { |
| 1 | 367 | | if (string.IsNullOrEmpty(uri) && defaultPicture != null) |
| | 368 | | { |
| 0 | 369 | | SetEventPicture(defaultPicture); |
| 0 | 370 | | return; |
| | 371 | | } |
| | 372 | |
|
| 1 | 373 | | model.eventPictureUri = uri; |
| | 374 | |
|
| 1 | 375 | | if (!Application.isPlaying) |
| 0 | 376 | | return; |
| | 377 | |
|
| 1 | 378 | | if (eventImage == null) |
| 0 | 379 | | return; |
| | 380 | |
|
| 1 | 381 | | eventImage.SetImage(uri); |
| 1 | 382 | | } |
| | 383 | |
|
| | 384 | | public void SetEventAsLive(bool isLive) |
| | 385 | | { |
| 21 | 386 | | model.isLive = isLive; |
| | 387 | |
|
| 21 | 388 | | if (liveTag != null) |
| 19 | 389 | | liveTag.gameObject.SetActive(isLive); |
| | 390 | |
|
| 21 | 391 | | if (eventDateText != null && !isEventCardModal) |
| 15 | 392 | | eventDateText.gameObject.SetActive(!isLive); |
| | 393 | |
|
| 21 | 394 | | if (eventDateTextOnFocus != null) |
| 17 | 395 | | eventDateTextOnFocus.gameObject.SetActive(!isLive); |
| | 396 | |
|
| 21 | 397 | | if (jumpinButton != null) |
| 21 | 398 | | jumpinButton.gameObject.SetActive(isEventCardModal || isLive); |
| | 399 | |
|
| 21 | 400 | | if (secondaryJumpinButton != null) |
| 2 | 401 | | secondaryJumpinButton.gameObject.SetActive(isEventCardModal || isLive); |
| | 402 | |
|
| 21 | 403 | | if (subscribeEventButton != null) |
| 21 | 404 | | subscribeEventButton.gameObject.SetActive(!isLive && !model.eventFromAPIInfo.attending); |
| | 405 | |
|
| 21 | 406 | | if (unsubscribeEventButton != null) |
| 21 | 407 | | unsubscribeEventButton.gameObject.SetActive(!isLive && model.eventFromAPIInfo.attending); |
| | 408 | |
|
| 21 | 409 | | if (eventStartedInTitleForLive) |
| 19 | 410 | | eventStartedInTitleForLive.gameObject.SetActive(isLive); |
| | 411 | |
|
| 21 | 412 | | if (eventStartedInTitleForLiveOnFocus) |
| 17 | 413 | | eventStartedInTitleForLiveOnFocus.gameObject.SetActive(isLive); |
| | 414 | |
|
| 21 | 415 | | if (eventStartedInTitleForNotLive) |
| 2 | 416 | | eventStartedInTitleForNotLive.gameObject.SetActive(!isLive); |
| | 417 | |
|
| 21 | 418 | | if (subscribedUsersTitleForLive != null) |
| 2 | 419 | | subscribedUsersTitleForLive.gameObject.SetActive(isLive); |
| | 420 | |
|
| 21 | 421 | | if (subscribedUsersTitleForNotLive != null) |
| 2 | 422 | | subscribedUsersTitleForNotLive.gameObject.SetActive(!isLive); |
| | 423 | |
|
| 21 | 424 | | if(goingUsersGameObject != null) |
| 0 | 425 | | goingUsersGameObject.SetActive(!isLive); |
| 21 | 426 | | } |
| | 427 | |
|
| | 428 | | public void SetNumberOfUsers(int newNumberOfUsers) |
| | 429 | | { |
| 13 | 430 | | model.numberOfUsers = newNumberOfUsers; |
| | 431 | |
|
| 13 | 432 | | if (numberOfUsersText == null) |
| 2 | 433 | | return; |
| | 434 | |
|
| 11 | 435 | | numberOfUsersText.text = FormatNumber(newNumberOfUsers); |
| 11 | 436 | | numberOfUsersContainer.SetActive(model.isLive && newNumberOfUsers > 0); |
| 11 | 437 | | } |
| | 438 | |
|
| | 439 | | public void SetLiveTagText(string newText) |
| | 440 | | { |
| 14 | 441 | | model.liveTagText = newText; |
| | 442 | |
|
| 14 | 443 | | if (liveTag != null) |
| 12 | 444 | | liveTag.SetText(newText); |
| 14 | 445 | | } |
| | 446 | |
|
| | 447 | | public void SetEventDate(string newDate) |
| | 448 | | { |
| 14 | 449 | | model.eventDateText = newDate; |
| | 450 | |
|
| 14 | 451 | | if (eventDateText != null) |
| 14 | 452 | | eventDateText.text = newDate; |
| | 453 | |
|
| 14 | 454 | | if (eventDateTextOnFocus != null) |
| 10 | 455 | | eventDateTextOnFocus.text = newDate; |
| 14 | 456 | | } |
| | 457 | |
|
| | 458 | | public void SetEventName(string newText) |
| | 459 | | { |
| 14 | 460 | | model.eventName = newText; |
| | 461 | |
|
| 14 | 462 | | string wrappedText = newText.Substring(0, Math.Min(EVENT_TITLE_LENGTH_LIMIT, newText.Length)); |
| | 463 | |
|
| 14 | 464 | | if (eventNameText != null) |
| 14 | 465 | | eventNameText.text = wrappedText; |
| | 466 | |
|
| 14 | 467 | | if (eventNameTextOnFocus != null) |
| 10 | 468 | | eventNameTextOnFocus.text = wrappedText; |
| 14 | 469 | | } |
| | 470 | |
|
| | 471 | | public void SetEventDescription(string newText) |
| | 472 | | { |
| 14 | 473 | | model.eventDescription = newText; |
| | 474 | |
|
| 14 | 475 | | if (eventDescText == null) |
| 9 | 476 | | return; |
| | 477 | |
|
| 5 | 478 | | eventDescText.text = string.IsNullOrEmpty(newText) ? NO_DESCRIPTION_TEXT : newText; |
| 5 | 479 | | } |
| | 480 | |
|
| | 481 | | public void SetEventStartedIn(string newText) |
| | 482 | | { |
| 14 | 483 | | model.eventStartedIn = newText; |
| | 484 | |
|
| 14 | 485 | | if (eventStartedInText == null) |
| 2 | 486 | | return; |
| | 487 | |
|
| 12 | 488 | | eventStartedInText.text = newText; |
| 12 | 489 | | } |
| | 490 | |
|
| | 491 | | public void SetEventStartsInFromTo(string newText) |
| | 492 | | { |
| 14 | 493 | | model.eventStartsInFromTo = newText; |
| | 494 | |
|
| 14 | 495 | | if (eventStartsInFromToText == null) |
| 11 | 496 | | return; |
| | 497 | |
|
| 3 | 498 | | eventStartsInFromToText.text = newText; |
| 3 | 499 | | } |
| | 500 | |
|
| | 501 | | public void SetEventOrganizer(string newText) |
| | 502 | | { |
| 14 | 503 | | model.eventOrganizer = newText; |
| | 504 | |
|
| 14 | 505 | | if (eventOrganizerText == null) |
| 11 | 506 | | return; |
| | 507 | |
|
| 3 | 508 | | eventOrganizerText.text = newText; |
| 3 | 509 | | } |
| | 510 | |
|
| | 511 | | public void SetEventPlace(string newText, bool isWorld) |
| | 512 | | { |
| 15 | 513 | | model.eventPlace = newText; |
| | 514 | |
|
| 15 | 515 | | if (eventPlaceText != null) |
| 15 | 516 | | eventPlaceText.text = newText; |
| | 517 | |
|
| 15 | 518 | | if (placeIcon != null) |
| 15 | 519 | | placeIcon.SetActive(!isWorld); |
| | 520 | |
|
| 15 | 521 | | if (worldIcon != null) |
| 15 | 522 | | worldIcon.SetActive(isWorld); |
| 15 | 523 | | } |
| | 524 | |
|
| | 525 | | public void SetSubscribersUsers(int newNumberOfUsers) |
| | 526 | | { |
| 17 | 527 | | model.subscribedUsers = newNumberOfUsers; |
| 17 | 528 | | if (subscribedUsersText == null) |
| 0 | 529 | | return; |
| | 530 | |
|
| 17 | 531 | | if (!isEventCardModal) |
| | 532 | | { |
| 13 | 533 | | subscribedUsersText.text = $"{newNumberOfUsers.ToString()} interested"; |
| 13 | 534 | | subscribedUsersText.gameObject.SetActive(!model.isLive); |
| | 535 | | } |
| | 536 | | else |
| 4 | 537 | | subscribedUsersText.text = newNumberOfUsers > 0 ? string.Format(USERS_CONFIRMED_MESSAGE, newNumberOfUsers) : |
| 4 | 538 | | } |
| | 539 | |
|
| | 540 | | public void SetCoords(Vector2Int newCoords, string worldAddress) |
| | 541 | | { |
| 15 | 542 | | model.coords = newCoords; |
| 15 | 543 | | model.worldAddress = worldAddress; |
| | 544 | |
|
| 15 | 545 | | if (secondaryJumpinButton == null || !isEventCardModal) |
| 11 | 546 | | return; |
| | 547 | |
|
| 4 | 548 | | secondaryJumpinButton.SetText(string.IsNullOrEmpty(worldAddress) ? $"{newCoords.x},{newCoords.y}" : worldAddress |
| 4 | 549 | | } |
| | 550 | |
|
| | 551 | | public void SetLoadingIndicatorVisible(bool isVisible) |
| | 552 | | { |
| 2 | 553 | | imageContainer.SetActive(!isVisible); |
| 2 | 554 | | eventInfoContainer.SetActive(!isVisible); |
| 2 | 555 | | loadingSpinner.SetActive(isVisible); |
| 2 | 556 | | } |
| | 557 | |
|
| | 558 | | internal void RebuildCardLayouts() |
| | 559 | | { |
| 13 | 560 | | if (contentVerticalLayout != null) |
| 2 | 561 | | Utils.ForceRebuildLayoutImmediate(contentVerticalLayout.transform as RectTransform); |
| | 562 | |
|
| 13 | 563 | | if (infoVerticalLayout != null) |
| 2 | 564 | | Utils.ForceRebuildLayoutImmediate(infoVerticalLayout.transform as RectTransform); |
| | 565 | |
|
| 13 | 566 | | if (timeAndPlayersHorizontalLayout != null) |
| 2 | 567 | | Utils.ForceRebuildLayoutImmediate(timeAndPlayersHorizontalLayout.transform as RectTransform); |
| | 568 | |
|
| 13 | 569 | | if (numberOfUsersContainer != null) |
| 11 | 570 | | Utils.ForceRebuildLayoutImmediate(numberOfUsersContainer.transform as RectTransform); |
| 13 | 571 | | } |
| | 572 | |
|
| 4 | 573 | | internal void CloseModal() { Hide(); } |
| | 574 | |
|
| 2 | 575 | | internal void OnCloseActionTriggered(DCLAction_Trigger action) { CloseModal(); } |
| | 576 | |
|
| | 577 | | private static string FormatNumber(int num) |
| | 578 | | { |
| 11 | 579 | | if (num < 1000) |
| 11 | 580 | | return num.ToString(); |
| | 581 | |
|
| 0 | 582 | | float divided = num / 1000.0f; |
| 0 | 583 | | divided = (int)(divided * 100) / 100f; |
| 0 | 584 | | return $"{divided:F2}k"; |
| | 585 | | } |
| | 586 | |
|
| | 587 | | private void ResetScrollPosition() |
| | 588 | | { |
| 13 | 589 | | if (scroll == null) |
| 11 | 590 | | return; |
| | 591 | |
|
| 2 | 592 | | scroll.verticalNormalizedPosition = 1; |
| 2 | 593 | | } |
| | 594 | | } |