@@ -78,6 +78,11 @@ var faviconRE = /^favicon\.(jpg|png|gif)$/i;
78
78
* @property {HappyFunTimes~Info } happyFunTimes
79
79
*/
80
80
81
+ /**
82
+ * @typedef {Object } HFT~TemplateInfo
83
+ * @property {string } name name of template
84
+ */
85
+
81
86
/**
82
87
* @typedef {Object } HFT~RuntimeInfo
83
88
* @property {NPM~Info } info
@@ -90,8 +95,8 @@ var faviconRE = /^favicon\.(jpg|png|gif)$/i;
90
95
* @property {string } gameExecutable the baseDir relative path
91
96
* to the game's executable if it's a native
92
97
* executable. Like a Unity game for example.
93
- * @property {string? } screenshotUrl
94
- * @property {string? } gameExecutable (not used?)
98
+ * @property {string } [ screenshotUrl]
99
+ * @property {string } [ gameExecutable] (not used?)
95
100
* @property {string } htmlPath Path to html files (see rootPath)
96
101
* @property {string } rootPath path to all files.
97
102
* Originally htmlPath and rootPath where the same but
@@ -100,6 +105,10 @@ var faviconRE = /^favicon\.(jpg|png|gif)$/i;
100
105
* @property {string } packagePath. Path to package.json
101
106
* Originally was <rootPath>/package.json but now can also be
102
107
* <rootPath>/Assets/WebPlayerTemplates/HappyFunTimes/package.json
108
+ * @property {Object.<string, boolean } templateUrls which urls need substitutions.
109
+ * This is poorly named. It means treat this URL like template by calling string.replaceParams
110
+ * on it.
111
+ * @property {Object.<string>
103
112
*
104
113
* @property {string[] } files added in addGamesByList. It's used
105
114
* by uninstall
@@ -536,10 +545,10 @@ GameInfo.prototype.parseGameInfo = function(contents, packagePath, rootPath) {
536
545
537
546
var jsType = "hft-late" ;
538
547
if ( features . useScriptTag ) {
539
- game . afterScripts . push ( createScriptTag ( { src : "scripts/game .js" } ) ) ;
540
- controller . afterScripts . push ( createScriptTag ( { src : "scripts/controller .js" , type : jsType } ) ) ;
548
+ game . afterScripts . push ( createScriptTag ( { src : "scripts/%(filename)s .js" } ) ) ;
549
+ controller . afterScripts . push ( createScriptTag ( { src : "scripts/%(filename)s .js" , type : jsType } ) ) ;
541
550
} else {
542
- game . afterScripts . push ( createScriptTag ( { src : "/3rdparty/require.js" , "data-main" : "scripts/game .js" } ) ) ;
551
+ game . afterScripts . push ( createScriptTag ( { src : "/3rdparty/require.js" , "data-main" : "scripts/%(filename)s .js" } ) ) ;
543
552
game . afterScripts . push ( createScriptTag ( { } , [
544
553
"requirejs.config({" ,
545
554
" paths: {" ,
@@ -549,7 +558,7 @@ GameInfo.prototype.parseGameInfo = function(contents, packagePath, rootPath) {
549
558
" }," ,
550
559
"});" ,
551
560
] . join ( "\n" ) ) ) ;
552
- controller . afterScripts . push ( createScriptTag ( { src : "/3rdparty/require.js" , "data-main" : "scripts/controller .js" , type : jsType } ) ) ;
561
+ controller . afterScripts . push ( createScriptTag ( { src : "/3rdparty/require.js" , "data-main" : "scripts/%(filename)s .js" , type : jsType } ) ) ;
553
562
controller . afterScripts . push ( createScriptTag ( { type : jsType } , [
554
563
"requirejs.config({" ,
555
564
" paths: {" ,
@@ -606,6 +615,18 @@ GameInfo.prototype.parseGameInfo = function(contents, packagePath, rootPath) {
606
615
runtimeInfo . templateUrls [ fullUrl ] = true ;
607
616
} ) ;
608
617
618
+ runtimeInfo . templateFileOptions = { } ;
619
+ if ( hftInfo . templateFileOptions && ! semver . gte ( hftInfo . apiVersion , "1.15.0" ) ) {
620
+ console . error ( "error: package.json apiVersion must be 1.15.0 or greater to use templateFileOptions" ) ;
621
+ return ;
622
+ }
623
+ ( hftInfo . templateFileOptions || [ ] ) . forEach ( function ( options ) {
624
+ var info = {
625
+ urlInfo : options ,
626
+ } ;
627
+ runtimeInfo . templateFileOptions [ options . filename ] = info ;
628
+ } ) ;
629
+
609
630
} catch ( e ) {
610
631
console . error ( "ERROR: Parsing " + packagePath ) ;
611
632
throw e ;
0 commit comments