NPCCharaSelect.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. using System;
  2. using I2.Loc;
  3. using UnityEngine;
  4. using wf;
  5. namespace SceneNPCEdit
  6. {
  7. public class NPCCharaSelect : MonoBehaviour
  8. {
  9. public EditCharacterDatabase.Data selectNPC { get; private set; }
  10. private UIProgressBar scrollBar
  11. {
  12. get
  13. {
  14. return this.scrollView.verticalScrollBar;
  15. }
  16. }
  17. private void Awake()
  18. {
  19. NDebug.AssertNull(this.MaidPlateParentGrid != null);
  20. this.plateTabPanel = this.MaidPlateParentGrid.gameObject.GetComponent<UIWFTabPanel>();
  21. this.scrollView = UTY.GetChildObject(base.gameObject, "Contents", false).GetComponent<UIScrollView>();
  22. this.Create();
  23. }
  24. public void Create()
  25. {
  26. foreach (EditCharacterDatabase.Data data in EditCharacterDatabase.GetAllDatas(true))
  27. {
  28. GameObject gameObject = Utility.CreatePrefab(this.MaidPlateParentGrid.gameObject, "CharacterSelect/Prefab/MaidPlateSimple", true);
  29. gameObject.name = data.id.ToString();
  30. NPCEditPlate npceditPlate = gameObject.AddComponent<NPCEditPlate>();
  31. npceditPlate.onSelectEvent = new Action<NPCEditPlate>(this.OnSelectPlate);
  32. npceditPlate.lastName = data.npcData.lastName;
  33. npceditPlate.firstName = data.npcData.firstName;
  34. if (Product.supportMultiLanguage)
  35. {
  36. npceditPlate.lastName = data.npcData.firstName;
  37. npceditPlate.firstName = data.npcData.lastName;
  38. string translation = LocalizationManager.GetTranslation(data.firstNameTerm, true, 0, true, false, null, Product.EnumConvert.ToI2LocalizeLanguageName(Product.defaultLanguage));
  39. if (!string.IsNullOrEmpty(translation))
  40. {
  41. npceditPlate.lastName = translation;
  42. }
  43. translation = LocalizationManager.GetTranslation(data.lastNameTerm, true, 0, true, false, null, Product.EnumConvert.ToI2LocalizeLanguageName(Product.defaultLanguage));
  44. if (!string.IsNullOrEmpty(translation))
  45. {
  46. npceditPlate.firstName = translation;
  47. }
  48. }
  49. Texture2D thumbnail = (!SaveData.Contains(data.id)) ? data.GetThumbnail() : SaveData.GetPreset(data.id).texThum;
  50. npceditPlate.thumbnail = thumbnail;
  51. }
  52. this.plateTabPanel.UpdateChildren();
  53. Utility.ResetNGUI(this.MaidPlateParentGrid);
  54. Utility.ResetNGUI(this.scrollView);
  55. if (this.MaidPlateParentGrid.GetChildList().Count != 0)
  56. {
  57. if (NPCCharaSelect.editTargetNPCData != null)
  58. {
  59. for (int i = 0; i < this.MaidPlateParentGrid.transform.childCount; i++)
  60. {
  61. int num = int.Parse(this.MaidPlateParentGrid.GetChild(i).name);
  62. if (num == NPCCharaSelect.editTargetNPCData.id)
  63. {
  64. UIWFTabButton component = UTY.GetChildObject(this.MaidPlateParentGrid.GetChild(i).gameObject, "Button", false).GetComponent<UIWFTabButton>();
  65. if (component != null)
  66. {
  67. this.plateTabPanel.Select(component);
  68. }
  69. break;
  70. }
  71. }
  72. }
  73. else
  74. {
  75. UIWFTabButton component2 = UTY.GetChildObject(this.MaidPlateParentGrid.GetChild(0).gameObject, "Button", false).GetComponent<UIWFTabButton>();
  76. if (component2 != null)
  77. {
  78. this.plateTabPanel.Select(component2);
  79. }
  80. }
  81. }
  82. NPCCharaSelect.editTargetNPCData = null;
  83. }
  84. public void UpdateSelectData()
  85. {
  86. for (int i = 0; i < this.MaidPlateParentGrid.transform.childCount; i++)
  87. {
  88. int num = int.Parse(this.MaidPlateParentGrid.GetChild(i).name);
  89. if (num == this.selectNPC.id)
  90. {
  91. NPCEditPlate component = this.MaidPlateParentGrid.GetChild(i).GetComponent<NPCEditPlate>();
  92. Texture2D thumbnail = (!SaveData.Contains(num)) ? this.selectNPC.GetThumbnail() : SaveData.GetPreset(num).texThum;
  93. component.thumbnail = thumbnail;
  94. this.statusPanel.Apply(component, this.selectNPC.additionalInformationText, this.selectNPC.informationTerm);
  95. }
  96. }
  97. }
  98. public void OnSelectPlate(NPCEditPlate selectPlate)
  99. {
  100. this.selectNPC = EditCharacterDatabase.GetData(int.Parse(selectPlate.name));
  101. this.statusPanel.Apply(selectPlate, this.selectNPC.additionalInformationText, this.selectNPC.informationTerm);
  102. }
  103. public static EditCharacterDatabase.Data editTargetNPCData;
  104. [SerializeField]
  105. private UIGrid MaidPlateParentGrid;
  106. [SerializeField]
  107. private NPCEditStatus statusPanel;
  108. private UIWFTabPanel plateTabPanel;
  109. private UIScrollView scrollView;
  110. }
  111. }