e6a7dffe35c86c8410da8f0036ef2cb9f544da69
[fp1415-soccerfun.git] / src / Gui / guiInterface.icl
1 implementation module guiInterface
2
3 import fileIO
4 import matchGame
5
6 inDir img :== "afbeeldingen\\"+++img+++".bmp"
7
8 getSplashImageForGui :: !*env -> (!GamePicture,!*env) | FileSystem env
9 getSplashImageForGui env
10 # pathToSplash = inDir "AmsterdamArenA"
11 # (splashImg, env) = getImage pathToSplash env
12 = ({img = splashImg, path = pathToSplash},env)
13
14 stepMatchForGui :: !FootballGame !*env -> (![RefereeAction], !FootballGame, !*env) | FileSystem env
15 stepMatchForGui game env
16 | timeLeft game
17 # ((refEvents,actions),match) = stepMatch game.match
18 # env = logMatch game.logging match refEvents actions env
19 = (refEvents,{game & match=match},env)
20 | otherwise
21 = ([GameOver],game,env)
22
23 getActionPicsForGui :: !Match !*env -> (!ActionPics,!*env) | FileSystem env
24 getActionPicsForGui match env
25 # (refereePics,env) = sseqList (map fillWithPics` match.theReferee.refActionPics) env
26 = ({refereePics=refereePics},env)
27 where
28 fillWithPics` :: !Path !*env -> (!GamePicture,!*env) | FileSystem env
29 fillWithPics` path env
30 # (img,env) = getImage path env
31 = ({img=img, path=path},env)
32
33 instance toString DisplaySpeed where toString Slowest = "Slowest"
34 toString Slower = "Slower"
35 toString Normal = "Normal"
36 toString Faster = "Faster"
37 toString Fastest = "Fastest"
38 instance fromString DisplaySpeed where fromString "Slowest" = Slowest
39 fromString "Slower" = Slower
40 fromString "Normal" = Normal
41 fromString "Faster" = Faster
42 fromString "Fastest" = Fastest
43 instance == DisplaySpeed where == Slowest Slowest = True
44 == Slower Slower = True
45 == Normal Normal = True
46 == Faster Faster = True
47 == Fastest Fastest = True
48 == _ _ = False
49
50 intervalFactor :: !DisplaySpeed -> Real
51 intervalFactor Slowest = 1.0 / 0.2 // five times slower
52 intervalFactor Slower = 1.0 / 0.5 // two times slower
53 intervalFactor Normal = 1.0 // two times faster
54 intervalFactor Faster = 1.0 / 5.0 // five times faster
55 intervalFactor Fastest = zero // no timer delay