|
@@ -2,17 +2,27 @@ using System.Collections.Generic;
|
|
|
using ET;
|
|
|
using FairyGUI;
|
|
|
using UI.Poem;
|
|
|
+using UnityEngine;
|
|
|
|
|
|
namespace GFGGame
|
|
|
{
|
|
|
+ public struct SavePhotoList
|
|
|
+ {
|
|
|
+ public int pageIndex;
|
|
|
+ public List<PoemPhotoData> photoInfos;
|
|
|
+ public List<long> listChoose;
|
|
|
+ }
|
|
|
+
|
|
|
public class PoemPhotoView : BaseWindow
|
|
|
{
|
|
|
private UI_PoemPhotoUI _ui;
|
|
|
- private List<long> _listDelete = new List<long>();
|
|
|
+ private List<long> _listChoose = new List<long>();
|
|
|
+
|
|
|
private List<PoemPhotoData> _photoInfos;
|
|
|
private int _sourceType = 0;
|
|
|
|
|
|
|
|
|
+
|
|
|
public override void Dispose()
|
|
|
{
|
|
|
if (_ui != null)
|
|
@@ -42,8 +52,11 @@ namespace GFGGame
|
|
|
|
|
|
_ui.m_btnback.onClick.Add(OnBtnBackClick);
|
|
|
_ui.m_btnDelete.onClick.Add(OnBtnDeleteClick);
|
|
|
- _ui.m_btnConfirmDelete.target.onClick.Add(OnBtnConfirmDeleteClick);
|
|
|
+ _ui.m_btnSave.onClick.Add(OnBtnSaveClick);
|
|
|
+ _ui.m_btnConfirmDelete.onClick.Add(OnBtnConfirmDeleteClick);
|
|
|
_ui.m_c1.onChanged.Add(OnBtnTabChange);
|
|
|
+ _ui.m_btnChooseAll.onClick.Add(OnClickBtnChooseAll);
|
|
|
+ _ui.m_btnConfirmSave.onClick.Add(OnClickConfirmSave);
|
|
|
|
|
|
InitTypeList();
|
|
|
}
|
|
@@ -56,7 +69,7 @@ namespace GFGGame
|
|
|
protected override void OnShown()
|
|
|
{
|
|
|
base.OnShown();
|
|
|
- if(this.viewData != null)
|
|
|
+ if (this.viewData != null)
|
|
|
{
|
|
|
_ui.m_c1.selectedIndex = (int)this.viewData;
|
|
|
}
|
|
@@ -70,7 +83,7 @@ namespace GFGGame
|
|
|
{
|
|
|
base.OnHide();
|
|
|
_ui.m_c2.selectedIndex = 0;
|
|
|
- _listDelete.Clear();
|
|
|
+ _listChoose.Clear();
|
|
|
Timers.inst.Remove(CheckGuide);
|
|
|
}
|
|
|
|
|
@@ -97,23 +110,40 @@ namespace GFGGame
|
|
|
}
|
|
|
private void OnBtnDeleteClick()
|
|
|
{
|
|
|
- if (_ui.m_c1.selectedIndex == 0 && _ui.m_list.numItems == 0)
|
|
|
+ if (_ui.m_c1.selectedIndex == 0 && GetEnablePhotoNum(true) == 0)
|
|
|
{
|
|
|
PromptController.Instance.ShowFloatTextPrompt("暂无照片可删除");
|
|
|
return;
|
|
|
}
|
|
|
- if (_ui.m_c1.selectedIndex == 1 && _ui.m_listTravel.numItems == 0)
|
|
|
+ if (_ui.m_c1.selectedIndex == 1 && GetEnablePhotoNum(true) == 0)
|
|
|
{
|
|
|
PromptController.Instance.ShowFloatTextPrompt("暂无明信片可删除");
|
|
|
return;
|
|
|
}
|
|
|
_ui.m_c2.selectedIndex = 1;
|
|
|
+ _ui.m_btnChooseAll.selected = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void OnBtnSaveClick()
|
|
|
+ {
|
|
|
+ if (_ui.m_c1.selectedIndex == 0 && _photoInfos.Count == 0)
|
|
|
+ {
|
|
|
+ PromptController.Instance.ShowFloatTextPrompt("暂无照片可保存");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (_ui.m_c1.selectedIndex == 1 && _photoInfos.Count == 0)
|
|
|
+ {
|
|
|
+ PromptController.Instance.ShowFloatTextPrompt("暂无明信片可保存");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ _ui.m_c2.selectedIndex = 2;
|
|
|
+ _ui.m_btnChooseAll.selected = false;
|
|
|
}
|
|
|
|
|
|
private void OnBtnTabChange()
|
|
|
{
|
|
|
_ui.m_c2.selectedIndex = 0;
|
|
|
- _listDelete.Clear();
|
|
|
+ _listChoose.Clear();
|
|
|
UpdateView();
|
|
|
|
|
|
}
|
|
@@ -138,14 +168,16 @@ namespace GFGGame
|
|
|
_ui.m_txtCount.text = string.Format("{0}/{1}", _photoInfos.Count, RoleDataManager.WanShuiQianShanMaxStorageCount);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- _ui.m_btnConfirmDelete.m_txtTitle.text = string.Format("删除 {0}/{1}", _listDelete.Count, _photoInfos.Count);
|
|
|
+
|
|
|
+ _ui.m_btnConfirmDelete.title = string.Format("删除 {0}/{1}", _listChoose.Count, _photoInfos.Count);
|
|
|
+ _ui.m_btnConfirmSave.title = string.Format("保存 {0}/{1}", _listChoose.Count, _photoInfos.Count);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private void RenderListItem(int index, GObject obj)
|
|
|
{
|
|
|
UI_ListPhotoItem item = UI_ListPhotoItem.Proxy(obj);
|
|
|
- if (_ui.m_c2.selectedIndex == 1 && _listDelete.IndexOf(_photoInfos[index].PictureId) >= 0)
|
|
|
+ if (_ui.m_c2.selectedIndex != 0 && _listChoose.IndexOf(_photoInfos[index].PictureId) >= 0)
|
|
|
{
|
|
|
item.m_c1.SetSelectedIndex(1);
|
|
|
}
|
|
@@ -193,7 +225,7 @@ namespace GFGGame
|
|
|
|
|
|
UI_ComPhotoPostcard item = UI_ComPhotoPostcard.Proxy(obj);
|
|
|
|
|
|
- item.m_c1.selectedIndex = _ui.m_c2.selectedIndex == 1 && _listDelete.IndexOf(_photoInfos[index].PictureId) >= 0 ? 1 : 0;
|
|
|
+ item.m_c1.selectedIndex = _ui.m_c2.selectedIndex != 0 && _listChoose.IndexOf(_photoInfos[index].PictureId) >= 0 ? 1 : 0;
|
|
|
item.m_comTravel.m_loaBg.url = ResPathUtil.GetTravelBgPath(loactionCfg.res);
|
|
|
item.m_comTravel.m_loaRole.url = "";
|
|
|
if (poemPhotoData.TravelSuitId > 0)
|
|
@@ -235,36 +267,51 @@ namespace GFGGame
|
|
|
{
|
|
|
ViewManager.Show<PoemPhotoPreView>(new object[] { index, _photoInfos, _sourceType });
|
|
|
}
|
|
|
- else if (_ui.m_c2.selectedIndex == 1)
|
|
|
+ else
|
|
|
{
|
|
|
- if (photoData.LockingStatus)
|
|
|
+ if (_ui.m_c2.selectedIndex == 1)
|
|
|
{
|
|
|
- PromptController.Instance.ShowFloatTextPrompt("锁定的照片无法删除");
|
|
|
- return;
|
|
|
- }
|
|
|
- if (photoData.ToppingStatus)
|
|
|
- {
|
|
|
- PromptController.Instance.ShowFloatTextPrompt("置顶的照片无法删除");
|
|
|
- return;
|
|
|
+ if (photoData.LockingStatus)
|
|
|
+ {
|
|
|
+ PromptController.Instance.ShowFloatTextPrompt("锁定的照片无法删除");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (photoData.ToppingStatus)
|
|
|
+ {
|
|
|
+ PromptController.Instance.ShowFloatTextPrompt("置顶的照片无法删除");
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
UI_ListPhotoItem item = UI_ListPhotoItem.Proxy(obj.parent);
|
|
|
|
|
|
item.m_c1.selectedIndex ^= 1;
|
|
|
if (item.m_c1.selectedIndex == 1)
|
|
|
{
|
|
|
- _listDelete.Add(photoData.PictureId);
|
|
|
+ _listChoose.Add(photoData.PictureId);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- _listDelete.Remove(photoData.PictureId);
|
|
|
+ _listChoose.Remove(photoData.PictureId);
|
|
|
}
|
|
|
UI_ListPhotoItem.ProxyEnd();
|
|
|
- _ui.m_btnConfirmDelete.m_txtTitle.text = string.Format("删除({0}/{1})", _listDelete.Count, _photoInfos.Count);
|
|
|
+
|
|
|
+ if (_ui.m_c2.selectedIndex == 1)
|
|
|
+ {
|
|
|
+ _ui.m_btnConfirmDelete.title = string.Format("删除({0}/{1})", _listChoose.Count, _photoInfos.Count);
|
|
|
+ _ui.m_btnChooseAll.selected = (GetEnablePhotoNum(true) == _listChoose.Count);
|
|
|
+ }
|
|
|
+ else if (_ui.m_c2.selectedIndex == 2)
|
|
|
+ {
|
|
|
+ _ui.m_btnConfirmSave.title = string.Format("保存({0}/{1})", _listChoose.Count, _photoInfos.Count);
|
|
|
+ _ui.m_btnChooseAll.selected = (GetEnablePhotoNum(false) == _listChoose.Count);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
private void OnBtnConfirmDeleteClick()
|
|
|
{
|
|
|
- if (_listDelete.Count == 0)
|
|
|
+ if (_listChoose.Count == 0)
|
|
|
{
|
|
|
PromptController.Instance.ShowFloatTextPrompt("请选择要删除的照片");
|
|
|
return;
|
|
@@ -272,10 +319,10 @@ namespace GFGGame
|
|
|
AlertUI.Show("删除后的照片无法恢复,是否确认删除?")
|
|
|
.SetLeftButton(true, "否").SetRightButton(true, "是", async (object data) =>
|
|
|
{
|
|
|
- bool result = await PoemPhotoSProxy.ReqRemovedPhoto(_listDelete, _sourceType);
|
|
|
+ bool result = await PoemPhotoSProxy.ReqRemovedPhoto(_listChoose, _sourceType);
|
|
|
if (result)
|
|
|
{
|
|
|
- _listDelete.Clear();
|
|
|
+ _listChoose.Clear();
|
|
|
OnBtnTabChange();
|
|
|
}
|
|
|
});
|
|
@@ -283,9 +330,9 @@ namespace GFGGame
|
|
|
|
|
|
private void OnBtnLockClick(EventContext context)
|
|
|
{
|
|
|
- if (_ui.m_c2.selectedIndex == 1)
|
|
|
+ if (_ui.m_c2.selectedIndex != 0)
|
|
|
{
|
|
|
- PromptController.Instance.ShowFloatTextPrompt("删除状态无法操作");
|
|
|
+ //PromptController.Instance.ShowFloatTextPrompt("删除状态无法操作");
|
|
|
return;
|
|
|
}
|
|
|
GObject item = context.sender as GObject;
|
|
@@ -314,9 +361,9 @@ namespace GFGGame
|
|
|
|
|
|
private void OnBtnUpClick(EventContext context)
|
|
|
{
|
|
|
- if (_ui.m_c2.selectedIndex == 1)
|
|
|
+ if (_ui.m_c2.selectedIndex != 0)
|
|
|
{
|
|
|
- PromptController.Instance.ShowFloatTextPrompt("删除状态无法操作");
|
|
|
+ //PromptController.Instance.ShowFloatTextPrompt("删除状态无法操作");
|
|
|
return;
|
|
|
}
|
|
|
GObject item = context.sender as GObject;
|
|
@@ -364,12 +411,140 @@ namespace GFGGame
|
|
|
/// </summary>
|
|
|
private void InitTypeList()
|
|
|
{
|
|
|
- for(int i = 0; i < _ui.m_typeList.numChildren; i++)
|
|
|
+ for (int i = 0; i < _ui.m_typeList.numChildren; i++)
|
|
|
{
|
|
|
UI_Button6 button6 = UI_Button6.Proxy(_ui.m_typeList.GetChildAt(i));
|
|
|
button6.m_title1.text = button6.target.title;
|
|
|
UI_Button6.ProxyEnd();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 获取当前相册可操作的相片数量
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="delete">为true时跳过锁住的和置顶的相片</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private int GetEnablePhotoNum(bool delete)
|
|
|
+ {
|
|
|
+ int num = 0;
|
|
|
+ for (int i = 0; i < _photoInfos.Count; i++)
|
|
|
+ {
|
|
|
+ PoemPhotoData photoData = _photoInfos[i];
|
|
|
+
|
|
|
+ if (delete && (photoData.LockingStatus || photoData.ToppingStatus))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ ++num;
|
|
|
+ }
|
|
|
+
|
|
|
+ return num;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void OnClickBtnChooseAll()
|
|
|
+ {
|
|
|
+ _listChoose.Clear();
|
|
|
+
|
|
|
+ GList list = ((_ui.m_c1.selectedIndex == 0) ? _ui.m_list : _ui.m_listTravel);
|
|
|
+ for (int i = 0; i < _photoInfos.Count; i++)
|
|
|
+ {
|
|
|
+ PoemPhotoData photoData = _photoInfos[i];
|
|
|
+
|
|
|
+ // 删除全选时不选择 置顶或者锁住 的照片
|
|
|
+ if (_ui.m_c2.selectedIndex == 1 && (photoData.LockingStatus || photoData.ToppingStatus))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (_ui.m_btnChooseAll.selected)
|
|
|
+ {
|
|
|
+ _listChoose.Add(photoData.PictureId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ list.numItems = _photoInfos.Count;
|
|
|
+ if (_ui.m_c2.selectedIndex == 1)
|
|
|
+ {
|
|
|
+ _ui.m_btnConfirmDelete.title = string.Format("删除({0}/{1})", _listChoose.Count, _photoInfos.Count);
|
|
|
+ }
|
|
|
+ else if (_ui.m_c2.selectedIndex == 2)
|
|
|
+ {
|
|
|
+ _ui.m_btnConfirmSave.title = string.Format("保存({0}/{1})", _listChoose.Count, _photoInfos.Count);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void OnClickConfirmSave()
|
|
|
+ {
|
|
|
+ if (_listChoose.Count == 0)
|
|
|
+ {
|
|
|
+ PromptController.Instance.ShowFloatTextPrompt("请选择要保存的照片");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+#if UNITY_EDITOR
|
|
|
+ OpenSaveView();
|
|
|
+#else
|
|
|
+ CheckSaveLocal();
|
|
|
+#endif
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 检查保存相片相应权限
|
|
|
+ /// </summary>
|
|
|
+ private async void CheckSaveLocal()
|
|
|
+ {
|
|
|
+ string permissionName = "存储";
|
|
|
+#if UNITY_IOS
|
|
|
+ permissionName = "相册";
|
|
|
+#endif
|
|
|
+ NativeGallery.Permission permission = NativeGallery.CheckPermission(NativeGallery.PermissionType.Write, NativeGallery.MediaType.Image);
|
|
|
+ Debug.Log("Permission result: " + permission);
|
|
|
+
|
|
|
+ if (permission.Equals(NativeGallery.Permission.Denied))
|
|
|
+ {
|
|
|
+ string tips = $"保存至本地需要使用{permissionName}权限,您已经禁止!请前往手机系统设置开启应用的{permissionName}权限。";
|
|
|
+ if (NativeGallery.CanOpenSettings())
|
|
|
+ {
|
|
|
+ AlertSystem.Show(tips)
|
|
|
+ .SetLeftButton(true, "前往", (data) => { NativeGallery.OpenSettings(); })
|
|
|
+ .SetRightButton(true, "拒绝");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ AlertSystem.Show(tips)
|
|
|
+ .SetLeftButton(true, "知道了");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (permission.Equals(NativeGallery.Permission.ShouldAsk))
|
|
|
+ {
|
|
|
+ string tips = $"保存至本地需要使用{permissionName}权限,请同意!";
|
|
|
+ PromptController.Instance.ShowFloatTextPrompt(tips);
|
|
|
+ permission = await NativeGallery.RequestPermissionAsync(NativeGallery.PermissionType.Write, NativeGallery.MediaType.Image);
|
|
|
+ //Debug.Log("Permission result: " + permission);
|
|
|
+ if (!permission.Equals(NativeGallery.Permission.Granted))
|
|
|
+ {
|
|
|
+ PromptController.Instance.ShowFloatTextPrompt($"由于被禁止{permissionName}权限,保存失败!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //Debug.Log("Permission result: " + permission);
|
|
|
+ }
|
|
|
+
|
|
|
+ OpenSaveView();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void OpenSaveView()
|
|
|
+ {
|
|
|
+ SavePhotoList savePhoto = new SavePhotoList();
|
|
|
+ savePhoto.pageIndex = _ui.m_c1.selectedIndex;
|
|
|
+ savePhoto.photoInfos = _photoInfos;
|
|
|
+ savePhoto.listChoose = _listChoose;
|
|
|
+
|
|
|
+ ViewManager.Show<PoemPhotoSaveView>(savePhoto);
|
|
|
+ }
|
|
|
}
|
|
|
}
|