TravelGuideView.cs 2.4 KB

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