public static PrivateChatWindowHUDView Create(PrivateChatWindowHUDController controller) { var view = Instantiate(Resources.Load <GameObject>(VIEW_PATH)).GetComponent <PrivateChatWindowHUDView>(); view.Initialize(controller); return(view); }
private void Initialize(PrivateChatWindowHUDController controller) { this.controller = controller; this.minimizeButton.onClick.AddListener(OnMinimizeButtonPressed); this.closeButton.onClick.AddListener(OnCloseButtonPressed); this.backButton.onClick.AddListener(() => { OnPressBack?.Invoke(); }); }
protected override IEnumerator SetUp() { yield return(base.SetUp()); UserProfileController.i.ClearProfilesCatalog(); var ownProfile = UserProfile.GetOwnUserProfile(); ownProfileModel = new UserProfileModel(); ownProfileModel.userId = "my-user-id"; ownProfileModel.name = "NO_USER"; ownProfile.UpdateData(ownProfileModel, false); testProfileModel = new UserProfileModel(); testProfileModel.userId = "my-user-id-2"; testProfileModel.name = "TEST_USER"; UserProfileController.i.AddUserProfileToCatalog(testProfileModel); //NOTE(Brian): This profile is added by the LoadProfile message in the normal flow. // Adding this here because its used by the chat flow in ChatMessageToChatEntry. UserProfileController.i.AddUserProfileToCatalog(ownProfileModel); controller = new PrivateChatWindowHUDController(); chatController = new ChatController_Mock(); controller.Initialize(chatController); controller.Configure(testProfileModel.userId); controller.SetVisibility(true); this.view = controller.view; Assert.IsTrue(view != null, "World chat hud view is null?"); Assert.IsTrue(controller != null, "World chat hud controller is null?"); yield break; }
private void InitializeChatWindowController(IChatController chatController) { controller = new PrivateChatWindowHUDController(); controller.Initialize(chatController); controller.Configure(testProfileModel.userId); controller.SetVisibility(true); view = controller.view; }
public void AddPrivateChatWindow(PrivateChatWindowHUDController controller) { if (controller == null || controller.view == null) { Debug.LogWarning("AddPrivateChatWindow >>> Private Chat Window doesn't exist yet!"); return; } if (controller.view.transform.parent == view.windowContainer) { return; } controller.view.transform.SetParent(view.windowContainer, false); privateChatWindowHud = controller; privateChatWindowHud.view.OnMinimize += () => { ChatHeadButton btn = view.GetButtonList().FirstOrDefault( (x) => x is ChatHeadButton && (x as ChatHeadButton).profile.userId == privateChatWindowHud.conversationUserId) as ChatHeadButton; if (btn != null) { btn.SetToggleState(false, false); } if (!AnyWindowsDifferentThanChatIsOpen()) { worldChatWindowHud.MarkWorldChatMessagesAsRead(); } }; privateChatWindowHud.view.OnClose += () => { ChatHeadButton btn = view.GetButtonList().FirstOrDefault( (x) => x is ChatHeadButton && (x as ChatHeadButton).profile.userId == privateChatWindowHud.conversationUserId) as ChatHeadButton; if (btn != null) { btn.SetToggleState(false, false); view.chatHeadsGroup.RemoveChatHead(btn); } if (!AnyWindowsDifferentThanChatIsOpen()) { worldChatWindowHud.MarkWorldChatMessagesAsRead(); } }; }
public void ToggleWindowsProperly() { privateChatController = new PrivateChatWindowHUDController(); privateChatController.Initialize(chatController); controller.AddPrivateChatWindow(privateChatController); const string badPositionMsg = "Anchored position should be zero or it won't be correctly placed inside the taskbar"; const string badPivotMsg = "Pivot should be zero or it won't be correctly placed inside the taskbar"; RectTransform rt = privateChatController.view.transform as RectTransform; Assert.AreEqual(Vector2.zero, rt.anchoredPosition, badPositionMsg); Assert.AreEqual(Vector2.zero, rt.pivot, badPivotMsg); worldChatWindowController = new WorldChatWindowHUDController(); worldChatWindowController.Initialize(chatController, null); controller.AddWorldChatWindow(worldChatWindowController); rt = worldChatWindowController.view.transform as RectTransform; Assert.AreEqual(Vector2.zero, rt.anchoredPosition, badPositionMsg); Assert.AreEqual(Vector2.zero, rt.pivot, badPivotMsg); friendsHudController = new FriendsHUDController(); friendsHudController.Initialize(friendsController, UserProfile.GetOwnUserProfile()); controller.AddFriendsWindow(friendsHudController); rt = friendsHudController.view.transform as RectTransform; Assert.AreEqual(Vector2.zero, rt.anchoredPosition, badPositionMsg); Assert.AreEqual(Vector2.zero, rt.pivot, badPivotMsg); TestHelpers_Friends.FakeAddFriend(friendsController, friendsHudController.view, "test-1"); TestHelpers_Chat.FakePrivateChatMessageFrom(chatController, "test-1", "test message!"); var buttonList = view.GetButtonList(); Assert.AreEqual(8, buttonList.Count, "Chat head is missing when receiving a private message?"); Assert.IsFalse(view.chatButton.toggledOn); Assert.IsTrue(buttonList[2] is ChatHeadButton); ChatHeadButton headButton = buttonList[2] as ChatHeadButton; Assert.IsFalse(headButton.toggledOn); //NOTE(Brian): Toggle chat head on and test it works as intended headButton.toggleButton.onClick.Invoke(); Assert.IsTrue(headButton.lineOnIndicator.isVisible); Assert.IsFalse(view.friendsButton.lineOnIndicator.isVisible); Assert.IsFalse(view.chatButton.lineOnIndicator.isVisible); Assert.IsTrue(controller.privateChatWindowHud.view.gameObject.activeInHierarchy); //NOTE(Brian): Toggle friends window on and test all other windows are untoggled view.friendsButton.toggleButton.onClick.Invoke(); Assert.IsFalse(controller.privateChatWindowHud.view.gameObject.activeInHierarchy); Assert.IsFalse(headButton.lineOnIndicator.isVisible); Assert.IsTrue(view.friendsButton.lineOnIndicator.isVisible); Assert.IsFalse(view.chatButton.lineOnIndicator.isVisible); //NOTE(Brian): Toggle friends window off and test all other windows are untoggled view.friendsButton.toggleButton.onClick.Invoke(); Assert.IsFalse(controller.privateChatWindowHud.view.gameObject.activeInHierarchy); Assert.IsFalse(headButton.lineOnIndicator.isVisible); Assert.IsFalse(view.friendsButton.lineOnIndicator.isVisible); //NOTE(Brian): Toggle friends on, and then chat button on. Then check if world chat window is showing up. view.friendsButton.toggleButton.onClick.Invoke(); view.chatButton.toggleButton.onClick.Invoke(); Assert.IsTrue(controller.worldChatWindowHud.view.gameObject.activeInHierarchy); Assert.IsFalse(controller.friendsHud.view.gameObject.activeInHierarchy); Assert.IsFalse(view.friendsButton.lineOnIndicator.isVisible); }
public virtual IHUD CreateHUD(HUDElementID hudElementId) { IHUD hudElement = null; switch (hudElementId) { case HUDElementID.NONE: break; case HUDElementID.MINIMAP: hudElement = new MinimapHUDController(); break; case HUDElementID.PROFILE_HUD: hudElement = new ProfileHUDController(); break; case HUDElementID.NOTIFICATION: hudElement = new NotificationHUDController(); break; case HUDElementID.AVATAR_EDITOR: hudElement = new AvatarEditorHUDController(); break; case HUDElementID.SETTINGS_PANEL: hudElement = new SettingsPanelHUDController(); break; case HUDElementID.EXPRESSIONS: hudElement = new ExpressionsHUDController(); break; case HUDElementID.PLAYER_INFO_CARD: hudElement = new PlayerInfoCardHUDController(); break; case HUDElementID.AIRDROPPING: hudElement = new AirdroppingHUDController(); break; case HUDElementID.TERMS_OF_SERVICE: hudElement = new TermsOfServiceHUDController(); break; case HUDElementID.WORLD_CHAT_WINDOW: hudElement = new WorldChatWindowHUDController(); break; case HUDElementID.FRIENDS: hudElement = new FriendsHUDController(); break; case HUDElementID.PRIVATE_CHAT_WINDOW: hudElement = new PrivateChatWindowHUDController(); break; case HUDElementID.TASKBAR: hudElement = new TaskbarHUDController(); break; case HUDElementID.MESSAGE_OF_THE_DAY: hudElement = new WelcomeHUDController(); break; case HUDElementID.OPEN_EXTERNAL_URL_PROMPT: hudElement = new ExternalUrlPromptHUDController(); break; case HUDElementID.NFT_INFO_DIALOG: hudElement = new NFTPromptHUDController(); break; case HUDElementID.TELEPORT_DIALOG: hudElement = new TeleportPromptHUDController(); break; case HUDElementID.CONTROLS_HUD: hudElement = new ControlsHUDController(); break; case HUDElementID.EXPLORE_HUD: hudElement = new ExploreHUDController(); break; case HUDElementID.HELP_AND_SUPPORT_HUD: hudElement = new HelpAndSupportHUDController(); break; case HUDElementID.USERS_AROUND_LIST_HUD: hudElement = new UsersAroundListHUDController(); break; case HUDElementID.GRAPHIC_CARD_WARNING: hudElement = new GraphicCardWarningHUDController(); break; case HUDElementID.BUILDER_IN_WORLD_MAIN: hudElement = new BuildModeHUDController(); break; case HUDElementID.QUESTS_PANEL: hudElement = new QuestsPanelHUDController(); break; case HUDElementID.QUESTS_TRACKER: hudElement = new QuestsTrackerHUDController(); break; case HUDElementID.SIGNUP: hudElement = new SignupHUDController(); break; case HUDElementID.BUILDER_PROJECTS_PANEL: hudElement = new BuilderProjectsPanelController(); break; case HUDElementID.LOADING: hudElement = new LoadingHUDController(); break; case HUDElementID.AVATAR_NAMES: hudElement = new AvatarNamesHUDController(); break; } return(hudElement); }