License | BSD-3-Clause |
---|---|
Safe Haskell | None |
Language | Haskell2010 |
Swarm.Game.Display
Description
Utilities for describing how to display in-game entities in the TUI.
Synopsis
- type Priority = Int
- data Attribute
- readAttribute :: Text -> Attribute
- data Display
- data ChildInheritance
- defaultChar :: Lens' Display Char
- orientationMap :: Lens' Display (Map AbsoluteDir Char)
- curOrientation :: Lens' Display (Maybe Direction)
- boundaryOverride :: Lens' Display (Maybe Char)
- displayAttr :: Lens' Display Attribute
- displayPriority :: Lens' Display Priority
- invisible :: Lens' Display Bool
- childInheritance :: Lens' Display ChildInheritance
- displayChar :: Display -> Char
- hidden :: Display -> Display
- getBoundaryDisplay :: (AbsoluteDir -> Bool) -> Maybe Char
- defaultTerrainDisplay :: Attribute -> Display
- defaultEntityDisplay :: Char -> Display
- defaultRobotDisplay :: Display
The display record
Display priority. Entities with higher priority will be drawn on top of entities with lower priority.
An internal attribute name.
Instances
readAttribute :: Text -> Attribute Source #
A record explaining how to display an entity in the TUI.
Instances
FromJSON Display Source # | |||||
Defined in Swarm.Game.Display | |||||
ToJSON Display Source # | |||||
Monoid Display Source # | |||||
Semigroup Display Source # | |||||
Generic Display Source # | |||||
Defined in Swarm.Game.Display Associated Types
| |||||
Show Display Source # | |||||
Eq Display Source # | |||||
Ord Display Source # | |||||
Hashable Display Source # | |||||
Defined in Swarm.Game.Display | |||||
FromJSONE Display Display Source # | |||||
Defined in Swarm.Game.Display Methods parseJSONE :: Value -> ParserE Display Display parseJSONE' :: Display -> Value -> Parser Display | |||||
type Rep Display Source # | |||||
Defined in Swarm.Game.Display type Rep Display = D1 ('MetaData "Display" "Swarm.Game.Display" "swarm-0.7.0.0-IuFfgHrMoE7JrptOBRVOwx-swarm-scenario" 'False) (C1 ('MetaCons "Display" 'PrefixI 'True) (((S1 ('MetaSel ('Just "_defaultChar") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Char) :*: S1 ('MetaSel ('Just "_orientationMap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Map AbsoluteDir Char))) :*: (S1 ('MetaSel ('Just "_curOrientation") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Direction)) :*: S1 ('MetaSel ('Just "_boundaryOverride") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Char)))) :*: ((S1 ('MetaSel ('Just "_displayAttr") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Attribute) :*: S1 ('MetaSel ('Just "_displayPriority") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Priority)) :*: (S1 ('MetaSel ('Just "_invisible") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Bool) :*: S1 ('MetaSel ('Just "_childInheritance") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ChildInheritance))))) |
data ChildInheritance Source #
Constructors
Invisible | |
Inherit | |
DefaultDisplay |
Instances
Generic ChildInheritance Source # | |||||
Defined in Swarm.Game.Display Associated Types
Methods from :: ChildInheritance -> Rep ChildInheritance x # to :: Rep ChildInheritance x -> ChildInheritance # | |||||
Show ChildInheritance Source # | |||||
Defined in Swarm.Game.Display Methods showsPrec :: Int -> ChildInheritance -> ShowS # show :: ChildInheritance -> String # showList :: [ChildInheritance] -> ShowS # | |||||
Eq ChildInheritance Source # | |||||
Defined in Swarm.Game.Display Methods (==) :: ChildInheritance -> ChildInheritance -> Bool # (/=) :: ChildInheritance -> ChildInheritance -> Bool # | |||||
Ord ChildInheritance Source # | |||||
Defined in Swarm.Game.Display Methods compare :: ChildInheritance -> ChildInheritance -> Ordering # (<) :: ChildInheritance -> ChildInheritance -> Bool # (<=) :: ChildInheritance -> ChildInheritance -> Bool # (>) :: ChildInheritance -> ChildInheritance -> Bool # (>=) :: ChildInheritance -> ChildInheritance -> Bool # max :: ChildInheritance -> ChildInheritance -> ChildInheritance # min :: ChildInheritance -> ChildInheritance -> ChildInheritance # | |||||
Hashable ChildInheritance Source # | |||||
Defined in Swarm.Game.Display | |||||
type Rep ChildInheritance Source # | |||||
Defined in Swarm.Game.Display type Rep ChildInheritance = D1 ('MetaData "ChildInheritance" "Swarm.Game.Display" "swarm-0.7.0.0-IuFfgHrMoE7JrptOBRVOwx-swarm-scenario" 'False) (C1 ('MetaCons "Invisible" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Inherit" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DefaultDisplay" 'PrefixI 'False) (U1 :: Type -> Type))) |
Fields
orientationMap :: Lens' Display (Map AbsoluteDir Char) Source #
For robots or other entities that have an orientation, this map
optionally associates different display characters with
different orientations. If an orientation is not in the map,
the defaultChar
will be used.
curOrientation :: Lens' Display (Maybe Direction) Source #
The display caches the current orientation of the entity, so we know which character to use from the orientation map.
boundaryOverride :: Lens' Display (Maybe Char) Source #
The display character to substitute when neighbor boundaries are present
displayPriority :: Lens' Display Priority Source #
This entity's display priority. Higher priorities are drawn on top of lower.
childInheritance :: Lens' Display ChildInheritance Source #
For robots, whether children of this inherit the parent's display
Rendering
displayChar :: Display -> Char Source #
Look up the character that should be used for a display.
Modify a display to use a ?
character for entities that are
hidden/unknown.
Neighbor-based boundary rendering
Construction
defaultTerrainDisplay :: Attribute -> Display Source #
The default way to display some terrain using the given character and attribute, with priority 0.
defaultEntityDisplay :: Char -> Display Source #
Construct a default display for an entity that uses only a single display character, the default entity attribute, and priority 1.
defaultRobotDisplay :: Display Source #
Construct a default robot display for a given orientation, with
display characters "X^>v<"
, the default robot attribute, and
priority 10.
Note that the defaultChar
is used for direction DDown
and is overridden for the special base robot.