| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- using System.Collections.Generic;
- using cfg.GfgCfg;
- 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 = CommonDataManager.Tables.TblTravelGuideCfg.DataList.Count;
- }
- 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 = CommonDataManager.Tables.TblTravelGuideCfg.DataList[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);
- }
- }
- }
|