UserEditMgr.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. using System;
  2. using System.Collections.Generic;
  3. public class UserEditMgr : BaseCreatePanel
  4. {
  5. public override void Init()
  6. {
  7. this.m_goPanel = base.GetPanel("UserEditPanel");
  8. this.m_ctrl = base.GetCtrl<UserEditCtrl>();
  9. this.m_api = new UserEditAPI();
  10. this.m_ctrl.Init(this, this.m_api, this.m_goPanel);
  11. this.m_goPanel.SetActive(false);
  12. this.m_api.Init(this, new UserEditAPI.dgOnCharaLoadedCallBack(this.OnCharaLoaded));
  13. this.m_init = true;
  14. }
  15. private void OnCharaLoaded()
  16. {
  17. this.OpenUserEditPanel();
  18. }
  19. public void OnDestroy()
  20. {
  21. if (this.m_api != null)
  22. {
  23. this.m_api.Uninit();
  24. }
  25. }
  26. public void OpenUserEditPanel()
  27. {
  28. base.BaseOpenPanel();
  29. }
  30. protected override void OpenPanel()
  31. {
  32. Dictionary<string, UserEditCtrl.HeadButton> dicHeadPreset = this.LoadData();
  33. this.m_ctrl.CreateViewer(dicHeadPreset);
  34. }
  35. public void CloseUserEditPanel()
  36. {
  37. base.BaseClosePanel();
  38. }
  39. protected override void BeforeClose()
  40. {
  41. this.m_ctrl.SaveAndLoadScene();
  42. }
  43. protected override void AfterClose()
  44. {
  45. if (this.sceneMgr != null)
  46. {
  47. this.m_api.EndNextScene(new CameraMain.dgOnCompleteFade(this.sceneMgr.CloseScene));
  48. }
  49. }
  50. public void ClickPreset()
  51. {
  52. string name = UIButton.current.name;
  53. if (name != this.m_currentActivePreset)
  54. {
  55. this.m_ctrl.SetPreset(name);
  56. this.m_currentActivePreset = name;
  57. }
  58. }
  59. public void OnAbdomenValueChange()
  60. {
  61. if (this.m_init)
  62. {
  63. this.m_ctrl.UpdateAbdomenValue();
  64. }
  65. }
  66. public void OnColorValueChange()
  67. {
  68. if (this.m_init)
  69. {
  70. this.m_ctrl.UpdateColorValue();
  71. }
  72. }
  73. public void OnChangeName()
  74. {
  75. string value = UIInput.current.value;
  76. this.m_ctrl.SetName(value);
  77. }
  78. protected override void SetFadeTargetPanel()
  79. {
  80. this.fadeTargetPanel = this.m_goPanel;
  81. }
  82. private Dictionary<string, UserEditCtrl.HeadButton> LoadData()
  83. {
  84. Dictionary<string, UserEditCtrl.HeadButton> dictionary = new Dictionary<string, UserEditCtrl.HeadButton>();
  85. List<SceneEdit.SMenuItem> menu = this.m_api.GetMenu(MPN.head);
  86. foreach (SceneEdit.SMenuItem smenuItem in menu)
  87. {
  88. if (smenuItem.m_bMan)
  89. {
  90. UserEditCtrl.HeadButton headButton = new UserEditCtrl.HeadButton();
  91. headButton.name = smenuItem.m_strMenuFileName;
  92. headButton.headIcon = smenuItem.m_texIconRef;
  93. headButton.item = smenuItem;
  94. if (!dictionary.ContainsKey(headButton.name))
  95. {
  96. dictionary.Add(headButton.name, headButton);
  97. }
  98. }
  99. }
  100. return dictionary;
  101. }
  102. private UserEditCtrl m_ctrl;
  103. private string m_currentActivePreset;
  104. private bool m_init;
  105. private UserEditAPI m_api;
  106. }