Browse Source

Working on Atomic web player

Josh Engebretson 10 years ago
parent
commit
2fcdbbcc73

+ 19 - 0
CLI/atomic-cli/bin/atomic-cli.js

@@ -131,6 +131,25 @@ program
 
 
   });
   });
 
 
+
+  program
+    .command('build <platform>')
+    .option('--project <path>')
+    .description('builds the project for the specified platform')
+    .action(function(platform, options) {
+      if(options.project) {
+        process.chdir(options.project)
+      }
+      cli.build(platform)
+      .then(function () {
+      })
+      .catch(function (error) {
+          process.exit(1);
+      });
+
+    });
+
+
 program
 program
   .command('edit [path_to_project]')
   .command('edit [path_to_project]')
   .description('edits the project in the cwd or on at a specified path')
   .description('edits the project in the cwd or on at a specified path')

+ 1 - 1
CLI/atomic-cli/lib/atomictool.js

@@ -87,7 +87,7 @@ var run = function (platform, opts) {
 var exec = function (command, flags, opts) {
 var exec = function (command, flags, opts) {
     opts = opts || {};
     opts = opts || {};
     if (opts.verbose !== false) {
     if (opts.verbose !== false) {
-        //console.log([command].concat(flags).join(" "));
+        console.log([command].concat(flags).join(" "));
     }
     }
 
 
     var deferred = Q.defer();
     var deferred = Q.defer();

+ 127 - 0
Data/AtomicEditor/Deployment/Web/AtomicLoader.js

@@ -0,0 +1,127 @@
+var AtomicLoader;
+if (typeof AtomicLoader === 'undefined') AtomicLoader = eval('(function() { try { return AtomicLoader || {} } catch(e) { return {} } })()');
+
+window.addEventListener("keydown", function(e) {
+
+  // Disable stock behavior, which was causing scroll errors
+  // space and arrow keys
+  if([32, 37, 38, 39, 40].indexOf(e.keyCode) > -1) {
+    e.preventDefault();
+  }
+}, false);
+
+
+var atomicCanvas = document.getElementById('canvas');
+
+var _backgroundImageData = null;
+
+// <canvas id="loadcanvas" width="800" height="600" oncontextmenu="event.preventDefault()"></canvas>
+
+function DrawProgress(text, current) {
+
+  var bg = document.getElementById('loadcanvas');
+  var ctx = bg.getContext('2d');
+  var rect = bg.getBoundingClientRect();
+
+  var cwidth = rect.width;
+  var cheight = rect.height;
+
+  // for background image
+  if (!_backgroundImageData)
+    _backgroundImageData = ctx.getImageData(0, 0, cwidth, cheight);
+
+  ctx.putImageData(_backgroundImageData, 0, 0);
+
+  ctx.font="30px Arial";
+
+  var progressText = (current * 100) + "%";
+
+  var textSize =  ctx.measureText(progressText);
+
+  ctx.fillText(progressText, cwidth/2 - textSize.width/2, cheight/2 + 15);
+
+  ctx.beginPath();
+  ctx.strokeStyle = '#99CC33';
+  ctx.lineCap = 'square';
+  ctx.closePath();
+  ctx.fill();
+  ctx.lineWidth = 10.0;
+
+  var circ = Math.PI * 2;
+  var quart = Math.PI / 2;
+  ctx.beginPath();
+  ctx.arc(cwidth/2, cheight/2, 70, -(quart), ((circ) * current) - quart, false);
+  ctx.stroke();
+
+}
+
+document.getElementById('canvas').style.display = 'none';
+
+DrawProgress("Downloading", 0.1);
+
+var Module = {
+
+  arguments: ["-x", "800", "-y", "600"],
+
+  preRun:[function() {
+    DrawProgress("Initializing", 0.75);
+  }],
+
+  postRun: [function() {
+    document.getElementById('loadcanvas').style.display = 'none';
+    document.getElementById('canvas').style.display = 'block';
+  }],
+
+  print: (function() {
+    var element = document.getElementById('output');
+    if (element) element.value = ''; // clear browser cache
+    return function(text) {
+      if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
+      // These replacements are necessary if you render to raw HTML
+      //text = text.replace(/&/g, "&amp;");
+      //text = text.replace(/</g, "&lt;");
+      //text = text.replace(/>/g, "&gt;");
+      //text = text.replace('\n', '<br>', 'g');
+      console.log(text);
+      if (element) {
+        element.value += text + "\n";
+        element.scrollTop = element.scrollHeight; // focus on bottom
+      }
+    };
+  })(),
+  printErr: function(text) {
+    if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
+    if (0) { // XXX disabled for safety typeof dump == 'function') {
+      dump(text + '\n'); // fast, straight to the real console
+    } else {
+      console.error(text);
+    }
+  },
+  canvas: (function() {
+    var canvas = document.getElementById('canvas');
+
+    // As a default initial behavior, pop up an alert when webgl context is lost. To make your
+    // application robust, you may want to override this behavior before shipping!
+    // See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
+    canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
+
+    return canvas;
+  })(),
+  setStatus: function(text) {
+
+  },
+  totalDependencies: 0,
+  monitorRunDependencies: function(left) {
+    this.totalDependencies = Math.max(this.totalDependencies, left);
+    Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
+  }
+};
+
+Module.setStatus('Downloading...');
+window.onerror = function(event) {
+  // TODO: do not warn on ok events like simulating an infinite loop or exitStatus
+  Module.setStatus('Exception thrown, see JavaScript console');
+  Module.setStatus = function(text) {
+    if (text) Module.printErr('[post-exception status] ' + text);
+  };
+};

File diff suppressed because it is too large
+ 2 - 186
Data/AtomicEditor/Deployment/Web/AtomicPlayer.html


+ 10 - 9
Data/AtomicEditor/Deployment/Web/AtomicResources_js.template

@@ -24,9 +24,9 @@ Module.expectedDataFileDownloads++;
     var REMOTE_PACKAGE_NAME = typeof Module['locateFile'] === 'function' ?
     var REMOTE_PACKAGE_NAME = typeof Module['locateFile'] === 'function' ?
                               Module['locateFile'](REMOTE_PACKAGE_BASE) :
                               Module['locateFile'](REMOTE_PACKAGE_BASE) :
                               ((Module['filePackagePrefixURL'] || '') + REMOTE_PACKAGE_BASE);
                               ((Module['filePackagePrefixURL'] || '') + REMOTE_PACKAGE_BASE);
-    var REMOTE_PACKAGE_SIZE = 1265134;
+    var REMOTE_PACKAGE_SIZE = $$REMOTE_PACKAGE_SIZE$$;
     var PACKAGE_UUID = 'd832f5b3-9296-453e-be32-e9a18cf5c8c7';
     var PACKAGE_UUID = 'd832f5b3-9296-453e-be32-e9a18cf5c8c7';
-  
+
     function fetchRemotePackage(packageName, packageSize, callback, errback) {
     function fetchRemotePackage(packageName, packageSize, callback, errback) {
       var xhr = new XMLHttpRequest();
       var xhr = new XMLHttpRequest();
       xhr.open('GET', packageName, true);
       xhr.open('GET', packageName, true);
@@ -71,7 +71,7 @@ Module.expectedDataFileDownloads++;
     function handleError(error) {
     function handleError(error) {
       console.error('package error:', error);
       console.error('package error:', error);
     };
     };
-  
+
       var fetched = null, fetchedCallback = null;
       var fetched = null, fetchedCallback = null;
       fetchRemotePackage(REMOTE_PACKAGE_NAME, REMOTE_PACKAGE_SIZE, function(data) {
       fetchRemotePackage(REMOTE_PACKAGE_NAME, REMOTE_PACKAGE_SIZE, function(data) {
         if (fetchedCallback) {
         if (fetchedCallback) {
@@ -81,7 +81,7 @@ Module.expectedDataFileDownloads++;
           fetched = data;
           fetched = data;
         }
         }
       }, handleError);
       }, handleError);
-    
+
   function runWithFS() {
   function runWithFS() {
 
 
 function assert(check, msg) {
 function assert(check, msg) {
@@ -122,14 +122,15 @@ function assert(check, msg) {
         this.requests[this.name] = null;
         this.requests[this.name] = null;
       },
       },
     };
     };
-      $$ATOMIC_RESOURCES_DATA_REQUEST$$
+
+    $$ATOMIC_RESOURCES_DATA_REQUEST$$
 
 
     function processPackageData(arrayBuffer) {
     function processPackageData(arrayBuffer) {
       Module.finishedDataFileDownloads++;
       Module.finishedDataFileDownloads++;
       assert(arrayBuffer, 'Loading data file failed.');
       assert(arrayBuffer, 'Loading data file failed.');
       var byteArray = new Uint8Array(arrayBuffer);
       var byteArray = new Uint8Array(arrayBuffer);
       var curr;
       var curr;
-      
+
       // copy the entire loaded file into a spot in the heap. Files will refer to slices in that. They cannot be freed though.
       // copy the entire loaded file into a spot in the heap. Files will refer to slices in that. They cannot be freed though.
       var ptr = Module['_malloc'](byteArray.length);
       var ptr = Module['_malloc'](byteArray.length);
       Module['HEAPU8'].set(byteArray, ptr);
       Module['HEAPU8'].set(byteArray, ptr);
@@ -139,9 +140,9 @@ function assert(check, msg) {
 
 
     };
     };
     Module['addRunDependency']('datafile_AtomicResources.data');
     Module['addRunDependency']('datafile_AtomicResources.data');
-  
+
     if (!Module.preloadResults) Module.preloadResults = {};
     if (!Module.preloadResults) Module.preloadResults = {};
-  
+
       Module.preloadResults[PACKAGE_NAME] = {fromCache: false};
       Module.preloadResults[PACKAGE_NAME] = {fromCache: false};
       if (fetched) {
       if (fetched) {
         processPackageData(fetched);
         processPackageData(fetched);
@@ -149,7 +150,7 @@ function assert(check, msg) {
       } else {
       } else {
         fetchedCallback = processPackageData;
         fetchedCallback = processPackageData;
       }
       }
-    
+
   }
   }
   if (Module['calledRun']) {
   if (Module['calledRun']) {
     runWithFS();
     runWithFS();

+ 4 - 0
Data/AtomicEditor/Deployment/Web/index.html

@@ -0,0 +1,4 @@
+
+
+
+<iframe src="AtomicPlayer.html" width="800" height="600", marginwidth="0", marginheight="0", frameborder="0", scrolling="no"></iframe>

+ 2 - 2
Source/AtomicPlayer/AtomicPlayer.cpp

@@ -66,8 +66,8 @@ void AtomicPlayer::Setup()
 #elif ATOMIC_PLATFORM_WEB
 #elif ATOMIC_PLATFORM_WEB
     engineParameters_["FullScreen"] = false;
     engineParameters_["FullScreen"] = false;
     engineParameters_["ResourcePaths"] = "AtomicResources";
     engineParameters_["ResourcePaths"] = "AtomicResources";
-    engineParameters_["WindowWidth"] = 1280;
-    engineParameters_["WindowHeight"] = 720;
+    // engineParameters_["WindowWidth"] = 1280;
+    // engineParameters_["WindowHeight"] = 720;
 #elif ATOMIC_PLATFORM_IOS
 #elif ATOMIC_PLATFORM_IOS
     engineParameters_["FullScreen"] = false;
     engineParameters_["FullScreen"] = false;
     engineParameters_["ResourcePaths"] = "AtomicResources";
     engineParameters_["ResourcePaths"] = "AtomicResources";

+ 5 - 2
Source/ToolCore/Build/BuildWeb.cpp

@@ -2,6 +2,7 @@
 // Please see LICENSE.md in repository root for license information
 // Please see LICENSE.md in repository root for license information
 // https://github.com/AtomicGameEngine/AtomicGameEngine
 // https://github.com/AtomicGameEngine/AtomicGameEngine
 
 
+#include <Atomic/Core/StringUtils.h>
 #include <Atomic/IO/FileSystem.h>
 #include <Atomic/IO/FileSystem.h>
 #include <Atomic/IO/File.h>
 #include <Atomic/IO/File.h>
 
 
@@ -30,7 +31,7 @@ void BuildWeb::Initialize()
 
 
     String dataPath = tsystem->GetDataPath();
     String dataPath = tsystem->GetDataPath();
     String projectResources = project->GetResourcePath();
     String projectResources = project->GetResourcePath();
-    String coreDataFolder = dataPath + "Atomic/Resources/CoreData/";
+    String coreDataFolder = dataPath + "CoreData/";
 
 
     AddResourceDir(coreDataFolder);
     AddResourceDir(coreDataFolder);
     AddResourceDir(projectResources);
     AddResourceDir(projectResources);
@@ -51,7 +52,7 @@ void BuildWeb::Build(const String& buildPath)
 
 
     String dataPath = tsystem->GetDataPath();
     String dataPath = tsystem->GetDataPath();
 
 
-    String buildSourceDir  = dataPath + "Atomic/Deployment/Web";
+    String buildSourceDir  = dataPath + "Deployment/Web";
 
 
     fileSystem->CreateDir(buildPath_);
     fileSystem->CreateDir(buildPath_);
 
 
@@ -59,6 +60,7 @@ void BuildWeb::Build(const String& buildPath)
     GenerateResourcePackage(resourcePackagePath);
     GenerateResourcePackage(resourcePackagePath);
 
 
     fileSystem->Copy(buildSourceDir + "/AtomicPlayer.html", buildPath_ + "/AtomicPlayer.html");
     fileSystem->Copy(buildSourceDir + "/AtomicPlayer.html", buildPath_ + "/AtomicPlayer.html");
+    fileSystem->Copy(buildSourceDir + "/AtomicPlayer.html.mem", buildPath_ + "/AtomicPlayer.html.mem");
     fileSystem->Copy(buildSourceDir + "/AtomicPlayer.js", buildPath_ + "/AtomicPlayer.js");
     fileSystem->Copy(buildSourceDir + "/AtomicPlayer.js", buildPath_ + "/AtomicPlayer.js");
 
 
     File file(context_, buildSourceDir + "/AtomicResources_js.template", FILE_READ);
     File file(context_, buildSourceDir + "/AtomicResources_js.template", FILE_READ);
@@ -79,6 +81,7 @@ void BuildWeb::Build(const String& buildPath)
     String request;
     String request;
     request.AppendWithFormat("new DataRequest(0, %i, 0, 0).open('GET', '/AtomicResources.pak');", rsize);
     request.AppendWithFormat("new DataRequest(0, %i, 0, 0).open('GET', '/AtomicResources.pak');", rsize);
 
 
+    resourcejs.Replace("$$REMOTE_PACKAGE_SIZE$$", ToString("%i", rsize));
     resourcejs.Replace("$$ATOMIC_RESOURCES_DATA_REQUEST$$", request);
     resourcejs.Replace("$$ATOMIC_RESOURCES_DATA_REQUEST$$", request);
 
 
     file.Open(buildPath_ + "/AtomicResources.js", FILE_WRITE);
     file.Open(buildPath_ + "/AtomicResources.js", FILE_WRITE);

+ 23 - 13
Source/ToolCore/License/LicenseSystem.cpp

@@ -386,6 +386,9 @@ void LicenseSystem::HandleVerification(StringHash eventType, VariantMap& eventDa
 
 
     CurlRequest* request = (CurlRequest*) (eventData[CurlComplete::P_CURLREQUEST].GetPtr());
     CurlRequest* request = (CurlRequest*) (eventData[CurlComplete::P_CURLREQUEST].GetPtr());
 
 
+    bool licenseError = false;
+    bool resetLicense = false;
+
     if (serverVerification_.NotNull())
     if (serverVerification_.NotNull())
     {
     {
         assert(request == serverVerification_);
         assert(request == serverVerification_);
@@ -399,34 +402,29 @@ void LicenseSystem::HandleVerification(StringHash eventType, VariantMap& eventDa
             LicenseParse parse;
             LicenseParse parse;
             int code = ParseResponse(serverVerification_->GetResponse(), parse);
             int code = ParseResponse(serverVerification_->GetResponse(), parse);
 
 
-            // Not activated
             if (code == 4)
             if (code == 4)
             {
             {
-
+                // not activated
+                resetLicense = true;
+                licenseError = true;
             }
             }
             else if (code == 2)
             else if (code == 2)
             {
             {
                 // something is wrong with the key
                 // something is wrong with the key
-                LOGERRORF("Error with product key");
-
-                RemoveLicense();
-                ResetLicense();
-                /*
-                UIModalOps* ops = GetSubsystem<UIModalOps>();
-                ops->Hide();
-                ops->ShowActivation();
-                */
+                resetLicense = true;
+                licenseError = true;
 
 
             }
             }
             else if (code == 3)
             else if (code == 3)
             {
             {
                 // something is wrong on the activation server
                 // something is wrong on the activation server
-                key_ = "";
+                licenseError = true;
             }
             }
             else if (code == 1)
             else if (code == 1)
             {
             {
                 // exceeded code, should not happen here as we aren't activating
                 // exceeded code, should not happen here as we aren't activating
-                key_ = "";
+                resetLicense = true;
+                licenseError = true;
             }
             }
             else if (code == 0)
             else if (code == 0)
             {
             {
@@ -481,6 +479,18 @@ void LicenseSystem::HandleVerification(StringHash eventType, VariantMap& eventDa
         serverVerification_ = 0;
         serverVerification_ = 0;
     }
     }
 
 
+    if (resetLicense)
+    {
+        RemoveLicense();
+        ResetLicense();
+    }
+
+    if (licenseError)
+    {
+        LOGINFO("There was an issue with the atomic-cli activation.  Please reactivate or contact [email protected] if this problem persists");
+        SendEvent(E_LICENSE_ERROR);
+    }
+
 }
 }
 
 
 void LicenseSystem::HandleDeactivate(StringHash eventType, VariantMap& eventData)
 void LicenseSystem::HandleDeactivate(StringHash eventType, VariantMap& eventData)

Some files were not shown because too many files changed in this diff