123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- 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<UIWFTabPanel>();
- this.scroll_view_ = NGUITools.FindInParents<UIScrollView>(this.ContentGrid.transform);
- this.PopupList.onChangePopUpListValue.Add(new Action<KeyValuePair<string, UnityEngine.Object>>(this.OnChangePopUpList));
- UTY.GetChildObject(this.content_game_object, "ListParent/DragMat", false).GetComponent<BoxCollider>().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<UILabel>().text = PhotoMaidItemData.data[i].name;
- EventDelegate.Add(gameObject.GetComponent<UIWFTabButton>().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<string, string> 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<string, string> dictionary = new Dictionary<string, string>();
- foreach (KeyValuePair<string, string> 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<string, string> keyValuePair2 in dictionary)
- {
- maidStoreData[keyValuePair2.Key] = keyValuePair2.Value;
- }
- }
- foreach (KeyValuePair<string, string> 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<BoxCollider>().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<BoxCollider>().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<string, UnityEngine.Object> popup_val)
- {
- List<Transform> childList = this.ContentGrid.GetChildList();
- for (int i = 0; i < childList.Count; i++)
- {
- childList[i].GetComponent<UIWFTabButton>().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<string, string> maidStoreData = base.GetMaidStoreData(base.mgr.select_maid);
- long num = long.Parse(maidStoreData[popup_val.Key]);
- UIWFTabButton uiwftabButton = null;
- List<PhotoMaidItemData> 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<UIWFTabButton>();
- }
- }
- 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<string, string> 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_;
- }
|