init.lua 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. local class, object = require("class"), require("class.object")
  2. local Console = require("debug_overlay.console")
  3. local Graphs = require("debug_overlay.graphs")
  4. local Watch = require("debug_overlay.watch")
  5. local ECSDebug = require("debug_overlay.ecs")
  6. require("imgui")
  7. local Debug = class(object)
  8. function Debug:init()
  9. self.debug_windows = {
  10. Console = Console:new(),
  11. Graphs = Graphs:new(),
  12. Watch = Watch:new(),
  13. ECS = ECSDebug:new(),
  14. }
  15. self.console = self.debug_windows.Console
  16. self.watch = self.debug_windows.Watch
  17. end
  18. function Debug:render()
  19. self.debug_windows.Graphs:update()
  20. -- Menu
  21. if imgui.BeginMainMenuBar() then
  22. if imgui.BeginMenu("Debug") then
  23. for k,v in pairs(self.debug_windows) do
  24. if imgui.MenuItem(k, v.shortcut, v.visible) then
  25. v:toggle()
  26. end
  27. end
  28. imgui.EndMenu()
  29. end
  30. imgui.EndMainMenuBar()
  31. end
  32. for k,v in pairs(self.debug_windows) do
  33. if v.visible then
  34. v:render()
  35. end
  36. end
  37. end
  38. function Debug:keypressed(key)
  39. for k,v in pairs(self.debug_windows) do
  40. if v.shortcut and key == v.shortcut then
  41. v:toggle()
  42. end
  43. end
  44. end
  45. return Debug