SceneEditNameSettingPanel.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. using System;
  2. using UnityEngine;
  3. [RequireComponent(typeof(WfFadeBasic))]
  4. public class SceneEditNameSettingPanel : MonoBehaviour
  5. {
  6. public Maid maid
  7. {
  8. get
  9. {
  10. return GameMain.Instance.CharacterMgr.GetMaid(0);
  11. }
  12. }
  13. public void Awake()
  14. {
  15. if (Product.SIBD)
  16. {
  17. Vector3 localPosition = this.lastNameInput.transform.parent.localPosition;
  18. Vector3 localPosition2 = this.firstNameInput.transform.parent.localPosition;
  19. this.lastNameInput.transform.parent.localPosition = localPosition2;
  20. this.firstNameInput.transform.parent.localPosition = localPosition;
  21. }
  22. this.fadeBasic = base.GetComponent<WfFadeBasic>();
  23. EventDelegate.Add(this.lastNameInput.onChange, new EventDelegate.Callback(this.OnInputName));
  24. EventDelegate.Add(this.firstNameInput.onChange, new EventDelegate.Callback(this.OnInputName));
  25. EventDelegate.Add(this.enterButton.onClick, new EventDelegate.Callback(this.Close));
  26. EventDelegate.Add(this.cancelButton.onClick, new EventDelegate.Callback(this.Chancel));
  27. EventDelegate.Add(this.lastNameRandomButton.onClick, delegate()
  28. {
  29. this.lastNameInput.RemoveFocus();
  30. this.lastNameInput.value = MaidRandomName.GetLastName();
  31. });
  32. EventDelegate.Add(this.firstNameRandomButton.onClick, delegate()
  33. {
  34. this.firstNameInput.RemoveFocus();
  35. this.firstNameInput.value = MaidRandomName.GetFirstName();
  36. });
  37. this.fadeBasic.onCompleteFadeInAction = delegate(WfFadeBasic execFade)
  38. {
  39. this.lastNameInput.isSelected = true;
  40. };
  41. }
  42. public void Call()
  43. {
  44. this.backupLastName = this.maid.status.lastName;
  45. this.backupFirstName = this.maid.status.firstName;
  46. this.lastNameInput.value = this.backupLastName;
  47. this.firstNameInput.value = this.backupFirstName;
  48. this.fadeBasic.alpha = 0f;
  49. WfFadeJob.Create(this.fadeBasic, null, 0.3f, iTween.EaseType.linear);
  50. }
  51. public void Chancel()
  52. {
  53. if (this.fadeBasic.alpha != 1f)
  54. {
  55. return;
  56. }
  57. this.maid.status.lastName = this.backupLastName;
  58. this.maid.status.firstName = this.backupFirstName;
  59. this.Close();
  60. }
  61. public void Close()
  62. {
  63. this.lastNameInput.RemoveFocus();
  64. this.firstNameInput.RemoveFocus();
  65. this.fadeBasic.alpha = 1f;
  66. WfFadeJob.Create(null, this.fadeBasic, 0.3f, iTween.EaseType.linear);
  67. }
  68. private void OnInputName()
  69. {
  70. if (UIInput.current == this.lastNameInput)
  71. {
  72. this.maid.status.lastName = UIInput.current.value;
  73. }
  74. else
  75. {
  76. this.maid.status.firstName = UIInput.current.value;
  77. }
  78. UIInput.current.value = ((!(UIInput.current == this.lastNameInput)) ? this.maid.status.firstName : this.maid.status.lastName);
  79. }
  80. [SerializeField]
  81. private UIInput lastNameInput;
  82. [SerializeField]
  83. private UIButton lastNameRandomButton;
  84. [SerializeField]
  85. private UIInput firstNameInput;
  86. [SerializeField]
  87. private UIButton firstNameRandomButton;
  88. [SerializeField]
  89. private UIButton enterButton;
  90. [SerializeField]
  91. private UIButton cancelButton;
  92. private WfFadeBasic fadeBasic;
  93. private string backupLastName;
  94. private string backupFirstName;
  95. }