PoemPhotoView.cs 28 KB

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