using UnityEngine; using UnityEngine.UI; using System.Collections; public class ClanPanel : PopUpPanel { public NavTab navTab; public ViewStack viewStack; public ClanInfoViewStack infoViewStack; private UserData myUserData; void Awake() { myUserData = Session.GetInstance ().myUserData; RefreshTitle (); navTab.OnNavTabChanged = OnNavTabChanged; } private void OnNavTabChanged(int index) { if(index == 0) { infoViewStack.SetClanId (myUserData.clanId); } } private void RefreshTitle() { if (myUserData == null) return; if (myUserData.clanId > 0) { navTab.SetTitles (new string[]{ Language.GetStr ("ClanPanel", "tab2Btn0"), Language.GetStr ("ClanPanel", "tab2Btn1") }); } else { navTab.SetTitles (new string[]{ Language.GetStr ("ClanPanel", "tab1Btn0"), Language.GetStr ("ClanPanel", "tab1Btn1") }); } } public void ClanCreated() { } override protected void Remove() { base.Remove (); currentPanel = null; } public static bool IsShown() { return currentPanel != null && currentPanel.gameObject.activeSelf; } private static ClanPanel currentPanel; public static ClanPanel Show() { if (currentPanel != null) { currentPanel.gameObject.SetActive (true); PopUpManager.AddToMainCanvas (currentPanel.gameObject); } else currentPanel = PopUpManager.AddPopUp (Resources.Load ("Prefabs/UI/ClanPanel/ClanPanel"), null, true); currentPanel.Open (); return currentPanel; } public static ClanPanel ShowEdit() { if (!IsShown()) ClanPanel.Show (); currentPanel.navTab.UnSelected (); currentPanel.viewStack.viewIndex = 0; currentPanel.infoViewStack.SetClanId (0); return currentPanel; } public static ClanPanel ShowClanInfo(int clanId) { if (!IsShown()) ClanPanel.Show (); if (clanId == Session.GetInstance ().myUserData.clanId) { currentPanel.navTab.UnSelected (); currentPanel.navTab.navTabIndex = 0; currentPanel.infoViewStack.Refresh(); } else { currentPanel.navTab.UnSelected (); currentPanel.viewStack.viewIndex = 0; currentPanel.infoViewStack.SetClanId (clanId); } return currentPanel; } }