PoemPhotoView.cs 28 KB

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