BGWindow.cs 6.3 KB

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