WindowManager.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 void DrawWindow(BaseWindow window)
  15. {
  16. if (window.Visible)
  17. {
  18. GUIStyle windowStyle = new GUIStyle(GUI.skin.box);
  19. window.WindowRect = GUI.Window(window.windowID, window.WindowRect, window.GUIFunc, "", windowStyle);
  20. }
  21. }
  22. public void DrawWindows()
  23. {
  24. foreach (BaseWindow window in Windows.Values)
  25. {
  26. DrawWindow(window);
  27. }
  28. }
  29. public void Update()
  30. {
  31. foreach (BaseWindow window in Windows.Values)
  32. {
  33. window.Update();
  34. }
  35. }
  36. public void Activate()
  37. {
  38. foreach (BaseWindow window in Windows.Values)
  39. {
  40. window.Activate();
  41. }
  42. }
  43. public void Deactivate()
  44. {
  45. foreach (BaseWindow window in Windows.Values)
  46. {
  47. window.Deactivate();
  48. }
  49. }
  50. }
  51. }