MaidSwitcherPane.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using UnityEngine;
  2. namespace COM3D2.MeidoPhotoStudio.Plugin
  3. {
  4. internal class MaidSwitcherPane : BasePane
  5. {
  6. private MeidoManager meidoManager;
  7. private Button PreviousButton;
  8. private Button NextButton;
  9. private int SelectedMeido => meidoManager.SelectedMeido;
  10. public MaidSwitcherPane(MeidoManager meidoManager)
  11. {
  12. this.meidoManager = meidoManager;
  13. PreviousButton = new Button("<");
  14. PreviousButton.ControlEvent += (s, a) => ChangeMaid(-1);
  15. NextButton = new Button(">");
  16. NextButton.ControlEvent += (s, a) => ChangeMaid(1);
  17. }
  18. public override void Draw()
  19. {
  20. GUIStyle boxStyle = new GUIStyle(GUI.skin.box);
  21. GUIStyle buttonStyle = new GUIStyle(GUI.skin.button);
  22. GUIStyle labelStyle = new GUIStyle(GUI.skin.label);
  23. boxStyle.padding.top = -15;
  24. buttonStyle.margin.top = 20;
  25. labelStyle.alignment = TextAnchor.UpperLeft;
  26. GUILayout.BeginHorizontal();
  27. GUI.enabled = meidoManager.HasActiveMeido;
  28. PreviousButton.Draw(buttonStyle, GUILayout.Height(40), GUILayout.ExpandWidth(false));
  29. if (meidoManager.HasActiveMeido)
  30. MiscGUI.DrawTexture(meidoManager.ActiveMeido.Image, GUILayout.Width(70), GUILayout.Height(70));
  31. else
  32. GUILayout.Box("", boxStyle, GUILayout.Height(70), GUILayout.Width(70));
  33. GUILayout.BeginVertical();
  34. GUILayout.Space(30);
  35. GUILayout.Label(
  36. meidoManager.HasActiveMeido
  37. ? meidoManager.ActiveMeido.NameJP
  38. : "",
  39. labelStyle, GUILayout.ExpandWidth(false)
  40. );
  41. GUILayout.EndVertical();
  42. NextButton.Draw(buttonStyle, GUILayout.Height(40), GUILayout.ExpandWidth(false));
  43. GUILayout.EndHorizontal();
  44. }
  45. private void ChangeMaid(int dir)
  46. {
  47. dir = (int)Mathf.Sign(dir);
  48. int selected = Utility.Wrap(
  49. this.meidoManager.SelectedMeido + dir, 0, this.meidoManager.ActiveMeidoList.Count
  50. );
  51. this.meidoManager.ChangeMaid(selected);
  52. }
  53. }
  54. }