1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- using UnityEngine;
- using UnityEngine.UI;
- using System.Collections;
- public class ChatPanel : PopUpPanel
- {
- public Text titleTxt;
- public ViewStack viewStack;
- public ChatView chatView;
- public FriendFindView friendFindView;
- public Button profileBtn;
- void Awake()
- {
- chatView.titleTxt = titleTxt;
- }
- override protected void Remove()
- {
- base.Remove ();
- currentPanel = null;
- }
- public static bool IsShown()
- {
- return currentPanel != null && currentPanel.gameObject.activeSelf;
- }
- private static ChatPanel currentPanel;
- public static ChatPanel Show()
- {
- if (currentPanel != null) {
- currentPanel.gameObject.SetActive (true);
- PopUpManager.AddToMainCanvas (currentPanel.gameObject);
- }
- else
- currentPanel = PopUpManager.AddPopUp<ChatPanel> (Resources.Load<GameObject> ("Prefabs/UI/ChatPanel/ChatPanel"), null, true);
- currentPanel.Open ();
- return currentPanel;
- }
- public static ChatPanel ShowChat(int friendId)
- {
- if (!IsShown())
- ChatPanel.Show ();
- currentPanel.viewStack.viewIndex = 0;
- currentPanel.chatView.data = friendId;
- currentPanel.profileBtn.gameObject.SetActive (true);
- return currentPanel;
- }
- public static ChatPanel ShowFindFriend()
- {
- if (!IsShown())
- ChatPanel.Show ();
- currentPanel.profileBtn.gameObject.SetActive (false);
- currentPanel.viewStack.viewIndex = 1;
- currentPanel.titleTxt.text = Language.GetStr ("ChatPanel", "findPlayer");
- return currentPanel;
- }
- public static void Hide()
- {
- if (currentPanel != null)
- currentPanel.Close ();
- }
- }
|