MaidFaceBlendPane.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using UnityEngine;
  2. namespace COM3D2.MeidoPhotoStudio.Plugin
  3. {
  4. internal class MaidFaceBlendPane : BasePane
  5. {
  6. private MeidoManager meidoManager;
  7. private Dropdown faceBlendDropdown;
  8. private Button facePrevButton;
  9. private Button faceNextButton;
  10. public MaidFaceBlendPane(MeidoManager meidoManager)
  11. {
  12. this.meidoManager = meidoManager;
  13. this.faceBlendDropdown = new Dropdown(
  14. Translation.GetArray("faceBlendPresetsDropdown", Constants.FaceBlendList)
  15. );
  16. this.faceBlendDropdown.SelectionChange += (s, a) =>
  17. {
  18. if (updating) return;
  19. string faceBlend = Constants.FaceBlendList[this.faceBlendDropdown.SelectedItemIndex];
  20. this.meidoManager.ActiveMeido.SetFaceBlendSet(faceBlend);
  21. };
  22. this.facePrevButton = new Button("<");
  23. this.facePrevButton.ControlEvent += (s, a) => this.faceBlendDropdown.Step(-1);
  24. this.faceNextButton = new Button(">");
  25. this.faceNextButton.ControlEvent += (s, a) => this.faceBlendDropdown.Step(1);
  26. }
  27. protected override void ReloadTranslation()
  28. {
  29. this.updating = true;
  30. faceBlendDropdown.SetDropdownItems(
  31. Translation.GetArray("faceBlendPresetsDropdown", Constants.FaceBlendList)
  32. );
  33. this.updating = false;
  34. }
  35. public override void Draw()
  36. {
  37. float arrowButtonSize = 30;
  38. GUILayoutOption[] arrowLayoutOptions = {
  39. GUILayout.Width(arrowButtonSize),
  40. GUILayout.Height(arrowButtonSize)
  41. };
  42. float dropdownButtonHeight = arrowButtonSize;
  43. float dropdownButtonWidth = 153f;
  44. GUILayoutOption[] dropdownLayoutOptions = new GUILayoutOption[] {
  45. GUILayout.Height(dropdownButtonHeight),
  46. GUILayout.Width(dropdownButtonWidth)
  47. };
  48. GUI.enabled = this.meidoManager.HasActiveMeido;
  49. GUILayout.BeginHorizontal();
  50. this.facePrevButton.Draw(arrowLayoutOptions);
  51. this.faceBlendDropdown.Draw(dropdownLayoutOptions);
  52. this.faceNextButton.Draw(arrowLayoutOptions);
  53. GUILayout.EndHorizontal();
  54. GUI.enabled = true;
  55. }
  56. public override void UpdatePane()
  57. {
  58. this.updating = true;
  59. int faceBlendSetIndex = Constants.FaceBlendList.FindIndex(
  60. blend => blend == this.meidoManager.ActiveMeido.FaceBlendSet
  61. );
  62. this.faceBlendDropdown.SelectedItemIndex = Mathf.Clamp(faceBlendSetIndex, 0, Constants.FaceBlendList.Count);
  63. this.updating = false;
  64. }
  65. }
  66. }