ChatPanel.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System.Collections;
  4. public class ChatPanel : PopUpPanel
  5. {
  6. public Text titleTxt;
  7. public ViewStack viewStack;
  8. public ChatView chatView;
  9. public FriendFindView friendFindView;
  10. public Button profileBtn;
  11. void Awake()
  12. {
  13. chatView.titleTxt = titleTxt;
  14. }
  15. override protected void Remove()
  16. {
  17. base.Remove ();
  18. currentPanel = null;
  19. }
  20. public static bool IsShown()
  21. {
  22. return currentPanel != null && currentPanel.gameObject.activeSelf;
  23. }
  24. private static ChatPanel currentPanel;
  25. public static ChatPanel Show()
  26. {
  27. if (currentPanel != null) {
  28. currentPanel.gameObject.SetActive (true);
  29. PopUpManager.AddToMainCanvas (currentPanel.gameObject);
  30. }
  31. else
  32. currentPanel = PopUpManager.AddPopUp<ChatPanel> (Resources.Load<GameObject> ("Prefabs/UI/ChatPanel/ChatPanel"), null, true);
  33. currentPanel.Open ();
  34. return currentPanel;
  35. }
  36. public static ChatPanel ShowChat(int friendId)
  37. {
  38. if (!IsShown())
  39. ChatPanel.Show ();
  40. currentPanel.viewStack.viewIndex = 0;
  41. currentPanel.chatView.data = friendId;
  42. currentPanel.profileBtn.gameObject.SetActive (true);
  43. return currentPanel;
  44. }
  45. public static ChatPanel ShowFindFriend()
  46. {
  47. if (!IsShown())
  48. ChatPanel.Show ();
  49. currentPanel.profileBtn.gameObject.SetActive (false);
  50. currentPanel.viewStack.viewIndex = 1;
  51. currentPanel.titleTxt.text = Language.GetStr ("ChatPanel", "findPlayer");
  52. return currentPanel;
  53. }
  54. public static void Hide()
  55. {
  56. if (currentPanel != null)
  57. currentPanel.Close ();
  58. }
  59. }