A helper module to display a useful debugging tool during development.
The state needed to render the debug bar. Track this in your Model.
debugBar : (String -> msg) -> NarrativeEngine.Core.WorldModel.WorldModel a -> State -> Html msg
A minimal "debug bar" that you can place at the top or bottom of your screen. Shows the last matched rule id and last interaction id. Includes a search field to search/filter the current world model's state. Entities are displayed in the "entity syntax" described in Syntax.EntityParser
. This makes it easy to search for an entity by ID. You can also search for a tag to show all entities with that tag. You can also find all linked entities in a similar fashion. "." will show all entities. Clear the search field to hide matching entities.
You must include the message that you use to call updateSearch
, which will get triggered on each changed input. Also include the current world model, and current debug state.
Note, if your client responds to key events, you may need to stop propagation on those events from the debug bar. You can do something like this:
div [ stopPropagationOn "keydown" <| Json.succeed ( NoOp, True ) ]
[ Debug.debugBar DebugSeachWorldModelMsg model.worldModel model.debugState ]
init : State
An empty debug state to start off with.
setLastInteractionId : String -> State -> State
Set the last interaction id (call this upon each interaction).
setLastMatchedRuleId : String -> State -> State
Set the last matched rule id (call this upon each interaction, use the interaction id if no rules matched).
updateSearch : String -> State -> State
Call this any time the debug bar's search field changes (ie. the update code for the msg
supplied to debugBar
.