123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- using wf;
- public class AlignmentPresetWindow : BaseMaidPhotoWindow
- {
- public override void Awake()
- {
- base.Awake();
- PhotoAlignmentPreset.Create();
- this.noCharaActive = base.GetComponentInChildren<PhotoNoCharaActive>();
- }
- public override void Start()
- {
- base.Start();
- this.Init();
- }
- public void Init()
- {
- for (int i = 0; i < PhotoAlignmentPreset.datas.Count; i++)
- {
- this.CreateAlignmentPresetButton(this.contentGrid.gameObject, PhotoAlignmentPreset.datas[i]);
- }
- Utility.ResetNGUI(this.contentGrid);
- Utility.ResetNGUI(NGUITools.FindInParents<UIScrollView>(this.contentGrid.transform));
- Utility.ResetNGUI(this.maidListGrid);
- Utility.ResetNGUI(NGUITools.FindInParents<UIScrollView>(this.maidListGrid.transform));
- this.UpdateMaidList();
- this.noCharaActive.ChangeMode(true, true);
- UIButton[] componentsInChildren = this.contentGrid.GetComponentsInChildren<UIButton>();
- foreach (UIButton uibutton in componentsInChildren)
- {
- uibutton.isEnabled = false;
- }
- }
- public override void OnMaidAddEvent(Maid maid, bool is_deserialize_load)
- {
- if (maid == null || maid.boMAN)
- {
- return;
- }
- this.activeMaidList.Add(maid);
- this.UpdateMaidList();
- this.noCharaActive.ChangeMode(false, true);
- }
- public void OnSelectMaid()
- {
- GameObject gameObject = UIButton.current.transform.parent.gameObject;
- MaidPlate component = gameObject.GetComponent<MaidPlate>();
- bool selected = UIWFSelectButton.selected;
- if (selected)
- {
- for (int i = 0; i < this.selectMaidList.Length; i++)
- {
- if (this.selectMaidList[i] == null)
- {
- this.selectMaidList[i] = component;
- this.selectMaidList[i].SetSelectNoVisible(i + 1, true);
- break;
- }
- }
- }
- else
- {
- for (int j = 0; j < this.selectMaidList.Length; j++)
- {
- if (this.selectMaidList[j] == component)
- {
- this.selectMaidList[j].SetSelectNoVisible(j + 1, false);
- this.selectMaidList[j] = null;
- break;
- }
- }
- }
- bool flag = false;
- int num = 0;
- while (num < this.selectMaidList.Length && !flag)
- {
- if (this.selectMaidList[num] != null)
- {
- flag = true;
- }
- num++;
- }
- UIButton[] componentsInChildren = this.contentGrid.GetComponentsInChildren<UIButton>();
- foreach (UIButton uibutton in componentsInChildren)
- {
- uibutton.isEnabled = flag;
- }
- }
- public override void OnMaidRemoveEvent(Maid maid)
- {
- if (maid == null || maid.boMAN)
- {
- return;
- }
- this.activeMaidList.Remove(maid);
- this.UpdateMaidList();
- if (this.activeMaidList.Count <= 0)
- {
- this.noCharaActive.ChangeMode(true, true);
- }
- }
- public override void OnDeserializeEvent()
- {
- AlignmentPresetWindow.SelectData = null;
- }
- public void UpdateMaidList()
- {
- Dictionary<Maid, int> dictionary = new Dictionary<Maid, int>();
- for (int i = 0; i < this.selectMaidList.Length; i++)
- {
- if (this.selectMaidList[i] != null)
- {
- this.selectMaidList[i].SetSelectNoVisibleAllOff();
- bool flag = this.activeMaidList.Contains(this.selectMaidList[i].maid);
- if (flag)
- {
- dictionary.Add(this.selectMaidList[i].maid, i);
- }
- }
- this.selectMaidList[i] = null;
- }
- MaidPlate[] array = new MaidPlate[this.selectMaidList.Length];
- List<Transform> childList = this.maidListGrid.GetChildList();
- for (int j = 0; j < childList.Count; j++)
- {
- UnityEngine.Object.DestroyImmediate(childList[j].gameObject);
- }
- this.maidListGrid.transform.DetachChildren();
- List<Maid> sortedActiveMaidList = this.GetSortedActiveMaidList();
- for (int k = 0; k < sortedActiveMaidList.Count; k++)
- {
- GameObject gameObject = Utility.CreatePrefab(this.maidListGrid.gameObject, "ScenePhotoMode/SimpleMaidPlate", true);
- gameObject.GetComponent<MaidPlate>().SetMaidData(sortedActiveMaidList[k]);
- UIWFSelectButton component = UTY.GetChildObject(gameObject, "Button", false).GetComponent<UIWFSelectButton>();
- UIWFTabButton component2 = UTY.GetChildObject(gameObject, "Button", false).GetComponent<UIWFTabButton>();
- UnityEngine.Object.Destroy(component2);
- component.enabled = true;
- EventDelegate.Add(component.onSelect, new EventDelegate.Callback(this.OnSelectMaid));
- if (dictionary.ContainsKey(sortedActiveMaidList[k]))
- {
- array[dictionary[sortedActiveMaidList[k]]] = gameObject.GetComponent<MaidPlate>();
- }
- }
- this.switchPanel.SetNumberOfSelected(5);
- this.switchPanel.UpdateChildren();
- Utility.ResetNGUI(this.maidListGrid);
- Utility.ResetNGUI(NGUITools.FindInParents<UIScrollView>(this.maidListGrid.transform));
- this.UpdateChildren();
- for (int l = 0; l < array.Length; l++)
- {
- if (!(array[l] == null))
- {
- UIWFSelectButton component3 = UTY.GetChildObject(array[l].gameObject, "Button", false).GetComponent<UIWFSelectButton>();
- this.switchPanel.Select(component3);
- }
- }
- bool isEnabled = false;
- this.selectMaidList = array;
- for (int m = 0; m < this.selectMaidList.Length; m++)
- {
- if (this.selectMaidList[m] != null)
- {
- this.selectMaidList[m].SetSelectNoVisibleAllOff();
- this.selectMaidList[m].SetSelectNoVisible(m + 1, true);
- isEnabled = true;
- }
- }
- UIButton[] componentsInChildren = this.contentGrid.GetComponentsInChildren<UIButton>();
- foreach (UIButton uibutton in componentsInChildren)
- {
- uibutton.isEnabled = isEnabled;
- }
- }
- public GameObject CreateAlignmentPresetButton(GameObject parentObject, PhotoAlignmentPreset.Data data)
- {
- GameObject gameObject = Utility.CreatePrefab(parentObject, "ScenePhotoMode/AlignmentPresetButton", true);
- gameObject.name = data.id.ToString();
- UI2DSprite component = UTY.GetChildObject(gameObject, "Plate/Plate/BG/ThumImage", false).GetComponent<UI2DSprite>();
- if (!string.IsNullOrEmpty(data.thumbnailName))
- {
- Texture2D texture2D = ImportCM.CreateTexture(data.thumbnailName + ".tex");
- Sprite sprite2D = Sprite.Create(texture2D, new Rect(0f, 0f, (float)texture2D.width, (float)texture2D.height), default(Vector2));
- if (component.sprite2D != null && component.sprite2D.texture != null)
- {
- UnityEngine.Object.DestroyImmediate(component.sprite2D.texture);
- }
- component.sprite2D = sprite2D;
- component.SetDimensions(texture2D.width, texture2D.height);
- }
- UIButton componentInChildren = gameObject.GetComponentInChildren<UIButton>();
- componentInChildren.name = data.id.ToString();
- EventDelegate.Add(componentInChildren.onClick, new EventDelegate.Callback(this.OnClickLoadBtn));
- return gameObject;
- }
- private void OnClickLoadBtn()
- {
- GameObject gameObject = UIButton.current.transform.parent.parent.gameObject;
- int id = int.Parse(gameObject.name);
- PhotoAlignmentPreset.Data data = PhotoAlignmentPreset.GetData(id);
- GameMain.Instance.SysDlg.Show("選択した配置に変更します。\n宜しいですか?", SystemDialog.TYPE.OK_CANCEL, delegate
- {
- GameMain.Instance.SysDlg.Close();
- this.ExecAlignmentPreset(data);
- }, null);
- }
- private void ExecAlignmentPreset(PhotoAlignmentPreset.Data data)
- {
- for (int i = 0; i < this.selectMaidList.Length; i++)
- {
- if (this.selectMaidList[i] != null)
- {
- this.selectMaidList[i].maid.transform.localPosition = data.positions[i];
- }
- }
- }
- private List<Maid> GetSortedActiveMaidList()
- {
- if (this.activeMaidList.Count <= 0)
- {
- return new List<Maid>();
- }
- if (this.placementWindow == null)
- {
- this.placementWindow = (base.mgr.GetWindow(PhotoWindowManager.WindowType.Placement) as PlacementWindow);
- }
- List<Maid> list = new List<Maid>();
- List<Maid> maid_list = this.placementWindow.maid_list;
- for (int i = 0; i < maid_list.Count; i++)
- {
- if (this.activeMaidList.Contains(maid_list[i]))
- {
- list.Add(maid_list[i]);
- }
- }
- return list;
- }
- [HideInInspector]
- public static PhotoAlignmentPreset.Data SelectData;
- [SerializeField]
- private UIGrid maidListGrid;
- [SerializeField]
- private UIWFSwitchPanel switchPanel;
- [SerializeField]
- private UIGrid contentGrid;
- private MaidPlate[] selectMaidList = new MaidPlate[5];
- private PhotoNoCharaActive noCharaActive;
- private HashSet<Maid> activeMaidList = new HashSet<Maid>();
- private PlacementWindow placementWindow;
- }
|