Josh Engebretson 11 years ago
parent
commit
e998ae427d

+ 10 - 9
Bin/CoreData/AtomicModules/AtomicGame.js

@@ -3,12 +3,12 @@ Atomic.editor = null;
 
 function Game() {
 
-	this.engine = Atomic.GetEngine();
-	this.cache = Atomic.GetResourceCache();	
-	this.renderer = Atomic.GetRenderer();
-	this.graphics = Atomic.GetGraphics();
-	this.input = Atomic.GetInput();
-    this.ui = Atomic.GetUI();
+	this.engine = Atomic.getEngine();
+	this.cache = Atomic.getResourceCache();	
+	this.renderer = Atomic.getRenderer();
+	this.graphics = Atomic.getGraphics();
+	this.input = Atomic.getInput();
+    this.ui = Atomic.getUI();
 
     if (Atomic.platform == "Android") {
         this.renderer.reuseShadowMaps = false;
@@ -19,13 +19,14 @@ function Game() {
 
 Game.prototype.init = function(start, update) {
 
-	this.start = start;
 	this.update = update;
 
-	// register globals to get at quickly
-	__js_atomicgame_start = start;
+	// register global to get at quickly
 	__js_atomicgame_update = update;
 
+    if (typeof(start) === "function")
+        start();
+
 }
 
 Game.prototype.getSpriteSheet2D = function(xmlFile) {

+ 6 - 6
Source/Atomic/Javascript/JSAtomic.cpp

@@ -250,22 +250,22 @@ void jsapi_init_atomic(JSVM* vm)
     duk_pop(ctx);
 
     duk_push_c_function(ctx, js_atomic_GetEngine, 0);
-    duk_put_prop_string(ctx, -2, "GetEngine");
+    duk_put_prop_string(ctx, -2, "getEngine");
 
     duk_push_c_function(ctx, js_atomic_GetGraphics, 0);
-    duk_put_prop_string(ctx, -2, "GetGraphics");
+    duk_put_prop_string(ctx, -2, "getGraphics");
 
     duk_push_c_function(ctx, js_atomic_GetRenderer, 0);
-    duk_put_prop_string(ctx, -2, "GetRenderer");
+    duk_put_prop_string(ctx, -2, "getRenderer");
 
     duk_push_c_function(ctx, js_atomic_GetResourceCache, 0);
-    duk_put_prop_string(ctx, -2, "GetResourceCache");
+    duk_put_prop_string(ctx, -2, "getResourceCache");
 
     duk_push_c_function(ctx, js_atomic_GetInput, 0);
-    duk_put_prop_string(ctx, -2, "GetInput");
+    duk_put_prop_string(ctx, -2, "getInput");
 
     duk_push_c_function(ctx, js_atomic_GetUI, 0);
-    duk_put_prop_string(ctx, -2, "GetUI");
+    duk_put_prop_string(ctx, -2, "getUI");
 
     duk_push_c_function(ctx, js_atomic_script, 1);
     duk_put_prop_string(ctx, -2, "script");

+ 3 - 1
Source/Atomic/Javascript/JSVM.cpp

@@ -378,6 +378,9 @@ bool JSVM::ExecuteScript(const String& scriptPath)
     if (!path.StartsWith("Scripts/"))
         path = "Scripts/" + path;
 
+    if (!path.EndsWith(".js"))
+        path += ".js";
+
     SharedPtr<File> file (GetSubsystem<ResourceCache>()->GetFile(path));
 
     if (file.Null())
@@ -457,7 +460,6 @@ bool JSVM::ExecuteMain()
 
     duk_pop(ctx_);
 
-    ExecuteFunction("__js_atomicgame_start");
     return true;
 }
 

+ 1 - 0
Source/Atomic/Javascript/JSVM.h

@@ -31,6 +31,7 @@ public:
     bool ExecuteScript(const String& scriptPath);
     // Resources/Script/main.js
 
+    // Catches not requiring AtomicGame, etc
     bool ExecuteMain();
 
     bool ExecuteFunction(const String& functionName);