Safe Haskell | None |
---|
Game messages displayed on top of the screen for the player to read.
- makePhrase :: [Part] -> Text
- makeSentence :: [Part] -> Text
- type Msg = Text
- (<>) :: Text -> Text -> Text
- (<+>) :: Text -> Text -> Text
- showT :: Show a => a -> Text
- moreMsg :: Msg
- yesnoMsg :: Msg
- truncateMsg :: X -> Text -> Text
- data Report
- emptyReport :: Report
- nullReport :: Report -> Bool
- singletonReport :: Msg -> Report
- addMsg :: Report -> Msg -> Report
- splitReport :: Report -> [Text]
- renderReport :: Report -> Text
- findInReport :: (ByteString -> Bool) -> Report -> Maybe ByteString
- data History
- emptyHistory :: History
- singletonHistory :: Report -> History
- mergeHistory :: [(Msg, History)] -> History
- addReport :: Report -> History -> History
- renderHistory :: History -> Overlay
- takeHistory :: Int -> History -> History
- type Overlay = [Text]
- stringByLocation :: X -> Y -> Overlay -> (Text, PointXY -> Maybe Char, Maybe Text)
- data Slideshow
- splitOverlay :: Y -> Overlay -> Overlay -> Slideshow
- toSlideshow :: [Overlay] -> Slideshow
Documentation
makePhrase :: [Part] -> Text
Re-exported English phrase creation functions, applied to default irregular word sets.
makeSentence :: [Part] -> Text
Re-exported English phrase creation functions, applied to default irregular word sets.
type Msg = Text
The type of a single message.
(<>) :: Text -> Text -> Text
(<+>) :: Text -> Text -> Text
truncateMsg :: X -> Text -> Text
Add a space at the message end, for display overlayed over the level map. Also trims (does not wrap!) too long lines. In case of newlines, displays only the first line, but marks the message as partial.
Empty set of messages.
nullReport :: Report -> Bool
Test if the set of messages is empty.
singletonReport :: Msg -> Report
Construct a singleton set of messages.
splitReport :: Report -> [Text]
Split a messages into chunks that fit in one line. We assume the width of the messages line is the same as of level map.
renderReport :: Report -> Text
Render a report as a (possibly very long) string.
findInReport :: (ByteString -> Bool) -> Report -> Maybe ByteString
Empty history of reports.
singletonHistory :: Report -> History
Construct a singleton history of reports.
mergeHistory :: [(Msg, History)] -> History
renderHistory :: History -> Overlay
Render history as many lines of text, wrapping if necessary.
takeHistory :: Int -> History -> History
Take the given prefix of reports from a history.
type Overlay = [Text]
A series of screen lines that may or may not fit the width nor height of the screen. An overlay may be transformed by adding the first line and/or by splitting into a slideshow of smaller overlays.
stringByLocation :: X -> Y -> Overlay -> (Text, PointXY -> Maybe Char, Maybe Text)
Returns a function that looks up the characters in the string by position. Takes the width and height of the display plus the string. Returns also the message to print at the top and bottom.
data Slideshow
A few overlays, displayed one by one upon keypress. When displayed, they are trimmed, not wrapped and any lines below the lower screen edge are not visible.
splitOverlay :: Y -> Overlay -> Overlay -> Slideshow
Split an overlay into a slideshow in which each overlay,
prefixed by msg
and postfixed by moreMsg
except for the last one,
fits on the screen wrt height (but lines may still be too wide).
toSlideshow :: [Overlay] -> Slideshow
Declare the list of overlays to be fit for display on the screen.
In particular, current Report
is eiter empty or unimportant
or contained in the overlays and if any vertical or horizontal
trimming of the overlays happens, this is intended.