12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- using System;
- using System.Collections;
- using System.IO;
- using ET;
- using FairyGUI;
- using UI.DressUp;
- using UnityEngine;
- namespace GFGGame
- {
- public class PhotographSaveView : BaseView
- {
- private UI_PhotographSaveUI _ui;
- private byte[] bytes;
- protected override void OnInit()
- {
- base.OnInit();
- packageName = UI_PhotographUI.PACKAGE_NAME;
- _ui = UI_PhotographSaveUI.Create();
- viewCom = _ui.target;
- isfullScreen = true;
- _ui.m_btnClose.onClick.Add(this.Hide);
- _ui.m_btnSave.onClick.Add(this.OnClickBtnSave);
- _ui.m_btnSavePhoto.onClick.Add(this.OnClickBtnSavePhoto);
- }
- protected override void OnShown()
- {
- base.OnShown();
- Texture2D tex = this.viewData as Texture2D;
- bytes = tex.EncodeToJPG();//将纹理数据,转化成一个jpg图片
- _ui.m_imgRes.texture = new NTexture(tex);
- float width = _ui.m_imgBorder.width;
- float height = width * tex.height / tex.width;
- _ui.m_imgRes.SetSize(width, height);
- _ui.m_imgBorder.SetSize(width, height + 12);
- }
- protected override void OnHide()
- {
- base.OnHide();
- }
- public override void Dispose()
- {
- if (_ui != null)
- {
- _ui.Dispose();
- _ui = null;
- }
- base.Dispose();
- }
- private void OnClickBtnSave()
- {
- // Texture2D tex = this.viewData as Texture2D;
- // byte[] bytes = tex.EncodeToJPG();//将纹理数据,转化成一个jpg图片
- string fileName = "wsj" + TimeHelper.ServerNowSecs + ".jpg";
- PhotographDataManager.Instance.SavePicturoToLocal(bytes, fileName);
- }
- private async void OnClickBtnSavePhoto()
- {
- if (PoemPhotoDataManager.Instance.PersonalPhotoInfos.Count >= GlobalCfgArray.globalCfg.maxPhotoCount)
- {
- PromptController.Instance.ShowFloatTextPrompt("照片数量已达上限");
- return;
- }
- // Texture2D tex = this.viewData as Texture2D;
- // byte[] bytes = tex.EncodeToJPG();//将纹理数据,转化成一个jpg图片
- string[] rsp = await PoemPhotoSProxy.ReqTempPictureUrl((int)PictureType.jpg);
- if (rsp == null) return;
- string code = PoemPhotoSProxy.PushToHWCloud(rsp[0], bytes);
- if (string.IsNullOrEmpty(code)) return;
- PoemPhotoSProxy.ReqAddTophoto(rsp[1], (int)PictureSourceType.PersonalAlbum).Coroutine();
- }
- }
- }
|