using System; using System.Collections.Generic; using UnityEngine; using wf; public class BGWindow : BaseMaidPhotoWindow { public override void Awake() { base.Awake(); PhotoBGData.Create(); Dictionary>> dictionary = new Dictionary>>(); foreach (KeyValuePair> keyValuePair in PhotoBGData.category_list) { if (!dictionary.ContainsKey(keyValuePair.Key)) { dictionary.Add(keyValuePair.Key, new List>()); } for (int i = 0; i < keyValuePair.Value.Count; i++) { dictionary[keyValuePair.Key].Add(new KeyValuePair(keyValuePair.Value[i].name, keyValuePair.Value[i])); } } this.PopupAndTabList.SetData(dictionary, false); this.PopupAndTabList.onChangePopUpListValue.Add(new Action>(this.OnChangePopUpList)); this.PopupAndTabList.onSelect.Add(new Action(this.OnSelectItem)); this.PopupAndTabList.popup_value_list = PhotoBGData.popup_category_list; this.CheckSolidColor.onClick.Add(new Action(this.OnClickCheckSolidColorCheckBox)); this.ColorInput.onChangeValue.Add(new Action(this.OnChangeValueColorInput)); } public override void Start() { base.Start(); this.UpdateChildren(); this.PopupAndTabList.SetPopupValue(PhotoBGData.popup_category_list[0].Key); this.PopupAndTabList.SetSelectButton(PhotoBGData.init_data, true); this.CheckSolidColor.check = false; this.ColorInput.visible = false; this.ColorInput.ResetNum = GameMain.Instance.MainCamera.camera.backgroundColor; this.ColorInput.OnReset(); } private void OnSelectItem(object select_data_obj) { if (select_data_obj == null) { return; } PhotoBGData photoBGData = select_data_obj as PhotoBGData; Dictionary> woldStoreData = base.GetWoldStoreData(); if (!woldStoreData.ContainsKey("ベース背景")) { woldStoreData["ベース背景"] = new Dictionary(); } woldStoreData["ベース背景"]["id"] = photoBGData.id; this.SetBg(photoBGData); } private void OnChangeValueColorInput(WindowPartsInputColorrPalette obj, Color color) { this.Apply(); } protected void OnChangePopUpList(KeyValuePair popup_val) { } private void SetBg(PhotoBGData bg_data) { ObjectManagerWindow objectManagerWindow = base.mgr.GetWindow(PhotoWindowManager.WindowType.ObjectManager) as ObjectManagerWindow; objectManagerWindow.RemoveTransTargetObject(GameMain.Instance.BgMgr.current_bg_object); bg_data.Apply(); List list = new List(); Transform transform = GameMain.Instance.BgMgr.current_bg_object.transform; for (int i = 0; i < transform.childCount; i++) { if (!transform.GetChild(i).gameObject.activeSelf) { list.Add(transform.GetChild(i).gameObject); } } foreach (GameObject obj in list) { UnityEngine.Object.DestroyImmediate(obj); } objectManagerWindow.AddTransTargetObject(GameMain.Instance.BgMgr.current_bg_object, bg_data.name, PhotoTransTargetObject.Type.BG); } public override void OnReset() { } public void OnClickCheckSolidColorCheckBox(WFCheckBox check_box) { this.Apply(); } public void Apply() { Dictionary> woldStoreData = base.GetWoldStoreData(); Dictionary dictionary = woldStoreData["ベース背景"]; Transform transform = GameMain.Instance.BgMgr.current_bg_object.transform; transform.gameObject.SetActive(!this.CheckSolidColor.check); if (!transform.gameObject.activeSelf) { this.ColorInput.visible = true; this.PopupAndTabList.gameObject.SetActive(false); } else { this.ColorInput.visible = false; this.PopupAndTabList.gameObject.SetActive(true); } GameMain.Instance.MainCamera.camera.backgroundColor = this.ColorInput.value; } public override void OnSerializeEvent() { base.OnSerializeEvent(); Dictionary> woldStoreData = base.GetWoldStoreData(); Dictionary dictionary = woldStoreData["ベース背景"]; Transform transform = GameMain.Instance.BgMgr.current_bg_object.transform; dictionary["position"] = transform.position.ToString("G9"); dictionary["rotation"] = transform.rotation.ToString("G9"); dictionary["scale"] = transform.localScale.ToString("G9"); dictionary["visible"] = transform.gameObject.activeSelf.ToString(); dictionary["背景色"] = GameMain.Instance.MainCamera.camera.backgroundColor.ToString("G9"); } public override void OnDeserializeEvent() { this.ColorInput.visible = true; this.PopupAndTabList.gameObject.SetActive(true); Dictionary> woldStoreData = base.GetWoldStoreData(); Dictionary dictionary = woldStoreData["ベース背景"]; PhotoBGData photoBGData = PhotoBGData.Get(dictionary["id"]); if (photoBGData == null) { photoBGData = PhotoBGData.init_data; } string categoryNameFromSelectButton = this.PopupAndTabList.GetCategoryNameFromSelectButton(photoBGData); if (!string.IsNullOrEmpty(categoryNameFromSelectButton)) { this.PopupAndTabList.SetPopupValue(categoryNameFromSelectButton); this.PopupAndTabList.SetSelectButton(photoBGData, true); } Transform transform = GameMain.Instance.BgMgr.current_bg_object.transform; transform.position = Parse.Vector3(dictionary["position"]); transform.rotation = Parse.Quaternion(dictionary["rotation"]); transform.localScale = Parse.Vector3(dictionary["scale"]); this.CheckSolidColor.check = !bool.Parse(dictionary["visible"]); if (!dictionary.ContainsKey("背景色")) { dictionary["背景色"] = Color.black.ToString("G9"); } this.ColorInput.value = Parse.Color(dictionary["背景色"]); } public PopupAndTabList PopupAndTabList; public WFCheckBox CheckSolidColor; public WindowPartsInputColorrPalette ColorInput; }