MaidSwitcherPane.cs 2.4 KB

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