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(); } 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(this.contentGrid.transform)); Utility.ResetNGUI(this.maidListGrid); Utility.ResetNGUI(NGUITools.FindInParents(this.maidListGrid.transform)); this.UpdateMaidList(); this.noCharaActive.ChangeMode(true, true); UIButton[] componentsInChildren = this.contentGrid.GetComponentsInChildren(); 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(); 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(); 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 dictionary = new Dictionary(); 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 childList = this.maidListGrid.GetChildList(); for (int j = 0; j < childList.Count; j++) { UnityEngine.Object.DestroyImmediate(childList[j].gameObject); } this.maidListGrid.transform.DetachChildren(); List sortedActiveMaidList = this.GetSortedActiveMaidList(); for (int k = 0; k < sortedActiveMaidList.Count; k++) { GameObject gameObject = Utility.CreatePrefab(this.maidListGrid.gameObject, "ScenePhotoMode/SimpleMaidPlate", true); gameObject.GetComponent().SetMaidData(sortedActiveMaidList[k]); UIWFSelectButton component = UTY.GetChildObject(gameObject, "Button", false).GetComponent(); UIWFTabButton component2 = UTY.GetChildObject(gameObject, "Button", false).GetComponent(); 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(); } } this.switchPanel.SetNumberOfSelected(5); this.switchPanel.UpdateChildren(); Utility.ResetNGUI(this.maidListGrid); Utility.ResetNGUI(NGUITools.FindInParents(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(); 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(); 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(); 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(); 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.ShowFromLanguageTerm("ScenePhotoMode/配置/ダイアログ/選択した配置に変更します。宜しいですか?", null, 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 GetSortedActiveMaidList() { if (this.activeMaidList.Count <= 0) { return new List(); } if (this.placementWindow == null) { this.placementWindow = (base.mgr.GetWindow(PhotoWindowManager.WindowType.Placement) as PlacementWindow); } List list = new List(); List 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 activeMaidList = new HashSet(); private PlacementWindow placementWindow; }