MaidSwitcherPane.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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.Portrait, 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. string label = "";
  36. if (meidoManager.HasActiveMeido)
  37. {
  38. Meido meido = meidoManager.ActiveMeido;
  39. label = $"{meido.LastName}\n{meido.FirstName}";
  40. }
  41. GUILayout.Label(label, labelStyle, GUILayout.ExpandWidth(false));
  42. GUILayout.EndVertical();
  43. NextButton.Draw(buttonStyle, GUILayout.Height(40), GUILayout.ExpandWidth(false));
  44. GUILayout.EndHorizontal();
  45. }
  46. private void ChangeMaid(int dir)
  47. {
  48. dir = (int)Mathf.Sign(dir);
  49. int selected = Utility.Wrap(
  50. this.meidoManager.SelectedMeido + dir, 0, this.meidoManager.ActiveMeidoList.Count
  51. );
  52. this.meidoManager.ChangeMaid(selected);
  53. }
  54. }
  55. }