MaidSwitcherPane.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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(meidoManager.HasActiveMeido ? meidoManager.ActiveMeido.NameJP : "", labelStyle, GUILayout.ExpandWidth(false));
  37. GUILayout.EndVertical();
  38. NextButton.Draw(buttonStyle, GUILayout.Height(40), GUILayout.ExpandWidth(false));
  39. GUILayout.EndHorizontal();
  40. }
  41. private static void ChangeMaid(int dir)
  42. {
  43. dir = (int)Mathf.Sign(dir);
  44. int selected = Utility.Wrap(SelectedMeido + dir, 0, meidoManager.ActiveMeidoList.Count);
  45. OnMaidChange(new MeidoChangeEventArgs(selected));
  46. }
  47. private static void OnMaidChange(MeidoChangeEventArgs args)
  48. {
  49. MaidChange?.Invoke(null, args);
  50. }
  51. }
  52. }