AEEditorCommon.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. #ifdef ATOMIC_DOTNET
  14. #include <AtomicNET/NETCore/NETCore.h>
  15. #endif
  16. #include "AEEditorCommon.h"
  17. namespace AtomicEditor
  18. {
  19. AEEditorCommon::AEEditorCommon(Context* context) :
  20. Application(context)
  21. {
  22. }
  23. void AEEditorCommon::Start()
  24. {
  25. Input* input = GetSubsystem<Input>();
  26. input->SetMouseVisible(true);
  27. // Register IPC system
  28. context_->RegisterSubsystem(new IPC(context_));
  29. // Instantiate and register the Javascript subsystem
  30. Javascript* javascript = new Javascript(context_);
  31. context_->RegisterSubsystem(javascript);
  32. #ifdef ATOMIC_DOTNET
  33. // Instantiate and register the AtomicNET subsystem
  34. SharedPtr<NETCore> netCore (new NETCore(context_));
  35. String netCoreErrorMsg;
  36. if (!netCore->Initialize("/Users/josh/Desktop/OSX.x64.Debug/", netCoreErrorMsg))
  37. {
  38. LOGERRORF("NetCore: Unable to initialize! %s", netCoreErrorMsg.CString());
  39. }
  40. else
  41. {
  42. context_->RegisterSubsystem(netCore);
  43. }
  44. #endif
  45. vm_ = javascript->InstantiateVM("MainVM");
  46. vm_->InitJSContext();
  47. }
  48. void AEEditorCommon::Setup()
  49. {
  50. #ifdef ATOMIC_3D
  51. RegisterEnvironmentLibrary(context_);
  52. #endif
  53. }
  54. void AEEditorCommon::Stop()
  55. {
  56. context_->RemoveSubsystem<IPC>();
  57. vm_ = 0;
  58. context_->RemoveSubsystem<Javascript>();
  59. // make sure JSVM is really down and no outstanding refs
  60. // as if not, will hold on engine subsystems, which is bad
  61. assert(!JSVM::GetJSVM(0));
  62. #ifdef ATOMIC_DOTNET
  63. NETCore* netCore = GetSubsystem<NETCore>();
  64. if (netCore)
  65. {
  66. netCore->Shutdown();
  67. context_->RemoveSubsystem<NETCore>();
  68. }
  69. #endif
  70. }
  71. }