123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
- using System;
- using System.IO;
- using System.Xml.Linq;
- using UnityEngine;
- public class PhotoModePoseSave : MonoBehaviour
- {
- public static string folder_path
- {
- get
- {
- string text = PhotoWindowManager.path_photo_folder + "MyPose";
- if (!Directory.Exists(text))
- {
- Directory.CreateDirectory(text);
- }
- return text;
- }
- }
- 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 OpenFingerSaveMode(XDocument save_target_xml, string save_dir_name, Action success_call_back)
- {
- if (save_target_xml == null)
- {
- return;
- }
- this.mode_ = PhotoModePoseSave.Mode.Finger;
- this.save_target_binary_ = null;
- this.save_target_xml_ = save_target_xml;
- this.save_dir_name_ = save_dir_name;
- this.success_call_back_ = success_call_back;
- this.Open();
- }
- public void OpenPoseSaveMode(byte[] save_target_binary)
- {
- if (this.is_fade_processed || save_target_binary == null || save_target_binary.Length <= 0)
- {
- return;
- }
- this.mode_ = PhotoModePoseSave.Mode.Pose;
- this.save_target_xml_ = null;
- this.save_target_binary_ = save_target_binary;
- this.Open();
- }
- public void OnBtnOk()
- {
- this.InputPoseName.RemoveFocus();
- char[] invalidFileNameChars = Path.GetInvalidFileNameChars();
- string file_name = this.InputPoseName.value;
- if (string.IsNullOrEmpty(file_name))
- {
- GameMain.Instance.SysDlg.ShowFromLanguageTerm("ScenePhotoMode/Pエディット/ダイアログ/ポーズ名が記入されていません", null, SystemDialog.TYPE.OK, null, null);
- return;
- }
- if (0 <= file_name.IndexOfAny(invalidFileNameChars))
- {
- GameMain.Instance.SysDlg.ShowFromLanguageTerm("ScenePhotoMode/Pエディット/ダイアログ/ポーズ名に使用できない文字が使われています", null, SystemDialog.TYPE.OK, null, null);
- return;
- }
- if (this.mode_ == PhotoModePoseSave.Mode.Pose)
- {
- file_name = this.mode_folder_path + "\\" + file_name + ".anm";
- }
- else
- {
- file_name = this.mode_folder_path + "\\" + file_name + ".xml";
- }
- if (250 < file_name.Length)
- {
- GameMain.Instance.SysDlg.ShowFromLanguageTerm("ScenePhotoMode/Pエディット/ダイアログ/ポーズ名が長すぎます", null, SystemDialog.TYPE.OK, null, null);
- return;
- }
- if (File.Exists(file_name))
- {
- GameMain.Instance.SysDlg.ShowFromLanguageTerm("ScenePhotoMode/Pエディット/ダイアログ/データが既に存在しています上書きしますか?", null, SystemDialog.TYPE.YES_NO, delegate
- {
- GameMain.Instance.SysDlg.Close();
- this.Save(file_name);
- }, null);
- return;
- }
- this.Save(file_name);
- }
- public void Save(string file_name)
- {
- if (this.mode_ == PhotoModePoseSave.Mode.Pose)
- {
- if (this.save_target_binary_ == null && this.save_target_binary_.Length <= 0)
- {
- return;
- }
- }
- else if (this.save_target_xml_ == null)
- {
- return;
- }
- bool flag = File.Exists(file_name);
- try
- {
- if (this.mode_ == PhotoModePoseSave.Mode.Pose)
- {
- File.WriteAllBytes(file_name, this.save_target_binary_);
- }
- else
- {
- this.save_target_xml_.Save(file_name);
- }
- MotionWindow motionWindow = this.PhotoMgr.GetWindow(PhotoWindowManager.WindowType.Motion) as MotionWindow;
- if (this.mode_ == PhotoModePoseSave.Mode.Pose)
- {
- if (!flag)
- {
- motionWindow.AddMyPose(file_name);
- }
- else
- {
- motionWindow.OnUpdateMyPose(file_name);
- }
- }
- if (this.success_call_back_ != null)
- {
- this.success_call_back_();
- }
- }
- catch
- {
- GameMain.Instance.SysDlg.ShowFromLanguageTerm("ScenePhotoMode/Pエディット/ダイアログ/ポーズの保存に失敗しました", null, SystemDialog.TYPE.OK, null, null);
- return;
- }
- if (this.mode_ == PhotoModePoseSave.Mode.Pose)
- {
- GameMain.Instance.SysDlg.ShowFromLanguageTerm("ScenePhotoMode/Pエディット/ダイアログ/ポーズを保存しましたモーションウィンドウのマイポーズから選択できます", null, SystemDialog.TYPE.OK, delegate
- {
- GameMain.Instance.SysDlg.Close();
- this.OnBtnCancel();
- }, null);
- }
- else
- {
- GameMain.Instance.SysDlg.ShowFromLanguageTerm("ScenePhotoMode/Pエディット/ダイアログ/ポーズを保存しました", 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 void Open()
- {
- 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);
- }
- });
- }
- private void Update()
- {
- }
- private void OnChangeTitle(PhotSaveLoagDataUnit unit)
- {
- }
- public void OnClickBG()
- {
- if (this.is_fade_processed)
- {
- return;
- }
- if (UICamera.currentTouchID == -2)
- {
- this.OnBtnCancel();
- }
- }
- private bool is_fade_processed
- {
- get
- {
- TweenAlpha component = base.gameObject.GetComponent<TweenAlpha>();
- if (component != null && !component.enabled)
- {
- component.enabled = true;
- }
- return component != null;
- }
- }
- private string mode_folder_path
- {
- get
- {
- string text = string.Empty;
- if (this.mode_ == PhotoModePoseSave.Mode.Pose)
- {
- text = PhotoModePoseSave.folder_path;
- }
- else
- {
- if (!Directory.Exists(PhotoWindowManager.path_photo_folder + "FingerData"))
- {
- Directory.CreateDirectory(PhotoWindowManager.path_photo_folder + "FingerData");
- }
- text = PhotoWindowManager.path_photo_folder + "FingerData/" + this.save_dir_name_;
- if (!Directory.Exists(text))
- {
- Directory.CreateDirectory(text);
- }
- }
- return text;
- }
- }
- public PhotoWindowManager PhotoMgr;
- public UIInput InputPoseName;
- private PhotoModePoseSave.Mode mode_;
- private byte[] save_target_binary_;
- private string save_dir_name_;
- private XDocument save_target_xml_;
- private Action success_call_back_;
- private enum Mode
- {
- Pose,
- Finger
- }
- }
|