ClanPanel.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System.Collections;
  4. public class ClanPanel : PopUpPanel
  5. {
  6. public NavTab navTab;
  7. public ViewStack viewStack;
  8. public ClanInfoViewStack infoViewStack;
  9. private UserData myUserData;
  10. void Awake()
  11. {
  12. myUserData = Session.GetInstance ().myUserData;
  13. RefreshTitle ();
  14. navTab.OnNavTabChanged = OnNavTabChanged;
  15. }
  16. private void OnNavTabChanged(int index)
  17. {
  18. if(index == 0)
  19. {
  20. infoViewStack.SetClanId (myUserData.clanId);
  21. }
  22. }
  23. private void RefreshTitle()
  24. {
  25. if (myUserData == null)
  26. return;
  27. if (myUserData.clanId > 0) {
  28. navTab.SetTitles (new string[]{ Language.GetStr ("ClanPanel", "tab2Btn0"), Language.GetStr ("ClanPanel", "tab2Btn1") });
  29. } else {
  30. navTab.SetTitles (new string[]{ Language.GetStr ("ClanPanel", "tab1Btn0"), Language.GetStr ("ClanPanel", "tab1Btn1") });
  31. }
  32. }
  33. public void ClanCreated()
  34. {
  35. }
  36. override protected void Remove()
  37. {
  38. base.Remove ();
  39. currentPanel = null;
  40. }
  41. public static bool IsShown()
  42. {
  43. return currentPanel != null && currentPanel.gameObject.activeSelf;
  44. }
  45. private static ClanPanel currentPanel;
  46. public static ClanPanel Show()
  47. {
  48. if (currentPanel != null) {
  49. currentPanel.gameObject.SetActive (true);
  50. PopUpManager.AddToMainCanvas (currentPanel.gameObject);
  51. }
  52. else
  53. currentPanel = PopUpManager.AddPopUp<ClanPanel> (Resources.Load<GameObject> ("Prefabs/UI/ClanPanel/ClanPanel"), null, true);
  54. currentPanel.Open ();
  55. return currentPanel;
  56. }
  57. public static ClanPanel ShowEdit()
  58. {
  59. if (!IsShown())
  60. ClanPanel.Show ();
  61. currentPanel.navTab.UnSelected ();
  62. currentPanel.viewStack.viewIndex = 0;
  63. currentPanel.infoViewStack.SetClanId (0);
  64. return currentPanel;
  65. }
  66. public static ClanPanel ShowClanInfo(int clanId)
  67. {
  68. if (!IsShown())
  69. ClanPanel.Show ();
  70. if (clanId == Session.GetInstance ().myUserData.clanId) {
  71. currentPanel.navTab.UnSelected ();
  72. currentPanel.navTab.navTabIndex = 0;
  73. currentPanel.infoViewStack.Refresh();
  74. } else {
  75. currentPanel.navTab.UnSelected ();
  76. currentPanel.viewStack.viewIndex = 0;
  77. currentPanel.infoViewStack.SetClanId (clanId);
  78. }
  79. return currentPanel;
  80. }
  81. }