AEEditorCommon.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
  2. // Please see LICENSE.md in repository root for license information
  3. // https://github.com/AtomicGameEngine/AtomicGameEngine
  4. #include <Atomic/Engine/Engine.h>
  5. #include <Atomic/Input/Input.h>
  6. #include <Atomic/IPC/IPC.h>
  7. // Move me to Engine
  8. #include <Atomic/Environment/Environment.h>
  9. #include <AtomicJS/Javascript/Javascript.h>
  10. #include "AEEditorCommon.h"
  11. namespace AtomicEditor
  12. {
  13. AEEditorCommon::AEEditorCommon(Context* context) :
  14. Application(context)
  15. {
  16. }
  17. void AEEditorCommon::Start()
  18. {
  19. Input* input = GetSubsystem<Input>();
  20. input->SetMouseVisible(true);
  21. // Register IPC system
  22. context_->RegisterSubsystem(new IPC(context_));
  23. // Instantiate and register the Javascript subsystem
  24. Javascript* javascript = new Javascript(context_);
  25. context_->RegisterSubsystem(javascript);
  26. vm_ = javascript->InstantiateVM("MainVM");
  27. vm_->InitJSContext();
  28. }
  29. void AEEditorCommon::Setup()
  30. {
  31. #ifdef ATOMIC_3D
  32. RegisterEnvironmentLibrary(context_);
  33. #endif
  34. }
  35. void AEEditorCommon::Stop()
  36. {
  37. vm_ = 0;
  38. context_->RemoveSubsystem<Javascript>();
  39. // make sure JSVM is really down and no outstanding refs
  40. // as if not, will hold on engine subsystems, which is bad
  41. assert(!JSVM::GetJSVM(0));
  42. }
  43. }