SceneEditNameSettingPanel.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. this.fadeBasic = base.GetComponent<WfFadeBasic>();
  16. EventDelegate.Add(this.lastNameInput.onChange, new EventDelegate.Callback(this.OnInputName));
  17. EventDelegate.Add(this.firstNameInput.onChange, new EventDelegate.Callback(this.OnInputName));
  18. EventDelegate.Add(this.enterButton.onClick, new EventDelegate.Callback(this.Close));
  19. EventDelegate.Add(this.cancelButton.onClick, new EventDelegate.Callback(this.Chancel));
  20. EventDelegate.Add(this.lastNameRandomButton.onClick, delegate()
  21. {
  22. this.lastNameInput.RemoveFocus();
  23. this.lastNameInput.value = MaidRandomName.GetLastName();
  24. });
  25. EventDelegate.Add(this.firstNameRandomButton.onClick, delegate()
  26. {
  27. this.firstNameInput.RemoveFocus();
  28. this.firstNameInput.value = MaidRandomName.GetFirstName();
  29. });
  30. this.fadeBasic.onCompleteFadeInAction = delegate(WfFadeBasic execFade)
  31. {
  32. this.lastNameInput.isSelected = true;
  33. };
  34. }
  35. public void Call()
  36. {
  37. this.backupLastName = this.maid.status.lastName;
  38. this.backupFirstName = this.maid.status.firstName;
  39. this.lastNameInput.value = this.backupLastName;
  40. this.firstNameInput.value = this.backupFirstName;
  41. this.fadeBasic.alpha = 0f;
  42. WfFadeJob.Create(this.fadeBasic, null, 0.3f, iTween.EaseType.linear);
  43. }
  44. public void Chancel()
  45. {
  46. if (this.fadeBasic.alpha != 1f)
  47. {
  48. return;
  49. }
  50. this.maid.status.lastName = this.backupLastName;
  51. this.maid.status.firstName = this.backupFirstName;
  52. this.Close();
  53. }
  54. public void Close()
  55. {
  56. this.lastNameInput.RemoveFocus();
  57. this.firstNameInput.RemoveFocus();
  58. this.fadeBasic.alpha = 1f;
  59. WfFadeJob.Create(null, this.fadeBasic, 0.3f, iTween.EaseType.linear);
  60. }
  61. private void OnInputName()
  62. {
  63. if (UIInput.current == this.lastNameInput)
  64. {
  65. this.maid.status.lastName = UIInput.current.value;
  66. }
  67. else
  68. {
  69. this.maid.status.firstName = UIInput.current.value;
  70. }
  71. UIInput.current.value = ((!(UIInput.current == this.lastNameInput)) ? this.maid.status.firstName : this.maid.status.lastName);
  72. }
  73. [SerializeField]
  74. private UIInput lastNameInput;
  75. [SerializeField]
  76. private UIButton lastNameRandomButton;
  77. [SerializeField]
  78. private UIInput firstNameInput;
  79. [SerializeField]
  80. private UIButton firstNameRandomButton;
  81. [SerializeField]
  82. private UIButton enterButton;
  83. [SerializeField]
  84. private UIButton cancelButton;
  85. private WfFadeBasic fadeBasic;
  86. private string backupLastName;
  87. private string backupFirstName;
  88. }