using System; using System.Collections.Generic; using System.IO; using System.Xml.Linq; using MaidStatus; using UnityEngine; using wf; public class PhotoWindowManager : BasePhotoWindowManager { public static Dictionary maidGuidReplaceDic { get; private set; } public static GameObject GetWorldTransformAxisParent() { GameObject gameObject = GameObject.Find("WorldTransformAxisParent"); if (gameObject == null) { gameObject = new GameObject("WorldTransformAxisParent"); } return gameObject; } public static WorldTransformAxis CreateWorldTransformAxis(GameObject move_target_obj, bool forc_create, bool small = false) { GameObject gameObject = GameObject.Find("WorldTransformAxisParent"); if (gameObject == null) { gameObject = new GameObject("WorldTransformAxisParent"); } GameObject gameObject2 = GameObject.Find("WorldTransformAxisParent/TargetObj_" + move_target_obj.name); if (gameObject2 != null && !forc_create) { return gameObject2.GetComponent(); } WorldTransformAxis component; if (!small) { if (GameMain.Instance.VRMode) { component = Utility.CreatePrefab(gameObject, "System/Prefab/XYZAxis_VR", false).GetComponent(); } else { component = Utility.CreatePrefab(gameObject, "System/Prefab/XYZAxis", true).GetComponent(); } } else if (GameMain.Instance.VRMode) { component = Utility.CreatePrefab(gameObject, "System/Prefab/XYZAxis_VR_s", false).GetComponent(); } else { component = Utility.CreatePrefab(gameObject, "System/Prefab/XYZAxis_s", false).GetComponent(); } component.TargetObject = move_target_obj; component.name = "TargetObj_" + move_target_obj.name; component.Update(); return component; } public static GizmoRender CreateWorldTransformRotate(GameObject rotate_target_obj, bool forc_create) { GizmoRender gizmoRender = rotate_target_obj.GetComponent(); if (gizmoRender == null) { gizmoRender = rotate_target_obj.AddComponent(); gizmoRender.eRotate = true; gizmoRender.Visible = false; } return gizmoRender; } public static string path_photo_folder { get { return Path.Combine(GameMain.Instance.SerializeStorageManager.StoreDirectoryPath, "PhotoModeData\\"); } } public static string path_photo_save { get { string text = Path.Combine(PhotoWindowManager.path_photo_folder, "SaveData"); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } return text; } } public static string path_photo_mod_motion { get { string text = Path.Combine(PhotoWindowManager.path_photo_folder, "Mod\\Motion"); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } return text; } } public override void Awake() { PhotoWindowManager.maidGuidReplaceDic = null; BaseMaidPhotoWindow[] componentsInChildren = base.transform.GetComponentsInChildren(true); foreach (BaseMaidPhotoWindow baseMaidPhotoWindow in componentsInChildren) { if (!baseMaidPhotoWindow.gameObject.activeSelf) { baseMaidPhotoWindow.gameObject.SetActive(true); } } BasePhotoSubWindow[] componentsInChildren2 = base.transform.GetComponentsInChildren(true); foreach (BasePhotoSubWindow basePhotoSubWindow in componentsInChildren2) { if (!basePhotoSubWindow.gameObject.activeSelf) { basePhotoSubWindow.gameObject.SetActive(true); } } base.Awake(); } public override void Start() { Dictionary indexDic = new Dictionary(); for (int i = 0; i < PhotoWindowManager.deserializeWindowArray.Length; i++) { indexDic.Add(PhotoWindowManager.deserializeWindowArray[i], i); } this.window_dic_.Sort((KeyValuePair a, KeyValuePair b) => indexDic[(a.Key as PhotoWindow).Type] - indexDic[(b.Key as PhotoWindow).Type]); base.Start(); this.maid_store_data_.Clear(); GameMain.Instance.CharacterMgr.DeactivateCharaAll(); GameMain.Instance.CharacterMgr.DeactivateMaid(0); this.SaveAndLoadManager.folder_path = PhotoWindowManager.path_photo_save; this.SaveAndLoadManager.onSerializeEvent = new Func(this.OnSerializeEvent); this.SaveAndLoadManager.onDeserializeEvent = new Action(this.OnDeserializeEvent); } public void Initialize() { this.OnMaidChangeEvent(null); uGUITutorialPanel.OpenTutorial("ScenePhotoMode", null, false); GameMain.Instance.SysShortcut.strSceneHelpName = "ScenePhotoMode"; } public virtual void Update() { } public void CallTutorial() { uGUITutorialPanel.OpenTutorial("ScenePhotoMode", null, true); } public void OpenSavePanel() { if (this.SaveAndLoadManager != null) { this.SaveAndLoadManager.Open(true); } } public void OpenLoadPanel() { if (this.SaveAndLoadManager != null) { this.SaveAndLoadManager.Open(false); } } protected override bool OnAddWindow(BasePhotoWindow add_win) { InterfaceMaidPhotoWindow interfaceMaidPhotoWindow = add_win as InterfaceMaidPhotoWindow; return interfaceMaidPhotoWindow != null; } public PhotoWindow GetWindow(PhotoWindowManager.WindowType window_type) { foreach (KeyValuePair keyValuePair in this.window_dic_) { InterfaceMaidPhotoWindow interfaceMaidPhotoWindow = keyValuePair.Key as InterfaceMaidPhotoWindow; if (interfaceMaidPhotoWindow != null) { if (interfaceMaidPhotoWindow.window_type == window_type) { return keyValuePair.Key as PhotoWindow; } } } return null; } public void OnMaidChangeEvent(Maid maid) { this.select_maid_ = maid; foreach (KeyValuePair keyValuePair in this.window_dic_) { (keyValuePair.Key as InterfaceMaidPhotoWindow).OnMaidChangeEvent(maid); } } public void OnMaidAddEvent(Maid maid, bool is_deserialize_load) { if (!this.maid_store_data_.ContainsKey(maid.status.guid)) { this.maid_store_data_.Add(maid.status.guid, new Dictionary>()); } foreach (KeyValuePair keyValuePair in this.window_dic_) { (keyValuePair.Key as InterfaceMaidPhotoWindow).OnMaidAddEvent(maid, is_deserialize_load); } } public void OnFinishMaidDeserializeLoad() { foreach (KeyValuePair keyValuePair in this.window_dic_) { (keyValuePair.Key as InterfaceMaidPhotoWindow).OnFinishMaidDeserializeLoad(); } } public void OnMaidRemoveEvent(Maid maid) { if (this.maid_store_data_.ContainsKey(maid.status.guid)) { this.maid_store_data_.Remove(maid.status.guid); } if (maid == this.select_maid_) { this.select_maid_ = null; } foreach (KeyValuePair keyValuePair in this.window_dic_) { (keyValuePair.Key as InterfaceMaidPhotoWindow).OnMaidRemoveEvent(maid); } } public void OnMaidRemoveEventPrev(Maid maid) { if (maid == this.select_maid_) { this.select_maid_ = null; } foreach (KeyValuePair keyValuePair in this.window_dic_) { (keyValuePair.Key as InterfaceMaidPhotoWindow).OnMaidRemoveEventPrev(maid); } } public Dictionary GetMaidStoreData(Maid maid, PhotoWindow photo_window) { if (maid == null) { return null; } return this.GetMaidStoreData(maid.status.guid, photo_window); } public Dictionary GetMaidStoreData(string maid_guid, PhotoWindow photo_window) { if (string.IsNullOrEmpty(maid_guid)) { return null; } if (!this.maid_store_data_[maid_guid].ContainsKey(photo_window.Type.ToString())) { this.maid_store_data_[maid_guid].Add(photo_window.Type.ToString(), new Dictionary()); } return this.maid_store_data_[maid_guid][photo_window.Type.ToString()]; } public List GetMaidStoreGuidList() { List list = new List(); foreach (KeyValuePair>> keyValuePair in this.maid_store_data_) { list.Add(keyValuePair.Key); } return list; } public XElement OnSerializeEvent() { List list = new List(); foreach (KeyValuePair keyValuePair in this.window_dic_) { (keyValuePair.Key as InterfaceMaidPhotoWindow).OnSerializeEvent(); } CameraMain mainCamera = GameMain.Instance.MainCamera; this.world_store_data_["カメラ"] = new Dictionary>(); this.world_store_data_["カメラ"]["transform"] = new Dictionary(); this.world_store_data_["カメラ"]["transform"]["target_position"] = mainCamera.GetTargetPos().ToString("G9"); this.world_store_data_["カメラ"]["transform"]["distance"] = mainCamera.GetDistance().ToString("G9"); this.world_store_data_["カメラ"]["transform"]["rotation"] = mainCamera.GetAroundAngle().ToString("G9"); List list2 = new List(); foreach (KeyValuePair>> keyValuePair2 in this.world_store_data_) { string key = keyValuePair2.Key; Dictionary> value = keyValuePair2.Value; List list3 = new List(); foreach (KeyValuePair> keyValuePair3 in value) { string key2 = keyValuePair3.Key; List list4 = new List(); foreach (KeyValuePair keyValuePair4 in keyValuePair3.Value) { string key3 = keyValuePair4.Key; string value2 = keyValuePair4.Value; XElement xelement = new XElement("elm", value2); xelement.SetAttributeValue("name", key3); list4.Add(xelement); } XElement xelement2 = new XElement("Category"); xelement2.SetAttributeValue("name", key2); xelement2.Add(list4.ToArray()); list3.Add(xelement2); } XElement xelement3 = new XElement("Type"); xelement3.SetAttributeValue("name", key); xelement3.Add(list3); list2.Add(xelement3); } XElement xelement4 = new XElement("World", list2.ToArray()); Dictionary>> dictionary = this.maid_store_data_; List list5 = new List(); foreach (KeyValuePair>> keyValuePair5 in this.maid_store_data_) { int num = -1; string key4 = keyValuePair5.Key; Maid maid = GameMain.Instance.CharacterMgr.GetMaid(key4); if (maid == null) { for (int i = 0; i < GameMain.Instance.CharacterMgr.GetManCount(); i++) { Maid man = GameMain.Instance.CharacterMgr.GetMan(i); if (man != null && man.status.guid == key4) { num = i; maid = man; break; } } } if (maid == null) { Debug.Log("GUIDからMaidを探せなかったので保存されませんでした\n" + key4); } else { if (!keyValuePair5.Value.ContainsKey(PhotoWindowManager.WindowType.Placement.ToString())) { keyValuePair5.Value[PhotoWindowManager.WindowType.Placement.ToString()] = new Dictionary(); } Dictionary dictionary2 = keyValuePair5.Value[PhotoWindowManager.WindowType.Placement.ToString()]; dictionary2["position"] = maid.gameObject.transform.position.ToString("G9"); dictionary2["rotation"] = maid.gameObject.transform.rotation.ToString("G9"); dictionary2["scale"] = maid.gameObject.transform.localScale.ToString("G9"); dictionary2["visible"] = (maid.transform.GetChild(0).localScale.x != 0f).ToString(); List list6 = new List(); foreach (KeyValuePair> keyValuePair6 in keyValuePair5.Value) { XElement xelement5 = new XElement("Type"); xelement5.SetAttributeValue("name", keyValuePair6.Key); List list7 = new List(); foreach (KeyValuePair keyValuePair7 in keyValuePair6.Value) { string key5 = keyValuePair7.Key; string value3 = keyValuePair7.Value; XElement xelement6 = new XElement("elm", value3); xelement6.SetAttributeValue("name", key5); list7.Add(xelement6); } xelement5.Add(list7.ToArray()); list6.Add(xelement5); } XElement xelement7 = new XElement("Maid"); xelement7.SetAttributeValue("guid", key4); List list8 = new List(); NamePair charaName = maid.status.charaName; list8.Add(new XElement("name", charaName.name1 + " " + charaName.name2)); if (maid.boMAN) { list8.Add(new XElement("man_sloat", num.ToString())); } xelement7.Add(list8.ToArray()); xelement7.Add(list6.ToArray()); list5.Add(xelement7); } } XElement xelement8 = new XElement("Maids", list5.ToArray()); return new XElement("PhotSetting", new object[] { xelement4, xelement8 }); } public List GetDeserializeWindowList() { List list = new List(); for (int i = 0; i < PhotoWindowManager.deserializeWindowArray.Length; i++) { foreach (KeyValuePair keyValuePair in this.window_dic_) { if ((keyValuePair.Key as InterfaceMaidPhotoWindow).window_type == PhotoWindowManager.deserializeWindowArray[i]) { list.Add(keyValuePair.Key as InterfaceMaidPhotoWindow); break; } } } return list; } public void OnDeserializeEvent(XElement xml_data) { List call_window_list = this.GetDeserializeWindowList(); for (int i = 0; i < call_window_list.Count; i++) { call_window_list[i].OnReset(); } XElement xelement = xml_data.Element("PhotSetting"); XElement xelement2 = xelement.Element("World"); XElement xelement3 = xelement.Element("Maids"); this.world_store_data_.Clear(); foreach (XElement xelement4 in xelement2.Elements("Type")) { string value = xelement4.Attribute("name").Value; this.world_store_data_[value] = new Dictionary>(); foreach (XElement xelement5 in xelement4.Elements("Category")) { string value2 = xelement5.Attribute("name").Value; this.world_store_data_[value][value2] = new Dictionary(); foreach (XElement xelement6 in xelement5.Elements("elm")) { this.world_store_data_[value][value2].Add(xelement6.Attribute("name").Value, xelement6.Value); } } } this.maid_store_data_.Clear(); List> list = new List>(); foreach (XElement xelement7 in xelement3.Elements("Maid")) { bool flag = xelement7.Element("man_sloat") != null; int nManNo = (!flag) ? 0 : int.Parse(xelement7.Element("man_sloat").Value); string key = xelement7.Attribute("guid").Value; string value3 = xelement7.Element("name").Value; if (flag) { Maid man = GameMain.Instance.CharacterMgr.GetMan(nManNo); if (man == null) { continue; } key = man.status.guid; } this.maid_store_data_[key] = new Dictionary>(); foreach (XElement xelement8 in xelement7.Elements("Type")) { string value4 = xelement8.Attribute("name").Value; this.maid_store_data_[key][value4] = new Dictionary(); foreach (XElement xelement9 in xelement8.Elements("elm")) { this.maid_store_data_[key][value4].Add(xelement9.Attribute("name").Value, xelement9.Value); } } if (!flag) { list.Add(new KeyValuePair(key, value3)); } else { this.maid_store_data_[key]["is_man"] = new Dictionary(); this.maid_store_data_[key]["is_man"].Add("no", nManNo.ToString()); } } this.SaveAndLoadManager.LoadReplaceMaidPanel.OnReplaceEndEvent = delegate(Dictionary replace_dic) { PhotoWindowManager.maidGuidReplaceDic = new Dictionary(); foreach (KeyValuePair keyValuePair in replace_dic) { Dictionary> value5 = this.maid_store_data_[keyValuePair.Key]; this.maid_store_data_.Remove(keyValuePair.Key); if (keyValuePair.Value != null) { this.maid_store_data_[keyValuePair.Value.status.guid] = value5; } PhotoWindowManager.maidGuidReplaceDic.Add(keyValuePair.Key, (!(keyValuePair.Value != null)) ? string.Empty : keyValuePair.Value.status.guid); } for (int j = 0; j < call_window_list.Count; j++) { call_window_list[j].OnDeserializeEvent(); } PhotoWindowManager.maidGuidReplaceDic = null; }; this.SaveAndLoadManager.LoadReplaceMaidPanel.CheckAndStart(list); Dictionary dictionary = this.world_store_data_["カメラ"]["transform"]; GameMain.Instance.MainCamera.SetTargetPos(Parse.Vector3(dictionary["target_position"]), true); GameMain.Instance.MainCamera.SetDistance(float.Parse(dictionary["distance"]), true); GameMain.Instance.MainCamera.SetAroundAngle(Parse.Vector2(dictionary["rotation"]), true); } public void ScreenShot() { GameMain.Instance.SoundMgr.PlaySe("SE022.ogg", false); GameMain.Instance.MainCamera.ScreenShot(true); } public void AllCloseWindow() { GameObject childObject = UTY.GetChildObject(base.gameObject, "WindowVisibleBtnsParent", false); WindowPartsWindowVisible[] componentsInChildren = childObject.GetComponentsInChildren(); for (int i = 0; i < componentsInChildren.Length; i++) { if (componentsInChildren[i].TargetWindow.visible) { componentsInChildren[i].TargetWindow.visible = false; } } } public void AllInitPosWindow() { GameObject childObject = UTY.GetChildObject(base.gameObject, "WindowVisibleBtnsParent", false); WindowPartsWindowVisible[] componentsInChildren = childObject.GetComponentsInChildren(); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].TargetWindow.ResetPosition(); } } public void SetUIDrawOn() { foreach (KeyValuePair keyValuePair in this.window_dic_) { keyValuePair.Key.gameObject.SetActive(true); } UTY.GetChildObject(base.gameObject, "WindowVisibleBtnsParent/WindowVisibleBtns/Grid", false).SetActive(true); UTY.GetChildObject(base.gameObject, "WindowVisibleBtnsParent/WindowVisibleBtnsLine2/Grid", false).SetActive(true); UTY.GetChildObject(base.gameObject, "WindowVisibleBtnsParent/WindowVisibleBtns/UIOFF", false).SetActive(true); UTY.GetChildObject(base.gameObject, "WindowVisibleBtnsParent/WindowVisibleBtnsLine2/End", false).SetActive(true); UTY.GetChildObject(base.gameObject, "WindowVisibleBtnsParent/WindowVisibleBtnsLine2/UION", false).SetActive(false); for (int i = 0; i < this.ui_hide_object_list_.Count; i++) { this.ui_hide_object_list_[i].SetActive(true); } for (int j = 0; j < this.ui_gizmo_object_list_.Count; j++) { this.ui_gizmo_object_list_[j].Visible = true; } this.ui_hide_object_list_.Clear(); this.ui_gizmo_object_list_.Clear(); } public void SetUIDrawOff() { foreach (KeyValuePair keyValuePair in this.window_dic_) { keyValuePair.Key.gameObject.SetActive(false); } UTY.GetChildObject(base.gameObject, "WindowVisibleBtnsParent/WindowVisibleBtns/Grid", false).SetActive(false); UTY.GetChildObject(base.gameObject, "WindowVisibleBtnsParent/WindowVisibleBtnsLine2/Grid", false).SetActive(false); UTY.GetChildObject(base.gameObject, "WindowVisibleBtnsParent/WindowVisibleBtns/UIOFF", false).SetActive(false); UTY.GetChildObject(base.gameObject, "WindowVisibleBtnsParent/WindowVisibleBtnsLine2/End", false).SetActive(false); UTY.GetChildObject(base.gameObject, "WindowVisibleBtnsParent/WindowVisibleBtnsLine2/UION", false).SetActive(true); this.ui_hide_object_list_.Clear(); GameObject gameObject = GameObject.Find("WorldTransformAxisParent"); if (gameObject != null) { Transform transform = gameObject.transform; for (int i = 0; i < transform.childCount; i++) { if (transform.gameObject.activeSelf) { transform.gameObject.SetActive(true); this.ui_hide_object_list_.Add(transform.gameObject); } } gameObject.SetActive(false); } this.ui_gizmo_object_list_.Clear(); string[] array = new string[] { "BG", "Character/Active" }; for (int j = 0; j < array.Length; j++) { GameObject childObject = UTY.GetChildObject(GameMain.Instance.gameObject, array[j], true); if (!(childObject == null)) { GizmoRender[] componentsInChildren = childObject.GetComponentsInChildren(); for (int k = 0; k < componentsInChildren.Length; k++) { if (componentsInChildren[k].Visible) { componentsInChildren[k].Visible = false; this.ui_gizmo_object_list_.Add(componentsInChildren[k]); } } } } GameObject gameObject2 = GameObject.Find("PoseEditWorkParent"); if (gameObject2 != null) { GizmoRender[] componentsInChildren2 = gameObject2.GetComponentsInChildren(); for (int l = 0; l < componentsInChildren2.Length; l++) { if (componentsInChildren2[l].Visible) { componentsInChildren2[l].Visible = false; this.ui_gizmo_object_list_.Add(componentsInChildren2[l]); } } } } public void OnEnd() { List deserializeWindowList = this.GetDeserializeWindowList(); for (int i = 0; i < deserializeWindowList.Count; i++) { deserializeWindowList[i].OnReset(); } } public int GetActiveMaidCount() { return this.GetWindow(PhotoWindowManager.WindowType.Placement).GetComponentInChildren().GetActiveMaidCount(); } public Maid select_maid { get { return this.select_maid_; } } protected override string save_fullpath_uidata { get { string str = Path.Combine(PhotoWindowManager.path_photo_folder, "SaveData"); return str + "/PhotoModeUISetting.save"; } } protected override string save_header_uidata { get { return "CM3D2_PhotoModeUISetting"; } } public static PhotoWindowManager.WindowType[] deserializeWindowArray = new PhotoWindowManager.WindowType[] { PhotoWindowManager.WindowType.Sound, PhotoWindowManager.WindowType.Placement, PhotoWindowManager.WindowType.Face, PhotoWindowManager.WindowType.Motion, PhotoWindowManager.WindowType.PoseEdit, PhotoWindowManager.WindowType.BG, PhotoWindowManager.WindowType.ObjectCreate, PhotoWindowManager.WindowType.BGObject, PhotoWindowManager.WindowType.Light, PhotoWindowManager.WindowType.ObjectManager, PhotoWindowManager.WindowType.Effect, PhotoWindowManager.WindowType.Message, PhotoWindowManager.WindowType.ScenePreset, PhotoWindowManager.WindowType.AlignmentPreset, PhotoWindowManager.WindowType.MaidItem, PhotoWindowManager.WindowType.Undressing, PhotoWindowManager.WindowType.GravityContro }; public PhotoModeSaveAndLoad SaveAndLoadManager; public UIButton EndButton; public Action CallEditSceneFunction; public List> onMaidChangeEventList = new List>(); private Maid select_maid_; private Dictionary>> maid_store_data_ = new Dictionary>>(); private List ui_hide_object_list_ = new List(); private List ui_gizmo_object_list_ = new List(); public enum WindowType { ObjectManager, BG, Placement, Motion, Face, BGObject, MaidItem, Light, Undressing, Effect, Sound, PoseEdit, Message, ScenePreset, AlignmentPreset, ObjectCreate, GravityContro } }