Permalink
Browse files

- Little steps.

- SDL Window created.
  • Loading branch information...
graninas committed Jan 30, 2014
1 parent 63364a1 commit faab4926bdf8741490aed196c47cd3ec84b46910
View
@@ -53,7 +53,10 @@ library
Middleware.Config.Scheme,
View.Color,
View.Config,
- View.View
+ View.View,
+ Main,
+ View.Language,
+ View.SdlFacade
executable Amoeba
build-depends: base >= 4
@@ -77,4 +80,7 @@ executable Amoeba
Middleware.Config.Scheme,
Middleware.Config.Facade,
View.View,
- View.Config
+ View.Config,
+ Main,
+ View.Language,
+ View.SdlFacade
View
@@ -1,13 +1,13 @@
-module Main where
+module Amoeba where
import Middleware.Config.Facade
import Application.Boot
optionsFile = "./Data/Options.cfg"
-main::IO ()
-main = do
+run::IO ()
+run = do
cfg <- loadConfiguration optionsFile
putStrLn $ getOption cfg appName
View
@@ -1,11 +1,23 @@
module Application.Boot where
+import Application.Environment
import View.Config
+import View.View
import Middleware.Config.Facade
+loadViewSettings cfg = do
+ screen <- extract cfg screenInfo
+ caption <- extract cfg captionInfo
+ print screen
+ print caption
+ return (screen, caption)
+
boot cfg = do
+ (screen, caption) <- loadViewSettings cfg
+ withEnvironment $ do
+ view <- setupScreen screen caption
+ putStrLn "Loaded."
+ getLine
+ putStrLn "Unloaded."
- viewCfg <- getConfig cfg viewConfig'
-
-
- print viewCfg
+
View
@@ -0,0 +1,6 @@
+module Main where
+
+import Amoeba
+
+
+main = run
@@ -31,7 +31,6 @@ option cfg = do
return $ getOption cp cfg
intOption = option :: CfgReader Int
-stringOption = option :: CfgReader String
+strOption = option :: CfgReader String
-getConfig cp loader = return $ R.runReader loader cp
-
+extract cp loader = return $ R.runReader loader cp
@@ -1,4 +1,4 @@
module Middleware.Config.Facade (module X) where
import Data.Either.Utils as X (forceEither)
-import Middleware.Config.Config as X ( getOption, loadConfiguration, intOption, stringOption, getConfig)
+import Middleware.Config.Config as X (getOption, loadConfiguration, intOption, strOption, extract)
import Middleware.Config.Scheme as X
@@ -7,6 +7,6 @@ appName = deflt <| opt "applicationName"
video = sect "VIDEO"
-screenWidth = video <| opt "screenWidth"
+screenWidth = video <| opt "screenWidth"
screenHeight = video <| opt "screenHeight"
-colorDepth = video <| opt "colorDepth"
+colorDepth = video <| opt "colorDepth"
View
@@ -1,20 +1,17 @@
module View.Config where
-import Middleware.Config.Facade
-import Control.Monad
-
-data Screen = Screen { width :: Int
- , height :: Int
- , depth :: Int
- }
- deriving (Show, Read, Eq)
+import View.Language
+import Middleware.Config.Facade
+import Control.Monad (liftM3)
-viewConfig = do
+screenInfo = do
sw <- intOption screenWidth
sh <- intOption screenHeight
cd <- intOption colorDepth
return $ Screen sw sh cd
+captionInfo = strOption appName
+
i = intOption
viewConfig' = liftM3 Screen (i screenWidth) (i screenHeight) (i colorDepth)
View
@@ -0,0 +1,8 @@
+module View.Language where
+
+data Screen = Screen { width :: Int
+ , height :: Int
+ , depth :: Int }
+ deriving (Show, Read, Eq)
+
+
View
@@ -0,0 +1,6 @@
+module View.SdlFacade (module SDL) where
+
+import Graphics.UI.SDL as SDL
+import Graphics.UI.SDL.Video as SDL
+import Graphics.UI.SDL.Types as SDL
+
View
@@ -1,24 +1,16 @@
module View.View where
-import qualified Graphics.UI.SDL.Video as SDL
-import qualified Graphics.UI.SDL.Types as SDL
+import View.Language
+import qualified View.SdlFacade as SDL
data View = View { viewSurface :: SDL.Surface
, viewScreen :: Screen }
-
-getView :: IO View
-getView = do
- surface <- SDL.getVideoSurface
- vInfo <- SDL.getVideoInfo
- let w = SDL.videoInfoWidth vInfo
- let h = SDL.videoInfoHeight vInfo
- return $ View surface (Screen w h)
-setupScreen :: (Screen, Int) -> String -> IO View
-setupScreen (scr@(Screen scrWidth scrHeight), scrBpp) caption = do
- surface <- SDL.setVideoMode scrWidth scrHeight scrBpp [SDL.SWSurface]
+setupScreen :: Screen -> String -> IO View
+setupScreen scr@(Screen w h bpp) caption = do
+ surface <- SDL.setVideoMode w h bpp [SDL.SWSurface]
SDL.setCaption caption []
SDL.flip surface
return $ View surface scr
View
Binary file not shown.
View
@@ -4,7 +4,7 @@ set -e
echo "Building..."
cd Amoeba
-ghc -threaded --make -outputdir ../.bin -o ../.bin/Amoeba Amoeba.hs
+ghc -threaded --make -outputdir ../.bin -o ../.bin/Amoeba Main.hs
cd ..
set +e
View
@@ -1,14 +0,0 @@
-#!/bin/bash
-
-set -e
-
-echo "Building..."
-cd Amoeba
-ghc -threaded --make -outputdir ../.bin -o ../.bin/Amoeba Amoeba.hs
-cd ..
-
-set +e
-
-echo "Copying..."
-rm -f ./Game/Amoeba
-cp ./.bin/Amoeba ./Game/
View
@@ -6,13 +6,4 @@ echo "Cleaning..."
rm -fr "./.bin/*"
-echo "Building..."
-cd Amoeba
-ghc -threaded --make -outputdir ../.bin -o ../.bin/Amoeba Amoeba.hs
-cd ..
-
-set +e
-
-echo "Copying..."
-rm -f "./Game/Amoeba"
-cp "./.bin/Amoeba" "./Game/"
+./build.sh
View
@@ -1,18 +0,0 @@
-#!/bin/bash
-
-set -e
-
-echo "Cleaning..."
-
-rm -fr "./.bin/*"
-
-echo "Building..."
-cd Amoeba
-ghc -threaded --make -outputdir ../.bin -o ../.bin/Amoeba Amoeba.hs
-cd ..
-
-set +e
-
-echo "Copying..."
-rm -f ./Game/Amoeba
-cp ./.bin/Amoeba ./Game/

0 comments on commit faab492

Please sign in to comment.