TravelGuideView.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using System.Collections.Generic;
  2. using FairyGUI;
  3. using UI.FieldGuide;
  4. namespace GFGGame
  5. {
  6. public class TravelGuideView : BaseWindow
  7. {
  8. private UI_TravelGuideUI _ui;
  9. public override void Dispose()
  10. {
  11. if (_ui != null)
  12. {
  13. _ui.Dispose();
  14. _ui = null;
  15. }
  16. base.Dispose();
  17. }
  18. protected override void OnInit()
  19. {
  20. base.OnInit();
  21. packageName = UI_TravelGuideUI.PACKAGE_NAME;
  22. _ui = UI_TravelGuideUI.Create();
  23. this.viewCom = _ui.target;
  24. isfullScreen = true;
  25. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  26. _ui.m_list.itemRenderer = RenderListItem;
  27. _ui.m_list.onClickItem.Add(OnListItemClick);
  28. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("xqfs_bj");
  29. }
  30. protected override void AddEventListener()
  31. {
  32. base.AddEventListener();
  33. }
  34. protected override void OnShown()
  35. {
  36. base.OnShown();
  37. TravelLoactionCfg[] cfgs = TravelLoactionCfgArray.Instance.dataArray;
  38. _ui.m_list.numItems = TravelGuideCfgArray.Instance.dataArray.Length;
  39. }
  40. protected override void OnHide()
  41. {
  42. base.OnHide();
  43. if (_ui.m_list.numItems > 0) _ui.m_list.ScrollToView(0);
  44. }
  45. protected override void RemoveEventListener()
  46. {
  47. base.RemoveEventListener();
  48. }
  49. private void OnClickBtnBack()
  50. {
  51. ViewManager.GoBackFrom(typeof(TravelGuideView).FullName);
  52. }
  53. private void RenderListItem(int index, GObject obj)
  54. {
  55. TravelGuideCfg cfg = TravelGuideCfgArray.Instance.dataArray[index];
  56. UI_ListTravelAreaItem item = UI_ListTravelAreaItem.Proxy(obj);
  57. item.m_loaIcon.url = string.Format("ui://FieldGuide/{0}", cfg.res);
  58. item.target.data = cfg;
  59. RedDotController.Instance.SetComRedDot(item.target, RedDotDataManager.Instance.GetTravelGuideAreaRed(cfg.id));
  60. UI_ListTravelAreaItem.ProxyEnd();
  61. }
  62. private void OnListItemClick(EventContext context)
  63. {
  64. GObject obj = context.data as GObject;
  65. TravelGuideCfg cfg = obj.data as TravelGuideCfg;
  66. ViewManager.Show<TravelShowView>(cfg, new object[] { typeof(TravelGuideView).FullName, this.viewData });
  67. }
  68. }
  69. }