using System; using I2.Loc; using UnityEngine; using wf; namespace SceneNPCEdit { public class NPCCharaSelect : MonoBehaviour { public EditCharacterDatabase.Data selectNPC { get; private set; } private UIProgressBar scrollBar { get { return this.scrollView.verticalScrollBar; } } private void Awake() { NDebug.AssertNull(this.MaidPlateParentGrid != null); this.plateTabPanel = this.MaidPlateParentGrid.gameObject.GetComponent(); this.scrollView = UTY.GetChildObject(base.gameObject, "Contents", false).GetComponent(); this.Create(); } public void Create() { foreach (EditCharacterDatabase.Data data in EditCharacterDatabase.GetAllDatas(true)) { GameObject gameObject = Utility.CreatePrefab(this.MaidPlateParentGrid.gameObject, "CharacterSelect/Prefab/MaidPlateSimple", true); gameObject.name = data.id.ToString(); NPCEditPlate npceditPlate = gameObject.AddComponent(); npceditPlate.onSelectEvent = new Action(this.OnSelectPlate); npceditPlate.lastName = data.npcData.lastName; npceditPlate.firstName = data.npcData.firstName; if (Product.supportMultiLanguage) { npceditPlate.lastName = data.npcData.firstName; npceditPlate.firstName = data.npcData.lastName; string translation = LocalizationManager.GetTranslation(data.firstNameTerm, true, 0, true, false, null, Product.EnumConvert.ToI2LocalizeLanguageName(Product.defaultLanguage)); if (!string.IsNullOrEmpty(translation)) { npceditPlate.lastName = translation; } translation = LocalizationManager.GetTranslation(data.lastNameTerm, true, 0, true, false, null, Product.EnumConvert.ToI2LocalizeLanguageName(Product.defaultLanguage)); if (!string.IsNullOrEmpty(translation)) { npceditPlate.firstName = translation; } } Texture2D thumbnail = (!SaveData.Contains(data.id)) ? data.GetThumbnail() : SaveData.GetPreset(data.id).texThum; npceditPlate.thumbnail = thumbnail; } this.plateTabPanel.UpdateChildren(); Utility.ResetNGUI(this.MaidPlateParentGrid); Utility.ResetNGUI(this.scrollView); if (this.MaidPlateParentGrid.GetChildList().Count != 0) { if (NPCCharaSelect.editTargetNPCData != null) { for (int i = 0; i < this.MaidPlateParentGrid.transform.childCount; i++) { int num = int.Parse(this.MaidPlateParentGrid.GetChild(i).name); if (num == NPCCharaSelect.editTargetNPCData.id) { UIWFTabButton component = UTY.GetChildObject(this.MaidPlateParentGrid.GetChild(i).gameObject, "Button", false).GetComponent(); if (component != null) { this.plateTabPanel.Select(component); } break; } } } else { UIWFTabButton component2 = UTY.GetChildObject(this.MaidPlateParentGrid.GetChild(0).gameObject, "Button", false).GetComponent(); if (component2 != null) { this.plateTabPanel.Select(component2); } } } NPCCharaSelect.editTargetNPCData = null; } public void UpdateSelectData() { for (int i = 0; i < this.MaidPlateParentGrid.transform.childCount; i++) { int num = int.Parse(this.MaidPlateParentGrid.GetChild(i).name); if (num == this.selectNPC.id) { NPCEditPlate component = this.MaidPlateParentGrid.GetChild(i).GetComponent(); Texture2D thumbnail = (!SaveData.Contains(num)) ? this.selectNPC.GetThumbnail() : SaveData.GetPreset(num).texThum; component.thumbnail = thumbnail; this.statusPanel.Apply(component, this.selectNPC.additionalInformationText, this.selectNPC.informationTerm); } } } public void OnSelectPlate(NPCEditPlate selectPlate) { this.selectNPC = EditCharacterDatabase.GetData(int.Parse(selectPlate.name)); this.statusPanel.Apply(selectPlate, this.selectNPC.additionalInformationText, this.selectNPC.informationTerm); } public static EditCharacterDatabase.Data editTargetNPCData; [SerializeField] private UIGrid MaidPlateParentGrid; [SerializeField] private NPCEditStatus statusPanel; private UIWFTabPanel plateTabPanel; private UIScrollView scrollView; } }