initial framework added
[fp1415-soccerfun.git] / src / Gui / guiInterface.icl
diff --git a/src/Gui/guiInterface.icl b/src/Gui/guiInterface.icl
new file mode 100644 (file)
index 0000000..e6a7dff
--- /dev/null
@@ -0,0 +1,55 @@
+implementation module guiInterface\r
+\r
+import fileIO\r
+import matchGame\r
+\r
+inDir img :== "afbeeldingen\\"+++img+++".bmp"\r
+\r
+getSplashImageForGui :: !*env -> (!GamePicture,!*env) | FileSystem env\r
+getSplashImageForGui env\r
+# pathToSplash         = inDir "AmsterdamArenA"\r
+# (splashImg, env)     = getImage pathToSplash env\r
+= ({img = splashImg, path = pathToSplash},env)\r
+\r
+stepMatchForGui :: !FootballGame !*env -> (![RefereeAction], !FootballGame, !*env) | FileSystem env\r
+stepMatchForGui game env\r
+| timeLeft game\r
+       # ((refEvents,actions),match)   = stepMatch game.match\r
+       # env                                                   = logMatch game.logging match refEvents actions env\r
+       = (refEvents,{game & match=match},env)\r
+| otherwise\r
+       = ([GameOver],game,env)\r
+\r
+getActionPicsForGui :: !Match !*env -> (!ActionPics,!*env) | FileSystem env\r
+getActionPicsForGui match env\r
+# (refereePics,env)    = sseqList (map fillWithPics` match.theReferee.refActionPics) env\r
+= ({refereePics=refereePics},env)\r
+where\r
+       fillWithPics` :: !Path !*env -> (!GamePicture,!*env) | FileSystem env\r
+       fillWithPics` path env\r
+       # (img,env)                     = getImage path env\r
+       = ({img=img, path=path},env)\r
+\r
+instance toString   DisplaySpeed where toString Slowest                = "Slowest"\r
+                                                                               toString Slower                 = "Slower"\r
+                                                                               toString Normal                 = "Normal"\r
+                                                                               toString Faster                 = "Faster"\r
+                                                                               toString Fastest                = "Fastest"\r
+instance fromString DisplaySpeed where fromString "Slowest"    = Slowest\r
+                                                                               fromString "Slower"             = Slower\r
+                                                                               fromString "Normal"             = Normal\r
+                                                                               fromString "Faster"             = Faster\r
+                                                                               fromString "Fastest"    = Fastest\r
+instance ==         DisplaySpeed where == Slowest Slowest              = True\r
+                                                                               == Slower  Slower               = True\r
+                                                                               == Normal  Normal               = True\r
+                                                                               == Faster  Faster               = True\r
+                                                                               == Fastest Fastest              = True\r
+                                                                               == _       _                    = False\r
+\r
+intervalFactor :: !DisplaySpeed -> Real\r
+intervalFactor Slowest         = 1.0 / 0.2     // five times slower\r
+intervalFactor Slower          = 1.0 / 0.5     // two  times slower\r
+intervalFactor Normal          = 1.0           // two  times faster\r
+intervalFactor Faster          = 1.0 / 5.0 // five times faster\r
+intervalFactor Fastest         = zero          // no timer delay\r