123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- 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<ClanPanel> (Resources.Load<GameObject> ("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;
- }
- }
|