PoemPhotoView.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
  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_listTravel.numItems = 0;
  148. _photoInfos = PoemPhotoDataManager.Instance.PersonalPhotoInfos;
  149. _sourceType = (int)PictureSourceType.PersonalAlbum;
  150. _ui.m_list.numItems = _photoInfos.Count;
  151. _ui.m_txtCount.text = string.Format("{0}/{1}", _photoInfos.Count, GlobalCfgArray.globalCfg.maxPhotoCount);
  152. }
  153. else if(_ui.m_c1.selectedIndex == 1)
  154. {
  155. _ui.m_list.numItems = 0;
  156. _photoInfos = PoemPhotoDataManager.Instance.WsqsPhotoInfos;
  157. _sourceType = (int)PictureSourceType.WanShuiQianShan;
  158. _ui.m_listTravel.numItems = _photoInfos.Count;
  159. _ui.m_txtCount.text = string.Format("{0}/{1}", _photoInfos.Count, RoleDataManager.WanShuiQianShanMaxStorageCount);
  160. }
  161. else if(_ui.m_c1.selectedIndex == 2)
  162. {
  163. _ui.m_list.numItems = 0;
  164. _ui.m_listTravel.numItems = 0;
  165. _photoInfos = MatchingCompetitionDataManager.Instance.MatchingPhotoInfos;
  166. _sourceType = 2;
  167. _ui.m_listCompetion.numItems = _photoInfos.Count;
  168. _ui.m_txtCount.text = "";
  169. _ui.m_btnDelete.visible = false;
  170. }
  171. _ui.m_btnConfirmDelete.title = string.Format("删除 {0}/{1}", _listChoose.Count, _photoInfos.Count);
  172. _ui.m_btnConfirmSave.title = string.Format("保存 {0}/{1}", _listChoose.Count, _photoInfos.Count);
  173. }
  174. private void RenderListItem(int index, GObject obj)
  175. {
  176. UI_ListPhotoItem item = UI_ListPhotoItem.Proxy(obj);
  177. if (_ui.m_c2.selectedIndex != 0 && _listChoose.IndexOf(_photoInfos[index].PictureId) >= 0)
  178. {
  179. item.m_c1.SetSelectedIndex(1);
  180. }
  181. else
  182. {
  183. item.m_c1.SetSelectedIndex(0);
  184. }
  185. GLoader loaIcon = item.m_comIcon.m_loaIcon;
  186. loaIcon.visible = true;
  187. if (_photoInfos[index].Ntexture == null)
  188. {
  189. loaIcon.visible = false;
  190. }
  191. loaIcon.texture = _photoInfos[index].Ntexture;
  192. string[] timeStr = TimeUtil.FormattingTime1(_photoInfos[index].CreationTime, '/').Split(' ');
  193. item.m_txtTime.text = timeStr[0];
  194. //item.m_txtTime.visible = false;
  195. item.m_btnLock.m_c1.selectedIndex = _photoInfos[index].LockingStatus ? 1 : 0;
  196. item.m_btnUp.m_c1.selectedIndex = _photoInfos[index].ToppingStatus ? 1 : 0;
  197. if (item.m_btnLock.target.data == null)
  198. {
  199. item.m_btnLock.target.onClick.Add(OnBtnLockClick);
  200. }
  201. item.m_btnLock.target.data = index;
  202. if (item.m_btnUp.target.data == null)
  203. {
  204. item.m_btnUp.target.onClick.Add(OnBtnUpClick);
  205. }
  206. item.m_btnUp.target.data = index;
  207. if (item.m_comIcon.target.data == null)
  208. {
  209. item.m_comIcon.target.onClick.Add(OnLoaIconClick);
  210. }
  211. item.m_comIcon.target.data = index;
  212. UI_ListPhotoItem.ProxyEnd();
  213. }
  214. private void RenderListTravelItem(int index, GObject obj)
  215. {
  216. PoemPhotoData poemPhotoData = _photoInfos[index];
  217. TravelLoactionCfg loactionCfg = TravelLoactionCfgArray.Instance.GetCfg(poemPhotoData.TravelLocationId);
  218. UI_ComPhotoPostcard item = UI_ComPhotoPostcard.Proxy(obj);
  219. item.m_c1.selectedIndex = _ui.m_c2.selectedIndex != 0 && _listChoose.IndexOf(_photoInfos[index].PictureId) >= 0 ? 1 : 0;
  220. item.m_comTravel.m_loaBg.url = ResPathUtil.GetTravelBgPath(loactionCfg.res);
  221. item.m_comTravel.m_loaRole.url = "";
  222. if (poemPhotoData.TravelSuitId > 0)
  223. {
  224. TravelSuitCfg travelSuitCfg = TravelSuitCfgArray.Instance.GetCfg(poemPhotoData.TravelSuitId);
  225. item.m_comTravel.m_loaRole.url = ResPathUtil.GetTravelRolePath(travelSuitCfg.reourcesArr[poemPhotoData.SuitResIndex]);
  226. item.m_comTravel.m_loaRole.SetXY(loactionCfg.positionsArr[poemPhotoData.PositionIndex][0], loactionCfg.positionsArr[poemPhotoData.PositionIndex][1]);
  227. }
  228. item.m_btnLock.m_c1.selectedIndex = _photoInfos[index].LockingStatus ? 1 : 0;
  229. item.m_btnUp.m_c1.selectedIndex = _photoInfos[index].ToppingStatus ? 1 : 0;
  230. if (item.m_btnLock.target.data == null)
  231. {
  232. item.m_btnLock.target.onClick.Add(OnBtnLockClick);
  233. }
  234. item.m_btnLock.target.data = index;
  235. if (item.m_btnUp.target.data == null)
  236. {
  237. item.m_btnUp.target.onClick.Add(OnBtnUpClick);
  238. }
  239. item.m_btnUp.target.data = index;
  240. if (item.m_comTravel.target.data == null)
  241. {
  242. item.m_comTravel.target.onClick.Add(OnLoaIconClick);
  243. }
  244. item.m_comTravel.target.data = index;
  245. UI_ComPhotoPostcard.ProxyEnd();
  246. }
  247. private void RenderMatchingListItem(int index, GObject obj)
  248. {
  249. UI_ListPhotoItem item = UI_ListPhotoItem.Proxy(obj);
  250. if (_ui.m_c2.selectedIndex != 0 && _listChoose.IndexOf(_photoInfos[index].PictureId) >= 0)
  251. {
  252. item.m_c1.SetSelectedIndex(1);
  253. }
  254. else
  255. {
  256. item.m_c1.SetSelectedIndex(0);
  257. }
  258. GLoader loaIcon = item.m_comIcon.m_loaIcon;
  259. loaIcon.visible = true;
  260. if (_photoInfos[index].Ntexture == null)
  261. {
  262. loaIcon.visible = false;
  263. }
  264. loaIcon.texture = _photoInfos[index].Ntexture;
  265. string[] timeStr = TimeUtil.FormattingTime1(_photoInfos[index].CreationTime, '/').Split(' ');
  266. item.m_txtTime.text = timeStr[0];
  267. //item.m_txtTime.visible = false;
  268. item.m_btnLock.m_c1.selectedIndex = _photoInfos[index].LockingStatus ? 1 : 0;
  269. item.m_btnUp.m_c1.selectedIndex = _photoInfos[index].ToppingStatus ? 1 : 0;
  270. if (item.m_btnLock.target.data == null)
  271. {
  272. item.m_btnLock.target.onClick.Add(OnBtnMatchingLockClick);
  273. }
  274. item.m_btnLock.target.data = index;
  275. if (item.m_btnUp.target.data == null)
  276. {
  277. item.m_btnUp.target.onClick.Add(OnBtnMatchingUpClick);
  278. }
  279. item.m_btnUp.target.data = index;
  280. if (item.m_comIcon.target.data == null)
  281. {
  282. item.m_comIcon.target.onClick.Add(OnMatchingLoaIconClick);
  283. }
  284. item.m_comIcon.target.data = index;
  285. UI_ListPhotoItem.ProxyEnd();
  286. }
  287. private void OnLoaIconClick(EventContext context)
  288. {
  289. GObject obj = context.sender as GObject;
  290. int index = (int)obj.data;
  291. PoemPhotoData photoData = _photoInfos[index];
  292. if (_ui.m_c2.selectedIndex == 0)
  293. {
  294. ViewManager.Show<PoemPhotoPreView>(new object[] { index, _photoInfos, _sourceType });
  295. }
  296. else
  297. {
  298. if (_ui.m_c2.selectedIndex == 1)
  299. {
  300. if (photoData.LockingStatus)
  301. {
  302. PromptController.Instance.ShowFloatTextPrompt("锁定的照片无法删除");
  303. return;
  304. }
  305. if (photoData.ToppingStatus)
  306. {
  307. PromptController.Instance.ShowFloatTextPrompt("置顶的照片无法删除");
  308. return;
  309. }
  310. }
  311. UI_ListPhotoItem item = UI_ListPhotoItem.Proxy(obj.parent);
  312. item.m_c1.selectedIndex ^= 1;
  313. if (item.m_c1.selectedIndex == 1)
  314. {
  315. _listChoose.Add(photoData.PictureId);
  316. }
  317. else
  318. {
  319. _listChoose.Remove(photoData.PictureId);
  320. }
  321. UI_ListPhotoItem.ProxyEnd();
  322. if (_ui.m_c2.selectedIndex == 1)
  323. {
  324. _ui.m_btnConfirmDelete.title = string.Format("删除({0}/{1})", _listChoose.Count, _photoInfos.Count);
  325. _ui.m_btnChooseAll.selected = (GetEnablePhotoNum(true) == _listChoose.Count);
  326. }
  327. else if (_ui.m_c2.selectedIndex == 2)
  328. {
  329. _ui.m_btnConfirmSave.title = string.Format("保存({0}/{1})", _listChoose.Count, _photoInfos.Count);
  330. _ui.m_btnChooseAll.selected = (GetEnablePhotoNum(false) == _listChoose.Count);
  331. }
  332. }
  333. }
  334. private void OnMatchingLoaIconClick(EventContext context)
  335. {
  336. GObject obj = context.sender as GObject;
  337. int index = (int)obj.data;
  338. PoemPhotoData photoData = _photoInfos[index];
  339. if (_ui.m_c2.selectedIndex == 0)
  340. {
  341. ViewManager.Show<PoemPhotoPreView>(new object[] { index, _photoInfos, _sourceType });
  342. }
  343. else
  344. {
  345. if (_ui.m_c2.selectedIndex == 1)
  346. {
  347. if (photoData.LockingStatus)
  348. {
  349. PromptController.Instance.ShowFloatTextPrompt("锁定的照片无法删除");
  350. return;
  351. }
  352. if (photoData.ToppingStatus)
  353. {
  354. PromptController.Instance.ShowFloatTextPrompt("置顶的照片无法删除");
  355. return;
  356. }
  357. }
  358. UI_ListPhotoItem item = UI_ListPhotoItem.Proxy(obj.parent);
  359. item.m_c1.selectedIndex ^= 1;
  360. if (item.m_c1.selectedIndex == 1)
  361. {
  362. _listChoose.Add(photoData.PictureId);
  363. }
  364. else
  365. {
  366. _listChoose.Remove(photoData.PictureId);
  367. }
  368. UI_ListPhotoItem.ProxyEnd();
  369. if (_ui.m_c2.selectedIndex == 1)
  370. {
  371. _ui.m_btnConfirmDelete.title = string.Format("删除({0}/{1})", _listChoose.Count, _photoInfos.Count);
  372. _ui.m_btnChooseAll.selected = (GetEnablePhotoNum(true) == _listChoose.Count);
  373. }
  374. else if (_ui.m_c2.selectedIndex == 2)
  375. {
  376. _ui.m_btnConfirmSave.title = string.Format("保存({0}/{1})", _listChoose.Count, _photoInfos.Count);
  377. _ui.m_btnChooseAll.selected = (GetEnablePhotoNum(false) == _listChoose.Count);
  378. }
  379. }
  380. }
  381. private void OnBtnConfirmDeleteClick()
  382. {
  383. if (_listChoose.Count == 0)
  384. {
  385. PromptController.Instance.ShowFloatTextPrompt("请选择要删除的照片");
  386. return;
  387. }
  388. AlertUI.Show("删除后的照片无法恢复,是否确认删除?")
  389. .SetLeftButton(true, "否").SetRightButton(true, "是", async (object data) =>
  390. {
  391. if (_ui.m_c2.selectedIndex != 2)
  392. {
  393. bool result = await PoemPhotoSProxy.ReqRemovedPhoto(_listChoose, _sourceType);
  394. if (result)
  395. {
  396. _listChoose.Clear();
  397. OnBtnTabChange();
  398. }
  399. }
  400. else
  401. {
  402. bool result = await MatchingCompetitionSproxy.ReqRemovedPhoto(_listChoose, _sourceType);
  403. if (result)
  404. {
  405. _listChoose.Clear();
  406. OnBtnTabChange();
  407. }
  408. }
  409. });
  410. }
  411. private void OnBtnLockClick(EventContext context)
  412. {
  413. if (_ui.m_c2.selectedIndex != 0)
  414. {
  415. //PromptController.Instance.ShowFloatTextPrompt("删除状态无法操作");
  416. return;
  417. }
  418. GObject item = context.sender as GObject;
  419. int index = (int)item.data;
  420. PoemPhotoData photoData = _photoInfos[index];
  421. if (photoData.LockingStatus == false)
  422. {
  423. AlertUI.Show("是否确认锁定此照片?", "(锁定的照片无法被删除)")
  424. .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
  425. {
  426. PoemPhotoSProxy.ReqChangeLockingState(photoData.PictureId, true, _sourceType).Coroutine();
  427. });
  428. }
  429. else
  430. {
  431. AlertUI.Show("是否确认解锁此照片?", "(解锁后的照片可随意删除)")
  432. .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
  433. {
  434. PoemPhotoSProxy.ReqChangeLockingState(photoData.PictureId, false, _sourceType).Coroutine();
  435. });
  436. }
  437. }
  438. private void OnBtnMatchingLockClick(EventContext context)
  439. {
  440. if (_ui.m_c2.selectedIndex != 0)
  441. {
  442. //PromptController.Instance.ShowFloatTextPrompt("删除状态无法操作");
  443. return;
  444. }
  445. GObject item = context.sender as GObject;
  446. int index = (int)item.data;
  447. PoemPhotoData photoData = _photoInfos[index];
  448. if (photoData.LockingStatus == false)
  449. {
  450. AlertUI.Show("是否确认锁定此照片?", "(锁定的照片无法被删除)")
  451. .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
  452. {
  453. MatchingCompetitionSproxy.ReqChangeLockingState(photoData.PictureId, true, _sourceType).Coroutine();
  454. });
  455. }
  456. else
  457. {
  458. AlertUI.Show("是否确认解锁此照片?", "(解锁后的照片可随意删除)")
  459. .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
  460. {
  461. MatchingCompetitionSproxy.ReqChangeLockingState(photoData.PictureId, false, _sourceType).Coroutine();
  462. });
  463. }
  464. }
  465. private void OnBtnUpClick(EventContext context)
  466. {
  467. if (_ui.m_c2.selectedIndex != 0)
  468. {
  469. //PromptController.Instance.ShowFloatTextPrompt("删除状态无法操作");
  470. return;
  471. }
  472. GObject item = context.sender as GObject;
  473. int index = (int)item.data;
  474. PoemPhotoData photoData = _photoInfos[index];
  475. if (photoData.ToppingStatus == false)
  476. {
  477. AlertUI.Show("是否确认置顶此照片?")
  478. .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
  479. {
  480. PoemPhotoSProxy.ReqChangeToppingState(photoData.PictureId, true, _sourceType).Coroutine();
  481. });
  482. }
  483. else
  484. {
  485. AlertUI.Show("是否确认取消置顶此照片?")
  486. .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
  487. {
  488. PoemPhotoSProxy.ReqChangeToppingState(photoData.PictureId, false, _sourceType).Coroutine();
  489. });
  490. }
  491. }
  492. private void OnBtnMatchingUpClick(EventContext context)
  493. {
  494. if (_ui.m_c2.selectedIndex != 0)
  495. {
  496. //PromptController.Instance.ShowFloatTextPrompt("删除状态无法操作");
  497. return;
  498. }
  499. GObject item = context.sender as GObject;
  500. int index = (int)item.data;
  501. PoemPhotoData photoData = _photoInfos[index];
  502. if (photoData.ToppingStatus == false)
  503. {
  504. AlertUI.Show("是否确认置顶此照片?")
  505. .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
  506. {
  507. MatchingCompetitionSproxy.ReqChangeToppingState(photoData.PictureId, true, _sourceType).Coroutine();
  508. });
  509. }
  510. else
  511. {
  512. AlertUI.Show("是否确认取消置顶此照片?")
  513. .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
  514. {
  515. MatchingCompetitionSproxy.ReqChangeToppingState(photoData.PictureId, false, _sourceType).Coroutine();
  516. });
  517. }
  518. }
  519. private void CheckGuide(object param)
  520. {
  521. if (GuideDataManager.IsGuideFinish(ConstGuideId.POEM) <= 0)
  522. {
  523. UpdateToCheckGuide(null);
  524. }
  525. else
  526. {
  527. Timers.inst.Remove(CheckGuide);
  528. }
  529. }
  530. protected override void UpdateToCheckGuide(object param)
  531. {
  532. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  533. GuideController.TryGuide(null, ConstGuideId.POEM, 1, "在“拍照”中保存的图片都会保存到这里。");
  534. GuideController.TryGuide(_ui.m_btnback, ConstGuideId.POEM, 2, "");
  535. GuideController.TryCompleteGuideIndex(ConstGuideId.POEM, 2);
  536. GuideController.TryCompleteGuide(ConstGuideId.POEM, 2);
  537. }
  538. /// <summary>
  539. /// 初始化分类菜单文本,点击和未点击是两种样式,需要统一文字
  540. /// </summary>
  541. private void InitTypeList()
  542. {
  543. for (int i = 0; i < _ui.m_typeList.numChildren; i++)
  544. {
  545. UI_Button6 button6 = UI_Button6.Proxy(_ui.m_typeList.GetChildAt(i));
  546. button6.m_title1.text = button6.target.title;
  547. UI_Button6.ProxyEnd();
  548. }
  549. }
  550. /// <summary>
  551. /// 获取当前相册可操作的相片数量
  552. /// </summary>
  553. /// <param name="delete">为true时跳过锁住的和置顶的相片</param>
  554. /// <returns></returns>
  555. private int GetEnablePhotoNum(bool delete)
  556. {
  557. int num = 0;
  558. for (int i = 0; i < _photoInfos.Count; i++)
  559. {
  560. PoemPhotoData photoData = _photoInfos[i];
  561. if (delete && (photoData.LockingStatus || photoData.ToppingStatus))
  562. {
  563. continue;
  564. }
  565. ++num;
  566. }
  567. return num;
  568. }
  569. private void OnClickBtnChooseAll()
  570. {
  571. _listChoose.Clear();
  572. GList list = ((_ui.m_c1.selectedIndex == 0) ? _ui.m_list : _ui.m_listTravel);
  573. for (int i = 0; i < _photoInfos.Count; i++)
  574. {
  575. PoemPhotoData photoData = _photoInfos[i];
  576. // 删除全选时不选择 置顶或者锁住 的照片
  577. if (_ui.m_c2.selectedIndex == 1 && (photoData.LockingStatus || photoData.ToppingStatus))
  578. {
  579. continue;
  580. }
  581. if (_ui.m_btnChooseAll.selected)
  582. {
  583. _listChoose.Add(photoData.PictureId);
  584. }
  585. }
  586. list.numItems = _photoInfos.Count;
  587. if (_ui.m_c2.selectedIndex == 1)
  588. {
  589. _ui.m_btnConfirmDelete.title = string.Format("删除({0}/{1})", _listChoose.Count, _photoInfos.Count);
  590. }
  591. else if (_ui.m_c2.selectedIndex == 2)
  592. {
  593. _ui.m_btnConfirmSave.title = string.Format("保存({0}/{1})", _listChoose.Count, _photoInfos.Count);
  594. }
  595. }
  596. private void OnClickConfirmSave()
  597. {
  598. if (_listChoose.Count == 0)
  599. {
  600. PromptController.Instance.ShowFloatTextPrompt("请选择要保存的照片");
  601. return;
  602. }
  603. #if UNITY_EDITOR
  604. OpenSaveView();
  605. #else
  606. CheckSaveLocal();
  607. #endif
  608. }
  609. /// <summary>
  610. /// 检查保存相片相应权限
  611. /// </summary>
  612. private async void CheckSaveLocal()
  613. {
  614. string permissionName = "存储";
  615. #if UNITY_IOS
  616. permissionName = "相册";
  617. #endif
  618. NativeGallery.Permission permission = NativeGallery.CheckPermission(NativeGallery.PermissionType.Write, NativeGallery.MediaType.Image);
  619. Debug.Log("Permission result: " + permission);
  620. if (permission.Equals(NativeGallery.Permission.Denied))
  621. {
  622. string tips = $"保存至本地需要使用{permissionName}权限,您已经禁止!请前往手机系统设置开启应用的{permissionName}权限。";
  623. if (NativeGallery.CanOpenSettings())
  624. {
  625. AlertSystem.Show(tips)
  626. .SetLeftButton(true, "前往", (data) => { NativeGallery.OpenSettings(); })
  627. .SetRightButton(true, "拒绝");
  628. }
  629. else
  630. {
  631. AlertSystem.Show(tips)
  632. .SetLeftButton(true, "知道了");
  633. }
  634. }
  635. else
  636. {
  637. if (permission.Equals(NativeGallery.Permission.ShouldAsk))
  638. {
  639. string tips = $"保存至本地需要使用{permissionName}权限,请同意!";
  640. PromptController.Instance.ShowFloatTextPrompt(tips);
  641. permission = await NativeGallery.RequestPermissionAsync(NativeGallery.PermissionType.Write, NativeGallery.MediaType.Image);
  642. //Debug.Log("Permission result: " + permission);
  643. if (!permission.Equals(NativeGallery.Permission.Granted))
  644. {
  645. PromptController.Instance.ShowFloatTextPrompt($"由于被禁止{permissionName}权限,保存失败!");
  646. return;
  647. }
  648. }
  649. //Debug.Log("Permission result: " + permission);
  650. }
  651. OpenSaveView();
  652. }
  653. private void OpenSaveView()
  654. {
  655. SavePhotoList savePhoto = new SavePhotoList();
  656. savePhoto.pageIndex = _ui.m_c1.selectedIndex;
  657. savePhoto.photoInfos = _photoInfos;
  658. savePhoto.listChoose = _listChoose;
  659. ViewManager.Show<PoemPhotoSaveView>(savePhoto);
  660. }
  661. }
  662. }