AEEditorCommon.cpp 2.5 KB

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