changeset 7:66d8fd6a64e8

Browser compatibility check.
author Mikhail Kryshen <mikhail@kryshen.net>
date Wed, 23 Mar 2016 21:34:08 +0300
parents 11c20013e0e5
children b32efce2d860
files src/Serpentron.st
diffstat 1 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/Serpentron.st	Thu Feb 18 01:35:45 2016 +0300
+++ b/src/Serpentron.st	Wed Mar 23 21:34:08 2016 +0300
@@ -319,6 +319,12 @@
 !Serpentron methodsFor: 'rendering'!
 
 augmentPage
+	Serpentron isCompatibleBrowser ifFalse: [
+		'#serpentron' asSilk resetContents
+			<< 'Your browser is not supported.'
+			<< Silk BR
+			<< 'Please use a modern browser to run the game.'.
+		^ self ].
 	'#serpentron' asSilk resetContents << 'Loading...'.
 	skin
 		load: 'resources/skin.png'
@@ -362,6 +368,15 @@
 
 Serpentron class instanceVariableNames: 'Instance'!
 
+!Serpentron class methodsFor: 'compatibility'!
+
+isCompatibleBrowser
+	"No reason to polyfill requestAnimationFrame
+	 or use vendor prefixes as browsers that do not have it
+	 will likely have other incompatibilities."
+	< return window.requestAnimationFrame && true || false >
+! !
+
 !Serpentron class methodsFor: 'starting'!
 
 start