123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- using System.Collections.Generic;
- using ET;
- using FairyGUI;
- using UI.Poem;
- using UnityEngine;
- namespace GFGGame
- {
- public class PoemPhotoPreView : BaseWindow
- {
- private UI_PoemPhotoPreviewUI _ui;
- private List<PoemPhotoData> _photoInfos;
- private int _curIndex = 0;
- private int _sourceType = 0;
- public override void Dispose()
- {
- if (_ui != null)
- {
- _ui.Dispose();
- _ui = null;
- }
- base.Dispose();
- }
- protected override void OnInit()
- {
- base.OnInit();
- packageName = UI_PoemPhotoPreviewUI.PACKAGE_NAME;
- _ui = UI_PoemPhotoPreviewUI.Create();
- this.viewCom = _ui.target;
- isfullScreen = true;
- _ui.m_grhBg.onClick.Add(OnBtnBackClick);
- _ui.m_list.SetVirtual();
- _ui.m_list.itemRenderer = RenderListItem;
- _ui.m_btnLeft.onClick.Add(OnBtnLeftClick);
- _ui.m_btnRight.onClick.Add(OnBtnRightClick);
- _ui.m_btnLock.target.onClick.Add(OnBtnLockClick);
- _ui.m_btnUp.target.onClick.Add(OnBtnUpClick);
- _ui.m_btnShare.onClick.Add(OnBtnShareClick);
- }
- protected override void AddEventListener()
- {
- base.AddEventListener();
- }
- protected override void OnShown()
- {
- base.OnShown();
- _curIndex = (int)(this.viewData as object[])[0];
- _sourceType = (int)(this.viewData as object[])[1];
- if (_sourceType == (int)PictureSourceType.PersonalAlbum)
- {
- _photoInfos = PoemPhotoDataManager.Instance.PersonalPhotoInfos;
- }
- else
- {
- _photoInfos = PoemPhotoDataManager.Instance.WsqsPhotoInfos;
- }
- _ui.m_list.numItems = _photoInfos.Count;
- if (_photoInfos.Count > 0) _ui.m_list.ScrollToView(_curIndex);
- UpdateView();
- }
- protected override void OnHide()
- {
- base.OnHide();
- }
- protected override void RemoveEventListener()
- {
- base.RemoveEventListener();
- }
- private void OnBtnBackClick()
- {
- ViewManager.GoBackFrom(typeof(PoemPhotoPreView).FullName);
- }
- private void UpdateView()
- {
- _ui.m_btnLeft.enabled = _curIndex > 0;
- _ui.m_btnRight.enabled = _curIndex < _ui.m_list.numItems - 1;
- _ui.m_txtTime.text = TimeUtil.FormattingTime1(_photoInfos[_curIndex].CreationTime);
- if (_ui.m_btnLock.target.data == null)
- {
- _ui.m_btnLock.target.onClick.Add(OnBtnLockClick);
- }
- _ui.m_btnLock.target.data = _curIndex;
- if (_ui.m_btnUp.target.data == null)
- {
- _ui.m_btnUp.target.onClick.Add(OnBtnUpClick);
- }
- _ui.m_btnUp.target.data = _curIndex;
- }
- private void RenderListItem(int index, GObject obj)
- {
- UI_ListPhotoPreviewItem item = UI_ListPhotoPreviewItem.Proxy(obj);
- item.m_comPhoto.m_loaPhoto.texture = PoemPhotoDataManager.Instance.BytesToTexture2D(_photoInfos[index].Bytes);
- UI_ListPhotoPreviewItem.ProxyEnd();
- }
- private void OnBtnLeftClick()
- {
- _curIndex--;
- _curIndex = Mathf.Max(0, _curIndex);
- UpdateView();
- }
- private void OnBtnRightClick()
- {
- _curIndex++;
- _curIndex = Mathf.Min(_ui.m_list.numItems - 1, _curIndex);
- UpdateView();
- }
- private void OnBtnLockClick()
- {
- PoemPhotoData photoData = _photoInfos[_curIndex];
- if (photoData.LockingStatus == false)
- {
- AlertUI.Show("是否确认锁定此照片?", "(锁住的照片无法被删除)")
- .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
- {
- PoemPhotoSProxy.ReqChangeLockingState(photoData.PictureId, true, _sourceType).Coroutine();
- });
- }
- else
- {
- AlertUI.Show("是否确认解锁此照片?", "(解锁后的照片可随意删除)")
- .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
- {
- PoemPhotoSProxy.ReqChangeLockingState(photoData.PictureId, false, _sourceType).Coroutine();
- });
- }
- }
- private void OnBtnUpClick()
- {
- PoemPhotoData photoData = _photoInfos[_curIndex];
- if (photoData.ToppingStatus == false)
- {
- AlertUI.Show("是否确认置顶此照片?")
- .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
- {
- PoemPhotoSProxy.ReqChangeToppingState(photoData.PictureId, true, _sourceType).Coroutine();
- });
- }
- else
- {
- AlertUI.Show("是否确认取消置顶此照片?")
- .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
- {
- PoemPhotoSProxy.ReqChangeToppingState(photoData.PictureId, false, _sourceType).Coroutine();
- });
- }
- }
- private void OnBtnShareClick()
- {
- ViewManager.Show<PoemPhotoShareView>(new object[] { _curIndex, _sourceType }, new object[] { typeof(PoemPhotoPreView).FullName, _curIndex });
- }
- }
- }
|