PersonalPhotoView.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. using UI.RoleInfo;
  2. using FairyGUI;
  3. namespace GFGGame
  4. {
  5. public class PersonalPhotoView : BaseWindow
  6. {
  7. private UI_PersonalPhotoUI _ui;
  8. private int _showIndex = 0;
  9. private long _showPictureId = 0;
  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_PersonalPhotoUI.PACKAGE_NAME;
  23. _ui = UI_PersonalPhotoUI.Create();
  24. this.viewCom = _ui.target;
  25. isfullScreen = true;
  26. _ui.m_btnback.onClick.Add(OnBtnBackClick);
  27. _ui.m_list.SetVirtual();
  28. _ui.m_list.itemRenderer = RenderListItem;
  29. _ui.m_list.onClickItem.Add(OnListItemClick);
  30. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("xc_bjbj");
  31. }
  32. protected override void OnShown()
  33. {
  34. base.OnShown();
  35. _showIndex = (int)this.viewData;
  36. _showPictureId = RoleDataManager.photoDatas[_showIndex];
  37. _ui.m_list.numItems = PoemPhotoDataManager.Instance.PersonalPhotoInfos.Count;
  38. _ui.m_grpNothing.visible = _ui.m_list.numItems == 0;
  39. }
  40. protected override void OnHide()
  41. {
  42. base.OnHide();
  43. }
  44. private void OnBtnBackClick()
  45. {
  46. ViewManager.GoBackFrom(typeof(PersonalPhotoView).FullName);
  47. }
  48. private void RenderListItem(int index, GObject obj)
  49. {
  50. PoemPhotoData photoData = PoemPhotoDataManager.Instance.PersonalPhotoInfos[index];
  51. UI_ListPhotoItem1 item = UI_ListPhotoItem1.Proxy(obj);
  52. item.m_comIcon.m_loaIcon.texture = photoData.Ntexture;
  53. bool curSelect = photoData.PictureId == _showPictureId;
  54. bool otherSelect = !curSelect && RoleDataManager.photoDatas.IndexOf(photoData.PictureId) >= 0;
  55. item.m_imgSelect.visible = curSelect;
  56. item.m_imgOtherSelect.visible = otherSelect;
  57. item.m_txtTime.text = TimeUtil.FormattingTime1(photoData.CreationTime);
  58. item.target.data = photoData.PictureId;
  59. UI_ListPhotoItem1.ProxyEnd();
  60. }
  61. private async void OnListItemClick(EventContext context)
  62. {
  63. GObject obj = context.data as GObject;
  64. long selectPictureId = (long)obj.data;
  65. if (selectPictureId == _showPictureId)//删除:点击相同id照片
  66. {
  67. RoleDataManager.photoDatas[_showIndex] = 0;
  68. }
  69. else
  70. {
  71. if (_showPictureId == 0)//添加:原来未展示图片
  72. {
  73. if (RoleDataManager.photoDatas.IndexOf(selectPictureId) < 0)//选中的图片未被选中
  74. {
  75. RoleDataManager.photoDatas[_showIndex] = selectPictureId;
  76. }
  77. }
  78. else//原来有展示图片
  79. {
  80. if (RoleDataManager.photoDatas.IndexOf(selectPictureId) < 0)//更换:选中的图片未被选中
  81. {
  82. RoleDataManager.photoDatas[_showIndex] = selectPictureId;
  83. }
  84. else
  85. {
  86. int selectPictureIndex = RoleDataManager.photoDatas.IndexOf(selectPictureId);
  87. RoleDataManager.photoDatas[_showIndex] = selectPictureId;
  88. RoleDataManager.photoDatas[selectPictureIndex] = _showPictureId;
  89. }
  90. }
  91. }
  92. bool result = await RoleInfoSProxy.ReqModifyShowPhoto(RoleDataManager.photoDatas);
  93. if (result)
  94. {
  95. ViewManager.GoBackFrom(typeof(PersonalPhotoView).FullName);
  96. }
  97. }
  98. }
  99. }