SavePosePane.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System;
  2. using UnityEngine;
  3. namespace COM3D2.MeidoPhotoStudio.Plugin
  4. {
  5. internal class SavePosePane : BasePane
  6. {
  7. private MeidoManager meidoManager;
  8. private Button savePoseButton;
  9. private TextField poseNameTextField;
  10. private ComboBox categoryComboBox;
  11. private string categoryHeader;
  12. private string nameHeader;
  13. public SavePosePane(MeidoManager meidoManager)
  14. {
  15. Constants.customPoseChange += (s, a) =>
  16. {
  17. this.categoryComboBox.SetDropdownItems(Constants.CustomPoseGroupList.ToArray());
  18. };
  19. this.meidoManager = meidoManager;
  20. this.categoryHeader = Translation.Get("posePane", "categoryHeader");
  21. this.nameHeader = Translation.Get("posePane", "nameHeader");
  22. this.savePoseButton = new Button(Translation.Get("posePane", "saveButton"));
  23. this.savePoseButton.ControlEvent += OnSavePose;
  24. this.categoryComboBox = new ComboBox(Constants.CustomPoseGroupList.ToArray());
  25. this.poseNameTextField = new TextField();
  26. this.poseNameTextField.ControlEvent += OnSavePose;
  27. }
  28. protected override void ReloadTranslation()
  29. {
  30. this.categoryHeader = Translation.Get("posePane", "categoryHeader");
  31. this.nameHeader = Translation.Get("posePane", "nameHeader");
  32. this.savePoseButton.Label = Translation.Get("posePane", "saveButton");
  33. }
  34. public override void Draw()
  35. {
  36. GUI.enabled = this.meidoManager.HasActiveMeido;
  37. MiscGUI.Header(categoryHeader);
  38. this.categoryComboBox.Draw(GUILayout.Width(160f));
  39. MiscGUI.Header(nameHeader);
  40. GUILayout.BeginHorizontal();
  41. this.poseNameTextField.Draw(GUILayout.Width(160f));
  42. this.savePoseButton.Draw(GUILayout.ExpandWidth(false));
  43. GUILayout.EndHorizontal();
  44. GUI.enabled = true;
  45. }
  46. private void OnSavePose(object sender, EventArgs args)
  47. {
  48. byte[] anmBinary = this.meidoManager.ActiveMeido.SerializePose();
  49. Constants.AddPose(anmBinary, this.poseNameTextField.Value, this.categoryComboBox.Value);
  50. this.poseNameTextField.Value = String.Empty;
  51. }
  52. }
  53. }