123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- using System;
- using System.IO;
- using UnityEngine;
- public class PhotoModeObjectSave : MonoBehaviour
- {
- public void Awake()
- {
- EventDelegate.Add(UTY.GetChildObject(base.gameObject, "Base/Ok", false).GetComponent<UIButton>().onClick, new EventDelegate.Callback(this.OnBtnOk));
- EventDelegate.Add(UTY.GetChildObject(base.gameObject, "Base/Cancel", false).GetComponent<UIButton>().onClick, new EventDelegate.Callback(this.OnBtnCancel));
- }
- public void Start()
- {
- }
- public void Open(BasePhotoCustomObject saveObject, Action<string> successCallBack)
- {
- this.saveObject = saveObject;
- this.successCallBack = successCallBack;
- base.gameObject.SetActive(true);
- TweenAlpha tweenAlpha = base.gameObject.AddComponent<TweenAlpha>();
- tweenAlpha.from = 0f;
- tweenAlpha.to = 1f;
- tweenAlpha.duration = 0.3f;
- tweenAlpha.PlayForward();
- EventDelegate.Set(tweenAlpha.onFinished, delegate()
- {
- TweenAlpha component = base.gameObject.GetComponent<TweenAlpha>();
- if (component != null)
- {
- UnityEngine.Object.DestroyImmediate(component);
- }
- });
- }
- public void OnBtnOk()
- {
- this.InputPoseName.RemoveFocus();
- char[] invalidFileNameChars = Path.GetInvalidFileNameChars();
- string text = this.InputPoseName.value;
- if (string.IsNullOrEmpty(text))
- {
- GameMain.Instance.SysDlg.ShowFromLanguageTerm("ScenePhotoMode/マイオブジェ/ダイアログ/オブジェクト名が記入されていません", null, SystemDialog.TYPE.OK, null, null);
- return;
- }
- if (0 <= text.IndexOfAny(invalidFileNameChars))
- {
- GameMain.Instance.SysDlg.ShowFromLanguageTerm("ScenePhotoMode/マイオブジェ/ダイアログ/オブジェクト名に使用できない文字が使われています", null, SystemDialog.TYPE.OK, null, null);
- return;
- }
- text = ObjectCreateWindow.folder_path + "\\" + text + ".poj";
- if (250 < text.Length)
- {
- GameMain.Instance.SysDlg.ShowFromLanguageTerm("ScenePhotoMode/マイオブジェ/ダイアログ/オブジェクト名が長すぎます", null, SystemDialog.TYPE.OK, null, null);
- return;
- }
- if (File.Exists(text))
- {
- GameMain.Instance.SysDlg.ShowFromLanguageTerm("ScenePhotoMode/マイオブジェ/ダイアログ/データが既に存在しています別の名前を指定してください", null, SystemDialog.TYPE.OK, null, null);
- return;
- }
- this.Save(text);
- }
- public void Save(string file_name)
- {
- try
- {
- File.WriteAllBytes(file_name, this.saveObject.Serialize());
- }
- catch
- {
- GameMain.Instance.SysDlg.ShowFromLanguageTerm("ScenePhotoMode/マイオブジェ/ダイアログ/オブジェクトの保存に失敗しました", null, SystemDialog.TYPE.OK, null, null);
- return;
- }
- if (this.successCallBack != null)
- {
- this.successCallBack(file_name);
- }
- GameMain.Instance.SysDlg.ShowFromLanguageTerm("ScenePhotoMode/マイオブジェ/ダイアログ/オブジェクトを保存しましたオブジェクト管理ウィンドウのマイオブジェクトから選択できます", null, SystemDialog.TYPE.OK, delegate
- {
- GameMain.Instance.SysDlg.Close();
- this.OnBtnCancel();
- }, null);
- }
- public void OnBtnCancel()
- {
- this.InputPoseName.RemoveFocus();
- if (this.is_fade_processed)
- {
- return;
- }
- TweenAlpha tweenAlpha = base.gameObject.AddComponent<TweenAlpha>();
- tweenAlpha.from = 1f;
- tweenAlpha.to = 0f;
- tweenAlpha.duration = 0.3f;
- tweenAlpha.PlayForward();
- EventDelegate.Set(tweenAlpha.onFinished, delegate()
- {
- TweenAlpha component = base.gameObject.GetComponent<TweenAlpha>();
- if (component != null)
- {
- UnityEngine.Object.DestroyImmediate(component);
- }
- base.gameObject.SetActive(false);
- });
- }
- private bool is_fade_processed
- {
- get
- {
- TweenAlpha component = base.gameObject.GetComponent<TweenAlpha>();
- if (component != null && !component.enabled)
- {
- component.enabled = true;
- }
- return component != null;
- }
- }
- public PhotoWindowManager PhotoMgr;
- public UIInput InputPoseName;
- private BasePhotoCustomObject saveObject;
- private Action<string> successCallBack;
- }
|