{-# LANGUAGE TemplateHaskell #-}
module Client.UI.Content.Screen
( standardLayoutAndFeatures
) where
import Prelude ()
import Game.LambdaHack.Core.Prelude
import qualified Data.EnumMap.Strict as EM
import Data.FileEmbed (embedDir)
import Language.Haskell.TH.Syntax
import System.IO
import Game.LambdaHack.Client.UI.Content.Screen
standardLayoutAndFeatures :: ScreenContent
standardLayoutAndFeatures :: ScreenContent
standardLayoutAndFeatures = $WScreenContent :: X
-> X
-> X
-> String
-> ([String], [[String]])
-> EnumMap Char Text
-> [(String, ByteString)]
-> ScreenContent
ScreenContent
{ rwidth :: X
rwidth = 80
, rheight :: X
rheight = 45
, rwrap :: X
rwrap = 53
, rwebAddress :: String
rwebAddress = "http://allureofthestars.com"
, rintroScreen :: ([String], [[String]])
rintroScreen = $(do
let path = "GameDefinition/PLAYING.md"
qAddDependentFile path
x <- qRunIO $ do
handle <- openFile path ReadMode
hSetEncoding handle utf8
hGetContents handle
let paragraphs :: [String] -> [String] -> [[String]]
paragraphs [] rows = [reverse rows]
paragraphs (l@"" : ls) rows = case (rows, ls) of
(('=':'=' : _) : _, _) ->
paragraphs ls (l : rows)
(('-':'-' : _) : _, _) ->
paragraphs ls (l : rows)
((' ':' ':' ':' ' : _) : _, (' ':' ':' ':' ' : _) : _) ->
paragraphs ls (l : rows)
_ -> reverse rows : paragraphs ls []
paragraphs (l : ls) rows = paragraphs ls (l : rows)
intro = case paragraphs (lines x) [] of
_titleAndBlurb : par1 : par2 : par3 : rest ->
(par1 ++ [""] ++ par2 ++ [""] ++ par3, rest)
_ -> error "not enough paragraphs in intro screen text"
lift intro)
, rapplyVerbMap :: EnumMap Char Text
rapplyVerbMap =
[(Char, Text)] -> EnumMap Char Text
forall k a. Enum k => [(k, a)] -> EnumMap k a
EM.fromList [('!', "imbibe"), (',', "eat"), ('?', "activate")]
, rFontFiles :: [(String, ByteString)]
rFontFiles =
#ifdef USE_JSFILE
[]
#else
$(embedDir "GameDefinition/fonts")
#endif
}