using System; using System.Collections.Generic; using UnityEngine; using wf; public class MaidItemWindow : BaseMaidPhotoWindow { public override void Awake() { base.Awake(); PhotoMaidItemData.Create(); this.tab_panel_ = this.ContentGrid.GetComponentInChildren(); this.scroll_view_ = NGUITools.FindInParents(this.ContentGrid.transform); this.PopupList.onChangePopUpListValue.Add(new Action>(this.OnChangePopUpList)); UTY.GetChildObject(this.content_game_object, "ListParent/DragMat", false).GetComponent().enabled = false; this.tmp_parent_ = new GameObject(); this.tmp_parent_.name = "一時置き場"; this.tmp_parent_.transform.SetParent(this.ContentGrid.transform.parent, false); for (int i = 0; i < PhotoMaidItemData.data.Count; i++) { GameObject gameObject = Utility.CreatePrefab(this.tmp_parent_, "ScenePhotoMode/WindowListItem", true); gameObject.name = PhotoMaidItemData.data[i].id.ToString(); gameObject.GetComponentInChildren().text = PhotoMaidItemData.data[i].name; EventDelegate.Add(gameObject.GetComponent().onSelect, new EventDelegate.Callback(this.OnSelectItem)); } this.tmp_parent_.SetActive(false); } public override void Start() { base.Start(); this.UpdateChildren(); } public override void OnMaidAddEvent(Maid maid, bool is_deserialize_load) { base.OnMaidAddEvent(maid, is_deserialize_load); if (maid == null || maid.boMAN) { return; } Dictionary maidStoreData = base.GetMaidStoreData(maid); if (!is_deserialize_load || maidStoreData.Count <= 0) { for (int i = 0; i < PhotoMaidItemData.data.Count; i++) { PhotoMaidItemData photoMaidItemData = PhotoMaidItemData.data[i]; if (photoMaidItemData.init_item) { maidStoreData[photoMaidItemData.category] = photoMaidItemData.id.ToString(); } } } else { Dictionary dictionary = new Dictionary(); foreach (KeyValuePair keyValuePair in maidStoreData) { if (PhotoMaidItemData.Get(long.Parse(keyValuePair.Value)) == null) { for (int j = 0; j < PhotoMaidItemData.data.Count; j++) { if (keyValuePair.Key == PhotoMaidItemData.data[j].category && PhotoMaidItemData.data[j].init_item) { dictionary[keyValuePair.Key] = PhotoMaidItemData.data[j].id.ToString(); break; } } } } foreach (KeyValuePair keyValuePair2 in dictionary) { maidStoreData[keyValuePair2.Key] = keyValuePair2.Value; } } foreach (KeyValuePair keyValuePair3 in maidStoreData) { PhotoMaidItemData photoMaidItemData2 = PhotoMaidItemData.Get(long.Parse(keyValuePair3.Value)); if (photoMaidItemData2 != null) { photoMaidItemData2.Apply(maid); } } } public override void OnMaidRemoveEventPrev(Maid maid) { base.OnMaidRemoveEventPrev(maid); if (maid == null || maid.boMAN) { return; } PhotoMaidItemData.Clear(maid); } public override void OnMaidChangeEvent(Maid maid) { base.OnMaidChangeEvent(maid); if (maid == null || maid.boMAN) { UTY.GetChildObject(this.content_game_object, "ListParent/DragMat", false).GetComponent().enabled = false; this.PopupList.popup_value_list = null; this.PopupList.SetPopupValue(this.PopupList.popup_value_list[0].Key); } else { UTY.GetChildObject(this.content_game_object, "ListParent/DragMat", false).GetComponent().enabled = true; if (this.PopupList.popup_value_list.Count == 1) { this.PopupList.popup_value_list = PhotoMaidItemData.popup_category_list; this.PopupList.SetPopupValue(this.PopupList.popup_value_list[0].Key); } else { this.PopupList.SetPopupValue(this.PopupList.popup_select_value.Key); } } } protected void OnChangePopUpList(KeyValuePair popup_val) { List childList = this.ContentGrid.GetChildList(); for (int i = 0; i < childList.Count; i++) { childList[i].GetComponent().SetSelect(false); childList[i].SetParent(this.tmp_parent_.transform, false); } this.ContentGrid.transform.DetachChildren(); this.tab_panel_.ResetSelect(); this.tab_panel_.UpdateChildren(); if (!PhotoMaidItemData.category_list.ContainsKey(popup_val.Key)) { this.ContentGrid.Reposition(); this.scroll_view_.ResetPosition(); return; } Dictionary maidStoreData = base.GetMaidStoreData(base.mgr.select_maid); long num = long.Parse(maidStoreData[popup_val.Key]); UIWFTabButton uiwftabButton = null; List list = PhotoMaidItemData.category_list[popup_val.Key]; for (int j = 0; j < list.Count; j++) { GameObject childObject = UTY.GetChildObject(this.tmp_parent_, list[j].id.ToString(), false); childObject.transform.SetParent(this.ContentGrid.transform, false); if (num == long.Parse(childObject.name)) { uiwftabButton = childObject.GetComponent(); } } this.tab_panel_.UpdateChildren(); this.ContentGrid.Reposition(); this.scroll_view_.ResetPosition(); if (uiwftabButton != null) { this.tab_panel_.Select(uiwftabButton); } } private void OnSelectItem() { if (UIWFSelectButton.current == null || base.mgr.select_maid == null || !UIWFSelectButton.current.isSelected) { return; } PhotoMaidItemData photoMaidItemData = PhotoMaidItemData.Get(long.Parse(UIWFTabButton.current.name)); Dictionary maidStoreData = base.GetMaidStoreData(base.mgr.select_maid); maidStoreData[this.PopupList.popup_select_value.Key] = photoMaidItemData.id.ToString(); photoMaidItemData.Apply(base.mgr.select_maid); } public override void OnDeserializeEvent() { } public WindowPartsPopUpList PopupList; public UIGrid ContentGrid; private UIScrollView scroll_view_; private GameObject tmp_parent_; private UIWFTabPanel tab_panel_; }