LambdaHack-0.11.0.1: A game engine library for tactical squad ASCII roguelike dungeon crawlers

Safe Haskell | None
Language | Haskell2010

Game.LambdaHack.Client.UI.Overlay

Contents

- DisplayFont
- FontSetup
- AttrString
- AttrLine
- Overlay
- Internal operations

Description

Screen overlays.

Synopsis

- data DisplayFont
- isPropFont :: DisplayFont -> Bool
- isSquareFont :: DisplayFont -> Bool
- isMonoFont :: DisplayFont -> Bool
- textSize :: DisplayFont -> [a] -> Int
- data FontSetup = FontSetup {
  - squareFont :: DisplayFont
  - monoFont :: DisplayFont
  - propFont :: DisplayFont
  }
- multiFontSetup :: FontSetup
- singleFontSetup :: FontSetup
- type AttrString = [AttrCharW32]
- blankAttrString :: Int -> AttrString
- textToAS :: Text -> AttrString
- textFgToAS :: Color -> Text -> AttrString
- stringToAS :: String -> AttrString
- attrStringToString :: AttrString -> String
- (<+:>) :: AttrString -> AttrString -> AttrString
- (<\:>) :: AttrString -> AttrString -> AttrString
- data AttrLine
- attrLine :: AttrLine -> AttrString
- emptyAttrLine :: AttrLine
- attrStringToAL :: AttrString -> AttrLine
- firstParagraph :: AttrString -> AttrLine
- textToAL :: Text -> AttrLine
- textFgToAL :: Color -> Text -> AttrLine
- stringToAL :: String -> AttrLine
- linesAttr :: AttrString -> [AttrLine]
- splitAttrString :: Int -> Int -> AttrString -> [AttrLine]
- indentSplitAttrString :: DisplayFont -> Int -> AttrString -> [AttrLine]
- type Overlay = [(PointUI, AttrLine)]
- xytranslateOverlay :: Int -> Int -> Overlay -> Overlay
- xtranslateOverlay :: Int -> Overlay -> Overlay
- ytranslateOverlay :: Int -> Overlay -> Overlay
- offsetOverlay :: [AttrLine] -> Overlay
- offsetOverlayX :: [(Int, AttrLine)] -> Overlay
- typesetXY :: (Int, Int) -> [AttrLine] -> Overlay
- updateLine :: Int -> (Int -> AttrString -> AttrString) -> Overlay -> Overlay
- rectangleOfSpaces :: Int -> Int -> Overlay
- maxYofOverlay :: Overlay -> Int
- labDescOverlay :: DisplayFont -> Int -> AttrString -> (Overlay, Overlay)
- nonbreakableRev :: [String]
- isPrefixOfNonbreakable :: AttrString -> Bool
- breakAtSpace :: AttrString -> (AttrString, AttrString)
- splitAttrPhrase :: Int -> Int -> AttrLine -> [AttrLine]

# DisplayFont

data DisplayFont Source #

Three types of fonts used in the UI. Overlays (layers, more or less) in proportional font are overwritten by layers in square font, which are overwritten by layers in mono font. All overlays overwrite the rendering of the game map, which is the underlying basic UI frame, comprised of square font glyps.

This type needs to be kept abstract to ensure that frontend-enforced or user config-enforced font assignments in `FontSetup` (e.g., stating that the supposedly proportional font is overriden to be the square font) can't be ignored. Otherwise a programmer could use arbirary `DisplayFont`, instead of the one taken from `FontSetup`, and so, e.g., calculating the width of an overlay so constructed in order to decide where another overlay can start would be inconsistent what what font is really eventually used when rendering.

Note that the order of constructors has limited effect, but it illustrates how overwriting is explicitly implemented in frontends that support all fonts.

#### Instances

Instances details

Enum DisplayFont Source # |

Instance details

Defined in Game.LambdaHack.Client.UI.Overlay

Methods

succ :: DisplayFont -> DisplayFont Source #

pred :: DisplayFont -> DisplayFont Source #

toEnum :: Int -> DisplayFont Source #

fromEnum :: DisplayFont -> Int Source #

enumFrom :: DisplayFont -> [DisplayFont] Source #

enumFromThen :: DisplayFont -> DisplayFont -> [DisplayFont] Source #

enumFromTo :: DisplayFont -> DisplayFont -> [DisplayFont] Source #

enumFromThenTo :: DisplayFont -> DisplayFont -> DisplayFont -> [DisplayFont] Source #

Show DisplayFont Source # |
Instance details Defined in Game.LambdaHack.Client.UI.Overlay Methods showsPrec :: Int -> DisplayFont -> ShowS Source # show :: DisplayFont -> String Source # showList :: [DisplayFont] -> ShowS Source #
Eq DisplayFont Source # |
Instance details Defined in Game.LambdaHack.Client.UI.Overlay Methods (==) :: DisplayFont -> DisplayFont -> Bool Source # (/=) :: DisplayFont -> DisplayFont -> Bool Source #

isPropFont :: DisplayFont -> Bool Source #

isSquareFont :: DisplayFont -> Bool Source #

isMonoFont :: DisplayFont -> Bool Source #

textSize :: DisplayFont -> [a] -> Int Source #

# FontSetup

data FontSetup Source #

Constructors

FontSetup |

Fields

- squareFont :: DisplayFont
- monoFont :: DisplayFont
- propFont :: DisplayFont

#### Instances

Instances details

Show FontSetup Source # |
Instance details Defined in Game.LambdaHack.Client.UI.Overlay Methods showsPrec :: Int -> FontSetup -> ShowS Source # show :: FontSetup -> String Source # showList :: [FontSetup] -> ShowS Source #
Eq FontSetup Source # |
Instance details Defined in Game.LambdaHack.Client.UI.Overlay Methods (==) :: FontSetup -> FontSetup -> Bool Source # (/=) :: FontSetup -> FontSetup -> Bool Source #

multiFontSetup :: FontSetup Source #

singleFontSetup :: FontSetup Source #

# AttrString

type AttrString = [AttrCharW32] Source #

String of colourful text. End of line characters permitted.

blankAttrString :: Int -> AttrString Source #

textToAS :: Text -> AttrString Source #

textFgToAS :: Color -> Text -> AttrString Source #

stringToAS :: String -> AttrString Source #

attrStringToString :: AttrString -> String Source #

Transform `AttrString` type to `String`.

(<+:>) :: AttrString -> AttrString -> AttrString infixr 6 Source #

(<\:>) :: AttrString -> AttrString -> AttrString infixr 6 Source #

# AttrLine

data AttrLine Source #

Line of colourful text. End of line characters forbidden. Trailing `White` space forbidden.

#### Instances

Instances details

Show AttrLine Source # |
Instance details Defined in Game.LambdaHack.Client.UI.Overlay Methods showsPrec :: Int -> AttrLine -> ShowS Source # show :: AttrLine -> String Source # showList :: [AttrLine] -> ShowS Source #
Eq AttrLine Source # |
Instance details Defined in Game.LambdaHack.Client.UI.Overlay Methods (==) :: AttrLine -> AttrLine -> Bool Source # (/=) :: AttrLine -> AttrLine -> Bool Source #

attrLine :: AttrLine -> AttrString Source #

emptyAttrLine :: AttrLine Source #

attrStringToAL :: AttrString -> AttrLine Source #

firstParagraph :: AttrString -> AttrLine Source #

textToAL :: Text -> AttrLine Source #

textFgToAL :: Color -> Text -> AttrLine Source #

stringToAL :: String -> AttrLine Source #

linesAttr :: AttrString -> [AttrLine] Source #

splitAttrString :: Int -> Int -> AttrString -> [AttrLine] Source #

Split a string into lines. Avoid breaking the line at a character other than space. Remove the spaces on which lines are broken, keep other spaces. In expensive assertions mode (dev debug mode) fail at trailing spaces, but keep leading spaces, e.g., to make distance from a text in another font. Newlines are respected.

Note that we only split wrt `White` space, nothing else, and the width, in the first argument, is calculated in characters, not in UI (mono font) coordinates, so that taking and dropping characters is performed correctly.

indentSplitAttrString :: DisplayFont -> Int -> AttrString -> [AttrLine] Source #

# Overlay

type Overlay = [(PointUI, AttrLine)] Source #

A series of screen lines with start positions at which they should be overlayed over the base frame or a blank screen, depending on context. The position point is represented as in integer that is an index into the frame character array. The lines either fit the width of the screen or are intended for truncation when displayed. The start positions of lines may fall outside the length of the screen, too, unlike in `SingleFrame`. Then they are simply not shown.

xytranslateOverlay :: Int -> Int -> Overlay -> Overlay Source #

xtranslateOverlay :: Int -> Overlay -> Overlay Source #

ytranslateOverlay :: Int -> Overlay -> Overlay Source #

offsetOverlay :: [AttrLine] -> Overlay Source #

offsetOverlayX :: [(Int, AttrLine)] -> Overlay Source #

typesetXY :: (Int, Int) -> [AttrLine] -> Overlay Source #

updateLine :: Int -> (Int -> AttrString -> AttrString) -> Overlay -> Overlay Source #

rectangleOfSpaces :: Int -> Int -> Overlay Source #

maxYofOverlay :: Overlay -> Int Source #

labDescOverlay :: DisplayFont -> Int -> AttrString -> (Overlay, Overlay) Source #

# Internal operations

nonbreakableRev :: [String] Source #

isPrefixOfNonbreakable :: AttrString -> Bool Source #

breakAtSpace :: AttrString -> (AttrString, AttrString) Source #

splitAttrPhrase :: Int -> Int -> AttrLine -> [AttrLine] Source #