WindowManager.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. namespace COM3D2.MeidoPhotoStudio.Plugin
  4. {
  5. using static Constants;
  6. internal class WindowManager : IManager
  7. {
  8. private Dictionary<Window, BaseWindow> Windows = new Dictionary<Window, BaseWindow>();
  9. public BaseWindow this[Window id]
  10. {
  11. get => Windows[id];
  12. set => Windows[id] = value;
  13. }
  14. public WindowManager()
  15. {
  16. InputManager.Register(MpsKey.ToggleUI, KeyCode.Tab);
  17. }
  18. public void DrawWindow(BaseWindow window)
  19. {
  20. if (window.Visible)
  21. {
  22. GUIStyle windowStyle = new GUIStyle(GUI.skin.box);
  23. window.WindowRect = GUI.Window(window.windowID, window.WindowRect, window.GUIFunc, "", windowStyle);
  24. }
  25. }
  26. public void DrawWindows()
  27. {
  28. foreach (BaseWindow window in Windows.Values)
  29. {
  30. DrawWindow(window);
  31. }
  32. }
  33. public void Update()
  34. {
  35. foreach (BaseWindow window in Windows.Values)
  36. {
  37. window.Update();
  38. }
  39. }
  40. public void Activate()
  41. {
  42. foreach (BaseWindow window in Windows.Values)
  43. {
  44. window.Activate();
  45. }
  46. }
  47. public void Deactivate()
  48. {
  49. foreach (BaseWindow window in Windows.Values)
  50. {
  51. window.Deactivate();
  52. }
  53. }
  54. }
  55. }