Browse Source

require the editor main.js instead of evaling it

Josh Engebretson 10 years ago
parent
commit
23367ff55f
2 changed files with 6 additions and 11 deletions
  1. 1 1
      Script/AtomicEditor/main.ts
  2. 5 10
      Source/AtomicEditor/Application/AEEditorApp.cpp

+ 1 - 1
Script/AtomicEditor/main.ts

@@ -5,8 +5,8 @@
 
 import Editor = require("editor/Editor");
 
-//Main is still evaling for now, need to have it done through requiring it
 class Main {
+
     static Editor:Editor;
 
     static main() {

+ 5 - 10
Source/AtomicEditor/Application/AEEditorApp.cpp

@@ -67,19 +67,14 @@ void AEEditorApp::Start()
     jsapi_init_toolcore(vm_);
     jsapi_init_editor(vm_);
 
-    SharedPtr<File> file (GetSubsystem<ResourceCache>()->GetFile("AtomicEditor/out/main.js"));
-
-    if (file.Null())
+    duk_get_global_string(vm_->GetJSContext(), "require");
+    duk_push_string(vm_->GetJSContext(), "main");
+    if (duk_pcall(vm_->GetJSContext(), 1) != 0)
     {
-        ErrorExit("Unable to load AtomicEditor/out/main.js");
-        return;
+        vm_->SendJSErrorEvent();
+        ErrorExit("Error executing main.js");
     }
 
-    if (!vm_->ExecuteFile(file))
-    {
-        ErrorExit("Error executing AtomicEditor/out/main.js");
-        return;
-    }
 
     GetSubsystem<LicenseSystem>()->Initialize();