12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- using System.Collections.Generic;
- using FairyGUI;
- using UI.FieldGuide;
- namespace GFGGame
- {
- public class TravelGuideView : BaseWindow
- {
- private UI_TravelGuideUI _ui;
- public override void Dispose()
- {
- if (_ui != null)
- {
- _ui.Dispose();
- _ui = null;
- }
- base.Dispose();
- }
- protected override void OnInit()
- {
- base.OnInit();
- packageName = UI_TravelGuideUI.PACKAGE_NAME;
- _ui = UI_TravelGuideUI.Create();
- this.viewCom = _ui.target;
- isfullScreen = true;
- isReturnView = true;
- _ui.m_btnBack.onClick.Add(OnClickBtnBack);
- _ui.m_list.itemRenderer = RenderListItem;
- _ui.m_list.onClickItem.Add(OnListItemClick);
- _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("tjbg");
- }
- protected override void AddEventListener()
- {
- base.AddEventListener();
- }
- protected override void OnShown()
- {
- base.OnShown();
- TravelLoactionCfg[] cfgs = TravelLoactionCfgArray.Instance.dataArray;
- _ui.m_list.numItems = TravelGuideCfgArray.Instance.dataArray.Length;
- }
- protected override void OnHide()
- {
- base.OnHide();
- if (_ui.m_list.numItems > 0) _ui.m_list.ScrollToView(0);
- }
- protected override void RemoveEventListener()
- {
- base.RemoveEventListener();
- }
- private void OnClickBtnBack()
- {
- ViewManager.GoBackFrom(typeof(TravelGuideView).FullName);
- }
- private void RenderListItem(int index, GObject obj)
- {
- TravelGuideCfg cfg = TravelGuideCfgArray.Instance.dataArray[index];
- UI_ListTravelAreaItem item = UI_ListTravelAreaItem.Proxy(obj);
- item.m_loaIcon.url = string.Format("ui://FieldGuide/{0}", cfg.res);
- item.target.data = cfg;
- RedDotController.Instance.SetComRedDot(item.target, RedDotDataManager.Instance.GetTravelGuideAreaRed(cfg.id));
- UI_ListTravelAreaItem.ProxyEnd();
- }
- private void OnListItemClick(EventContext context)
- {
- GObject obj = context.data as GObject;
- TravelGuideCfg cfg = obj.data as TravelGuideCfg;
- ViewManager.Show<TravelShowView>(cfg);
- }
- }
- }
|