123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- 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<UIWFTabPanel>();
- this.scrollView = UTY.GetChildObject(base.gameObject, "Contents", false).GetComponent<UIScrollView>();
- 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>();
- npceditPlate.onSelectEvent = new Action<NPCEditPlate>(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<UIWFTabButton>();
- if (component != null)
- {
- this.plateTabPanel.Select(component);
- }
- break;
- }
- }
- }
- else
- {
- UIWFTabButton component2 = UTY.GetChildObject(this.MaidPlateParentGrid.GetChild(0).gameObject, "Button", false).GetComponent<UIWFTabButton>();
- 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<NPCEditPlate>();
- 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;
- }
- }
|