// // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved // LICENSE: Atomic Game Engine Editor and Tools EULA // Please see LICENSE_ATOMIC_EDITOR_AND_TOOLS.md in repository root for // license information: https://github.com/AtomicGameEngine/AtomicGameEngine // #include #include #include // Move me to Engine #include #include #include #ifdef ATOMIC_DOTNET #include #include #endif #include "AEEditorCommon.h" namespace Atomic { void jsapi_init_atomicnet(JSVM* vm); } namespace AtomicEditor { AEEditorCommon::AEEditorCommon(Context* context) : Application(context) { } void AEEditorCommon::Start() { Input* input = GetSubsystem(); input->SetMouseVisible(true); Javascript* javascript = GetSubsystem(); vm_ = javascript->InstantiateVM("MainVM"); vm_->InitJSContext(); #ifdef ATOMIC_DOTNET jsapi_init_atomicnet(vm_); #endif } void AEEditorCommon::Setup() { #ifdef ATOMIC_3D RegisterEnvironmentLibrary(context_); #endif // Register IPC system context_->RegisterSubsystem(new IPC(context_)); context_->RegisterSubsystem(new ScriptSystem(context_)); // Instantiate and register the Javascript subsystem Javascript* javascript = new Javascript(context_); context_->RegisterSubsystem(javascript); #ifdef ATOMIC_DOTNET // Instantiate and register the AtomicNET subsystem SharedPtr netCore (new NETCore(context_)); context_->RegisterSubsystem(netCore); String netCoreErrorMsg; #ifdef ATOMIC_DEV_BUILD String assemblyLoadPaths = GetNativePath(ToString("%s/Artifacts/AtomicNET/", ATOMIC_ROOT_SOURCE_DIR)); #ifdef ATOMIC_PLATFORM_WINDOWS String coreCLRAbsPath = GetNativePath(ToString("%s/Submodules/CoreCLR/Windows/Debug/x64/", ATOMIC_ROOT_SOURCE_DIR)); String coreCLRTPAPaths = ToString("%s/Submodules/CoreCLR/Windows/Debug/AnyCPU/TPA/", ATOMIC_ROOT_SOURCE_DIR); coreCLRTPAPaths += ToString(";%s/Artifacts/AtomicNET/TPA/", ATOMIC_ROOT_SOURCE_DIR); #else String coreCLRAbsPath = GetNativePath(ToString("%s/Submodules/CoreCLR/OSX/Debug/x64/", ATOMIC_ROOT_SOURCE_DIR); #endif #else assert(0); #endif NETHost::SetCoreCLRFilesAbsPath(coreCLRAbsPath); NETHost::SetCoreCLRTPAPaths(coreCLRTPAPaths); NETHost::SetCoreCLRAssemblyLoadPaths(assemblyLoadPaths); if (!netCore->Initialize(netCoreErrorMsg)) { LOGERRORF("NetCore: Unable to initialize! %s", netCoreErrorMsg.CString()); context_->RemoveSubsystem(NETCore::GetTypeStatic()); } else { } #endif } void AEEditorCommon::Stop() { context_->RemoveSubsystem(); vm_ = 0; context_->RemoveSubsystem(); // make sure JSVM is really down and no outstanding refs // as if not, will hold on engine subsystems, which is bad assert(!JSVM::GetJSVM(0)); #ifdef ATOMIC_DOTNET NETCore* netCore = GetSubsystem(); if (netCore) { netCore->Shutdown(); context_->RemoveSubsystem(); } #endif } }