BGWindow.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using wf;
  5. public class BGWindow : BaseMaidPhotoWindow
  6. {
  7. public override void Awake()
  8. {
  9. base.Awake();
  10. PhotoBGData.Create();
  11. Dictionary<string, List<KeyValuePair<string, object>>> dictionary = new Dictionary<string, List<KeyValuePair<string, object>>>();
  12. foreach (KeyValuePair<string, List<PhotoBGData>> keyValuePair in PhotoBGData.category_list)
  13. {
  14. if (!dictionary.ContainsKey(keyValuePair.Key))
  15. {
  16. dictionary.Add(keyValuePair.Key, new List<KeyValuePair<string, object>>());
  17. }
  18. for (int i = 0; i < keyValuePair.Value.Count; i++)
  19. {
  20. dictionary[keyValuePair.Key].Add(new KeyValuePair<string, object>(keyValuePair.Value[i].name, keyValuePair.Value[i]));
  21. }
  22. }
  23. this.PopupAndTabList.SetData(dictionary, false);
  24. this.PopupAndTabList.onChangePopUpListValue.Add(new Action<KeyValuePair<string, UnityEngine.Object>>(this.OnChangePopUpList));
  25. this.PopupAndTabList.onSelect.Add(new Action<object>(this.OnSelectItem));
  26. this.PopupAndTabList.popup_value_list = PhotoBGData.popup_category_list;
  27. this.CheckSolidColor.onClick.Add(new Action<WFCheckBox>(this.OnClickCheckSolidColorCheckBox));
  28. this.ColorInput.onChangeValue.Add(new Action<WindowPartsInputColorrPalette, Color>(this.OnChangeValueColorInput));
  29. }
  30. public override void Start()
  31. {
  32. base.Start();
  33. this.UpdateChildren();
  34. this.PopupAndTabList.SetPopupValue(PhotoBGData.popup_category_list[0].Key);
  35. this.PopupAndTabList.SetSelectButton(PhotoBGData.init_data, true);
  36. this.CheckSolidColor.check = false;
  37. this.ColorInput.visible = false;
  38. this.ColorInput.ResetNum = GameMain.Instance.MainCamera.camera.backgroundColor;
  39. this.ColorInput.OnReset();
  40. }
  41. private void OnSelectItem(object select_data_obj)
  42. {
  43. if (select_data_obj == null)
  44. {
  45. return;
  46. }
  47. PhotoBGData photoBGData = select_data_obj as PhotoBGData;
  48. Dictionary<string, Dictionary<string, string>> woldStoreData = base.GetWoldStoreData();
  49. if (!woldStoreData.ContainsKey("ベース背景"))
  50. {
  51. woldStoreData["ベース背景"] = new Dictionary<string, string>();
  52. }
  53. woldStoreData["ベース背景"]["id"] = photoBGData.id;
  54. this.SetBg(photoBGData);
  55. }
  56. private void OnChangeValueColorInput(WindowPartsInputColorrPalette obj, Color color)
  57. {
  58. this.Apply();
  59. }
  60. protected void OnChangePopUpList(KeyValuePair<string, UnityEngine.Object> popup_val)
  61. {
  62. }
  63. private void SetBg(PhotoBGData bg_data)
  64. {
  65. ObjectManagerWindow objectManagerWindow = base.mgr.GetWindow(PhotoWindowManager.WindowType.ObjectManager) as ObjectManagerWindow;
  66. objectManagerWindow.RemoveTransTargetObject(GameMain.Instance.BgMgr.current_bg_object);
  67. bg_data.Apply();
  68. List<GameObject> list = new List<GameObject>();
  69. Transform transform = GameMain.Instance.BgMgr.current_bg_object.transform;
  70. for (int i = 0; i < transform.childCount; i++)
  71. {
  72. if (!transform.GetChild(i).gameObject.activeSelf)
  73. {
  74. list.Add(transform.GetChild(i).gameObject);
  75. }
  76. }
  77. foreach (GameObject obj in list)
  78. {
  79. UnityEngine.Object.DestroyImmediate(obj);
  80. }
  81. objectManagerWindow.AddTransTargetObject(GameMain.Instance.BgMgr.current_bg_object, bg_data.name, PhotoTransTargetObject.Type.BG);
  82. }
  83. public override void OnReset()
  84. {
  85. }
  86. public void OnClickCheckSolidColorCheckBox(WFCheckBox check_box)
  87. {
  88. this.Apply();
  89. }
  90. public void Apply()
  91. {
  92. Dictionary<string, Dictionary<string, string>> woldStoreData = base.GetWoldStoreData();
  93. Dictionary<string, string> dictionary = woldStoreData["ベース背景"];
  94. Transform transform = GameMain.Instance.BgMgr.current_bg_object.transform;
  95. transform.gameObject.SetActive(!this.CheckSolidColor.check);
  96. if (!transform.gameObject.activeSelf)
  97. {
  98. this.ColorInput.visible = true;
  99. this.PopupAndTabList.gameObject.SetActive(false);
  100. }
  101. else
  102. {
  103. this.ColorInput.visible = false;
  104. this.PopupAndTabList.gameObject.SetActive(true);
  105. }
  106. GameMain.Instance.MainCamera.camera.backgroundColor = this.ColorInput.value;
  107. }
  108. public override void OnSerializeEvent()
  109. {
  110. base.OnSerializeEvent();
  111. Dictionary<string, Dictionary<string, string>> woldStoreData = base.GetWoldStoreData();
  112. Dictionary<string, string> dictionary = woldStoreData["ベース背景"];
  113. Transform transform = GameMain.Instance.BgMgr.current_bg_object.transform;
  114. dictionary["position"] = transform.position.ToString("G9");
  115. dictionary["rotation"] = transform.rotation.ToString("G9");
  116. dictionary["scale"] = transform.localScale.ToString("G9");
  117. dictionary["visible"] = transform.gameObject.activeSelf.ToString();
  118. dictionary["背景色"] = GameMain.Instance.MainCamera.camera.backgroundColor.ToString("G9");
  119. }
  120. public override void OnDeserializeEvent()
  121. {
  122. this.ColorInput.visible = true;
  123. this.PopupAndTabList.gameObject.SetActive(true);
  124. Dictionary<string, Dictionary<string, string>> woldStoreData = base.GetWoldStoreData();
  125. Dictionary<string, string> dictionary = woldStoreData["ベース背景"];
  126. PhotoBGData photoBGData = PhotoBGData.Get(dictionary["id"]);
  127. if (photoBGData == null)
  128. {
  129. photoBGData = PhotoBGData.init_data;
  130. }
  131. string categoryNameFromSelectButton = this.PopupAndTabList.GetCategoryNameFromSelectButton(photoBGData);
  132. if (!string.IsNullOrEmpty(categoryNameFromSelectButton))
  133. {
  134. this.PopupAndTabList.SetPopupValue(categoryNameFromSelectButton);
  135. this.PopupAndTabList.SetSelectButton(photoBGData, true);
  136. }
  137. Transform transform = GameMain.Instance.BgMgr.current_bg_object.transform;
  138. transform.position = Parse.Vector3(dictionary["position"]);
  139. transform.rotation = Parse.Quaternion(dictionary["rotation"]);
  140. transform.localScale = Parse.Vector3(dictionary["scale"]);
  141. this.CheckSolidColor.check = !bool.Parse(dictionary["visible"]);
  142. if (!dictionary.ContainsKey("背景色"))
  143. {
  144. dictionary["背景色"] = Color.black.ToString("G9");
  145. }
  146. this.ColorInput.value = Parse.Color(dictionary["背景色"]);
  147. }
  148. public PopupAndTabList PopupAndTabList;
  149. public WFCheckBox CheckSolidColor;
  150. public WindowPartsInputColorrPalette ColorInput;
  151. }