AEEditorCommon.cpp 1.4 KB

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