BackgroundWindow.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using UnityEngine;
  5. namespace COM3D2.MeidoPhotoStudio.Plugin
  6. {
  7. public class BackgroundWindow : BaseMainWindow
  8. {
  9. private EnvironmentManager environmentManager;
  10. private Dropdown bgDropdown;
  11. private Button prevBGButton;
  12. private Button nextBGButton;
  13. public BackgroundWindow(EnvironmentManager environmentManager)
  14. {
  15. this.environmentManager = environmentManager;
  16. int theaterIndex = Constants.BGList.FindIndex(bg => bg == "Theater");
  17. this.bgDropdown = new Dropdown(Translation.GetList("bgDropdown", Constants.BGList), theaterIndex);
  18. this.bgDropdown.SelectionChange += (s, a) =>
  19. {
  20. string bg = Constants.BGList[this.bgDropdown.SelectedItemIndex];
  21. environmentManager.ChangeBackground(bg);
  22. };
  23. this.prevBGButton = new Button("<");
  24. this.prevBGButton.ControlEvent += (s, a) => this.bgDropdown.Step(-1);
  25. this.nextBGButton = new Button(">");
  26. this.nextBGButton.ControlEvent += (s, a) => this.bgDropdown.Step(1);
  27. }
  28. public override void Draw(params GUILayoutOption[] layoutOptions)
  29. {
  30. float arrowButtonSize = 30;
  31. GUILayoutOption[] arrowLayoutOptions = {
  32. GUILayout.Width(arrowButtonSize),
  33. GUILayout.Height(arrowButtonSize)
  34. };
  35. float dropdownButtonHeight = arrowButtonSize;
  36. float dropdownButtonWidth = 143f;
  37. GUILayoutOption[] dropdownLayoutOptions = new GUILayoutOption[] {
  38. GUILayout.Height(dropdownButtonHeight),
  39. GUILayout.Width(dropdownButtonWidth)
  40. };
  41. GUILayout.BeginHorizontal();
  42. this.prevBGButton.Draw(arrowLayoutOptions);
  43. this.bgDropdown.Draw(dropdownLayoutOptions);
  44. this.nextBGButton.Draw(arrowLayoutOptions);
  45. GUILayout.EndHorizontal();
  46. }
  47. }
  48. }