LambdaHack- A game engine library for roguelike dungeon crawlers

Safe HaskellNone



Game messages displayed on top of the screen for the player to read.



makePhrase :: [Part] -> Text Source

Re-exported English phrase creation functions, applied to default irregular word sets.

makeSentence :: [Part] -> Text Source

Re-exported English phrase creation functions, applied to default irregular word sets.

type Msg = Text Source

The type of a single message.

(<>) :: Monoid m => m -> m -> m infixr 6

An infix synonym for mappend.


(<+>) :: Text -> Text -> Text infixr 6 Source

tshow :: Show a => a -> Text Source

moreMsg :: Msg Source

The "press something to see more" mark.

endMsg :: Msg Source

The "end of screenfuls of text" mark.

yesnoMsg :: Msg Source

The confirmation request message.

truncateMsg :: X -> Text -> Text Source

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.

data Report Source

The type of a set of messages to show at the screen at once.


emptyReport :: Report Source

Empty set of messages.

nullReport :: Report -> Bool Source

Test if the set of messages is empty.

singletonReport :: Msg -> Report Source

Construct a singleton set of messages.

addMsg :: Report -> Msg -> Report Source

Add message to the end of report.

splitReport :: X -> Report -> Overlay Source

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 Source

Render a report as a (possibly very long) string.

data History Source

The history of reports. This is a ring buffer of the given length

emptyHistory :: Int -> History Source

Empty history of reports of the given maximal length.

addReport :: History -> Time -> Report -> History Source

Add a report to history, handling repetitions.

renderHistory :: History -> Overlay Source

Render history as many lines of text, wrapping if necessary.

data Overlay Source

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.

data Slideshow Source

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. If the first pair element is not Nothing, the overlay is displayed over a blank screen, including the bottom lines. The boolean flag then indicates whether to start at the topmost screenful or bottommost.

splitOverlay :: Maybe Bool -> Y -> Overlay -> Overlay -> Slideshow Source

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 be too wide).

toSlideshow :: Maybe Bool -> [[Text]] -> Slideshow Source

Declare the list of raw 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.

splitText :: X -> Text -> [Text] Source

Split a string into lines. Avoids ending the line with a character other than whitespace or punctuation. Space characters are removed from the start, but never from the end of lines. Newlines are respected.