PoemPhotoView.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753
  1. using System.Collections.Generic;
  2. using ET;
  3. using FairyGUI;
  4. using UI.Poem;
  5. using UnityEngine;
  6. namespace GFGGame
  7. {
  8. public struct SavePhotoList
  9. {
  10. public int pageIndex;
  11. public List<PoemPhotoData> photoInfos;
  12. public List<long> listChoose;
  13. }
  14. public class PoemPhotoView : BaseWindow
  15. {
  16. private UI_PoemPhotoUI _ui;
  17. private List<long> _listChoose = new List<long>();
  18. private List<PoemPhotoData> _photoInfos;
  19. private int _sourceType = 0;
  20. public override void Dispose()
  21. {
  22. if (_ui != null)
  23. {
  24. _ui.Dispose();
  25. _ui = null;
  26. }
  27. base.Dispose();
  28. }
  29. protected override void OnInit()
  30. {
  31. base.OnInit();
  32. packageName = UI_PoemPhotoUI.PACKAGE_NAME;
  33. _ui = UI_PoemPhotoUI.Create();
  34. this.viewCom = _ui.target;
  35. isfullScreen = true;
  36. isReturnView = true;
  37. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("tjbg");
  38. _ui.m_list.SetVirtual();
  39. _ui.m_list.itemRenderer = RenderListItem;
  40. _ui.m_listTravel.SetVirtual();
  41. _ui.m_listTravel.itemRenderer = RenderListTravelItem;
  42. _ui.m_listCompetion.itemRenderer = RenderMatchingListItem;
  43. _ui.m_btnRule.onClick.Add(RuleController.ShowRuleView);
  44. _ui.m_btnRule.data = 300018;
  45. _ui.m_btnback.onClick.Add(OnBtnBackClick);
  46. _ui.m_btnDelete.onClick.Add(OnBtnDeleteClick);
  47. _ui.m_btnSave.onClick.Add(OnBtnSaveClick);
  48. _ui.m_btnConfirmDelete.onClick.Add(OnBtnConfirmDeleteClick);
  49. _ui.m_c1.onChanged.Add(OnBtnTabChange);
  50. _ui.m_btnChooseAll.onClick.Add(OnClickBtnChooseAll);
  51. _ui.m_btnConfirmSave.onClick.Add(OnClickConfirmSave);
  52. InitTypeList();
  53. }
  54. protected override void AddEventListener()
  55. {
  56. base.AddEventListener();
  57. EventAgent.AddEventListener(ConstMessage.POEM_PHOTO_INFOS_CHANGE, OnBtnTabChange);
  58. }
  59. protected override void OnShown()
  60. {
  61. base.OnShown();
  62. if (this.viewData != null)
  63. {
  64. _ui.m_c1.selectedIndex = (int)this.viewData;
  65. }
  66. //_ui.m_c1.selectedIndex = (this.viewData == null) ? (int)PictureSourceType.PersonalAlbum : (int)this.viewData;
  67. OnBtnTabChange();
  68. // UpdateView();
  69. Timers.inst.AddUpdate(CheckGuide);
  70. }
  71. protected override void OnHide()
  72. {
  73. base.OnHide();
  74. _ui.m_c2.selectedIndex = 0;
  75. _listChoose.Clear();
  76. Timers.inst.Remove(CheckGuide);
  77. }
  78. protected override void RemoveEventListener()
  79. {
  80. base.RemoveEventListener();
  81. EventAgent.RemoveEventListener(ConstMessage.POEM_PHOTO_INFOS_CHANGE, OnBtnTabChange);
  82. }
  83. private void OnBtnBackClick()
  84. {
  85. if (_ui.m_c2.selectedIndex == 1)
  86. {
  87. _ui.m_c2.selectedIndex = 0;
  88. }
  89. else
  90. {
  91. ViewManager.GoBackFrom(typeof(PoemPhotoView).FullName);
  92. if (_ui.m_list.numItems > 0) _ui.m_list.ScrollToView(0);
  93. _ui.m_c1.selectedIndex = 0;
  94. }
  95. _ui.m_c2.selectedIndex = 0;
  96. }
  97. private void OnBtnDeleteClick()
  98. {
  99. if (_ui.m_c1.selectedIndex == 0 && GetEnablePhotoNum(true) == 0)
  100. {
  101. PromptController.Instance.ShowFloatTextPrompt("暂无照片可删除");
  102. return;
  103. }
  104. if (_ui.m_c1.selectedIndex == 1 && GetEnablePhotoNum(true) == 0)
  105. {
  106. PromptController.Instance.ShowFloatTextPrompt("暂无明信片可删除");
  107. return;
  108. }
  109. if (_ui.m_c1.selectedIndex == 2 && GetEnablePhotoNum(true) == 0)
  110. {
  111. PromptController.Instance.ShowFloatTextPrompt("暂无图片可删除");
  112. return;
  113. }
  114. _ui.m_c2.selectedIndex = 1;
  115. _ui.m_btnChooseAll.selected = false;
  116. }
  117. private void OnBtnSaveClick()
  118. {
  119. if (_ui.m_c1.selectedIndex == 0 && _photoInfos.Count == 0)
  120. {
  121. PromptController.Instance.ShowFloatTextPrompt("暂无照片可保存");
  122. return;
  123. }
  124. if (_ui.m_c1.selectedIndex == 1 && _photoInfos.Count == 0)
  125. {
  126. PromptController.Instance.ShowFloatTextPrompt("暂无明信片可保存");
  127. return;
  128. }
  129. if (_ui.m_c1.selectedIndex == 2 && _photoInfos.Count == 0)
  130. {
  131. PromptController.Instance.ShowFloatTextPrompt("暂无图片可保存");
  132. return;
  133. }
  134. _ui.m_c2.selectedIndex = 2;
  135. _ui.m_btnChooseAll.selected = false;
  136. }
  137. private void OnBtnTabChange()
  138. {
  139. _ui.m_c2.selectedIndex = 0;
  140. _listChoose.Clear();
  141. UpdateView();
  142. }
  143. private void UpdateView()
  144. {
  145. if (_ui.m_c1.selectedIndex == 0)
  146. {
  147. _ui.m_btnDelete.visible = true;
  148. _ui.m_listTravel.numItems = 0;
  149. _ui.m_descText.visible = false;
  150. _photoInfos = PoemPhotoDataManager.Instance.PersonalPhotoInfos;
  151. _sourceType = (int)PictureSourceType.PersonalAlbum;
  152. _ui.m_list.numItems = _photoInfos.Count;
  153. _ui.m_txtCount.text = string.Format("{0}/{1}", _photoInfos.Count, GlobalCfgArray.globalCfg.maxPhotoCount);
  154. }
  155. else if(_ui.m_c1.selectedIndex == 1)
  156. {
  157. _ui.m_btnDelete.visible = true;
  158. _ui.m_list.numItems = 0;
  159. _ui.m_descText.visible = false;
  160. _photoInfos = PoemPhotoDataManager.Instance.WsqsPhotoInfos;
  161. _sourceType = (int)PictureSourceType.WanShuiQianShan;
  162. _ui.m_listTravel.numItems = _photoInfos.Count;
  163. _ui.m_txtCount.text = string.Format("{0}/{1}", _photoInfos.Count, RoleDataManager.WanShuiQianShanMaxStorageCount);
  164. }
  165. else if(_ui.m_c1.selectedIndex == 2)
  166. {
  167. _ui.m_list.numItems = 0;
  168. _ui.m_listTravel.numItems = 0;
  169. _photoInfos = MatchingCompetitionDataManager.Instance.MatchingPhotoInfos;
  170. _sourceType = 2;
  171. _ui.m_listCompetion.numItems = _photoInfos.Count;
  172. if (_photoInfos.Count == 0)
  173. {
  174. _ui.m_descText.visible = true;
  175. }
  176. else
  177. {
  178. _ui.m_descText.visible = false;
  179. }
  180. _ui.m_txtCount.text = "";
  181. _ui.m_btnDelete.visible = false;
  182. }
  183. _ui.m_btnConfirmDelete.title = string.Format("删除 {0}/{1}", _listChoose.Count, _photoInfos.Count);
  184. _ui.m_btnConfirmSave.title = string.Format("保存 {0}/{1}", _listChoose.Count, _photoInfos.Count);
  185. }
  186. private void RenderListItem(int index, GObject obj)
  187. {
  188. UI_ListPhotoItem item = UI_ListPhotoItem.Proxy(obj);
  189. if (_ui.m_c2.selectedIndex != 0 && _listChoose.IndexOf(_photoInfos[index].PictureId) >= 0)
  190. {
  191. item.m_c1.SetSelectedIndex(1);
  192. }
  193. else
  194. {
  195. item.m_c1.SetSelectedIndex(0);
  196. }
  197. GLoader loaIcon = item.m_comIcon.m_loaIcon;
  198. loaIcon.visible = true;
  199. if (_photoInfos[index].Ntexture == null)
  200. {
  201. loaIcon.visible = false;
  202. }
  203. loaIcon.texture = _photoInfos[index].Ntexture;
  204. string[] timeStr = TimeUtil.FormattingTime1(_photoInfos[index].CreationTime, '/').Split(' ');
  205. item.m_txtTime.text = timeStr[0];
  206. //item.m_txtTime.visible = false;
  207. item.m_btnLock.m_c1.selectedIndex = _photoInfos[index].LockingStatus ? 1 : 0;
  208. item.m_btnUp.m_c1.selectedIndex = _photoInfos[index].ToppingStatus ? 1 : 0;
  209. if (item.m_btnLock.target.data == null)
  210. {
  211. item.m_btnLock.target.onClick.Add(OnBtnLockClick);
  212. }
  213. item.m_btnLock.target.data = index;
  214. if (item.m_btnUp.target.data == null)
  215. {
  216. item.m_btnUp.target.onClick.Add(OnBtnUpClick);
  217. }
  218. item.m_btnUp.target.data = index;
  219. if (item.m_comIcon.target.data == null)
  220. {
  221. item.m_comIcon.target.onClick.Add(OnLoaIconClick);
  222. }
  223. item.m_comIcon.target.data = index;
  224. UI_ListPhotoItem.ProxyEnd();
  225. }
  226. private void RenderListTravelItem(int index, GObject obj)
  227. {
  228. PoemPhotoData poemPhotoData = _photoInfos[index];
  229. TravelLoactionCfg loactionCfg = TravelLoactionCfgArray.Instance.GetCfg(poemPhotoData.TravelLocationId);
  230. UI_ComPhotoPostcard item = UI_ComPhotoPostcard.Proxy(obj);
  231. item.m_c1.selectedIndex = _ui.m_c2.selectedIndex != 0 && _listChoose.IndexOf(_photoInfos[index].PictureId) >= 0 ? 1 : 0;
  232. item.m_comTravel.m_loaBg.url = ResPathUtil.GetTravelBgPath(loactionCfg.res);
  233. item.m_comTravel.m_loaRole.url = "";
  234. if (poemPhotoData.TravelSuitId > 0)
  235. {
  236. TravelSuitCfg travelSuitCfg = TravelSuitCfgArray.Instance.GetCfg(poemPhotoData.TravelSuitId);
  237. item.m_comTravel.m_loaRole.url = ResPathUtil.GetTravelRolePath(travelSuitCfg.reourcesArr[poemPhotoData.SuitResIndex]);
  238. item.m_comTravel.m_loaRole.SetXY(loactionCfg.positionsArr[poemPhotoData.PositionIndex][0], loactionCfg.positionsArr[poemPhotoData.PositionIndex][1]);
  239. }
  240. item.m_btnLock.m_c1.selectedIndex = _photoInfos[index].LockingStatus ? 1 : 0;
  241. item.m_btnUp.m_c1.selectedIndex = _photoInfos[index].ToppingStatus ? 1 : 0;
  242. if (item.m_btnLock.target.data == null)
  243. {
  244. item.m_btnLock.target.onClick.Add(OnBtnLockClick);
  245. }
  246. item.m_btnLock.target.data = index;
  247. if (item.m_btnUp.target.data == null)
  248. {
  249. item.m_btnUp.target.onClick.Add(OnBtnUpClick);
  250. }
  251. item.m_btnUp.target.data = index;
  252. if (item.m_comTravel.target.data == null)
  253. {
  254. item.m_comTravel.target.onClick.Add(OnLoaIconClick);
  255. }
  256. item.m_comTravel.target.data = index;
  257. UI_ComPhotoPostcard.ProxyEnd();
  258. }
  259. private void RenderMatchingListItem(int index, GObject obj)
  260. {
  261. UI_ListPhotoItem item = UI_ListPhotoItem.Proxy(obj);
  262. if (_ui.m_c2.selectedIndex != 0 && _listChoose.IndexOf(_photoInfos[index].PictureId) >= 0)
  263. {
  264. item.m_c1.SetSelectedIndex(1);
  265. }
  266. else
  267. {
  268. item.m_c1.SetSelectedIndex(0);
  269. }
  270. GLoader loaIcon = item.m_comIcon.m_loaIcon;
  271. loaIcon.visible = true;
  272. if (_photoInfos[index].Ntexture == null)
  273. {
  274. loaIcon.visible = false;
  275. }
  276. loaIcon.texture = _photoInfos[index].Ntexture;
  277. string[] timeStr = TimeUtil.FormattingTime1(_photoInfos[index].CreationTime, '/').Split(' ');
  278. item.m_txtTime.text = timeStr[0];
  279. //item.m_txtTime.visible = false;
  280. item.m_btnLock.m_c1.selectedIndex = _photoInfos[index].LockingStatus ? 1 : 0;
  281. item.m_btnUp.m_c1.selectedIndex = _photoInfos[index].ToppingStatus ? 1 : 0;
  282. if (item.m_btnLock.target.data == null)
  283. {
  284. item.m_btnLock.target.onClick.Add(OnBtnMatchingLockClick);
  285. }
  286. item.m_btnLock.target.data = index;
  287. if (item.m_btnUp.target.data == null)
  288. {
  289. item.m_btnUp.target.onClick.Add(OnBtnMatchingUpClick);
  290. }
  291. item.m_btnUp.target.data = index;
  292. if (item.m_comIcon.target.data == null)
  293. {
  294. item.m_comIcon.target.onClick.Add(OnMatchingLoaIconClick);
  295. }
  296. item.m_comIcon.target.data = index;
  297. UI_ListPhotoItem.ProxyEnd();
  298. }
  299. private void OnLoaIconClick(EventContext context)
  300. {
  301. GObject obj = context.sender as GObject;
  302. int index = (int)obj.data;
  303. PoemPhotoData photoData = _photoInfos[index];
  304. if (_ui.m_c2.selectedIndex == 0)
  305. {
  306. ViewManager.Show<PoemPhotoPreView>(new object[] { index, _photoInfos, _sourceType });
  307. }
  308. else
  309. {
  310. if (_ui.m_c2.selectedIndex == 1)
  311. {
  312. if (photoData.LockingStatus)
  313. {
  314. PromptController.Instance.ShowFloatTextPrompt("锁定的照片无法删除");
  315. return;
  316. }
  317. if (photoData.ToppingStatus)
  318. {
  319. PromptController.Instance.ShowFloatTextPrompt("置顶的照片无法删除");
  320. return;
  321. }
  322. }
  323. UI_ListPhotoItem item = UI_ListPhotoItem.Proxy(obj.parent);
  324. item.m_c1.selectedIndex ^= 1;
  325. if (item.m_c1.selectedIndex == 1)
  326. {
  327. _listChoose.Add(photoData.PictureId);
  328. }
  329. else
  330. {
  331. _listChoose.Remove(photoData.PictureId);
  332. }
  333. UI_ListPhotoItem.ProxyEnd();
  334. if (_ui.m_c2.selectedIndex == 1)
  335. {
  336. _ui.m_btnConfirmDelete.title = string.Format("删除({0}/{1})", _listChoose.Count, _photoInfos.Count);
  337. _ui.m_btnChooseAll.selected = (GetEnablePhotoNum(true) == _listChoose.Count);
  338. }
  339. else if (_ui.m_c2.selectedIndex == 2)
  340. {
  341. _ui.m_btnConfirmSave.title = string.Format("保存({0}/{1})", _listChoose.Count, _photoInfos.Count);
  342. _ui.m_btnChooseAll.selected = (GetEnablePhotoNum(false) == _listChoose.Count);
  343. }
  344. }
  345. }
  346. private void OnMatchingLoaIconClick(EventContext context)
  347. {
  348. GObject obj = context.sender as GObject;
  349. int index = (int)obj.data;
  350. PoemPhotoData photoData = _photoInfos[index];
  351. if (_ui.m_c2.selectedIndex == 0)
  352. {
  353. ViewManager.Show<PoemPhotoPreView>(new object[] { index, _photoInfos, _sourceType });
  354. }
  355. else
  356. {
  357. if (_ui.m_c2.selectedIndex == 1)
  358. {
  359. if (photoData.LockingStatus)
  360. {
  361. PromptController.Instance.ShowFloatTextPrompt("锁定的照片无法删除");
  362. return;
  363. }
  364. if (photoData.ToppingStatus)
  365. {
  366. PromptController.Instance.ShowFloatTextPrompt("置顶的照片无法删除");
  367. return;
  368. }
  369. }
  370. UI_ListPhotoItem item = UI_ListPhotoItem.Proxy(obj.parent);
  371. item.m_c1.selectedIndex ^= 1;
  372. if (item.m_c1.selectedIndex == 1)
  373. {
  374. _listChoose.Add(photoData.PictureId);
  375. }
  376. else
  377. {
  378. _listChoose.Remove(photoData.PictureId);
  379. }
  380. UI_ListPhotoItem.ProxyEnd();
  381. if (_ui.m_c2.selectedIndex == 1)
  382. {
  383. _ui.m_btnConfirmDelete.title = string.Format("删除({0}/{1})", _listChoose.Count, _photoInfos.Count);
  384. _ui.m_btnChooseAll.selected = (GetEnablePhotoNum(true) == _listChoose.Count);
  385. }
  386. else if (_ui.m_c2.selectedIndex == 2)
  387. {
  388. _ui.m_btnConfirmSave.title = string.Format("保存({0}/{1})", _listChoose.Count, _photoInfos.Count);
  389. _ui.m_btnChooseAll.selected = (GetEnablePhotoNum(false) == _listChoose.Count);
  390. }
  391. }
  392. }
  393. private void OnBtnConfirmDeleteClick()
  394. {
  395. if (_listChoose.Count == 0)
  396. {
  397. PromptController.Instance.ShowFloatTextPrompt("请选择要删除的照片");
  398. return;
  399. }
  400. AlertUI.Show("删除后的照片无法恢复,是否确认删除?")
  401. .SetLeftButton(true, "否").SetRightButton(true, "是", async (object data) =>
  402. {
  403. if (_ui.m_c2.selectedIndex != 2)
  404. {
  405. bool result = await PoemPhotoSProxy.ReqRemovedPhoto(_listChoose, _sourceType);
  406. if (result)
  407. {
  408. _listChoose.Clear();
  409. OnBtnTabChange();
  410. }
  411. }
  412. else
  413. {
  414. bool result = await MatchingCompetitionSproxy.ReqRemovedPhoto(_listChoose, _sourceType);
  415. if (result)
  416. {
  417. _listChoose.Clear();
  418. OnBtnTabChange();
  419. }
  420. }
  421. });
  422. }
  423. private void OnBtnLockClick(EventContext context)
  424. {
  425. if (_ui.m_c2.selectedIndex != 0)
  426. {
  427. //PromptController.Instance.ShowFloatTextPrompt("删除状态无法操作");
  428. return;
  429. }
  430. GObject item = context.sender as GObject;
  431. int index = (int)item.data;
  432. PoemPhotoData photoData = _photoInfos[index];
  433. if (photoData.LockingStatus == false)
  434. {
  435. AlertUI.Show("是否确认锁定此照片?", "(锁定的照片无法被删除)")
  436. .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
  437. {
  438. PoemPhotoSProxy.ReqChangeLockingState(photoData.PictureId, true, _sourceType).Coroutine();
  439. });
  440. }
  441. else
  442. {
  443. AlertUI.Show("是否确认解锁此照片?", "(解锁后的照片可随意删除)")
  444. .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
  445. {
  446. PoemPhotoSProxy.ReqChangeLockingState(photoData.PictureId, false, _sourceType).Coroutine();
  447. });
  448. }
  449. }
  450. private void OnBtnMatchingLockClick(EventContext context)
  451. {
  452. if (_ui.m_c2.selectedIndex != 0)
  453. {
  454. //PromptController.Instance.ShowFloatTextPrompt("删除状态无法操作");
  455. return;
  456. }
  457. GObject item = context.sender as GObject;
  458. int index = (int)item.data;
  459. PoemPhotoData photoData = _photoInfos[index];
  460. if (photoData.LockingStatus == false)
  461. {
  462. AlertUI.Show("是否确认锁定此照片?", "(锁定的照片无法被删除)")
  463. .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
  464. {
  465. MatchingCompetitionSproxy.ReqChangeLockingState(photoData.PictureId, true, _sourceType).Coroutine();
  466. });
  467. }
  468. else
  469. {
  470. AlertUI.Show("是否确认解锁此照片?", "(解锁后的照片可随意删除)")
  471. .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
  472. {
  473. MatchingCompetitionSproxy.ReqChangeLockingState(photoData.PictureId, false, _sourceType).Coroutine();
  474. });
  475. }
  476. }
  477. private void OnBtnUpClick(EventContext context)
  478. {
  479. if (_ui.m_c2.selectedIndex != 0)
  480. {
  481. //PromptController.Instance.ShowFloatTextPrompt("删除状态无法操作");
  482. return;
  483. }
  484. GObject item = context.sender as GObject;
  485. int index = (int)item.data;
  486. PoemPhotoData photoData = _photoInfos[index];
  487. if (photoData.ToppingStatus == false)
  488. {
  489. AlertUI.Show("是否确认置顶此照片?")
  490. .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
  491. {
  492. PoemPhotoSProxy.ReqChangeToppingState(photoData.PictureId, true, _sourceType).Coroutine();
  493. });
  494. }
  495. else
  496. {
  497. AlertUI.Show("是否确认取消置顶此照片?")
  498. .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
  499. {
  500. PoemPhotoSProxy.ReqChangeToppingState(photoData.PictureId, false, _sourceType).Coroutine();
  501. });
  502. }
  503. }
  504. private void OnBtnMatchingUpClick(EventContext context)
  505. {
  506. if (_ui.m_c2.selectedIndex != 0)
  507. {
  508. //PromptController.Instance.ShowFloatTextPrompt("删除状态无法操作");
  509. return;
  510. }
  511. GObject item = context.sender as GObject;
  512. int index = (int)item.data;
  513. PoemPhotoData photoData = _photoInfos[index];
  514. if (photoData.ToppingStatus == false)
  515. {
  516. AlertUI.Show("是否确认置顶此照片?")
  517. .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
  518. {
  519. MatchingCompetitionSproxy.ReqChangeToppingState(photoData.PictureId, true, _sourceType).Coroutine();
  520. });
  521. }
  522. else
  523. {
  524. AlertUI.Show("是否确认取消置顶此照片?")
  525. .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
  526. {
  527. MatchingCompetitionSproxy.ReqChangeToppingState(photoData.PictureId, false, _sourceType).Coroutine();
  528. });
  529. }
  530. }
  531. private void CheckGuide(object param)
  532. {
  533. if (GuideDataManager.IsGuideFinish(ConstGuideId.POEM) <= 0)
  534. {
  535. UpdateToCheckGuide(null);
  536. }
  537. else
  538. {
  539. Timers.inst.Remove(CheckGuide);
  540. }
  541. }
  542. protected override void UpdateToCheckGuide(object param)
  543. {
  544. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  545. GuideController.TryGuide(null, ConstGuideId.POEM, 1, "在“拍照”中保存的图片都会保存到这里。");
  546. GuideController.TryGuide(_ui.m_btnback, ConstGuideId.POEM, 2, "");
  547. GuideController.TryCompleteGuideIndex(ConstGuideId.POEM, 2);
  548. GuideController.TryCompleteGuide(ConstGuideId.POEM, 2);
  549. }
  550. /// <summary>
  551. /// 初始化分类菜单文本,点击和未点击是两种样式,需要统一文字
  552. /// </summary>
  553. private void InitTypeList()
  554. {
  555. for (int i = 0; i < _ui.m_typeList.numChildren; i++)
  556. {
  557. UI_Button6 button6 = UI_Button6.Proxy(_ui.m_typeList.GetChildAt(i));
  558. button6.m_title1.text = button6.target.title;
  559. UI_Button6.ProxyEnd();
  560. }
  561. }
  562. /// <summary>
  563. /// 获取当前相册可操作的相片数量
  564. /// </summary>
  565. /// <param name="delete">为true时跳过锁住的和置顶的相片</param>
  566. /// <returns></returns>
  567. private int GetEnablePhotoNum(bool delete)
  568. {
  569. int num = 0;
  570. for (int i = 0; i < _photoInfos.Count; i++)
  571. {
  572. PoemPhotoData photoData = _photoInfos[i];
  573. if (delete && (photoData.LockingStatus || photoData.ToppingStatus))
  574. {
  575. continue;
  576. }
  577. ++num;
  578. }
  579. return num;
  580. }
  581. private void OnClickBtnChooseAll()
  582. {
  583. _listChoose.Clear();
  584. GList list = ((_ui.m_c1.selectedIndex == 0) ? _ui.m_list : _ui.m_listTravel);
  585. for (int i = 0; i < _photoInfos.Count; i++)
  586. {
  587. PoemPhotoData photoData = _photoInfos[i];
  588. // 删除全选时不选择 置顶或者锁住 的照片
  589. if (_ui.m_c2.selectedIndex == 1 && (photoData.LockingStatus || photoData.ToppingStatus))
  590. {
  591. continue;
  592. }
  593. if (_ui.m_btnChooseAll.selected)
  594. {
  595. _listChoose.Add(photoData.PictureId);
  596. }
  597. }
  598. list.numItems = _photoInfos.Count;
  599. if (_ui.m_c2.selectedIndex == 1)
  600. {
  601. _ui.m_btnConfirmDelete.title = string.Format("删除({0}/{1})", _listChoose.Count, _photoInfos.Count);
  602. }
  603. else if (_ui.m_c2.selectedIndex == 2)
  604. {
  605. _ui.m_btnConfirmSave.title = string.Format("保存({0}/{1})", _listChoose.Count, _photoInfos.Count);
  606. }
  607. }
  608. private void OnClickConfirmSave()
  609. {
  610. if (_listChoose.Count == 0)
  611. {
  612. PromptController.Instance.ShowFloatTextPrompt("请选择要保存的照片");
  613. return;
  614. }
  615. #if UNITY_EDITOR
  616. OpenSaveView();
  617. #else
  618. CheckSaveLocal();
  619. #endif
  620. }
  621. /// <summary>
  622. /// 检查保存相片相应权限
  623. /// </summary>
  624. private async void CheckSaveLocal()
  625. {
  626. string permissionName = "存储";
  627. #if UNITY_IOS
  628. permissionName = "相册";
  629. #endif
  630. NativeGallery.Permission permission = NativeGallery.CheckPermission(NativeGallery.PermissionType.Write, NativeGallery.MediaType.Image);
  631. Debug.Log("Permission result: " + permission);
  632. if (permission.Equals(NativeGallery.Permission.Denied))
  633. {
  634. string tips = $"保存至本地需要使用{permissionName}权限,您已经禁止!请前往手机系统设置开启应用的{permissionName}权限。";
  635. if (NativeGallery.CanOpenSettings())
  636. {
  637. AlertSystem.Show(tips)
  638. .SetLeftButton(true, "前往", (data) => { NativeGallery.OpenSettings(); })
  639. .SetRightButton(true, "拒绝");
  640. }
  641. else
  642. {
  643. AlertSystem.Show(tips)
  644. .SetLeftButton(true, "知道了");
  645. }
  646. }
  647. else
  648. {
  649. if (permission.Equals(NativeGallery.Permission.ShouldAsk))
  650. {
  651. string tips = $"保存至本地需要使用{permissionName}权限,请同意!";
  652. PromptController.Instance.ShowFloatTextPrompt(tips);
  653. permission = await NativeGallery.RequestPermissionAsync(NativeGallery.PermissionType.Write, NativeGallery.MediaType.Image);
  654. //Debug.Log("Permission result: " + permission);
  655. if (!permission.Equals(NativeGallery.Permission.Granted))
  656. {
  657. PromptController.Instance.ShowFloatTextPrompt($"由于被禁止{permissionName}权限,保存失败!");
  658. return;
  659. }
  660. }
  661. //Debug.Log("Permission result: " + permission);
  662. }
  663. OpenSaveView();
  664. }
  665. private void OpenSaveView()
  666. {
  667. SavePhotoList savePhoto = new SavePhotoList();
  668. savePhoto.pageIndex = _ui.m_c1.selectedIndex;
  669. savePhoto.photoInfos = _photoInfos;
  670. savePhoto.listChoose = _listChoose;
  671. ViewManager.Show<PoemPhotoSaveView>(savePhoto);
  672. }
  673. }
  674. }