SaveHandPane.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using UnityEngine;
  2. namespace COM3D2.MeidoPhotoStudio.Plugin
  3. {
  4. internal class SaveHandPane : BasePane
  5. {
  6. private MeidoManager meidoManager;
  7. private ComboBox categoryComboBox;
  8. private TextField handNameTextField;
  9. private Button saveLeftHandButton;
  10. private Button saveRightHandButton;
  11. private string categoryHeader;
  12. private string nameHeader;
  13. public SaveHandPane(MeidoManager meidoManager)
  14. {
  15. Constants.customHandChange += (s, a) =>
  16. {
  17. this.categoryComboBox.SetDropdownItems(Constants.CustomHandGroupList.ToArray());
  18. };
  19. this.meidoManager = meidoManager;
  20. this.categoryHeader = Translation.Get("handPane", "categoryHeader");
  21. this.nameHeader = Translation.Get("handPane", "nameHeader");
  22. this.saveLeftHandButton = new Button(Translation.Get("handPane", "saveLeftButton"));
  23. this.saveLeftHandButton.ControlEvent += (s, a) => SaveHand(right: false);
  24. this.saveRightHandButton = new Button(Translation.Get("handPane", "saveRightButton"));
  25. this.saveRightHandButton.ControlEvent += (s, a) => SaveHand(right: true);
  26. this.categoryComboBox = new ComboBox(Constants.CustomHandGroupList.ToArray());
  27. this.handNameTextField = new TextField();
  28. }
  29. protected override void ReloadTranslation()
  30. {
  31. this.categoryHeader = Translation.Get("handPane", "categoryHeader");
  32. this.nameHeader = Translation.Get("handPane", "nameHeader");
  33. this.saveLeftHandButton.Label = Translation.Get("handPane", "saveLeftButton");
  34. this.saveRightHandButton.Label = Translation.Get("handPane", "saveRightButton");
  35. }
  36. public override void Draw()
  37. {
  38. GUI.enabled = this.meidoManager.HasActiveMeido;
  39. MiscGUI.Header(categoryHeader);
  40. this.categoryComboBox.Draw(GUILayout.Width(165f));
  41. MiscGUI.Header(nameHeader);
  42. this.handNameTextField.Draw(GUILayout.Width(165f));
  43. GUILayout.BeginHorizontal();
  44. this.saveRightHandButton.Draw();
  45. this.saveLeftHandButton.Draw();
  46. GUILayout.EndHorizontal();
  47. GUI.enabled = true;
  48. }
  49. private void SaveHand(bool right)
  50. {
  51. byte[] handBinary = this.meidoManager.ActiveMeido.IKManager.SerializeHand(right);
  52. Constants.AddHand(handBinary, right, this.handNameTextField.Value, this.categoryComboBox.Value);
  53. this.handNameTextField.Value = string.Empty;
  54. }
  55. }
  56. }