| | 1 | | using System; |
| | 2 | | using DCL; |
| | 3 | | using DCL.HelpAndSupportHUD; |
| | 4 | | using DCL.Huds.QuestsPanel; |
| | 5 | | using DCL.Huds.QuestsTracker; |
| | 6 | | using DCL.QuestsController; |
| | 7 | | using DCL.SettingsPanelHUD; |
| | 8 | | using System.Collections.Generic; |
| | 9 | | using LoadingHUD; |
| | 10 | | using SignupHUD; |
| | 11 | | using UnityEngine; |
| | 12 | | using UnityEngine.EventSystems; |
| | 13 | |
|
| | 14 | | public class HUDController : IHUDController |
| | 15 | | { |
| | 16 | | private const string TOGGLE_UI_VISIBILITY_ASSET_NAME = "ToggleUIVisibility"; |
| | 17 | |
|
| | 18 | | static bool VERBOSE = false; |
| 0 | 19 | | public static HUDController i { get; private set; } |
| | 20 | |
|
| | 21 | | public IHUDFactory hudFactory = null; |
| | 22 | |
|
| | 23 | | private InputAction_Trigger toggleUIVisibilityTrigger; |
| | 24 | |
|
| 798 | 25 | | private readonly DCL.NotificationModel.Model hiddenUINotification = new DCL.NotificationModel.Model() |
| | 26 | | { |
| | 27 | | timer = 3, |
| | 28 | | type = DCL.NotificationModel.Type.UI_HIDDEN, |
| | 29 | | groupID = "UIHiddenNotification" |
| | 30 | | }; |
| | 31 | |
|
| | 32 | | public void Initialize(IHUDFactory hudFactory) |
| | 33 | | { |
| 798 | 34 | | i = this; |
| 798 | 35 | | this.hudFactory = hudFactory; |
| | 36 | |
|
| 798 | 37 | | toggleUIVisibilityTrigger = Resources.Load<InputAction_Trigger>(TOGGLE_UI_VISIBILITY_ASSET_NAME); |
| 798 | 38 | | toggleUIVisibilityTrigger.OnTriggered += ToggleUIVisibility_OnTriggered; |
| | 39 | |
|
| 798 | 40 | | CommonScriptableObjects.allUIHidden.OnChange += AllUIHiddenOnOnChange; |
| 798 | 41 | | UserContextMenu.OnOpenPrivateChatRequest += OpenPrivateChatWindow; |
| 798 | 42 | | } |
| | 43 | |
|
| | 44 | | public event Action OnTaskbarCreation; |
| | 45 | |
|
| 10 | 46 | | public ProfileHUDController profileHud => GetHUDElement(HUDElementID.PROFILE_HUD) as ProfileHUDController; |
| | 47 | |
|
| | 48 | | public NotificationHUDController notificationHud => |
| 1 | 49 | | GetHUDElement(HUDElementID.NOTIFICATION) as NotificationHUDController; |
| | 50 | |
|
| 7 | 51 | | public MinimapHUDController minimapHud => GetHUDElement(HUDElementID.MINIMAP) as MinimapHUDController; |
| | 52 | |
|
| | 53 | | public AvatarEditorHUDController avatarEditorHud => |
| 2 | 54 | | GetHUDElement(HUDElementID.AVATAR_EDITOR) as AvatarEditorHUDController; |
| | 55 | |
|
| 108 | 56 | | public SettingsPanelHUDController settingsPanelHud => GetHUDElement(HUDElementID.SETTINGS_PANEL) as SettingsPanelHUD |
| | 57 | |
|
| | 58 | | public EmotesHUDController emotesHUD => |
| 0 | 59 | | GetHUDElement(HUDElementID.EMOTES) as EmotesHUDController; |
| | 60 | |
|
| | 61 | | public PlayerInfoCardHUDController playerInfoCardHud => |
| 0 | 62 | | GetHUDElement(HUDElementID.PLAYER_INFO_CARD) as PlayerInfoCardHUDController; |
| | 63 | |
|
| | 64 | | public WelcomeHUDController messageOfTheDayHud => |
| 1 | 65 | | GetHUDElement(HUDElementID.MESSAGE_OF_THE_DAY) as WelcomeHUDController; |
| | 66 | |
|
| | 67 | | public AirdroppingHUDController airdroppingHud => |
| 0 | 68 | | GetHUDElement(HUDElementID.AIRDROPPING) as AirdroppingHUDController; |
| | 69 | |
|
| | 70 | | public TermsOfServiceHUDController termsOfServiceHud => |
| 0 | 71 | | GetHUDElement(HUDElementID.TERMS_OF_SERVICE) as TermsOfServiceHUDController; |
| | 72 | |
|
| 827 | 73 | | public TaskbarHUDController taskbarHud => GetHUDElement(HUDElementID.TASKBAR) as TaskbarHUDController; |
| | 74 | |
|
| | 75 | | public WorldChatWindowHUDController worldChatWindowHud => |
| 818 | 76 | | GetHUDElement(HUDElementID.WORLD_CHAT_WINDOW) as WorldChatWindowHUDController; |
| | 77 | |
|
| | 78 | | public PrivateChatWindowHUDController privateChatWindowHud => |
| 810 | 79 | | GetHUDElement(HUDElementID.PRIVATE_CHAT_WINDOW) as PrivateChatWindowHUDController; |
| | 80 | |
|
| 816 | 81 | | public FriendsHUDController friendsHud => GetHUDElement(HUDElementID.FRIENDS) as FriendsHUDController; |
| | 82 | |
|
| 0 | 83 | | public TeleportPromptHUDController teleportHud => GetHUDElement(HUDElementID.TELEPORT_DIALOG) as TeleportPromptHUDCo |
| | 84 | |
|
| 2 | 85 | | public ControlsHUDController controlsHud => GetHUDElement(HUDElementID.CONTROLS_HUD) as ControlsHUDController; |
| | 86 | |
|
| 1 | 87 | | public HelpAndSupportHUDController helpAndSupportHud => GetHUDElement(HUDElementID.HELP_AND_SUPPORT_HUD) as HelpAndS |
| | 88 | |
|
| 2 | 89 | | public UsersAroundListHUDController usersAroundListHud => GetHUDElement(HUDElementID.USERS_AROUND_LIST_HUD) as Users |
| 1 | 90 | | public QuestsPanelHUDController questsPanelHUD => GetHUDElement(HUDElementID.QUESTS_PANEL) as QuestsPanelHUDControll |
| 1 | 91 | | public QuestsTrackerHUDController questsTrackerHUD => GetHUDElement(HUDElementID.QUESTS_TRACKER) as QuestsTrackerHUD |
| 1 | 92 | | public SignupHUDController signupHUD => GetHUDElement(HUDElementID.SIGNUP) as SignupHUDController; |
| 1 | 93 | | public LoadingHUDController loadingController => GetHUDElement(HUDElementID.LOADING) as LoadingHUDController; |
| | 94 | |
|
| 798 | 95 | | public Dictionary<HUDElementID, IHUD> hudElements { get; private set; } = new Dictionary<HUDElementID, IHUD>(); |
| | 96 | |
|
| 1 | 97 | | private UserProfile ownUserProfile => UserProfile.GetOwnUserProfile(); |
| 1 | 98 | | private BaseDictionary<string, WearableItem> wearableCatalog => CatalogController.wearableCatalog; |
| | 99 | |
|
| 0 | 100 | | private void ShowSettings() { settingsPanelHud?.SetVisibility(true); } |
| | 101 | |
|
| 0 | 102 | | private void ShowControls() { controlsHud?.SetVisibility(true); } |
| | 103 | |
|
| | 104 | | private void ToggleUIVisibility_OnTriggered(DCLAction_Trigger action) |
| | 105 | | { |
| 0 | 106 | | bool anyInputFieldIsSelected = EventSystem.current != null && |
| | 107 | | EventSystem.current.currentSelectedGameObject != null && |
| | 108 | | EventSystem.current.currentSelectedGameObject.GetComponent<TMPro.TMP_InputField>( |
| | 109 | | (!worldChatWindowHud.view.chatHudView.inputField.isFocused || !worldChatWindowHud |
| | 110 | |
|
| 0 | 111 | | if (anyInputFieldIsSelected || |
| | 112 | | settingsPanelHud.view.isOpen || |
| | 113 | | avatarEditorHud.view.isOpen || |
| | 114 | | DataStore.i.HUDs.navmapVisible.Get() || |
| | 115 | | CommonScriptableObjects.tutorialActive) |
| 0 | 116 | | return; |
| | 117 | |
|
| 0 | 118 | | CommonScriptableObjects.allUIHidden.Set(!CommonScriptableObjects.allUIHidden.Get()); |
| 0 | 119 | | } |
| | 120 | |
|
| | 121 | | private void AllUIHiddenOnOnChange(bool current, bool previous) |
| | 122 | | { |
| 35 | 123 | | if (current) |
| | 124 | | { |
| 17 | 125 | | NotificationsController.i?.ShowNotification(hiddenUINotification); |
| 17 | 126 | | } |
| | 127 | | else |
| | 128 | | { |
| 18 | 129 | | NotificationsController.i?.DismissAllNotifications(hiddenUINotification.groupID); |
| | 130 | | } |
| 18 | 131 | | } |
| | 132 | |
|
| | 133 | | public void ConfigureHUDElement(HUDElementID hudElementId, HUDConfiguration configuration, string extraPayload = nul |
| | 134 | | { |
| | 135 | | //TODO(Brian): For now, the factory code is using this switch approach. |
| | 136 | | // In order to avoid the factory upkeep we can transform the IHUD elements |
| | 137 | | // To ScriptableObjects. In this scenario, we can make each element handle its own |
| | 138 | | // specific initialization details. |
| | 139 | | // |
| | 140 | | // This will allow us to unify the serialized factory objects design, |
| | 141 | | // like we already do with ECS components. |
| | 142 | |
|
| | 143 | | switch (hudElementId) |
| | 144 | | { |
| | 145 | | case HUDElementID.NONE: |
| | 146 | | break; |
| | 147 | | case HUDElementID.MINIMAP: |
| 1 | 148 | | CreateHudElement(configuration, hudElementId); |
| 1 | 149 | | break; |
| | 150 | | case HUDElementID.PROFILE_HUD: |
| 1 | 151 | | CreateHudElement(configuration, hudElementId); |
| 1 | 152 | | break; |
| | 153 | | case HUDElementID.NOTIFICATION: |
| 1 | 154 | | CreateHudElement(configuration, hudElementId); |
| 1 | 155 | | NotificationsController.i?.Initialize(notificationHud); |
| 1 | 156 | | break; |
| | 157 | | case HUDElementID.AVATAR_EDITOR: |
| 1 | 158 | | CreateHudElement(configuration, hudElementId); |
| 1 | 159 | | avatarEditorHud?.Initialize(ownUserProfile, wearableCatalog); |
| 1 | 160 | | break; |
| | 161 | | case HUDElementID.SETTINGS_PANEL: |
| 1 | 162 | | CreateHudElement(configuration, hudElementId); |
| 1 | 163 | | if (settingsPanelHud != null) |
| 1 | 164 | | settingsPanelHud.Initialize(); |
| 1 | 165 | | break; |
| | 166 | | case HUDElementID.EXPRESSIONS: |
| | 167 | | case HUDElementID.EMOTES: |
| 2 | 168 | | CreateHudElement(configuration, hudElementId); |
| 2 | 169 | | break; |
| | 170 | | case HUDElementID.PLAYER_INFO_CARD: |
| 1 | 171 | | CreateHudElement(configuration, hudElementId); |
| 1 | 172 | | break; |
| | 173 | | case HUDElementID.AIRDROPPING: |
| 1 | 174 | | CreateHudElement(configuration, hudElementId); |
| 1 | 175 | | break; |
| | 176 | | case HUDElementID.TERMS_OF_SERVICE: |
| 1 | 177 | | CreateHudElement(configuration, hudElementId); |
| 1 | 178 | | break; |
| | 179 | | case HUDElementID.WORLD_CHAT_WINDOW: |
| 1 | 180 | | if (worldChatWindowHud == null) |
| | 181 | | { |
| 1 | 182 | | CreateHudElement(configuration, hudElementId); |
| | 183 | |
|
| 1 | 184 | | if (worldChatWindowHud != null) |
| | 185 | | { |
| 1 | 186 | | worldChatWindowHud.Initialize(ChatController.i, SceneReferences.i.mouseCatcher); |
| 1 | 187 | | worldChatWindowHud.OnPressPrivateMessage -= OpenPrivateChatWindow; |
| 1 | 188 | | worldChatWindowHud.OnPressPrivateMessage += OpenPrivateChatWindow; |
| 1 | 189 | | worldChatWindowHud.view.OnDeactivatePreview -= View_OnDeactivatePreview; |
| 1 | 190 | | worldChatWindowHud.view.OnDeactivatePreview += View_OnDeactivatePreview; |
| | 191 | |
|
| 1 | 192 | | taskbarHud?.AddWorldChatWindow(worldChatWindowHud); |
| | 193 | | } |
| 0 | 194 | | } |
| | 195 | | else |
| | 196 | | { |
| 0 | 197 | | UpdateHudElement(configuration, hudElementId); |
| | 198 | | } |
| | 199 | |
|
| 0 | 200 | | break; |
| | 201 | | case HUDElementID.FRIENDS: |
| 1 | 202 | | if (friendsHud == null) |
| | 203 | | { |
| 1 | 204 | | CreateHudElement(configuration, hudElementId); |
| | 205 | |
|
| 1 | 206 | | if (friendsHud != null) |
| | 207 | | { |
| 1 | 208 | | friendsHud.Initialize(FriendsController.i, UserProfile.GetOwnUserProfile()); |
| 1 | 209 | | friendsHud.OnPressWhisper -= OpenPrivateChatWindow; |
| 1 | 210 | | friendsHud.OnPressWhisper += OpenPrivateChatWindow; |
| | 211 | |
|
| 1 | 212 | | taskbarHud?.AddFriendsWindow(friendsHud); |
| | 213 | | } |
| 1 | 214 | | } |
| | 215 | | else |
| | 216 | | { |
| 0 | 217 | | UpdateHudElement(configuration, hudElementId); |
| | 218 | |
|
| 0 | 219 | | if (!configuration.active) |
| 0 | 220 | | taskbarHud?.DisableFriendsWindow(); |
| | 221 | | } |
| | 222 | |
|
| 1 | 223 | | if (privateChatWindowHud == null) |
| | 224 | | { |
| 1 | 225 | | CreateHudElement(configuration, HUDElementID.PRIVATE_CHAT_WINDOW); |
| | 226 | |
|
| 1 | 227 | | if (privateChatWindowHud != null) |
| | 228 | | { |
| 1 | 229 | | privateChatWindowHud.Initialize(ChatController.i); |
| 1 | 230 | | privateChatWindowHud.OnPressBack -= PrivateChatWindowHud_OnPressBack; |
| 1 | 231 | | privateChatWindowHud.OnPressBack += PrivateChatWindowHud_OnPressBack; |
| | 232 | |
|
| 1 | 233 | | taskbarHud?.AddPrivateChatWindow(privateChatWindowHud); |
| | 234 | | } |
| | 235 | | } |
| | 236 | |
|
| 1 | 237 | | break; |
| | 238 | | case HUDElementID.TASKBAR: |
| 1 | 239 | | if (taskbarHud == null) |
| | 240 | | { |
| 1 | 241 | | CreateHudElement(configuration, hudElementId); |
| | 242 | |
|
| 1 | 243 | | if (taskbarHud != null) |
| | 244 | | { |
| 1 | 245 | | taskbarHud.Initialize( |
| | 246 | | SceneReferences.i.mouseCatcher, |
| | 247 | | ChatController.i, |
| | 248 | | FriendsController.i, |
| | 249 | | DCL.Environment.i.world.sceneController, |
| | 250 | | DCL.Environment.i.world.state); |
| 1 | 251 | | taskbarHud.OnAnyTaskbarButtonClicked -= TaskbarHud_onAnyTaskbarButtonClicked; |
| 1 | 252 | | taskbarHud.OnAnyTaskbarButtonClicked += TaskbarHud_onAnyTaskbarButtonClicked; |
| | 253 | |
|
| 1 | 254 | | if (!string.IsNullOrEmpty(extraPayload)) |
| | 255 | | { |
| 0 | 256 | | var config = JsonUtility.FromJson<TaskbarHUDController.Configuration>(extraPayload); |
| 0 | 257 | | if (config.enableVoiceChat) |
| | 258 | | { |
| 0 | 259 | | taskbarHud.OnAddVoiceChat(); |
| | 260 | | } |
| | 261 | | } |
| | 262 | |
|
| 1 | 263 | | OnTaskbarCreation?.Invoke(); |
| | 264 | | } |
| 0 | 265 | | } |
| | 266 | | else |
| | 267 | | { |
| 0 | 268 | | UpdateHudElement(configuration, hudElementId); |
| | 269 | | } |
| | 270 | |
|
| 0 | 271 | | break; |
| | 272 | | case HUDElementID.MESSAGE_OF_THE_DAY: |
| 1 | 273 | | CreateHudElement(configuration, hudElementId); |
| 1 | 274 | | messageOfTheDayHud?.Initialize(JsonUtility.FromJson<MessageOfTheDayConfig>(extraPayload)); |
| 1 | 275 | | break; |
| | 276 | | case HUDElementID.OPEN_EXTERNAL_URL_PROMPT: |
| 1 | 277 | | CreateHudElement(configuration, hudElementId); |
| 1 | 278 | | break; |
| | 279 | | case HUDElementID.NFT_INFO_DIALOG: |
| 1 | 280 | | CreateHudElement(configuration, hudElementId); |
| 1 | 281 | | break; |
| | 282 | | case HUDElementID.TELEPORT_DIALOG: |
| 1 | 283 | | CreateHudElement(configuration, hudElementId); |
| 1 | 284 | | break; |
| | 285 | | case HUDElementID.CONTROLS_HUD: |
| 1 | 286 | | CreateHudElement(configuration, hudElementId); |
| 1 | 287 | | break; |
| | 288 | | case HUDElementID.HELP_AND_SUPPORT_HUD: |
| 1 | 289 | | CreateHudElement(configuration, hudElementId); |
| 1 | 290 | | settingsPanelHud?.AddHelpAndSupportWindow(helpAndSupportHud); |
| 1 | 291 | | break; |
| | 292 | | case HUDElementID.USERS_AROUND_LIST_HUD: |
| 1 | 293 | | CreateHudElement(configuration, hudElementId); |
| 1 | 294 | | if (usersAroundListHud != null) |
| | 295 | | { |
| 1 | 296 | | minimapHud?.AddUsersAroundIndicator(usersAroundListHud); |
| | 297 | | } |
| | 298 | |
|
| 1 | 299 | | break; |
| | 300 | | case HUDElementID.GRAPHIC_CARD_WARNING: |
| 1 | 301 | | CreateHudElement(configuration, hudElementId); |
| 1 | 302 | | break; |
| | 303 | | case HUDElementID.QUESTS_PANEL: |
| 1 | 304 | | CreateHudElement(configuration, hudElementId); |
| 1 | 305 | | if (configuration.active) |
| 1 | 306 | | questsPanelHUD.Initialize(QuestsController.i); |
| 1 | 307 | | break; |
| | 308 | | case HUDElementID.QUESTS_TRACKER: |
| 1 | 309 | | CreateHudElement(configuration, hudElementId); |
| 1 | 310 | | if (configuration.active) |
| 1 | 311 | | questsTrackerHUD.Initialize(QuestsController.i); |
| 1 | 312 | | break; |
| | 313 | | case HUDElementID.SIGNUP: |
| 1 | 314 | | CreateHudElement(configuration, hudElementId); |
| 1 | 315 | | if (configuration.active) |
| | 316 | | { |
| | 317 | | //Same race condition risks as with the ProfileHUD |
| | 318 | | //TODO Refactor the way AvatarEditor sets its visibility to match our data driven pattern |
| | 319 | | //Then this reference can be removed so we just work with a BaseVariable<bool>. |
| | 320 | | //This refactor applies to the ProfileHUD and the way kernel asks the HUDController during signup |
| 1 | 321 | | signupHUD.Initialize(avatarEditorHud); |
| | 322 | | } |
| 1 | 323 | | break; |
| | 324 | | case HUDElementID.LOADING: |
| 1 | 325 | | CreateHudElement(configuration, hudElementId); |
| 1 | 326 | | if (configuration.active) |
| 1 | 327 | | loadingController.Initialize(); |
| | 328 | | break; |
| | 329 | | case HUDElementID.AVATAR_NAMES: |
| | 330 | | // TODO Remove the HUDElementId once kernel stops sending the Configure HUD message |
| | 331 | | break; |
| | 332 | | } |
| | 333 | |
|
| 32 | 334 | | var hudElement = GetHUDElement(hudElementId); |
| | 335 | |
|
| 32 | 336 | | if (hudElement != null) |
| 26 | 337 | | hudElement.SetVisibility(configuration.active && configuration.visible); |
| 32 | 338 | | } |
| | 339 | |
|
| 0 | 340 | | private void OpenPrivateChatWindow(string targetUserId) { taskbarHud?.OpenPrivateChatTo(targetUserId); } |
| | 341 | |
|
| 0 | 342 | | private void View_OnDeactivatePreview() { playerInfoCardHud?.CloseCard(); } |
| | 343 | |
|
| 0 | 344 | | private void PrivateChatWindowHud_OnPressBack() { taskbarHud?.OpenFriendsWindow(); } |
| | 345 | |
|
| 0 | 346 | | private void TaskbarHud_onAnyTaskbarButtonClicked() { playerInfoCardHud?.CloseCard(); } |
| | 347 | |
|
| | 348 | | public void CreateHudElement(HUDConfiguration config, HUDElementID id) |
| | 349 | | { |
| 26 | 350 | | bool controllerCreated = hudElements.ContainsKey(id); |
| | 351 | |
|
| 26 | 352 | | if (config.active && !controllerCreated) |
| | 353 | | { |
| 26 | 354 | | hudElements.Add(id, hudFactory.CreateHUD(id)); |
| | 355 | |
|
| 26 | 356 | | if (VERBOSE) |
| 0 | 357 | | Debug.Log($"Adding {id} .. type {hudElements[id].GetType().Name}"); |
| | 358 | | } |
| 26 | 359 | | } |
| | 360 | |
|
| | 361 | | public void UpdateHudElement(HUDConfiguration config, HUDElementID id) |
| | 362 | | { |
| 0 | 363 | | if (!hudElements.ContainsKey(id)) |
| 0 | 364 | | return; |
| | 365 | |
|
| 0 | 366 | | if (VERBOSE) |
| 0 | 367 | | Debug.Log($"Updating {id}, type {hudElements[id].GetType().Name}, active: {config.active} visible: {config.v |
| | 368 | |
|
| 0 | 369 | | hudElements[id].SetVisibility(config.visible); |
| 0 | 370 | | } |
| | 371 | | public void Cleanup() |
| | 372 | | { |
| 803 | 373 | | toggleUIVisibilityTrigger.OnTriggered -= ToggleUIVisibility_OnTriggered; |
| 803 | 374 | | CommonScriptableObjects.allUIHidden.OnChange -= AllUIHiddenOnOnChange; |
| | 375 | |
|
| 803 | 376 | | if (worldChatWindowHud != null) |
| | 377 | | { |
| 1 | 378 | | worldChatWindowHud.OnPressPrivateMessage -= OpenPrivateChatWindow; |
| 1 | 379 | | worldChatWindowHud.view.OnDeactivatePreview -= View_OnDeactivatePreview; |
| | 380 | | } |
| | 381 | |
|
| 803 | 382 | | if (privateChatWindowHud != null) |
| 1 | 383 | | privateChatWindowHud.OnPressBack -= PrivateChatWindowHud_OnPressBack; |
| | 384 | |
|
| 803 | 385 | | if (friendsHud != null) |
| 1 | 386 | | friendsHud.OnPressWhisper -= OpenPrivateChatWindow; |
| | 387 | |
|
| 803 | 388 | | if (taskbarHud != null) |
| 1 | 389 | | taskbarHud.OnAnyTaskbarButtonClicked -= TaskbarHud_onAnyTaskbarButtonClicked; |
| | 390 | |
|
| 803 | 391 | | UserContextMenu.OnOpenPrivateChatRequest -= OpenPrivateChatWindow; |
| | 392 | |
|
| 1658 | 393 | | foreach (var kvp in hudElements) |
| | 394 | | { |
| 26 | 395 | | kvp.Value?.Dispose(); |
| | 396 | | } |
| | 397 | |
|
| 803 | 398 | | hudElements.Clear(); |
| 803 | 399 | | } |
| | 400 | |
|
| | 401 | | public IHUD GetHUDElement(HUDElementID id) |
| | 402 | | { |
| 3531 | 403 | | if (!hudElements.ContainsKey(id)) |
| 3434 | 404 | | return null; |
| | 405 | |
|
| 97 | 406 | | return hudElements[id]; |
| | 407 | | } |
| | 408 | |
|
| | 409 | | public static bool IsHUDElementDeprecated(HUDElementID element) |
| | 410 | | { |
| 32 | 411 | | Type enumType = typeof(HUDElementID); |
| 32 | 412 | | var enumName = enumType.GetEnumName(element); |
| 32 | 413 | | var fieldInfo = enumType.GetField(enumName); |
| 32 | 414 | | return Attribute.IsDefined(fieldInfo, typeof(ObsoleteAttribute)); |
| | 415 | | } |
| | 416 | |
|
| | 417 | | #if UNITY_EDITOR |
| | 418 | | [ContextMenu("Trigger fake PlayerInfoCard")] |
| | 419 | | public void TriggerFakePlayerInfoCard() |
| | 420 | | { |
| 0 | 421 | | var newModel = ownUserProfile.CloneModel(); |
| 0 | 422 | | newModel.name = "FakePassport"; |
| 0 | 423 | | newModel.description = "Fake Description for Testing"; |
| 0 | 424 | | newModel.userId = "test-id"; |
| 0 | 425 | | newModel.inventory = new[] |
| | 426 | | { |
| | 427 | | "dcl://halloween_2019/machete_headband_top_head", |
| | 428 | | "dcl://halloween_2019/bee_suit_upper_body", |
| | 429 | | "dcl://halloween_2019/bride_of_frankie_upper_body", |
| | 430 | | "dcl://halloween_2019/creepy_nurse_upper_body", |
| | 431 | | }; |
| | 432 | |
|
| 0 | 433 | | UserProfileController.i.AddUserProfileToCatalog(newModel); |
| 0 | 434 | | Resources.Load<StringVariable>("CurrentPlayerInfoCardId").Set(newModel.userId); |
| 0 | 435 | | } |
| | 436 | | #endif |
| 1596 | 437 | | public void Dispose() { Cleanup(); } |
| | 438 | | } |