Debugger.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #include "../../Include/RmlUi/Debugger/Debugger.h"
  2. #include "../../Include/RmlUi/Core/Core.h"
  3. #include "DebuggerPlugin.h"
  4. namespace Rml {
  5. namespace Debugger {
  6. bool Initialise(Context* context)
  7. {
  8. if (DebuggerPlugin::GetInstance() != nullptr)
  9. {
  10. Log::Message(Log::LT_WARNING, "Unable to initialise debugger plugin, already initialised!");
  11. return false;
  12. }
  13. DebuggerPlugin* plugin = new DebuggerPlugin();
  14. if (!plugin->Initialise(context))
  15. {
  16. Log::Message(Log::LT_WARNING, "Unable to initialise debugger plugin.");
  17. delete plugin;
  18. return false;
  19. }
  20. SetContext(context);
  21. RegisterPlugin(plugin);
  22. return true;
  23. }
  24. void Shutdown()
  25. {
  26. DebuggerPlugin* plugin = DebuggerPlugin::GetInstance();
  27. if (!plugin)
  28. {
  29. Log::Message(Log::LT_WARNING, "Unable to shutdown debugger plugin, it was not initialised!");
  30. return;
  31. }
  32. UnregisterPlugin(plugin);
  33. }
  34. bool SetContext(Context* context)
  35. {
  36. DebuggerPlugin* plugin = DebuggerPlugin::GetInstance();
  37. if (plugin == nullptr)
  38. return false;
  39. plugin->SetContext(context);
  40. return true;
  41. }
  42. void SetVisible(bool visibility)
  43. {
  44. DebuggerPlugin* plugin = DebuggerPlugin::GetInstance();
  45. if (plugin != nullptr)
  46. plugin->SetVisible(visibility);
  47. }
  48. bool IsVisible()
  49. {
  50. DebuggerPlugin* plugin = DebuggerPlugin::GetInstance();
  51. if (plugin == nullptr)
  52. return false;
  53. return plugin->IsVisible();
  54. }
  55. } // namespace Debugger
  56. } // namespace Rml