MaidSelectorPane.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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(Translation.Get("maidCallWindow", "clearButton"));
  18. clearMaidsButton.ControlEvent += (s, a) => selectedMaidList.Clear();
  19. Controls.Add(clearMaidsButton);
  20. callMaidsButton = new Button(Translation.Get("maidCallWindow", "callButton"));
  21. callMaidsButton.ControlEvent += (s, a) => this.meidoManager.OnBeginCallMeidos(this.selectedMaidList);
  22. Controls.Add(callMaidsButton);
  23. }
  24. protected override void ReloadTranslation()
  25. {
  26. clearMaidsButton.Label = Translation.Get("maidCallWindow", "clearButton");
  27. callMaidsButton.Label = Translation.Get("maidCallWindow", "callButton");
  28. }
  29. public override void Draw(params GUILayoutOption[] layoutOptions)
  30. {
  31. clearMaidsButton.Draw();
  32. callMaidsButton.Draw();
  33. GUIStyle labelStyle = new GUIStyle(GUI.skin.label);
  34. labelStyle.fontSize = 14;
  35. GUIStyle selectLabelStyle = new GUIStyle(labelStyle);
  36. selectLabelStyle.normal.textColor = Color.black;
  37. selectLabelStyle.alignment = TextAnchor.UpperRight;
  38. GUIStyle labelSelectedStyle = new GUIStyle(labelStyle);
  39. labelSelectedStyle.normal.textColor = Color.black;
  40. float windowHeight = Screen.height * 0.8f;
  41. int buttonHeight = 85;
  42. int buttonWidth = 205;
  43. Rect positionRect = new Rect(5, 115, buttonWidth + 15, windowHeight - 140);
  44. Rect viewRect = new Rect(0, 0, buttonWidth - 5, buttonHeight * meidoManager.meidos.Length + 5);
  45. maidListScrollPos = GUI.BeginScrollView(positionRect, maidListScrollPos, viewRect);
  46. for (int i = 0; i < meidoManager.meidos.Length; i++)
  47. {
  48. Meido meido = meidoManager.meidos[i];
  49. float y = i * buttonHeight;
  50. bool selectedMaid = selectedMaidList.Contains(i);
  51. if (GUI.Button(new Rect(0, y, buttonWidth, buttonHeight), ""))
  52. {
  53. if (selectedMaid) selectedMaidList.Remove(i);
  54. else selectedMaidList.Add(i);
  55. }
  56. if (selectedMaid)
  57. {
  58. int selectedIndex = selectedMaidList.IndexOf(i) + 1;
  59. GUI.DrawTexture(new Rect(5, y + 5, buttonWidth - 10, buttonHeight - 10), Texture2D.whiteTexture);
  60. GUI.Label(
  61. new Rect(0, y + 5, buttonWidth - 10, buttonHeight), selectedIndex.ToString(), selectLabelStyle
  62. );
  63. }
  64. GUI.DrawTexture(new Rect(5, y, buttonHeight, buttonHeight), meido.Image);
  65. GUI.Label(
  66. new Rect(95, y + 30, buttonWidth - 80, buttonHeight),
  67. meido.NameJP, selectedMaid ? labelSelectedStyle : labelStyle
  68. );
  69. }
  70. GUI.EndScrollView();
  71. }
  72. }
  73. }