Commit a760134ffdd81f00ddb2a54450bd60d109faeee4
1 parent
ccb62554
Exists in
master
Adds support to Safari
Showing
6 changed files
with
433 additions
and
385 deletions
Show diff stats
.gitignore
VLibrasWeb/Player/Release/Setup.js
... | ... | @@ -1,374 +0,0 @@ |
1 | -//====================== Player Configuration =========================== | |
2 | -// connect to canvas | |
3 | -var Module = { | |
4 | - TOTAL_MEMORY: 314572800, | |
5 | - filePackagePrefixURL: VLibrasPlayer.getPath() + '/Player/Release/', | |
6 | - memoryInitializerPrefixURL: VLibrasPlayer.getPath() + '/Player/Release/', | |
7 | - preRun: [], | |
8 | - postRun: [], | |
9 | - print: (function() { | |
10 | - return function(text) { | |
11 | - console.log (text); | |
12 | - }; | |
13 | - })(), | |
14 | - printErr: function(text) { | |
15 | - console.error (text); | |
16 | - }, | |
17 | - canvas: VLibrasPlayer.getCanvasElement(), | |
18 | - progress: null, | |
19 | - setStatus: function(text) { | |
20 | - if (this.progress == null) | |
21 | - { | |
22 | - if (typeof UnityProgress != 'function') | |
23 | - return; | |
24 | - this.progress = new UnityProgress (canvas); | |
25 | - } | |
26 | - if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' }; | |
27 | - if (text === Module.setStatus.text) return; | |
28 | - this.progress.SetMessage (text); | |
29 | - var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/); | |
30 | - if (m) | |
31 | - this.progress.SetProgress (parseInt(m[2])/parseInt(m[4])); | |
32 | - if (text === "") | |
33 | - this.progress.Clear() | |
34 | - }, | |
35 | - totalDependencies: 0, | |
36 | - monitorRunDependencies: function(left) { | |
37 | - this.totalDependencies = Math.max(this.totalDependencies, left); | |
38 | - Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.'); | |
39 | - } | |
40 | -}; | |
41 | -Module.setStatus('Downloading (0.0/1)'); | |
42 | - | |
43 | -//============ FileLoader ===================== | |
44 | - | |
45 | - | |
46 | - | |
47 | -var Module; | |
48 | - | |
49 | -if (typeof Module === 'undefined') Module = eval('(function() { try { return Module || {} } catch(e) { return {} } })()'); | |
50 | - | |
51 | -if (!Module.expectedDataFileDownloads) { | |
52 | - Module.expectedDataFileDownloads = 0; | |
53 | - Module.finishedDataFileDownloads = 0; | |
54 | -} | |
55 | -Module.expectedDataFileDownloads++; | |
56 | -(function() { | |
57 | - var loadPackage = function(metadata) { | |
58 | - | |
59 | - var PACKAGE_PATH; | |
60 | - if (typeof window === 'object') { | |
61 | - PACKAGE_PATH = window['encodeURIComponent'](window.location.pathname.toString().substring(0, window.location.pathname.toString().lastIndexOf('/')) + '/'); | |
62 | - } else if (typeof location !== 'undefined') { | |
63 | - // worker | |
64 | - PACKAGE_PATH = encodeURIComponent(location.pathname.toString().substring(0, location.pathname.toString().lastIndexOf('/')) + '/'); | |
65 | - } else { | |
66 | - throw 'using preloaded data can only be done on a web page or in a web worker'; | |
67 | - } | |
68 | - var PACKAGE_NAME = 'rnp_webgl_DC_ON_AA0x_VsyncOFF.data'; | |
69 | - var REMOTE_PACKAGE_BASE = 'rnp_webgl_DC_ON_AA0x_VsyncOFF.data'; | |
70 | - if (typeof Module['locateFilePackage'] === 'function' && !Module['locateFile']) { | |
71 | - Module['locateFile'] = Module['locateFilePackage']; | |
72 | - Module.printErr('warning: you defined Module.locateFilePackage, that has been renamed to Module.locateFile (using your locateFilePackage for now)'); | |
73 | - } | |
74 | - var REMOTE_PACKAGE_NAME = typeof Module['locateFile'] === 'function' ? | |
75 | - Module['locateFile'](REMOTE_PACKAGE_BASE) : | |
76 | - ((Module['filePackagePrefixURL'] || '') + REMOTE_PACKAGE_BASE); | |
77 | - | |
78 | - var REMOTE_PACKAGE_SIZE = 44246212; | |
79 | - var PACKAGE_UUID = '01d51089-f5b6-48dc-a9e7-50b8522039d5'; | |
80 | - | |
81 | - function fetchRemotePackage(packageName, packageSize, callback, errback) { | |
82 | - var xhr = new XMLHttpRequest(); | |
83 | - xhr.open('GET', packageName, true); | |
84 | - xhr.responseType = 'arraybuffer'; | |
85 | - xhr.onprogress = function(event) { | |
86 | - var url = packageName; | |
87 | - var size = packageSize; | |
88 | - if (event.total) size = event.total; | |
89 | - if (event.loaded) { | |
90 | - if (!xhr.addedTotal) { | |
91 | - xhr.addedTotal = true; | |
92 | - if (!Module.dataFileDownloads) Module.dataFileDownloads = {}; | |
93 | - Module.dataFileDownloads[url] = { | |
94 | - loaded: event.loaded, | |
95 | - total: size | |
96 | - }; | |
97 | - } else { | |
98 | - Module.dataFileDownloads[url].loaded = event.loaded; | |
99 | - } | |
100 | - var total = 0; | |
101 | - var loaded = 0; | |
102 | - var num = 0; | |
103 | - for (var download in Module.dataFileDownloads) { | |
104 | - var data = Module.dataFileDownloads[download]; | |
105 | - total += data.total; | |
106 | - loaded += data.loaded; | |
107 | - num++; | |
108 | - } | |
109 | - total = Math.ceil(total * Module.expectedDataFileDownloads/num); | |
110 | - if (Module['setStatus']) Module['setStatus']('Downloading data... (' + loaded + '/' + total + ')'); | |
111 | - } else if (!Module.dataFileDownloads) { | |
112 | - if (Module['setStatus']) Module['setStatus']('Downloading data...'); | |
113 | - } | |
114 | - }; | |
115 | - xhr.onload = function(event) { | |
116 | - var packageData = xhr.response; | |
117 | - callback(packageData); | |
118 | - }; | |
119 | - xhr.send(null); | |
120 | - }; | |
121 | - | |
122 | - function handleError(error) { | |
123 | - console.error('package error:', error); | |
124 | - }; | |
125 | - | |
126 | - function runWithFS() { | |
127 | - | |
128 | - function assert(check, msg) { | |
129 | - if (!check) throw msg + new Error().stack; | |
130 | - } | |
131 | -Module['FS_createPath']('/', 'Il2CppData', true, true); | |
132 | -Module['FS_createPath']('/Il2CppData', 'Metadata', true, true); | |
133 | -Module['FS_createPath']('/', 'Resources', true, true); | |
134 | - | |
135 | - function DataRequest(start, end, crunched, audio) { | |
136 | - this.start = start; | |
137 | - this.end = end; | |
138 | - this.crunched = crunched; | |
139 | - this.audio = audio; | |
140 | - } | |
141 | - DataRequest.prototype = { | |
142 | - requests: {}, | |
143 | - open: function(mode, name) { | |
144 | - this.name = name; | |
145 | - this.requests[name] = this; | |
146 | - Module['addRunDependency']('fp ' + this.name); | |
147 | - }, | |
148 | - send: function() {}, | |
149 | - onload: function() { | |
150 | - var byteArray = this.byteArray.subarray(this.start, this.end); | |
151 | - | |
152 | - this.finish(byteArray); | |
153 | - | |
154 | - }, | |
155 | - finish: function(byteArray) { | |
156 | - var that = this; | |
157 | - Module['FS_createPreloadedFile'](this.name, null, byteArray, true, true, function() { | |
158 | - Module['removeRunDependency']('fp ' + that.name); | |
159 | - }, function() { | |
160 | - if (that.audio) { | |
161 | - Module['removeRunDependency']('fp ' + that.name); // workaround for chromium bug 124926 (still no audio with this, but at least we don't hang) | |
162 | - } else { | |
163 | - Module.printErr('Preloading file ' + that.name + ' failed'); | |
164 | - } | |
165 | - }, false, true); // canOwn this data in the filesystem, it is a slide into the heap that will never change | |
166 | - this.requests[this.name] = null; | |
167 | - }, | |
168 | - }; | |
169 | - | |
170 | - new DataRequest(0, 50564, 0, 0).open('GET', '/mainData'); | |
171 | - new DataRequest(50564, 50732, 0, 0).open('GET', '/methods_pointedto_by_uievents.xml'); | |
172 | - new DataRequest(50732, 39552116, 0, 0).open('GET', '/sharedassets0.assets'); | |
173 | - new DataRequest(39552116, 41855056, 0, 0).open('GET', '/Il2CppData/Metadata/global-metadata.dat'); | |
174 | - new DataRequest(41855056, 43742480, 0, 0).open('GET', '/Resources/unity_default_resources'); | |
175 | - new DataRequest(43742480, 44246212, 0, 0).open('GET', '/Resources/unity_builtin_extra'); | |
176 | - | |
177 | - var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB; | |
178 | - var IDB_RO = "readonly"; | |
179 | - var IDB_RW = "readwrite"; | |
180 | - var DB_NAME = 'EM_PRELOAD_CACHE'; | |
181 | - var DB_VERSION = 1; | |
182 | - var METADATA_STORE_NAME = 'METADATA'; | |
183 | - var PACKAGE_STORE_NAME = 'PACKAGES'; | |
184 | - function openDatabase(callback, errback) { | |
185 | - try { | |
186 | - var openRequest = indexedDB.open(DB_NAME, DB_VERSION); | |
187 | - } catch (e) { | |
188 | - return errback(e); | |
189 | - } | |
190 | - openRequest.onupgradeneeded = function(event) { | |
191 | - var db = event.target.result; | |
192 | - | |
193 | - if(db.objectStoreNames.contains(PACKAGE_STORE_NAME)) { | |
194 | - db.deleteObjectStore(PACKAGE_STORE_NAME); | |
195 | - } | |
196 | - var packages = db.createObjectStore(PACKAGE_STORE_NAME); | |
197 | - | |
198 | - if(db.objectStoreNames.contains(METADATA_STORE_NAME)) { | |
199 | - db.deleteObjectStore(METADATA_STORE_NAME); | |
200 | - } | |
201 | - var metadata = db.createObjectStore(METADATA_STORE_NAME); | |
202 | - }; | |
203 | - openRequest.onsuccess = function(event) { | |
204 | - var db = event.target.result; | |
205 | - callback(db); | |
206 | - }; | |
207 | - openRequest.onerror = function(error) { | |
208 | - errback(error); | |
209 | - }; | |
210 | - }; | |
211 | - | |
212 | - /* Check if there's a cached package, and if so whether it's the latest available */ | |
213 | - function checkCachedPackage(db, packageName, callback, errback) { | |
214 | - var transaction = db.transaction([METADATA_STORE_NAME], IDB_RO); | |
215 | - var metadata = transaction.objectStore(METADATA_STORE_NAME); | |
216 | - | |
217 | - var getRequest = metadata.get(packageName); | |
218 | - getRequest.onsuccess = function(event) { | |
219 | - var result = event.target.result; | |
220 | - if (!result) { | |
221 | - return callback(false); | |
222 | - } else { | |
223 | - return callback(PACKAGE_UUID === result.uuid); | |
224 | - } | |
225 | - }; | |
226 | - getRequest.onerror = function(error) { | |
227 | - errback(error); | |
228 | - }; | |
229 | - }; | |
230 | - | |
231 | - function fetchCachedPackage(db, packageName, callback, errback) { | |
232 | - var transaction = db.transaction([PACKAGE_STORE_NAME], IDB_RO); | |
233 | - var packages = transaction.objectStore(PACKAGE_STORE_NAME); | |
234 | - | |
235 | - var getRequest = packages.get(packageName); | |
236 | - getRequest.onsuccess = function(event) { | |
237 | - var result = event.target.result; | |
238 | - callback(result); | |
239 | - }; | |
240 | - getRequest.onerror = function(error) { | |
241 | - errback(error); | |
242 | - }; | |
243 | - }; | |
244 | - | |
245 | - function cacheRemotePackage(db, packageName, packageData, packageMeta, callback, errback) { | |
246 | - var transaction = db.transaction([PACKAGE_STORE_NAME, METADATA_STORE_NAME], IDB_RW); | |
247 | - var packages = transaction.objectStore(PACKAGE_STORE_NAME); | |
248 | - var metadata = transaction.objectStore(METADATA_STORE_NAME); | |
249 | - | |
250 | - var putPackageRequest = packages.put(packageData, packageName); | |
251 | - putPackageRequest.onsuccess = function(event) { | |
252 | - var putMetadataRequest = metadata.put(packageMeta, packageName); | |
253 | - putMetadataRequest.onsuccess = function(event) { | |
254 | - callback(packageData); | |
255 | - }; | |
256 | - putMetadataRequest.onerror = function(error) { | |
257 | - errback(error); | |
258 | - }; | |
259 | - }; | |
260 | - putPackageRequest.onerror = function(error) { | |
261 | - errback(error); | |
262 | - }; | |
263 | - }; | |
264 | - | |
265 | - function processPackageData(arrayBuffer) { | |
266 | - Module.finishedDataFileDownloads++; | |
267 | - assert(arrayBuffer, 'Loading data file failed.'); | |
268 | - var byteArray = new Uint8Array(arrayBuffer); | |
269 | - var curr; | |
270 | - | |
271 | - // Reuse the bytearray from the XHR as the source for file reads. | |
272 | - DataRequest.prototype.byteArray = byteArray; | |
273 | - DataRequest.prototype.requests["/mainData"].onload(); | |
274 | - DataRequest.prototype.requests["/methods_pointedto_by_uievents.xml"].onload(); | |
275 | - DataRequest.prototype.requests["/sharedassets0.assets"].onload(); | |
276 | - DataRequest.prototype.requests["/Il2CppData/Metadata/global-metadata.dat"].onload(); | |
277 | - DataRequest.prototype.requests["/Resources/unity_default_resources"].onload(); | |
278 | - DataRequest.prototype.requests["/Resources/unity_builtin_extra"].onload(); | |
279 | - Module['removeRunDependency']('datafile_rnp_webgl_DC_ON_AA0x_VsyncOFF.data'); | |
280 | - | |
281 | - }; | |
282 | - Module['addRunDependency']('datafile_rnp_webgl_DC_ON_AA0x_VsyncOFF.data'); | |
283 | - | |
284 | - if (!Module.preloadResults) Module.preloadResults = {}; | |
285 | - | |
286 | - function preloadFallback(error) { | |
287 | - console.error(error); | |
288 | - console.error('falling back to default preload behavior'); | |
289 | - fetchRemotePackage(REMOTE_PACKAGE_NAME, REMOTE_PACKAGE_SIZE, processPackageData, handleError); | |
290 | - }; | |
291 | - | |
292 | - openDatabase( | |
293 | - function(db) { | |
294 | - checkCachedPackage(db, PACKAGE_PATH + PACKAGE_NAME, | |
295 | - function(useCached) { | |
296 | - Module.preloadResults[PACKAGE_NAME] = {fromCache: useCached}; | |
297 | - if (useCached) { | |
298 | - console.info('loading ' + PACKAGE_NAME + ' from cache'); | |
299 | - fetchCachedPackage(db, PACKAGE_PATH + PACKAGE_NAME, processPackageData, preloadFallback); | |
300 | - } else { | |
301 | - console.info('loading ' + PACKAGE_NAME + ' from remote'); | |
302 | - fetchRemotePackage(REMOTE_PACKAGE_NAME, REMOTE_PACKAGE_SIZE, | |
303 | - function(packageData) { | |
304 | - cacheRemotePackage(db, PACKAGE_PATH + PACKAGE_NAME, packageData, {uuid:PACKAGE_UUID}, processPackageData, | |
305 | - function(error) { | |
306 | - console.error(error); | |
307 | - processPackageData(packageData); | |
308 | - }); | |
309 | - } | |
310 | - , preloadFallback); | |
311 | - } | |
312 | - } | |
313 | - , preloadFallback); | |
314 | - } | |
315 | - , preloadFallback); | |
316 | - | |
317 | - if (Module['setStatus']) Module['setStatus']('Downloading...'); | |
318 | - | |
319 | - } | |
320 | - if (Module['calledRun']) { | |
321 | - runWithFS(); | |
322 | - } else { | |
323 | - if (!Module['preRun']) Module['preRun'] = []; | |
324 | - Module["preRun"].push(runWithFS); // FS is not initialized yet, wait for it | |
325 | - } | |
326 | - | |
327 | - } | |
328 | - loadPackage(); | |
329 | - | |
330 | -})(); | |
331 | - | |
332 | - | |
333 | - | |
334 | -//============== Load ======================== | |
335 | - | |
336 | -if (!(!Math.fround)) { | |
337 | - var script = document.createElement('script'); | |
338 | - script.src = VLibrasPlayer.getPath() + '/Player/Release/rnp_webgl_DC_ON_AA0x_VsyncOFF.js'; | |
339 | - document.body.appendChild(script); | |
340 | -} else { | |
341 | - var codeXHR = new XMLHttpRequest(); | |
342 | - codeXHR.open('GET', VLibrasPlayer.getPath() + '/Player/Release/rnp_webgl_DC_ON_AA0x_VsyncOFF.js', true); | |
343 | - codeXHR.onload = function() { | |
344 | - var code = codeXHR.responseText; | |
345 | - if (!Math.fround) { | |
346 | -try { | |
347 | - console.log('optimizing out Math.fround calls'); | |
348 | - var m = /var ([^=]+)=global\.Math\.fround;/.exec(code); | |
349 | - var minified = m[1]; | |
350 | - if (!minified) throw 'fail'; | |
351 | - var startAsm = code.indexOf('// EMSCRIPTEN_START_FUNCS'); | |
352 | - var endAsm = code.indexOf('// EMSCRIPTEN_END_FUNCS'); | |
353 | - var asm = code.substring(startAsm, endAsm); | |
354 | - do { | |
355 | - var moar = false; // we need to re-do, as x(x( will not be fixed | |
356 | - asm = asm.replace(new RegExp('[^a-zA-Z0-9\\$\\_]' + minified + '\\(', 'g'), function(s) { moar = true; return s[0] + '(' }); | |
357 | - } while (moar); | |
358 | - code = code.substring(0, startAsm) + asm + code.substring(endAsm); | |
359 | - code = code.replace("'use asm'", "'almost asm'"); | |
360 | -} catch(e) { console.log('failed to optimize out Math.fround calls ' + e) } | |
361 | - } | |
362 | - | |
363 | - var blob = new Blob([code], { type: 'text/javascript' }); | |
364 | - codeXHR = null; | |
365 | - var src = URL.createObjectURL(blob); | |
366 | - var script = document.createElement('script'); | |
367 | - script.src = URL.createObjectURL(blob); | |
368 | - script.onload = function() { | |
369 | - URL.revokeObjectURL(script.src); | |
370 | - }; | |
371 | - document.body.appendChild(script); | |
372 | - }; | |
373 | - codeXHR.send(null); | |
374 | -} | |
375 | 0 | \ No newline at end of file |
... | ... | @@ -0,0 +1,364 @@ |
1 | +//====================== Player Configuration =========================== | |
2 | +// connect to canvas | |
3 | +var Module = { | |
4 | + TOTAL_MEMORY: 314572800, | |
5 | + filePackagePrefixURL: VLibrasPlayer.getPath() + '/Player/WebGL/', | |
6 | + memoryInitializerPrefixURL: VLibrasPlayer.getPath() + '/Player/WebGL/', | |
7 | + preRun: [], | |
8 | + postRun: [], | |
9 | + print: (function() { | |
10 | + return function(text) { | |
11 | + console.log (text); | |
12 | + }; | |
13 | + })(), | |
14 | + printErr: function(text) { | |
15 | + console.error (text); | |
16 | + }, | |
17 | + canvas: VLibrasPlayer.getCanvasElement(), | |
18 | + progress: null, | |
19 | + setStatus: function(text) { | |
20 | + if (this.progress == null) | |
21 | + { | |
22 | + if (typeof UnityProgress != 'function') | |
23 | + return; | |
24 | + this.progress = new UnityProgress (canvas); | |
25 | + } | |
26 | + if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' }; | |
27 | + if (text === Module.setStatus.text) return; | |
28 | + this.progress.SetMessage (text); | |
29 | + var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/); | |
30 | + if (m) | |
31 | + this.progress.SetProgress (parseInt(m[2])/parseInt(m[4])); | |
32 | + if (text === "") | |
33 | + this.progress.Clear() | |
34 | + }, | |
35 | + totalDependencies: 0, | |
36 | + monitorRunDependencies: function(left) { | |
37 | + this.totalDependencies = Math.max(this.totalDependencies, left); | |
38 | + Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.'); | |
39 | + } | |
40 | +}; | |
41 | +Module.setStatus('Downloading (0.0/1)'); | |
42 | + | |
43 | +//============ FileLoader ===================== | |
44 | +if (!Module.expectedDataFileDownloads) { | |
45 | + Module.expectedDataFileDownloads = 0; | |
46 | + Module.finishedDataFileDownloads = 0; | |
47 | +} | |
48 | +Module.expectedDataFileDownloads++; | |
49 | +(function() { | |
50 | + var loadPackage = function(metadata) { | |
51 | + | |
52 | + var PACKAGE_PATH; | |
53 | + if (typeof window === 'object') { | |
54 | + PACKAGE_PATH = window['encodeURIComponent'](window.location.pathname.toString().substring(0, window.location.pathname.toString().lastIndexOf('/')) + '/'); | |
55 | + } else if (typeof location !== 'undefined') { | |
56 | + // worker | |
57 | + PACKAGE_PATH = encodeURIComponent(location.pathname.toString().substring(0, location.pathname.toString().lastIndexOf('/')) + '/'); | |
58 | + } else { | |
59 | + throw 'using preloaded data can only be done on a web page or in a web worker'; | |
60 | + } | |
61 | + var PACKAGE_NAME = 'rnp_webgl_DC_ON_AA0x_VsyncOFF.data'; | |
62 | + var REMOTE_PACKAGE_BASE = 'rnp_webgl_DC_ON_AA0x_VsyncOFF.data'; | |
63 | + if (typeof Module['locateFilePackage'] === 'function' && !Module['locateFile']) { | |
64 | + Module['locateFile'] = Module['locateFilePackage']; | |
65 | + Module.printErr('warning: you defined Module.locateFilePackage, that has been renamed to Module.locateFile (using your locateFilePackage for now)'); | |
66 | + } | |
67 | + var REMOTE_PACKAGE_NAME = typeof Module['locateFile'] === 'function' ? | |
68 | + Module['locateFile'](REMOTE_PACKAGE_BASE) : | |
69 | + ((Module['filePackagePrefixURL'] || '') + REMOTE_PACKAGE_BASE); | |
70 | + | |
71 | + var REMOTE_PACKAGE_SIZE = 44246208; | |
72 | + var PACKAGE_UUID = '98f2a60c-c33d-4976-b642-e132a50bd522'; | |
73 | + | |
74 | + function fetchRemotePackage(packageName, packageSize, callback, errback) { | |
75 | + var xhr = new XMLHttpRequest(); | |
76 | + xhr.open('GET', packageName, true); | |
77 | + xhr.responseType = 'arraybuffer'; | |
78 | + xhr.onprogress = function(event) { | |
79 | + var url = packageName; | |
80 | + var size = packageSize; | |
81 | + if (event.total) size = event.total; | |
82 | + if (event.loaded) { | |
83 | + if (!xhr.addedTotal) { | |
84 | + xhr.addedTotal = true; | |
85 | + if (!Module.dataFileDownloads) Module.dataFileDownloads = {}; | |
86 | + Module.dataFileDownloads[url] = { | |
87 | + loaded: event.loaded, | |
88 | + total: size | |
89 | + }; | |
90 | + } else { | |
91 | + Module.dataFileDownloads[url].loaded = event.loaded; | |
92 | + } | |
93 | + var total = 0; | |
94 | + var loaded = 0; | |
95 | + var num = 0; | |
96 | + for (var download in Module.dataFileDownloads) { | |
97 | + var data = Module.dataFileDownloads[download]; | |
98 | + total += data.total; | |
99 | + loaded += data.loaded; | |
100 | + num++; | |
101 | + } | |
102 | + total = Math.ceil(total * Module.expectedDataFileDownloads/num); | |
103 | + if (Module['setStatus']) Module['setStatus']('Downloading data... (' + loaded + '/' + total + ')'); | |
104 | + } else if (!Module.dataFileDownloads) { | |
105 | + if (Module['setStatus']) Module['setStatus']('Downloading data...'); | |
106 | + } | |
107 | + }; | |
108 | + xhr.onload = function(event) { | |
109 | + var packageData = xhr.response; | |
110 | + callback(packageData); | |
111 | + }; | |
112 | + xhr.send(null); | |
113 | + }; | |
114 | + | |
115 | + function handleError(error) { | |
116 | + console.error('package error:', error); | |
117 | + }; | |
118 | + | |
119 | + function runWithFS() { | |
120 | + | |
121 | + function assert(check, msg) { | |
122 | + if (!check) throw msg + new Error().stack; | |
123 | + } | |
124 | +Module['FS_createPath']('/', 'Il2CppData', true, true); | |
125 | +Module['FS_createPath']('/Il2CppData', 'Metadata', true, true); | |
126 | +Module['FS_createPath']('/', 'Resources', true, true); | |
127 | + | |
128 | + function DataRequest(start, end, crunched, audio) { | |
129 | + this.start = start; | |
130 | + this.end = end; | |
131 | + this.crunched = crunched; | |
132 | + this.audio = audio; | |
133 | + } | |
134 | + DataRequest.prototype = { | |
135 | + requests: {}, | |
136 | + open: function(mode, name) { | |
137 | + this.name = name; | |
138 | + this.requests[name] = this; | |
139 | + Module['addRunDependency']('fp ' + this.name); | |
140 | + }, | |
141 | + send: function() {}, | |
142 | + onload: function() { | |
143 | + var byteArray = this.byteArray.subarray(this.start, this.end); | |
144 | + | |
145 | + this.finish(byteArray); | |
146 | + | |
147 | + }, | |
148 | + finish: function(byteArray) { | |
149 | + var that = this; | |
150 | + Module['FS_createPreloadedFile'](this.name, null, byteArray, true, true, function() { | |
151 | + Module['removeRunDependency']('fp ' + that.name); | |
152 | + }, function() { | |
153 | + if (that.audio) { | |
154 | + Module['removeRunDependency']('fp ' + that.name); // workaround for chromium bug 124926 (still no audio with this, but at least we don't hang) | |
155 | + } else { | |
156 | + Module.printErr('Preloading file ' + that.name + ' failed'); | |
157 | + } | |
158 | + }, false, true); // canOwn this data in the filesystem, it is a slide into the heap that will never change | |
159 | + this.requests[this.name] = null; | |
160 | + }, | |
161 | + }; | |
162 | + | |
163 | + new DataRequest(0, 50564, 0, 0).open('GET', '/mainData'); | |
164 | + new DataRequest(50564, 50732, 0, 0).open('GET', '/methods_pointedto_by_uievents.xml'); | |
165 | + new DataRequest(50732, 39552116, 0, 0).open('GET', '/sharedassets0.assets'); | |
166 | + new DataRequest(39552116, 41855052, 0, 0).open('GET', '/Il2CppData/Metadata/global-metadata.dat'); | |
167 | + new DataRequest(41855052, 43742476, 0, 0).open('GET', '/Resources/unity_default_resources'); | |
168 | + new DataRequest(43742476, 44246208, 0, 0).open('GET', '/Resources/unity_builtin_extra'); | |
169 | + | |
170 | + var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB; | |
171 | + var IDB_RO = "readonly"; | |
172 | + var IDB_RW = "readwrite"; | |
173 | + var DB_NAME = 'EM_PRELOAD_CACHE'; | |
174 | + var DB_VERSION = 1; | |
175 | + var METADATA_STORE_NAME = 'METADATA'; | |
176 | + var PACKAGE_STORE_NAME = 'PACKAGES'; | |
177 | + function openDatabase(callback, errback) { | |
178 | + try { | |
179 | + var openRequest = indexedDB.open(DB_NAME, DB_VERSION); | |
180 | + } catch (e) { | |
181 | + return errback(e); | |
182 | + } | |
183 | + openRequest.onupgradeneeded = function(event) { | |
184 | + var db = event.target.result; | |
185 | + | |
186 | + if(db.objectStoreNames.contains(PACKAGE_STORE_NAME)) { | |
187 | + db.deleteObjectStore(PACKAGE_STORE_NAME); | |
188 | + } | |
189 | + var packages = db.createObjectStore(PACKAGE_STORE_NAME); | |
190 | + | |
191 | + if(db.objectStoreNames.contains(METADATA_STORE_NAME)) { | |
192 | + db.deleteObjectStore(METADATA_STORE_NAME); | |
193 | + } | |
194 | + var metadata = db.createObjectStore(METADATA_STORE_NAME); | |
195 | + }; | |
196 | + openRequest.onsuccess = function(event) { | |
197 | + var db = event.target.result; | |
198 | + callback(db); | |
199 | + }; | |
200 | + openRequest.onerror = function(error) { | |
201 | + errback(error); | |
202 | + }; | |
203 | + }; | |
204 | + | |
205 | + /* Check if there's a cached package, and if so whether it's the latest available */ | |
206 | + function checkCachedPackage(db, packageName, callback, errback) { | |
207 | + var transaction = db.transaction([METADATA_STORE_NAME], IDB_RO); | |
208 | + var metadata = transaction.objectStore(METADATA_STORE_NAME); | |
209 | + | |
210 | + var getRequest = metadata.get(packageName); | |
211 | + getRequest.onsuccess = function(event) { | |
212 | + var result = event.target.result; | |
213 | + if (!result) { | |
214 | + return callback(false); | |
215 | + } else { | |
216 | + return callback(PACKAGE_UUID === result.uuid); | |
217 | + } | |
218 | + }; | |
219 | + getRequest.onerror = function(error) { | |
220 | + errback(error); | |
221 | + }; | |
222 | + }; | |
223 | + | |
224 | + function fetchCachedPackage(db, packageName, callback, errback) { | |
225 | + var transaction = db.transaction([PACKAGE_STORE_NAME], IDB_RO); | |
226 | + var packages = transaction.objectStore(PACKAGE_STORE_NAME); | |
227 | + | |
228 | + var getRequest = packages.get(packageName); | |
229 | + getRequest.onsuccess = function(event) { | |
230 | + var result = event.target.result; | |
231 | + callback(result); | |
232 | + }; | |
233 | + getRequest.onerror = function(error) { | |
234 | + errback(error); | |
235 | + }; | |
236 | + }; | |
237 | + | |
238 | + function cacheRemotePackage(db, packageName, packageData, packageMeta, callback, errback) { | |
239 | + var transaction = db.transaction([PACKAGE_STORE_NAME, METADATA_STORE_NAME], IDB_RW); | |
240 | + var packages = transaction.objectStore(PACKAGE_STORE_NAME); | |
241 | + var metadata = transaction.objectStore(METADATA_STORE_NAME); | |
242 | + | |
243 | + var putPackageRequest = packages.put(packageData, packageName); | |
244 | + putPackageRequest.onsuccess = function(event) { | |
245 | + var putMetadataRequest = metadata.put(packageMeta, packageName); | |
246 | + putMetadataRequest.onsuccess = function(event) { | |
247 | + callback(packageData); | |
248 | + }; | |
249 | + putMetadataRequest.onerror = function(error) { | |
250 | + errback(error); | |
251 | + }; | |
252 | + }; | |
253 | + putPackageRequest.onerror = function(error) { | |
254 | + errback(error); | |
255 | + }; | |
256 | + }; | |
257 | + | |
258 | + function processPackageData(arrayBuffer) { | |
259 | + Module.finishedDataFileDownloads++; | |
260 | + assert(arrayBuffer, 'Loading data file failed.'); | |
261 | + var byteArray = new Uint8Array(arrayBuffer); | |
262 | + var curr; | |
263 | + | |
264 | + // Reuse the bytearray from the XHR as the source for file reads. | |
265 | + DataRequest.prototype.byteArray = byteArray; | |
266 | + DataRequest.prototype.requests["/mainData"].onload(); | |
267 | + DataRequest.prototype.requests["/methods_pointedto_by_uievents.xml"].onload(); | |
268 | + DataRequest.prototype.requests["/sharedassets0.assets"].onload(); | |
269 | + DataRequest.prototype.requests["/Il2CppData/Metadata/global-metadata.dat"].onload(); | |
270 | + DataRequest.prototype.requests["/Resources/unity_default_resources"].onload(); | |
271 | + DataRequest.prototype.requests["/Resources/unity_builtin_extra"].onload(); | |
272 | + Module['removeRunDependency']('datafile_rnp_webgl_DC_ON_AA0x_VsyncOFF.data'); | |
273 | + | |
274 | + }; | |
275 | + Module['addRunDependency']('datafile_rnp_webgl_DC_ON_AA0x_VsyncOFF.data'); | |
276 | + | |
277 | + if (!Module.preloadResults) Module.preloadResults = {}; | |
278 | + | |
279 | + function preloadFallback(error) { | |
280 | + console.error(error); | |
281 | + console.error('falling back to default preload behavior'); | |
282 | + fetchRemotePackage(REMOTE_PACKAGE_NAME, REMOTE_PACKAGE_SIZE, processPackageData, handleError); | |
283 | + }; | |
284 | + | |
285 | + openDatabase( | |
286 | + function(db) { | |
287 | + checkCachedPackage(db, PACKAGE_PATH + PACKAGE_NAME, | |
288 | + function(useCached) { | |
289 | + Module.preloadResults[PACKAGE_NAME] = {fromCache: useCached}; | |
290 | + if (useCached) { | |
291 | + console.info('loading ' + PACKAGE_NAME + ' from cache'); | |
292 | + fetchCachedPackage(db, PACKAGE_PATH + PACKAGE_NAME, processPackageData, preloadFallback); | |
293 | + } else { | |
294 | + console.info('loading ' + PACKAGE_NAME + ' from remote'); | |
295 | + fetchRemotePackage(REMOTE_PACKAGE_NAME, REMOTE_PACKAGE_SIZE, | |
296 | + function(packageData) { | |
297 | + cacheRemotePackage(db, PACKAGE_PATH + PACKAGE_NAME, packageData, {uuid:PACKAGE_UUID}, processPackageData, | |
298 | + function(error) { | |
299 | + console.error(error); | |
300 | + processPackageData(packageData); | |
301 | + }); | |
302 | + } | |
303 | + , preloadFallback); | |
304 | + } | |
305 | + } | |
306 | + , preloadFallback); | |
307 | + } | |
308 | + , preloadFallback); | |
309 | + | |
310 | + if (Module['setStatus']) Module['setStatus']('Downloading...'); | |
311 | + | |
312 | + } | |
313 | + if (Module['calledRun']) { | |
314 | + runWithFS(); | |
315 | + } else { | |
316 | + if (!Module['preRun']) Module['preRun'] = []; | |
317 | + Module["preRun"].push(runWithFS); // FS is not initialized yet, wait for it | |
318 | + } | |
319 | + | |
320 | + } | |
321 | + loadPackage(); | |
322 | + | |
323 | +})(); | |
324 | +//============== Load ======================== | |
325 | + | |
326 | +if (!(!Math.fround)) { | |
327 | + var script = document.createElement('script'); | |
328 | + script.src = VLibrasPlayer.getPath() + '/Player/WebGL/rnp_webgl_DC_ON_AA0x_VsyncOFF.js'; | |
329 | + document.body.appendChild(script); | |
330 | +} else { | |
331 | + var codeXHR = new XMLHttpRequest(); | |
332 | + codeXHR.open('GET', VLibrasPlayer.getPath() + '/Player/WebGL/rnp_webgl_DC_ON_AA0x_VsyncOFF.js', true); | |
333 | + codeXHR.onload = function() { | |
334 | + var code = codeXHR.responseText; | |
335 | + if (!Math.fround) { | |
336 | +try { | |
337 | + console.log('optimizing out Math.fround calls'); | |
338 | + var m = /var ([^=]+)=global\.Math\.fround;/.exec(code); | |
339 | + var minified = m[1]; | |
340 | + if (!minified) throw 'fail'; | |
341 | + var startAsm = code.indexOf('// EMSCRIPTEN_START_FUNCS'); | |
342 | + var endAsm = code.indexOf('// EMSCRIPTEN_END_FUNCS'); | |
343 | + var asm = code.substring(startAsm, endAsm); | |
344 | + do { | |
345 | + var moar = false; // we need to re-do, as x(x( will not be fixed | |
346 | + asm = asm.replace(new RegExp('[^a-zA-Z0-9\\$\\_]' + minified + '\\(', 'g'), function(s) { moar = true; return s[0] + '(' }); | |
347 | + } while (moar); | |
348 | + code = code.substring(0, startAsm) + asm + code.substring(endAsm); | |
349 | + code = code.replace("'use asm'", "'almost asm'"); | |
350 | +} catch(e) { console.log('failed to optimize out Math.fround calls ' + e) } | |
351 | + } | |
352 | + | |
353 | + var blob = new Blob([code], { type: 'text/javascript' }); | |
354 | + codeXHR = null; | |
355 | + var src = URL.createObjectURL(blob); | |
356 | + var script = document.createElement('script'); | |
357 | + script.src = URL.createObjectURL(blob); | |
358 | + script.onload = function() { | |
359 | + URL.revokeObjectURL(script.src); | |
360 | + }; | |
361 | + document.body.appendChild(script); | |
362 | + }; | |
363 | + codeXHR.send(null); | |
364 | +} | |
0 | 365 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,16 @@ |
1 | +if (!jQuery) { | |
2 | + var script = document.createElement('script'); | |
3 | + | |
4 | + script.src = '//code.jquery.com/jquery-1.11.3.min.js'; | |
5 | + script.onload = function () { | |
6 | + loadUnityObject(); | |
7 | + }; | |
8 | + | |
9 | + document.body.appendChild(script); | |
10 | +} else { | |
11 | + loadUnityObject(); | |
12 | +} | |
13 | + | |
14 | +function loadUnityObject() { | |
15 | + var unityObject={javaInstallDone:function(d,a,b){var c=parseInt(d.substring(d.lastIndexOf("_")+1),10);if(!isNaN(c)){setTimeout(function(){UnityObject2.instances[c].javaInstallDoneCallback(d,a,b)},10)}}};var UnityObject2=function(K){var af=[],i=window,aa=document,Y=navigator,F=null,h=[],ai=(document.location.protocol=="https:"),z=ai?"https://ssl-webplayer.unity3d.com/":"http://webplayer.unity3d.com/",L="_unity_triedjava",H=a(L),r="_unity_triedclickonce",u=a(r),ac=false,C=[],P=false,x=null,f=null,Q=null,l=[],V=null,q=[],X=false,W="installed",M="missing",b="broken",w="unsupported",D="ready",A="start",G="error",ab="first",B="java",s="clickonce",N=false,T=null,y={pluginName:"Unity Player",pluginMimeType:"application/vnd.unity",baseDownloadUrl:z+"download_webplayer-3.x/",fullInstall:false,autoInstall:false,enableJava:true,enableJVMPreloading:false,enableClickOnce:true,enableUnityAnalytics:false,enableGoogleAnalytics:true,enableBrowserDeprecatedWarning:true,params:{},attributes:{},referrer:null,debugLevel:0,pluginVersionChecker:{container:jQuery("body")[0],hide:true,id:"version-checker"}};y=jQuery.extend(true,y,K);if(y.referrer===""){y.referrer=null}if(ai){y.enableUnityAnalytics=false}function a(aj){var ak=new RegExp(escape(aj)+"=([^;]+)");if(ak.test(aa.cookie+";")){ak.exec(aa.cookie+";");return RegExp.$1}return false}function e(aj,ak){document.cookie=escape(aj)+"="+escape(ak)+"; path=/"}function O(ap){var aq=0,al,ao,am,aj,ak;if(ap){var an=ap.toLowerCase().match(/^(\d+)(?:\.(\d+)(?:\.(\d+)([dabfr])?(\d+)?)?)?$/);if(an&&an[1]){al=an[1];ao=an[2]?an[2]:0;am=an[3]?an[3]:0;aj=an[4]?an[4]:"r";ak=an[5]?an[5]:0;aq|=((al/10)%10)<<28;aq|=(al%10)<<24;aq|=(ao%10)<<20;aq|=(am%10)<<16;aq|={d:2<<12,a:4<<12,b:6<<12,f:8<<12,r:8<<12}[aj];aq|=((ak/100)%10)<<8;aq|=((ak/10)%10)<<4;aq|=(ak%10)}}return aq}function ah(an,aj){var al=y.pluginVersionChecker.container;var ak=aa.createElement("object");var am=0;if(al&&ak){ak.setAttribute("type",y.pluginMimeType);ak.setAttribute("id",y.pluginVersionChecker.id);if(y.pluginVersionChecker.hide){ak.style.visibility="hidden"}al.appendChild(ak);(function(){if(typeof ak.GetPluginVersion==="undefined"){setTimeout(arguments.callee,100)}else{var ao={};if(aj){for(am=0;am<aj.length;++am){ao[aj[am]]=ak.GetUnityVersion(aj[am])}}ao.plugin=ak.GetPluginVersion();al.removeChild(ak);an(ao)}})()}else{an(null)}}function c(){var aj="";if(t.x64){aj=y.fullInstall?"UnityWebPlayerFull64.exe":"UnityWebPlayer64.exe"}else{aj=y.fullInstall?"UnityWebPlayerFull.exe":"UnityWebPlayer.exe"}if(y.referrer!==null){aj+="?referrer="+y.referrer}return aj}function ae(){var aj="UnityPlayer.plugin.zip";if(y.referrer!=null){aj+="?referrer="+y.referrer}return aj}function m(){return y.baseDownloadUrl+(t.win?c():ae())}function E(al,ak,am,aj){if(al===M){N=true}if(jQuery.inArray(al,q)===-1){if(N){j.send(al,ak,am,aj)}q.push(al)}V=al}var t=function(){var al=Y.userAgent,an=Y.platform;var ap=/chrome/i.test(al);var ao=false;if(/msie/i.test(al)){ao=parseFloat(al.replace(/^.*msie ([0-9]+(\.[0-9]+)?).*$/i,"$1"))}else{if(/Trident/i.test(al)){ao=parseFloat(al.replace(/^.*rv:([0-9]+(\.[0-9]+)?).*$/i,"$1"))}}var aq={w3:typeof aa.getElementById!="undefined"&&typeof aa.getElementsByTagName!="undefined"&&typeof aa.createElement!="undefined",win:an?/win/i.test(an):/win/i.test(al),mac:an?/mac/i.test(an):/mac/i.test(al),ie:ao,ff:/firefox/i.test(al),op:/opera/i.test(al),ch:ap,ch_v:/chrome/i.test(al)?parseFloat(al.replace(/^.*chrome\/(\d+(\.\d+)?).*$/i,"$1")):false,sf:/safari/i.test(al)&&!ap,wk:/webkit/i.test(al)?parseFloat(al.replace(/^.*webkit\/(\d+(\.\d+)?).*$/i,"$1")):false,x64:/win64/i.test(al)&&/x64/i.test(al),moz:/mozilla/i.test(al)?parseFloat(al.replace(/^.*mozilla\/([0-9]+(\.[0-9]+)?).*$/i,"$1")):0,mobile:/ipad/i.test(an)||/iphone/i.test(an)||/ipod/i.test(an)||/android/i.test(al)||/windows phone/i.test(al)};aq.clientBrand=aq.ch?"ch":aq.ff?"ff":aq.sf?"sf":aq.ie?"ie":aq.op?"op":"??";aq.clientPlatform=aq.win?"win":aq.mac?"mac":"???";var ar=aa.getElementsByTagName("script");for(var aj=0;aj<ar.length;++aj){var am=ar[aj].src.match(/^(.*)3\.0\/uo\/UnityObject2\.js$/i);if(am){y.baseDownloadUrl=am[1];break}}function ak(av,au){for(var aw=0;aw<Math.max(av.length,au.length);++aw){var at=(aw<av.length)&&av[aw]?new Number(av[aw]):0;var ax=(aw<au.length)&&au[aw]?new Number(au[aw]):0;if(at<ax){return -1}if(at>ax){return 1}}return 0}aq.java=function(){if(Y.javaEnabled()){var aw=(aq.win&&aq.ff);var az=false;if(aw||az){if(typeof Y.mimeTypes!="undefined"){var ay=aw?[1,6,0,12]:[1,4,2,0];for(var av=0;av<Y.mimeTypes.length;++av){if(Y.mimeTypes[av].enabledPlugin){var at=Y.mimeTypes[av].type.match(/^application\/x-java-applet;(?:jpi-)?version=(\d+)(?:\.(\d+)(?:\.(\d+)(?:_(\d+))?)?)?$/);if(at!=null){if(ak(ay,at.slice(1))<=0){return true}}}}}}else{if(aq.win&&aq.ie){if(typeof ActiveXObject!="undefined"){function au(aA){try{return new ActiveXObject("JavaWebStart.isInstalled."+aA+".0")!=null}catch(aB){return false}}function ax(aA){try{return new ActiveXObject("JavaPlugin.160_"+aA)!=null}catch(aB){return false}}if(au("1.7.0")){return true}if(aq.ie>=8){if(au("1.6.0")){for(var av=12;av<=50;++av){if(ax(av)){if(aq.ie==9&&aq.moz==5&&av<24){continue}else{return true}}}return false}}else{return au("1.6.0")||au("1.5.0")||au("1.4.2")}}}}}return false}();aq.co=function(){if(aq.win&&aq.ie){var at=al.match(/(\.NET CLR [0-9.]+)|(\.NET[0-9.]+)/g);if(at!=null){var ax=[3,5,0];for(var aw=0;aw<at.length;++aw){var au=at[aw].match(/[0-9.]{2,}/g)[0].split(".");if(ak(ax,au)<=0){return true}}}}return false}();return aq}();var j=function(){var aj=function(){var ar=new Date();var aq=Date.UTC(ar.getUTCFullYear(),ar.getUTCMonth(),ar.getUTCDay(),ar.getUTCHours(),ar.getUTCMinutes(),ar.getUTCSeconds(),ar.getUTCMilliseconds());return aq.toString(16)+ap().toString(16)}();var al=0;var ak=window._gaq=(window._gaq||[]);an();function ap(){return Math.floor(Math.random()*2147483647)}function an(){var aw=("https:"==document.location.protocol?"https://ssl":"http://www")+".google-analytics.com/ga.js";var at=aa.getElementsByTagName("script");var ax=false;for(var av=0;av<at.length;++av){if(at[av].src&&at[av].src.toLowerCase()==aw.toLowerCase()){ax=true;break}}if(!ax){var au=aa.createElement("script");au.type="text/javascript";au.async=true;au.src=aw;var ar=document.getElementsByTagName("script")[0];ar.parentNode.insertBefore(au,ar)}var aq=(y.debugLevel===0)?"UA-16068464-16":"UA-16068464-17";ak.push(["unity._setDomainName","none"]);ak.push(["unity._setAllowLinker",true]);ak.push(["unity._setReferrerOverride"," "+this.location.toString()]);ak.push(["unity._setAccount",aq]);ak.push(["unity._setCustomVar",1,"Revision","e7947df39b5c",2])}function am(av,at,aw,ar){if(!y.enableUnityAnalytics){if(ar){ar()}return}var aq="http://unityanalyticscapture.appspot.com/event?u="+encodeURIComponent(aj)+"&s="+encodeURIComponent(al)+"&e="+encodeURIComponent(av);aq+="&v="+encodeURIComponent("e7947df39b5c");if(y.referrer!==null){aq+="?r="+y.referrer}if(at){aq+="&t="+encodeURIComponent(at)}if(aw){aq+="&d="+encodeURIComponent(aw)}var au=new Image();if(ar){au.onload=au.onerror=ar}au.src=aq}function ao(at,aq,au,aB){if(!y.enableGoogleAnalytics){if(aB){aB()}return}var ay="/webplayer/install/"+at;var az="?";if(aq){ay+=az+"t="+encodeURIComponent(aq);az="&"}if(au){ay+=az+"d="+encodeURIComponent(au);az="&"}if(aB){ak.push(function(){setTimeout(aB,1000)})}var aw=y.src;if(aw.length>40){aw=aw.replace("http://","");var ar=aw.split("/");var aA=ar.shift();var av=ar.pop();aw=aA+"/../"+av;while(aw.length<40&&ar.length>0){var ax=ar.pop();if(aw.length+ax.length+5<40){av=ax+"/"+av}else{av="../"+av}aw=aA+"/../"+av}}ak.push(["unity._setCustomVar",2,"GameURL",aw,3]);ak.push(["unity._setCustomVar",1,"UnityObjectVersion","2",3]);if(aq){ak.push(["unity._setCustomVar",3,"installMethod",aq,3])}ak.push(["unity._trackPageview",ay])}return{send:function(au,at,aw,aq){if(y.enableUnityAnalytics||y.enableGoogleAnalytics){n("Analytics SEND",au,at,aw,aq)}++al;var av=2;var ar=function(){if(0==--av){x=null;window.location=aq}};if(aw===null||aw===undefined){aw=""}am(au,at,aw,aq?ar:null);ao(au,at,aw,aq?ar:null)}}}();function J(al,am,an){var aj,aq,ao,ap,ak;if(t.win&&t.ie){aq="";for(aj in al){aq+=" "+aj+'="'+al[aj]+'"'}ao="";for(aj in am){ao+='<param name="'+aj+'" value="'+am[aj]+'" />'}an.outerHTML="<object"+aq+">"+ao+"</object>"}else{ap=aa.createElement("object");for(aj in al){ap.setAttribute(aj,al[aj])}for(aj in am){ak=aa.createElement("param");ak.name=aj;ak.value=am[aj];ap.appendChild(ak)}an.parentNode.replaceChild(ap,an)}}function o(aj){if(typeof aj=="undefined"){return false}if(!aj.complete){return false}if(typeof aj.naturalWidth!="undefined"&&aj.naturalWidth==0){return false}return true}function I(am){var ak=false;for(var al=0;al<l.length;al++){if(!l[al]){continue}var aj=aa.images[l[al]];if(!o(aj)){ak=true}else{l[al]=null}}if(ak){setTimeout(arguments.callee,100)}else{setTimeout(function(){d(am)},100)}}function d(am){var ao=aa.getElementById(am);if(!ao){ao=aa.createElement("div");var aj=aa.body.lastChild;aa.body.insertBefore(ao,aj.nextSibling)}var an=y.baseDownloadUrl+"3.0/jws/";var ak={id:am,type:"application/x-java-applet",code:"JVMPreloader",width:1,height:1,name:"JVM Preloader"};var al={context:am,codebase:an,classloader_cache:false,scriptable:true,mayscript:true};J(ak,al,ao);jQuery("#"+am).show()}function U(ak){H=true;e(L,H);var am=aa.getElementById(ak);var ao=ak+"_applet_"+F;C[ao]={attributes:y.attributes,params:y.params,callback:y.callback,broken:y.broken};var aq=C[ao];var an={id:ao,type:"application/x-java-applet",archive:y.baseDownloadUrl+"3.0/jws/UnityWebPlayer.jar",code:"UnityWebPlayer",width:1,height:1,name:"Unity Web Player"};if(t.win&&t.ff){an.style="visibility: hidden;"}var ap={context:ao,jnlp_href:y.baseDownloadUrl+"3.0/jws/UnityWebPlayer.jnlp",classloader_cache:false,installer:m(),image:z+"installation/unitylogo.png",centerimage:true,boxborder:false,scriptable:true,mayscript:true};for(var aj in aq.params){if(aj=="src"){continue}if(aq.params[aj]!=Object.prototype[aj]){ap[aj]=aq.params[aj];if(aj.toLowerCase()=="logoimage"){ap.image=aq.params[aj]}else{if(aj.toLowerCase()=="backgroundcolor"){ap.boxbgcolor="#"+aq.params[aj]}else{if(aj.toLowerCase()=="bordercolor"){ap.boxborder=true}else{if(aj.toLowerCase()=="textcolor"){ap.boxfgcolor="#"+aq.params[aj]}}}}}}var al=aa.createElement("div");am.appendChild(al);J(an,ap,al);jQuery("#"+ak).show()}function Z(aj){setTimeout(function(){var ak=aa.getElementById(aj);if(ak){ak.parentNode.removeChild(ak)}},0)}function g(an){var ao=C[an],am=aa.getElementById(an),al;if(!am){return}am.width=ao.attributes.width||600;am.height=ao.attributes.height||450;var ak=am.parentNode;var aj=ak.childNodes;for(var ap=0;ap<aj.length;ap++){al=aj[ap];if(al.nodeType==1&&al!=am){ak.removeChild(al)}}}function k(al,aj,ak){n("_javaInstallDoneCallback",al,aj,ak);if(!aj){E(G,B,ak)}}function ag(){af.push(arguments);if(y.debugLevel>0&&window.console&&window.console.log){console.log(Array.prototype.slice.call(arguments))}}function n(){af.push(arguments);if(y.debugLevel>1&&window.console&&window.console.log){console.log(Array.prototype.slice.call(arguments))}}function p(aj){if(/^[-+]?[0-9]+$/.test(aj)){aj+="px"}return aj}function v(aw,ak){var au=this;var am=M;var an;Y.plugins.refresh();if(t.clientBrand==="??"||t.clientPlatform==="???"||t.mobile){am=w}else{if(t.op&&t.mac){am=w;an="OPERA-MAC"}else{if(typeof Y.plugins!="undefined"&&Y.plugins[y.pluginName]&&typeof Y.mimeTypes!="undefined"&&Y.mimeTypes[y.pluginMimeType]&&Y.mimeTypes[y.pluginMimeType].enabledPlugin){am=W;if(t.sf&&/Mac OS X 10_6/.test(Y.appVersion)){ah(function(ax){if(!ax||!ax.plugin){am=b;an="OSX10.6-SFx64"}aw(am,Q,an,ax)},ak);return}else{if(t.mac&&t.ch){ah(function(ax){if(ax&&(O(ax.plugin)<=O("2.6.1f3"))){am=b;an="OSX-CH-U<=2.6.1f3"}aw(am,Q,an,ax)},ak);return}else{if(ak){ah(function(ax){aw(am,Q,an,ax)},ak);return}}}}else{if(t.ie){var al=false;try{if(ActiveXObject.prototype!=null){al=true}}catch(ap){}if(!al){am=w;an="ActiveXFailed"}else{am=M;try{var av=new ActiveXObject("UnityWebPlayer.UnityWebPlayer.1");var aj=av.GetPluginVersion();if(ak){var aq={};for(var at=0;at<ak.length;++at){aq[ak[at]]=av.GetUnityVersion(ak[at])}aq.plugin=aj}am=W;if(aj=="2.5.0f5"){var ar=/Windows NT \d+\.\d+/.exec(Y.userAgent);if(ar&&ar.length>0){var ao=parseFloat(ar[0].split(" ")[2]);if(ao>=6){am=b;an="WIN-U2.5.0f5"}}}}catch(ap){}}}}}}aw(am,Q,an,aq)}function R(ak,aj){v(function(am,an,ao,al){ak(am,al)},aj)}function ad(ak,aj){v(function(am,an,ao,al){E(am,an,ao);ak(am,al)},aj)}var S={getLogHistory:function(){return af},getConfig:function(){return y},getPlatformInfo:function(){return t},initPlugin:function(aj,al){y.targetEl=aj;y.src=al;n("ua:",t);var ak=this;ad(function(an,am){ak.handlePluginStatus(an,am)})},detectUnity:function(al,aj){var ak=this;R(function(an,am){al.call(ak,an,am)},aj)},handlePluginStatus:function(al,aj){var ak=y.targetEl;var an=jQuery(ak);switch(al){case W:this.notifyProgress(an);this.embedPlugin(an,y.callback);break;case M:this.notifyProgress(an);var am=this;var ao=(y.debugLevel===0)?1000:8000;setTimeout(function(){y.targetEl=ak;am.detectUnity(am.handlePluginStatus)},ao);break;case b:this.notifyProgress(an);break;case w:this.notifyProgress(an);break}},getPluginURL:function(){var aj="http://unity3d.com/webplayer/";if(t.win){aj=y.baseDownloadUrl+c()}else{if(Y.platform=="MacIntel"){aj=y.baseDownloadUrl+(y.fullInstall?"webplayer-i386.dmg":"webplayer-mini.dmg");if(y.referrer!==null){aj+="?referrer="+y.referrer}}else{if(Y.platform=="MacPPC"){aj=y.baseDownloadUrl+(y.fullInstall?"webplayer-ppc.dmg":"webplayer-mini.dmg");if(y.referrer!==null){aj+="?referrer="+y.referrer}}}}return aj},getClickOnceURL:function(){return y.baseDownloadUrl+"3.0/co/UnityWebPlayer.application?installer="+encodeURIComponent(y.baseDownloadUrl+c())},embedPlugin:function(am,aw){am=jQuery(am).empty();var au=y.src;var ak=y.width||"100%";var ap=y.height||"100%";var av=this;if(t.win&&t.ie){var al="";for(var aj in y.attributes){if(y.attributes[aj]!=Object.prototype[aj]){if(aj.toLowerCase()=="styleclass"){al+=' class="'+y.attributes[aj]+'"'}else{if(aj.toLowerCase()!="classid"){al+=" "+aj+'="'+y.attributes[aj]+'"'}}}}var ao="";ao+='<param name="src" value="'+au+'" />';ao+='<param name="firstFrameCallback" value="UnityObject2.instances['+F+'].firstFrameCallback();" />';for(var aj in y.params){if(y.params[aj]!=Object.prototype[aj]){if(aj.toLowerCase()!="classid"){ao+='<param name="'+aj+'" value="'+y.params[aj]+'" />'}}}var ar='<object classid="clsid:444785F1-DE89-4295-863A-D46C3A781394" style="display: block; width: '+p(ak)+"; height: "+p(ap)+';"'+al+">"+ao+"</object>";var aq=jQuery(ar);am.append(aq);h.push(am.attr("id"));T=aq[0]}else{var an=jQuery("<embed/>").attr({src:au,type:y.pluginMimeType,width:ak,height:ap,firstFrameCallback:"UnityObject2.instances["+F+"].firstFrameCallback();"}).attr(y.attributes).attr(y.params).css({display:"block",width:p(ak),height:p(ap)}).appendTo(am);T=an[0]}if(!t.sf||!t.mac){setTimeout(function(){T.focus()},100)}if(aw){aw()}},getBestInstallMethod:function(){var aj="Manual";if(t.x64){return aj}if(y.enableJava&&t.java&&H===false){aj="JavaInstall"}else{if(y.enableClickOnce&&t.co&&u===false){aj="ClickOnceIE"}}return aj},installPlugin:function(ak){if(ak==null||ak==undefined){ak=this.getBestInstallMethod()}var aj=null;switch(ak){case"JavaInstall":this.doJavaInstall(y.targetEl.id);break;case"ClickOnceIE":u=true;e(r,u);var al=jQuery("<iframe src='"+this.getClickOnceURL()+"' style='display:none;' />");jQuery(y.targetEl).append(al);break;default:case"Manual":var al=jQuery("<iframe src='"+this.getPluginURL()+"' style='display:none;' />");jQuery(y.targetEl).append(al);break}Q=ak;j.send(A,ak,null,null)},trigger:function(ak,aj){if(aj){n('trigger("'+ak+'")',aj)}else{n('trigger("'+ak+'")')}jQuery(document).trigger(ak,aj)},notifyProgress:function(am){if(typeof ac!=="undefined"&&typeof ac==="function"){var an={ua:t,pluginStatus:V,bestMethod:null,lastType:Q,targetEl:y.targetEl,unityObj:this};if(V===M){var ao=t.ch&&(t.ch_v>41);if(ao&&y.enableBrowserDeprecatedWarning){an.pluginStatus=w;var al=aa.getElementById("ChromeMissingUnityPlayer");if(!al){var aj=$("<div id='ChromeMissingUnityPlayer'>");aj.css("width","100%").css("height","200px").css("background","#f9f8e6").css("background","rgba(231,228,157,.25)").css("border-color","#fcfbf1").css("border-color","rgba(231,228,157,.15)").css("border-style","solid").css("border-width","5x").css("color","#595959").css("color","rgba(0,0,0,.65)").css("text-align","left").css("padding","10px").appendTo(am);var ak="";if(t.win){ak="<a href='http://windows.microsoft.com/en-us/internet-explorer/'>Internet Explorer</a>, <a href='http://www.mozilla.org/firefox'>Firefox</a> or <a href='http://www.opera.com/'>Opera</a>"}else{ak="<a href='http://www.mozilla.org/firefox'>Firefox</a>, <a href='https://www.apple.com/safari/'>Safari</a>"}var ap="<img src='https://files.unity3d.com/UnityObject2/resources/other_browser.jpg' style='float: left; margin-right: 15px;' /><div style='overflow:hidden;'><div style='height:202px; display:inline-block; vertical-align:middle;'></div><div style='display:inline-block;'><div style='display:inline-block; vertical-align:middle;'><span style='font-weight:bold; font-size: 1.1em;'>Sorry, Chrome can't run this app</span><p>You are using a version of Chrome that does not currently support the Unity Web Player plugin needed to run this app.<br/>We recommend using another browser, such as "+ak+'.<br/>Alternatively, you can enable NPAPI plugins at chrome://flags/#enable-npapi (requires browser relaunch).</p><p>If you enabled the NPAPI flag and the plugin still does not work for you, try <a href="'+this.getPluginURL()+'">manual install</a>.</p></div></div></div>';aj.html(ap)}}else{an.bestMethod=this.getBestInstallMethod()}}if(f!==V){f=V;ac(an)}}},observeProgress:function(aj){ac=aj},firstFrameCallback:function(){n("*** firstFrameCallback ("+F+") ***");V=ab;this.notifyProgress();if(N===true){j.send(V,Q)}},setPluginStatus:function(al,ak,am,aj){E(al,ak,am,aj)},doJavaInstall:function(aj){U(aj)},jvmPreloaded:function(aj){Z(aj)},appletStarted:function(aj){g(aj)},javaInstallDoneCallback:function(al,aj,ak){k(al,aj,ak)},getUnity:function(){return T}};F=UnityObject2.instances.length;UnityObject2.instances.push(S);return S};UnityObject2.instances=[]; | |
16 | +} | |
0 | 17 | \ No newline at end of file | ... | ... |
VLibrasWeb/vlibras-player.js
... | ... | @@ -3,6 +3,7 @@ |
3 | 3 | this.loaded = false; |
4 | 4 | this.glosa = undefined; |
5 | 5 | this.canvas = undefined; |
6 | + this.WebPlayer = undefined; | |
6 | 7 | this.initialized = false; |
7 | 8 | } |
8 | 9 | |
... | ... | @@ -23,16 +24,16 @@ |
23 | 24 | |
24 | 25 | VLibrasPlayer.prototype.play = function () { |
25 | 26 | if (this.glosa !== undefined && this.loaded === true) { |
26 | - window.SendMessage('PlayerManager', 'catchGlosa', this.glosa); | |
27 | + this.sendMessage('PlayerManager', 'catchGlosa', this.glosa); | |
27 | 28 | } |
28 | 29 | }; |
29 | 30 | |
30 | 31 | VLibrasPlayer.prototype.setSpeed = function (speed) { |
31 | - window.SendMessage('PlayerManager', 'setSlider', speed); | |
32 | + this.sendMessage('PlayerManager', 'setSlider', speed); | |
32 | 33 | }; |
33 | 34 | |
34 | 35 | VLibrasPlayer.prototype.switchSubtitle = function () { |
35 | - window.SendMessage('PlayerManager', 'switchSubtitleStatus'); | |
36 | + this.sendMessage('PlayerManager', 'switchSubtitleStatus'); | |
36 | 37 | }; |
37 | 38 | |
38 | 39 | VLibrasPlayer.prototype.addProgressListener = function (callback) { |
... | ... | @@ -75,14 +76,35 @@ |
75 | 76 | this.path = path; |
76 | 77 | |
77 | 78 | var script = document.createElement('script'); |
78 | - script.src = path + '/Player/Release/Setup.js'; | |
79 | - document.body.appendChild(script); | |
79 | + var browser = navigator.appCodeName.toLowerCase(); | |
80 | + | |
81 | + if (browser.indexOf('safari') != -1 || !checkWebGLCompability()) { | |
82 | + script.src = path + '/Player/WebPlayer/Setup.js'; | |
80 | 83 | |
81 | - script.onload = (callback || noop); | |
84 | + script.onload = function () { | |
85 | + this.WebPlayer = new UnityObject2(); | |
86 | + this.WebPlayer.initPlugin(this.canvas, this.path + '/Player/WebPlayer/rnp_webplayer_DC_ON_AA0x_VsyncOFF.unity3d'); | |
82 | 87 | |
88 | + (callback || noop)(); | |
89 | + }; | |
90 | + } else { | |
91 | + script.src = path + '/Player/WebGL/Setup.js'; | |
92 | + | |
93 | + script.onload = (callback || noop); | |
94 | + } | |
95 | + | |
96 | + document.body.appendChild(script); | |
83 | 97 | this.initialized = true; |
84 | 98 | }; |
85 | 99 | |
100 | + VLibrasPlayer.sendMessage = function(object, method, params) { | |
101 | + if (this.WebPlayer) { | |
102 | + this.WebPlayer.getUnity().SendMessage(object, method, params); | |
103 | + } else { | |
104 | + window.SendMessage(object, method, params); | |
105 | + } | |
106 | + }; | |
107 | + | |
86 | 108 | window.onLoadPlayer = function () { |
87 | 109 | this.VLibrasPlayer.load(); |
88 | 110 | }; |
... | ... | @@ -104,4 +126,15 @@ |
104 | 126 | |
105 | 127 | xhr.send(); |
106 | 128 | }; |
129 | + | |
130 | + function checkWebGLCompability() { | |
131 | + var canvas = document.createElement('canvas'); | |
132 | + var gl = canvas.getContext('webgl'); | |
133 | + if (!gl) { | |
134 | + gl = canvas.getContext('experimental-webgl'); | |
135 | + if (!gl) return false; | |
136 | + } | |
137 | + | |
138 | + return true; | |
139 | + }; | |
107 | 140 | })(window, document); |
108 | 141 | \ No newline at end of file | ... | ... |
VLibrasWeb/vlibras-web.css
... | ... | @@ -41,6 +41,7 @@ |
41 | 41 | width: 70px; |
42 | 42 | padding: 5px; |
43 | 43 | text-align: center; |
44 | + background-color: #fff; | |
44 | 45 | |
45 | 46 | -webkit-box-shadow: 0px 0px 9px 0px rgba(0,0,0,0.75); |
46 | 47 | -moz-box-shadow: 0px 0px 9px 0px rgba(0,0,0,0.75); |
... | ... | @@ -49,8 +50,8 @@ |
49 | 50 | |
50 | 51 | .vw-btn-access img { |
51 | 52 | margin-bottom: 5px; |
52 | - width: 70px; | |
53 | - height: 70px; | |
53 | + width: 65px; | |
54 | + height: 65px; | |
54 | 55 | } |
55 | 56 | |
56 | 57 | .vw-btn-access span { |
... | ... | @@ -106,9 +107,13 @@ |
106 | 107 | |
107 | 108 | .vw-player .vw-topbar { |
108 | 109 | padding: 8.5px 10px; |
109 | - height: 20px; | |
110 | + height: 37px; | |
110 | 111 | background-color: #004088; |
111 | 112 | color: #fff; |
113 | + | |
114 | + -webkit-box-sizing: border-box; | |
115 | + -moz-box-sizing: border-box; | |
116 | + box-sizing: border-box; | |
112 | 117 | } |
113 | 118 | |
114 | 119 | .vw-player .vw-btn-close { | ... | ... |