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