MaidFaceBlendPane.cs 2.8 KB

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