MaidSelectorPane.cs 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace COM3D2.MeidoPhotoStudio.Plugin
  5. {
  6. public class MaidSelectorPane : BasePane
  7. {
  8. private MeidoManager meidoManager;
  9. public List<int> selectedMaidList { get; private set; }
  10. private Vector2 maidListScrollPos;
  11. private Button clearMaidsButton;
  12. private Button callMaidsButton;
  13. public MaidSelectorPane(MeidoManager meidoManager) : base()
  14. {
  15. this.meidoManager = meidoManager;
  16. selectedMaidList = new List<int>();
  17. clearMaidsButton = new Button("Clear");
  18. clearMaidsButton.ControlEvent += (s, a) => selectedMaidList.Clear();
  19. Controls.Add(clearMaidsButton);
  20. callMaidsButton = new Button("Call");
  21. callMaidsButton.ControlEvent += (s, a) => this.meidoManager.OnBeginCallMeidos(this.selectedMaidList);
  22. Controls.Add(callMaidsButton);
  23. }
  24. public override void Draw(params GUILayoutOption[] layoutOptions)
  25. {
  26. clearMaidsButton.Draw();
  27. callMaidsButton.Draw();
  28. GUIStyle labelStyle = new GUIStyle(GUI.skin.label);
  29. labelStyle.fontSize = 14;
  30. GUIStyle selectLabelStyle = new GUIStyle(labelStyle);
  31. selectLabelStyle.normal.textColor = Color.black;
  32. selectLabelStyle.alignment = TextAnchor.UpperRight;
  33. GUIStyle labelSelectedStyle = new GUIStyle(labelStyle);
  34. labelSelectedStyle.normal.textColor = Color.black;
  35. float windowHeight = Screen.height * 0.8f;
  36. int buttonHeight = 85;
  37. int buttonWidth = 205;
  38. Rect positionRect = new Rect(5, 115, buttonWidth + 15, windowHeight - 140);
  39. Rect viewRect = new Rect(0, 0, buttonWidth - 5, buttonHeight * meidoManager.meidos.Length + 5);
  40. maidListScrollPos = GUI.BeginScrollView(positionRect, maidListScrollPos, viewRect);
  41. for (int i = 0; i < meidoManager.meidos.Length; i++)
  42. {
  43. Meido meido = meidoManager.meidos[i];
  44. float y = i * buttonHeight;
  45. bool selectedMaid = selectedMaidList.Contains(i);
  46. if (GUI.Button(new Rect(0, y, buttonWidth, buttonHeight), ""))
  47. {
  48. if (selectedMaid) selectedMaidList.Remove(i);
  49. else selectedMaidList.Add(i);
  50. }
  51. if (selectedMaid)
  52. {
  53. int selectedIndex = selectedMaidList.IndexOf(i) + 1;
  54. GUI.DrawTexture(new Rect(5, y + 5, buttonWidth - 10, buttonHeight - 10), Texture2D.whiteTexture);
  55. GUI.Label(new Rect(0, y + 5, buttonWidth - 10, buttonHeight), selectedIndex.ToString(), selectLabelStyle);
  56. }
  57. GUI.DrawTexture(new Rect(5, y, buttonHeight, buttonHeight), meido.Image);
  58. GUI.Label(new Rect(95, y + 30, buttonWidth - 80, buttonHeight), meido.NameJP, selectedMaid ? labelSelectedStyle : labelStyle);
  59. }
  60. GUI.EndScrollView();
  61. }
  62. }
  63. }